query
stringlengths
7
3.85k
document
stringlengths
11
430k
metadata
dict
negatives
sequencelengths
0
101
negative_scores
sequencelengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
SetBytes records the number of bytes processed in a single operation. If this is called, the benchmark will report ns/op and MB/s.
func (b *B) SetBytes(n int64) {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (b *B) SetBytes(n int64)", "func (mr *MockUnsignedTxMockRecorder) SetBytes(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"SetBytes\", reflect.TypeOf((*MockUnsignedTx)(nil).SetBytes), arg0)\n}", "func SetBytes(z *big.Int, buf []byte) *big.Int {\n\treturn z.SetBytes(buf)\n}", "func (s *Disk) SetBytes(v int64) *Disk {\n\ts.Bytes = &v\n\treturn s\n}", "func (a *api) SetBytes(raw bool) {\n\ta.Commentf(\"%s constructs a field element from bytes in big-endian order.\", rawname(\"SetBytes\", raw))\n\ta.rawcomment(raw)\n\ta.Printf(\"func (x %s) %s(b []byte) %s\", a.PointerType(), rawname(\"SetBytes\", raw), a.PointerType())\n\ta.EnterBlock()\n\ta.Linef(\"x.%s(new(big.Int).SetBytes(b))\", rawname(\"SetInt\", raw))\n\ta.Linef(\"return x\")\n\ta.LeaveBlock()\n}", "func MemBytes(m int64) optionSetter {\n\treturn func(o *options) error {\n\t\tif m < 0 {\n\t\t\treturn fmt.Errorf(\"memBytes should be >= 0\")\n\t\t}\n\t\to.memBytes = m\n\t\treturn nil\n\t}\n}", "func (m *MockUnsignedTx) SetBytes(arg0 []byte) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"SetBytes\", arg0)\n}", "func (r *RedisResult) SetBytes(b []byte) {\n\tr.resultType = BYTES\n\tr.resultBytes = b\n}", "func (m *Main) AddBytes(n int) {\n\tm.bytesLock.Lock()\n\tm.totalBytes += int64(n)\n\tm.bytesLock.Unlock()\n}", "func (z *Int) SetBytes(buf []byte) *Int {\n\tvar d uint64\n\tk := 0\n\ts := uint64(0)\n\ti := len(buf)\n\tz[0], z[1], z[2], z[3] = 0, 0, 0, 0\n\tfor ; i > 0; i-- {\n\t\td |= uint64(buf[i-1]) << s\n\t\tif s += 8; s == 64 {\n\t\t\tz[k] = d\n\t\t\tk++\n\t\t\ts, d = 0, 0\n\t\t\tif k >= len(z) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tif k < len(z) {\n\t\tz[k] = d\n\t}\n\t//fmt.Printf(\"z %v \\n\", z.Hex())\n\treturn z\n}", "func (s *ConnStats) incOutputBytes(n int) {\n\ts.totalOutputBytes.Inc(uint64(n))\n}", "func (z nat) setBytes(buf []byte) nat {\n\tz = z.make((len(buf) + _S - 1) / _S)\n\n\tk := 0\n\ts := uint(0)\n\tvar d Word\n\tfor i := len(buf); i > 0; i-- {\n\t\td |= Word(buf[i-1]) << s\n\t\tif s += 8; s == _S*8 {\n\t\t\tz[k] = d\n\t\t\tk++\n\t\t\ts = 0\n\t\t\td = 0\n\t\t}\n\t}\n\tif k < len(z) {\n\t\tz[k] = d\n\t}\n\n\treturn z.norm()\n}", "func (s *ConnStats) incOutputBytes(n int) {\n\ts.totalOutputBytes.Add(uint64(n))\n}", "func (fs *FakeStats) TimedIncrementBytes(b int, d time.Duration) {\n\tfs.mutex.Lock()\n\tdefer fs.mutex.Unlock()\n\tfs.TimedIncrementBytesCalls = append(fs.TimedIncrementBytesCalls, struct {\n\t\tBytes int\n\t\tDuration time.Duration\n\t}{b, d})\n}", "func (c *Cache) SizeBytes() int {\n\tn := 0\n\tfor _, shard := range c.shards {\n\t\tn += shard.SizeBytes()\n\t}\n\treturn n\n}", "func (sc *simpleLRUStatsCache) SetBytesLimit(BytesLimit int64) {\n\tsc.mu.Lock()\n\tdefer sc.mu.Unlock()\n\tsc.memTracker.SetBytesLimit(BytesLimit)\n\tsc.memCapacity = BytesLimit\n}", "func (s *SeriesIDSet) Bytes() int {\n\tvar b int\n\ts.RLock()\n\tb += 24 // mu RWMutex is 24 bytes\n\tb += int(unsafe.Sizeof(s.bitmap)) + int(s.bitmap.GetSizeInBytes())\n\ts.RUnlock()\n\treturn b\n}", "func BenchmarkSet(b *testing.B) {\n\tbenchmarkCommand(b, \"SET\", \"foo\", \"bar\")\n}", "func (h *Hash) SetBytes(b []byte) {\n\tif len(*h) == len(b) {\n\t\tcopy(h[:], b[:HashSize])\n\t}\n}", "func (this *Stats) SentBytes() int { return int(this.ptr.i_sent_bytes) }", "func UpdateProgress(bytes int64) {\n\tmutex.Lock()\n\t// increment the bytes\n\tcurrentBytes += bytes\n\t// set the current ingest speed\n\telapsedSec := int64(duration().Seconds())\n\tif elapsedSec > 0 {\n\t\tbytesPerSec = currentBytes / elapsedSec\n\t}\n\tmutex.Unlock()\n\truntime.Gosched()\n}", "func (h *Hash) SetBytes(b []byte) {\n\tif len(b) > len(h) {\n\t\tb = b[len(b)-HashLength:]\n\t}\n\n\tcopy(h[HashLength-len(b):], b)\n}", "func (h *Hash) SetBytes(b []byte) {\n\tif len(b) > len(h) {\n\t\tb = b[len(b)-HashLength:]\n\t}\n\n\tcopy(h[HashLength-len(b):], b)\n}", "func (h *Hash) SetBytes(b []byte) {\n\tif len(b) > len(h) {\n\t\tb = b[len(b)-HashLength:]\n\t}\n\n\tcopy(h[HashLength-len(b):], b)\n}", "func (h *Hash20) SetBytes(b []byte) {\n\tif len(b) > len(h) {\n\t\tb = b[len(b)-32:]\n\t}\n\n\tcopy(h[32-len(b):], b)\n}", "func (n *Uint256) SetBytes(b *[32]byte) *Uint256 {\n\t// Pack the 256 total bits across the 4 uint64 words. This could be done\n\t// with a for loop, but benchmarks show this unrolled version is about 2\n\t// times faster than the variant that uses a loop.\n\tn.n[0] = uint64(b[31]) | uint64(b[30])<<8 | uint64(b[29])<<16 |\n\t\tuint64(b[28])<<24 | uint64(b[27])<<32 | uint64(b[26])<<40 |\n\t\tuint64(b[25])<<48 | uint64(b[24])<<56\n\tn.n[1] = uint64(b[23]) | uint64(b[22])<<8 | uint64(b[21])<<16 |\n\t\tuint64(b[20])<<24 | uint64(b[19])<<32 | uint64(b[18])<<40 |\n\t\tuint64(b[17])<<48 | uint64(b[16])<<56\n\tn.n[2] = uint64(b[15]) | uint64(b[14])<<8 | uint64(b[13])<<16 |\n\t\tuint64(b[12])<<24 | uint64(b[11])<<32 | uint64(b[10])<<40 |\n\t\tuint64(b[9])<<48 | uint64(b[8])<<56\n\tn.n[3] = uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 |\n\t\tuint64(b[4])<<24 | uint64(b[3])<<32 | uint64(b[2])<<40 |\n\t\tuint64(b[1])<<48 | uint64(b[0])<<56\n\treturn n\n}", "func IntSetBytes(z *big.Int, buf []byte) *big.Int", "func (r *RawData) SetBytes(b []byte) {\n\tr.Data = &b\n}", "func (h *Key) SetBytes(b []byte) {\n\tif len(b) > len(h) {\n\t\tb = b[len(b)-COMMONLEN:]\n\t}\n\tcopy(h[COMMONLEN-len(b):], b)\n}", "func (p *ProgressMeter) TransferBytes(direction, name string, read, total int64, current int) {\n\tatomic.AddInt64(&p.currentBytes, int64(current))\n\tp.logBytes(direction, name, read, total)\n}", "func (p *ProgressMeter) TransferBytes(direction, name string, read, total int64, current int) {\n\tatomic.AddInt64(&p.currentBytes, int64(current))\n\tp.logBytes(direction, name, read, total)\n}", "func (n *NodeManager) IncreaseBytes(node OsqueryNode, incBytes int) error {\n\tif err := n.DB.Model(&node).Update(\"bytes_received\", node.BytesReceived+incBytes).Error; err != nil {\n\t\treturn fmt.Errorf(\"Update bytes_received - %v\", err)\n\t}\n\treturn nil\n}", "func (h *Hash32) SetBytes(b []byte) {\n\tif len(b) > len(h) {\n\t\tb = b[len(b)-32:]\n\t}\n\n\tcopy(h[32-len(b):], b)\n}", "func (r BenchmarkResult) AllocedBytesPerOp() int64 {}", "func (s *Sign) SetBytes(b []byte) {\n\tif len(b) > len(s) {\n\t\tb = b[len(b)-SignLength:]\n\t}\n\tcopy(s[SignLength-len(b):], b)\n}", "func (p *CompressedEdwardsY) SetBytes(in []byte) (*CompressedEdwardsY, error) {\n\tif len(in) != CompressedPointSize {\n\t\treturn nil, fmt.Errorf(\"curve/edwards: unexpected input size\")\n\t}\n\n\tcopy(p[:], in)\n\n\treturn p, nil\n}", "func CountBytes(b []byte) (int, error) {\n\tvar count int\n\tfor len(b) >= 8 {\n\t\tv := binary.BigEndian.Uint64(b[:8])\n\t\tb = b[8:]\n\n\t\tsel := v >> 60\n\t\tif sel >= 16 {\n\t\t\treturn 0, fmt.Errorf(\"invalid selector value: %v\", sel)\n\t\t}\n\t\tcount += selector[sel].n\n\t}\n\n\tif len(b) > 0 {\n\t\treturn 0, fmt.Errorf(\"invalid slice len remaining: %v\", len(b))\n\t}\n\treturn count, nil\n}", "func Bytes(s uint64) string {\n\tsizes := []string{\"B\", \"kB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\"}\n\treturn humanateBytes(s, 1024, sizes)\n}", "func Bytes(s int64) string {\n\tsizes := []string{\"B\", \"K\", \"M\", \"G\", \"T\", \"P\", \"E\"}\n\treturn humanateBytes(s, 1000, sizes)\n}", "func (c ByteMapCache) Set(key string, newBytes []byte, stats *tc.CRConfigStats) {\n\tc.m.Lock()\n\tdefer c.m.Unlock()\n\t(*c.cache)[key] = ByteTime{bytes: newBytes, stats: stats, time: time.Now()}\n}", "func (mm *BytesMonitor) SetMetrics(curCount *metric.Gauge, maxHist *metric.Histogram) {\n\tmm.mu.Lock()\n\tdefer mm.mu.Unlock()\n\tmm.mu.curBytesCount = curCount\n\tmm.mu.maxBytesHist = maxHist\n}", "func (s *OutputStats) Bytes() int64 {\n\treturn atomic.LoadInt64(&s.bytes)\n}", "func (f *ServiceFlags) SetBytes(x []byte) {\n\tvar b [4]byte\n\tcopy(b[:], x)\n\t*f = ServiceFlags(*(*uint32)(unsafe.Pointer(&b)))\n}", "func (mr *MockPostForkBlockMockRecorder) Bytes() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Bytes\", reflect.TypeOf((*MockPostForkBlock)(nil).Bytes))\n}", "func (m *mSignatureKeyHolderMockFixedByteSize) Set(f func() (r int)) *SignatureKeyHolderMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.FixedByteSizeFunc = f\n\treturn m.mock\n}", "func (r *Receiver) countBytes(length uint64, update bool) error {\n\tif length > MaxTransfer {\n\t\treturn fmt.Errorf(\"file too large, %d\", length)\n\t}\n\tif r.byteLimit != 0 && r.totalBytes > uint64(r.byteLimit)-length {\n\t\treturn fmt.Errorf(\"file too large, %d\", length)\n\t}\n\tif update {\n\t\tr.totalBytes += length\n\t}\n\treturn nil\n}", "func (f *FunctionSelector) SetBytes(b []byte) { copy(f[:], b[:FunctionSelectorLength]) }", "func BytesSize(bytes float64, format string, prec int) string {\n\n\tif bytes <= 0 {\n\t\treturn \"0\"\n\t}\n\n\t// Default format is decimal: MB, GB\n\tvalue := 1000.0\n\tresFormat := \"\"\n\n\t// Binary format: MiB, GiB\n\tif format == \"binary\" {\n\t\tvalue = 1024.0\n\t\tresFormat = \"i\"\n\t}\n\n\tif bytes < value {\n\t\tstrRes := strconv.FormatFloat(bytes, 'f', prec, 64)\n\t\treturn strings.TrimSuffix(strRes, \".0\") + \"B\"\n\t}\n\n\tdivider, exp := value, 0\n\tfor n := bytes / value; n >= value; n /= value {\n\t\tdivider *= value\n\t\texp++\n\t}\n\n\tstrRes := strconv.FormatFloat(bytes/divider, 'f', prec, 64)\n\tif prec == 0 {\n\t\t\tstrRes = strings.TrimSuffix(strRes, \".0\")\n\t}\n\n\treturn strRes + fmt.Sprintf(\"%c%sB\", \"KMGTPE\"[exp], resFormat)\n}", "func ByteCount(b int64) string {\n\tconst unit = 1000\n\tif b < unit {\n\t\treturn fmt.Sprintf(\"%d B\", b)\n\t}\n\tdiv, exp := int64(unit), 0\n\tfor n := b / unit; n >= unit; n /= unit {\n\t\tdiv *= unit\n\t\texp++\n\t}\n\treturn fmt.Sprintf(\"%.1f %cB\",\n\t\tfloat64(b)/float64(div), \"kMGTPE\"[exp])\n}", "func (hash *Hash) SetBytes(newHash []byte) error {\n\tif len(newHash) != HashSize {\n\t\treturn errors.Errorf(\"invalid hash length got %d, expected %d\", len(newHash),\n\t\t\tHashSize)\n\t}\n\tcopy(hash[:], newHash)\n\treturn nil\n}", "func BenchmarkSET(b *testing.B) {\n\tdb := setUp()\n\tb.ResetTimer()\n\n\t// run the SET method b.N times\n\tfor n := 0; n < b.N; n++ {\n\t\tdb.SET(\"key\", \"value\")\n\t}\n}", "func (s *serverMetricsRecorder) SetMemoryUtilization(val float64) {\n\tif val < 0 || val > 1 {\n\t\tif logger.V(2) {\n\t\t\tlogger.Infof(\"Ignoring Memory Utilization value out of range: %v\", val)\n\t\t}\n\t\treturn\n\t}\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\ts.state.MemUtilization = val\n}", "func (m *Memtable) SizeBytes() int64 {\n\tm.mu.Lock()\n\tdefer m.mu.Unlock()\n\treturn m.size\n}", "func (m *MockMempool) TxsBytes() int64 {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"TxsBytes\")\n\tret0, _ := ret[0].(int64)\n\treturn ret0\n}", "func main() {\n\tfmt.Printf(\"1 KB = %d bytes\\n\", KB)\n\tfmt.Printf(\"1 MB = %d | KB = %d bytes\\n\", MB/KB, MB)\n\tfmt.Printf(\"1 GB = %d | MB = %d | KB = %d bytes\\n\", GB/MB, GB/KB, GB)\n\tfmt.Printf(\"1 TB = %d | GB = %d | MB = %d | KB = %d bytes\\n\", TB/GB, TB/MB, TB/KB, TB)\n}", "func hostSetBytes(objId int32, keyId int32, typeId int32, value *byte, size int32)", "func Bytes(s uint64) string {\n\treturn humanateBytes(s, 1000, nameSizes, 1, nil)\n}", "func (f *WriteRequest) ByteCount() int {\n\treturn 1 + len(f.Data)\n}", "func (_m *MockOStream) WriteBytes(bytes []byte) {\n\t_m.ctrl.Call(_m, \"WriteBytes\", bytes)\n}", "func (id *Identity) SetBytes(b []byte) {\n\tif len(b) > len(id) {\n\t\tb = b[len(b)-IdentityLength:]\n\t}\n\tcopy(id[IdentityLength-len(b):], b)\n}", "func (c *connCounter) SetInBytesCounter(u *atomic.Uint64) {\n\tif u == nil {\n\t\treturn\n\t}\n\tc.inBytesCounter = u\n}", "func (m *memStats) fmtBytes(b uint64) string {\n\tvar (\n\t\tkb uint64 = 1024\n\t\tmb uint64 = kb * 1024\n\t\tgb uint64 = mb * 1024\n\t)\n\tif b < kb {\n\t\treturn fmt.Sprintf(\"%dB\", b)\n\t}\n\tif b < mb {\n\t\treturn fmt.Sprintf(\"%dKB\", b/kb)\n\t}\n\tif b < gb {\n\t\treturn fmt.Sprintf(\"%dMB\", b/mb)\n\t}\n\treturn fmt.Sprintf(\"%dGB\", b/gb)\n}", "func (hash *Hash) SetBytes(newHash []byte) error {\n\tnhlen := len(newHash)\n\tif nhlen != HashSize {\n\t\treturn fmt.Errorf(\"invalid hash length of %v, want %v\", nhlen,\n\t\t\tHashSize)\n\t}\n\tcopy(hash[:], newHash)\n\n\treturn nil\n}", "func (hash *Hash) SetBytes(newHash []byte) error {\n\tnhlen := len(newHash)\n\tif nhlen != HashSize {\n\t\treturn fmt.Errorf(\"invalid hash length of %v, want %v\", nhlen,\n\t\t\tHashSize)\n\t}\n\tcopy(hash[:], newHash)\n\n\treturn nil\n}", "func (m *Metric) Set(val float64) {\n\tm.Value = apiresource.NewMilliQuantity(\n\t\tint64(val*1000), apiresource.DecimalSI)\n}", "func (p *PointAffine) SetBytes(buf []byte) (int, error) {\n\n\tif len(buf) < sizePointCompressed {\n\t\treturn 0, io.ErrShortBuffer\n\t}\n\tbufCopy := make([]byte, sizePointCompressed)\n\tsubtle.ConstantTimeCopy(1, bufCopy, buf[:sizePointCompressed])\n\tfor i, j := 0, sizePointCompressed-1; i < j; i, j = i+1, j-1 {\n\t\tbufCopy[i], bufCopy[j] = bufCopy[j], bufCopy[i]\n\t}\n\tisLexicographicallyLargest := (mCompressedNegative&bufCopy[0])>>7 == 1\n\tbufCopy[0] &= mUnmask\n\tp.Y.SetBytes(bufCopy)\n\tp.X = computeX(&p.Y)\n\tif isLexicographicallyLargest {\n\t\tif !p.X.LexicographicallyLargest() {\n\t\t\tp.X.Neg(&p.X)\n\t\t}\n\t} else {\n\t\tif p.X.LexicographicallyLargest() {\n\t\t\tp.X.Neg(&p.X)\n\t\t}\n\t}\n\n\treturn sizePointCompressed, nil\n}", "func formatBytes(i int64) (result string) {\n\tswitch {\n\tcase i > (1024 * 1024 * 1024 * 1024):\n\t\tresult = fmt.Sprintf(\"%.02f TB\", float64(i)/1024/1024/1024/1024)\n\tcase i > (1024 * 1024 * 1024):\n\t\tresult = fmt.Sprintf(\"%.02f GB\", float64(i)/1024/1024/1024)\n\tcase i > (1024 * 1024):\n\t\tresult = fmt.Sprintf(\"%.02f MB\", float64(i)/1024/1024)\n\tcase i > 1024:\n\t\tresult = fmt.Sprintf(\"%.02f KB\", float64(i)/1024)\n\tdefault:\n\t\tresult = fmt.Sprintf(\"%d B\", i)\n\t}\n\tresult = strings.Trim(result, \" \")\n\treturn\n}", "func formatBytes(i int64) (result string) {\n\tswitch {\n\tcase i > (1024 * 1024 * 1024 * 1024):\n\t\tresult = fmt.Sprintf(\"%.02f TB\", float64(i)/1024/1024/1024/1024)\n\tcase i > (1024 * 1024 * 1024):\n\t\tresult = fmt.Sprintf(\"%.02f GB\", float64(i)/1024/1024/1024)\n\tcase i > (1024 * 1024):\n\t\tresult = fmt.Sprintf(\"%.02f MB\", float64(i)/1024/1024)\n\tcase i > 1024:\n\t\tresult = fmt.Sprintf(\"%.02f KB\", float64(i)/1024)\n\tdefault:\n\t\tresult = fmt.Sprintf(\"%d B\", i)\n\t}\n\tresult = strings.Trim(result, \" \")\n\treturn\n}", "func (o BackupOutput) SizeBytes() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Backup) pulumi.StringOutput { return v.SizeBytes }).(pulumi.StringOutput)\n}", "func (ms MVCCStats) GCBytes() int64 {\n\treturn ms.KeyBytes + ms.ValBytes - ms.LiveBytes\n}", "func (mmAsBytes *mDigestHolderMockAsBytes) Set(f func() (ba1 []byte)) *DigestHolderMock {\n\tif mmAsBytes.defaultExpectation != nil {\n\t\tmmAsBytes.mock.t.Fatalf(\"Default expectation is already set for the DigestHolder.AsBytes method\")\n\t}\n\n\tif len(mmAsBytes.expectations) > 0 {\n\t\tmmAsBytes.mock.t.Fatalf(\"Some expectations are already set for the DigestHolder.AsBytes method\")\n\t}\n\n\tmmAsBytes.mock.funcAsBytes = f\n\treturn mmAsBytes.mock\n}", "func PutBytes(buf *[]byte) {\n\tbbPool.give(buf)\n}", "func (a *Address) SetBytes(b []byte) {\n\tif len(b) > len(a) {\n\t\tb = b[len(b)-AddressLength:]\n\t}\n\tcopy(a[AddressLength-len(b):], b)\n}", "func (a *Address) SetBytes(b []byte) {\n\tif len(b) > len(a) {\n\t\tb = b[len(b)-AddressLength:]\n\t}\n\tcopy(a[AddressLength-len(b):], b)\n}", "func (a *Address) SetBytes(b []byte) {\n\tif len(b) > len(a) {\n\t\tb = b[len(b)-AddressLength:]\n\t}\n\tcopy(a[AddressLength-len(b):], b)\n}", "func (a *Address) SetBytes(b []byte) {\n\tif len(b) > len(a) {\n\t\tb = b[len(b)-AddressLength:]\n\t}\n\tcopy(a[AddressLength-len(b):], b)\n}", "func FormatBytes(i int64) (result string) {\n\tswitch {\n\tcase i > (1024 * 1024 * 1024 * 1024):\n\t\tresult = fmt.Sprintf(\"%#.02f TB\", float64(i)/1024/1024/1024/1024)\n\tcase i > (1024 * 1024 * 1024):\n\t\tresult = fmt.Sprintf(\"%#.02f GB\", float64(i)/1024/1024/1024)\n\tcase i > (1024 * 1024):\n\t\tresult = fmt.Sprintf(\"%#.02f MB\", float64(i)/1024/1024)\n\tcase i > 1024:\n\t\tresult = fmt.Sprintf(\"%#.02f KB\", float64(i)/1024)\n\tdefault:\n\t\tresult = fmt.Sprintf(\"%d B\", i)\n\t}\n\tresult = strings.Trim(result, \" \")\n\treturn\n}", "func FormatBytes(i int64) (result string) {\n\tswitch {\n\tcase i > (1024 * 1024 * 1024 * 1024):\n\t\tresult = fmt.Sprintf(\"%#.02f TB\", float64(i)/1024/1024/1024/1024)\n\tcase i > (1024 * 1024 * 1024):\n\t\tresult = fmt.Sprintf(\"%#.02f GB\", float64(i)/1024/1024/1024)\n\tcase i > (1024 * 1024):\n\t\tresult = fmt.Sprintf(\"%#.02f MB\", float64(i)/1024/1024)\n\tcase i > 1024:\n\t\tresult = fmt.Sprintf(\"%#.02f KB\", float64(i)/1024)\n\tdefault:\n\t\tresult = fmt.Sprintf(\"%d B\", i)\n\t}\n\tresult = strings.Trim(result, \" \")\n\treturn\n}", "func SnapshotDatasetShardSizeBytes(value int64) SnapshotDatasetAttr {\n\treturn func(m optionalAttr) {\n\t\tm[\"shard_size_bytes\"] = value\n\t}\n}", "func (a *Address) SetBytes(b []byte) {\n\tif len(b) > len(a) {\n\t\tb = b[len(b)-AddressLength:]\n\t}\n\n\tcopy(a[AddressLength-len(b):], b)\n}", "func (s Size) Kibibytes() float64 { return float64(s) / float64(Kibibyte) }", "func (mc *MockCluster) UpdateStorageWrittenBytes(storeID uint64, BytesWritten uint64) {\n\tstore := mc.GetStore(storeID)\n\tstore.Stats.BytesWritten = BytesWritten\n\tnow := time.Now().Second()\n\tinterval := &pdpb.TimeInterval{StartTimestamp: uint64(now - storeHeartBeatReportInterval), EndTimestamp: uint64(now)}\n\tstore.Stats.Interval = interval\n\tmc.PutStore(store)\n}", "func (m *MockScheduler) SetClassLoadPercents(classLoads map[string]int32) error {\n\tret := m.ctrl.Call(m, \"SetClassLoadPercents\", classLoads)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (hash *Sha) SetBytes(newHash []byte) error {\n\tnhlen := len(newHash)\n\tif nhlen != ShaSize {\n\t\treturn fmt.Errorf(\"invalid sha length of %v, want %v\", nhlen,\n\t\t\tShaSize)\n\t}\n\tcopy(hash[:], newHash)\n\n\treturn nil\n}", "func (m *logMeasurement) bytes() int {\n\tvar b int\n\tb += len(m.name)\n\tfor k, v := range m.tagSet {\n\t\tb += len(k)\n\t\tb += v.bytes()\n\t}\n\tb += (int(m.cardinality()) * 8)\n\tb += int(unsafe.Sizeof(*m))\n\treturn b\n}", "func (d *Download) TotalBytes() int {\r\n\treturn d.max\r\n}", "func (p *PublicKey) SetBytes(b []byte) {\n\tif len(b) > len(p) {\n\t\tb = b[len(b)-PublicKeyLength:]\n\t}\n\n\tcopy(p[PublicKeyLength-len(b):], b)\n}", "func (m *MockStreamFlowController) AddBytesSent(arg0 protocol.ByteCount) {\n\tm.ctrl.Call(m, \"AddBytesSent\", arg0)\n}", "func (c *cache) Set(k string, x []byte, d time.Duration) {\n\tatomic.AddInt32(&c.Statistic.SetCount, 1)\n\tatomic.AddInt32(&c.Statistic.ItemsCount, 1)\n\tatomic.AddInt32(&c.Statistic.Size, int32(len(x)))\n\tc.set(k, x, d)\n}", "func DiskSizeBytes(disk string) uint64 {\n\tmsg := `\nThe DiskSizeBytes() function has been DEPRECATED and will be\nremoved in the 1.0 release of ghw. Please use the Disk.SizeBytes attribute.\n`\n\twarn(msg)\n\tctx := contextFromEnv()\n\treturn ctx.diskSizeBytes(disk)\n}", "func WithBytes(buf []byte) (Counter, error) {\n\tversion := buf[0]\n\tif version != Version {\n\t\treturn Counter{}, ErrIncompatibleVersion\n\t}\n\n\tp := buf[1]\n\tbits, err := bitbucket.WithBytes(buf[2:])\n\tif err != nil {\n\t\treturn Counter{}, err\n\t}\n\n\tc := Counter{\n\t\tp: p,\n\t\tbits: bits,\n\t}\n\tc.initParams()\n\treturn c, nil\n}", "func (s Size) Terabytes() float64 { return float64(s) / float64(Terabyte) }", "func (m *MockPostForkBlock) Bytes() []byte {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Bytes\")\n\tret0, _ := ret[0].([]byte)\n\treturn ret0\n}", "func (mm *BytesMonitor) releaseBytes(ctx context.Context, sz int64) {\n\tmm.mu.Lock()\n\tdefer mm.mu.Unlock()\n\n\tmm.mu.curAllocated -= sz\n\tif mm.mu.curBytesCount != nil {\n\t\tmm.mu.curBytesCount.Dec(sz)\n\t}\n\tmm.adjustBudget(ctx)\n\n}", "func (br *BandwidthMeter) Write(p []byte) (int, error) {\n // Always completes and never returns an error.\n br.lastRead = time.Now().UTC()\n n := len(p)\n br.bytesRead += uint64(n)\n if br.start.IsZero() {\n br.start = br.lastRead\n }\n\n return n, nil\n}", "func (*Client) BytesWritten() uint64 {\n\tbytesWritten.Write(m)\n\treturn uint64(*m.Counter.Value)\n}", "func (mr *MockValueMockRecorder) Bytes() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Bytes\", reflect.TypeOf((*MockValue)(nil).Bytes))\n}", "func (s Size) Mebibytes() float64 { return float64(s) / float64(Mebibyte) }", "func Benchmark_5_0_1kB(b *testing.B) { benchmarkNoFaults(6, 1024, b) }", "func (m metrics) WriteBytes() prometheus.Counter {\n\treturn m.writeBytes\n}" ]
[ "0.6600146", "0.60165143", "0.5987008", "0.5880965", "0.57906413", "0.57371676", "0.57300454", "0.5614308", "0.5451881", "0.5433504", "0.54001087", "0.53871846", "0.53859985", "0.53717464", "0.53510094", "0.5333213", "0.5298324", "0.5295165", "0.5218187", "0.5207804", "0.5195761", "0.5158128", "0.5158128", "0.5158128", "0.51578224", "0.51508796", "0.51422995", "0.5116726", "0.51031923", "0.5083838", "0.5083838", "0.50735563", "0.507254", "0.5030285", "0.50297356", "0.50288063", "0.50199276", "0.501763", "0.49965322", "0.49774683", "0.49708715", "0.49668622", "0.4966654", "0.49514586", "0.4946221", "0.49427292", "0.49405214", "0.49201027", "0.49099913", "0.4908588", "0.49064437", "0.49006668", "0.48910168", "0.48867315", "0.4880517", "0.48662663", "0.48653442", "0.48615927", "0.48443383", "0.48365468", "0.48221567", "0.48186627", "0.48093346", "0.48093346", "0.480451", "0.4798935", "0.47909832", "0.4789738", "0.47892198", "0.47840738", "0.47791237", "0.4778377", "0.47674054", "0.47674054", "0.47674054", "0.47674054", "0.47645208", "0.47645208", "0.47555584", "0.47453922", "0.47368157", "0.4736192", "0.47321796", "0.4718551", "0.47116286", "0.4709886", "0.4703612", "0.47028282", "0.4682796", "0.46780595", "0.46563414", "0.46521473", "0.46479174", "0.4639435", "0.46360683", "0.46328342", "0.46265513", "0.46260956", "0.46225825", "0.46211103" ]
0.675753
0
ReportAllocs enables malloc statistics for this benchmark. It is equivalent to setting test.benchmem, but it only affects the benchmark function that calls ReportAllocs.
func (b *B) ReportAllocs() {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (b *B) ReportAllocs()", "func allocs(c echo.Context) error {\n\tpprof.Handler(\"allocs\").ServeHTTP(c.Response(), c.Request())\n\treturn nil\n}", "func Report(c context.Context) {\n\tvar stats runtime.MemStats\n\truntime.ReadMemStats(&stats)\n\n\tMemAlloc.Set(c, int64(stats.Alloc))\n\tMemTotalAlloc.Set(c, int64(stats.TotalAlloc))\n\tMemMallocs.Set(c, int64(stats.Mallocs))\n\tMemFrees.Set(c, int64(stats.Frees))\n\tMemNextGC.Set(c, int64(stats.NextGC))\n\tMemNumGC.Set(c, int64(stats.NumGC))\n\tMemPauseTotal.Set(c, int64(stats.PauseTotalNs/1000))\n\tMemHeapSys.Set(c, int64(stats.HeapSys))\n\tMemHeapIdle.Set(c, int64(stats.HeapIdle))\n\tMemHeapInuse.Set(c, int64(stats.HeapInuse))\n\tMemHeapObjects.Set(c, int64(stats.HeapObjects))\n\tMemStackInuse.Set(c, int64(stats.StackInuse))\n\tMemStackSys.Set(c, int64(stats.StackSys))\n\tMemMSpanInuse.Set(c, int64(stats.MSpanInuse))\n\tMemMSpanSys.Set(c, int64(stats.MSpanSys))\n\tMemMCacheInuse.Set(c, int64(stats.MCacheInuse))\n\tMemMCacheSys.Set(c, int64(stats.MCacheSys))\n\n\tGoroutineNum.Set(c, int64(runtime.NumGoroutine()))\n}", "func memAlloc(v unsafe.Pointer, n uintptr) unsafe.Pointer {\n\trequiredPages := uint64(round(n, _PAGESIZE) / _PAGESIZE)\n\n\treturn _atman_mm.allocPages(v, requiredPages)\n}", "func BenchmarkMemTool(b *testing.B) {\n\tvar blk [4096]byte\n\tb.ReportAllocs()\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tClear(unsafe.Pointer(&blk), 4096)\n\t}\n}", "func TestPallocBitsAlloc(t *testing.T) {\n\ttests := map[string]struct {\n\t\tbefore []BitRange\n\t\tafter []BitRange\n\t\tnpages uintptr\n\t\thits []uint\n\t}{\n\t\t\"AllFree1\": {\n\t\t\tnpages: 1,\n\t\t\thits: []uint{0, 1, 2, 3, 4, 5},\n\t\t\tafter: []BitRange{{0, 6}},\n\t\t},\n\t\t\"AllFree2\": {\n\t\t\tnpages: 2,\n\t\t\thits: []uint{0, 2, 4, 6, 8, 10},\n\t\t\tafter: []BitRange{{0, 12}},\n\t\t},\n\t\t\"AllFree5\": {\n\t\t\tnpages: 5,\n\t\t\thits: []uint{0, 5, 10, 15, 20},\n\t\t\tafter: []BitRange{{0, 25}},\n\t\t},\n\t\t\"AllFree64\": {\n\t\t\tnpages: 64,\n\t\t\thits: []uint{0, 64, 128},\n\t\t\tafter: []BitRange{{0, 192}},\n\t\t},\n\t\t\"AllFree65\": {\n\t\t\tnpages: 65,\n\t\t\thits: []uint{0, 65, 130},\n\t\t\tafter: []BitRange{{0, 195}},\n\t\t},\n\t\t\"SomeFree64\": {\n\t\t\tbefore: []BitRange{{0, 32}, {64, 32}, {100, PallocChunkPages - 100}},\n\t\t\tnpages: 64,\n\t\t\thits: []uint{^uint(0)},\n\t\t\tafter: []BitRange{{0, 32}, {64, 32}, {100, PallocChunkPages - 100}},\n\t\t},\n\t\t\"NoneFree1\": {\n\t\t\tbefore: []BitRange{{0, PallocChunkPages}},\n\t\t\tnpages: 1,\n\t\t\thits: []uint{^uint(0), ^uint(0)},\n\t\t\tafter: []BitRange{{0, PallocChunkPages}},\n\t\t},\n\t\t\"NoneFree2\": {\n\t\t\tbefore: []BitRange{{0, PallocChunkPages}},\n\t\t\tnpages: 2,\n\t\t\thits: []uint{^uint(0), ^uint(0)},\n\t\t\tafter: []BitRange{{0, PallocChunkPages}},\n\t\t},\n\t\t\"NoneFree5\": {\n\t\t\tbefore: []BitRange{{0, PallocChunkPages}},\n\t\t\tnpages: 5,\n\t\t\thits: []uint{^uint(0), ^uint(0)},\n\t\t\tafter: []BitRange{{0, PallocChunkPages}},\n\t\t},\n\t\t\"NoneFree65\": {\n\t\t\tbefore: []BitRange{{0, PallocChunkPages}},\n\t\t\tnpages: 65,\n\t\t\thits: []uint{^uint(0), ^uint(0)},\n\t\t\tafter: []BitRange{{0, PallocChunkPages}},\n\t\t},\n\t\t\"ExactFit1\": {\n\t\t\tbefore: []BitRange{{0, PallocChunkPages/2 - 3}, {PallocChunkPages/2 - 2, PallocChunkPages/2 + 2}},\n\t\t\tnpages: 1,\n\t\t\thits: []uint{PallocChunkPages/2 - 3, ^uint(0)},\n\t\t\tafter: []BitRange{{0, PallocChunkPages}},\n\t\t},\n\t\t\"ExactFit2\": {\n\t\t\tbefore: []BitRange{{0, PallocChunkPages/2 - 3}, {PallocChunkPages/2 - 1, PallocChunkPages/2 + 1}},\n\t\t\tnpages: 2,\n\t\t\thits: []uint{PallocChunkPages/2 - 3, ^uint(0)},\n\t\t\tafter: []BitRange{{0, PallocChunkPages}},\n\t\t},\n\t\t\"ExactFit5\": {\n\t\t\tbefore: []BitRange{{0, PallocChunkPages/2 - 3}, {PallocChunkPages/2 + 2, PallocChunkPages/2 - 2}},\n\t\t\tnpages: 5,\n\t\t\thits: []uint{PallocChunkPages/2 - 3, ^uint(0)},\n\t\t\tafter: []BitRange{{0, PallocChunkPages}},\n\t\t},\n\t\t\"ExactFit65\": {\n\t\t\tbefore: []BitRange{{0, PallocChunkPages/2 - 31}, {PallocChunkPages/2 + 34, PallocChunkPages/2 - 34}},\n\t\t\tnpages: 65,\n\t\t\thits: []uint{PallocChunkPages/2 - 31, ^uint(0)},\n\t\t\tafter: []BitRange{{0, PallocChunkPages}},\n\t\t},\n\t\t\"SomeFree161\": {\n\t\t\tbefore: []BitRange{{0, 185}, {331, 1}},\n\t\t\tnpages: 161,\n\t\t\thits: []uint{332},\n\t\t\tafter: []BitRange{{0, 185}, {331, 162}},\n\t\t},\n\t}\n\tfor name, v := range tests {\n\t\tv := v\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tb := makePallocBits(v.before)\n\t\t\tfor iter, i := range v.hits {\n\t\t\t\ta, _ := b.Find(v.npages, 0)\n\t\t\t\tif i != a {\n\t\t\t\t\tt.Fatalf(\"find #%d picked wrong index: want %d, got %d\", iter+1, i, a)\n\t\t\t\t}\n\t\t\t\tif i != ^uint(0) {\n\t\t\t\t\tb.AllocRange(a, uint(v.npages))\n\t\t\t\t}\n\t\t\t}\n\t\t\twant := makePallocBits(v.after)\n\t\t\tcheckPallocBits(t, b, want)\n\t\t})\n\t}\n}", "func BenchmarkMemTool3(b *testing.B) {\n\tvar blk [4096]byte\n\tb.ReportAllocs()\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tfor x := 0; x < len(blk); x++ {\n\t\t\tblk[x] = 0\n\t\t}\n\t}\n}", "func TestPageAllocScavenge(t *testing.T) {\n\tif GOOS == \"openbsd\" && testing.Short() {\n\t\tt.Skip(\"skipping because virtual memory is limited; see #36210\")\n\t}\n\ttype test struct {\n\t\trequest, expect uintptr\n\t}\n\tminPages := PhysPageSize / PageSize\n\tif minPages < 1 {\n\t\tminPages = 1\n\t}\n\ttype setup struct {\n\t\tbeforeAlloc map[ChunkIdx][]BitRange\n\t\tbeforeScav map[ChunkIdx][]BitRange\n\t\texpect []test\n\t\tafterScav map[ChunkIdx][]BitRange\n\t}\n\ttests := map[string]setup{\n\t\t\"AllFreeUnscavExhaust\": {\n\t\t\tbeforeAlloc: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {},\n\t\t\t\tBaseChunkIdx + 1: {},\n\t\t\t\tBaseChunkIdx + 2: {},\n\t\t\t},\n\t\t\tbeforeScav: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {},\n\t\t\t\tBaseChunkIdx + 1: {},\n\t\t\t\tBaseChunkIdx + 2: {},\n\t\t\t},\n\t\t\texpect: []test{\n\t\t\t\t{^uintptr(0), 3 * PallocChunkPages * PageSize},\n\t\t\t},\n\t\t\tafterScav: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {{0, PallocChunkPages}},\n\t\t\t\tBaseChunkIdx + 1: {{0, PallocChunkPages}},\n\t\t\t\tBaseChunkIdx + 2: {{0, PallocChunkPages}},\n\t\t\t},\n\t\t},\n\t\t\"NoneFreeUnscavExhaust\": {\n\t\t\tbeforeAlloc: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {{0, PallocChunkPages}},\n\t\t\t\tBaseChunkIdx + 1: {},\n\t\t\t\tBaseChunkIdx + 2: {{0, PallocChunkPages}},\n\t\t\t},\n\t\t\tbeforeScav: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {},\n\t\t\t\tBaseChunkIdx + 1: {{0, PallocChunkPages}},\n\t\t\t\tBaseChunkIdx + 2: {},\n\t\t\t},\n\t\t\texpect: []test{\n\t\t\t\t{^uintptr(0), 0},\n\t\t\t},\n\t\t\tafterScav: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {},\n\t\t\t\tBaseChunkIdx + 1: {{0, PallocChunkPages}},\n\t\t\t\tBaseChunkIdx + 2: {},\n\t\t\t},\n\t\t},\n\t\t\"ScavHighestPageFirst\": {\n\t\t\tbeforeAlloc: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {},\n\t\t\t},\n\t\t\tbeforeScav: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {{uint(minPages), PallocChunkPages - uint(2*minPages)}},\n\t\t\t},\n\t\t\texpect: []test{\n\t\t\t\t{1, minPages * PageSize},\n\t\t\t},\n\t\t\tafterScav: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {{uint(minPages), PallocChunkPages - uint(minPages)}},\n\t\t\t},\n\t\t},\n\t\t\"ScavMultiple\": {\n\t\t\tbeforeAlloc: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {},\n\t\t\t},\n\t\t\tbeforeScav: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {{uint(minPages), PallocChunkPages - uint(2*minPages)}},\n\t\t\t},\n\t\t\texpect: []test{\n\t\t\t\t{minPages * PageSize, minPages * PageSize},\n\t\t\t\t{minPages * PageSize, minPages * PageSize},\n\t\t\t},\n\t\t\tafterScav: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {{0, PallocChunkPages}},\n\t\t\t},\n\t\t},\n\t\t\"ScavMultiple2\": {\n\t\t\tbeforeAlloc: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {},\n\t\t\t\tBaseChunkIdx + 1: {},\n\t\t\t},\n\t\t\tbeforeScav: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {{uint(minPages), PallocChunkPages - uint(2*minPages)}},\n\t\t\t\tBaseChunkIdx + 1: {{0, PallocChunkPages - uint(2*minPages)}},\n\t\t\t},\n\t\t\texpect: []test{\n\t\t\t\t{2 * minPages * PageSize, 2 * minPages * PageSize},\n\t\t\t\t{minPages * PageSize, minPages * PageSize},\n\t\t\t\t{minPages * PageSize, minPages * PageSize},\n\t\t\t},\n\t\t\tafterScav: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {{0, PallocChunkPages}},\n\t\t\t\tBaseChunkIdx + 1: {{0, PallocChunkPages}},\n\t\t\t},\n\t\t},\n\t\t\"ScavDiscontiguous\": {\n\t\t\tbeforeAlloc: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {},\n\t\t\t\tBaseChunkIdx + 0xe: {},\n\t\t\t},\n\t\t\tbeforeScav: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {{uint(minPages), PallocChunkPages - uint(2*minPages)}},\n\t\t\t\tBaseChunkIdx + 0xe: {{uint(2 * minPages), PallocChunkPages - uint(2*minPages)}},\n\t\t\t},\n\t\t\texpect: []test{\n\t\t\t\t{2 * minPages * PageSize, 2 * minPages * PageSize},\n\t\t\t\t{^uintptr(0), 2 * minPages * PageSize},\n\t\t\t\t{^uintptr(0), 0},\n\t\t\t},\n\t\t\tafterScav: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {{0, PallocChunkPages}},\n\t\t\t\tBaseChunkIdx + 0xe: {{0, PallocChunkPages}},\n\t\t\t},\n\t\t},\n\t}\n\t// Disable these tests on iOS since we have a small address space.\n\t// See #46860.\n\tif PageAlloc64Bit != 0 && goos.IsIos == 0 {\n\t\ttests[\"ScavAllVeryDiscontiguous\"] = setup{\n\t\t\tbeforeAlloc: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {},\n\t\t\t\tBaseChunkIdx + 0x1000: {},\n\t\t\t},\n\t\t\tbeforeScav: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {},\n\t\t\t\tBaseChunkIdx + 0x1000: {},\n\t\t\t},\n\t\t\texpect: []test{\n\t\t\t\t{^uintptr(0), 2 * PallocChunkPages * PageSize},\n\t\t\t\t{^uintptr(0), 0},\n\t\t\t},\n\t\t\tafterScav: map[ChunkIdx][]BitRange{\n\t\t\t\tBaseChunkIdx: {{0, PallocChunkPages}},\n\t\t\t\tBaseChunkIdx + 0x1000: {{0, PallocChunkPages}},\n\t\t\t},\n\t\t}\n\t}\n\tfor name, v := range tests {\n\t\tv := v\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tb := NewPageAlloc(v.beforeAlloc, v.beforeScav)\n\t\t\tdefer FreePageAlloc(b)\n\n\t\t\tfor iter, h := range v.expect {\n\t\t\t\tif got := b.Scavenge(h.request); got != h.expect {\n\t\t\t\t\tt.Fatalf(\"bad scavenge #%d: want %d, got %d\", iter+1, h.expect, got)\n\t\t\t\t}\n\t\t\t}\n\t\t\twant := NewPageAlloc(v.beforeAlloc, v.afterScav)\n\t\t\tdefer FreePageAlloc(want)\n\n\t\t\tcheckPageAlloc(t, want, b)\n\t\t})\n\t}\n}", "func BenchmarkMemoryHeap(b *testing.B) {\n\tvar s *S\n\n\tf, err := os.Create(\"heap.out\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer f.Close()\n\n\terr = trace.Start(f)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor i := 0; i < b.N; i++ {\n\t\ts = byPointer()\n\t}\n\n\ttrace.Stop()\n\n\tb.StopTimer()\n\n\t_ = fmt.Sprintf(\"%v\", s.a)\n}", "func PrintMemStats(m *runtime.MemStats, mstats, ostats, astats, gc bool, pauses int) {\n\tif mstats {\n\t\tfmt.Printf(\"Alloc=%h, TotalAlloc=%h, Sys=%h, Lookups=%h, Mallocs=%h, Frees=%h\\n\",\n\t\t\thu(m.Alloc, \"B\"), hu(m.TotalAlloc, \"B\"), hu(m.Sys, \"B\"), hu(m.Lookups, \"\"), hu(m.Mallocs, \"\"), hu(m.Frees, \"\"))\n\t\tfmt.Printf(\"HeapAlloc=%h, HeapSys=%h, HeapIdle=%h, HeapInuse=%h, HeapReleased=%h, HeapObjects=%h, StackInuse=%h, StackSys=%h\\n\",\n\t\t\thu(m.HeapAlloc, \"B\"), hu(m.HeapSys, \"B\"), hu(m.HeapIdle, \"B\"), hu(m.HeapInuse, \"B\"), hu(m.HeapReleased, \"B\"),\n\t\t\thu(m.HeapObjects, \"\"), hu(m.StackInuse, \"B\"), hu(m.StackSys, \"B\"))\n\t\tif ostats {\n\t\t\tfmt.Printf(\"MSpanInuse=%d, MSpanSys=%d, m.MCacheInuse=%d, MCacheSys=%d, BuckHashSys=%d, GCSys=%d, OtherSys=%d\\n\",\n\t\t\t\tm.MSpanInuse, m.MSpanSys, m.MCacheInuse, m.MCacheSys, m.BuckHashSys, m.GCSys, m.OtherSys)\n\t\t}\n\n\t\tt1 := time.Unix(0, int64(m.LastGC))\n\t\t//t2 := time.Now()\n\t\t//t3 := time.Unix(int64(0), int64(m.PauseTotalNs))\n\t\tet := time.Duration(int64(m.PauseTotalNs)) // Since(t3)\n\t\tfmt.Printf(\"NextGC=%h, NumGC=%d, LastGC=%s, PauseTotalNs=%v, NumForcedGC=%d, GCCPUFraction=%0.2f\\n\",\n\t\t\thu(m.NextGC, \"B\"), m.NumGC, t1.Format(\"15:04:05.99\"), et, m.NumForcedGC, m.GCCPUFraction)\n\t}\n\tfmt.Printf(\"\\n\")\n\n\tif astats {\n\t\tfor i, b := range m.BySize {\n\t\t\tif b.Mallocs == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfmt.Printf(\"BySize[%d]: Size=%d, Malloc=%d, Frees=%d\\n\", i, b.Size, b.Mallocs, b.Frees)\n\t\t}\n\t\tfmt.Printf(\"\\n\")\n\t}\n\n\tif gc {\n\t\tPrintCircularBuffer(\"PauseNs\", pauses, int(m.NumGC), true, m.PauseNs)\n\t\tPrintCircularBuffer(\"PauseEnd\", pauses, int(m.NumGC), false, m.PauseEnd)\n\t\tfmt.Printf(\"\\n\")\n\t}\n}", "func NewAlloc(startChunkSize int, slabSize int, growthFactor float64, malloc func(size int) []byte) *Alloc {\n\tc := new(Alloc)\n\tc.m = make(locker,1)\n\tc.arena = slab.NewArena(startChunkSize,slabSize,growthFactor,malloc)\n\tc.recycle = make(chan []byte,128)\n\treturn c\n}", "func (r BenchmarkResult) AllocsPerOp() int64 {}", "func sysAlloc(n uintptr, sysStat *uint64) unsafe.Pointer {\n\tp := memAlloc(nil, n)\n\tif p != nil {\n\t\tmSysStatInc(sysStat, n)\n\t}\n\treturn p\n}", "func BenchmarkMemTool2(b *testing.B) {\n\tvar blk [4096]byte\n\tb.ReportAllocs()\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tclearBlockForEach(&blk)\n\t}\n}", "func TestAllocGarbageCollector_MakeRoomFor_MaxAllocs(t *testing.T) {\n\tci.Parallel(t)\n\n\tconst maxAllocs = 6\n\trequire := require.New(t)\n\n\tserver, serverAddr, cleanupS := testServer(t, nil)\n\tdefer cleanupS()\n\ttestutil.WaitForLeader(t, server.RPC)\n\n\tclient, cleanup := TestClient(t, func(c *config.Config) {\n\t\tc.GCMaxAllocs = maxAllocs\n\t\tc.GCDiskUsageThreshold = 100\n\t\tc.GCInodeUsageThreshold = 100\n\t\tc.GCParallelDestroys = 1\n\t\tc.GCInterval = time.Hour\n\t\tc.RPCHandler = server\n\t\tc.Servers = []string{serverAddr}\n\t\tc.ConsulConfig.ClientAutoJoin = new(bool)\n\t})\n\tdefer cleanup()\n\twaitTilNodeReady(client, t)\n\n\tjob := mock.Job()\n\tjob.TaskGroups[0].Count = 1\n\tjob.TaskGroups[0].Tasks[0].Driver = \"mock_driver\"\n\tjob.TaskGroups[0].Tasks[0].Config = map[string]interface{}{\n\t\t\"run_for\": \"30s\",\n\t}\n\n\tindex := uint64(98)\n\tnextIndex := func() uint64 {\n\t\tindex++\n\t\treturn index\n\t}\n\n\tupsertJobFn := func(server *nomad.Server, j *structs.Job) {\n\t\tstate := server.State()\n\t\trequire.NoError(state.UpsertJob(structs.MsgTypeTestSetup, nextIndex(), j))\n\t\trequire.NoError(state.UpsertJobSummary(nextIndex(), mock.JobSummary(j.ID)))\n\t}\n\n\t// Insert the Job\n\tupsertJobFn(server, job)\n\n\tupsertAllocFn := func(server *nomad.Server, a *structs.Allocation) {\n\t\tstate := server.State()\n\t\trequire.NoError(state.UpsertAllocs(structs.MsgTypeTestSetup, nextIndex(), []*structs.Allocation{a}))\n\t}\n\n\tupsertNewAllocFn := func(server *nomad.Server, j *structs.Job) *structs.Allocation {\n\t\talloc := mock.Alloc()\n\t\talloc.Job = j\n\t\talloc.JobID = j.ID\n\t\talloc.NodeID = client.NodeID()\n\n\t\tupsertAllocFn(server, alloc)\n\n\t\treturn alloc.Copy()\n\t}\n\n\tvar allocations []*structs.Allocation\n\n\t// Fill the node with allocations\n\tfor i := 0; i < maxAllocs; i++ {\n\t\tallocations = append(allocations, upsertNewAllocFn(server, job))\n\t}\n\n\t// Wait until the allocations are ready\n\ttestutil.WaitForResult(func() (bool, error) {\n\t\tar := len(client.getAllocRunners())\n\n\t\treturn ar == maxAllocs, fmt.Errorf(\"Expected %d allocs, got %d\", maxAllocs, ar)\n\t}, func(err error) {\n\t\tt.Fatalf(\"Allocs did not start: %v\", err)\n\t})\n\n\t// Mark the first three as terminal\n\tfor i := 0; i < 3; i++ {\n\t\tallocations[i].DesiredStatus = structs.AllocDesiredStatusStop\n\t\tupsertAllocFn(server, allocations[i].Copy())\n\t}\n\n\t// Wait until the allocations are stopped\n\ttestutil.WaitForResult(func() (bool, error) {\n\t\tar := client.getAllocRunners()\n\t\tstopped := 0\n\t\tfor _, r := range ar {\n\t\t\tif r.Alloc().TerminalStatus() {\n\t\t\t\tstopped++\n\t\t\t}\n\t\t}\n\n\t\treturn stopped == 3, fmt.Errorf(\"Expected %d terminal allocs, got %d\", 3, stopped)\n\t}, func(err error) {\n\t\tt.Fatalf(\"Allocs did not terminate: %v\", err)\n\t})\n\n\t// Upsert a new allocation\n\t// This does not get appended to `allocations` as we do not use them again.\n\tupsertNewAllocFn(server, job)\n\n\t// A single allocation should be GC'd\n\ttestutil.WaitForResult(func() (bool, error) {\n\t\tar := client.getAllocRunners()\n\t\tdestroyed := 0\n\t\tfor _, r := range ar {\n\t\t\tif r.IsDestroyed() {\n\t\t\t\tdestroyed++\n\t\t\t}\n\t\t}\n\n\t\treturn destroyed == 1, fmt.Errorf(\"Expected %d gc'd ars, got %d\", 1, destroyed)\n\t}, func(err error) {\n\t\tt.Fatalf(\"Allocs did not get GC'd: %v\", err)\n\t})\n\n\t// Upsert a new allocation\n\t// This does not get appended to `allocations` as we do not use them again.\n\tupsertNewAllocFn(server, job)\n\n\t// 2 allocations should be GC'd\n\ttestutil.WaitForResult(func() (bool, error) {\n\t\tar := client.getAllocRunners()\n\t\tdestroyed := 0\n\t\tfor _, r := range ar {\n\t\t\tif r.IsDestroyed() {\n\t\t\t\tdestroyed++\n\t\t\t}\n\t\t}\n\n\t\treturn destroyed == 2, fmt.Errorf(\"Expected %d gc'd ars, got %d\", 2, destroyed)\n\t}, func(err error) {\n\t\tt.Fatalf(\"Allocs did not get GC'd: %v\", err)\n\t})\n\n\t// check that all 8 get run eventually\n\ttestutil.WaitForResult(func() (bool, error) {\n\t\tar := client.getAllocRunners()\n\t\tif len(ar) != 8 {\n\t\t\treturn false, fmt.Errorf(\"expected 8 ARs, found %d: %v\", len(ar), ar)\n\t\t}\n\t\treturn true, nil\n\t}, func(err error) {\n\t\trequire.NoError(err)\n\t})\n}", "func CollectRuntimeMemStats(statsd scopedstatsd.Client, memstatsCurrent *runtime.MemStats, memstatsPrev *runtime.MemStats, tags []string) {\n\t// Collect number of bytes obtained from system.\n\tstatsd.Gauge(\"mem.sys_bytes\", float64(memstatsCurrent.Sys), tags, 1)\n\n\t// Collect number of pointer lookups.\n\tstatsd.Gauge(\"mem.pointer_lookups\", float64(memstatsCurrent.Lookups), tags, 1)\n\n\t// Collect increased heap objects allocated compared to last flush.\n\tstatsd.Count(\"mem.mallocs_total\", int64(memstatsCurrent.Mallocs-memstatsPrev.Mallocs), tags, 1)\n\n\t// Collect increased heap objects freed compared to last flush.\n\tstatsd.Count(\"mem.frees_total\", int64(memstatsCurrent.Frees-memstatsPrev.Frees), tags, 1)\n\n\t// Collect number of mallocs.\n\tstatsd.Gauge(\"mem.mallocs_count\", float64(memstatsCurrent.Mallocs-memstatsCurrent.Frees), tags, 1)\n\n\t// Collect number of bytes newly allocated for heap objects compared to last flush.\n\tstatsd.Count(\"mem.heap_alloc_bytes_total\", int64(memstatsCurrent.TotalAlloc-memstatsPrev.TotalAlloc), tags, 1)\n\n\t// Collect number of heap bytes allocated and still in use.\n\tstatsd.Gauge(\"mem.heap_alloc_bytes\", float64(memstatsCurrent.HeapAlloc), tags, 1)\n\n\t// Collect number of heap bytes obtained from system.\n\tstatsd.Gauge(\"mem.heap_sys_bytes\", float64(memstatsCurrent.HeapSys), tags, 1)\n\n\t// Collect number of heap bytes waiting to be used.\n\tstatsd.Gauge(\"mem.heap_idle_bytes\", float64(memstatsCurrent.HeapIdle), tags, 1)\n\n\t// Collect number of heap bytes that are in use.\n\tstatsd.Gauge(\"mem.heap_inuse_bytes\", float64(memstatsCurrent.HeapInuse), tags, 1)\n\n\t// Collect number of heap bytes released to OS.\n\tstatsd.Gauge(\"mem.heap_released_bytes\", float64(memstatsCurrent.HeapReleased), tags, 1)\n\n\t// Collect number of allocated objects.\n\tstatsd.Gauge(\"mem.heap_objects_count\", float64(memstatsCurrent.HeapObjects), tags, 1)\n\n\t// Collect number of bytes in use by the stack allocator.\n\tstatsd.Gauge(\"mem.stack_inuse_bytes\", float64(memstatsCurrent.StackInuse), tags, 1)\n\n\t// Collect number of bytes obtained from system for stack allocator.\n\tstatsd.Gauge(\"mem.stack_sys_bytes\", float64(memstatsCurrent.StackSys), tags, 1)\n\n\t// Collect number of bytes in use by mspan structures.\n\tstatsd.Gauge(\"mem.mspan_inuse_bytes\", float64(memstatsCurrent.MSpanInuse), tags, 1)\n\n\t// Collect number of bytes used for mspan structures obtained from system.\n\tstatsd.Gauge(\"mem.mspan_sys_bytes\", float64(memstatsCurrent.MSpanSys), tags, 1)\n\n\t// Collect number of bytes in use by mcache structures.\n\tstatsd.Gauge(\"mem.mcache_inuse_bytes\", float64(memstatsCurrent.MCacheInuse), tags, 1)\n\n\t// Collect number of bytes used for mcache structures obtained from system.\n\tstatsd.Gauge(\"mem.mcache_sys_bytes\", float64(memstatsCurrent.MCacheSys), tags, 1)\n\n\t// Collect number of bytes used by the profiling bucket hash table.\n\tstatsd.Gauge(\"mem.buck_hash_sys_bytes\", float64(memstatsCurrent.BuckHashSys), tags, 1)\n\n\t// Collect number of bytes used for garbage collection system metadata.\n\tstatsd.Gauge(\"mem.gc_sys_bytes\", float64(memstatsCurrent.GCSys), tags, 1)\n\n\t// Collect number of bytes used for other system allocations.\n\tstatsd.Gauge(\"mem.other_sys_bytes\", float64(memstatsCurrent.OtherSys), tags, 1)\n\n\t// Collect number of heap bytes when next garbage collection will take pace.\n\tstatsd.Gauge(\"mem.next_gc_bytes\", float64(memstatsCurrent.NextGC), tags, 1)\n}", "func TestMemory_WMISimple(t *testing.T) {\n\tif os.Getenv(\"TEST_MEM\") == \"\" {\n\t\tt.Skip(\"Skipping TestMemory_WMISimple; $TEST_MEM is not set\")\n\t}\n\n\tstart := time.Now()\n\tfmt.Printf(\"Benchmark Iterations: %d (Private Memory should stabilize around 7MB after ~3000)\\n\", memReps)\n\n\tvar privateMB, allocMB, allocTotalMB float64\n\tfor i := 0; i < memReps; i++ {\n\t\tprivateMB, allocMB, allocTotalMB = getMemoryUsageMB(t)\n\t\tif i%1000 == 0 {\n\t\t\tfmt.Printf(\"Time: %4ds Count: %5d \", time.Now().Sub(start)/time.Second, i)\n\t\t\tprintlnMemUsage(privateMB, allocMB, allocTotalMB)\n\t\t}\n\t}\n\n\tfmt.Printf(\"Final Time: %4ds \", time.Now().Sub(start)/time.Second)\n\tprintlnMemUsage(privateMB, allocMB, allocTotalMB)\n}", "func InitAllocator(addr uint32) {\n\t// Warning: Lot of unsafe pointer usage and manipulation ahead.\n\t// This function basically initializes memory at given address, so that\n\t// _buddyAllocator, and it's members, point to this address.\n\n\t// create freeBuddiesList\n\tvar _freeBuddiesList *[MaxOrder + 1]freeBuddiesList\n\t_freeBuddiesList = (*[MaxOrder + 1]freeBuddiesList)(pointer.Get(addr))\n\taddr += (MaxOrder + 1) * uint32(unsafe.Sizeof(freeBuddiesList{}))\n\n\t// set freeBuddiesList in buddyAllocator\n\t_buddyAllocator.buddies = (*_freeBuddiesList)[:MaxOrder+1]\n\n\t// create bigPagesBitmap\n\t// _nBigPages size for array is way more than needed. this is done since\n\t// array sizes need to be constant.\n\tvar _bigPagesBitmap *[_nBigPages]uint32\n\t_bigPagesBitmap = (*[_nBigPages]uint32)(pointer.Get(addr))\n\taddr += nMaps(_nBigPages) * 4\n\n\t// set bigPagesBitmap in buddyAllocator\n\t_buddyAllocator.buddies[MaxOrder].freeMap.maps = (*_bigPagesBitmap)[:nMaps(_nBigPages)]\n\n\t// mark all big pages as free\n\tfor i := uint32(0); i < nMaps(_nBigPages); i++ {\n\t\t_buddyAllocator.buddies[MaxOrder].freeMap.maps[i] = _allSet\n\t}\n\n\t// create the individual freeBuddiesList\n\tfor i := 0; i < MaxOrder; i++ {\n\t\t// maxOrder - 1 pages of order i, further divide by 2 since we use 1 bit\n\t\t// for buddy pair.\n\t\tvar nBuddies uint32 = _nBigPages * (1 << uint32(MaxOrder-i-1))\n\t\tnMaps := nMaps(nBuddies)\n\n\t\t// set address for this freeBuddiesList\n\t\t// we are addressing way more memory than needed, because array sizes need\n\t\t// to be constant. this will be more than enough for largest freeBuddiesList\n\t\tvar maps *[_nBigPages * _nBigPages]uint32\n\t\tmaps = (*[_nBigPages * _nBigPages]uint32)(pointer.Get(addr))\n\t\taddr += nMaps * 4\n\n\t\t// set the freeBuddiesList\n\t\t_buddyAllocator.buddies[i].freeMap.maps = (*maps)[:nMaps]\n\n\t\t// zero out the freeBuddiesList\n\t\tfor j := uint32(0); j < nMaps; j++ {\n\t\t\t_buddyAllocator.buddies[i].freeMap.maps[j] = 0\n\t\t}\n\t}\n\n\tinitNodePool(addr)\n}", "func printMemoryUsage() {\n\truntime.GC()\n\truntime.ReadMemStats(&mem)\n\tlog.Printf(\"%s: %dkb\", \"mem usage\", mem.HeapAlloc/1024)\n}", "func allocMany() {\n\t// Allocate 1 MiB of 64 KiB chunks repeatedly.\n\tfor {\n\t\tfor i := 0; i < 16; i++ {\n\t\t\t_ = make([]byte, 64*1024)\n\t\t}\n\t\ttime.Sleep(100 * time.Millisecond)\n\t}\n}", "func sysAlloc(n uintptr, sysStat *sysMemStat) unsafe.Pointer {\n\tp, err := mmap(nil, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0)\n\tif err != 0 {\n\t\tif err == _EACCES {\n\t\t\tprint(\"runtime: mmap: access denied\\n\")\n\t\t\texit(2)\n\t\t}\n\t\tif err == _EAGAIN {\n\t\t\tprint(\"runtime: mmap: too much locked memory (check 'ulimit -l').\\n\")\n\t\t\texit(2)\n\t\t}\n\t\treturn nil\n\t}\n\tsysStat.add(int64(n))\n\treturn p\n}", "func AllocateJobs(noOfJobs int, noOfWarmupJobs int, testDuration time.Duration, warmupDuration time.Duration, maxSpeedPerSecond int, scenarios []Scenario, jobs chan Job) error {\n\tlog.Debugf(\"Allocating jobs ...\")\n\n\tdistributionsBuckets, err := buildDistributionBuckets(scenarios)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn err\n\t}\n\n\tif testDuration > 0 {\n\t\tshouldWarmupStop := make(chan bool)\n\t\tgo func() {\n\t\t\tif warmupDuration != 0 {\n\t\t\t\tlog.Debugf(\"Starting warmup for [%d]ms\", warmupDuration)\n\t\t\t\t<-time.After(warmupDuration)\n\t\t\t\tlog.Debugf(\"Warmup Done\")\n\t\t\t}\n\t\t\tshouldWarmupStop <- true\n\t\t}()\n\n\t\tshouldStop := make(chan bool)\n\t\tgo func() {\n\t\t\tlog.Debugf(\"Allocating for [%d]ms\", testDuration)\n\t\t\t<-time.After(testDuration)\n\t\t\tlog.Debugf(\"Stop allocation\")\n\t\t\tshouldStop <- true\n\t\t}()\n\n\t\tallocateJobsUntilDone(shouldStop, shouldWarmupStop, maxSpeedPerSecond, scenarios, distributionsBuckets, jobs)\n\t} else {\n\t\tallocatePredefinedNumberOfJobs(noOfJobs, noOfWarmupJobs, maxSpeedPerSecond, scenarios, distributionsBuckets, jobs)\n\t}\n\n\tclose(jobs)\n\tlog.Debugf(\"Allocating done\")\n\treturn nil\n}", "func sysAlloc(n uintptr, sysStat *uint64) unsafe.Pointer {\n\tp := mmap(nil, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0)\n\tif uintptr(p) < 4096 {\n\t\tif uintptr(p) == _EACCES {\n\t\t\tprint(\"runtime: mmap: access denied\\n\")\n\t\t\texit(2)\n\t\t}\n\t\tif uintptr(p) == _EAGAIN {\n\t\t\tprint(\"runtime: mmap: too much locked memory (check 'ulimit -l').\\n\")\n\t\t\texit(2)\n\t\t}\n\t\treturn nil\n\t}\n\tmSysStatInc(sysStat, n)\n\treturn p\n}", "func alloc() uint64 {\n\tvar stats runtime.MemStats\n\truntime.GC()\n\truntime.ReadMemStats(&stats)\n\t// return stats.Alloc - uint64(unsafe.Sizeof(hs[0]))*uint64(cap(hs))\n\treturn stats.Alloc\n}", "func PrintMemUsage(memprofile string) {\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\t// For info on each, see: https://golang.org/pkg/runtime/#MemStats\n\tfmt.Printf(\"Alloc = %v MiB\", bToMb(m.Alloc))\n\tfmt.Printf(\"\\tTotalAlloc = %v MiB\", bToMb(m.TotalAlloc))\n\tfmt.Printf(\"\\tSys = %v MiB\", bToMb(m.Sys))\n\tfmt.Printf(\"\\tNumGC = %v\\n\", m.NumGC)\n\n\tif memprofile != \"\" {\n\t\tf, err := os.Create(memprofile)\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"could not create memory profile: \", err)\n\t\t}\n\t\truntime.GC() // get up-to-date statistics\n\t\tif err := pprof.WriteHeapProfile(f); err != nil {\n\t\t\tlog.Fatal(\"could not write memory profile: \", err)\n\t\t}\n\t\tf.Close()\n\t}\n}", "func PrintMemUsage() {\n\tvar m runtime.MemStats\n\truntime.GC()\n\truntime.ReadMemStats(&m)\n\t// For info on each, see: https://golang.org/pkg/runtime/#MemStats\n\tfmt.Print(\"Alloc = \", humanize.Bytes(m.Alloc))\n\tfmt.Print(\"\\tTotalAlloc = \", humanize.Bytes(m.TotalAlloc))\n\tfmt.Print(\"\\tSys = \", humanize.Bytes(m.Sys))\n\tfmt.Print(\"\\tGCSys = \", humanize.Bytes(m.GCSys))\n\tfmt.Print(\"\\tNumGC = \", m.NumGC)\n\tfmt.Println(\"\\tTimeGC =\", m.PauseTotalNs/uint64(time.Millisecond), \"ms\")\n}", "func (s *Service) MemoryAllocated(req *MemoryRequest) (*MemoryReply, error) {\n\ttime.Sleep(30000)\n\tvar b int\n\ts.db.View(func(tx *bbolt.Tx) error {\n\t\tstats := tx.Bucket(s.bucketNameTx).Stats()\n\t\t// b = stats.LeafInuse + stats.BranchInuse\n\t\tb = stats.LeafInuse\n\t\treturn nil\n\t})\n\treturn &MemoryReply{\n\t\tBytesAllocated: b,\n\t\tNbrTrees: len(s.trees),\n\t}, nil\n}", "func (mr *MockNuvoVMMockRecorder) AllocParcels(arg0, arg1, arg2 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"AllocParcels\", reflect.TypeOf((*MockNuvoVM)(nil).AllocParcels), arg0, arg1, arg2)\n}", "func allocPDFLexbufMemory(n int) unsafe.Pointer {\n\tmem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfPDFLexbufValue))\n\tif err != nil {\n\t\tpanic(\"memory alloc error: \" + err.Error())\n\t}\n\treturn mem\n}", "func RegisterAndWaitForAllocs(t *testing.T, nomadClient *api.Client, jobFile, jobID, cToken string) []*api.AllocationListStub {\n\tjobs := nomadClient.Jobs()\n\n\t// Start allocations\n\tRegisterAllocs(t, nomadClient, jobFile, jobID, cToken)\n\n\tvar err error\n\tallocs := []*api.AllocationListStub{}\n\tevals := []*api.Evaluation{}\n\n\t// Wrap in retry to wait until placement\n\ttestutil.WaitForResultRetries(retries, func() (bool, error) {\n\t\ttime.Sleep(time.Second)\n\n\t\tallocs, _, err = jobs.Allocations(jobID, false, nil)\n\t\tif len(allocs) == 0 {\n\t\t\tevals, _, err = nomadClient.Jobs().Evaluations(jobID, nil)\n\t\t\treturn false, fmt.Errorf(\"no allocations for job %v\", jobID)\n\t\t}\n\n\t\treturn true, nil\n\t}, func(e error) {\n\t\tmsg := fmt.Sprintf(\"allocations not placed for %s\", jobID)\n\t\tfor _, eval := range evals {\n\t\t\tmsg += fmt.Sprintf(\"\\n %s - %s\", eval.Status, eval.StatusDescription)\n\t\t}\n\n\t\trequire.Fail(t, msg, \"full evals: %v\", pretty.Sprint(evals))\n\t})\n\n\trequire.NoError(t, err) // we only care about the last error\n\n\treturn allocs\n}", "func allocPDFWriteOptionsMemory(n int) unsafe.Pointer {\n\tmem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfPDFWriteOptionsValue))\n\tif err != nil {\n\t\tpanic(\"memory alloc error: \" + err.Error())\n\t}\n\treturn mem\n}", "func (_m *HostMemoryManager) ReportUnmanagedSpaceUsageChange(bytes int64) {\n\t_m.Called(bytes)\n}", "func Benchmark_WriteRaw(b *testing.B) {\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\n\tclient, done := benchmarkSetup(ctx, b)\n\n\tf, err := os.ReadFile(\"testdata/alloc_objects.pb.gz\")\n\trequire.NoError(b, err)\n\n\t// Benchmark section\n\tb.ReportAllocs()\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\t_, err := client.WriteRaw(ctx, &pb.WriteRawRequest{\n\t\t\tSeries: []*pb.RawProfileSeries{\n\t\t\t\t{\n\t\t\t\t\tLabels: &pb.LabelSet{\n\t\t\t\t\t\tLabels: []*pb.Label{\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tName: labels.MetricName,\n\t\t\t\t\t\t\t\tValue: \"allocs\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tName: \"test\",\n\t\t\t\t\t\t\t\tValue: b.Name(),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tSamples: []*pb.RawSample{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tRawProfile: f,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t\trequire.NoError(b, err)\n\t}\n\tb.StopTimer()\n\n\tcancel()\n\t<-done\n}", "func (o *V0037Node) SetAllocMemory(v int64) {\n\to.AllocMemory = &v\n}", "func (c *AgonesDiscoverAllocator) Allocate(ctx context.Context, req *pb.AssignTicketsRequest) error {\n\tlogger := runtime.Logger().WithField(\"component\", \"allocator\")\n\n\tfor _, assignmentGroup := range req.Assignments {\n\t\tif err := IsAssignmentGroupValidForAllocation(assignmentGroup); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfilter, err := extensions.ExtractFilterFromExtensions(assignmentGroup.Assignment.Extensions)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"the assignment does not have a valid filter extension\")\n\t\t}\n\n\t\tgameservers, err := c.ListGameServers(ctx, filter)\n\t\tif err != nil {\n\t\t\tlogger.Error(err)\n\t\t\treturn err\n\t\t}\n\n\t\tif len(gameservers) == 0 {\n\t\t\tlogger.Debugf(\"gameservers not found for request with filter %v\", filter.Map())\n\t\t\tcontinue\n\t\t}\n\n\t\t// NiceToHave: Filter GameServers by Capacity and Count\n\t\t// Remove not assigned tickets based on playersCapacity - Count\n\t\t// strategy: allTogether, CapacityBased FallBack\n\t\tfor _, gs := range gameservers {\n\t\t\tif HasCapacity(assignmentGroup, gs) {\n\t\t\t\tassignmentGroup.Assignment.Connection = gs.Status.Address\n\t\t\t\t//logger.Debugf(\"extension %v\", assignmentGroup.Assignment.Extensions)\n\t\t\t\tlogger.Infof(\"gameserver %s connection %s assigned to request, total tickets: %d\", gs.Name, assignmentGroup.Assignment.Connection, len(assignmentGroup.TicketIds))\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func PrintMemUsage() {\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\n\tfmt.Printf(\"Alloc = %v MiB\", m.Alloc/1024/1024)\n\tfmt.Printf(\" TotalAlloc = %v MiB\", m.TotalAlloc/1024/1024)\n\tfmt.Printf(\" Sys = %v MiB\", m.Sys/1024/1024)\n\tfmt.Printf(\" NumGC = %v\\n\", m.NumGC)\n}", "func _dirtySeriesMapAlloc(opts _dirtySeriesMapOptions) *dirtySeriesMap {\n\tm := &dirtySeriesMap{_dirtySeriesMapOptions: opts}\n\tm.Reallocate()\n\treturn m\n}", "func overrideAllocatableMemoryTest(f *framework.Framework, allocatablePods int) {\n\tconst (\n\t\tpodType = \"memory_limit_test_pod\"\n\t)\n\n\ttotalAllocatable := getTotalAllocatableMemory(f)\n\n\tmemValue := totalAllocatable.Value()\n\tmemPerPod := memValue / int64(allocatablePods)\n\tginkgo.By(fmt.Sprintf(\"Deploying %d pods with mem limit %v, then one additional pod\", allocatablePods, memPerPod))\n\n\t// these should all work\n\tpods := newMemLimitTestPods(allocatablePods, imageutils.GetPauseImageName(), podType, strconv.FormatInt(memPerPod, 10))\n\tf.PodClient().CreateBatch(pods)\n\n\tfailurePods := newMemLimitTestPods(1, imageutils.GetPauseImageName(), podType, strconv.FormatInt(memPerPod, 10))\n\tf.PodClient().Create(failurePods[0])\n\n\tgomega.Eventually(func() bool {\n\t\teventList, err := f.ClientSet.CoreV1().Events(f.Namespace.Name).List(metav1.ListOptions{})\n\t\tframework.ExpectNoError(err)\n\t\tfor _, e := range eventList.Items {\n\t\t\t// Look for an event that shows FailedScheduling\n\t\t\tif e.Type == \"Warning\" && e.Reason == \"FailedScheduling\" && e.InvolvedObject.Name == failurePods[0].ObjectMeta.Name {\n\t\t\t\tframework.Logf(\"Found %+v event with message %+v\", e.Reason, e.Message)\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\treturn false\n\t}, 3*time.Minute, 10*time.Second).Should(gomega.Equal(true))\n}", "func (p *ResourcePool) Allocs(ctx context.Context) ([]Alloc, error) {\n\tp.mu.Lock()\n\tdefer p.mu.Unlock()\n\tallocs := make([]Alloc, len(p.allocs))\n\ti := 0\n\tfor _, a := range p.allocs {\n\t\tallocs[i] = a\n\t\ti++\n\t}\n\treturn allocs, nil\n}", "func TestMemory_WbemConnection(t *testing.T) {\n\tif os.Getenv(\"TEST_MEM\") == \"\" {\n\t\tt.Skip(\"Skipping TestMemory_WbemConnection; $TEST_MEM is not set\")\n\t}\n\ts, err := ConnectSWbemServices()\n\tif err != nil {\n\t\tt.Fatalf(\"InitializeSWbemServices: %s\", err)\n\t}\n\n\tstart := time.Now()\n\tfmt.Printf(\"Benchmark Iterations: %d (Private Memory should stabilize around 7MB after ~3000)\\n\", memReps)\n\n\tvar privateMB, allocMB, allocTotalMB float64\n\tfor i := 0; i < memReps; i++ {\n\t\tprivateMB, allocMB, allocTotalMB = wbemConnGetMemoryUsageMB(t, s)\n\t\tif i%100 == 0 {\n\t\t\tfmt.Printf(\"Time: %4ds Count: %5d \", time.Now().Sub(start)/time.Second, i)\n\t\t\tprintlnMemUsage(privateMB, allocMB, allocTotalMB)\n\t\t}\n\t}\n\n\terrClose := s.Close()\n\tif errClose != nil {\n\t\tt.Fatalf(\"Close: %s\", err)\n\t}\n\n\tfmt.Printf(\"Final Time: %4ds \", time.Now().Sub(start)/time.Second)\n\tprintlnMemUsage(privateMB, allocMB, allocTotalMB)\n}", "func (c UdpPort_send) AllocResults() (UdpPort_send_Results, error) {\n\tr, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 0, PointerCount: 0})\n\treturn UdpPort_send_Results{Struct: r}, err\n}", "func (mr *MockVolumeMgrMockRecorder) Alloc(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Alloc\", reflect.TypeOf((*MockVolumeMgr)(nil).Alloc), arg0, arg1)\n}", "func (d *DeviceAccounter) AddAllocs(allocs []*Allocation) (collision bool) {\n\tfor _, a := range allocs {\n\t\t// Filter any terminal allocation\n\t\tif a.TerminalStatus() {\n\t\t\tcontinue\n\t\t}\n\n\t\t// COMPAT(0.11): Remove in 0.11\n\t\t// If the alloc doesn't have the new style resources, it can't have\n\t\t// devices\n\t\tif a.AllocatedResources == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Go through each task resource\n\t\tfor _, tr := range a.AllocatedResources.Tasks {\n\n\t\t\t// Go through each assigned device group\n\t\t\tfor _, device := range tr.Devices {\n\t\t\t\tdevID := device.ID()\n\n\t\t\t\t// Go through each assigned device\n\t\t\t\tfor _, instanceID := range device.DeviceIDs {\n\n\t\t\t\t\t// Mark that we are using the device. It may not be in the\n\t\t\t\t\t// map if the device is no longer being fingerprinted, is\n\t\t\t\t\t// unhealthy, etc.\n\t\t\t\t\tif devInst, ok := d.Devices[*devID]; ok {\n\t\t\t\t\t\tif i, ok := devInst.Instances[instanceID]; ok {\n\t\t\t\t\t\t\t// Mark that the device is in use\n\t\t\t\t\t\t\tdevInst.Instances[instanceID]++\n\n\t\t\t\t\t\t\tif i != 0 {\n\t\t\t\t\t\t\t\tcollision = true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn\n}", "func BenchmarkMockEntryDetail(b *testing.B) {\n\tb.ReportAllocs()\n\tfor i := 0; i < b.N; i++ {\n\t\ttestMockEntryDetail(b)\n\t}\n}", "func (s *Stats) GetMemoryInfo(logMemory, logGoMemory bool) {\n\n if logGoMemory {\n if s.GoInfo == nil {\n s.initGoInfo()\n }\n\n runtime.ReadMemStats(s.GoInfo.Memory.mem)\n s.GoInfo.GoRoutines = runtime.NumGoroutine()\n s.GoInfo.Memory.Alloc = s.GoInfo.Memory.mem.Alloc\n s.GoInfo.Memory.HeapAlloc = s.GoInfo.Memory.mem.HeapAlloc\n s.GoInfo.Memory.HeapSys = s.GoInfo.Memory.mem.HeapSys\n\n if s.GoInfo.Memory.LastGC != s.GoInfo.Memory.mem.LastGC {\n s.GoInfo.Memory.LastGC = s.GoInfo.Memory.mem.LastGC\n s.GoInfo.Memory.NumGC = s.GoInfo.Memory.mem.NumGC - s.GoInfo.Memory.lastNumGC\n s.GoInfo.Memory.lastNumGC = s.GoInfo.Memory.mem.NumGC\n s.GoInfo.Memory.LastGCPauseDuration = s.GoInfo.Memory.mem.PauseNs[(s.GoInfo.Memory.mem.NumGC+255)%256]\n } else {\n s.GoInfo.Memory.NumGC = 0\n s.GoInfo.Memory.LastGCPauseDuration = 0\n }\n }\n\n if logMemory {\n\n if s.MemInfo == nil {\n s.MemInfo = new(MemInfo)\n }\n\n s.MemInfo.Memory, _ = mem.VirtualMemory()\n s.MemInfo.Swap, _ = mem.SwapMemory()\n }\n}", "func WithMemDump(min int, diff int, abs int) Option {\n\treturn optionFunc(func(opts *options) (err error) {\n\t\topts.MemOpts.MemTriggerPercentMin = min\n\t\topts.MemOpts.MemTriggerPercentDiff = diff\n\t\topts.MemOpts.MemTriggerPercentAbs = abs\n\t\treturn\n\t})\n}", "func TestMemoryTracker(ptr unsafe.Pointer, sz C.size_t, op C.rtloader_mem_ops_t) {\n\tswitch op {\n\tcase C.DATADOG_AGENT_RTLOADER_ALLOCATION:\n\t\tAllocations.Add(1)\n\tcase C.DATADOG_AGENT_RTLOADER_FREE:\n\t\tFrees.Add(1)\n\t}\n}", "func TestMemoryTracker(ptr unsafe.Pointer, sz C.size_t, op C.rtloader_mem_ops_t) {\n\tswitch op {\n\tcase C.DATADOG_AGENT_RTLOADER_ALLOCATION:\n\t\tAllocations.Add(1)\n\tcase C.DATADOG_AGENT_RTLOADER_FREE:\n\t\tFrees.Add(1)\n\t}\n}", "func Allocs(nomad *NomadServer) []Alloc {\n\tallocs := make([]Alloc, 0)\n\tdecodeJSON(url(nomad)+\"/v1/allocations\", &allocs)\n\treturn allocs\n}", "func (h BryanMemoryStatsHook) printMemStats() {\n\th.Log.Debug(\"Reading memory statistics\")\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\t\n\th.Log.Debug(\"Printing memory statistics\")\n\th.printHeader(&m)\n\th.printMemAlloc(&m)\n\th.printMemTotalAlloc(&m)\n\th.printMemSys(&m)\n\th.printMemFrees(&m)\n\th.printMemNumGC(&m)\n\th.printFooter(&m)\n}", "func testNoMallocs(a *assert.Assertions, x *demo.ContainerType, topLevel bool) {\n\tstats := runtime.MemStats{}\n\ttimer := time.NewTimer(1 * time.Second)\n\tfn := func(ctx demo.TargetContext, x demo.Target) (ret demo.TargetDecision) { return }\n\n\tfor {\n\t\tselect {\n\t\tcase <-timer.C:\n\t\t\ta.Fail(\"timeout\")\n\t\t\treturn\n\t\tdefault:\n\t\t\tvar err error\n\t\t\truntime.ReadMemStats(&stats)\n\t\t\tmemBefore := stats.Mallocs\n\n\t\t\tif topLevel {\n\t\t\t\t_, _, err = demo.WalkTarget(x, fn)\n\t\t\t} else {\n\t\t\t\t_, _, err = x.WalkTarget(fn)\n\t\t\t}\n\t\t\truntime.ReadMemStats(&stats)\n\n\t\t\ta.NoError(err)\n\t\t\tmemAfter := stats.Mallocs\n\t\t\tif memAfter == memBefore {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}", "func ReportStats(ctx context.Context, pool *redis.Pool, name string) {\n\tstats := pool.Stats()\n\tconnsMetric.Set(ctx, int64(stats.IdleCount), name, \"idle\")\n\tconnsMetric.Set(ctx, int64(stats.ActiveCount-stats.IdleCount), name, \"in-use\")\n\twaitCountMetric.Set(ctx, int64(stats.WaitCount), name)\n\twaitDurationMetric.Set(ctx, int64(stats.WaitDuration.Nanoseconds()/1000), name)\n}", "func BenchmarkBatchXCKCreate(b *testing.B) {\n\tb.ReportAllocs()\n\tfor i := 0; i < b.N; i++ {\n\t\ttestBatchXCKCreate(b)\n\t}\n}", "func BenchmarkBufferedWrite(b *testing.B) {\n\tb.ReportAllocs()\n\twrite(b, bufio.NewWriter(newTmpFile()))\n}", "func MemoryMetrics(ctx context.Context, base *BaseMetrics, pre *PreData, p *perf.Values, outdir, suffix string) error {\n\tvar innerBase *metrics.BaseMemoryStats\n\tif base != nil {\n\t\tinnerBase = base.innerMetrics\n\t}\n\treturn metrics.LogMemoryStats(ctx, innerBase, ARCFromPre(pre), p, outdir, suffix)\n}", "func (p *mockPolicy) GetAllocatableMemory(s state.State) []state.Block {\n\treturn []state.Block{}\n}", "func CaptureMemStats(d time.Duration) {\n\tcaptureMemStats(metrics.DefaultRegistry, d)\n}", "func allocPDFLexbufLargeMemory(n int) unsafe.Pointer {\n\tmem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfPDFLexbufLargeValue))\n\tif err != nil {\n\t\tpanic(\"memory alloc error: \" + err.Error())\n\t}\n\treturn mem\n}", "func PrintMemUsage() {\r\n\tvar m runtime.MemStats\r\n\truntime.ReadMemStats(&m)\r\n\t// For info on each, see: https://golang.org/pkg/runtime/#MemStats\r\n\tfmt.Printf(\"Alloc = %v MiB\", bToMb(m.Alloc))\r\n\tfmt.Printf(\"\\tTotalAlloc = %v MiB\", bToMb(m.TotalAlloc))\r\n\tfmt.Printf(\"\\tSys = %v MiB\", bToMb(m.Sys))\r\n\tfmt.Printf(\"\\tNumGC = %v\\n\", m.NumGC)\r\n}", "func PrintMemUsage() {\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\t// For info on each, see: https://golang.org/pkg/runtime/#MemStats\n\tlog.Printf(\"Alloc = %v MiB\", bToMb(m.Alloc))\n\tlog.Printf(\"TotalAlloc = %v MiB\", bToMb(m.TotalAlloc))\n\tlog.Printf(\"Sys = %v MiB\", bToMb(m.Sys))\n\tlog.Printf(\"NumGC = %v\", m.NumGC)\n}", "func PrintMemUsage() {\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\t// For info on each, see: https://golang.org/pkg/runtime/#MemStats\n\tfmt.Printf(\"Alloc = %v MiB\", bToMb(m.Alloc))\n\tfmt.Printf(\"\\tTotalAlloc = %v MiB\", bToMb(m.TotalAlloc))\n\tfmt.Printf(\"\\tSys = %v MiB\", bToMb(m.Sys))\n\tfmt.Printf(\"\\tNumGC = %v\\n\", m.NumGC)\n}", "func systemMemoryMonitor(logger *logrus.Logger, wg *sync.WaitGroup, done chan struct{}, kill chan struct{}) {\n\tdefer wg.Done()\n\tdefer close(kill)\n\n\tvar swapUsedBaseline uint64 = math.MaxUint64\n\n\tfor {\n\t\tselect {\n\t\tcase <-done:\n\t\t\treturn\n\t\tcase <-time.After(1 * time.Second):\n\t\t}\n\n\t\tctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)\n\t\tmemStat, err := mem.VirtualMemoryWithContext(ctx)\n\n\t\tif err != nil {\n\t\t\tlogger.WithError(err).Debugf(\"Failed to retrieve memory usage.\")\n\t\t}\n\n\t\tcancel()\n\n\t\tctx, cancel = context.WithTimeout(context.Background(), 100*time.Millisecond)\n\t\tswapStat, err := mem.SwapMemoryWithContext(ctx)\n\n\t\tif err != nil {\n\t\t\tlogger.WithError(err).Debugf(\"Failed to retrieve swap usage.\")\n\t\t}\n\n\t\tcancel()\n\n\t\tswapUsed := uint64(0)\n\t\tif swapStat.Used < swapUsedBaseline {\n\t\t\tswapUsed = swapStat.Used\n\t\t} else {\n\t\t\tswapUsed = swapStat.Used - swapUsedBaseline\n\t\t}\n\n\t\tused := float64(memStat.Used+swapUsed) / float64(memStat.Total)\n\t\tlogger.Debugf(\n\t\t\t\"Memory usage: %.2f%% - RAM %s / Swap %s.\",\n\t\t\tused*100,\n\t\t\thumanBytes(memStat.Used),\n\t\t\thumanBytes(swapUsed),\n\t\t)\n\n\t\tif used > 0.9 {\n\t\t\treturn\n\t\t}\n\t}\n}", "func (c Controller_dev) AllocResults() (Controller_dev_Results, error) {\n\tr, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 0, PointerCount: 2})\n\treturn Controller_dev_Results(r), err\n}", "func allocSize(bufCap, reqLen int) int {\n\tif bufCap == 0 {\n\t\treturn reqLen\n\t}\n\treturn 5 * reqLen / 4\n}", "func mmapDataAlloc(size int) (*mmapData, error) {\n\tflags := syscall.MAP_SHARED | syscall.MAP_ANONYMOUS\n\tprot := syscall.PROT_WRITE | syscall.PROT_READ\n\tdata, err := syscallMmap(-1, 0, size, prot, flags)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &mmapData{data: data}, nil\n}", "func (mm *atmanMemoryManager) allocPage(page vaddr) {\n\tvar (\n\t\tl4offset = page.pageTableOffset(pageTableLevel4)\n\t\tl3offset = page.pageTableOffset(pageTableLevel3)\n\t\tl2offset = page.pageTableOffset(pageTableLevel2)\n\t\tl1offset = page.pageTableOffset(pageTableLevel1)\n\t)\n\n\tl4 := mm.l4\n\tl3pte := l4.Get(l4offset)\n\n\tif !l3pte.hasFlag(xenPageTablePresent) {\n\t\tpfn := mm.physAllocPage()\n\t\tl3pte = mm.writePte(mm.l4PFN, l4offset, pfn, PTE_PAGE_TABLE_FLAGS|xenPageTableWritable)\n\t}\n\n\tl3 := mm.getPageTable(-1, -1, l4offset)\n\tl2pte := l3.Get(l3offset)\n\n\tif !l2pte.hasFlag(xenPageTablePresent) {\n\t\tpfn := mm.physAllocPage()\n\t\tl2pte = mm.writePte(l3pte.pfn(), l3offset, pfn, PTE_PAGE_TABLE_FLAGS|xenPageTableWritable)\n\t}\n\n\tl2 := mm.getPageTable(-1, l4offset, l3offset)\n\tl1pte := l2.Get(l2offset)\n\n\tif !l1pte.hasFlag(xenPageTablePresent) {\n\t\tpfn := mm.physAllocPage()\n\t\tl1pte = mm.writePte(l2pte.pfn(), l2offset, pfn, PTE_PAGE_TABLE_FLAGS|xenPageTableWritable)\n\t}\n\n\tpagepfn := mm.physAllocPage()\n\tmm.writePte(l1pte.pfn(), l1offset, pagepfn, PTE_PAGE_FLAGS)\n\n\t// ensure page is writable\n\t*(*uintptr)(unsafe.Pointer(page)) = 0x0\n}", "func TestMultiWriter_WriteStringSingleAlloc(t *testing.T) {\n\tt.Skip(\"skipping on gccgo until we have escape analysis\")\n\tvar sink1, sink2 bytes.Buffer\n\ttype simpleWriter struct { // hide bytes.Buffer's WriteString\n\t\tWriter\n\t}\n\tmw := MultiWriter(simpleWriter{&sink1}, simpleWriter{&sink2})\n\tallocs := int(testing.AllocsPerRun(1000, func() {\n\t\tWriteString(mw, \"foo\")\n\t}))\n\tif allocs != 1 {\n\t\tt.Errorf(\"num allocations = %d; want 1\", allocs)\n\t}\n}", "func setupMemory(ctx context.Context, r types.Resources, s *specs.Spec) {\n\tmemory := &specs.LinuxMemory{}\n\tif r.Memory > 0 {\n\t\tv := r.Memory\n\t\tmemory.Limit = &v\n\t}\n\n\tif r.MemorySwap != 0 {\n\t\tv := r.MemorySwap\n\t\tmemory.Swap = &v\n\t}\n\n\tif r.MemorySwappiness != nil {\n\t\tv := uint64(*r.MemorySwappiness)\n\t\tmemory.Swappiness = &v\n\t}\n\n\tif r.OomKillDisable != nil {\n\t\tv := bool(*r.OomKillDisable)\n\t\tmemory.DisableOOMKiller = &v\n\t}\n\n\ts.Linux.Resources.Memory = memory\n}", "func mallocWithAlarm(int n, void **pp) (nFull int) {\n\tvoid *p;\n\tnFull = sqlite3Config.m.xRoundup(n);\n\tsqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, n);\n\tif mem0.alarmCallback != 0 {\n\t\tint nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);\n\t\tif nUsed >= mem0.alarmThreshold - nFull {\n\t\t\tmem0.nearlyFull = 1;\n\t\t\tsqlite3MallocAlarm(nFull);\n\t\t} else {\n\t\t\tmem0.nearlyFull = 0;\n\t\t}\n\t}\n\tp = sqlite3Config.m.xMalloc(nFull);\n\tif p != nil {\n\t\tnFull = sqlite3MallocSize(p);\n\t\tsqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nFull);\n\t\tsqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, 1);\n\t}\n\t*pp = p;\n\treturn\n}", "func allocPDFMrangeMemory(n int) unsafe.Pointer {\n\tmem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfPDFMrangeValue))\n\tif err != nil {\n\t\tpanic(\"memory alloc error: \" + err.Error())\n\t}\n\treturn mem\n}", "func Alloc(addr, size uint64, allocType, protect int) *Memory {\n\tpanic(\"not implemented\")\n}", "func (m *MockNuvoVM) AllocParcels(arg0, arg1 string, arg2 uint64) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"AllocParcels\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func alloc(size uintptr, layout unsafe.Pointer) unsafe.Pointer", "func (mr *MockNuvoVMMockRecorder) AllocCache(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"AllocCache\", reflect.TypeOf((*MockNuvoVM)(nil).AllocCache), arg0, arg1)\n}", "func NewMemInfoCollector() MetricsCollector {\n\treturn &memInfoCollector{\n\t\tMetricsCollector: \"meminfo\",\n\t}\n}", "func alloc(size uintptr, layout unsafe.Pointer) unsafe.Pointer {\n\t// TODO: this can be optimized by not casting between pointers and ints so\n\t// much. And by using platform-native data types (e.g. *uint8 for 8-bit\n\t// systems).\n\tsize = align(size)\n\taddr := heapptr\n\theapptr += size\n\tfor heapptr >= heapEnd {\n\t\t// Try to increase the heap and check again.\n\t\tif growHeap() {\n\t\t\tcontinue\n\t\t}\n\t\t// Failed to make the heap bigger, so we must really be out of memory.\n\t\truntimePanic(\"out of memory\")\n\t}\n\tpointer := unsafe.Pointer(addr)\n\tmemzero(pointer, size)\n\treturn pointer\n}", "func allocPDFCmapMemory(n int) unsafe.Pointer {\n\tmem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfPDFCmapValue))\n\tif err != nil {\n\t\tpanic(\"memory alloc error: \" + err.Error())\n\t}\n\treturn mem\n}", "func (m *merger) Preallocate() {\n\tarr := make([]byte, preallocationBufferSize)\n\tpos := int64(0)\n\n\tfor {\n\t\tif pos + preallocationBufferSize > m.totalSize {\n\t\t\tm.file.WriteAt(arr[0:m.totalSize - pos], pos)\n\t\t} else {\n\t\t\tm.file.WriteAt(arr, pos)\n\t\t}\n\t\tpos += preallocationBufferSize\n\n\t\tfmt.Printf(\"\\rPreallocating... %.2f%%\", 100.0*math.Min(float64(pos), float64(m.totalSize))/float64(m.totalSize))\n\n\t\tif pos >= m.totalSize {\n\t\t\tfmt.Println()\n\t\t\tbreak\n\t\t}\n\t}\n}", "func TestMetricsMemoryPressureResponse(t *testing.T) {\n\tvar currentMemAlloc uint64\n\tml := &memoryLimiter{\n\t\tusageChecker: memUsageChecker{\n\t\t\tmemAllocLimit: 1024,\n\t\t},\n\t\treadMemStatsFn: func(ms *runtime.MemStats) {\n\t\t\tms.Alloc = currentMemAlloc\n\t\t},\n\t\tobsrep: obsreport.NewProcessorObsReport(configtelemetry.LevelNone, \"\"),\n\t\tlogger: zap.NewNop(),\n\t}\n\tmp, err := processorhelper.NewMetricsProcessor(\n\t\t&Config{\n\t\t\tProcessorSettings: configmodels.ProcessorSettings{\n\t\t\t\tTypeVal: typeStr,\n\t\t\t\tNameVal: typeStr,\n\t\t\t},\n\t\t},\n\t\tconsumertest.NewMetricsNop(),\n\t\tml,\n\t\tprocessorhelper.WithCapabilities(processorCapabilities),\n\t\tprocessorhelper.WithShutdown(ml.shutdown))\n\trequire.NoError(t, err)\n\n\tctx := context.Background()\n\tmd := pdata.NewMetrics()\n\n\t// Below memAllocLimit.\n\tcurrentMemAlloc = 800\n\tml.checkMemLimits()\n\tassert.NoError(t, mp.ConsumeMetrics(ctx, md))\n\n\t// Above memAllocLimit.\n\tcurrentMemAlloc = 1800\n\tml.checkMemLimits()\n\tassert.Equal(t, errForcedDrop, mp.ConsumeMetrics(ctx, md))\n\n\t// Check ballast effect\n\tml.ballastSize = 1000\n\n\t// Below memAllocLimit accounting for ballast.\n\tcurrentMemAlloc = 800 + ml.ballastSize\n\tml.checkMemLimits()\n\tassert.NoError(t, mp.ConsumeMetrics(ctx, md))\n\n\t// Above memAllocLimit even accountiing for ballast.\n\tcurrentMemAlloc = 1800 + ml.ballastSize\n\tml.checkMemLimits()\n\tassert.Equal(t, errForcedDrop, mp.ConsumeMetrics(ctx, md))\n\n\t// Restore ballast to default.\n\tml.ballastSize = 0\n\n\t// Check spike limit\n\tml.usageChecker.memSpikeLimit = 512\n\n\t// Below memSpikeLimit.\n\tcurrentMemAlloc = 500\n\tml.checkMemLimits()\n\tassert.NoError(t, mp.ConsumeMetrics(ctx, md))\n\n\t// Above memSpikeLimit.\n\tcurrentMemAlloc = 550\n\tml.checkMemLimits()\n\tassert.Equal(t, errForcedDrop, mp.ConsumeMetrics(ctx, md))\n\n}", "func (i *Interpreter) alloc(n int) {\n\ti.mem = append(i.mem, make([]int, n, n)...)\n}", "func (c IpInterface_listenUdp) AllocResults() (IpInterface_listenUdp_Results, error) {\n\tr, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 0, PointerCount: 1})\n\treturn IpInterface_listenUdp_Results{Struct: r}, err\n}", "func BenchmarkUnbufferedWrite(b *testing.B) {\n\tb.ReportAllocs()\n\twrite(b, newTmpFile())\n}", "func newStatsCacheWithMemCap(memoryCapacity int64, tp statsCacheType) (StatsCache, error) {\n\tswitch tp {\n\tcase simpleLRUCache:\n\t\treturn newSimpleLRUStatsCache(memoryCapacity), nil\n\t}\n\treturn nil, errors.New(\"wrong statsCache type\")\n}", "func NewMeminfoCollector() (Collector, error) {\n\treturn &meminfoCollector{\n\t\tmetrics: map[string]prometheus.Gauge{},\n\t}, nil\n}", "func (c IpInterface_listenTcp) AllocResults() (IpInterface_listenTcp_Results, error) {\n\tr, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 0, PointerCount: 1})\n\treturn IpInterface_listenTcp_Results{Struct: r}, err\n}", "func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {\n\treturn p.MemoryMapsWithContext(context.Background(), grouped)\n}", "func BenchmarkBatchCTXCreate(b *testing.B) {\n\tb.ReportAllocs()\n\tfor i := 0; i < b.N; i++ {\n\t\ttestBatchCTXCreate(b)\n\t}\n}", "func TlsAlloc() DWORD {\n\tret1 := syscall3(tlsAlloc, 0,\n\t\t0,\n\t\t0,\n\t\t0)\n\treturn DWORD(ret1)\n}", "func (c Controller_devShell) AllocResults() (Controller_devShell_Results, error) {\n\tr, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 0, PointerCount: 2})\n\treturn Controller_devShell_Results(r), err\n}", "func allocPDFDaInfoMemory(n int) unsafe.Pointer {\n\tmem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfPDFDaInfoValue))\n\tif err != nil {\n\t\tpanic(\"memory alloc error: \" + err.Error())\n\t}\n\treturn mem\n}", "func (a *Agent) setMemMetrics(statsData *types.StatsJSON, entry *stats.MetricsEntry) {\n\tentry.Mem = &stats.MetricsMemEntry{\n\t\tFailcnt: int64(statsData.MemoryStats.Failcnt),\n\t\tLimit: int64(statsData.MemoryStats.Limit),\n\t\tMaxusage: int64(statsData.MemoryStats.MaxUsage),\n\t\tUsage: int64(statsData.MemoryStats.Usage),\n\t\tUsageP: a.getMemUsage(statsData),\n\t}\n}", "func (n *NodeDrainer) drainAllocs(future *structs.BatchFuture, allocs []*structs.Allocation) {\n\t// Compute the effected jobs and make the transition map\n\tjobs := make(map[string]*structs.Allocation, 4)\n\ttransistions := make(map[string]*structs.DesiredTransition, len(allocs))\n\tfor _, alloc := range allocs {\n\t\ttransistions[alloc.ID] = &structs.DesiredTransition{\n\t\t\tMigrate: helper.BoolToPtr(true),\n\t\t}\n\t\tjobs[alloc.JobID] = alloc\n\t}\n\n\tevals := make([]*structs.Evaluation, 0, len(jobs))\n\tfor job, alloc := range jobs {\n\t\tevals = append(evals, &structs.Evaluation{\n\t\t\tID: uuid.Generate(),\n\t\t\tNamespace: alloc.Namespace,\n\t\t\tPriority: alloc.Job.Priority,\n\t\t\tType: alloc.Job.Type,\n\t\t\tTriggeredBy: structs.EvalTriggerNodeDrain,\n\t\t\tJobID: job,\n\t\t\tStatus: structs.EvalStatusPending,\n\t\t})\n\t}\n\n\t// Commit this update via Raft\n\tvar finalIndex uint64\n\tfor _, u := range partitionAllocDrain(defaultMaxIdsPerTxn, transistions, evals) {\n\t\tindex, err := n.raft.AllocUpdateDesiredTransition(u.Transitions, u.Evals)\n\t\tif err != nil {\n\t\t\tfuture.Respond(0, err)\n\t\t\treturn\n\t\t}\n\t\tfinalIndex = index\n\t}\n\n\tfuture.Respond(finalIndex, nil)\n}", "func TestPallocBitsSummarize(t *testing.T) {\n\tvar emptySum = PackPallocSum(PallocChunkPages, PallocChunkPages, PallocChunkPages)\n\ttype test struct {\n\t\tfree []BitRange // Ranges of free (zero) bits.\n\t\thits []PallocSum\n\t}\n\ttests := make(map[string]test)\n\ttests[\"NoneFree\"] = test{\n\t\tfree: []BitRange{},\n\t\thits: []PallocSum{\n\t\t\tPackPallocSum(0, 0, 0),\n\t\t},\n\t}\n\ttests[\"OnlyStart\"] = test{\n\t\tfree: []BitRange{{0, 10}},\n\t\thits: []PallocSum{\n\t\t\tPackPallocSum(10, 10, 0),\n\t\t},\n\t}\n\ttests[\"OnlyEnd\"] = test{\n\t\tfree: []BitRange{{PallocChunkPages - 40, 40}},\n\t\thits: []PallocSum{\n\t\t\tPackPallocSum(0, 40, 40),\n\t\t},\n\t}\n\ttests[\"StartAndEnd\"] = test{\n\t\tfree: []BitRange{{0, 11}, {PallocChunkPages - 23, 23}},\n\t\thits: []PallocSum{\n\t\t\tPackPallocSum(11, 23, 23),\n\t\t},\n\t}\n\ttests[\"StartMaxEnd\"] = test{\n\t\tfree: []BitRange{{0, 4}, {50, 100}, {PallocChunkPages - 4, 4}},\n\t\thits: []PallocSum{\n\t\t\tPackPallocSum(4, 100, 4),\n\t\t},\n\t}\n\ttests[\"OnlyMax\"] = test{\n\t\tfree: []BitRange{{1, 20}, {35, 241}, {PallocChunkPages - 50, 30}},\n\t\thits: []PallocSum{\n\t\t\tPackPallocSum(0, 241, 0),\n\t\t},\n\t}\n\ttests[\"MultiMax\"] = test{\n\t\tfree: []BitRange{{35, 2}, {40, 5}, {100, 5}},\n\t\thits: []PallocSum{\n\t\t\tPackPallocSum(0, 5, 0),\n\t\t},\n\t}\n\ttests[\"One\"] = test{\n\t\tfree: []BitRange{{2, 1}},\n\t\thits: []PallocSum{\n\t\t\tPackPallocSum(0, 1, 0),\n\t\t},\n\t}\n\ttests[\"AllFree\"] = test{\n\t\tfree: []BitRange{{0, PallocChunkPages}},\n\t\thits: []PallocSum{\n\t\t\temptySum,\n\t\t},\n\t}\n\tfor name, v := range tests {\n\t\tv := v\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tb := makePallocBits(v.free)\n\t\t\t// In the PallocBits we create 1's represent free spots, but in our actual\n\t\t\t// PallocBits 1 means not free, so invert.\n\t\t\tinvertPallocBits(b)\n\t\t\tfor _, h := range v.hits {\n\t\t\t\tcheckPallocSum(t, b.Summarize(), h)\n\t\t\t}\n\t\t})\n\t}\n}", "func procMem(_ int) (ProcMemStats, error) {\n\treturn ProcMemStats{}, nil\n}", "func TestTraceMemoryPressureResponse(t *testing.T) {\n\tvar currentMemAlloc uint64\n\tml := &memoryLimiter{\n\t\tusageChecker: memUsageChecker{\n\t\t\tmemAllocLimit: 1024,\n\t\t},\n\t\treadMemStatsFn: func(ms *runtime.MemStats) {\n\t\t\tms.Alloc = currentMemAlloc\n\t\t},\n\t\tobsrep: obsreport.NewProcessorObsReport(configtelemetry.LevelNone, \"\"),\n\t\tlogger: zap.NewNop(),\n\t}\n\ttp, err := processorhelper.NewTraceProcessor(\n\t\t&Config{\n\t\t\tProcessorSettings: configmodels.ProcessorSettings{\n\t\t\t\tTypeVal: typeStr,\n\t\t\t\tNameVal: typeStr,\n\t\t\t},\n\t\t},\n\t\tconsumertest.NewTracesNop(),\n\t\tml,\n\t\tprocessorhelper.WithCapabilities(processorCapabilities),\n\t\tprocessorhelper.WithShutdown(ml.shutdown))\n\trequire.NoError(t, err)\n\n\tctx := context.Background()\n\ttd := pdata.NewTraces()\n\n\t// Below memAllocLimit.\n\tcurrentMemAlloc = 800\n\tml.checkMemLimits()\n\tassert.NoError(t, tp.ConsumeTraces(ctx, td))\n\n\t// Above memAllocLimit.\n\tcurrentMemAlloc = 1800\n\tml.checkMemLimits()\n\tassert.Equal(t, errForcedDrop, tp.ConsumeTraces(ctx, td))\n\n\t// Check ballast effect\n\tml.ballastSize = 1000\n\n\t// Below memAllocLimit accounting for ballast.\n\tcurrentMemAlloc = 800 + ml.ballastSize\n\tml.checkMemLimits()\n\tassert.NoError(t, tp.ConsumeTraces(ctx, td))\n\n\t// Above memAllocLimit even accountiing for ballast.\n\tcurrentMemAlloc = 1800 + ml.ballastSize\n\tml.checkMemLimits()\n\tassert.Equal(t, errForcedDrop, tp.ConsumeTraces(ctx, td))\n\n\t// Restore ballast to default.\n\tml.ballastSize = 0\n\n\t// Check spike limit\n\tml.usageChecker.memSpikeLimit = 512\n\n\t// Below memSpikeLimit.\n\tcurrentMemAlloc = 500\n\tml.checkMemLimits()\n\tassert.NoError(t, tp.ConsumeTraces(ctx, td))\n\n\t// Above memSpikeLimit.\n\tcurrentMemAlloc = 550\n\tml.checkMemLimits()\n\tassert.Equal(t, errForcedDrop, tp.ConsumeTraces(ctx, td))\n\n}", "func LogStats() {\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\tlog.Infof(\"Alloc=%v TotalAlloc=%v Sys=%v NumGC=%v Goroutines=%d\",\n\t\tm.Alloc/1024, m.TotalAlloc/1024, m.Sys/1024, m.NumGC, runtime.NumGoroutine())\n\n}", "func allocPDFGraftMapMemory(n int) unsafe.Pointer {\n\tmem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfPDFGraftMapValue))\n\tif err != nil {\n\t\tpanic(\"memory alloc error: \" + err.Error())\n\t}\n\treturn mem\n}", "func BenchmarkPallocBitsSummarize(b *testing.B) {\n\tpatterns := []uint64{\n\t\t0,\n\t\t^uint64(0),\n\t\t0xaa,\n\t\t0xaaaaaaaaaaaaaaaa,\n\t\t0x80000000aaaaaaaa,\n\t\t0xaaaaaaaa00000001,\n\t\t0xbbbbbbbbbbbbbbbb,\n\t\t0x80000000bbbbbbbb,\n\t\t0xbbbbbbbb00000001,\n\t\t0xcccccccccccccccc,\n\t\t0x4444444444444444,\n\t\t0x4040404040404040,\n\t\t0x4000400040004000,\n\t\t0x1000404044ccaaff,\n\t}\n\tfor _, p := range patterns {\n\t\tbuf := new(PallocBits)\n\t\tfor i := 0; i < len(buf); i++ {\n\t\t\tbuf[i] = p\n\t\t}\n\t\tb.Run(fmt.Sprintf(\"Unpacked%02X\", p), func(b *testing.B) {\n\t\t\tcheckPallocSum(b, buf.Summarize(), SummarizeSlow(buf))\n\t\t\tfor i := 0; i < b.N; i++ {\n\t\t\t\tbuf.Summarize()\n\t\t\t}\n\t\t})\n\t}\n}", "func (mm *BytesMonitor) AllocBytes() int64 {\n\tmm.mu.Lock()\n\tdefer mm.mu.Unlock()\n\treturn mm.mu.curAllocated\n}", "func Free(config *FreeConfig) error {\n\tm, err := meminfo()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tmmi, err := getMainMemInfo(m, config)\n\tif err != nil {\n\t\treturn err\n\t}\n\tsi, err := getSwapInfo(m, config)\n\tif err != nil {\n\t\treturn err\n\t}\n\tmi := MemInfo{Mem: *mmi, Swap: *si}\n\tif config.ToJSON {\n\t\tjsonData, err := json.Marshal(mi)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfmt.Println(string(jsonData))\n\t} else {\n\t\tfmt.Printf(\" total used free shared buff/cache available\\n\")\n\t\tfmt.Printf(\"%-7s %11v %11v %11v %11v %11v %11v\\n\",\n\t\t\t\"Mem:\",\n\t\t\tformatValueByConfig(mmi.Total, config),\n\t\t\tformatValueByConfig(mmi.Used, config),\n\t\t\tformatValueByConfig(mmi.Free, config),\n\t\t\tformatValueByConfig(mmi.Shared, config),\n\t\t\tformatValueByConfig(mmi.Buffers+mmi.Cached, config),\n\t\t\tformatValueByConfig(mmi.Available, config),\n\t\t)\n\t\tfmt.Printf(\"%-7s %11v %11v %11v\\n\",\n\t\t\t\"Swap:\",\n\t\t\tformatValueByConfig(si.Total, config),\n\t\t\tformatValueByConfig(si.Used, config),\n\t\t\tformatValueByConfig(si.Free, config),\n\t\t)\n\t}\n\treturn nil\n}" ]
[ "0.74036807", "0.6688823", "0.6501399", "0.6230664", "0.6176789", "0.5929078", "0.5918433", "0.5865994", "0.5713867", "0.56269395", "0.5620441", "0.56038296", "0.5561375", "0.5464719", "0.54509616", "0.5442123", "0.5417522", "0.54055613", "0.5358954", "0.53147954", "0.5314264", "0.5305677", "0.52664685", "0.526043", "0.5223579", "0.52214515", "0.5200839", "0.518643", "0.5183598", "0.514714", "0.5127285", "0.509637", "0.5092134", "0.5091263", "0.50873005", "0.506529", "0.505987", "0.50556207", "0.50489444", "0.5043232", "0.5040447", "0.5038194", "0.5034065", "0.5029704", "0.5022017", "0.5021701", "0.5017347", "0.5017347", "0.5009064", "0.49901178", "0.49758255", "0.49562183", "0.49541345", "0.49521077", "0.49488726", "0.49357873", "0.49350762", "0.49019694", "0.4887742", "0.4872251", "0.48718366", "0.48657852", "0.48644248", "0.48524168", "0.4852237", "0.4849509", "0.48377007", "0.48376903", "0.4820993", "0.48164287", "0.4799705", "0.4798646", "0.47947124", "0.4786452", "0.47780934", "0.4771118", "0.47683537", "0.47659388", "0.47658715", "0.47618732", "0.4761406", "0.4760098", "0.47462332", "0.47359782", "0.47350848", "0.4730861", "0.47276577", "0.47258374", "0.47194603", "0.4719082", "0.47128", "0.470744", "0.47023812", "0.4692653", "0.4692503", "0.4692181", "0.46835825", "0.46792305", "0.46722656", "0.46700695" ]
0.7178466
1
ReportMetric adds "n unit" to the reported benchmark results. If the metric is periteration, the caller should divide by b.N, and by convention units should end in "/op". ReportMetric overrides any previously reported value for the same unit. ReportMetric panics if unit is the empty string or if unit contains any whitespace. If unit is a unit normally reported by the benchmark framework itself (such as "allocs/op"), ReportMetric will override that metric. Setting "ns/op" to 0 will suppress that builtin metric.
func (b *B) ReportMetric(n float64, unit string) {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *SysbenchMemory) Report(b *testing.B, output string) {\n\tb.Helper()\n\tresult, err := s.parseOperations(output)\n\tif err != nil {\n\t\tb.Fatalf(\"parsing result %s failed with err: %v\", output, err)\n\t}\n\tReportCustomMetric(b, result, \"memory_operations\" /*metric name*/, \"ops_per_second\" /*unit*/)\n}", "func (o TopicRuleErrorActionCloudwatchMetricOutput) MetricUnit() pulumi.StringOutput {\n\treturn o.ApplyT(func(v TopicRuleErrorActionCloudwatchMetric) string { return v.MetricUnit }).(pulumi.StringOutput)\n}", "func (o TopicRuleCloudwatchMetricOutput) MetricUnit() pulumi.StringOutput {\n\treturn o.ApplyT(func(v TopicRuleCloudwatchMetric) string { return v.MetricUnit }).(pulumi.StringOutput)\n}", "func CountMetric(metric_in, m1Prefix string) (metric_out string) {\n\tv := GetVersion(metric_in)\n\tif v == M20 {\n\t\tparts := strings.Split(metric_in, \".\")\n\t\tfor i, part := range parts {\n\t\t\tif strings.HasPrefix(part, \"unit=\") {\n\t\t\t\tparts[i] = \"unit=Metric\"\n\t\t\t\tparts = append(parts, \"orig_unit=\"+part[5:])\n\t\t\t}\n\t\t\tif strings.HasPrefix(part, \"target_type=\") {\n\t\t\t\tparts[i] = \"target_type=count\"\n\t\t\t}\n\t\t}\n\t\tmetric_out = strings.Join(parts, \".\")\n\t} else if v == M20NoEquals {\n\t\tparts := strings.Split(metric_in, \".\")\n\t\tfor i, part := range parts {\n\t\t\tif strings.HasPrefix(part, \"unit_is_\") {\n\t\t\t\tparts[i] = \"unit_is_Metric\"\n\t\t\t\tparts = append(parts, \"orig_unit_is_\"+part[8:])\n\t\t\t}\n\t\t\tif strings.HasPrefix(part, \"target_type_is_\") {\n\t\t\t\tparts[i] = \"target_type_is_count\"\n\t\t\t}\n\t\t}\n\t\tmetric_out = strings.Join(parts, \".\")\n\t} else {\n\t\tmetric_out = m1Prefix + metric_in + \".count\"\n\t}\n\treturn\n}", "func (o ElastigroupMultipleMetricsMetricOutput) Unit() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupMultipleMetricsMetric) *string { return v.Unit }).(pulumi.StringPtrOutput)\n}", "func (md *pcpMetricDesc) Unit() MetricUnit { return md.u }", "func (o TopicRuleErrorActionCloudwatchMetricPtrOutput) MetricUnit() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *TopicRuleErrorActionCloudwatchMetric) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.MetricUnit\n\t}).(pulumi.StringPtrOutput)\n}", "func (o TopicRuleCloudwatchMetricPtrOutput) MetricUnit() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *TopicRuleCloudwatchMetric) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.MetricUnit\n\t}).(pulumi.StringPtrOutput)\n}", "func (s *SysbenchMutex) Report(b *testing.B, output string) {\n\tb.Helper()\n\n\tresult, err := s.parseExecutionTime(output)\n\tif err != nil {\n\t\tb.Fatalf(\"parsing result %s failed with err: %v\", output, err)\n\t}\n\tReportCustomMetric(b, result, \"average_execution_time\" /*metric name*/, \"s\" /*unit*/)\n\n\tresult, err = s.parseDeviation(output)\n\tif err != nil {\n\t\tb.Fatalf(\"parsing result %s failed with err: %v\", output, err)\n\t}\n\tReportCustomMetric(b, result, \"stddev_execution_time\" /*metric name*/, \"s\" /*unit*/)\n\n\tresult, err = s.parseLatency(output)\n\tif err != nil {\n\t\tb.Fatalf(\"parsing result %s failed with err: %v\", output, err)\n\t}\n\tReportCustomMetric(b, result/1000, \"average_latency\" /*metric name*/, \"s\" /*unit*/)\n}", "func (c *Prometheus) TrackMetricN(section string, operation *bucket.MetricOperation, n int) Client {\n\tb := bucket.NewPrometheus(section, operation, true, c.unicode)\n\tmetric := b.Metric()\n\tmetricTotal := b.MetricTotal()\n\n\tmetricInc := c.getIncrementer(metric)\n\tmetricTotalInc := c.getIncrementer(metricTotal)\n\n\tmetric = c.prepareMetric(metric)\n\tmetricTotal = c.prepareMetric(metricTotal)\n\tmetricInc.IncrementN(metric, n, operation.Labels)\n\tmetricTotalInc.IncrementN(metricTotal, n, operation.Labels)\n\n\treturn c\n}", "func (s *SysbenchCPU) Report(b *testing.B, output string) {\n\tb.Helper()\n\tresult, err := s.parseEvents(output)\n\tif err != nil {\n\t\tb.Fatalf(\"parsing CPU events from %s failed: %v\", output, err)\n\t}\n\tReportCustomMetric(b, result, \"cpu_events\" /*metric name*/, \"events_per_second\" /*unit*/)\n}", "func (p *ProgressBar) Report(uid, n int) {\n\tp.m.Lock()\n\tdefer p.m.Unlock()\n\tvar si *SpeedInfo\n\tif _, ok := p.speeds[uid]; !ok {\n\t\tsi = &SpeedInfo{}\n\t\tp.speeds[uid] = si\n\t} else {\n\t\tsi = p.speeds[uid]\n\t}\n\tsi.Report(n)\n\tp.reports++\n\n\t// Sample sum of averages if we need to.\n\tif p.reports%p.ReportsPerSample == 0 {\n\t\tp.om.Lock()\n\t\tdefer p.om.Unlock()\n\t\tp.overallSpeed = 0.0\n\t\tfor _, si := range p.speeds {\n\t\t\tp.overallSpeed += si.Average()\n\t\t}\n\t}\n}", "func (b *Plain) Metric() string {\n\treturn b.section + \".\" + b.operation\n}", "func (ms MetricDescriptor) Unit() string {\n\treturn (*ms.orig).Unit\n}", "func (ms MetricDescriptor) SetUnit(v string) {\n\t(*ms.orig).Unit = v\n}", "func getPromMetricName(desc *otlp.MetricDescriptor, ns string) string {\n\n\tif desc == nil {\n\t\treturn \"\"\n\t}\n\t// whether _total suffix should be applied\n\tisCounter := desc.Type == otlp.MetricDescriptor_MONOTONIC_INT64 ||\n\t\tdesc.Type == otlp.MetricDescriptor_MONOTONIC_DOUBLE\n\n\tb := strings.Builder{}\n\n\tb.WriteString(ns)\n\n\tif b.Len() > 0 {\n\t\tb.WriteString(delimeter)\n\t}\n\tb.WriteString(desc.GetName())\n\n\t// Including units makes two metrics with the same name and label set belong to two different TimeSeries if the\n\t// units are different.\n\t/*\n\t\tif b.Len() > 0 && len(desc.GetUnit()) > 0{\n\t\t\tfmt.Fprintf(&b, delimeter)\n\t\t\tfmt.Fprintf(&b, desc.GetUnit())\n\t\t}\n\t*/\n\n\tif b.Len() > 0 && isCounter {\n\t\tb.WriteString(delimeter)\n\t\tb.WriteString(totalStr)\n\t}\n\treturn sanitize(b.String())\n}", "func metricString(ns []string) string {\n\treturn strings.Join(ns, \"/\")\n}", "func (s *RunStore) ReportMetric(metric *model.RunMetric) (err error) {\n\tpayloadBytes, err := json.Marshal(metric)\n\tif err != nil {\n\t\treturn util.NewInternalServerError(err,\n\t\t\t\"failed to marshal metric to json: %+v\", metric)\n\t}\n\tsql, args, err := sq.\n\t\tInsert(\"run_metrics\").\n\t\tSetMap(sq.Eq{\n\t\t\t\"RunUUID\": metric.RunUUID,\n\t\t\t\"NodeID\": metric.NodeID,\n\t\t\t\"Name\": metric.Name,\n\t\t\t\"NumberValue\": metric.NumberValue,\n\t\t\t\"Format\": metric.Format,\n\t\t\t\"Payload\": string(payloadBytes)}).ToSql()\n\tif err != nil {\n\t\treturn util.NewInternalServerError(err,\n\t\t\t\"failed to create query for inserting metric: %+v\", metric)\n\t}\n\t_, err = s.db.Exec(sql, args...)\n\tif err != nil {\n\t\tif s.db.IsDuplicateError(err) {\n\t\t\treturn util.NewAlreadyExistError(\n\t\t\t\t\"same metric has been reported before: %s/%s\", metric.NodeID, metric.Name)\n\t\t}\n\t\treturn util.NewInternalServerError(err, \"failed to insert metric: %v\", metric)\n\t}\n\treturn nil\n}", "func TestMetricName(t *testing.T) {\n\ttcs := []struct {\n\t\tprefix string\n\t\tname string\n\t\twantMetric string\n\t\twantLabel string\n\t}{\n\t\t{\n\t\t\tprefix: \"serverStatus.metrics.commands.saslStart.\",\n\t\t\tname: \"total\",\n\t\t\twantMetric: \"mongodb_ss_metrics_commands_saslStart_total\",\n\t\t},\n\t\t{\n\t\t\tprefix: \"serverStatus.metrics.commands._configsvrShardCollection.\",\n\t\t\tname: \"failed\",\n\t\t\twantMetric: \"mongodb_ss_metrics_commands_configsvrShardCollection_failed\",\n\t\t},\n\t\t{\n\t\t\tprefix: \"serverStatus.wiredTiger.lock.\",\n\t\t\tname: \"metadata lock acquisitions\",\n\t\t\twantMetric: \"mongodb_ss_wt_lock_metadata_lock_acquisitions\",\n\t\t},\n\t\t{\n\t\t\tprefix: \"serverStatus.wiredTiger.perf.\",\n\t\t\tname: \"file system write latency histogram (bucket 5) - 500-999ms\",\n\t\t\twantMetric: \"mongodb_ss_wt_perf\",\n\t\t\twantLabel: \"perf_bucket\",\n\t\t},\n\t\t{\n\t\t\tprefix: \"serverStatus.wiredTiger.transaction.\",\n\t\t\tname: \"rollback to stable updates removed from lookaside\",\n\t\t\twantMetric: \"mongodb_ss_wt_txn_rollback_to_stable_updates_removed_from_lookaside\",\n\t\t},\n\t}\n\n\tfor _, tc := range tcs {\n\t\tmetric, label := nameAndLabel(tc.prefix, tc.name)\n\t\tassert.Equal(t, tc.wantMetric, metric, tc.prefix+tc.name)\n\t\tassert.Equal(t, tc.wantLabel, label, tc.prefix+tc.name)\n\t}\n}", "func (o QuotaLimitOutput) Metric() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v QuotaLimit) *string { return v.Metric }).(pulumi.StringPtrOutput)\n}", "func TestGenerateMetricName(t *testing.T) {\n\tpacket := collectd.Packet{\n\t\tPlugin: \"irq\",\n\t\tType: \"irq\",\n\t\tTypeInstance: \"7\",\n\t}\n\tname := coco.MetricName(packet)\n\texpected := 2\n\tactual := strings.Count(name, \"/\")\n\tif actual != expected {\n\t\tt.Errorf(\"Expected %d / separators, got %d\", expected, actual)\n\t}\n\n\tpacket = collectd.Packet{\n\t\tPlugin: \"load\",\n\t\tType: \"load\",\n\t}\n\tname = coco.MetricName(packet)\n\texpected = 1\n\tactual = strings.Count(name, \"/\")\n\tif actual != expected {\n\t\tt.Errorf(\"Expected %d / separators, got %d\", expected, actual)\n\t}\n}", "func (s *StressReport) AddMetric(name string, value float64, unit string) {\n\tif s.Extras == nil {\n\t\ts.Extras = map[string]struct {\n\t\t\tValue float64\n\t\t\tUnit string\n\t\t}{}\n\t}\n\ts.Extras[name] = struct {\n\t\tValue float64\n\t\tUnit string\n\t}{\n\t\tValue: value,\n\t\tUnit: unit,\n\t}\n}", "func (o LogConfigCounterOptionsOutput) Metric() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v LogConfigCounterOptions) *string { return v.Metric }).(pulumi.StringPtrOutput)\n}", "func (o QuotaLimitResponseOutput) Metric() pulumi.StringOutput {\n\treturn o.ApplyT(func(v QuotaLimitResponse) string { return v.Metric }).(pulumi.StringOutput)\n}", "func (o LogConfigCounterOptionsResponseOutput) Metric() pulumi.StringOutput {\n\treturn o.ApplyT(func(v LogConfigCounterOptionsResponse) string { return v.Metric }).(pulumi.StringOutput)\n}", "func (o TopicRuleErrorActionTimestreamTimestampOutput) Unit() pulumi.StringOutput {\n\treturn o.ApplyT(func(v TopicRuleErrorActionTimestreamTimestamp) string { return v.Unit }).(pulumi.StringOutput)\n}", "func (o *DataExportQuery) SetUnit(v string) {\n\to.Unit = &v\n}", "func (o TopicRuleTimestreamTimestampOutput) Unit() pulumi.StringOutput {\n\treturn o.ApplyT(func(v TopicRuleTimestreamTimestamp) string { return v.Unit }).(pulumi.StringOutput)\n}", "func (o MrScalarTaskScalingUpPolicyOutput) Unit() pulumi.StringOutput {\n\treturn o.ApplyT(func(v MrScalarTaskScalingUpPolicy) string { return v.Unit }).(pulumi.StringOutput)\n}", "func testCounterMetric(t *testing.T, reporter *Reporter, m *stats.Int64Measure) {\n\ttotalNumberOfOperations := 2\n\treporter.Report(m.M(1))\n\treporter.Report(m.M(1))\n\trow, err := view.RetrieveData(m.Name())\n\tif err != nil {\n\t\tt.Errorf(\"Error when retrieving data: %v from %v\", err, m.Name())\n\t}\n\n\tcount, ok := row[0].Data.(*view.CountData)\n\tif !ok {\n\t\tt.Error(\"ReportRequest should have aggregation Count()\")\n\t}\n\tif count.Value != int64(totalNumberOfOperations) {\n\t\tt.Errorf(\"Metric: %v - Expected %v, got %v. \", m.Name(), count.Value, totalNumberOfOperations)\n\t}\n}", "func (m *Float64Measure) Unit() string {\n\treturn m.desc.unit\n}", "func (r ApiGetMetricsForBitlinkByDevicesRequest) Unit(unit TimeUnit) ApiGetMetricsForBitlinkByDevicesRequest {\n\tr.unit = &unit\n\treturn r\n}", "func (o MrScalarTaskScalingDownPolicyOutput) Unit() pulumi.StringOutput {\n\treturn o.ApplyT(func(v MrScalarTaskScalingDownPolicy) string { return v.Unit }).(pulumi.StringOutput)\n}", "func OpMetrics(w http.ResponseWriter, r *http.Request) {\n\n\t// Init output\n\toutput := []byte(\"\")\n\n\t// Add content type header to the response\n\tcontentType := \"application/json\"\n\tcharset := \"utf-8\"\n\tw.Header().Add(\"Content-Type\", fmt.Sprintf(\"%s; charset=%s\", contentType, charset))\n\n\t// Grab context references\n\trefStr := gorillaContext.Get(r, \"str\").(stores.Store)\n\n\t// Get Results Object\n\tres, err := metrics.GetUsageCpuMem(refStr)\n\n\tif err != nil && err.Error() != \"not found\" {\n\t\terr := APIErrQueryDatastore()\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\t// Output result to JSON\n\tresJSON, err := res.ExportJSON()\n\n\tif err != nil {\n\t\terr := APIErrExportJSON()\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\t// Write response\n\toutput = []byte(resJSON)\n\trespondOK(w, output)\n\n}", "func (o MrScalarCoreScalingUpPolicyOutput) Unit() pulumi.StringOutput {\n\treturn o.ApplyT(func(v MrScalarCoreScalingUpPolicy) string { return v.Unit }).(pulumi.StringOutput)\n}", "func (b *Plain) MetricWithSuffix() string {\n\treturn b.section + \"-\" + operationsStatus[b.success] + \".\" + b.operation\n}", "func (o LogConfigCounterOptionsPtrOutput) Metric() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *LogConfigCounterOptions) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Metric\n\t}).(pulumi.StringPtrOutput)\n}", "func NewMetricUnit() MetricUnit {\n\treturn &metricUnit{}\n}", "func RecordVolumeOperationMetric(pluginName, opName string, timeTaken float64, err error) {\n\tif pluginName == \"\" {\n\t\tpluginName = \"N/A\"\n\t}\n\tif err != nil {\n\t\tvolumeOperationErrorsMetric.WithLabelValues(pluginName, opName).Inc()\n\t\treturn\n\t}\n\tvolumeOperationMetric.WithLabelValues(pluginName, opName).Observe(timeTaken)\n}", "func metricName(s string) string {\n\treturn strings.ReplaceAll(s, \"/\", \"_\")\n}", "func (o MrScalarCoreScalingDownPolicyOutput) Unit() pulumi.StringOutput {\n\treturn o.ApplyT(func(v MrScalarCoreScalingDownPolicy) string { return v.Unit }).(pulumi.StringOutput)\n}", "func (s *HistoricalMetric) SetUnit(v string) *HistoricalMetric {\n\ts.Unit = &v\n\treturn s\n}", "func MetricName(measurement, fieldKey string, valueType telegraf.ValueType) string {\n\tswitch valueType {\n\tcase telegraf.Histogram, telegraf.Summary:\n\t\tswitch {\n\t\tcase strings.HasSuffix(fieldKey, \"_bucket\"):\n\t\t\tfieldKey = strings.TrimSuffix(fieldKey, \"_bucket\")\n\t\tcase strings.HasSuffix(fieldKey, \"_sum\"):\n\t\t\tfieldKey = strings.TrimSuffix(fieldKey, \"_sum\")\n\t\tcase strings.HasSuffix(fieldKey, \"_count\"):\n\t\t\tfieldKey = strings.TrimSuffix(fieldKey, \"_count\")\n\t\t}\n\t}\n\n\tif measurement == \"prometheus\" {\n\t\treturn fieldKey\n\t}\n\treturn measurement + \"_\" + fieldKey\n}", "func (s *CurrentMetric) SetUnit(v string) *CurrentMetric {\n\ts.Unit = &v\n\treturn s\n}", "func (o ObjectMetricStatusOutput) MetricName() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ObjectMetricStatus) string { return v.MetricName }).(pulumi.StringOutput)\n}", "func (s *SpeedInfo) Report(n int) {\n\tif s.init && time.Since(s.last).Nanoseconds() == 0 {\n\t\t// If the call since last time is too fast, Since() might evaluate\n\t\t// to literally 0, so if that's the case, buffer n and wait for the\n\t\t// next call.\n\t\ts.buf += n\n\t\treturn\n\t}\n\n\tif s.reports == nil {\n\t\tif s.reportCount == 0 {\n\t\t\ts.reportCount = defaultReportCount\n\t\t}\n\n\t\ts.reports = ring.New(s.reportCount)\n\t}\n\n\tif s.init {\n\t\ts.buf = 0\n\t\ts.reports.Value = float64(n) / time.Since(s.last).Seconds()\n\t\ts.reports = s.reports.Next()\n\t} else {\n\t\ts.init = true\n\t}\n\n\ts.last = time.Now()\n}", "func (o ElastigroupScalingUpPolicyOutput) Unit() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupScalingUpPolicy) *string { return v.Unit }).(pulumi.StringPtrOutput)\n}", "func (o ObjectMetricStatusPatchOutput) MetricName() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ObjectMetricStatusPatch) *string { return v.MetricName }).(pulumi.StringPtrOutput)\n}", "func ProcessMetric(metric *Metric, flushDuration time.Duration, quantiles []int, logger Logger) {\n\tflushInterval := flushDuration / time.Second\n\n\tsort.Sort(metric.AllValues)\n\tswitch metric.MetricType {\n\tcase MetricTypeCounter:\n\t\tmetric.ValuesPerSecond = metric.LastValue / float64(flushInterval)\n\tcase MetricTypeGauge:\n\t\tmetric.MedianValue = metric.AllValues.Median()\n\t\tmetric.MeanValue = metric.AllValues.Mean()\n\tcase MetricTypeSet:\n\t\tmetric.LastValue = float64(metric.AllValues.UniqueCount())\n\tcase MetricTypeTimer:\n\t\tmetric.MinValue, metric.MaxValue, _ = metric.AllValues.Minmax()\n\t\tmetric.MedianValue = metric.AllValues.Median()\n\t\tmetric.MeanValue = metric.AllValues.Mean()\n\t\tmetric.ValuesPerSecond = metric.TotalHits / float64(flushInterval)\n\n\t\tmetric.Quantiles = make([]MetricQuantile, 0)\n\t\tfor _, q := range quantiles {\n\t\t\tpercentile := float64(q) / float64(100)\n\t\t\tquantile := new(MetricQuantile)\n\t\t\tquantile.Quantile = q\n\n\t\t\t// Make calculations based on the desired quantile.\n\t\t\tquantile.Boundary = metric.AllValues.Quantile(percentile)\n\t\t\tfor _, value := range metric.AllValues {\n\t\t\t\tif value > quantile.Boundary {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tquantile.AllValues = append(quantile.AllValues, value)\n\t\t\t}\n\t\t\t_, quantile.Max, _ = quantile.AllValues.Minmax()\n\t\t\tquantile.Mean = quantile.AllValues.Mean()\n\t\t\tquantile.Median = quantile.AllValues.Median()\n\t\t\tquantile.Sum = quantile.AllValues.Sum()\n\t\t\tmetric.Quantiles = append(metric.Quantiles, *quantile)\n\t\t}\n\t}\n}", "func (nam KubeNodeStatusCapacityMemoryBytesMetric) Write(m *dto.Metric) error {\n\tm.Gauge = &dto.Gauge{\n\t\tValue: &nam.bytes,\n\t}\n\tm.Label = []*dto.LabelPair{\n\t\t{\n\t\t\tName: toStringPtr(\"node\"),\n\t\t\tValue: &nam.node,\n\t\t},\n\t}\n\treturn nil\n}", "func (p *parser) metric() labels.Labels {\n\tname := \"\"\n\tvar m labels.Labels\n\n\tt := p.peek().typ\n\tif t == itemIdentifier || t == itemMetricIdentifier {\n\t\tname = p.next().val\n\t\tt = p.peek().typ\n\t}\n\tif t != itemLeftBrace && name == \"\" {\n\t\tp.errorf(\"missing metric name or metric selector\")\n\t}\n\tif t == itemLeftBrace {\n\t\tm = p.labelSet()\n\t}\n\tif name != \"\" {\n\t\tm = append(m, labels.Label{Name: labels.MetricName, Value: name})\n\t\tsort.Sort(m)\n\t}\n\treturn m\n}", "func (m Metric) String() string {\n\tswitch m {\n\tcase MetricCPUPercentAllocation:\n\t\treturn \"cpu_percent_allocation\"\n\tcase MetricGPUPercentAllocation:\n\t\treturn \"gpu_percent_allocation\"\n\tcase MetricMemoryPercentAllocation:\n\t\treturn \"memory_percent_allocation\"\n\tcase MetricEphemeralStoragePercentAllocation:\n\t\treturn \"ephemeral_storage_percent_allocation\"\n\tcase MetricPodPercentAllocation:\n\t\treturn \"pod_percent_allocation\"\n\t}\n\n\treturn \"unknown\"\n}", "func (r ApiGetMetricsForBitlinkByReferrersRequest) Unit(unit TimeUnit) ApiGetMetricsForBitlinkByReferrersRequest {\n\tr.unit = &unit\n\treturn r\n}", "func TestMetric(value interface{}, name ...string) optic.Metric {\n\tif value == nil {\n\t\tpanic(\"Cannot use a nil value\")\n\t}\n\tnamespace := \"test1\"\n\tif len(name) > 0 {\n\t\tnamespace = name[0]\n\t}\n\ttags := map[string]string{\"tag1\": \"value1\"}\n\tm, _ := metric.New(\n\t\tnamespace,\n\t\ttags,\n\t\tmap[string]interface{}{\"value\": value},\n\t\ttime.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),\n\t)\n\treturn m\n}", "func (o ElastigroupScalingDownPolicyOutput) Unit() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupScalingDownPolicy) *string { return v.Unit }).(pulumi.StringPtrOutput)\n}", "func (s *GeoDistanceSort) Unit(unit string) *GeoDistanceSort {\n\ts.unit = unit\n\treturn s\n}", "func testOperationDurationMetric(t *testing.T, reporter *Reporter, m *stats.Float64Measure) {\n\tminimumDuration := float64(2)\n\tmaximumDuration := float64(4)\n\ttestOperationKey := \"test\"\n\terr := reporter.ReportOperation(testOperationKey, m.M(minimumDuration))\n\tif err != nil {\n\t\tt.Errorf(\"Error when reporting metrics: %v from %v\", err, m.Name())\n\t}\n\terr = reporter.ReportOperation(testOperationKey, m.M(maximumDuration))\n\tif err != nil {\n\t\tt.Errorf(\"Error when reporting metrics: %v from %v\", err, m.Name())\n\t}\n\n\trow, err := view.RetrieveData(m.Name())\n\tif err != nil {\n\t\tt.Errorf(\"Error when retrieving data: %v from %v\", err, m.Name())\n\t}\n\n\tduration, ok := row[0].Data.(*view.DistributionData)\n\tif !ok {\n\t\tt.Error(\"DistributionData missing\")\n\t}\n\n\ttag := row[0].Tags[0]\n\tif tag.Key.Name() != operationTypeKey.Name() && tag.Value != testOperationKey {\n\t\tt.Errorf(\"Tag does not match for %v\", operationTypeKey.Name())\n\t}\n\tif duration.Min != minimumDuration {\n\t\tt.Errorf(\"Metric: %v - Expected %v, got %v. \", m.Name(), duration.Min, minimumDuration)\n\t}\n\tif duration.Max != maximumDuration {\n\t\tt.Errorf(\"Metric: %v - Expected %v, got %v. \", m.Name(), duration.Max, maximumDuration)\n\t}\n}", "func ReportFailure(action string, label string) {\n\tactionlabel := getLabel(action, label)\n\tif metricEnabled() {\n\t\tmetrics.GopherActions.WithLabelValues(\"failure\", actionlabel).Inc()\n\t}\n}", "func (r *Rule) MetricName() pulumi.StringOutput {\n\treturn (pulumi.StringOutput)(r.s.State[\"metricName\"])\n}", "func ReportAPIRequestMetric(handler, method, status string, started time.Time) {\n\trequestsTotalAPI.WithLabelValues(handler, method, status).Inc()\n\trequestLatencyAPI.WithLabelValues(handler, method, status).Observe(time.Since(started).Seconds())\n}", "func (o PodsMetricStatusPatchOutput) MetricName() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v PodsMetricStatusPatch) *string { return v.MetricName }).(pulumi.StringPtrOutput)\n}", "func (o ElastigroupScalingTargetPolicyOutput) Unit() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupScalingTargetPolicy) *string { return v.Unit }).(pulumi.StringPtrOutput)\n}", "func (o SecurityProfileBehaviorOutput) Metric() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v SecurityProfileBehavior) *string { return v.Metric }).(pulumi.StringPtrOutput)\n}", "func (r BenchmarkResult) MemString() string {}", "func (o ElastigroupIntegrationNomadAutoscaleHeadroomOutput) MemoryPerUnit() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupIntegrationNomadAutoscaleHeadroom) *int { return v.MemoryPerUnit }).(pulumi.IntPtrOutput)\n}", "func (o AutoscalingPolicyCustomMetricUtilizationResponseOutput) Metric() pulumi.StringOutput {\n\treturn o.ApplyT(func(v AutoscalingPolicyCustomMetricUtilizationResponse) string { return v.Metric }).(pulumi.StringOutput)\n}", "func (r *Reporter) Report() {\n\t//---------------------------------------------------\n\t// Report to console\n\t//---------------------------------------------------\n\tsort.Ints(r.nOrderPerSec)\n\tsort.Ints(r.nRequestPerSec)\n\tnOrderPerSecMax := MeanOfMaxFive(r.nOrderPerSec)\n\tnOrderPerSecMin := MeanOfMinFive(r.nOrderPerSec)\n\tnOrderPerSecMean := Mean(r.nOrderPerSec)\n\tnRequestPerSecMax := MeanOfMaxFive(r.nRequestPerSec)\n\tnRequestPerSecMin := MeanOfMinFive(r.nRequestPerSec)\n\tnRequestPerSecMean := Mean(r.nRequestPerSec)\n\tsort.Ints(r.nRequestPerSec)\n\tpayCostNanoseconds := []float64{}\n\tfor i := 0; i < len(r.payCosts); i++ {\n\t\tpayCostNanoseconds = append(payCostNanoseconds, float64(r.payCosts[i].Nanoseconds()))\n\t}\n\tsort.Float64s(payCostNanoseconds)\n\tmsTakenTotal := int(r.elapsed.Nanoseconds() / 1000000.0)\n\tmsPerOrder := MeanFloat64(payCostNanoseconds) / 1000000.0\n\tmsPerRequest := SumFloat64(payCostNanoseconds) / 1000000.0 / float64(r.nRequestOk)\n\t//---------------------------------------------------\n\t// Report to console\n\t//---------------------------------------------------\n\tfmt.Print(\"\\nStats\\n\")\n\tfmt.Printf(\"Concurrency level: %d\\n\", r.cocurrency)\n\tfmt.Printf(\"Time taken for tests: %dms\\n\", msTakenTotal)\n\tfmt.Printf(\"Complete requests: %d\\n\", r.nRequestOk)\n\tfmt.Printf(\"Failed requests: %d\\n\", r.nRequestErr)\n\tfmt.Printf(\"Complete orders: %d\\n\", r.nOrderOk)\n\tfmt.Printf(\"Failed orders: %d\\n\", r.nOrderErr)\n\tfmt.Printf(\"Time per request: %.2fms\\n\", msPerRequest)\n\tfmt.Printf(\"Time per order: %.2fms\\n\", msPerOrder)\n\tfmt.Printf(\"Request per second: %d (max) %d (min) %d(mean)\\n\", nRequestPerSecMax, nRequestPerSecMin, nRequestPerSecMean)\n\tfmt.Printf(\"Order per second: %d (max) %d (min) %d (mean)\\n\\n\", nOrderPerSecMax, nOrderPerSecMin, nOrderPerSecMean)\n\tfmt.Printf(\"Percentage of orders made within a certain time (ms)\\n\")\n\tif len(payCostNanoseconds) == 0 {\n\t\treturn\n\t}\n\tpercentages := []float64{10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 95.5, 96, 96.5, 97, 97.5, 98, 98.5, 99, 99.9, 99.99, 100}\n\tfor _, percentage := range percentages {\n\t\tidx := int(percentage * float64(len(payCostNanoseconds)) / float64(100.0))\n\t\tif idx > 0 {\n\t\t\tidx = idx - 1\n\t\t} else {\n\t\t\tidx = 0\n\t\t}\n\t\tpayCostNanosecond := payCostNanoseconds[idx]\n\t\tfmt.Printf(\"%.2f%%\\t%d ms\\n\", percentage, int(payCostNanosecond/1000000.0))\n\t}\n}", "func (c *Prometheus) TrackOperationN(section string, operation *bucket.MetricOperation, t timer.Timer, n int, success bool) Client {\n\tb := bucket.NewPrometheus(section, operation, success, c.unicode)\n\n\tif operation.Labels == nil {\n\t\toperation.Labels = map[string]string{\"success\": strconv.FormatBool(success)}\n\t} else {\n\t\toperation.Labels[\"success\"] = strconv.FormatBool(success)\n\t}\n\n\tc.TrackMetricN(section, operation, n)\n\n\tif nil != t {\n\t\tvar values []string\n\n\t\th := c.getHistogram(c.prepareMetric(b.Metric()), operation.Labels)\n\t\tfor _, value := range operation.Labels {\n\t\t\tvalues = append(values, value)\n\t\t}\n\t\th.WithLabelValues(values...).Observe(float64(t.Finish() / time.Millisecond))\n\t}\n\n\treturn c\n}", "func ReportWarning(action string, label string) {\n\tactionlabel := getLabel(action, label)\n\tif metricEnabled() {\n\t\tmetrics.GopherWarnings.WithLabelValues(actionlabel).Inc()\n\t}\n}", "func (s *Server) processMetricPacket(numBytes int, buf []byte, packetPool *sync.Pool, protocolType ProtocolType) {\n\tif numBytes > s.metricMaxLength {\n\t\tmetrics.ReportOne(s.TraceClient, ssf.Count(\"packet.error_total\", 1, map[string]string{\"packet_type\": \"unknown\", \"reason\": \"toolong\"}))\n\t\treturn\n\t}\n\n\t// statsd allows multiple packets to be joined by newlines and sent as\n\t// one larger packet\n\t// note that spurious newlines are not allowed in this format, it has\n\t// to be exactly one newline between each packet, with no leading or\n\t// trailing newlines\n\tsplitPacket := samplers.NewSplitBytes(buf[:numBytes], '\\n')\n\tfor splitPacket.Next() {\n\t\ts.HandleMetricPacket(splitPacket.Chunk(), protocolType)\n\t}\n\n\t//Only return to the pool if there is a pool\n\tif packetPool != nil {\n\t\t// the Metric struct created by HandleMetricPacket has no byte slices in it,\n\t\t// only strings\n\t\t// therefore there are no outstanding references to this byte slice, we\n\t\t// can return it to the pool\n\t\tpacketPool.Put(buf)\n\t}\n}", "func (o PodsMetricStatusOutput) MetricName() pulumi.StringOutput {\n\treturn o.ApplyT(func(v PodsMetricStatus) string { return v.MetricName }).(pulumi.StringOutput)\n}", "func (s *TtlDuration) SetUnit(v string) *TtlDuration {\n\ts.Unit = &v\n\treturn s\n}", "func TestMakeRawMetric(t *testing.T) {\n\tprefix := \"serverStatus.transactions.\"\n\tname := \"retriedCommandsCount\"\n\ttestCases := []struct {\n\t\tvalue interface{}\n\t\twantVal *float64\n\t}{\n\t\t{value: true, wantVal: pointer.ToFloat64(1)},\n\t\t{value: false, wantVal: pointer.ToFloat64(0)},\n\t\t{value: int32(1), wantVal: pointer.ToFloat64(1)},\n\t\t{value: int64(2), wantVal: pointer.ToFloat64(2)},\n\t\t{value: float32(1.23), wantVal: pointer.ToFloat64(float64(float32(1.23)))},\n\t\t{value: float64(1.23), wantVal: pointer.ToFloat64(1.23)},\n\t\t{value: primitive.A{}, wantVal: nil},\n\t\t{value: primitive.Timestamp{}, wantVal: nil},\n\t\t{value: \"zapp\", wantVal: nil},\n\t\t{value: []byte{}, wantVal: nil},\n\t\t{value: time.Date(2020, 06, 15, 0, 0, 0, 0, time.UTC), wantVal: nil},\n\t}\n\n\tln := make([]string, 0) // needs pre-allocation to accomplish pre-allocation for labels\n\tlv := make([]string, 0)\n\n\tfqName := prometheusize(prefix + name)\n\thelp := metricHelp(prefix, name)\n\n\tfor _, tc := range testCases {\n\t\tvar want *rawMetric\n\t\tif tc.wantVal != nil {\n\t\t\twant = &rawMetric{\n\t\t\t\tfqName: fqName,\n\t\t\t\thelp: help,\n\t\t\t\tln: ln,\n\t\t\t\tlv: lv,\n\t\t\t\tval: *tc.wantVal,\n\t\t\t\tvt: 3,\n\t\t\t}\n\t\t}\n\n\t\tm, err := makeRawMetric(prefix, name, tc.value, nil)\n\n\t\tassert.NoError(t, err)\n\t\tassert.Equal(t, want, m)\n\t}\n}", "func (o TopicRuleErrorActionTimestreamTimestampPtrOutput) Unit() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *TopicRuleErrorActionTimestreamTimestamp) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.Unit\n\t}).(pulumi.StringPtrOutput)\n}", "func TestStat(t *testing.T) {\n\tcases := []Case{\n\t\t// metrics 2.0 cases with equals\n\t\t{\"foo.bar.unit=yes.baz\", \"prefix.\", \"\", \"ignored\", \"foo.bar.unit=yes.baz.stat=max_90\"},\n\t\t{\"foo.bar.unit=yes\", \"prefix.\", \"our=prefix.\", \"ignored\", \"our=prefix.foo.bar.unit=yes.stat=max_90\"},\n\t\t{\"unit=yes.foo.bar\", \"prefix.\", \"\", \"ignored\", \"unit=yes.foo.bar.stat=max_90\"},\n\t\t{\"mtype=count.foo.unit=ok.bar\", \"prefix.\", \"\", \"ignored\", \"mtype=count.foo.unit=ok.bar.stat=max_90\"},\n\t\t// metrics 2.0 cases without equals\n\t\t{\"foo.bar.unit_is_yes.baz\", \"prefix.\", \"ignored\", \"\", \"foo.bar.unit_is_yes.baz.stat_is_max_90\"},\n\t\t{\"foo.bar.unit_is_yes\", \"prefix.\", \"ignored\", \"our_is_prefix.\", \"our_is_prefix.foo.bar.unit_is_yes.stat_is_max_90\"},\n\t\t{\"unit_is_yes.foo.bar\", \"prefix.\", \"ignored\", \"\", \"unit_is_yes.foo.bar.stat_is_max_90\"},\n\t\t{\"mtype_is_count.foo.unit_is_ok.bar\", \"prefix.\", \"ignored\", \"\", \"mtype_is_count.foo.unit_is_ok.bar.stat_is_max_90\"},\n\t}\n\tfor _, c := range cases {\n\t\tassert.Equal(t, Max(c.in, c.p1, c.p2, c.p2ne, \"90\", \"\"), c.out)\n\t}\n\t// same but without percentile\n\tfor i, c := range cases {\n\t\tcases[i].out = strings.Replace(c.out, \"max_90\", \"max\", 1)\n\t}\n\tfor _, c := range cases {\n\t\tassert.Equal(t, Max(c.in, c.p1, c.p2, c.p2ne, \"\", \"\"), c.out)\n\t}\n}", "func fillMetric(kind string, dfm dfMetric, metric *plugin.MetricType) {\n\tswitch kind {\n\tcase \"space_free\":\n\t\tmetric.Data_ = dfm.Available\n\tcase \"space_reserved\":\n\t\tmetric.Data_ = dfm.Blocks - (dfm.Used + dfm.Available)\n\tcase \"space_used\":\n\t\tmetric.Data_ = dfm.Used\n\tcase \"space_percent_free\":\n\t\tmetric.Data_ = 100 * float64(dfm.Available) / float64(dfm.Blocks)\n\tcase \"space_percent_reserved\":\n\t\tmetric.Data_ = 100 * float64(dfm.Blocks-(dfm.Used+dfm.Available)) / float64(dfm.Blocks)\n\tcase \"space_percent_used\":\n\t\tmetric.Data_ = 100 * float64(dfm.Used) / float64(dfm.Blocks)\n\tcase \"device_name\":\n\t\tmetric.Data_ = dfm.Filesystem\n\tcase \"device_type\":\n\t\tmetric.Data_ = dfm.FsType\n\tcase \"inodes_free\":\n\t\tmetric.Data_ = dfm.IFree\n\tcase \"inodes_reserved\":\n\t\tmetric.Data_ = dfm.Inodes - (dfm.IUsed + dfm.IFree)\n\tcase \"inodes_used\":\n\t\tmetric.Data_ = dfm.IUsed\n\tcase \"inodes_percent_free\":\n\t\tmetric.Data_ = 100 * float64(dfm.IFree) / float64(dfm.Inodes)\n\tcase \"inodes_percent_reserved\":\n\t\tmetric.Data_ = 100 * float64(dfm.Inodes-(dfm.IUsed+dfm.IFree)) / float64(dfm.Inodes)\n\tcase \"inodes_percent_used\":\n\t\tmetric.Data_ = 100 * float64(dfm.IUsed) / float64(dfm.Inodes)\n\t}\n}", "func (s *actions) Report(action string) Stats {\n\ts.lock.RLock()\n\tdefer s.lock.RUnlock()\n\n\tif m, ok := s.metrics[action]; ok {\n\t\treturn m.stats(action)\n\t}\n\n\treturn EmptyStats(action)\n}", "func (o AutoscalingPolicyCustomMetricUtilizationOutput) Metric() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v AutoscalingPolicyCustomMetricUtilization) *string { return v.Metric }).(pulumi.StringPtrOutput)\n}", "func (r BenchmarkResult) String() string {}", "func CountPckt(metric_in, m1Prefix string) (metric_out string) {\n\tv := GetVersion(metric_in)\n\tif v == M20 {\n\t\tparts := strings.Split(metric_in, \".\")\n\t\tfor i, part := range parts {\n\t\t\tif strings.HasPrefix(part, \"unit=\") {\n\t\t\t\tparts[i] = \"unit=Pckt\"\n\t\t\t\tparts = append(parts, \"orig_unit=\"+part[5:])\n\t\t\t}\n\t\t\tif strings.HasPrefix(part, \"target_type=\") {\n\t\t\t\tparts[i] = \"target_type=count\"\n\t\t\t}\n\t\t}\n\t\tparts = append(parts, \"pckt_type=sent\")\n\t\tparts = append(parts, \"direction=in\")\n\t\tmetric_out = strings.Join(parts, \".\")\n\t} else if v == M20NoEquals {\n\t\tparts := strings.Split(metric_in, \".\")\n\t\tfor i, part := range parts {\n\t\t\tif strings.HasPrefix(part, \"unit_is_\") {\n\t\t\t\tparts[i] = \"unit_is_Pckt\"\n\t\t\t\tparts = append(parts, \"orig_unit_is_\"+part[8:])\n\t\t\t}\n\t\t\tif strings.HasPrefix(part, \"target_type_is_\") {\n\t\t\t\tparts[i] = \"target_type_is_count\"\n\t\t\t}\n\t\t}\n\t\tparts = append(parts, \"pckt_type_is_sent\")\n\t\tparts = append(parts, \"direction_is_in\")\n\t\tmetric_out = strings.Join(parts, \".\")\n\t} else {\n\t\tmetric_out = m1Prefix + metric_in + \".count\"\n\t}\n\treturn\n}", "func (tuo *TimingUpdateOne) SetUnit(s string) *TimingUpdateOne {\n\ttuo.mutation.SetUnit(s)\n\treturn tuo\n}", "func (p *PerformanceDataPoint) SetUnit(unit string) *PerformanceDataPoint {\n\tp.Unit = unit\n\treturn p\n}", "func (op *Operation) emitMetrics(err *error, count, elapsed float64, labels []string) {\n\tif op.metrics == nil {\n\t\treturn\n\t}\n\n\top.metrics.Observe(elapsed, count, err, labels...)\n}", "func (op *Operation) emitMetrics(err *error, count, elapsed float64, labels []string) {\n\tif op.metrics == nil {\n\t\treturn\n\t}\n\n\top.metrics.Observe(elapsed, count, err, labels...)\n}", "func (o ExternalMetricStatusPatchOutput) MetricName() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ExternalMetricStatusPatch) *string { return v.MetricName }).(pulumi.StringPtrOutput)\n}", "func (o TopicRuleTimestreamTimestampPtrOutput) Unit() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *TopicRuleTimestreamTimestamp) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.Unit\n\t}).(pulumi.StringPtrOutput)\n}", "func simpleStat(metric_in, m1Prefix, stat1, stat2, percentile, timespec string) (metric_out string) {\n\tif percentile != \"\" {\n\t\tpercentile = \"_\" + percentile\n\t}\n\tif timespec != \"\" {\n\t\ttimespec = \"__\" + timespec\n\t}\n\tv := GetVersion(metric_in)\n\tif v == M20 {\n\t\treturn metric_in + \".stat=\" + stat2 + percentile + timespec\n\t}\n\tif v == M20NoEquals {\n\t\treturn metric_in + \".stat_is_\" + stat2 + percentile + timespec\n\t}\n\treturn m1Prefix + metric_in + \".\" + stat1 + percentile + timespec\n}", "func (*systemPodMetricsMeasurement) String() string {\n\treturn systemPodMetricsName\n}", "func (w *Writer) WriteMeter() (n int, d time.Duration) {\n\tw.Lock()\n\tdefer w.Unlock()\n\n\tn = w.n\n\td = w.d\n\tw.n = 0\n\tw.d = 0\n\treturn\n}", "func ParseMetric(input string) (m labels.Labels, err error) {\n\tp := newParser(input)\n\tdefer p.recover(&err)\n\n\tm = p.metric()\n\tif p.peek().typ != itemEOF {\n\t\tp.errorf(\"could not parse remaining input %.15q...\", p.lex.input[p.lex.lastPos:])\n\t}\n\treturn m, nil\n}", "func Count(metric_in, m1Prefix string) (metric_out string) {\n\tv := GetVersion(metric_in)\n\tif v == M20 {\n\t\tparts := strings.Split(metric_in, \".\")\n\t\tttSeen := false\n\t\tfor i, part := range parts {\n\t\t\tif strings.HasPrefix(part, \"target_type=\") {\n\t\t\t\tttSeen = true\n\t\t\t\tparts[i] = \"target_type=count\"\n\t\t\t}\n\t\t}\n\t\tif !ttSeen {\n\t\t\tparts = append(parts, \"target_type=count\")\n\t\t}\n\t\tmetric_out = strings.Join(parts, \".\")\n\t} else if v == M20NoEquals {\n\t\tparts := strings.Split(metric_in, \".\")\n\t\tttSeen := false\n\t\tfor i, part := range parts {\n\t\t\tif strings.HasPrefix(part, \"target_type_is_\") {\n\t\t\t\tttSeen = true\n\t\t\t\tparts[i] = \"target_type_is_count\"\n\t\t\t}\n\t\t}\n\t\tif !ttSeen {\n\t\t\tparts = append(parts, \"target_type_is_count\")\n\t\t}\n\t\tmetric_out = strings.Join(parts, \".\")\n\t} else {\n\t\tmetric_out = m1Prefix + metric_in + \".count\"\n\t}\n\treturn\n}", "func (o ExternalMetricStatusOutput) MetricName() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ExternalMetricStatus) string { return v.MetricName }).(pulumi.StringOutput)\n}", "func (r ApiGetMetricsForBitlinkByReferringDomainsRequest) Unit(unit TimeUnit) ApiGetMetricsForBitlinkByReferringDomainsRequest {\n\tr.unit = &unit\n\treturn r\n}", "func (o ElastigroupMultipleMetricsMetricOutput) MetricName() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ElastigroupMultipleMetricsMetric) string { return v.MetricName }).(pulumi.StringOutput)\n}", "func (s *Scale) SetUnit(v string) *Scale {\n\ts.Unit = &v\n\treturn s\n}", "func (b *Plain) MetricTotalWithSuffix() string {\n\treturn totalBucket + \".\" + b.section + \"-\" + operationsStatus[b.success]\n}", "func (o SecurityProfileMetricToRetainOutput) Metric() pulumi.StringOutput {\n\treturn o.ApplyT(func(v SecurityProfileMetricToRetain) string { return v.Metric }).(pulumi.StringOutput)\n}", "func (m Metrics) MetricStruct() {}", "func (o ElastigroupIntegrationKubernetesAutoscaleHeadroomOutput) MemoryPerUnit() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupIntegrationKubernetesAutoscaleHeadroom) *int { return v.MemoryPerUnit }).(pulumi.IntPtrOutput)\n}", "func NewMetric(asset, method string, backend MetricsBackend) Metric {\n\tm := Metric{}\n\n\tm.backend = backend\n\tm.methodName = method\n\tm.startTime = time.Now()\n\tm.asset = asset\n\n\tm.backend.AddMethod(m.asset, method)\n\treturn m\n}" ]
[ "0.61145514", "0.58451915", "0.5774043", "0.5726405", "0.5541881", "0.5441088", "0.5394693", "0.5334652", "0.5093722", "0.50429195", "0.50089675", "0.5003965", "0.4981386", "0.49562517", "0.49305192", "0.48886535", "0.48771197", "0.4864596", "0.4826988", "0.48240182", "0.48093677", "0.48086682", "0.47724107", "0.47461691", "0.46901518", "0.46852607", "0.46635583", "0.46612954", "0.46572742", "0.46436718", "0.4638473", "0.4628488", "0.4622761", "0.4618643", "0.46039262", "0.46035308", "0.45971575", "0.4593355", "0.45819163", "0.4573166", "0.4560441", "0.4553744", "0.45521966", "0.4550224", "0.4507799", "0.44898883", "0.44827378", "0.44810274", "0.44538397", "0.4445453", "0.44314447", "0.4428235", "0.44269916", "0.44153166", "0.44070432", "0.43953195", "0.4391273", "0.438529", "0.4375053", "0.43641156", "0.43637222", "0.435683", "0.43564016", "0.4353997", "0.4352867", "0.43494493", "0.43455085", "0.43425936", "0.43320882", "0.43255043", "0.43136245", "0.4306098", "0.42980114", "0.42970255", "0.42911223", "0.42892417", "0.4287351", "0.42829794", "0.42770466", "0.4276686", "0.42694205", "0.4268892", "0.42673713", "0.42673713", "0.4266383", "0.4262116", "0.4261639", "0.42614284", "0.42516664", "0.42407075", "0.42406663", "0.4238498", "0.4237834", "0.42340198", "0.42334688", "0.4229936", "0.4229148", "0.4228988", "0.42286983", "0.4228608" ]
0.70846057
0
NsPerOp returns the "ns/op" metric.
func (r BenchmarkResult) NsPerOp() int64 {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getPromMetricName(desc *otlp.MetricDescriptor, ns string) string {\n\n\tif desc == nil {\n\t\treturn \"\"\n\t}\n\t// whether _total suffix should be applied\n\tisCounter := desc.Type == otlp.MetricDescriptor_MONOTONIC_INT64 ||\n\t\tdesc.Type == otlp.MetricDescriptor_MONOTONIC_DOUBLE\n\n\tb := strings.Builder{}\n\n\tb.WriteString(ns)\n\n\tif b.Len() > 0 {\n\t\tb.WriteString(delimeter)\n\t}\n\tb.WriteString(desc.GetName())\n\n\t// Including units makes two metrics with the same name and label set belong to two different TimeSeries if the\n\t// units are different.\n\t/*\n\t\tif b.Len() > 0 && len(desc.GetUnit()) > 0{\n\t\t\tfmt.Fprintf(&b, delimeter)\n\t\t\tfmt.Fprintf(&b, desc.GetUnit())\n\t\t}\n\t*/\n\n\tif b.Len() > 0 && isCounter {\n\t\tb.WriteString(delimeter)\n\t\tb.WriteString(totalStr)\n\t}\n\treturn sanitize(b.String())\n}", "func Namespace(iops *v1alpha1.IstioOperatorSpec) string {\n\tif iops.Namespace != \"\" {\n\t\treturn iops.Namespace\n\t}\n\tif iops.Values == nil {\n\t\treturn \"\"\n\t}\n\tif iops.Values[globalKey] == nil {\n\t\treturn \"\"\n\t}\n\tv := iops.Values[globalKey].(map[string]interface{})\n\tn := v[istioNamespaceKey]\n\tif n == nil {\n\t\treturn \"\"\n\t}\n\treturn n.(string)\n}", "func (k *k8sUtil) NS() (string, error) {\n\tif nil == k.volProfile {\n\t\treturn \"\", fmt.Errorf(\"Volume provisioner profile not initialized at '%s'\", k.Name())\n\t}\n\n\t// Fetch pvc from volume provisioner profile\n\tpvc, err := k.volProfile.PVC()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Get orchestrator provider profile from pvc\n\toPrfle, err := orchProfile.GetOrchProviderProfile(pvc)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Get the namespace which will be queried\n\tns, err := oPrfle.NS()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn ns, nil\n}", "func GetOperatorNamespace() (string, error) {\n\tif isRunModeLocal() {\n\t\treturn \"\", ErrRunLocal\n\t}\n\tnsBytes, err := ioutil.ReadFile(\"/var/run/secrets/kubernetes.io/serviceaccount/namespace\")\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn \"\", ErrNoNamespace\n\t\t}\n\t\treturn \"\", err\n\t}\n\tns := strings.TrimSpace(string(nsBytes))\n\tlog.V(1).Info(\"Found namespace\", \"Namespace\", ns)\n\treturn ns, nil\n}", "func (c *Client) GetNamespaceOperator() scheduler.NamespaceOperator {\n\treturn c.Namespace\n}", "func FindOperatorNamespace(clientset *kubernetes.Clientset) (string, error) {\n\tlabelSelector := metav1.FormatLabelSelector(&metav1.LabelSelector{\n\t\tMatchExpressions: []metav1.LabelSelectorRequirement{\n\t\t\t{\n\t\t\t\tKey: \"app\",\n\t\t\t\tOperator: metav1.LabelSelectorOpIn,\n\t\t\t\tValues: []string{\"pixie-operator\"},\n\t\t\t},\n\t\t},\n\t})\n\n\tvzPods, err := clientset.CoreV1().Pods(\"\").List(context.Background(), metav1.ListOptions{\n\t\tLabelSelector: labelSelector,\n\t})\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif len(vzPods.Items) == 0 {\n\t\treturn \"\", nil\n\t}\n\n\treturn vzPods.Items[0].Namespace, nil\n}", "func DNSClusterOperatorName() types.NamespacedName {\n\treturn types.NamespacedName{\n\t\tName: DefaultOperatorName,\n\t}\n}", "func (ctx *Context) GetOperatorNamespace() (string, error) {\n\tvar err error\n\tctx.operatorNamespace, err = ctx.getNamespace(ctx.operatorNamespace)\n\treturn ctx.operatorNamespace, err\n}", "func (cp *ConstantPacer) hitsPerNs() float64 {\n\treturn float64(cp.Freq) / nano\n}", "func metricString(ns []string) string {\n\treturn strings.Join(ns, \"/\")\n}", "func (n *nsSvc) NumNamespace() int {\n\tn.mux.RLock()\n\tdefer n.mux.RUnlock()\n\treturn len(n.NsToSvc)\n}", "func NopMetrics() *Metrics {\n\treturn &Metrics{\n\t\tBlockVerifyingTime: discard.NewHistogram(),\n\t\tBlockProcessingTime: discard.NewHistogram(),\n\t\tBlockCommittingTime: discard.NewHistogram(),\n\t}\n}", "func GetOperatorNamespace() (string, error) {\n\tns, found := os.LookupEnv(OperatorNamespaceEnvVar)\n\tif !found {\n\t\treturn \"\", fmt.Errorf(\"%s must be set\", OperatorNamespaceEnvVar)\n\t}\n\treturn ns, nil\n}", "func getOp(s string) (string, int) {\n\ts = strings.TrimSpace(s)\n\tfor _, pair := range opPhrasePairs {\n\t\tif strings.HasPrefix(s, pair.phrase) {\n\t\t\ts = strings.TrimPrefix(s, pair.phrase)\n\t\t\treturn s, pair.op\n\t\t}\n\t}\n\treturn s, -1\n}", "func getNetworkNamespace(pid uint32) string {\n\treturn fmt.Sprintf(netNSFormat, pid)\n}", "func NS(hdr dns.RR_Header, ns string) *dns.NS {\n\treturn &dns.NS{\n\t\tHdr: hdr,\n\t\tNs: ns,\n\t}\n}", "func getSizeByOP(op int) int {\n\tswitch op {\n\tcase 1:\n\t\treturn 3\n\tcase 2:\n\t\treturn 3\n\tcase 3:\n\t\treturn 1\n\tcase 4:\n\t\treturn 1\n\tcase 5:\n\t\treturn 2\n\tcase 6:\n\t\treturn 2\n\tcase 7:\n\t\treturn 3\n\tcase 8:\n\t\treturn 3\n\tdefault:\n\t\treturn 0\n\t}\n}", "func getNSID() (uint64, error) {\n\tpath := fmt.Sprintf(\"/proc/%d/task/%d/ns/net\", os.Getpid(), syscall.Gettid())\n\tfd, err := unix.Open(path, syscall.O_RDONLY, 0)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tvar s unix.Stat_t\n\tif err := unix.Fstat(fd, &s); err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn s.Ino, nil\n}", "func (rt *operatorRuntime) numOp(op func(float64, float64) interface{},\n\tvs parser.Scope, is map[string]interface{}, tid uint64) (interface{}, error) {\n\tvar ok bool\n\tvar res1, res2 interface{}\n\tvar err error\n\n\terrorutil.AssertTrue(len(rt.node.Children) == 2,\n\t\tfmt.Sprint(\"Operation requires 2 operands\", rt.node))\n\n\tif res1, err = rt.node.Children[0].Runtime.Eval(vs, is, tid); err == nil {\n\t\tif res2, err = rt.node.Children[1].Runtime.Eval(vs, is, tid); err == nil {\n\t\t\tvar res1Num, res2Num float64\n\n\t\t\tif res1Num, ok = res1.(float64); !ok {\n\t\t\t\terr = rt.erp.NewRuntimeError(util.ErrNotANumber,\n\t\t\t\t\trt.errorDetailString(rt.node.Children[0].Token, res1), rt.node.Children[0])\n\n\t\t\t} else {\n\t\t\t\tif res2Num, ok = res2.(float64); !ok {\n\t\t\t\t\terr = rt.erp.NewRuntimeError(util.ErrNotANumber,\n\t\t\t\t\t\trt.errorDetailString(rt.node.Children[1].Token, res2), rt.node.Children[1])\n\n\t\t\t\t} else {\n\n\t\t\t\t\treturn op(res1Num, res2Num), err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil, err\n}", "func (n *miniNode) Op() Op { return n.op }", "func (m *DiscountMutation) Op() Op {\n\treturn m.op\n}", "func (spec *KubectlStorageOSConfigSpec) GetNamespace() (namespace string) {\n\tnamespace = spec.Install.StorageOSOperatorNamespace\n\tif namespace == \"\" {\n\t\tnamespace = spec.Uninstall.StorageOSOperatorNamespace\n\t}\n\n\treturn\n}", "func parseOpOpStat(node *node32) (RHS, error) {\n\trhs := new(ExpressionRHS)\n\trhs.SetToken(&node.token32)\n\n\tlhs, err := parseExpr(nextNode(node, ruleASSIGNLHS).up)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tswitch nextNode(node, ruleOPOP).up.pegRule {\n\tcase rulePLUSPLUS:\n\t\tone := &IntLiteral{value: 1}\n\t\tbinOp := &BinaryOperatorAdd{BinaryOperatorBase{rhs: one, lhs: lhs}}\n\t\tbinOp.SetToken(&node.token32)\n\t\trhs.expr = binOp\n\n\tcase ruleMINUSMINUS:\n\t\tone := &IntLiteral{value: 1}\n\t\tbinOp := &BinaryOperatorSub{BinaryOperatorBase{rhs: one, lhs: lhs}}\n\t\tbinOp.SetToken(&node.token32)\n\t\trhs.expr = binOp\n\t}\n\n\treturn rhs, nil\n}", "func CountMetric(metric_in, m1Prefix string) (metric_out string) {\n\tv := GetVersion(metric_in)\n\tif v == M20 {\n\t\tparts := strings.Split(metric_in, \".\")\n\t\tfor i, part := range parts {\n\t\t\tif strings.HasPrefix(part, \"unit=\") {\n\t\t\t\tparts[i] = \"unit=Metric\"\n\t\t\t\tparts = append(parts, \"orig_unit=\"+part[5:])\n\t\t\t}\n\t\t\tif strings.HasPrefix(part, \"target_type=\") {\n\t\t\t\tparts[i] = \"target_type=count\"\n\t\t\t}\n\t\t}\n\t\tmetric_out = strings.Join(parts, \".\")\n\t} else if v == M20NoEquals {\n\t\tparts := strings.Split(metric_in, \".\")\n\t\tfor i, part := range parts {\n\t\t\tif strings.HasPrefix(part, \"unit_is_\") {\n\t\t\t\tparts[i] = \"unit_is_Metric\"\n\t\t\t\tparts = append(parts, \"orig_unit_is_\"+part[8:])\n\t\t\t}\n\t\t\tif strings.HasPrefix(part, \"target_type_is_\") {\n\t\t\t\tparts[i] = \"target_type_is_count\"\n\t\t\t}\n\t\t}\n\t\tmetric_out = strings.Join(parts, \".\")\n\t} else {\n\t\tmetric_out = m1Prefix + metric_in + \".count\"\n\t}\n\treturn\n}", "func (r *LocalOperatorReconciler) namespaceForLocalOperator(cr *cachev1.LocalOperator) *corev1.Namespace {\n\tns := &corev1.Namespace{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: cr.Spec.Namespace,\n\t\t},\n\t}\n\t// Set LocalOperator instance as the owner and controller\n\tctrl.SetControllerReference(cr, ns, r.Scheme)\n\treturn ns\n}", "func (c *C) NS(prefix string, beforeControllers ...action) *NS {\n\tns := &NS{\n\t\tc: c,\n\t\tprefix: prefix,\n\t\tbCtrl: beforeControllers,\n\t}\n\n\treturn ns\n}", "func (nb *NetBuilder) getNamespaceIdentifier(ep *Endpoint) (NSType, string) {\n\tvar netNSType NSType\n\tvar namespaceIdentifier string\n\n\tif ep.NetNSName == \"\" || ep.NetNSName == \"none\" {\n\t\t// This is the first, i.e. infrastructure, container in the group.\n\t\t// The namespace identifier for such containers would be their container ID.\n\t\tnetNSType = infraContainerNS\n\t\tnamespaceIdentifier = ep.ContainerID\n\t} else if strings.HasPrefix(ep.NetNSName, containerPrefix) {\n\t\t// This is a workload container sharing the netns of a previously created infra container.\n\t\t// The namespace identifier for such containers would be the infra container's ID.\n\t\tnetNSType = nonInfraContainerNS\n\t\tnamespaceIdentifier = strings.TrimPrefix(ep.NetNSName, containerPrefix)\n\t\tlog.Infof(\"Container %s shares netns of container %s.\", ep.ContainerID, namespaceIdentifier)\n\t} else {\n\t\t// This plugin invocation does not need an infra container and uses an existing HCN Namespace.\n\t\t// The namespace identifier would be the HCN Namespace id.\n\t\tnetNSType = hcsNamespace\n\t\tnamespaceIdentifier = ep.NetNSName\n\t}\n\n\treturn netNSType, namespaceIdentifier\n}", "func (o IopingSpecPodConfigPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFieldsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v IopingSpecPodConfigPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFields) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o IopingSpecPodConfigPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v IopingSpecPodConfigPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (i *Instance) OperatorVersionNamespace() string {\n\tif i.Spec.OperatorVersion.Namespace == \"\" {\n\t\treturn i.ObjectMeta.Namespace\n\t}\n\treturn i.Spec.OperatorVersion.Namespace\n}", "func (o Iperf3SpecServerConfigurationPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFieldsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v Iperf3SpecServerConfigurationPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFields) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o Iperf3SpecServerConfigurationPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v Iperf3SpecServerConfigurationPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func NopMetrics() *Metrics {\n\treturn &Metrics{\n\t\tPeers: discard.NewGauge(),\n\t\tPeerReceiveBytesTotal: discard.NewCounter(),\n\t\tPeerSendBytesTotal: discard.NewCounter(),\n\t\tPeerPendingSendBytes: discard.NewGauge(),\n\t\tNumTxs: discard.NewGauge(),\n\t}\n}", "func (p *SimpleGasPolicy) GetCostForOp(op opcode.Opcode) uint64 {\n\treturn 1\n}", "func O2S(op Operation) string {\n\tswitch op {\n\tcase ADD:\n\t\treturn \"+\"\n\tcase DISCARD:\n\t\treturn \"-\"\n\tcase ARROW:\n\t\treturn \"*\"\n\t}\n\tpanic(\"invalid operation\")\n}", "func updateMetric(msg events.PubSubMessage) {\n\tswitch msg.Kind {\n\tcase announcements.NamespaceAdded:\n\t\tmetricsstore.DefaultMetricsStore.MonitoredNamespaceCounter.Inc()\n\tcase announcements.NamespaceDeleted:\n\t\tmetricsstore.DefaultMetricsStore.MonitoredNamespaceCounter.Dec()\n\t}\n}", "func (p *Expression) Namespace() string {\n\treturn p.namespace\n}", "func (o FioSpecPodConfigPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v FioSpecPodConfigPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o SysbenchSpecPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v SysbenchSpecPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o FioSpecPodConfigPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFieldsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v FioSpecPodConfigPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFields) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o Iperf3SpecClientConfigurationPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFieldsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v Iperf3SpecClientConfigurationPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFields) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (m *NurseMutation) Op() Op {\n\treturn m.op\n}", "func (o Iperf3SpecClientConfigurationPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v Iperf3SpecClientConfigurationPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o SysbenchSpecPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFieldsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v SysbenchSpecPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFields) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o MrScalarTaskScalingUpPolicyOutput) Namespace() pulumi.StringOutput {\n\treturn o.ApplyT(func(v MrScalarTaskScalingUpPolicy) string { return v.Namespace }).(pulumi.StringOutput)\n}", "func (o Iperf3SpecServerConfigurationPodSchedulingAffinityPodAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v Iperf3SpecServerConfigurationPodSchedulingAffinityPodAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o QperfSpecServerConfigurationPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v QperfSpecServerConfigurationPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (n *IfNode) Op() string { return n.op }", "func (this *KeyspaceTerm) Namespace() string {\n\tif this.path != nil {\n\t\treturn this.path.Namespace()\n\t}\n\treturn \"\"\n}", "func (o Iperf3SpecServerConfigurationPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v Iperf3SpecServerConfigurationPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (rt *operatorRuntime) strOp(op func(string, string) interface{},\n\tvs parser.Scope, is map[string]interface{}, tid uint64) (interface{}, error) {\n\n\tvar ret interface{}\n\n\terrorutil.AssertTrue(len(rt.node.Children) == 2,\n\t\tfmt.Sprint(\"Operation requires 2 operands\", rt.node))\n\n\tres1, err := rt.node.Children[0].Runtime.Eval(vs, is, tid)\n\tif err == nil {\n\t\tvar res2 interface{}\n\n\t\tif res2, err = rt.node.Children[1].Runtime.Eval(vs, is, tid); err == nil {\n\t\t\tret = op(fmt.Sprint(res1), fmt.Sprint(res2))\n\t\t}\n\t}\n\n\treturn ret, err\n}", "func podNamespace(pod corev1.Pod) string {\n\t// An empty namespace is the default namespace.\n\tnamespace := pod.Namespace\n\tif namespace == \"\" {\n\t\tnamespace = \"default\"\n\t}\n\n\treturn namespace\n}", "func (o QperfSpecServerConfigurationPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFieldsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v QperfSpecServerConfigurationPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFields) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (p *DockerPod) GetNetns() string {\n\tif p.netTask == nil {\n\t\treturn \"\"\n\t}\n\treturn fmt.Sprintf(defaultPodNetnsTemplate, strconv.Itoa(p.netTask.RuntimeConf.Pid))\n}", "func NewNS(name string, target string, ttl uint32) *dns.NS {\n\treturn &dns.NS{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeNS, Class: dns.ClassINET, Ttl: ttl}, Ns: target}\n}", "func (c ExprCell) Op() string {\n\treturn c[\"op\"].(string)\n}", "func Count(metric_in, m1Prefix string) (metric_out string) {\n\tv := GetVersion(metric_in)\n\tif v == M20 {\n\t\tparts := strings.Split(metric_in, \".\")\n\t\tttSeen := false\n\t\tfor i, part := range parts {\n\t\t\tif strings.HasPrefix(part, \"target_type=\") {\n\t\t\t\tttSeen = true\n\t\t\t\tparts[i] = \"target_type=count\"\n\t\t\t}\n\t\t}\n\t\tif !ttSeen {\n\t\t\tparts = append(parts, \"target_type=count\")\n\t\t}\n\t\tmetric_out = strings.Join(parts, \".\")\n\t} else if v == M20NoEquals {\n\t\tparts := strings.Split(metric_in, \".\")\n\t\tttSeen := false\n\t\tfor i, part := range parts {\n\t\t\tif strings.HasPrefix(part, \"target_type_is_\") {\n\t\t\t\tttSeen = true\n\t\t\t\tparts[i] = \"target_type_is_count\"\n\t\t\t}\n\t\t}\n\t\tif !ttSeen {\n\t\t\tparts = append(parts, \"target_type_is_count\")\n\t\t}\n\t\tmetric_out = strings.Join(parts, \".\")\n\t} else {\n\t\tmetric_out = m1Prefix + metric_in + \".count\"\n\t}\n\treturn\n}", "func (o PgbenchSpecPodConfigPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v PgbenchSpecPodConfigPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o MrScalarCoreScalingUpPolicyOutput) Namespace() pulumi.StringOutput {\n\treturn o.ApplyT(func(v MrScalarCoreScalingUpPolicy) string { return v.Namespace }).(pulumi.StringOutput)\n}", "func (o SysbenchSpecPodSchedulingAffinityPodAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v SysbenchSpecPodSchedulingAffinityPodAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o PgbenchSpecPodConfigPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFieldsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v PgbenchSpecPodConfigPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFields) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o SysbenchSpecPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v SysbenchSpecPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (c *Prometheus) TrackOperationN(section string, operation *bucket.MetricOperation, t timer.Timer, n int, success bool) Client {\n\tb := bucket.NewPrometheus(section, operation, success, c.unicode)\n\n\tif operation.Labels == nil {\n\t\toperation.Labels = map[string]string{\"success\": strconv.FormatBool(success)}\n\t} else {\n\t\toperation.Labels[\"success\"] = strconv.FormatBool(success)\n\t}\n\n\tc.TrackMetricN(section, operation, n)\n\n\tif nil != t {\n\t\tvar values []string\n\n\t\th := c.getHistogram(c.prepareMetric(b.Metric()), operation.Labels)\n\t\tfor _, value := range operation.Labels {\n\t\t\tvalues = append(values, value)\n\t\t}\n\t\th.WithLabelValues(values...).Observe(float64(t.Finish() / time.Millisecond))\n\t}\n\n\treturn c\n}", "func JNS(r operand.Op) { ctx.JNS(r) }", "func (o Iperf3SpecServerConfigurationPodSchedulingAffinityPodAffinityRequiredDuringSchedulingIgnoredDuringExecutionLabelSelectorMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v Iperf3SpecServerConfigurationPodSchedulingAffinityPodAffinityRequiredDuringSchedulingIgnoredDuringExecutionLabelSelectorMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func namespacesCount(cache kubeCache, now time.Time) []types.MetricPoint {\n\tnsCountByState := make(map[string]int)\n\n\tfor _, namespace := range cache.namespaces {\n\t\tstate := strings.ToLower(string(namespace.Status.Phase))\n\t\tnsCountByState[state]++\n\t}\n\n\tpoints := make([]types.MetricPoint, 0, len(nsCountByState))\n\n\tfor state, count := range nsCountByState {\n\t\tpoints = append(points, types.MetricPoint{\n\t\t\tPoint: types.Point{Time: now, Value: float64(count)},\n\t\t\tLabels: map[string]string{\n\t\t\t\ttypes.LabelName: \"kubernetes_namespaces_count\",\n\t\t\t\ttypes.LabelState: state,\n\t\t\t},\n\t\t})\n\t}\n\n\treturn points\n}", "func (o Iperf3SpecServerConfigurationPodSchedulingAffinityPodAntiAffinityRequiredDuringSchedulingIgnoredDuringExecutionLabelSelectorMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v Iperf3SpecServerConfigurationPodSchedulingAffinityPodAntiAffinityRequiredDuringSchedulingIgnoredDuringExecutionLabelSelectorMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func NetNamespace(task containerd.Task) string {\n\treturn fmt.Sprintf(NetNSPathFmt, task.Pid())\n}", "func (o QperfSpecClientConfigurationPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v QperfSpecClientConfigurationPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o SchedulingNodeAffinityResponseOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v SchedulingNodeAffinityResponse) string { return v.Operator }).(pulumi.StringOutput)\n}", "func (o QperfSpecServerConfigurationPodSchedulingAffinityPodAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v QperfSpecServerConfigurationPodSchedulingAffinityPodAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (mc *MockContiv) GetNsIndex(podNamespace string, podName string) (nsIndex uint32, exists bool) {\n\tnsIndex, exists = mc.podAppNs[podmodel.ID{Name: podName, Namespace: podNamespace}]\n\treturn nsIndex, exists\n}", "func (o QperfSpecClientConfigurationPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFieldsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v QperfSpecClientConfigurationPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFields) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (e *Executor) GetNetstats(node *corev1.Pod) (*Netstats, error) {\n\tout, err := e.run(node, \"netstats\", []string{})\n\tif err != nil || out == \"\" {\n\t\treturn nil, err\n\t}\n\n\tscanner := bufio.NewScanner(strings.NewReader(out))\n\n\tnetstat := &Netstats{}\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tif line == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tsplitLine := strings.Split(line, \":\")\n\t\tif len(splitLine) == 2 {\n\t\t\tkey := splitLine[0]\n\t\t\tvalue := strings.TrimSpace(splitLine[1])\n\t\t\tif key == \"Mode\" {\n\t\t\t\tnetstat.Mode = NodeMode(value)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif key == \"Attempted\" {\n\t\t\t\tattempted, err := strconv.Atoi(value)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\n\t\t\t\tnetstat.AttemptedReadRepairOps = attempted\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif key == \"Mismatch (Blocking)\" {\n\t\t\t\tblocking, err := strconv.Atoi(value)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\n\t\t\t\tnetstat.MismatchBlockingReadRepairOps = blocking\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif key == \"Mismatch (Background)\" {\n\t\t\t\tbg, err := strconv.Atoi(value)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\n\t\t\t\tnetstat.MismatchBgReadRepairOps = bg\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tif strings.Contains(line, \"Pool Name\") {\n\t\t\tnetstat.ThreadPoolNetstats = []ThreadPoolNetstat{}\n\t\t\tfor scanner.Scan() {\n\t\t\t\tstat, err := processThreadPool(scanner.Text())\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tnetstat.ThreadPoolNetstats = append(netstat.ThreadPoolNetstats, *stat)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn netstat, nil\n}", "func updateLabelOp(metric pmetric.Metric, mtpOp internalOperation, f internalFilter) {\n\top := mtpOp.configOperation\n\trangeDataPointAttributes(metric, func(attrs pcommon.Map) bool {\n\t\tif !f.matchAttrs(attrs) {\n\t\t\treturn true\n\t\t}\n\n\t\tattrKey := op.Label\n\t\tattrVal, ok := attrs.Get(attrKey)\n\t\tif !ok {\n\t\t\treturn true\n\t\t}\n\n\t\tif op.NewLabel != \"\" {\n\t\t\tattrVal.CopyTo(attrs.PutEmpty(op.NewLabel))\n\t\t\tattrs.Remove(attrKey)\n\t\t\tattrKey = op.NewLabel\n\t\t}\n\n\t\tif newValue, ok := mtpOp.valueActionsMapping[attrVal.Str()]; ok {\n\t\t\tattrs.PutStr(attrKey, newValue)\n\t\t}\n\t\treturn true\n\t})\n}", "func (o QperfSpecServerConfigurationPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v QperfSpecServerConfigurationPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o ApplicationSpecRolloutplanRolloutbatchesCanarymetricTemplaterefPtrOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ApplicationSpecRolloutplanRolloutbatchesCanarymetricTemplateref) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Namespace\n\t}).(pulumi.StringPtrOutput)\n}", "func (o DrillSpecPodConfigPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFieldsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v DrillSpecPodConfigPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchFields) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o SysbenchSpecPodSchedulingAffinityPodAntiAffinityRequiredDuringSchedulingIgnoredDuringExecutionLabelSelectorMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v SysbenchSpecPodSchedulingAffinityPodAntiAffinityRequiredDuringSchedulingIgnoredDuringExecutionLabelSelectorMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func getNamepace (command *parser.Command) (namespace string, err error) {\n\tswitch command.TargetType {\n\tcase parser.DOCKER:\n\t\tnamespace, err = koko_api.GetDockerContainerNS(\"\", command.Target)\n\tcase parser.IPNETNS:\n\t\tnamespace = fmt.Sprintf(\"/var/run/netns/%s\", command.Target)\n\tcase parser.NETNS:\n\t\tnamespace = command.Target\n\tcase parser.PID:\n\t\tvar pid int\n\t\tpid, err = strconv.Atoi(command.Target)\n\t\tif err == nil {\n\t namespace = fmt.Sprintf(\"/proc/%d/ns/net\", pid)\n\t }\n\t}\n\treturn namespace, err\n}", "func getOperandIndex(op string) (index int) {\n\t// get tier 3 operands\n\tfor i, c := range op {\n\t\tif c == '^' {\n\t\t\tif !isOpInBrackets(op[i:]) {\n\t\t\t\treturn i\n\t\t\t}\n\t\t}\n\t}\n\n\t// get tier 2 operands\n\tfor i, c := range op {\n\t\tif c == '*' || c == '/' {\n\t\t\tif !isOpInBrackets(op[i:]) {\n\t\t\t\treturn i\n\t\t\t}\n\t\t}\n\t}\n\n\t// get tier 1 operands\n\tfor i, c := range op {\n\t\tif c == '+' || c == '-' {\n\t\t\tif !isOpInBrackets(op[i:]) {\n\t\t\t\treturn i\n\t\t\t}\n\t\t}\n\t}\n\n\t// nothing was found\n\treturn 0\n}", "func (o IopingSpecPodConfigPodSchedulingAffinityNodeAffinityPreferredDuringSchedulingIgnoredDuringExecutionPreferenceMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v IopingSpecPodConfigPodSchedulingAffinityNodeAffinityPreferredDuringSchedulingIgnoredDuringExecutionPreferenceMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o SysbenchSpecPodSchedulingAffinityPodAffinityRequiredDuringSchedulingIgnoredDuringExecutionLabelSelectorMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v SysbenchSpecPodSchedulingAffinityPodAffinityRequiredDuringSchedulingIgnoredDuringExecutionLabelSelectorMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func Nop(c *CPU) {\n}", "func (o DrillSpecPodConfigPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v DrillSpecPodConfigPodSchedulingAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecutionNodeSelectorTermsMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o Iperf3SpecClientConfigurationPodSchedulingAffinityPodAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v Iperf3SpecClientConfigurationPodSchedulingAffinityPodAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o QuotaRateLimitOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *QuotaRateLimit) pulumi.StringPtrOutput { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (o ElastigroupScalingTargetPolicyOutput) Namespace() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ElastigroupScalingTargetPolicy) string { return v.Namespace }).(pulumi.StringOutput)\n}", "func NopStreamMetrics() *StreamMetrics {\n\treturn &StreamMetrics{\n\t\t//PulsarSendNum: discard.NewGauge(),\n\t\tCacheSize: discard.NewGauge(),\n\t}\n}", "func (o IopingSpecPodConfigPodSchedulingAffinityPodAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v IopingSpecPodConfigPodSchedulingAffinityPodAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o Iperf3SpecClientConfigurationPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v Iperf3SpecClientConfigurationPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o MrScalarTaskScalingDownPolicyOutput) Namespace() pulumi.StringOutput {\n\treturn o.ApplyT(func(v MrScalarTaskScalingDownPolicy) string { return v.Namespace }).(pulumi.StringOutput)\n}", "func (o QperfSpecServerConfigurationPodSchedulingAffinityPodAffinityRequiredDuringSchedulingIgnoredDuringExecutionLabelSelectorMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v QperfSpecServerConfigurationPodSchedulingAffinityPodAffinityRequiredDuringSchedulingIgnoredDuringExecutionLabelSelectorMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o Iperf3SpecServerConfigurationPodSchedulingAffinityNodeAffinityPreferredDuringSchedulingIgnoredDuringExecutionPreferenceMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v Iperf3SpecServerConfigurationPodSchedulingAffinityNodeAffinityPreferredDuringSchedulingIgnoredDuringExecutionPreferenceMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func setCounterNamespace(opts *prometheus.CounterOpts) {\n\topts.Namespace = processNamePrometheus()\n}", "func (ls *LocationStore) Namespace() string {\n\treturn fmt.Sprintf(\"locations.%s\", ls.name)\n}", "func (r *reconciler) getOperatorState(nsName string) ([]operatorv1.DNS, *corev1.Namespace, error) {\n\tns := &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: nsName}}\n\tif err := r.client.Get(context.TODO(), types.NamespacedName{Name: nsName}, ns); err != nil {\n\t\tif errors.IsNotFound(err) {\n\t\t\treturn nil, nil, nil\n\t\t}\n\t\treturn nil, nil, fmt.Errorf(\"failed to get namespace %s: %v\", nsName, err)\n\t}\n\n\tdnsList := &operatorv1.DNSList{}\n\tif err := r.client.List(context.TODO(), dnsList); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to list dnses: %v\", err)\n\t}\n\n\treturn dnsList.Items, ns, nil\n}", "func (o ApplicationSpecRolloutplanRolloutbatchesCanarymetricTemplaterefOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationSpecRolloutplanRolloutbatchesCanarymetricTemplateref) *string { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (o IopingSpecPodConfigPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v IopingSpecPodConfigPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionPodAffinityTermLabelSelectorMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}", "func (o SysbenchSpecPodSchedulingAffinityNodeAffinityPreferredDuringSchedulingIgnoredDuringExecutionPreferenceMatchExpressionsOutput) Operator() pulumi.StringOutput {\n\treturn o.ApplyT(func(v SysbenchSpecPodSchedulingAffinityNodeAffinityPreferredDuringSchedulingIgnoredDuringExecutionPreferenceMatchExpressions) string {\n\t\treturn v.Operator\n\t}).(pulumi.StringOutput)\n}" ]
[ "0.57224274", "0.5444601", "0.52460575", "0.52289724", "0.49640873", "0.49150625", "0.48725146", "0.48344836", "0.48164344", "0.48130932", "0.4811613", "0.47757563", "0.4772676", "0.47431546", "0.46914786", "0.46831667", "0.46792915", "0.46668288", "0.46610507", "0.46231055", "0.46088848", "0.45957527", "0.4592273", "0.45857972", "0.4580155", "0.4559812", "0.4553448", "0.45508406", "0.45500374", "0.45476002", "0.45376343", "0.45359793", "0.45341414", "0.45334175", "0.45309108", "0.45263392", "0.45164058", "0.4506494", "0.45026243", "0.45000237", "0.44975862", "0.44899598", "0.44866258", "0.44848818", "0.44810796", "0.4477287", "0.4475627", "0.44702178", "0.4469058", "0.4468481", "0.44644654", "0.4458788", "0.4454365", "0.44518772", "0.44518188", "0.44504356", "0.44461915", "0.44430262", "0.44386324", "0.44368398", "0.44314522", "0.4429097", "0.442835", "0.44230068", "0.44187704", "0.44177994", "0.44169572", "0.4413978", "0.4410603", "0.44105038", "0.44058868", "0.4398248", "0.4398166", "0.4393983", "0.43877503", "0.4387746", "0.4386779", "0.4381812", "0.43800104", "0.43735266", "0.4371415", "0.43712088", "0.4370035", "0.43683365", "0.43655014", "0.4364304", "0.43642727", "0.4363986", "0.43629566", "0.43592015", "0.43588942", "0.43577176", "0.4353402", "0.43526828", "0.4351633", "0.4351347", "0.43512228", "0.43499658", "0.4349603", "0.4346063" ]
0.61860836
0
AllocsPerOp returns the "allocs/op" metric, which is calculated as r.MemAllocs / r.N.
func (r BenchmarkResult) AllocsPerOp() int64 {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func AllocsPerRun(runs int, f func()) (avg float64)", "func (r BenchmarkResult) NsPerOp() int64 {}", "func AllocsPerRun(runs int, f func()) (avg float64) {}", "func (p *ResourcePool) Allocs(ctx context.Context) ([]Alloc, error) {\n\tp.mu.Lock()\n\tdefer p.mu.Unlock()\n\tallocs := make([]Alloc, len(p.allocs))\n\ti := 0\n\tfor _, a := range p.allocs {\n\t\tallocs[i] = a\n\t\ti++\n\t}\n\treturn allocs, nil\n}", "func (r BenchmarkResult) AllocedBytesPerOp() int64 {}", "func (p *Pool) Stats() map[string]int {\n\tfreeJobQueueSpaces := p.maxJobQueue - len(p.jobQueue)\n\n\treturn map[string]int{\n\t\t\"free_workers\": len(p.workerPool),\n\t\t\"free_job_queue_spaces\": freeJobQueueSpaces,\n\t}\n}", "func (p *president) EvaluateAllocationRequests(resourceRequest map[shared.ClientID]shared.Resources, availCommonPool shared.Resources) shared.PresidentReturnContent {\n\tp.c.clientPrint(\"Evaluating allocations...\")\n\tvar avgResource, avgRequest shared.Resources\n\tvar allocSum, commonPoolThreshold, sumRequest float64\n\n\t// Make sure resource skew is greater than 1\n\tresourceSkew := math.Max(float64(p.c.params.resourcesSkew), 1)\n\n\tresources := make(map[shared.ClientID]shared.Resources)\n\tallocations := make(map[shared.ClientID]float64)\n\tallocWeights := make(map[shared.ClientID]float64)\n\tfinalAllocations := make(map[shared.ClientID]shared.Resources)\n\n\tfor island, req := range resourceRequest {\n\t\tsumRequest += float64(req)\n\t\tresources[island] = shared.Resources(float64(p.c.declaredResources[island]) * math.Pow(resourceSkew, ((100-p.c.trustScore[island])/100)))\n\t}\n\n\tp.c.clientPrint(\"Resource requests: %+v\\n\", resourceRequest)\n\tp.c.clientPrint(\"Their resource estimation: %+v\\n\", p.c.declaredResources)\n\tp.c.clientPrint(\"Our estimation: %+v\\n\", resources)\n\tp.c.clientPrint(\"Trust Scores: %+v\\n\", p.c.trustScore)\n\n\tavgRequest = findAvgNoTails(resourceRequest)\n\tavgResource = findAvgNoTails(resources)\n\n\tfor island, resource := range resources {\n\t\tallocations[island] = float64(avgRequest) + p.c.params.equity*(float64(avgResource-resource)+float64(resourceRequest[island]-avgRequest))\n\t\t// p.c.clientPrint(\"Allocation for island %v: %f\", island, allocations[island])\n\t\tif island == p.c.GetID() {\n\t\t\tallocations[island] += math.Max(float64(resourceRequest[island])-allocations[island]*p.c.params.selfishness, 0)\n\t\t} else {\n\t\t\tallocations[island] = math.Min(float64(resourceRequest[island]), allocations[island]) // to prevent overallocating\n\t\t\tallocations[island] = math.Max(allocations[island], 0)\n\t\t}\n\t}\n\n\t// Collect weights\n\tfor _, alloc := range allocations {\n\t\tallocSum += alloc\n\t}\n\t// Normalise\n\tfor island, alloc := range allocations {\n\t\tallocWeights[island] = alloc / allocSum\n\t}\n\t// p.c.clientPrint(\"Allocation wieghts: %+v\\n\", allocWeights)\n\n\tcommonPoolThreshold = math.Min(float64(availCommonPool)*(1.0-p.c.params.riskFactor), sumRequest)\n\tif p.c.params.saveCriticalIsland {\n\t\tfor island := range resourceRequest {\n\t\t\tif resources[island] < p.c.criticalThreshold {\n\t\t\t\tfinalAllocations[island] = shared.Resources(math.Max((allocWeights[island] * commonPoolThreshold), float64(p.c.criticalThreshold-resources[island])))\n\t\t\t} else {\n\t\t\t\tfinalAllocations[island] = 0\n\t\t\t}\n\t\t}\n\t}\n\n\tfor island := range resourceRequest {\n\t\tif finalAllocations[island] == 0 {\n\t\t\tif sumRequest < commonPoolThreshold {\n\t\t\t\tfinalAllocations[island] = shared.Resources(math.Max(allocWeights[island]*float64(sumRequest), 0))\n\t\t\t} else {\n\t\t\t\tfinalAllocations[island] = shared.Resources(math.Max(allocWeights[island]*commonPoolThreshold, 0))\n\t\t\t}\n\t\t}\n\t}\n\n\tp.c.clientPrint(\"Final allocations: %+v\\n\", finalAllocations)\n\n\t// Curently always evaluate, would there be a time when we don't want to?\n\treturn shared.PresidentReturnContent{\n\t\tContentType: shared.PresidentAllocation,\n\t\tResourceMap: finalAllocations,\n\t\tActionTaken: true,\n\t}\n}", "func getSizeByOP(op int) int {\n\tswitch op {\n\tcase 1:\n\t\treturn 3\n\tcase 2:\n\t\treturn 3\n\tcase 3:\n\t\treturn 1\n\tcase 4:\n\t\treturn 1\n\tcase 5:\n\t\treturn 2\n\tcase 6:\n\t\treturn 2\n\tcase 7:\n\t\treturn 3\n\tcase 8:\n\t\treturn 3\n\tdefault:\n\t\treturn 0\n\t}\n}", "func getTotalAllocatableMemory(f *framework.Framework) *resource.Quantity {\n\tselector := labels.Set{\"beta.kubernetes.io/os\": \"windows\"}.AsSelector()\n\tnodeList, err := f.ClientSet.CoreV1().Nodes().List(metav1.ListOptions{\n\t\tLabelSelector: selector.String(),\n\t})\n\tframework.ExpectNoError(err)\n\n\tginkgo.By(\"Summing allocatable memory across all agent nodes\")\n\n\ttotalAllocatable := resource.NewQuantity(0, resource.BinarySI)\n\n\tfor _, node := range nodeList.Items {\n\t\tstatus := node.Status\n\n\t\ttotalAllocatable.Add(status.Allocatable[v1.ResourceMemory])\n\t}\n\n\treturn totalAllocatable\n}", "func currMemoryAlloc() int {\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\treturn int(m.Alloc)\n}", "func OpMetrics(w http.ResponseWriter, r *http.Request) {\n\n\t// Init output\n\toutput := []byte(\"\")\n\n\t// Add content type header to the response\n\tcontentType := \"application/json\"\n\tcharset := \"utf-8\"\n\tw.Header().Add(\"Content-Type\", fmt.Sprintf(\"%s; charset=%s\", contentType, charset))\n\n\t// Grab context references\n\trefStr := gorillaContext.Get(r, \"str\").(stores.Store)\n\n\t// Get Results Object\n\tres, err := metrics.GetUsageCpuMem(refStr)\n\n\tif err != nil && err.Error() != \"not found\" {\n\t\terr := APIErrQueryDatastore()\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\t// Output result to JSON\n\tresJSON, err := res.ExportJSON()\n\n\tif err != nil {\n\t\terr := APIErrExportJSON()\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\t// Write response\n\toutput = []byte(resJSON)\n\trespondOK(w, output)\n\n}", "func (s *plannerStats) BytesPerFact() int {\n\tr := s.impl.BytesPerFact()\n\treturn s.track(r, \"BytesPerFact\")\n}", "func AllocatorSize() (size uint32) {\n\t// size of freeBuddiesList\n\tsize += MaxOrder * uint32(unsafe.Sizeof(freeBuddiesList{}))\n\n\t// size of bigPagesBitmap\n\tsize += nMaps(_nBigPages) * 4\n\n\t// size of individual freeBuddiesList\n\tfor i := 0; i < MaxOrder; i++ {\n\t\t// maxOrder - 1 pages of order i, further divide by 2 since we use 1 bit\n\t\t// for buddy pair.\n\t\tvar nBuddies uint32 = _nBigPages * (1 << uint32(MaxOrder-i-1))\n\t\tsize += nMaps(nBuddies) * 4\n\t}\n\n\t// size of node pool\n\tsize += nodePoolSize()\n\n\treturn\n}", "func (c *Client) MetricResourcesPerNode() (result float64, err error) {\n\tret := ValueMetricJSON{}\n\treturn ret.Value, c.Metric(&ret, \"com.puppetlabs.puppetdb.query.population:type=default,name=avg-resources-per-node\")\n}", "func allocs(c echo.Context) error {\n\tpprof.Handler(\"allocs\").ServeHTTP(c.Response(), c.Request())\n\treturn nil\n}", "func Stats() (AllocatedSlabs int64, GrabbedChunks int64, ReleasedChunks int64, MemoryAllocated int64, MemoryInUse int64) {\n\tmemoryMutex.Lock()\n\tdefer memoryMutex.Unlock()\n\n\tAllocatedSlabs = int64(allocatedSlabs)\n\tGrabbedChunks = grabbedChunks\n\tReleasedChunks = releasedChunks\n\tMemoryInUse = (GrabbedChunks - ReleasedChunks) * int64(ChunkSize)\n\tMemoryAllocated = AllocatedSlabs * int64(SlabSize)\n\treturn\n}", "func resourceMetricsDPC(rs pmetric.ResourceMetrics) int {\n\tdataPointCount := 0\n\tilms := rs.ScopeMetrics()\n\tfor k := 0; k < ilms.Len(); k++ {\n\t\tdataPointCount += scopeMetricsDPC(ilms.At(k))\n\t}\n\treturn dataPointCount\n}", "func (p *basePhysicalAgg) MemoryUsage() (sum int64) {\n\tif p == nil {\n\t\treturn\n\t}\n\n\tsum = p.physicalSchemaProducer.MemoryUsage() + size.SizeOfInt\n\n\tfor _, agg := range p.AggFuncs {\n\t\tsum += agg.MemoryUsage()\n\t}\n\tfor _, expr := range p.GroupByItems {\n\t\tsum += expr.MemoryUsage()\n\t}\n\tfor _, mppCol := range p.MppPartitionCols {\n\t\tsum += mppCol.MemoryUsage()\n\t}\n\treturn\n}", "func allocSize(bufCap, reqLen int) int {\n\tif bufCap == 0 {\n\t\treturn reqLen\n\t}\n\treturn 5 * reqLen / 4\n}", "func (cg *CGroup) GetMemoryStats() (map[string]uint64, error) {\n\tvar (\n\t\terr error\n\t\tstats string\n\t)\n\n\tout := make(map[string]uint64)\n\n\tversion := cgControllers[\"memory\"]\n\tswitch version {\n\tcase Unavailable:\n\t\treturn nil, ErrControllerMissing\n\tcase V1, V2:\n\t\tstats, err = cg.rw.Get(version, \"memory\", \"memory.stat\")\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, stat := range strings.Split(stats, \"\\n\") {\n\t\tfield := strings.Split(stat, \" \")\n\n\t\tswitch field[0] {\n\t\tcase \"total_active_anon\", \"active_anon\":\n\t\t\tout[\"active_anon\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_active_file\", \"active_file\":\n\t\t\tout[\"active_file\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_inactive_anon\", \"inactive_anon\":\n\t\t\tout[\"inactive_anon\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_inactive_file\", \"inactive_file\":\n\t\t\tout[\"inactive_file\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_unevictable\", \"unevictable\":\n\t\t\tout[\"unevictable\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_writeback\", \"file_writeback\":\n\t\t\tout[\"writeback\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_dirty\", \"file_dirty\":\n\t\t\tout[\"dirty\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_mapped_file\", \"file_mapped\":\n\t\t\tout[\"mapped\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_rss\": // v1 only\n\t\t\tout[\"rss\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_shmem\", \"shmem\":\n\t\t\tout[\"shmem\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_cache\", \"file\":\n\t\t\tout[\"cache\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\t}\n\t}\n\n\t// Calculated values\n\tout[\"active\"] = out[\"active_anon\"] + out[\"active_file\"]\n\tout[\"inactive\"] = out[\"inactive_anon\"] + out[\"inactive_file\"]\n\n\treturn out, nil\n}", "func GetGPUMemoryFromPodResource(pod *v1.Pod) int {\n\tvar total int\n\tcontainers := pod.Spec.Containers\n\tfor _, container := range containers {\n\t\tif val, ok := container.Resources.Limits[ResourceName]; ok {\n\t\t\ttotal += int(val.Value())\n\t\t}\n\t}\n\treturn total\n}", "func MBUsed() float64 {\n var m runtime.MemStats\n runtime.ReadMemStats(&m)\n return float64(m.TotalAlloc) / BytesPerMBF \n}", "func GetStat() map[string]interface{} {\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\t// For info on each, see: https://golang.org/pkg/runtime/#MemStats\n\talloc := m.Alloc / 1024 / 1024\n\ttotalAlloc := m.TotalAlloc / 1024 / 1024\n\tsys := m.Sys / 1024 / 1024\n\tday, hour, min, sec := reqcounter.GetCounters()\n\treturn map[string]interface{}{\n\t\t\"alloc\": alloc,\n\t\t\"total_alloc\": totalAlloc,\n\t\t\"sys\": sys,\n\t\t\"requests_per_day\": day,\n\t\t\"requests_per_hour\": hour,\n\t\t\"requests_per_minute\": min,\n\t\t\"requests_per_second\": sec,\n\t}\n}", "func GetCPUMetricsLen() int {\n\treturn len(cpuMetrics)\n}", "func (o ElastigroupIntegrationKubernetesAutoscaleHeadroomOutput) MemoryPerUnit() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupIntegrationKubernetesAutoscaleHeadroom) *int { return v.MemoryPerUnit }).(pulumi.IntPtrOutput)\n}", "func alloc() uint64 {\n\tvar stats runtime.MemStats\n\truntime.GC()\n\truntime.ReadMemStats(&stats)\n\t// return stats.Alloc - uint64(unsafe.Sizeof(hs[0]))*uint64(cap(hs))\n\treturn stats.Alloc\n}", "func Allocs(nomad *NomadServer) []Alloc {\n\tallocs := make([]Alloc, 0)\n\tdecodeJSON(url(nomad)+\"/v1/allocations\", &allocs)\n\treturn allocs\n}", "func (pi *PartitionInfo) MemoryUsage() (sum int64) {\n\tif pi == nil {\n\t\treturn\n\t}\n\n\tsum = emptyPartitionInfoSize\n\tfor _, cond := range pi.PruningConds {\n\t\tsum += cond.MemoryUsage()\n\t}\n\tfor _, cis := range pi.PartitionNames {\n\t\tsum += cis.MemoryUsage()\n\t}\n\tfor _, col := range pi.Columns {\n\t\tsum += col.MemoryUsage()\n\t}\n\tfor _, colName := range pi.ColumnNames {\n\t\tsum += colName.MemoryUsage()\n\t}\n\treturn\n}", "func (cgCache *consumerGroupCache) incNumOpenConns(delta int32) int32 {\n\treturn int32(cgCache.cgMetrics.Add(load.CGMetricNumOpenConns, int64(delta)))\n}", "func (p *ProcMetrics) Collect() {\n\tif m, err := CollectProcInfo(p.pid); err == nil {\n\t\tnow := time.Now()\n\n\t\tif !p.lastTime.IsZero() {\n\t\t\tratio := 1.0\n\t\t\tswitch {\n\t\t\tcase m.CPU.Period > 0 && m.CPU.Quota > 0:\n\t\t\t\tratio = float64(m.CPU.Quota) / float64(m.CPU.Period)\n\t\t\tcase m.CPU.Shares > 0:\n\t\t\t\tratio = float64(m.CPU.Shares) / 1024\n\t\t\tdefault:\n\t\t\t\tratio = 1 / float64(runtime.NumCPU())\n\t\t\t}\n\n\t\t\tinterval := ratio * float64(now.Sub(p.lastTime))\n\n\t\t\tp.cpu.user.time = m.CPU.User - p.last.CPU.User\n\t\t\tp.cpu.user.percent = 100 * float64(p.cpu.user.time) / interval\n\n\t\t\tp.cpu.system.time = m.CPU.Sys - p.last.CPU.Sys\n\t\t\tp.cpu.system.percent = 100 * float64(p.cpu.system.time) / interval\n\n\t\t\tp.cpu.total.time = (m.CPU.User + m.CPU.Sys) - (p.last.CPU.User + p.last.CPU.Sys)\n\t\t\tp.cpu.total.percent = 100 * float64(p.cpu.total.time) / interval\n\t\t}\n\n\t\tp.memory.available = m.Memory.Available\n\t\tp.memory.size = m.Memory.Size\n\t\tp.memory.resident.usage = m.Memory.Resident\n\t\tp.memory.resident.percent = 100 * float64(p.memory.resident.usage) / float64(p.memory.available)\n\t\tp.memory.shared.usage = m.Memory.Shared\n\t\tp.memory.text.usage = m.Memory.Text\n\t\tp.memory.data.usage = m.Memory.Data\n\t\tp.memory.pagefault.major.count = m.Memory.MajorPageFaults - p.last.Memory.MajorPageFaults\n\t\tp.memory.pagefault.minor.count = m.Memory.MinorPageFaults - p.last.Memory.MinorPageFaults\n\n\t\tp.files.open = m.Files.Open\n\t\tp.files.max = m.Files.Max\n\n\t\tp.threads.num = m.Threads.Num\n\t\tp.threads.switches.voluntary.count = m.Threads.VoluntaryContextSwitches - p.last.Threads.VoluntaryContextSwitches\n\t\tp.threads.switches.involuntary.count = m.Threads.InvoluntaryContextSwitches - p.last.Threads.InvoluntaryContextSwitches\n\n\t\tp.last = m\n\t\tp.lastTime = now\n\t\tp.engine.Report(p)\n\t}\n}", "func (m *memStats) Log(segment string) {\n\tvar s runtime.MemStats\n\truntime.ReadMemStats(&s)\n\tm.logf(\"\\n\\n[%s] %d-collections:\\n\", segment, m.Collections)\n\tm.indent += 2\n\n\tm.logf(\"General statistics\\n\")\n\tm.indent += 2\n\tm.logColumns(\n\t\t[]interface{}{\"Alloc\", m.fmtBytes(s.Alloc), \"(allocated and still in use)\"},\n\t\t[]interface{}{\"TotalAlloc\", m.fmtBytes(s.TotalAlloc), \"(allocated (even if freed))\"},\n\t\t[]interface{}{\"Sys\", m.fmtBytes(s.Sys), \"(obtained from system (sum of XxxSys below))\"},\n\t\t[]interface{}{\"Lookups\", s.Lookups, \"(number of pointer lookups)\"},\n\t\t[]interface{}{\"Mallocs\", s.Mallocs, \"(number of mallocs)\"},\n\t\t[]interface{}{\"Frees\", s.Frees, \"(number of frees)\"},\n\t)\n\tm.indent -= 2\n\tfmt.Printf(\"\\n\")\n\n\tm.logf(\"Main allocation heap statistics\\n\")\n\tm.indent += 2\n\tm.logColumns(\n\t\t[]interface{}{\"HeapAlloc\", m.fmtBytes(s.HeapAlloc), \"(allocated and still in use)\"},\n\t\t[]interface{}{\"HeapSys\", m.fmtBytes(s.HeapSys), \"(obtained from system)\"},\n\t\t[]interface{}{\"HeapIdle\", m.fmtBytes(s.HeapIdle), \"(in idle spans)\"},\n\t\t[]interface{}{\"HeapInuse\", m.fmtBytes(s.HeapInuse), \"(in non-idle span)\"},\n\t\t[]interface{}{\"HeapReleased\", m.fmtBytes(s.HeapReleased), \"(released to the OS)\"},\n\t\t[]interface{}{\"HeapObjects\", s.HeapObjects, \"(total number of allocated objects)\"},\n\t)\n\tm.indent -= 2\n\tfmt.Printf(\"\\n\")\n\n\tm.logf(\"Low-level fixed-size structure allocator statistics\\n\")\n\tm.indent += 2\n\tm.logColumns(\n\t\t[]interface{}{\"StackInuse\", m.fmtBytes(s.StackInuse), \"(used by stack allocator right now)\"},\n\t\t[]interface{}{\"StackSys\", m.fmtBytes(s.StackSys), \"(obtained from system)\"},\n\t\t[]interface{}{\"MSpanInuse\", m.fmtBytes(s.MSpanInuse), \"(mspan structures / in use now)\"},\n\t\t[]interface{}{\"MSpanSys\", m.fmtBytes(s.MSpanSys), \"(obtained from system)\"},\n\t\t[]interface{}{\"MCacheInuse\", m.fmtBytes(s.MCacheInuse), \"(in use now))\"},\n\t\t[]interface{}{\"MCacheSys\", m.fmtBytes(s.MCacheSys), \"(mcache structures / obtained from system)\"},\n\t\t[]interface{}{\"BuckHashSys\", m.fmtBytes(s.BuckHashSys), \"(profiling bucket hash table / obtained from system)\"},\n\t\t[]interface{}{\"GCSys\", m.fmtBytes(s.GCSys), \"(GC metadata / obtained form system)\"},\n\t\t[]interface{}{\"OtherSys\", m.fmtBytes(s.OtherSys), \"(other system allocations)\"},\n\t)\n\tfmt.Printf(\"\\n\")\n\tm.indent -= 2\n\n\t// TODO(slimsag): remaining GC fields may be useful later:\n\t/*\n\t // Garbage collector statistics.\n\t NextGC uint64 // next collection will happen when HeapAlloc ≥ this amount\n\t LastGC uint64 // end time of last collection (nanoseconds since 1970)\n\t PauseTotalNs uint64\n\t PauseNs [256]uint64 // circular buffer of recent GC pause durations, most recent at [(NumGC+255)%256]\n\t PauseEnd [256]uint64 // circular buffer of recent GC pause end times\n\t NumGC uint32\n\t EnableGC bool\n\t DebugGC bool\n\n\t // Per-size allocation statistics.\n\t // 61 is NumSizeClasses in the C code.\n\t BySize [61]struct {\n\t Size uint32\n\t Mallocs uint64\n\t Frees uint64\n\t }\n\t*/\n}", "func (m *metricFlinkJvmGcCollectionsCount) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func (c *ClusterClient) PoolStats() *PoolStats {\n\tvar acc PoolStats\n\tfor _, node := range c.getNodes() {\n\t\ts := node.Client.connPool.Stats()\n\t\tacc.Requests += s.Requests\n\t\tacc.Hits += s.Hits\n\t\tacc.Timeouts += s.Timeouts\n\t\tacc.TotalConns += s.TotalConns\n\t\tacc.FreeConns += s.FreeConns\n\t}\n\treturn &acc\n}", "func (p *Pool) AllocCount() int {\n\tp.RLock()\n\tdefer p.RUnlock()\n\treturn len(p.allocated)\n}", "func (store *operationCountingStore) NumberOfOperations() int {\n\treturn int(store.read + store.write)\n}", "func (r raidLevel) PerDiskSize(targetUseableSize, totalDisks, stripeSize uint64) (usedDisks, perDiskSize uint64) {\n\tperSpanDisks, spans := r.Spans(totalDisks)\n\tusedDisks = perSpanDisks * spans\n\tperDiskSize = r.perDiskSize(spans, perSpanDisks, targetUseableSize)\n\tstripesPerDisk := perDiskSize / stripeSize\n\treturn usedDisks, stripesPerDisk * stripeSize\n}", "func (m *metricMysqlBufferPoolOperations) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func (m *metricBigipPoolRequestCount) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func LogStats() {\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\tlog.Infof(\"Alloc=%v TotalAlloc=%v Sys=%v NumGC=%v Goroutines=%d\",\n\t\tm.Alloc/1024, m.TotalAlloc/1024, m.Sys/1024, m.NumGC, runtime.NumGoroutine())\n\n}", "func PrintMemStats(m *runtime.MemStats, mstats, ostats, astats, gc bool, pauses int) {\n\tif mstats {\n\t\tfmt.Printf(\"Alloc=%h, TotalAlloc=%h, Sys=%h, Lookups=%h, Mallocs=%h, Frees=%h\\n\",\n\t\t\thu(m.Alloc, \"B\"), hu(m.TotalAlloc, \"B\"), hu(m.Sys, \"B\"), hu(m.Lookups, \"\"), hu(m.Mallocs, \"\"), hu(m.Frees, \"\"))\n\t\tfmt.Printf(\"HeapAlloc=%h, HeapSys=%h, HeapIdle=%h, HeapInuse=%h, HeapReleased=%h, HeapObjects=%h, StackInuse=%h, StackSys=%h\\n\",\n\t\t\thu(m.HeapAlloc, \"B\"), hu(m.HeapSys, \"B\"), hu(m.HeapIdle, \"B\"), hu(m.HeapInuse, \"B\"), hu(m.HeapReleased, \"B\"),\n\t\t\thu(m.HeapObjects, \"\"), hu(m.StackInuse, \"B\"), hu(m.StackSys, \"B\"))\n\t\tif ostats {\n\t\t\tfmt.Printf(\"MSpanInuse=%d, MSpanSys=%d, m.MCacheInuse=%d, MCacheSys=%d, BuckHashSys=%d, GCSys=%d, OtherSys=%d\\n\",\n\t\t\t\tm.MSpanInuse, m.MSpanSys, m.MCacheInuse, m.MCacheSys, m.BuckHashSys, m.GCSys, m.OtherSys)\n\t\t}\n\n\t\tt1 := time.Unix(0, int64(m.LastGC))\n\t\t//t2 := time.Now()\n\t\t//t3 := time.Unix(int64(0), int64(m.PauseTotalNs))\n\t\tet := time.Duration(int64(m.PauseTotalNs)) // Since(t3)\n\t\tfmt.Printf(\"NextGC=%h, NumGC=%d, LastGC=%s, PauseTotalNs=%v, NumForcedGC=%d, GCCPUFraction=%0.2f\\n\",\n\t\t\thu(m.NextGC, \"B\"), m.NumGC, t1.Format(\"15:04:05.99\"), et, m.NumForcedGC, m.GCCPUFraction)\n\t}\n\tfmt.Printf(\"\\n\")\n\n\tif astats {\n\t\tfor i, b := range m.BySize {\n\t\t\tif b.Mallocs == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfmt.Printf(\"BySize[%d]: Size=%d, Malloc=%d, Frees=%d\\n\", i, b.Size, b.Mallocs, b.Frees)\n\t\t}\n\t\tfmt.Printf(\"\\n\")\n\t}\n\n\tif gc {\n\t\tPrintCircularBuffer(\"PauseNs\", pauses, int(m.NumGC), true, m.PauseNs)\n\t\tPrintCircularBuffer(\"PauseEnd\", pauses, int(m.NumGC), false, m.PauseEnd)\n\t\tfmt.Printf(\"\\n\")\n\t}\n}", "func (p *PhysicalIndexMergeReader) MemoryUsage() (sum int64) {\n\tif p == nil {\n\t\treturn\n\t}\n\n\tsum = p.physicalSchemaProducer.MemoryUsage() + p.PartitionInfo.MemoryUsage()\n\tif p.tablePlan != nil {\n\t\tsum += p.tablePlan.MemoryUsage()\n\t}\n\n\tfor _, plans := range p.PartialPlans {\n\t\tfor _, plan := range plans {\n\t\t\tsum += plan.MemoryUsage()\n\t\t}\n\t}\n\tfor _, plan := range p.TablePlans {\n\t\tsum += plan.MemoryUsage()\n\t}\n\tfor _, plan := range p.partialPlans {\n\t\tsum += plan.MemoryUsage()\n\t}\n\treturn\n}", "func (m *metricFlinkJvmMemoryNonheapCommitted) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func newMetrics() metrics {\n\treturn metrics{\n\t\tsize: prometheus.NewGauge(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tNamespace: \"openebs\",\n\t\t\t\tName: \"pool_size\",\n\t\t\t\tHelp: \"Size of pool\",\n\t\t\t},\n\t\t),\n\n\t\tstatus: prometheus.NewGaugeVec(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tNamespace: \"openebs\",\n\t\t\t\tName: \"pool_status\",\n\t\t\t\tHelp: `Status of pool (0, 1, 2, 3, 4, 5, 6)= {\"Offline\", \"Online\", \"Degraded\", \"Faulted\", \"Removed\", \"Unavail\", \"NoPoolsAvailable\"}`,\n\t\t\t},\n\t\t\t[]string{\"pool\"},\n\t\t),\n\n\t\tusedCapacity: prometheus.NewGauge(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tNamespace: \"openebs\",\n\t\t\t\tName: \"used_pool_capacity\",\n\t\t\t\tHelp: \"Capacity used by pool\",\n\t\t\t},\n\t\t),\n\n\t\tfreeCapacity: prometheus.NewGauge(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tNamespace: \"openebs\",\n\t\t\t\tName: \"free_pool_capacity\",\n\t\t\t\tHelp: \"Free capacity in pool\",\n\t\t\t},\n\t\t),\n\n\t\tusedCapacityPercent: prometheus.NewGauge(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tNamespace: \"openebs\",\n\t\t\t\tName: \"used_pool_capacity_percent\",\n\t\t\t\tHelp: \"Capacity used by pool in percent\",\n\t\t\t},\n\t\t),\n\n\t\tzpoolListparseErrorCounter: prometheus.NewGauge(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tNamespace: \"openebs\",\n\t\t\t\tName: \"zpool_list_parse_error_count\",\n\t\t\t\tHelp: \"Total no of parsing errors\",\n\t\t\t},\n\t\t),\n\n\t\tzpoolRejectRequestCounter: prometheus.NewGauge(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tNamespace: \"openebs\",\n\t\t\t\tName: \"zpool_reject_request_count\",\n\t\t\t\tHelp: \"Total no of rejected requests of zpool command\",\n\t\t\t},\n\t\t),\n\n\t\tzpoolCommandErrorCounter: prometheus.NewGauge(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tNamespace: \"openebs\",\n\t\t\t\tName: \"zpool_command_error\",\n\t\t\t\tHelp: \"Total no of zpool command errors\",\n\t\t\t},\n\t\t),\n\n\t\tnoPoolAvailableErrorCounter: prometheus.NewGauge(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tNamespace: \"openebs\",\n\t\t\t\tName: \"no_pool_available_error\",\n\t\t\t\tHelp: \"Total no of no pool available errors\",\n\t\t\t},\n\t\t),\n\n\t\tincompleteOutputErrorCounter: prometheus.NewGauge(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tNamespace: \"openebs\",\n\t\t\t\tName: \"zpool_list_incomplete_stdout_error\",\n\t\t\t\tHelp: \"Total no of incomplete stdout of zpool list command errors\",\n\t\t\t},\n\t\t),\n\t}\n}", "func requestsAndLimits(cache kubeCache, now time.Time) []types.MetricPoint {\n\t// object represents a Kubernetes object.\n\ttype object struct {\n\t\tKind string\n\t\tName string\n\t\tNamespace string\n\t}\n\n\ttype resources struct {\n\t\tcpuRequests float64\n\t\tcpuLimits float64\n\t\tmemoryRequests float64\n\t\tmemoryLimits float64\n\t}\n\n\tresourceMap := make(map[object]resources, len(cache.pods))\n\n\tfor _, pod := range cache.pods {\n\t\tkind, name := podOwner(pod, cache.replicasetOwnerByUID)\n\t\tobj := object{\n\t\t\tKind: kind,\n\t\t\tName: name,\n\t\t\tNamespace: podNamespace(pod),\n\t\t}\n\n\t\t// Sum requests and limits over all containers in the pod.\n\t\tfor _, container := range pod.Spec.Containers {\n\t\t\tprevResources := resourceMap[obj]\n\n\t\t\tresourceMap[obj] = resources{\n\t\t\t\tcpuRequests: prevResources.cpuRequests + container.Resources.Requests.Cpu().AsApproximateFloat64(),\n\t\t\t\tcpuLimits: prevResources.cpuLimits + container.Resources.Limits.Cpu().AsApproximateFloat64(),\n\t\t\t\tmemoryRequests: prevResources.memoryRequests + container.Resources.Requests.Memory().AsApproximateFloat64(),\n\t\t\t\tmemoryLimits: prevResources.memoryLimits + container.Resources.Limits.Memory().AsApproximateFloat64(),\n\t\t\t}\n\t\t}\n\t}\n\n\t// There are 4 points per Kubernetes object :\n\t// cpu requests, cpu limits, memory requests, memory limits.\n\tpoints := make([]types.MetricPoint, 0, len(resourceMap)*4)\n\n\tfor obj, resource := range resourceMap {\n\t\tvalues := map[string]float64{\n\t\t\t\"kubernetes_cpu_requests\": resource.cpuRequests,\n\t\t\t\"kubernetes_cpu_limits\": resource.cpuLimits,\n\t\t\t\"kubernetes_memory_requests\": resource.memoryRequests,\n\t\t\t\"kubernetes_memory_limits\": resource.memoryLimits,\n\t\t}\n\n\t\tfor name, value := range values {\n\t\t\tlabels := map[string]string{\n\t\t\t\ttypes.LabelName: name,\n\t\t\t\ttypes.LabelOwnerKind: strings.ToLower(obj.Kind),\n\t\t\t\ttypes.LabelOwnerName: strings.ToLower(obj.Name),\n\t\t\t\ttypes.LabelNamespace: obj.Namespace,\n\t\t\t}\n\n\t\t\tpoints = append(points, types.MetricPoint{\n\t\t\t\tPoint: types.Point{Time: now, Value: value},\n\t\t\t\tLabels: labels,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn points\n}", "func CountSampleDeviceAllocatable(node *v1.Node) int64 {\n\tval, ok := node.Status.Allocatable[v1.ResourceName(SampleDeviceResourceName)]\n\tif !ok {\n\t\treturn 0\n\t}\n\treturn val.Value()\n}", "func GetProportionalBatchMemSize(b coldata.Batch, length int64) int64 {\n\tif length == 0 {\n\t\treturn 0\n\t}\n\tusesSel := b.Selection() != nil\n\tb.SetSelection(true)\n\tselCapacity := cap(b.Selection())\n\tb.SetSelection(usesSel)\n\tproportionalBatchMemSize := int64(0)\n\tif selCapacity > 0 {\n\t\tproportionalBatchMemSize = selVectorSize(selCapacity) * length / int64(selCapacity)\n\t}\n\tfor _, vec := range b.ColVecs() {\n\t\tif vec.CanonicalTypeFamily() == types.BytesFamily {\n\t\t\tproportionalBatchMemSize += int64(vec.Bytes().ProportionalSize(length))\n\t\t} else {\n\t\t\tproportionalBatchMemSize += getVecMemoryFootprint(vec) * length / int64(vec.Capacity())\n\t\t}\n\t}\n\treturn proportionalBatchMemSize\n}", "func (c *Cache) Requests() uint64 {\n\tn := uint64(0)\n\tfor _, shard := range c.shards {\n\t\tn += shard.Requests()\n\t}\n\treturn n\n}", "func (m *metricFlinkJvmMemoryMappedUsed) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func procMem(_ int) (ProcMemStats, error) {\n\treturn ProcMemStats{}, nil\n}", "func (m *metricBigipPoolMemberRequestCount) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func (o ElastigroupIntegrationEcsAutoscaleHeadroomOutput) MemoryPerUnit() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupIntegrationEcsAutoscaleHeadroom) *int { return v.MemoryPerUnit }).(pulumi.IntPtrOutput)\n}", "func GetRuntimeStats() (result map[string]float64) {\n\truntime.ReadMemStats(memStats)\n\n\tnow = time.Now()\n\tdiffTime = now.Sub(lastSampleTime).Seconds()\n\n\tresult = map[string]float64{\n\t\t\"alloc\": float64(memStats.Alloc),\n\t\t\"frees\": float64(memStats.Frees),\n\t\t\"gc.pause_total\": float64(memStats.PauseTotalNs) / nsInMs,\n\t\t\"heap.alloc\": float64(memStats.HeapAlloc),\n\t\t\"heap.objects\": float64(memStats.HeapObjects),\n\t\t\"mallocs\": float64(memStats.Mallocs),\n\t\t\"stack\": float64(memStats.StackInuse),\n\t}\n\n\tif lastPauseNs > 0 {\n\t\tpauseSinceLastSample = memStats.PauseTotalNs - lastPauseNs\n\t\tresult[\"gc.pause_per_second\"] = float64(pauseSinceLastSample) / nsInMs / diffTime\n\t}\n\n\tlastPauseNs = memStats.PauseTotalNs\n\n\tnbGc = memStats.NumGC - lastNumGc\n\tif lastNumGc > 0 {\n\t\tresult[\"gc.gc_per_second\"] = float64(nbGc) / diffTime\n\t}\n\n\t// Collect GC pauses\n\tif nbGc > 0 {\n\t\tif nbGc > 256 {\n\t\t\tnbGc = 256\n\t\t}\n\n\t\tvar i uint32\n\n\t\tfor i = 0; i < nbGc; i++ {\n\t\t\tidx := int((memStats.NumGC-uint32(i))+255) % 256\n\t\t\tpause := float64(memStats.PauseNs[idx])\n\t\t\tresult[\"gc.pause\"] = pause / nsInMs\n\t\t}\n\t}\n\n\t// Store last values\n\tlastNumGc = memStats.NumGC\n\tlastSampleTime = now\n\n\treturn result\n}", "func (o OceanLaunchSpecSchedulingTaskTaskHeadroomOutput) MemoryPerUnit() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v OceanLaunchSpecSchedulingTaskTaskHeadroom) *int { return v.MemoryPerUnit }).(pulumi.IntPtrOutput)\n}", "func (m *metricMysqlBufferPoolPageFlushes) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func (cgCache *consumerGroupCache) getNumOpenConns() int32 {\n\treturn int32(cgCache.cgMetrics.Get(load.CGMetricNumOpenConns))\n}", "func MemoryMetrics(ctx context.Context, base *BaseMetrics, pre *PreData, p *perf.Values, outdir, suffix string) error {\n\tvar innerBase *metrics.BaseMemoryStats\n\tif base != nil {\n\t\tinnerBase = base.innerMetrics\n\t}\n\treturn metrics.LogMemoryStats(ctx, innerBase, ARCFromPre(pre), p, outdir, suffix)\n}", "func (m *metricFlinkJvmMemoryHeapCommitted) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func (s StatsEntry) MemPerc() string {\n\tif s.err != nil {\n\t\treturn fmt.Sprintf(\"--\")\n\t}\n\treturn fmt.Sprintf(\"%.2f%%\", s.memoryPercentage)\n}", "func (m *metricFlinkJvmMemoryMappedTotalCapacity) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func CollectRuntimeMemStats(statsd scopedstatsd.Client, memstatsCurrent *runtime.MemStats, memstatsPrev *runtime.MemStats, tags []string) {\n\t// Collect number of bytes obtained from system.\n\tstatsd.Gauge(\"mem.sys_bytes\", float64(memstatsCurrent.Sys), tags, 1)\n\n\t// Collect number of pointer lookups.\n\tstatsd.Gauge(\"mem.pointer_lookups\", float64(memstatsCurrent.Lookups), tags, 1)\n\n\t// Collect increased heap objects allocated compared to last flush.\n\tstatsd.Count(\"mem.mallocs_total\", int64(memstatsCurrent.Mallocs-memstatsPrev.Mallocs), tags, 1)\n\n\t// Collect increased heap objects freed compared to last flush.\n\tstatsd.Count(\"mem.frees_total\", int64(memstatsCurrent.Frees-memstatsPrev.Frees), tags, 1)\n\n\t// Collect number of mallocs.\n\tstatsd.Gauge(\"mem.mallocs_count\", float64(memstatsCurrent.Mallocs-memstatsCurrent.Frees), tags, 1)\n\n\t// Collect number of bytes newly allocated for heap objects compared to last flush.\n\tstatsd.Count(\"mem.heap_alloc_bytes_total\", int64(memstatsCurrent.TotalAlloc-memstatsPrev.TotalAlloc), tags, 1)\n\n\t// Collect number of heap bytes allocated and still in use.\n\tstatsd.Gauge(\"mem.heap_alloc_bytes\", float64(memstatsCurrent.HeapAlloc), tags, 1)\n\n\t// Collect number of heap bytes obtained from system.\n\tstatsd.Gauge(\"mem.heap_sys_bytes\", float64(memstatsCurrent.HeapSys), tags, 1)\n\n\t// Collect number of heap bytes waiting to be used.\n\tstatsd.Gauge(\"mem.heap_idle_bytes\", float64(memstatsCurrent.HeapIdle), tags, 1)\n\n\t// Collect number of heap bytes that are in use.\n\tstatsd.Gauge(\"mem.heap_inuse_bytes\", float64(memstatsCurrent.HeapInuse), tags, 1)\n\n\t// Collect number of heap bytes released to OS.\n\tstatsd.Gauge(\"mem.heap_released_bytes\", float64(memstatsCurrent.HeapReleased), tags, 1)\n\n\t// Collect number of allocated objects.\n\tstatsd.Gauge(\"mem.heap_objects_count\", float64(memstatsCurrent.HeapObjects), tags, 1)\n\n\t// Collect number of bytes in use by the stack allocator.\n\tstatsd.Gauge(\"mem.stack_inuse_bytes\", float64(memstatsCurrent.StackInuse), tags, 1)\n\n\t// Collect number of bytes obtained from system for stack allocator.\n\tstatsd.Gauge(\"mem.stack_sys_bytes\", float64(memstatsCurrent.StackSys), tags, 1)\n\n\t// Collect number of bytes in use by mspan structures.\n\tstatsd.Gauge(\"mem.mspan_inuse_bytes\", float64(memstatsCurrent.MSpanInuse), tags, 1)\n\n\t// Collect number of bytes used for mspan structures obtained from system.\n\tstatsd.Gauge(\"mem.mspan_sys_bytes\", float64(memstatsCurrent.MSpanSys), tags, 1)\n\n\t// Collect number of bytes in use by mcache structures.\n\tstatsd.Gauge(\"mem.mcache_inuse_bytes\", float64(memstatsCurrent.MCacheInuse), tags, 1)\n\n\t// Collect number of bytes used for mcache structures obtained from system.\n\tstatsd.Gauge(\"mem.mcache_sys_bytes\", float64(memstatsCurrent.MCacheSys), tags, 1)\n\n\t// Collect number of bytes used by the profiling bucket hash table.\n\tstatsd.Gauge(\"mem.buck_hash_sys_bytes\", float64(memstatsCurrent.BuckHashSys), tags, 1)\n\n\t// Collect number of bytes used for garbage collection system metadata.\n\tstatsd.Gauge(\"mem.gc_sys_bytes\", float64(memstatsCurrent.GCSys), tags, 1)\n\n\t// Collect number of bytes used for other system allocations.\n\tstatsd.Gauge(\"mem.other_sys_bytes\", float64(memstatsCurrent.OtherSys), tags, 1)\n\n\t// Collect number of heap bytes when next garbage collection will take pace.\n\tstatsd.Gauge(\"mem.next_gc_bytes\", float64(memstatsCurrent.NextGC), tags, 1)\n}", "func metricDPC(ms pmetric.Metric) int {\n\tswitch ms.Type() {\n\tcase pmetric.MetricTypeGauge:\n\t\treturn ms.Gauge().DataPoints().Len()\n\tcase pmetric.MetricTypeSum:\n\t\treturn ms.Sum().DataPoints().Len()\n\tcase pmetric.MetricTypeHistogram:\n\t\treturn ms.Histogram().DataPoints().Len()\n\tcase pmetric.MetricTypeExponentialHistogram:\n\t\treturn ms.ExponentialHistogram().DataPoints().Len()\n\tcase pmetric.MetricTypeSummary:\n\t\treturn ms.Summary().DataPoints().Len()\n\t}\n\treturn 0\n}", "func TestPallocBitsAlloc(t *testing.T) {\n\ttests := map[string]struct {\n\t\tbefore []BitRange\n\t\tafter []BitRange\n\t\tnpages uintptr\n\t\thits []uint\n\t}{\n\t\t\"AllFree1\": {\n\t\t\tnpages: 1,\n\t\t\thits: []uint{0, 1, 2, 3, 4, 5},\n\t\t\tafter: []BitRange{{0, 6}},\n\t\t},\n\t\t\"AllFree2\": {\n\t\t\tnpages: 2,\n\t\t\thits: []uint{0, 2, 4, 6, 8, 10},\n\t\t\tafter: []BitRange{{0, 12}},\n\t\t},\n\t\t\"AllFree5\": {\n\t\t\tnpages: 5,\n\t\t\thits: []uint{0, 5, 10, 15, 20},\n\t\t\tafter: []BitRange{{0, 25}},\n\t\t},\n\t\t\"AllFree64\": {\n\t\t\tnpages: 64,\n\t\t\thits: []uint{0, 64, 128},\n\t\t\tafter: []BitRange{{0, 192}},\n\t\t},\n\t\t\"AllFree65\": {\n\t\t\tnpages: 65,\n\t\t\thits: []uint{0, 65, 130},\n\t\t\tafter: []BitRange{{0, 195}},\n\t\t},\n\t\t\"SomeFree64\": {\n\t\t\tbefore: []BitRange{{0, 32}, {64, 32}, {100, PallocChunkPages - 100}},\n\t\t\tnpages: 64,\n\t\t\thits: []uint{^uint(0)},\n\t\t\tafter: []BitRange{{0, 32}, {64, 32}, {100, PallocChunkPages - 100}},\n\t\t},\n\t\t\"NoneFree1\": {\n\t\t\tbefore: []BitRange{{0, PallocChunkPages}},\n\t\t\tnpages: 1,\n\t\t\thits: []uint{^uint(0), ^uint(0)},\n\t\t\tafter: []BitRange{{0, PallocChunkPages}},\n\t\t},\n\t\t\"NoneFree2\": {\n\t\t\tbefore: []BitRange{{0, PallocChunkPages}},\n\t\t\tnpages: 2,\n\t\t\thits: []uint{^uint(0), ^uint(0)},\n\t\t\tafter: []BitRange{{0, PallocChunkPages}},\n\t\t},\n\t\t\"NoneFree5\": {\n\t\t\tbefore: []BitRange{{0, PallocChunkPages}},\n\t\t\tnpages: 5,\n\t\t\thits: []uint{^uint(0), ^uint(0)},\n\t\t\tafter: []BitRange{{0, PallocChunkPages}},\n\t\t},\n\t\t\"NoneFree65\": {\n\t\t\tbefore: []BitRange{{0, PallocChunkPages}},\n\t\t\tnpages: 65,\n\t\t\thits: []uint{^uint(0), ^uint(0)},\n\t\t\tafter: []BitRange{{0, PallocChunkPages}},\n\t\t},\n\t\t\"ExactFit1\": {\n\t\t\tbefore: []BitRange{{0, PallocChunkPages/2 - 3}, {PallocChunkPages/2 - 2, PallocChunkPages/2 + 2}},\n\t\t\tnpages: 1,\n\t\t\thits: []uint{PallocChunkPages/2 - 3, ^uint(0)},\n\t\t\tafter: []BitRange{{0, PallocChunkPages}},\n\t\t},\n\t\t\"ExactFit2\": {\n\t\t\tbefore: []BitRange{{0, PallocChunkPages/2 - 3}, {PallocChunkPages/2 - 1, PallocChunkPages/2 + 1}},\n\t\t\tnpages: 2,\n\t\t\thits: []uint{PallocChunkPages/2 - 3, ^uint(0)},\n\t\t\tafter: []BitRange{{0, PallocChunkPages}},\n\t\t},\n\t\t\"ExactFit5\": {\n\t\t\tbefore: []BitRange{{0, PallocChunkPages/2 - 3}, {PallocChunkPages/2 + 2, PallocChunkPages/2 - 2}},\n\t\t\tnpages: 5,\n\t\t\thits: []uint{PallocChunkPages/2 - 3, ^uint(0)},\n\t\t\tafter: []BitRange{{0, PallocChunkPages}},\n\t\t},\n\t\t\"ExactFit65\": {\n\t\t\tbefore: []BitRange{{0, PallocChunkPages/2 - 31}, {PallocChunkPages/2 + 34, PallocChunkPages/2 - 34}},\n\t\t\tnpages: 65,\n\t\t\thits: []uint{PallocChunkPages/2 - 31, ^uint(0)},\n\t\t\tafter: []BitRange{{0, PallocChunkPages}},\n\t\t},\n\t\t\"SomeFree161\": {\n\t\t\tbefore: []BitRange{{0, 185}, {331, 1}},\n\t\t\tnpages: 161,\n\t\t\thits: []uint{332},\n\t\t\tafter: []BitRange{{0, 185}, {331, 162}},\n\t\t},\n\t}\n\tfor name, v := range tests {\n\t\tv := v\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tb := makePallocBits(v.before)\n\t\t\tfor iter, i := range v.hits {\n\t\t\t\ta, _ := b.Find(v.npages, 0)\n\t\t\t\tif i != a {\n\t\t\t\t\tt.Fatalf(\"find #%d picked wrong index: want %d, got %d\", iter+1, i, a)\n\t\t\t\t}\n\t\t\t\tif i != ^uint(0) {\n\t\t\t\t\tb.AllocRange(a, uint(v.npages))\n\t\t\t\t}\n\t\t\t}\n\t\t\twant := makePallocBits(v.after)\n\t\t\tcheckPallocBits(t, b, want)\n\t\t})\n\t}\n}", "func rcMemStats(ctx context.Context, in Params) (out Params, err error) {\n\tout = make(Params)\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\tout[\"Alloc\"] = m.Alloc\n\tout[\"TotalAlloc\"] = m.TotalAlloc\n\tout[\"Sys\"] = m.Sys\n\tout[\"Mallocs\"] = m.Mallocs\n\tout[\"Frees\"] = m.Frees\n\tout[\"HeapAlloc\"] = m.HeapAlloc\n\tout[\"HeapSys\"] = m.HeapSys\n\tout[\"HeapIdle\"] = m.HeapIdle\n\tout[\"HeapInuse\"] = m.HeapInuse\n\tout[\"HeapReleased\"] = m.HeapReleased\n\tout[\"HeapObjects\"] = m.HeapObjects\n\tout[\"StackInuse\"] = m.StackInuse\n\tout[\"StackSys\"] = m.StackSys\n\tout[\"MSpanInuse\"] = m.MSpanInuse\n\tout[\"MSpanSys\"] = m.MSpanSys\n\tout[\"MCacheInuse\"] = m.MCacheInuse\n\tout[\"MCacheSys\"] = m.MCacheSys\n\tout[\"BuckHashSys\"] = m.BuckHashSys\n\tout[\"GCSys\"] = m.GCSys\n\tout[\"OtherSys\"] = m.OtherSys\n\treturn out, nil\n}", "func (m *metricFlinkMemoryManagedTotal) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func GetMemoryResources(reservedMemory map[int]int64, getAvailableMemory func() ([]*topology.Node, []*rtesysinfo.Hugepages, error)) (map[string]PerNUMACounters, error) {\n\tnumaMemory := make(map[string]PerNUMACounters)\n\tnodes, hugepages, err := getAvailableMemory()\n\tif err != nil {\n\t\treturn numaMemory, err\n\t}\n\n\tcounters := make(PerNUMACounters)\n\tfor _, node := range nodes {\n\t\tcounters[node.ID] += node.Memory.TotalUsableBytes\n\t}\n\tmemCounters := make(PerNUMACounters)\n\tfor numaID, amount := range counters {\n\t\treserved := reservedMemory[numaID]\n\t\tif reserved > amount {\n\t\t\t// TODO log\n\t\t\tmemCounters[numaID] = 0\n\t\t}\n\t\tmemCounters[numaID] = amount - reserved\n\t}\n\tnumaMemory[string(corev1.ResourceMemory)] = memCounters\n\n\tfor _, hp := range hugepages {\n\t\tname := rtesysinfo.HugepageResourceNameFromSize(hp.SizeKB)\n\t\thpCounters, ok := numaMemory[name]\n\t\tif !ok {\n\t\t\thpCounters = make(PerNUMACounters)\n\t\t}\n\t\thpCounters[hp.NodeID] += int64(hp.Total)\n\t\tnumaMemory[name] = hpCounters\n\t}\n\n\treturn numaMemory, nil\n}", "func computeConcurrencyAllocation(requiredSum int, classes []allocProblemItem) ([]float64, float64, error) {\n\tif requiredSum < 0 {\n\t\treturn nil, 0, errors.New(\"negative sums are not supported\")\n\t}\n\trequiredSumF := float64(requiredSum)\n\tvar lowSum, highSum, targetSum float64\n\tubRange := minMax{min: float64(math.MaxFloat32)}\n\tlbRange := minMax{min: float64(math.MaxFloat32)}\n\trelativeItems := make([]relativeAllocItem, len(classes))\n\tfor idx, item := range classes {\n\t\ttarget := item.target\n\t\tif item.lowerBound < 0 {\n\t\t\treturn nil, 0, fmt.Errorf(\"lower bound %d is %v but negative lower bounds are not allowed\", idx, item.lowerBound)\n\t\t}\n\t\tif target < item.lowerBound {\n\t\t\treturn nil, 0, fmt.Errorf(\"target %d is %v, which is below its lower bound of %v\", idx, target, item.lowerBound)\n\t\t}\n\t\tif item.upperBound < item.lowerBound {\n\t\t\treturn nil, 0, fmt.Errorf(\"upper bound %d is %v but should not be less than the lower bound %v\", idx, item.upperBound, item.lowerBound)\n\t\t}\n\t\tif target < MinTarget {\n\t\t\t// tweak this to a non-zero value so avoid dividing by zero\n\t\t\ttarget = MinTarget\n\t\t}\n\t\tlowSum += item.lowerBound\n\t\thighSum += item.upperBound\n\t\ttargetSum += target\n\t\trelativeItem := relativeAllocItem{\n\t\t\ttarget: target,\n\t\t\trelativeLowerBound: item.lowerBound / target,\n\t\t\trelativeUpperBound: item.upperBound / target,\n\t\t}\n\t\tubRange.note(relativeItem.relativeUpperBound)\n\t\tlbRange.note(relativeItem.relativeLowerBound)\n\t\trelativeItems[idx] = relativeItem\n\t}\n\tif lbRange.max > 1 {\n\t\treturn nil, 0, fmt.Errorf(\"lbRange.max-1=%v, which is impossible because lbRange.max can not be greater than 1\", lbRange.max-1)\n\t}\n\tif lowSum-requiredSumF > epsilon {\n\t\treturn nil, 0, fmt.Errorf(\"lower bounds sum to %v, which is higher than the required sum of %v\", lowSum, requiredSum)\n\t}\n\tif requiredSumF-highSum > epsilon {\n\t\treturn nil, 0, fmt.Errorf(\"upper bounds sum to %v, which is lower than the required sum of %v\", highSum, requiredSum)\n\t}\n\tans := make([]float64, len(classes))\n\tif requiredSum == 0 {\n\t\treturn ans, 0, nil\n\t}\n\tif lowSum-requiredSumF > -epsilon { // no wiggle room, constrained from below\n\t\tfor idx, item := range classes {\n\t\t\tans[idx] = item.lowerBound\n\t\t}\n\t\treturn ans, lbRange.min, nil\n\t}\n\tif requiredSumF-highSum > -epsilon { // no wiggle room, constrained from above\n\t\tfor idx, item := range classes {\n\t\t\tans[idx] = item.upperBound\n\t\t}\n\t\treturn ans, ubRange.max, nil\n\t}\n\t// Now we know the solution is a unique fairProp in [lbRange.min, ubRange.max].\n\t// See if the solution does not run into any bounds.\n\tfairProp := requiredSumF / targetSum\n\tif lbRange.max <= fairProp && fairProp <= ubRange.min { // no bounds matter\n\t\tfor idx := range classes {\n\t\t\tans[idx] = relativeItems[idx].target * fairProp\n\t\t}\n\t\treturn ans, fairProp, nil\n\t}\n\t// Sadly, some bounds matter.\n\t// We find the solution by sorting the bounds and considering progressively\n\t// higher values of fairProp, starting from lbRange.min.\n\trap := (&relativeAllocProblem{items: relativeItems}).initIndices()\n\tsumSoFar := lowSum\n\tfairProp = lbRange.min\n\tvar sensitiveTargetSum, deltaSensitiveTargetSum float64\n\tvar numSensitiveClasses, deltaSensitiveClasses int\n\tvar nextIdx int\n\t// `nextIdx` is the next `rap` index to consider.\n\t// `sumSoFar` is what the allocs would sum to if the current\n\t// value of `fairProp` solves the problem.\n\t// If the current value of fairProp were the answer then\n\t// `sumSoFar == requiredSum`.\n\t// Otherwise the next increment in fairProp involves changing the allocations\n\t// of `numSensitiveClasses` classes whose targets sum to `sensitiveTargetSum`;\n\t// for the other classes, an upper or lower bound has applied and will continue to apply.\n\t// The last increment of nextIdx calls for adding `deltaSensitiveClasses`\n\t// to `numSensitiveClasses` and adding `deltaSensitiveTargetSum` to `sensitiveTargetSum`.\n\tfor sumSoFar < requiredSumF {\n\t\t// There might be more than one bound that is equal to the current value\n\t\t// of fairProp; find all of them because they will all be relevant to\n\t\t// the next change in fairProp.\n\t\t// Set nextBound to the next bound that is NOT equal to fairProp,\n\t\t// and advance nextIdx to the index of that bound.\n\t\tvar nextBound float64\n\t\tfor {\n\t\t\tsensitiveTargetSum += deltaSensitiveTargetSum\n\t\t\tnumSensitiveClasses += deltaSensitiveClasses\n\t\t\tif nextIdx >= rap.Len() {\n\t\t\t\treturn nil, 0, fmt.Errorf(\"impossible: ran out of bounds to consider in bound-constrained problem\")\n\t\t\t}\n\t\t\tvar itemIdx int\n\t\t\tvar lower bool\n\t\t\tnextBound, itemIdx, lower = rap.decode(nextIdx)\n\t\t\tif lower {\n\t\t\t\tdeltaSensitiveClasses = 1\n\t\t\t\tdeltaSensitiveTargetSum = rap.items[itemIdx].target\n\t\t\t} else {\n\t\t\t\tdeltaSensitiveClasses = -1\n\t\t\t\tdeltaSensitiveTargetSum = -rap.items[itemIdx].target\n\t\t\t}\n\t\t\tnextIdx++\n\t\t\tif nextBound > fairProp {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\t// fairProp can increase to nextBound without passing any intermediate bounds.\n\t\tif numSensitiveClasses == 0 {\n\t\t\t// No classes are affected by the next range of fairProp; skip right past it\n\t\t\tfairProp = nextBound\n\t\t\tcontinue\n\t\t}\n\t\t// See whether fairProp can increase to the solution before passing the next bound.\n\t\tdeltaFairProp := (requiredSumF - sumSoFar) / sensitiveTargetSum\n\t\tnextProp := fairProp + deltaFairProp\n\t\tif nextProp <= nextBound {\n\t\t\tfairProp = nextProp\n\t\t\tbreak\n\t\t}\n\t\t// No, fairProp has to increase above nextBound\n\t\tsumSoFar += (nextBound - fairProp) * sensitiveTargetSum\n\t\tfairProp = nextBound\n\t}\n\tfor idx, item := range classes {\n\t\tans[idx] = math.Max(item.lowerBound, math.Min(item.upperBound, fairProp*relativeItems[idx].target))\n\t}\n\treturn ans, fairProp, nil\n}", "func (m *metricMysqlBufferPoolPages) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func calculateRequestedCPU(pods []*apiv1.Pod) int64 {\n\tvar CPURequests int64\n\tfor _, pod := range pods {\n\t\tCPURequests += getPodCPURequests(pod)\n\t}\n\treturn CPURequests\n}", "func (o ElastigroupIntegrationNomadAutoscaleHeadroomOutput) MemoryPerUnit() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupIntegrationNomadAutoscaleHeadroom) *int { return v.MemoryPerUnit }).(pulumi.IntPtrOutput)\n}", "func getPodCPURequests(pod *apiv1.Pod) int64 {\n\tvar CPUTotal int64\n\tfor _, container := range pod.Spec.Containers {\n\t\tCPUTotal += container.Resources.Requests.Cpu().MilliValue()\n\t}\n\treturn CPUTotal\n}", "func (p *referenceCountedPool) Stats() map[string]interface{} {\n\treturn map[string]interface{}{\n\t\t\"allocated\": p.allocated,\n\t\t\"referenced\": p.referenced,\n\t\t\"returned\": p.returned,\n\t}\n}", "func scopeMetricsDPC(ilm pmetric.ScopeMetrics) int {\n\tdataPointCount := 0\n\tms := ilm.Metrics()\n\tfor k := 0; k < ms.Len(); k++ {\n\t\tdataPointCount += metricDPC(ms.At(k))\n\t}\n\treturn dataPointCount\n}", "func PoolStats(name string) (map[string]interface{}, error) {\n\tcmd := &Cmd{}\n\tres := make(map[string]interface{})\n\terr := NvlistIoctl(zfsHandle.Fd(), ZFS_IOC_POOL_STATS, name, cmd, nil, res, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif cmd.Cookie != 0 {\n\t\treturn nil, syscall.Errno(cmd.Cookie)\n\t}\n\treturn res, nil\n}", "func (o OceanLaunchSpecAutoscaleHeadroomOutput) MemoryPerUnit() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v OceanLaunchSpecAutoscaleHeadroom) *int { return v.MemoryPerUnit }).(pulumi.IntPtrOutput)\n}", "func (lbs *LoadBasedAlg) getTaskAllocations(numIdleWorkers int) (int, bool) {\n\ttotalTasksToStart := 0\n\thaveWaitingTasks := false\n\n\tfor _, className := range lbs.classByDescLoadPct {\n\t\tjc := lbs.jobClasses[className]\n\t\tnumTasksToStart := min(jc.numWaitingTasks, ceil(float32(numIdleWorkers)*(float32(jc.tempNormalizedPct)/100.0)))\n\t\tif jc.numTasksToStart < 0 {\n\t\t\t// we've determined we need to stop numTasksToStart for this class, but the subsequent loan calculation may\n\t\t\t// have determined this class can also get loaners, we'll reduce the number of tasks to stop by the loaner amount.\n\t\t\t// (below outside this if), but we also want to set the normalization pct to 0 to prevent redoing this reduction\n\t\t\t// if we repeat the loan calculation\n\t\t\tjc.tempNormalizedPct = 0.0\n\t\t}\n\n\t\tif (totalTasksToStart + numTasksToStart) > numIdleWorkers {\n\t\t\tnumTasksToStart = numIdleWorkers - totalTasksToStart\n\t\t}\n\t\tjc.numTasksToStart += numTasksToStart\n\t\tjc.numWaitingTasks -= numTasksToStart\n\t\tif jc.numWaitingTasks > 0 {\n\t\t\thaveWaitingTasks = true\n\t\t}\n\t\ttotalTasksToStart += numTasksToStart\n\t}\n\treturn totalTasksToStart, haveWaitingTasks\n}", "func (mtr *Dprdpr1intreg1Metrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.ErrPhvSopNoEop.Size()\n\n\tsz += mtr.ErrPhvEopNoSop.Size()\n\n\tsz += mtr.ErrOhiSopNoEop.Size()\n\n\tsz += mtr.ErrOhiEopNoSop.Size()\n\n\tsz += mtr.ErrPktinSopNoEop.Size()\n\n\tsz += mtr.ErrPktinEopNoSop.Size()\n\n\tsz += mtr.ErrCsumOffsetGtPktSize_4.Size()\n\n\tsz += mtr.ErrCsumOffsetGtPktSize_3.Size()\n\n\tsz += mtr.ErrCsumOffsetGtPktSize_2.Size()\n\n\tsz += mtr.ErrCsumOffsetGtPktSize_1.Size()\n\n\tsz += mtr.ErrCsumOffsetGtPktSize_0.Size()\n\n\tsz += mtr.ErrCsumPhdrOffsetGtPktSize_4.Size()\n\n\tsz += mtr.ErrCsumPhdrOffsetGtPktSize_3.Size()\n\n\tsz += mtr.ErrCsumPhdrOffsetGtPktSize_2.Size()\n\n\tsz += mtr.ErrCsumPhdrOffsetGtPktSize_1.Size()\n\n\tsz += mtr.ErrCsumPhdrOffsetGtPktSize_0.Size()\n\n\tsz += mtr.ErrCsumLocGtPktSize_4.Size()\n\n\tsz += mtr.ErrCsumLocGtPktSize_3.Size()\n\n\tsz += mtr.ErrCsumLocGtPktSize_2.Size()\n\n\tsz += mtr.ErrCsumLocGtPktSize_1.Size()\n\n\tsz += mtr.ErrCsumLocGtPktSize_0.Size()\n\n\tsz += mtr.ErrCrcOffsetGtPktSize.Size()\n\n\tsz += mtr.ErrCrcLocGtPktSize.Size()\n\n\tsz += mtr.ErrPtrFfOverflow.Size()\n\n\tsz += mtr.ErrCsumFfOverflow.Size()\n\n\tsz += mtr.ErrPktoutFfOverflow.Size()\n\n\treturn sz\n}", "func (tj *TensorFlowJob) AllocatedGPU() int64 {\n\tif tj.allocatedGPU > 0 {\n\t\treturn tj.allocatedGPU\n\t}\n\tfor _, pod := range tj.pods {\n\t\ttj.allocatedGPU += gpuInActivePod(pod)\n\t}\n\treturn tj.allocatedGPU\n}", "func (m *metricMysqlBufferPoolDataPages) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func (m *metricBigipNodeRequestCount) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func (m *metricFlinkJvmMemoryMetaspaceCommitted) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func (m *metricFlinkMemoryManagedUsed) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func (m *metricFlinkJvmMemoryDirectUsed) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func (ns *NominalSort) MemoryUsage() (sum int64) {\n\tif ns == nil {\n\t\treturn\n\t}\n\n\tsum = ns.basePhysicalPlan.MemoryUsage() + size.SizeOfSlice + int64(cap(ns.ByItems))*size.SizeOfPointer +\n\t\tsize.SizeOfBool\n\tfor _, byItem := range ns.ByItems {\n\t\tsum += byItem.MemoryUsage()\n\t}\n\treturn\n}", "func (m *Manager) AllocationCount() int {\n\tm.lock.RLock()\n\tdefer m.lock.RUnlock()\n\treturn len(m.allocations)\n}", "func TestAllocGarbageCollector_MakeRoomFor_MaxAllocs(t *testing.T) {\n\tci.Parallel(t)\n\n\tconst maxAllocs = 6\n\trequire := require.New(t)\n\n\tserver, serverAddr, cleanupS := testServer(t, nil)\n\tdefer cleanupS()\n\ttestutil.WaitForLeader(t, server.RPC)\n\n\tclient, cleanup := TestClient(t, func(c *config.Config) {\n\t\tc.GCMaxAllocs = maxAllocs\n\t\tc.GCDiskUsageThreshold = 100\n\t\tc.GCInodeUsageThreshold = 100\n\t\tc.GCParallelDestroys = 1\n\t\tc.GCInterval = time.Hour\n\t\tc.RPCHandler = server\n\t\tc.Servers = []string{serverAddr}\n\t\tc.ConsulConfig.ClientAutoJoin = new(bool)\n\t})\n\tdefer cleanup()\n\twaitTilNodeReady(client, t)\n\n\tjob := mock.Job()\n\tjob.TaskGroups[0].Count = 1\n\tjob.TaskGroups[0].Tasks[0].Driver = \"mock_driver\"\n\tjob.TaskGroups[0].Tasks[0].Config = map[string]interface{}{\n\t\t\"run_for\": \"30s\",\n\t}\n\n\tindex := uint64(98)\n\tnextIndex := func() uint64 {\n\t\tindex++\n\t\treturn index\n\t}\n\n\tupsertJobFn := func(server *nomad.Server, j *structs.Job) {\n\t\tstate := server.State()\n\t\trequire.NoError(state.UpsertJob(structs.MsgTypeTestSetup, nextIndex(), j))\n\t\trequire.NoError(state.UpsertJobSummary(nextIndex(), mock.JobSummary(j.ID)))\n\t}\n\n\t// Insert the Job\n\tupsertJobFn(server, job)\n\n\tupsertAllocFn := func(server *nomad.Server, a *structs.Allocation) {\n\t\tstate := server.State()\n\t\trequire.NoError(state.UpsertAllocs(structs.MsgTypeTestSetup, nextIndex(), []*structs.Allocation{a}))\n\t}\n\n\tupsertNewAllocFn := func(server *nomad.Server, j *structs.Job) *structs.Allocation {\n\t\talloc := mock.Alloc()\n\t\talloc.Job = j\n\t\talloc.JobID = j.ID\n\t\talloc.NodeID = client.NodeID()\n\n\t\tupsertAllocFn(server, alloc)\n\n\t\treturn alloc.Copy()\n\t}\n\n\tvar allocations []*structs.Allocation\n\n\t// Fill the node with allocations\n\tfor i := 0; i < maxAllocs; i++ {\n\t\tallocations = append(allocations, upsertNewAllocFn(server, job))\n\t}\n\n\t// Wait until the allocations are ready\n\ttestutil.WaitForResult(func() (bool, error) {\n\t\tar := len(client.getAllocRunners())\n\n\t\treturn ar == maxAllocs, fmt.Errorf(\"Expected %d allocs, got %d\", maxAllocs, ar)\n\t}, func(err error) {\n\t\tt.Fatalf(\"Allocs did not start: %v\", err)\n\t})\n\n\t// Mark the first three as terminal\n\tfor i := 0; i < 3; i++ {\n\t\tallocations[i].DesiredStatus = structs.AllocDesiredStatusStop\n\t\tupsertAllocFn(server, allocations[i].Copy())\n\t}\n\n\t// Wait until the allocations are stopped\n\ttestutil.WaitForResult(func() (bool, error) {\n\t\tar := client.getAllocRunners()\n\t\tstopped := 0\n\t\tfor _, r := range ar {\n\t\t\tif r.Alloc().TerminalStatus() {\n\t\t\t\tstopped++\n\t\t\t}\n\t\t}\n\n\t\treturn stopped == 3, fmt.Errorf(\"Expected %d terminal allocs, got %d\", 3, stopped)\n\t}, func(err error) {\n\t\tt.Fatalf(\"Allocs did not terminate: %v\", err)\n\t})\n\n\t// Upsert a new allocation\n\t// This does not get appended to `allocations` as we do not use them again.\n\tupsertNewAllocFn(server, job)\n\n\t// A single allocation should be GC'd\n\ttestutil.WaitForResult(func() (bool, error) {\n\t\tar := client.getAllocRunners()\n\t\tdestroyed := 0\n\t\tfor _, r := range ar {\n\t\t\tif r.IsDestroyed() {\n\t\t\t\tdestroyed++\n\t\t\t}\n\t\t}\n\n\t\treturn destroyed == 1, fmt.Errorf(\"Expected %d gc'd ars, got %d\", 1, destroyed)\n\t}, func(err error) {\n\t\tt.Fatalf(\"Allocs did not get GC'd: %v\", err)\n\t})\n\n\t// Upsert a new allocation\n\t// This does not get appended to `allocations` as we do not use them again.\n\tupsertNewAllocFn(server, job)\n\n\t// 2 allocations should be GC'd\n\ttestutil.WaitForResult(func() (bool, error) {\n\t\tar := client.getAllocRunners()\n\t\tdestroyed := 0\n\t\tfor _, r := range ar {\n\t\t\tif r.IsDestroyed() {\n\t\t\t\tdestroyed++\n\t\t\t}\n\t\t}\n\n\t\treturn destroyed == 2, fmt.Errorf(\"Expected %d gc'd ars, got %d\", 2, destroyed)\n\t}, func(err error) {\n\t\tt.Fatalf(\"Allocs did not get GC'd: %v\", err)\n\t})\n\n\t// check that all 8 get run eventually\n\ttestutil.WaitForResult(func() (bool, error) {\n\t\tar := client.getAllocRunners()\n\t\tif len(ar) != 8 {\n\t\t\treturn false, fmt.Errorf(\"expected 8 ARs, found %d: %v\", len(ar), ar)\n\t\t}\n\t\treturn true, nil\n\t}, func(err error) {\n\t\trequire.NoError(err)\n\t})\n}", "func (m *metricFlinkJvmMemoryDirectTotalCapacity) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func (m *metricFlinkJvmMemoryNonheapUsed) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func (o ElastigroupIntegrationDockerSwarmAutoscaleHeadroomOutput) MemoryPerUnit() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupIntegrationDockerSwarmAutoscaleHeadroom) *int { return v.MemoryPerUnit }).(pulumi.IntPtrOutput)\n}", "func (m *metricBigipPoolMemberCount) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func (d *DeviceAccounter) AddAllocs(allocs []*Allocation) (collision bool) {\n\tfor _, a := range allocs {\n\t\t// Filter any terminal allocation\n\t\tif a.TerminalStatus() {\n\t\t\tcontinue\n\t\t}\n\n\t\t// COMPAT(0.11): Remove in 0.11\n\t\t// If the alloc doesn't have the new style resources, it can't have\n\t\t// devices\n\t\tif a.AllocatedResources == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Go through each task resource\n\t\tfor _, tr := range a.AllocatedResources.Tasks {\n\n\t\t\t// Go through each assigned device group\n\t\t\tfor _, device := range tr.Devices {\n\t\t\t\tdevID := device.ID()\n\n\t\t\t\t// Go through each assigned device\n\t\t\t\tfor _, instanceID := range device.DeviceIDs {\n\n\t\t\t\t\t// Mark that we are using the device. It may not be in the\n\t\t\t\t\t// map if the device is no longer being fingerprinted, is\n\t\t\t\t\t// unhealthy, etc.\n\t\t\t\t\tif devInst, ok := d.Devices[*devID]; ok {\n\t\t\t\t\t\tif i, ok := devInst.Instances[instanceID]; ok {\n\t\t\t\t\t\t\t// Mark that the device is in use\n\t\t\t\t\t\t\tdevInst.Instances[instanceID]++\n\n\t\t\t\t\t\t\tif i != 0 {\n\t\t\t\t\t\t\t\tcollision = true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn\n}", "func TestMemoryTracker(ptr unsafe.Pointer, sz C.size_t, op C.rtloader_mem_ops_t) {\n\tswitch op {\n\tcase C.DATADOG_AGENT_RTLOADER_ALLOCATION:\n\t\tAllocations.Add(1)\n\tcase C.DATADOG_AGENT_RTLOADER_FREE:\n\t\tFrees.Add(1)\n\t}\n}", "func TestMemoryTracker(ptr unsafe.Pointer, sz C.size_t, op C.rtloader_mem_ops_t) {\n\tswitch op {\n\tcase C.DATADOG_AGENT_RTLOADER_ALLOCATION:\n\t\tAllocations.Add(1)\n\tcase C.DATADOG_AGENT_RTLOADER_FREE:\n\t\tFrees.Add(1)\n\t}\n}", "func (n *NodeDrainer) batchDrainAllocs(allocs []*structs.Allocation) (uint64, error) {\n\t// Add this to the batch\n\tn.batcher.Lock()\n\tn.batcher.updates = append(n.batcher.updates, allocs...)\n\n\t// Start a new batch if none\n\tfuture := n.batcher.updateFuture\n\tif future == nil {\n\t\tfuture = structs.NewBatchFuture()\n\t\tn.batcher.updateFuture = future\n\t\tn.batcher.updateTimer = time.AfterFunc(n.batcher.batchWindow, func() {\n\t\t\t// Get the pending updates\n\t\t\tn.batcher.Lock()\n\t\t\tupdates := n.batcher.updates\n\t\t\tfuture := n.batcher.updateFuture\n\t\t\tn.batcher.updates = nil\n\t\t\tn.batcher.updateFuture = nil\n\t\t\tn.batcher.updateTimer = nil\n\t\t\tn.batcher.Unlock()\n\n\t\t\t// Perform the batch update\n\t\t\tn.drainAllocs(future, updates)\n\t\t})\n\t}\n\tn.batcher.Unlock()\n\n\tif err := future.Wait(); err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn future.Index(), nil\n}", "func (m *metricAerospikeNamespaceMemoryUsage) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func (o ElastigroupIntegrationKubernetesAutoscaleHeadroomPtrOutput) MemoryPerUnit() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *ElastigroupIntegrationKubernetesAutoscaleHeadroom) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.MemoryPerUnit\n\t}).(pulumi.IntPtrOutput)\n}", "func (p *PhysicalIndexMergeJoin) MemoryUsage() (sum int64) {\n\tif p == nil {\n\t\treturn\n\t}\n\n\tsum = p.PhysicalIndexJoin.MemoryUsage() + size.SizeOfSlice*3 + int64(cap(p.KeyOff2KeyOffOrderByIdx))*size.SizeOfInt +\n\t\tint64(cap(p.CompareFuncs)+cap(p.OuterCompareFuncs))*size.SizeOfFunc + size.SizeOfBool*2\n\treturn\n}", "func NewPrometheusMetrics(namespace string, registry metrics.RegisterGatherer) *prometheusMetrics {\n\tm := &prometheusMetrics{\n\t\tregistry: registry,\n\t}\n\n\tm.AvailableIPs = prometheus.NewGaugeVec(prometheus.GaugeOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: ipamSubsystem,\n\t\tName: \"available_ips\",\n\t\tHelp: \"Total available IPs on Node for IPAM allocation\",\n\t}, []string{LabelTargetNodeName})\n\n\tm.UsedIPs = prometheus.NewGaugeVec(prometheus.GaugeOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: ipamSubsystem,\n\t\tName: \"used_ips\",\n\t\tHelp: \"Total used IPs on Node for IPAM allocation\",\n\t}, []string{LabelTargetNodeName})\n\n\tm.NeededIPs = prometheus.NewGaugeVec(prometheus.GaugeOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: ipamSubsystem,\n\t\tName: \"needed_ips\",\n\t\tHelp: \"Number of IPs that are needed on the Node to satisfy IPAM allocation requests\",\n\t}, []string{LabelTargetNodeName})\n\n\tm.IPsAllocated = prometheus.NewGaugeVec(prometheus.GaugeOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: ipamSubsystem,\n\t\tName: \"ips\",\n\t\tHelp: \"Number of IPs allocated\",\n\t}, []string{\"type\"})\n\n\tm.AllocateIpOps = prometheus.NewCounterVec(prometheus.CounterOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: ipamSubsystem,\n\t\tName: \"ip_allocation_ops\",\n\t\tHelp: \"Number of IP allocation operations\",\n\t}, []string{\"subnet_id\"})\n\n\tm.ReleaseIpOps = prometheus.NewCounterVec(prometheus.CounterOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: ipamSubsystem,\n\t\tName: \"ip_release_ops\",\n\t\tHelp: \"Number of IP release operations\",\n\t}, []string{\"subnet_id\"})\n\n\tm.AllocateInterfaceOps = prometheus.NewCounterVec(prometheus.CounterOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: ipamSubsystem,\n\t\tName: \"interface_creation_ops\",\n\t\tHelp: \"Number of interfaces allocated\",\n\t}, []string{\"subnet_id\"})\n\n\tm.AvailableInterfaces = prometheus.NewGauge(prometheus.GaugeOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: ipamSubsystem,\n\t\tName: \"available_interfaces\",\n\t\tHelp: \"Number of interfaces with addresses available\",\n\t})\n\n\tm.InterfaceCandidates = prometheus.NewGauge(prometheus.GaugeOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: ipamSubsystem,\n\t\tName: \"interface_candidates\",\n\t\tHelp: \"Number of attached interfaces with IPs available for allocation\",\n\t})\n\n\tm.EmptyInterfaceSlots = prometheus.NewGauge(prometheus.GaugeOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: ipamSubsystem,\n\t\tName: \"empty_interface_slots\",\n\t\tHelp: \"Number of empty interface slots available for interfaces to be attached\",\n\t})\n\n\tm.AvailableIPsPerSubnet = prometheus.NewGaugeVec(prometheus.GaugeOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: ipamSubsystem,\n\t\tName: \"available_ips_per_subnet\",\n\t\tHelp: \"Number of available IPs per subnet ID\",\n\t}, []string{\"subnet_id\", \"availability_zone\"})\n\n\tm.Nodes = prometheus.NewGaugeVec(prometheus.GaugeOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: ipamSubsystem,\n\t\tName: \"nodes\",\n\t\tHelp: \"Number of nodes by category { total | in-deficit | at-capacity }\",\n\t}, []string{\"category\"})\n\n\tm.Resync = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: ipamSubsystem,\n\t\tName: \"resync_total\",\n\t\tHelp: \"Number of resync operations to synchronize and resolve IP deficit of nodes\",\n\t})\n\n\tm.Allocation = prometheus.NewHistogramVec(prometheus.HistogramOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: ipamSubsystem,\n\t\tName: \"allocation_duration_seconds\",\n\t\tHelp: \"Allocation ip or interface latency in seconds\",\n\t\tBuckets: merge(\n\t\t\tprometheus.LinearBuckets(0.25, 0.25, 2), // 0.25s, 0.50s\n\t\t\tprometheus.LinearBuckets(1, 1, 60), // 1s, 2s, 3s, ... 60s,\n\t\t),\n\t}, []string{\"type\", \"status\", \"subnet_id\"})\n\n\tm.Release = prometheus.NewHistogramVec(prometheus.HistogramOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: ipamSubsystem,\n\t\tName: \"release_duration_seconds\",\n\t\tHelp: \"Release ip or interface latency in seconds\",\n\t\tBuckets: merge(\n\t\t\tprometheus.LinearBuckets(0.25, 0.25, 2), // 0.25s, 0.50s\n\t\t\tprometheus.LinearBuckets(1, 1, 60), // 1s, 2s, 3s, ... 60s,\n\t\t),\n\t}, []string{\"type\", \"status\", \"subnet_id\"})\n\n\t// pool_maintainer is a more generic name, but for backward compatibility\n\t// of dashboard, keep the metric name deficit_resolver unchanged\n\tm.poolMaintainer = NewTriggerMetrics(namespace, \"deficit_resolver\")\n\tm.k8sSync = NewTriggerMetrics(namespace, \"k8s_sync\")\n\tm.resync = NewTriggerMetrics(namespace, \"resync\")\n\n\tregistry.MustRegister(m.AvailableIPs)\n\tregistry.MustRegister(m.UsedIPs)\n\tregistry.MustRegister(m.NeededIPs)\n\n\tregistry.MustRegister(m.IPsAllocated)\n\tregistry.MustRegister(m.AllocateIpOps)\n\tregistry.MustRegister(m.ReleaseIpOps)\n\tregistry.MustRegister(m.AllocateInterfaceOps)\n\tregistry.MustRegister(m.AvailableInterfaces)\n\tregistry.MustRegister(m.InterfaceCandidates)\n\tregistry.MustRegister(m.EmptyInterfaceSlots)\n\tregistry.MustRegister(m.AvailableIPsPerSubnet)\n\tregistry.MustRegister(m.Nodes)\n\tregistry.MustRegister(m.Resync)\n\tregistry.MustRegister(m.Allocation)\n\tregistry.MustRegister(m.Release)\n\tm.poolMaintainer.Register(registry)\n\tm.k8sSync.Register(registry)\n\tm.resync.Register(registry)\n\n\treturn m\n}", "func (m *metricBigipPoolConnectionCount) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func (m *metricFlinkJvmMemoryHeapUsed) updateCapacity() {\n\tif m.data.Sum().DataPoints().Len() > m.capacity {\n\t\tm.capacity = m.data.Sum().DataPoints().Len()\n\t}\n}", "func TestPallocBitsSummarize(t *testing.T) {\n\tvar emptySum = PackPallocSum(PallocChunkPages, PallocChunkPages, PallocChunkPages)\n\ttype test struct {\n\t\tfree []BitRange // Ranges of free (zero) bits.\n\t\thits []PallocSum\n\t}\n\ttests := make(map[string]test)\n\ttests[\"NoneFree\"] = test{\n\t\tfree: []BitRange{},\n\t\thits: []PallocSum{\n\t\t\tPackPallocSum(0, 0, 0),\n\t\t},\n\t}\n\ttests[\"OnlyStart\"] = test{\n\t\tfree: []BitRange{{0, 10}},\n\t\thits: []PallocSum{\n\t\t\tPackPallocSum(10, 10, 0),\n\t\t},\n\t}\n\ttests[\"OnlyEnd\"] = test{\n\t\tfree: []BitRange{{PallocChunkPages - 40, 40}},\n\t\thits: []PallocSum{\n\t\t\tPackPallocSum(0, 40, 40),\n\t\t},\n\t}\n\ttests[\"StartAndEnd\"] = test{\n\t\tfree: []BitRange{{0, 11}, {PallocChunkPages - 23, 23}},\n\t\thits: []PallocSum{\n\t\t\tPackPallocSum(11, 23, 23),\n\t\t},\n\t}\n\ttests[\"StartMaxEnd\"] = test{\n\t\tfree: []BitRange{{0, 4}, {50, 100}, {PallocChunkPages - 4, 4}},\n\t\thits: []PallocSum{\n\t\t\tPackPallocSum(4, 100, 4),\n\t\t},\n\t}\n\ttests[\"OnlyMax\"] = test{\n\t\tfree: []BitRange{{1, 20}, {35, 241}, {PallocChunkPages - 50, 30}},\n\t\thits: []PallocSum{\n\t\t\tPackPallocSum(0, 241, 0),\n\t\t},\n\t}\n\ttests[\"MultiMax\"] = test{\n\t\tfree: []BitRange{{35, 2}, {40, 5}, {100, 5}},\n\t\thits: []PallocSum{\n\t\t\tPackPallocSum(0, 5, 0),\n\t\t},\n\t}\n\ttests[\"One\"] = test{\n\t\tfree: []BitRange{{2, 1}},\n\t\thits: []PallocSum{\n\t\t\tPackPallocSum(0, 1, 0),\n\t\t},\n\t}\n\ttests[\"AllFree\"] = test{\n\t\tfree: []BitRange{{0, PallocChunkPages}},\n\t\thits: []PallocSum{\n\t\t\temptySum,\n\t\t},\n\t}\n\tfor name, v := range tests {\n\t\tv := v\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tb := makePallocBits(v.free)\n\t\t\t// In the PallocBits we create 1's represent free spots, but in our actual\n\t\t\t// PallocBits 1 means not free, so invert.\n\t\t\tinvertPallocBits(b)\n\t\t\tfor _, h := range v.hits {\n\t\t\t\tcheckPallocSum(t, b.Summarize(), h)\n\t\t\t}\n\t\t})\n\t}\n}" ]
[ "0.58367735", "0.57967895", "0.5711421", "0.5415888", "0.53926235", "0.5278731", "0.5225933", "0.5166099", "0.5140884", "0.50157243", "0.4996488", "0.4967147", "0.49647212", "0.48921716", "0.4846859", "0.48438126", "0.4824856", "0.48070475", "0.47903964", "0.47834903", "0.47779596", "0.47770107", "0.47571737", "0.47135648", "0.47083056", "0.47067395", "0.4691224", "0.46815407", "0.46807116", "0.46403855", "0.46310356", "0.46229765", "0.4618124", "0.46149054", "0.4606531", "0.45995608", "0.4595724", "0.4592799", "0.4591325", "0.4582306", "0.45810446", "0.45634022", "0.45633927", "0.45519158", "0.4540712", "0.4538575", "0.45333314", "0.4526955", "0.4522674", "0.45216694", "0.4519974", "0.45151147", "0.45143217", "0.45044482", "0.45043075", "0.45022494", "0.44998413", "0.44994345", "0.44979483", "0.44969502", "0.449086", "0.4479222", "0.44731465", "0.44720012", "0.44712117", "0.44709504", "0.44671518", "0.44618797", "0.4457911", "0.44551176", "0.445274", "0.44522294", "0.4450136", "0.4450074", "0.4447591", "0.44397804", "0.44347796", "0.4433214", "0.44324708", "0.44260108", "0.4424532", "0.44220167", "0.442104", "0.44174457", "0.44126332", "0.44110438", "0.44073036", "0.4404793", "0.43999523", "0.4396358", "0.43945277", "0.43945277", "0.43933856", "0.43920064", "0.43918476", "0.43801424", "0.43766293", "0.43734095", "0.43683964", "0.43670183" ]
0.7850767
0
AllocedBytesPerOp returns the "B/op" metric, which is calculated as r.MemBytes / r.N.
func (r BenchmarkResult) AllocedBytesPerOp() int64 {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r BenchmarkResult) AllocsPerOp() int64 {}", "func (r BenchmarkResult) NsPerOp() int64 {}", "func getSizeByOP(op int) int {\n\tswitch op {\n\tcase 1:\n\t\treturn 3\n\tcase 2:\n\t\treturn 3\n\tcase 3:\n\t\treturn 1\n\tcase 4:\n\t\treturn 1\n\tcase 5:\n\t\treturn 2\n\tcase 6:\n\t\treturn 2\n\tcase 7:\n\t\treturn 3\n\tcase 8:\n\t\treturn 3\n\tdefault:\n\t\treturn 0\n\t}\n}", "func GetProportionalBatchMemSize(b coldata.Batch, length int64) int64 {\n\tif length == 0 {\n\t\treturn 0\n\t}\n\tusesSel := b.Selection() != nil\n\tb.SetSelection(true)\n\tselCapacity := cap(b.Selection())\n\tb.SetSelection(usesSel)\n\tproportionalBatchMemSize := int64(0)\n\tif selCapacity > 0 {\n\t\tproportionalBatchMemSize = selVectorSize(selCapacity) * length / int64(selCapacity)\n\t}\n\tfor _, vec := range b.ColVecs() {\n\t\tif vec.CanonicalTypeFamily() == types.BytesFamily {\n\t\t\tproportionalBatchMemSize += int64(vec.Bytes().ProportionalSize(length))\n\t\t} else {\n\t\t\tproportionalBatchMemSize += getVecMemoryFootprint(vec) * length / int64(vec.Capacity())\n\t\t}\n\t}\n\treturn proportionalBatchMemSize\n}", "func (s Size) Kilobytes() float64 { return float64(s) / float64(Kilobyte) }", "func MBUsed() float64 {\n var m runtime.MemStats\n runtime.ReadMemStats(&m)\n return float64(m.TotalAlloc) / BytesPerMBF \n}", "func (s *plannerStats) BytesPerFact() int {\n\tr := s.impl.BytesPerFact()\n\treturn s.track(r, \"BytesPerFact\")\n}", "func (p *decoded) BytesPerSample() int {\n\treturn 2\n}", "func (b *Buffer) TotalSize() int64 {\n\treturn int64(len(b.bufs) * allocBufLen)\n}", "func (r raidLevel) PerDiskSize(targetUseableSize, totalDisks, stripeSize uint64) (usedDisks, perDiskSize uint64) {\n\tperSpanDisks, spans := r.Spans(totalDisks)\n\tusedDisks = perSpanDisks * spans\n\tperDiskSize = r.perDiskSize(spans, perSpanDisks, targetUseableSize)\n\tstripesPerDisk := perDiskSize / stripeSize\n\treturn usedDisks, stripesPerDisk * stripeSize\n}", "func BytesSize(bytes float64, format string, prec int) string {\n\n\tif bytes <= 0 {\n\t\treturn \"0\"\n\t}\n\n\t// Default format is decimal: MB, GB\n\tvalue := 1000.0\n\tresFormat := \"\"\n\n\t// Binary format: MiB, GiB\n\tif format == \"binary\" {\n\t\tvalue = 1024.0\n\t\tresFormat = \"i\"\n\t}\n\n\tif bytes < value {\n\t\tstrRes := strconv.FormatFloat(bytes, 'f', prec, 64)\n\t\treturn strings.TrimSuffix(strRes, \".0\") + \"B\"\n\t}\n\n\tdivider, exp := value, 0\n\tfor n := bytes / value; n >= value; n /= value {\n\t\tdivider *= value\n\t\texp++\n\t}\n\n\tstrRes := strconv.FormatFloat(bytes/divider, 'f', prec, 64)\n\tif prec == 0 {\n\t\t\tstrRes = strings.TrimSuffix(strRes, \".0\")\n\t}\n\n\treturn strRes + fmt.Sprintf(\"%c%sB\", \"KMGTPE\"[exp], resFormat)\n}", "func (h *HashTable) getLoadFactor() float64 {\n\treturn float64(*h.size) / float64(len(h.table.buckets))\n}", "func (o Operations) OpThroughput() Throughput {\n\tvar aDur time.Duration\n\tvar aBytes int64\n\tfor _, op := range o {\n\t\tif op.Size > 0 {\n\t\t\taDur += op.Duration()\n\t\t\taBytes += op.Size\n\t\t}\n\t}\n\tif aDur == 0 {\n\t\treturn 0\n\t}\n\treturn Throughput(aBytes) * Throughput(time.Second) / Throughput(aDur)\n}", "func (d *Decoder) TotalSize() string {\n\treturn byten.Size(int64(len(d.buffer)))\n}", "func (s Size) Gibibytes() float64 { return float64(s) / float64(Gibibyte) }", "func DIVB(mr operand.Op) { ctx.DIVB(mr) }", "func (b *opBuffer) len() int { return len(b.ops) - 1 }", "func BytesPerVec() int {\n\treturn bytesPerVec\n}", "func (d Dense) SizeBytes() int {\n\treturn BytesFor(d.len)\n}", "func (c *Cuckoo) GetLoadFactor() float64 {\n\treturn float64(c.Elements) / float64(c.Size)\n}", "func (qmc QueryMemoryContext) computeSizeOfSlab(r Resolution) int64 {\n\tslabDuration := r.SlabDuration()\n\n\tvar sizeOfSlab int64\n\tif qmc.Columnar {\n\t\t// Contains an Offset (int32) and Last (float64) for each sample.\n\t\tsizeOfColumns := (sizeOfInt32 + sizeOfFloat64)\n\t\tif r.IsRollup() {\n\t\t\t// Five additional float64 (First, Min, Max, Sum, Variance) and one uint32\n\t\t\t// (count) per sample\n\t\t\tsizeOfColumns += 5*sizeOfFloat64 + sizeOfUint32\n\t\t}\n\t\tsizeOfSlab = sizeOfTimeSeriesData + (slabDuration/r.SampleDuration())*sizeOfColumns\n\t} else {\n\t\t// Contains a sample structure for each sample.\n\t\tsizeOfSlab = sizeOfTimeSeriesData + (slabDuration/r.SampleDuration())*sizeOfSample\n\t}\n\treturn sizeOfSlab\n}", "func (s Size) Petabytes() float64 { return float64(s) / float64(Petabyte) }", "func GetCPUMetricsLen() int {\n\treturn len(cpuMetrics)\n}", "func (m NumSeriesDistribution) ByteSize() int {\n\treturn 24 + len(m)*numSeriesDistributionBaseSize\n}", "func (b Datasize) Kilobytes() float64 {\n\treturn float64(b / Kilobyte)\n}", "func (o DiskOutput) SizeGb() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v Disk) *int { return v.SizeGb }).(pulumi.IntPtrOutput)\n}", "func ByteSize(b float64) string {\n\tvar (\n\t\tunit string\n\t\tdel float64 = 1\n\t)\n\n\tswitch {\n\tcase b >= YB:\n\t\tunit = \"Y\"\n\t\tdel = YB\n\tcase b >= ZB:\n\t\tunit = \"Z\"\n\t\tdel = ZB\n\tcase b >= EB:\n\t\tunit = \"E\"\n\t\tdel = EB\n\tcase b >= PB:\n\t\tunit = \"P\"\n\t\tdel = PB\n\tcase b >= TB:\n\t\tunit = \"T\"\n\t\tdel = TB\n\tcase b >= GB:\n\t\tunit = \"G\"\n\t\tdel = GB\n\tcase b >= MB:\n\t\tunit = \"M\"\n\t\tdel = MB\n\tcase b >= KB:\n\t\tunit = \"K\"\n\t\tdel = KB\n\tcase b == 0:\n\t\treturn \"0\"\n\tdefault:\n\t\tunit = \"B\"\n\t}\n\treturn strings.TrimSuffix(\n\t\tstrconv.FormatFloat(b/del, 'f', 1, 32),\n\t\t\".0\",\n\t) + unit\n}", "func (ms MVCCStats) GCBytes() int64 {\n\treturn ms.KeyBytes + ms.ValBytes - ms.LiveBytes\n}", "func (store *operationCountingStore) NumberOfOperations() int {\n\treturn int(store.read + store.write)\n}", "func (s Size) Kibibytes() float64 { return float64(s) / float64(Kibibyte) }", "func computeNumOfChunks(totalSize int64, chunkSize int64) uint32 {\n\tif totalSize%chunkSize == 0 {\n\t\treturn uint32(totalSize / chunkSize)\n\t} else {\n\t\treturn uint32(totalSize/chunkSize + 1)\n\t}\n}", "func main() {\n\tfmt.Printf(\"1 KB = %d bytes\\n\", KB)\n\tfmt.Printf(\"1 MB = %d | KB = %d bytes\\n\", MB/KB, MB)\n\tfmt.Printf(\"1 GB = %d | MB = %d | KB = %d bytes\\n\", GB/MB, GB/KB, GB)\n\tfmt.Printf(\"1 TB = %d | GB = %d | MB = %d | KB = %d bytes\\n\", TB/GB, TB/MB, TB/KB, TB)\n}", "func bToMb(b uint64) uint64 {\r\n return b / 1024 / 1024\r\n}", "func (s Size) Gigabytes() float64 { return float64(s) / float64(Gigabyte) }", "func (mtr *Dprdpr0intflopfifo1Metrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.DataMuxForceBypassCrcFlopFfUndflow.Size()\n\n\tsz += mtr.DprCrcInfoFlopFfUndflow.Size()\n\n\tsz += mtr.DprCrcUpdateInfoFlopFfUndflow.Size()\n\n\tsz += mtr.DprCsumInfoFlopFfUndflow.Size()\n\n\tsz += mtr.DataMuxForceBypassCsumFlopFfUndflow.Size()\n\n\tsz += mtr.DprCsumUpdateInfoFlopFfUndflow.Size()\n\n\tsz += mtr.PtrEarlyPktEopInfoFlopFfUndflow.Size()\n\n\tsz += mtr.DataMuxEopErrFlopFfUndflow.Size()\n\n\tsz += mtr.PktinEopErrFlopFfUndflow.Size()\n\n\tsz += mtr.CsumErrFlopFfUndflow.Size()\n\n\tsz += mtr.CrcErrFlopFfUndflow.Size()\n\n\tsz += mtr.DataMuxDropFlopFfUndflow.Size()\n\n\tsz += mtr.PhvPktDataFlopFfUndflow.Size()\n\n\tsz += mtr.PktoutLenCellFlopFfUndflow.Size()\n\n\tsz += mtr.PaddingSizeFlopFfUndflow.Size()\n\n\tsz += mtr.PktinErrFlopFfUndflow.Size()\n\n\tsz += mtr.PhvNoDataFlopFfUndflow.Size()\n\n\tsz += mtr.PtrLookahaedFlopFfUndflow.Size()\n\n\tsz += mtr.EopVldFlopFfUndflow.Size()\n\n\tsz += mtr.CsumCalVldFlopFfUndflow.Size()\n\n\treturn sz\n}", "func (c *Cache) SizeBytes() int {\n\tn := 0\n\tfor _, shard := range c.shards {\n\t\tn += shard.SizeBytes()\n\t}\n\treturn n\n}", "func (p *Pattern) CalcSize() uint8 {\n\tvar s uint8 = 36\n\tfor _, t := range p.Tracks {\n\t\ts += uint8(5 + len(t.Name) + lenTrackHits)\n\t}\n\n\treturn s\n}", "func ByteCount(b int64) string {\n\tconst unit = 1000\n\tif b < unit {\n\t\treturn fmt.Sprintf(\"%d B\", b)\n\t}\n\tdiv, exp := int64(unit), 0\n\tfor n := b / unit; n >= unit; n /= unit {\n\t\tdiv *= unit\n\t\texp++\n\t}\n\treturn fmt.Sprintf(\"%.1f %cB\",\n\t\tfloat64(b)/float64(div), \"kMGTPE\"[exp])\n}", "func (cl *Client) gceVolSize(ctx context.Context, volumeType string, requestedSizeBytes int64) (int64, int64) {\n\toneGib := int64(units.GiB)\n\tvolSize := requestedSizeBytes / oneGib\n\tif volSize*oneGib < requestedSizeBytes {\n\t\tvolSize++\n\t}\n\treturn volSize * oneGib, volSize\n}", "func (s Size) Terabytes() float64 { return float64(s) / float64(Terabyte) }", "func GetRWBytesPerSecond(partition string) (uint64, uint64) {\n // IOCountersStat\n first_ret, err := disk.IOCounters(partition)\n dealwithErr(err)\n\n var firstReadBytes, firstWriteBytes uint64\n for _, io := range first_ret {\n firstReadBytes = io.ReadBytes\n firstWriteBytes = io.WriteBytes\n } // end of for\n\ttime.Sleep(time.Second)\t\n\n // IOCountersStat\n second_ret, err := disk.IOCounters(partition)\n dealwithErr(err)\n\n var secondReadBytes, secondWriteBytes uint64\n for _, io := range second_ret {\n secondReadBytes = io.ReadBytes\n secondWriteBytes = io.WriteBytes\n } // end of for\n time.Sleep(time.Second)\n\n return secondReadBytes-firstReadBytes, secondWriteBytes-firstWriteBytes\n }", "func GetBatchMemSize(b coldata.Batch) int64 {\n\tif b == nil || b == coldata.ZeroBatch {\n\t\treturn 0\n\t}\n\t// We need to get the capacity of the internal selection vector, even if b\n\t// currently doesn't use it, so we set selection to true and will reset\n\t// below.\n\tusesSel := b.Selection() != nil\n\tb.SetSelection(true)\n\tmemUsage := selVectorSize(cap(b.Selection())) + getVecsMemoryFootprint(b.ColVecs())\n\tb.SetSelection(usesSel)\n\treturn memUsage\n}", "func (mtr *Dprdpr1intflopfifo1Metrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.DataMuxForceBypassCrcFlopFfUndflow.Size()\n\n\tsz += mtr.DprCrcInfoFlopFfUndflow.Size()\n\n\tsz += mtr.DprCrcUpdateInfoFlopFfUndflow.Size()\n\n\tsz += mtr.DprCsumInfoFlopFfUndflow.Size()\n\n\tsz += mtr.DataMuxForceBypassCsumFlopFfUndflow.Size()\n\n\tsz += mtr.DprCsumUpdateInfoFlopFfUndflow.Size()\n\n\tsz += mtr.PtrEarlyPktEopInfoFlopFfUndflow.Size()\n\n\tsz += mtr.DataMuxEopErrFlopFfUndflow.Size()\n\n\tsz += mtr.PktinEopErrFlopFfUndflow.Size()\n\n\tsz += mtr.CsumErrFlopFfUndflow.Size()\n\n\tsz += mtr.CrcErrFlopFfUndflow.Size()\n\n\tsz += mtr.DataMuxDropFlopFfUndflow.Size()\n\n\tsz += mtr.PhvPktDataFlopFfUndflow.Size()\n\n\tsz += mtr.PktoutLenCellFlopFfUndflow.Size()\n\n\tsz += mtr.PaddingSizeFlopFfUndflow.Size()\n\n\tsz += mtr.PktinErrFlopFfUndflow.Size()\n\n\tsz += mtr.PhvNoDataFlopFfUndflow.Size()\n\n\tsz += mtr.PtrLookahaedFlopFfUndflow.Size()\n\n\tsz += mtr.EopVldFlopFfUndflow.Size()\n\n\tsz += mtr.CsumCalVldFlopFfUndflow.Size()\n\n\treturn sz\n}", "func decimalBinSize(precision, frac int) int {\n\ttrace_util_0.Count(_mydecimal_00000, 375)\n\tdigitsInt := precision - frac\n\twordsInt := digitsInt / digitsPerWord\n\twordsFrac := frac / digitsPerWord\n\txInt := digitsInt - wordsInt*digitsPerWord\n\txFrac := frac - wordsFrac*digitsPerWord\n\treturn wordsInt*wordSize + dig2bytes[xInt] + wordsFrac*wordSize + dig2bytes[xFrac]\n}", "func (o DiskResponseOutput) SizeGb() pulumi.IntOutput {\n\treturn o.ApplyT(func(v DiskResponse) int { return v.SizeGb }).(pulumi.IntOutput)\n}", "func rate(read int64, t time.Duration) float64 {\n\treturn float64(read) / (1024 * 1024) / t.Seconds()\n}", "func afpacketComputeSize(targetSizeMb int, snaplen int, pageSize int) (\n\tframeSize int, blockSize int, numBlocks int, err error) {\n\n\tif snaplen < pageSize {\n\t\tframeSize = pageSize / (pageSize / snaplen)\n\t} else {\n\t\tframeSize = (snaplen/pageSize + 1) * pageSize\n\t}\n\n\t// 128 is the default from the gopacket library so just use that\n\tblockSize = frameSize * 128\n\tnumBlocks = (targetSizeMb * 1024 * 1024) / blockSize\n\n\tif numBlocks == 0 {\n\t\treturn 0, 0, 0, fmt.Errorf(\"interface buffersize is too small\")\n\t}\n\n\treturn frameSize, blockSize, numBlocks, nil\n}", "func calculateBufferSize(blocks uint64) uint64 {\n\tif nbb := NBufferBlocks; blocks < nbb {\n\t\treturn blocks\n\t} else {\n\t\treturn nbb\n\t}\n}", "func (s *IBBSegment) SizeTotalSize() uint64 {\n\treturn 4\n}", "func dcrPerKBToAtomsPerByte(dcrPerkB float64) (uint64, error) {\n\t// The caller should check for non-positive numbers, but don't allow\n\t// underflow when converting to an unsigned integer.\n\tif dcrPerkB < 0 {\n\t\treturn 0, fmt.Errorf(\"negative fee rate\")\n\t}\n\t// dcrPerkB * 1e8 / 1e3 => atomsPerB\n\tatomsPerKB, err := dcrutil.NewAmount(dcrPerkB)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn uint64(dex.IntDivUp(int64(atomsPerKB), 1000)), nil\n}", "func AllocatorSize() (size uint32) {\n\t// size of freeBuddiesList\n\tsize += MaxOrder * uint32(unsafe.Sizeof(freeBuddiesList{}))\n\n\t// size of bigPagesBitmap\n\tsize += nMaps(_nBigPages) * 4\n\n\t// size of individual freeBuddiesList\n\tfor i := 0; i < MaxOrder; i++ {\n\t\t// maxOrder - 1 pages of order i, further divide by 2 since we use 1 bit\n\t\t// for buddy pair.\n\t\tvar nBuddies uint32 = _nBigPages * (1 << uint32(MaxOrder-i-1))\n\t\tsize += nMaps(nBuddies) * 4\n\t}\n\n\t// size of node pool\n\tsize += nodePoolSize()\n\n\treturn\n}", "func (o MrScalarCoreEbsBlockDeviceOutput) SizeInGb() pulumi.IntOutput {\n\treturn o.ApplyT(func(v MrScalarCoreEbsBlockDevice) int { return v.SizeInGb }).(pulumi.IntOutput)\n}", "func (mtr *Dprdpr0intflopfifo0Metrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.DataMuxForceBypassCrcFlopFfOvflow.Size()\n\n\tsz += mtr.DprCrcInfoFlopFfOvflow.Size()\n\n\tsz += mtr.DprCrcUpdateInfoFlopFfOvflow.Size()\n\n\tsz += mtr.DprCsumInfoFlopFfOvflow.Size()\n\n\tsz += mtr.DataMuxForceBypassCsumFlopFfOvflow.Size()\n\n\tsz += mtr.DprCsumUpdateInfoFlopFfOvflow.Size()\n\n\tsz += mtr.PtrEarlyPktEopInfoFlopFfOvflow.Size()\n\n\tsz += mtr.DataMuxEopErrFlopFfOvflow.Size()\n\n\tsz += mtr.PktinEopErrFlopFfOvflow.Size()\n\n\tsz += mtr.CsumErrFlopFfOvflow.Size()\n\n\tsz += mtr.CrcErrFlopFfOvflow.Size()\n\n\tsz += mtr.DataMuxDropFlopFfOvflow.Size()\n\n\tsz += mtr.PhvPktDataFlopFfOvflow.Size()\n\n\tsz += mtr.PktoutLenCellFlopFfOvflow.Size()\n\n\tsz += mtr.PaddingSizeFlopFfOvflow.Size()\n\n\tsz += mtr.PktinErrFlopFfOvflow.Size()\n\n\tsz += mtr.PhvNoDataFlopFfOvflow.Size()\n\n\tsz += mtr.PtrLookahaedFlopFfOvflow.Size()\n\n\tsz += mtr.EopVldFlopFfOvflow.Size()\n\n\tsz += mtr.CsumCalVldFlopFfOvflow.Size()\n\n\treturn sz\n}", "func (mtr *Dprdpr1intflopfifo0Metrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.DataMuxForceBypassCrcFlopFfOvflow.Size()\n\n\tsz += mtr.DprCrcInfoFlopFfOvflow.Size()\n\n\tsz += mtr.DprCrcUpdateInfoFlopFfOvflow.Size()\n\n\tsz += mtr.DprCsumInfoFlopFfOvflow.Size()\n\n\tsz += mtr.DataMuxForceBypassCsumFlopFfOvflow.Size()\n\n\tsz += mtr.DprCsumUpdateInfoFlopFfOvflow.Size()\n\n\tsz += mtr.PtrEarlyPktEopInfoFlopFfOvflow.Size()\n\n\tsz += mtr.DataMuxEopErrFlopFfOvflow.Size()\n\n\tsz += mtr.PktinEopErrFlopFfOvflow.Size()\n\n\tsz += mtr.CsumErrFlopFfOvflow.Size()\n\n\tsz += mtr.CrcErrFlopFfOvflow.Size()\n\n\tsz += mtr.DataMuxDropFlopFfOvflow.Size()\n\n\tsz += mtr.PhvPktDataFlopFfOvflow.Size()\n\n\tsz += mtr.PktoutLenCellFlopFfOvflow.Size()\n\n\tsz += mtr.PaddingSizeFlopFfOvflow.Size()\n\n\tsz += mtr.PktinErrFlopFfOvflow.Size()\n\n\tsz += mtr.PhvNoDataFlopFfOvflow.Size()\n\n\tsz += mtr.PtrLookahaedFlopFfOvflow.Size()\n\n\tsz += mtr.EopVldFlopFfOvflow.Size()\n\n\tsz += mtr.CsumCalVldFlopFfOvflow.Size()\n\n\treturn sz\n}", "func (s *IBBSegment) TotalSize() uint64 {\n\tif s == nil {\n\t\treturn 0\n\t}\n\n\tvar size uint64\n\tsize += s.ReservedTotalSize()\n\tsize += s.FlagsTotalSize()\n\tsize += s.BaseTotalSize()\n\tsize += s.SizeTotalSize()\n\treturn size\n}", "func getMegabits(data *speedTestData) float64 {\n\treturn (float64(data.Bytes) / 1048576) * 8\n}", "func toKB(n int64) int64 {\n\treturn int64(math.Floor((float64(n) / 1024) + 0.5))\n}", "func DecimalBinSize(precision, frac int) (int, error) {\n\tdigitsInt := precision - frac\n\twordsInt := digitsInt / digitsPerWord\n\twordsFrac := frac / digitsPerWord\n\txInt := digitsInt - wordsInt*digitsPerWord\n\txFrac := frac - wordsFrac*digitsPerWord\n\tif xInt < 0 || xInt >= len(dig2bytes) || xFrac < 0 || xFrac >= len(dig2bytes) {\n\t\treturn 0, ErrBadNumber\n\t}\n\treturn wordsInt*wordSize + dig2bytes[xInt] + wordsFrac*wordSize + dig2bytes[xFrac], nil\n}", "func (m *memStats) fmtBytes(b uint64) string {\n\tvar (\n\t\tkb uint64 = 1024\n\t\tmb uint64 = kb * 1024\n\t\tgb uint64 = mb * 1024\n\t)\n\tif b < kb {\n\t\treturn fmt.Sprintf(\"%dB\", b)\n\t}\n\tif b < mb {\n\t\treturn fmt.Sprintf(\"%dKB\", b/kb)\n\t}\n\tif b < gb {\n\t\treturn fmt.Sprintf(\"%dMB\", b/mb)\n\t}\n\treturn fmt.Sprintf(\"%dGB\", b/gb)\n}", "func (o MrScalarTaskEbsBlockDeviceOutput) SizeInGb() pulumi.IntOutput {\n\treturn o.ApplyT(func(v MrScalarTaskEbsBlockDevice) int { return v.SizeInGb }).(pulumi.IntOutput)\n}", "func (v CachingType) TotalSize() uint64 {\n\treturn uint64(binary.Size(v))\n}", "func (mtr *Mcmc2mchintmcMetrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.Ecc_1BitThreshPs1.Size()\n\n\tsz += mtr.Ecc_1BitThreshPs0.Size()\n\n\treturn sz\n}", "func (vbl *VertexLayout) stride() int {\n\tsize := 0\n\tfor _, i := range vbl.layout {\n\t\tsize += i.getByteSize()\n\t}\n\n\treturn size\n}", "func (s *IBBSegment) BaseTotalSize() uint64 {\n\treturn 4\n}", "func (store *operationCountingStore) WriteRatio() float32 {\n\treturn float32(store.write) / float32(store.NumberOfOperations())\n}", "func (mio *Mio) getOptimalBlockSz(bufSz int) (bsz, gsz int) {\n if bufSz > maxM0BufSz {\n bufSz = maxM0BufSz\n }\n pver := C.m0_pool_version_find(&C.instance.m0c_pools_common,\n &mio.obj.ob_attr.oa_pver)\n if pver == nil {\n log.Panic(\"cannot find the object's pool version\")\n }\n pa := &pver.pv_attr\n if pa.pa_P < pa.pa_N + pa.pa_K + pa.pa_S {\n log.Panic(\"pool width (%v) is less than the parity group size\" +\n \" (%v + %v + %v == %v), check pool parity configuration\",\n pa.pa_P, pa.pa_N, pa.pa_K, pa.pa_S,\n pa.pa_N + pa.pa_K + pa.pa_S)\n }\n\n usz := int(C.m0_obj_layout_id_to_unit_size(mio.objLid))\n gsz = usz * int(pa.pa_N) // group size in data units only\n\n // bs should be max 4-times pool-width deep counting by 1MB units, or\n // 8-times deep counting by 512K units, 16-times deep by 256K units,\n // and so on. Several units to one target will be aggregated to make\n // fewer network RPCs, disk i/o operations and BE transactions.\n // For unit sizes of 32K or less, the koefficient (k) is 128, which\n // makes it 32K * 128 == 4MB - the maximum amount per target when\n // the performance is still good on LNet (which has max 1MB frames).\n // XXX: it may be different on libfabric, should be re-measured.\n k := C.uint(128 / ((usz + 0x7fff) / 0x8000))\n if k == 0 {\n k = 1\n }\n // P * N / (N + K + S) - number of data units to span the pool-width\n maxBs := int(k * C.uint(usz) * pa.pa_P * pa.pa_N /\n (pa.pa_N + pa.pa_K + pa.pa_S))\n maxBs = roundup(maxBs, gsz) // multiple of group size\n\n if bufSz >= maxBs {\n return maxBs, gsz\n } else if bufSz <= gsz {\n return gsz, gsz\n } else {\n return roundup(bufSz, gsz), gsz\n }\n}", "func calcFeePerKb(txDesc *TxDesc, ancestorStats *TxAncestorStats) float64 {\n\ttxSize := txDesc.Tx.MsgTx().SerializeSize()\n\tif ancestorStats.Fees < 0 || ancestorStats.SizeBytes < 0 {\n\t\treturn (float64(txDesc.Fee) * float64(kilobyte)) / float64(txSize)\n\t}\n\treturn (float64(txDesc.Fee+ancestorStats.Fees) * float64(kilobyte)) /\n\t\tfloat64(int64(txSize)+ancestorStats.SizeBytes)\n}", "func (d *DeviceProp) TotalConstMem() uint {\n\treturn (uint)(d.totalConstMem)\n}", "func (s Size) Pebibytes() float64 { return float64(s) / float64(Pebibyte) }", "func (m *logMeasurement) bytes() int {\n\tvar b int\n\tb += len(m.name)\n\tfor k, v := range m.tagSet {\n\t\tb += len(k)\n\t\tb += v.bytes()\n\t}\n\tb += (int(m.cardinality()) * 8)\n\tb += int(unsafe.Sizeof(*m))\n\treturn b\n}", "func (opts *UniversalCompactionOptions) GetSizeRatio() int {\n\treturn int(C.rocksdb_universal_compaction_options_get_size_ratio(opts.c))\n}", "func (mtr *Msmsintprp2Metrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.Read.Size()\n\n\tsz += mtr.Security.Size()\n\n\tsz += mtr.Decode.Size()\n\n\treturn sz\n}", "func (s Size) Megabytes() float64 { return float64(s) / float64(Megabyte) }", "func (b Bits) Kilobytes() float64 {\n\tbytes := b / KB\n\tbits := b % KB\n\treturn float64(bytes) + float64(bits)/(8*1000)\n}", "func (b *batch) Size() int { return b.size }", "func (a *Array64) count(axis ...int) float64 {\n\tif len(axis) == 0 {\n\t\treturn float64(a.strides[0])\n\t}\n\n\tcnt := 1\n\tfor _, w := range axis {\n\t\tcnt *= a.shape[w]\n\t}\n\n\treturn float64(cnt)\n}", "func (mtr *Mcmc3mchintmcMetrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.Ecc_1BitThreshPs1.Size()\n\n\tsz += mtr.Ecc_1BitThreshPs0.Size()\n\n\treturn sz\n}", "func AvgWidth(b1, b2, bTot Bucket) float64 {\n\treturn b2.Max - b1.Min\n}", "func (f *FileList) TotalByteSize() string {\n\treturn ByteSize(f.totalSize)\n}", "func afpacketComputeSize(target_size_mb int, snaplen int, page_size int) (\n\tframe_size int, block_size int, num_blocks int, err error) {\n\n\tif snaplen < page_size {\n\t\tframe_size = page_size / (page_size / snaplen)\n\t} else {\n\t\tframe_size = (snaplen/page_size + 1) * page_size\n\t}\n\n\t// 128 is the default from the gopacket library so just use that\n\tblock_size = frame_size * 128\n\tnum_blocks = (target_size_mb * 1024 * 1024) / block_size\n\n\tif num_blocks == 0 {\n\t\treturn 0, 0, 0, fmt.Errorf(\"Buffer size too small\")\n\t}\n\n\treturn frame_size, block_size, num_blocks, nil\n}", "func bToMb(b uint64) uint64 {\n\treturn b / 1024 / 1024\n}", "func (c *Cache) SizeMaxBytes() int {\n\tn := 0\n\tfor _, shard := range c.shards {\n\t\tn += shard.SizeMaxBytes()\n\t}\n\treturn n\n}", "func (s *IBBSegment) FlagsTotalSize() uint64 {\n\treturn 2\n}", "func (k Keeper) BlockByteSize(ctx sdk.Ctx) (res int64) {\n\tk.Paramstore.Get(ctx, types.KeyBlockByteSize, &res)\n\treturn\n}", "func (mtr *Dppdpp1intsramseccMetrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.DppPhvFifoUncorrectable.Size()\n\n\tsz += mtr.DppPhvFifoCorrectable.Size()\n\n\tsz += mtr.DppOhiFifoUncorrectable.Size()\n\n\tsz += mtr.DppOhiFifoCorrectable.Size()\n\n\treturn sz\n}", "func (mtr *Mcmc1mchintmcMetrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.Ecc_1BitThreshPs1.Size()\n\n\tsz += mtr.Ecc_1BitThreshPs0.Size()\n\n\treturn sz\n}", "func (o NetworkPacketCaptureOutput) MaximumBytesPerPacket() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *NetworkPacketCapture) pulumi.IntPtrOutput { return v.MaximumBytesPerPacket }).(pulumi.IntPtrOutput)\n}", "func calcBytesLengthForDecimal(m int) int {\n\treturn (m / 9 * 4) + ((m%9)+1)/2\n}", "func (mtr *Dppdpp0intsramseccMetrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.DppPhvFifoUncorrectable.Size()\n\n\tsz += mtr.DppPhvFifoCorrectable.Size()\n\n\tsz += mtr.DppOhiFifoUncorrectable.Size()\n\n\tsz += mtr.DppOhiFifoCorrectable.Size()\n\n\treturn sz\n}", "func (br *BandwidthMeter) Bandwidth() (bytesPerSec float64) {\n deltaSecs := br.lastRead.Sub(br.start).Seconds()\n bytesPerSec = float64(br.bytesRead) / deltaSecs\n return\n}", "func getMegabytesPerSecond(data *speedTestData) float64 {\n\treturn getMegabytes(data) / getSeconds(data)\n}", "func (s Size) Mebibytes() float64 { return float64(s) / float64(Mebibyte) }", "func GetTotalGPUMemory(node *v1.Node) int {\n\tval, ok := node.Status.Capacity[ResourceName]\n\n\tif !ok {\n\t\treturn 0\n\t}\n\n\treturn int(val.Value())\n}", "func (mtr *Mxmx1inteccMetrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.Uncorrectable.Size()\n\n\tsz += mtr.Correctable.Size()\n\n\treturn sz\n}", "func prettyNumBytes(n int64) string {\n\tconst (\n\t\t_ = 1 << (10 * iota)\n\t\tKB\n\t\tMB\n\t\tGB\n\t\tTB\n\t\tPB\n\t)\n\n\ttable := []struct {\n\t\tv int64\n\t\tn string\n\t}{\n\t\t{PB, \"PB\"},\n\t\t{TB, \"TB\"},\n\t\t{GB, \"GB\"},\n\t\t{MB, \"MB\"},\n\t\t{KB, \"KB\"},\n\t}\n\n\tfor _, t := range table {\n\t\tif n > t.v {\n\t\t\treturn fmt.Sprintf(\"%.2f%s\", float64(n)/float64(t.v), t.n)\n\t\t}\n\t}\n\n\t// Less than 1KB\n\treturn fmt.Sprintf(\"%dB\", n)\n}", "func (d *Driver) DbSize(context.Context) (int64, error) {\n\tstatus, err := d.kv.Status()\n\tif err != nil {\n\t\treturn -1, err\n\t}\n\treturn int64(status.Bytes()), nil\n}", "func (mtr *Msmsintprp3Metrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.Read.Size()\n\n\tsz += mtr.Security.Size()\n\n\tsz += mtr.Decode.Size()\n\n\treturn sz\n}", "func (mtr *Mcmc4mchintmcMetrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.Ecc_1BitThreshPs1.Size()\n\n\tsz += mtr.Ecc_1BitThreshPs0.Size()\n\n\treturn sz\n}", "func (mtr *Mcmc6mchintmcMetrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.Ecc_1BitThreshPs1.Size()\n\n\tsz += mtr.Ecc_1BitThreshPs0.Size()\n\n\treturn sz\n}", "func (f *LogFile) bytes() int {\n\tvar b int\n\tb += 24 // mu RWMutex is 24 bytes\n\tb += 16 // wg WaitGroup is 16 bytes\n\tb += int(unsafe.Sizeof(f.id))\n\t// Do not include f.data because it is mmap'd\n\t// TODO(jacobmarble): Uncomment when we are using go >= 1.10.0\n\t//b += int(unsafe.Sizeof(f.w)) + f.w.Size()\n\tb += int(unsafe.Sizeof(f.buf)) + len(f.buf)\n\tb += int(unsafe.Sizeof(f.keyBuf)) + len(f.keyBuf)\n\t// Do not count SeriesFile because it belongs to the code that constructed this Index.\n\tb += int(unsafe.Sizeof(f.size))\n\tb += int(unsafe.Sizeof(f.modTime))\n\tb += int(unsafe.Sizeof(f.seriesIDSet)) + f.seriesIDSet.Bytes()\n\tb += int(unsafe.Sizeof(f.tombstoneSeriesIDSet)) + f.tombstoneSeriesIDSet.Bytes()\n\tb += int(unsafe.Sizeof(f.mms)) + f.mms.bytes()\n\tb += int(unsafe.Sizeof(f.path)) + len(f.path)\n\treturn b\n}" ]
[ "0.63177806", "0.58997047", "0.5833068", "0.5424875", "0.5393999", "0.53623736", "0.5351161", "0.533708", "0.5200899", "0.5046271", "0.5031193", "0.5026935", "0.49018884", "0.4897368", "0.48915893", "0.48873994", "0.48818982", "0.48662895", "0.48648322", "0.48477483", "0.48427543", "0.48312977", "0.4825386", "0.48197252", "0.48146924", "0.480214", "0.48002332", "0.47877908", "0.47869048", "0.47731814", "0.47610468", "0.47608426", "0.47590384", "0.47538954", "0.4727268", "0.47234026", "0.47134307", "0.47104397", "0.46979856", "0.46920943", "0.46775374", "0.46764356", "0.46758276", "0.4673648", "0.46700352", "0.46644187", "0.4663146", "0.46324784", "0.46323302", "0.46298644", "0.46262854", "0.46244547", "0.4620396", "0.460802", "0.46050698", "0.45928547", "0.45845214", "0.45814124", "0.4568263", "0.45669892", "0.45661974", "0.45659044", "0.4565823", "0.4560551", "0.45593637", "0.45591512", "0.45507064", "0.45437953", "0.45373046", "0.45369595", "0.45342276", "0.45334506", "0.45266134", "0.45224524", "0.4521527", "0.45183828", "0.45180938", "0.450818", "0.4506679", "0.44980973", "0.44965687", "0.44930485", "0.44900814", "0.4486563", "0.4485393", "0.4485047", "0.4484297", "0.44825232", "0.44743893", "0.4471971", "0.4468687", "0.4468248", "0.44601402", "0.44575998", "0.44473478", "0.4445234", "0.4444588", "0.44413564", "0.44398367", "0.44369856" ]
0.81515044
0
String returns a summary of the benchmark results. It follows the benchmark result line format from not including the benchmark name. Extra metrics override builtin metrics of the same name. String does not include allocs/op or B/op, since those are reported by MemString.
func (r BenchmarkResult) String() string {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (b *Bench) String() string {\n\tprefix := \" \"\n\tvar buf bytes.Buffer\n\tpercentiles := []float64{5, 50, 70, 90, 95, 99, 99.9, 99.95, 99.99, 100}\n\n\tif b.rps <= 0 {\n\t\tfmt.Fprintf(&buf, \"Duration: %2.2fs, Concurrency: %d, Total runs: %d\\n\", b.timeTaken.Seconds(), b.concurrentRuns, b.calls)\n\t} else {\n\t\tfmt.Fprintf(&buf, \"Rate: %d calls/sec, Duration: %2.2fs, Concurrency: %d, Total runs: %d\\n\", b.rps, b.timeTaken.Seconds(), b.concurrentRuns, b.calls)\n\t}\n\n\tfor n, h := range b.timers {\n\t\tfmt.Fprintf(&buf, \"%s>>Timer: %s \\n\", prefix, n)\n\t\tfor _, p := range percentiles {\n\t\t\tfmt.Fprintf(&buf, \"%s%s%2.2fth percentile: %.2fms\\n\", prefix, prefix, p, float64(h.ValueAtQuantile(p))/1000000)\n\t\t}\n\t\tfmt.Fprintf(&buf, \"%s%sMean: %.2fms\\n\", prefix, prefix, float64(h.Mean())/1000000.0)\n\t}\n\tfor n, count := range b.counters {\n\t\tfmt.Fprintf(&buf, \"%s>>Counter: %s\\n\", prefix, n)\n\t\tfmt.Fprintf(&buf, \"%s%sValue: %d \\n\", prefix, prefix, count)\n\t}\n\treturn buf.String()\n}", "func (r BenchmarkResult) MemString() string {}", "func (s Statistics) String() string {\n\treturn fmt.Sprintf(\"\\nResult statistic:\\nCnt: bad=%v, timeout=%v\\nTime: min=%v, middle=%v, max=%v, full=%v\",\n\t\ts.CntBad, s.CntTimeout, s.MinTime, s.MiddleTime, s.MaxTime, s.FullTime)\n}", "func (s MeterStats) String() string {\n\treturn fmt.Sprintf(\"Meter <%s>: %d since %v, rate: %.3f current, %.3f average\\n\",\n\t\ts.Name, s.TotalCount, s.Start.Format(timeFormat), s.IntervalRatePerS, s.TotalRatePerS)\n}", "func (s *Stats) String() string {\n\tvar total int64\n\tcodes := make(map[string]int64)\n\tfor k, v := range s.StatusCodes {\n\t\tcode := strconv.Itoa(k)[:1] + \"xx\"\n\t\tif k == -1 {\n\t\t\tcode = \"Not Crawled\"\n\t\t}\n\t\ttotal += v\n\t\tcodes[code] += v\n\t}\n\n\tif total == 0 {\n\t\treturn \"\"\n\t}\n\n\t// calculate our crawl rate\n\tnano := float64(s.elapsed) // time.Duration is in nanoseconds\n\tmicro := nano / 1000\n\tmilli := micro / 1000\n\tsecond := milli / 1000\n\trps := total / int64(second)\n\n\tstats := fmt.Sprintf(\"[stats] Crawled: %v Elapsed: %v\\n\", total, s.elapsed)\n\tstats += fmt.Sprintf(\"[stats] Rate: %v per second, %v per minute, %v per hour, %v per day\\n\",\n\t\thumanize.Comma(rps), humanize.Comma(rps*60), humanize.Comma(rps*60*60), humanize.Comma(rps*60*60*24))\n\n\tstats += fmt.Sprint(\"[stats]\")\n\n\tkeys := []string{}\n\tfor k := range codes {\n\t\tkeys = append(keys, k)\n\t}\n\n\tsort.Strings(keys)\n\tfor _, k := range keys {\n\t\tstats += fmt.Sprintf(\"%v (%v%%) \", k, strconv.Itoa(int(100*codes[k]/total)))\n\t}\n\n\tstats += fmt.Sprintf(\"\\n\")\n\treturn stats\n}", "func (r Result) String() string {\n\tif r.Error == nil {\n\t\treturn fmt.Sprintf(\"ok %s (%d ms)\", r.Monitor.Name, r.Latency)\n\t}\n\n\tif r.Latency > 0 {\n\t\treturn fmt.Sprintf(\"FAIL %s: %s (%d ms)\", r.Monitor.Name, r.Error, r.Latency)\n\t}\n\n\treturn fmt.Sprintf(\"FAIL %s: %s\", r.Monitor.Name, r.Error)\n}", "func (s *Summary) String() string {\n\treturn fmt.Sprintf(\n\t\t\"\\n{Connections: %d, RequestRate: %d, RequestTotal: %d, SuccessTotal: %d, ErrorTotal: %d, TimeElapsed: %s, Throughput: %.2f/s}\",\n\t\ts.Connections, s.RequestRate, (s.SuccessTotal + s.ErrorTotal), s.SuccessTotal, s.ErrorTotal, s.TimeElapsed, s.Throughput)\n}", "func (s *FKCheckRuntimeStats) String() string {\n\tbuf := bytes.NewBuffer(make([]byte, 0, 32))\n\tbuf.WriteString(\"total:\")\n\tbuf.WriteString(execdetails.FormatDuration(s.Total))\n\tif s.Check > 0 {\n\t\tbuf.WriteString(\", check:\")\n\t\tbuf.WriteString(execdetails.FormatDuration(s.Check))\n\t}\n\tif s.Lock > 0 {\n\t\tbuf.WriteString(\", lock:\")\n\t\tbuf.WriteString(execdetails.FormatDuration(s.Lock))\n\t}\n\tif s.Keys > 0 {\n\t\tbuf.WriteString(\", foreign_keys:\")\n\t\tbuf.WriteString(strconv.Itoa(s.Keys))\n\t}\n\treturn buf.String()\n}", "func (m Metric) String() string {\n\tswitch m {\n\tcase MetricCPUPercentAllocation:\n\t\treturn \"cpu_percent_allocation\"\n\tcase MetricGPUPercentAllocation:\n\t\treturn \"gpu_percent_allocation\"\n\tcase MetricMemoryPercentAllocation:\n\t\treturn \"memory_percent_allocation\"\n\tcase MetricEphemeralStoragePercentAllocation:\n\t\treturn \"ephemeral_storage_percent_allocation\"\n\tcase MetricPodPercentAllocation:\n\t\treturn \"pod_percent_allocation\"\n\t}\n\n\treturn \"unknown\"\n}", "func (s MetricsSummary) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s *FKCascadeRuntimeStats) String() string {\n\tbuf := bytes.NewBuffer(make([]byte, 0, 32))\n\tbuf.WriteString(\"total:\")\n\tbuf.WriteString(execdetails.FormatDuration(s.Total))\n\tif s.Keys > 0 {\n\t\tbuf.WriteString(\", foreign_keys:\")\n\t\tbuf.WriteString(strconv.Itoa(s.Keys))\n\t}\n\treturn buf.String()\n}", "func (c *Collector) String() string {\n\tc.Lock()\n\tdefer c.Unlock()\n\n\tif len(c.Buckets) == 0 {\n\t\treturn \"\"\n\t}\n\n\tnLen := printfLen(\"%.2f\", c.Min)\n\tif maxLen := printfLen(\"%.2f\", c.Max); maxLen > nLen {\n\t\tnLen = maxLen\n\t}\n\t// if c.Max is +Inf, the second-largest element can be the longest.\n\tif maxLen := printfLen(\"%.2f\", c.Buckets[len(c.Buckets)-1].Min); maxLen > nLen {\n\t\tnLen = maxLen\n\t}\n\n\tcLen := printfLen(\"%d\", c.Count)\n\tsLen := 0\n\n\tvar res strings.Builder\n\n\tfmt.Fprintf(&res, \"[%*s %*s] %*s total%%\", nLen, \"min\", nLen, \"max\", cLen, \"cnt\")\n\n\tif c.PrintSum {\n\t\tsLen = printfLen(\"%.2f\", c.Sum)\n\t\tfmt.Fprintf(&res, \" %*s\", sLen, \"sum\")\n\t}\n\n\tfmt.Fprintf(&res, \" (%d events)\\n\", c.Count)\n\n\tfor _, b := range c.Buckets {\n\t\tpercent := float64(100*b.Count) / float64(c.Count)\n\n\t\tfmt.Fprintf(&res, \"[%*.2f %*.2f] %*d %5.2f%%\", nLen, b.Min, nLen, b.Max, cLen, b.Count, percent)\n\n\t\tif c.PrintSum {\n\t\t\tfmt.Fprintf(&res, \" %*.2f\", sLen, b.Sum)\n\t\t}\n\n\t\tif dots := strings.Repeat(\".\", int(percent)); len(dots) > 0 {\n\t\t\tfmt.Fprint(&res, \" \", dots)\n\t\t}\n\n\t\tfmt.Fprintln(&res)\n\t}\n\n\treturn res.String()\n}", "func (p *Pool) String() string {\n\ts := fmt.Sprintf(\"%+v\", p.Stats)\n\ts = strings.Replace(s, \":\", \"=\", -1)\n\ts = strings.Trim(s, \"{}\")\n\treturn s\n}", "func (s *statGroup) string() string {\n\treturn fmt.Sprintf(\"min: %8.2fms, med: %8.2fms, mean: %8.2fms, max: %7.2fms, stddev: %8.2fms, sum: %5.1fsec, count: %d\", s.min, s.median(), s.mean, s.max, s.stdDev, s.sum/1e3, s.count)\n}", "func (a *Analysis) String() string {\n\tvar out strings.Builder\n\tfmt.Fprintf(&out, \"Name: %s\\nObjectCount: %d\\nTotalSize: %s\\nCreationDate: %s\\nLastModified: %s\\n\",\n\t\ta.Name,\n\t\ta.TotalCount,\n\t\tbyteCountToHuman(a.TotalSize),\n\t\ta.CreationDate.Format(time.RFC3339),\n\t\ta.LastModified.Format(time.RFC3339))\n\tfmt.Fprintf(&out, \"Objects:\\n\")\n\tfor _, o := range a.Objects {\n\t\tfmt.Fprintf(&out, \" * %s\\n\", o)\n\t}\n\tfmt.Fprintf(&out, \"TotalSizePerAccount:\\n\")\n\tfor owner, size := range a.SizePerOwnerID {\n\t\tfmt.Fprintf(&out, \" * %s/%s %s\\n\", byteCountToHuman(size), byteCountToHuman(a.TotalSize), owner)\n\t}\n\treturn out.String()\n}", "func (m *Metric) String() string {\n\treturn fmt.Sprintf(\"%#v\", m)\n}", "func (creator *metricCreatorBase) String() string {\n\treturn formatMetricDesc(creator.fullPrefix, creator.fixedLabelNames, creator.fixedLabelValues)\n}", "func (s RecommendationJobInferenceBenchmark) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (statsResult *Result) Format() string {\n\tformat := \"\"\n\tformat += fmt.Sprintln(\"Summary:\")\n\tformat += fmt.Sprintf(\"\\tClients:\\t%d\\n\", statsResult.Clients)\n\tformat += fmt.Sprintf(\"\\tParallel calls per client:\\t%d\\n\", statsResult.Parallels)\n\tformat += fmt.Sprintf(\"\\tTotal calls:\\t%d\\n\", statsResult.TotalCalls)\n\tformat += fmt.Sprintf(\"\\tTotal time:\\t%.3fs\\n\", statsResult.TotalTime)\n\tformat += fmt.Sprintf(\"\\tRequests per second:\\t%.3f\\n\", statsResult.RequestsPerSecond)\n\tformat += fmt.Sprintf(\"\\tFastest time for request:\\t%.6fms\\n\", statsResult.FastestTimeForRequest)\n\tformat += fmt.Sprintf(\"\\tAverage time per request:\\t%.6fms\\n\", statsResult.AverageTimePerRequest)\n\tformat += fmt.Sprintf(\"\\tSlowest time for request:\\t%.6fms\\n\\n\", statsResult.SlowestTimeForRequest)\n\tformat += fmt.Sprintln(\"Time:\")\n\tformat += fmt.Sprintf(\"\\t00.0001%%\\ttime for request:\\t%.6fms\\n\", statsResult.N000001thMillionthTime)\n\tformat += fmt.Sprintf(\"\\t00.0010%%\\ttime for request:\\t%.6fms\\n\", statsResult.N000010thMillionthTime)\n\tformat += fmt.Sprintf(\"\\t00.0100%%\\ttime for request:\\t%.6fms\\n\", statsResult.N000100thMillionthTime)\n\tformat += fmt.Sprintf(\"\\t00.1000%%\\ttime for request:\\t%.6fms\\n\", statsResult.N001000thMillionthTime)\n\tformat += fmt.Sprintf(\"\\t01.0000%%\\ttime for request:\\t%.6fms\\n\", statsResult.N010000thMillionthTime)\n\tformat += fmt.Sprintf(\"\\t05.0000%%\\ttime for request:\\t%.6fms\\n\", statsResult.N050000thMillionthTime)\n\tformat += fmt.Sprintf(\"\\t10.0000%%\\ttime for request:\\t%.6fms\\n\", statsResult.N100000thMillionthTime)\n\tformat += fmt.Sprintf(\"\\t25.0000%%\\ttime for request:\\t%.6fms\\n\", statsResult.N250000thMillionthTime)\n\tformat += fmt.Sprintf(\"\\t50.0000%%\\ttime for request:\\t%.6fms\\n\", statsResult.N500000thMillionthTime)\n\tformat += fmt.Sprintf(\"\\t75.0000%%\\ttime for request:\\t%.6fms\\n\", statsResult.N750000thMillionthTime)\n\tformat += fmt.Sprintf(\"\\t90.0000%%\\ttime for request:\\t%.6fms\\n\", statsResult.N900000thMillionthTime)\n\tformat += fmt.Sprintf(\"\\t95.0000%%\\ttime for request:\\t%.6fms\\n\", statsResult.N950000thMillionthTime)\n\tformat += fmt.Sprintf(\"\\t99.0000%%\\ttime for request:\\t%.6fms\\n\", statsResult.N990000thMillionthTime)\n\tformat += fmt.Sprintf(\"\\t99.9000%%\\ttime for request:\\t%.6fms\\n\", statsResult.N999000thMillionthTime)\n\tformat += fmt.Sprintf(\"\\t99.9900%%\\ttime for request:\\t%.6fms\\n\", statsResult.N999900thMillionthTime)\n\tformat += fmt.Sprintf(\"\\t99.9990%%\\ttime for request:\\t%.6fms\\n\", statsResult.N999990thMillionthTime)\n\tformat += fmt.Sprintf(\"\\t99.9999%%\\ttime for request:\\t%.6fms\\n\\n\", statsResult.N999999thMillionthTime)\n\n\tif statsResult.TotalRequestBodySizes > 0 {\n\t\tformat += fmt.Sprintln(\"Request:\")\n\t\tformat += fmt.Sprintf(\"\\tTotal request body sizes:\\t%d\\n\", statsResult.TotalRequestBodySizes)\n\t\tformat += fmt.Sprintf(\"\\tAverage body size per request:\\t%.2f Byte\\n\", statsResult.AverageBodySizePerRequest)\n\t\tformat += fmt.Sprintf(\"\\tRequest rate per second:\\t%.2f Byte/s (%.2f MByte/s)\\n\\n\", statsResult.RequestRateBytePerSecond, statsResult.RequestRateMBytePerSecond)\n\t}\n\tif statsResult.TotalResponseBodySizes > 0 {\n\t\tformat += fmt.Sprintln(\"Response:\")\n\t\tformat += fmt.Sprintf(\"\\tTotal response body sizes:\\t%d\\n\", statsResult.TotalResponseBodySizes)\n\t\tformat += fmt.Sprintf(\"\\tAverage body size per response:\\t%.2f Byte\\n\", statsResult.AverageBodySizePerResponse)\n\t\tformat += fmt.Sprintf(\"\\tResponse rate per second:\\t%.2f Byte/s (%.2f MByte/s)\\n\\n\", statsResult.ResponseRateBytePerSecond, statsResult.ResponseRateMBytePerSecond)\n\t}\n\tformat += fmt.Sprintln(\"Result:\")\n\tformat += fmt.Sprintf(\"\\tResponse ok:\\t%d (%.3f%%)\\n\", statsResult.ResponseOk, statsResult.ResponseOkPercentile)\n\tformat += fmt.Sprintf(\"\\tErrors:\\t%d (%.3f%%)\\n\", statsResult.Errors, statsResult.ErrorsPercentile)\n\treturn format\n}", "func (m *InvocationMetrics) ToString() string {\n\treturn fmt.Sprintf(\"On air time: %v, Total time: %v\", m.SocketReadTimestamp.Sub(m.SocketWriteTimestamp), m.InvocationResponseTimestamp.Sub(m.InvocationRequestTimestamp))\n}", "func (s MetricResultV2) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (d *PerfData) String() string {\n\tvar sb strings.Builder\n\tneedsQuotes := strings.ContainsAny(d.Label, \" '=\\\"\")\n\tif needsQuotes {\n\t\tsb.WriteString(\"'\")\n\t}\n\tsb.WriteString(strings.ReplaceAll(d.Label, \"'\", \"''\"))\n\tif needsQuotes {\n\t\tsb.WriteString(\"'\")\n\t}\n\tsb.WriteString(\"=\")\n\tsb.WriteString(fmt.Sprintf(\"%s%s;\", d.value, d.units.String()))\n\tif d.bits&PDAT_WARN != 0 {\n\t\tsb.WriteString(d.warn.String())\n\t}\n\tsb.WriteString(\";\")\n\tif d.bits&PDAT_CRIT != 0 {\n\t\tsb.WriteString(d.crit.String())\n\t}\n\tsb.WriteString(\";\")\n\tif d.bits&PDAT_MIN != 0 {\n\t\tsb.WriteString(d.min)\n\t}\n\tsb.WriteString(\";\")\n\tif d.bits&PDAT_MAX != 0 {\n\t\tsb.WriteString(d.max)\n\t}\n\n\treturn sb.String()\n}", "func (*systemPodMetricsMeasurement) String() string {\n\treturn systemPodMetricsName\n}", "func (m *Metrics) String() string {\n\tb, _ := json.Marshal(m)\n\treturn string(b)\n}", "func (m Meter) String() string {\n\treturn fmt.Sprint(\"Meter[name=\", m.name,\n\t\t\", snapshotInterval=\", m.printInterval,\n\t\t\", start=\", m.start.Format(timeFormat),\n\t\t\", totalCount=\", m.totalCount,\n\t\t\", lastIntervalStart=\", m.lastIntervalStart.Format(timeFormat),\n\t\t\", lastCount=\", m.lastCount,\n\t\t\", lastStats=\", m.lastStats, \"]\")\n}", "func (s Metrics) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s JobMetrics) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (r Result) String() string {\n\treturn fmt.Sprintf(\"%s\\t%0.4f\\t%d\\t%s\\t%s\\t\", r.Status, r.Took, r.Epoch, r.URL, strings.Join(r.Locations, \"|\"))\n}", "func (tr *TimedRun) Summary() string {\n\tb := bytes.Buffer{}\n\n\ttr.cl.Lock()\n\tdefer tr.cl.Unlock()\n\tDefaultFormat.Execute(&b, tr.categories)\n\treturn b.String()\n}", "func (r WriteCounter) String() string {\n\treturn fmt.Sprintf(\"There were %v write operations totaling %v bytes\", r.numWrites, r.numBytes)\n}", "func (s OverallTestResults) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s CurrentMetricResult) String() string {\n\treturn awsutil.Prettify(s)\n}", "func benchCode() string {\n consoleCommand := `go test -bench . -benchtime=1s` // Single place to alter the command line command\n output := ``\n\n output += breakspace + cBold + cCyan + \" Golang Function Benchmarks:\" + cClr\n output += breakspace + cYellow + \" > \" + cClr + consoleCommand + breakspace\n\n output += breakspace\n\n testOutput, _ := exec.Command( \"cmd\", \"/c\", consoleCommand ).Output()\n\n // Alternative code:\n //cmd.Stdout = os.Stdout\n //cmd.Run()\n\n return output + statusColorize( string(testOutput) )\n}", "func (s *Stopwatch) String() string {\n\ts.RLock()\n\tdefer s.RUnlock()\n\n\t// display using local formatting if possible\n\tif s.format != nil {\n\t\treturn s.format(s.elapsedTime)\n\t}\n\t// display using package DefaultFormat\n\treturn DefaultFormat(s.elapsedTime)\n}", "func (s GetMetricStatisticsOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s GetJourneyExecutionMetricsOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (r ShardTimeRanges) SummaryString() string {\n\treturn r.summarize(rangesDuration)\n}", "func (m *ccMetric) String() string {\n\treturn fmt.Sprintf(\n\t\t\"Name: %s, Tags: %+v, Meta: %+v, fields: %+v, Timestamp: %d\",\n\t\tm.name, m.tags, m.meta, m.fields, m.tm.UnixNano(),\n\t)\n}", "func (s *StatGroup) String() string {\n\treturn fmt.Sprintf(\"min: %f, max: %f, mean: %f, count: %d, sum: %f\", s.Min, s.Max, s.Mean, s.Count, s.Sum)\n}", "func (s TestExecutionSummary) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s HistoricalMetricResult) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s UtteranceLevelTestResults) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s Metric) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s Statistics) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s Statistics) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (l *LiveStats) Summary() string {\n\treturn fmt.Sprintf(\n\t\t\"Top K values (approximate):\\n%s\",\n\t\tl.topKCounter.PrettyTable(\n\t\t\tlen(l.pathGroups),\n\t\t\tl.config.Numeric,\n\t\t\tl.config.SortByName,\n\t\t),\n\t)\n}", "func (m MetricDto) String() string {\n\treturn fmt.Sprintf(\"Metric--> key: %s - value: %d\", m.Key, m.Value)\n}", "func (m Monitor) String() string {\n\treturn fmt.Sprintf(\"Monitor '%s' to URL %s, %d headers, %d assertions\", m.Name, m.URL, len(m.Headers), len(m.Assertions))\n}", "func (nt *NodeTable) Stats() string {\n\treturn fmt.Sprintf(\"{\\n\"+\n\t\t`\"FastHTCount\": %d,`+\"\\n\"+\n\t\t`\"SlowHTCount\": %d,`+\"\\n\"+\n\t\t`\"Conflicts\": %d,`+\"\\n\"+\n\t\t`\"MemoryInUse\": %d`+\"\\n}\",\n\t\tnt.fastHTCount, nt.slowHTCount, nt.conflicts, nt.MemoryInUse())\n}", "func (ms *Measurements) String() string {\n\treturn fmt.Sprint(*ms)\n}", "func (s TrialComponentMetricSummary) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (t *SpecTest) String() string { return strings.Join(t.descstack, \" \") }", "func (s MetricData) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (c Counts) Summary() string {\n\treturn c.string(Weights{I: 5, M: 4, S: 3, Pow: 2, ParamM: 1})\n}", "func (s TaskMetric) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s MetricQuery) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (e *LegacyTabletStats) String() string {\n\treturn fmt.Sprint(*e)\n}", "func (s *flowStats) String() string {\n\ttstart := time.Unix(0, s.TimeStart)\n\ttout := int32(s.TimeOut)\n\treturn fmt.Sprintf(\"TS %v, TO %d(sec), proto %d src=%s dst=%s sport=%d dport=%d, snd=pkts/bytes %d/%d rcv=pkts/bytes %d/%d app-init %v, appNum %d, aclnum 0x%x\",\n\t\ttstart, tout, s.Proto, s.SrcIP, s.DstIP, s.SrcPort, s.DstPort, s.SendPkts, s.SendBytes,\n\t\ts.RecvPkts, s.RecvBytes, s.AppInitiate, s.appNum, s.aclNum)\n}", "func Summary() string {\n\treturn DefaultRun.Summary()\n}", "func CalculateGpuSummary() string {\n\tvar GpuFreeMemorys []string\n\tfor _, g := range GPUs {\n\t\telement := strings.Join(\n\t\t\t[]string{\n\t\t\t\tstrconv.FormatInt(int64(g.ID), 10),\n\t\t\t\tstrconv.FormatInt(int64(g.FreeMemory), 10)},\n\t\t\t\"_\")\n\t\tGpuFreeMemorys = append(GpuFreeMemorys, element)\n\t}\n\treturn strings.Join(GpuFreeMemorys, \".\")\n}", "func (c *Counter) String() string {\n\treturn fmt.Sprintf(\"%s\\t%v\",c.key,c.count)\n}", "func (s ModelMetrics) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s GetUsageStatisticsOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s CountsSummary) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (m *MetricUnion) String() string {\n\tswitch m.Type {\n\tcase CounterType:\n\t\treturn fmt.Sprintf(\"{type:%s,id:%s,value:%d}\", m.Type, m.ID.String(), m.CounterVal)\n\tcase BatchTimerType:\n\t\treturn fmt.Sprintf(\"{type:%s,id:%s,value:%v}\", m.Type, m.ID.String(), m.BatchTimerVal)\n\tcase GaugeType:\n\t\treturn fmt.Sprintf(\"{type:%s,id:%s,value:%f}\", m.Type, m.ID.String(), m.GaugeVal)\n\tdefault:\n\t\treturn fmt.Sprintf(\n\t\t\t\"{type:%d,id:%s,counterVal:%d,batchTimerVal:%v,gaugeVal:%f}\",\n\t\t\tm.Type, m.ID.String(), m.CounterVal, m.BatchTimerVal, m.GaugeVal,\n\t\t)\n\t}\n}", "func (s MeterUsageOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s MeterUsageOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s ListUtteranceMetricsOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (counter *Counter) String() string {\n\treturn fmt.Sprintf(\"{count: %d}\", counter.count)\n}", "func (d *dataUsageCache) StringAll() string {\n\ts := fmt.Sprintf(\"info:%+v\\n\", d.Info)\n\tfor k, v := range d.Cache {\n\t\ts += fmt.Sprintf(\"\\t%v: %+v\\n\", k, v)\n\t}\n\treturn strings.TrimSpace(s)\n}", "func (s *Stat) String() string {\n\treturn fmt.Sprintf(\"License propagation: %d added, %d skipped, %d autogenerated files\",\n\t\ts.Added, s.Skipped, s.DoNotModify)\n}", "func (s CacheHitResult) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s InsightResults) String() string {\n\treturn awsutil.Prettify(s)\n}", "func perf(elapsed, total, inputs, tput, index, collectors, failureCollectors, offlineCollectors float64) {\n\tpdata = fmt.Sprintf(\"time=%f;;;; total=%.f;;;; sources=%.f;;;; throughput=%.f;;;; index_failures=%.f;;;; collectors=%.f;;;; collector_failure=%.f;;;; collector_offline=%.f;;;;\", elapsed, total, inputs, tput, index, collectors, failureCollectors, offlineCollectors)\n}", "func (s DeviceStats) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s ComplianceExecutionSummary) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (t *Timing) String() string {\n\tvar builder strings.Builder\n\tbuilder.WriteString(\"Timing(\")\n\tbuilder.WriteString(fmt.Sprintf(\"id=%v\", t.ID))\n\tbuilder.WriteString(\", category=\")\n\tbuilder.WriteString(t.Category)\n\tbuilder.WriteString(\", timing_label=\")\n\tbuilder.WriteString(t.TimingLabel)\n\tbuilder.WriteString(\", unit=\")\n\tbuilder.WriteString(t.Unit)\n\tbuilder.WriteString(\", variable=\")\n\tbuilder.WriteString(t.Variable)\n\tbuilder.WriteString(\", value=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", t.Value))\n\tbuilder.WriteByte(')')\n\treturn builder.String()\n}", "func (s MeasureValue) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s MetricV2) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s BotRecommendationResultStatistics) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s ObjectiveStatusCounters) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (b *Plain) Metric() string {\n\treturn b.section + \".\" + b.operation\n}", "func AccuracyString(i big.Accuracy,) string", "func (ins *ArrayAlloc) String() string {\n\treturn fmt.Sprintf(\"%s = %s with %s elements\", ins.Result, ins.Kind, ins.Size)\n}", "func (s MetricValue) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s MetricValue) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s *SysbenchMemory) Report(b *testing.B, output string) {\n\tb.Helper()\n\tresult, err := s.parseOperations(output)\n\tif err != nil {\n\t\tb.Fatalf(\"parsing result %s failed with err: %v\", output, err)\n\t}\n\tReportCustomMetric(b, result, \"memory_operations\" /*metric name*/, \"ops_per_second\" /*unit*/)\n}", "func (o *Metrics) String() string {\n \n \n \n \n \n \n \n \n \n \n \n\n j, _ := json.Marshal(o)\n str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\\\u`, `\\u`, -1))\n\n return str\n}", "func (s ResourceCountsSummary) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s MetricSpecification) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (me TRequesterStatistic) String() string { return xsdt.String(me).String() }", "func (av AttributeGarbageCollectorName) String() string {\n\tswitch av {\n\tcase AttributeGarbageCollectorNamePSMarkSweep:\n\t\treturn \"PS_MarkSweep\"\n\tcase AttributeGarbageCollectorNamePSScavenge:\n\t\treturn \"PS_Scavenge\"\n\tcase AttributeGarbageCollectorNameG1YoungGeneration:\n\t\treturn \"G1_Young_Generation\"\n\tcase AttributeGarbageCollectorNameG1OldGeneration:\n\t\treturn \"G1_Old_Generation\"\n\t}\n\treturn \"\"\n}", "func metricString(ns []string) string {\n\treturn strings.Join(ns, \"/\")\n}", "func (s Timing) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s MonitoringExecutionSummary) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (o *Apiusageclientquery) String() string {\n \n \n o.Metrics = []string{\"\"} \n o.GroupBy = []string{\"\"} \n\n j, _ := json.Marshal(o)\n str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\\\u`, `\\u`, -1))\n\n return str\n}", "func (e *ExpectedClusterStatus) String() string {\n\treturn \"call to ClusterStatus() which:\" +\n\t\toptionsString(e.options) +\n\t\tdelayString(e.delay) +\n\t\terrorString(e.err)\n}", "func (s RecommendationMetrics) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (t *Trace) String() string {\n\treturn fmt.Sprintf(\"[Total=%+q, Start=%+q, End=%+q]\", t.EndTime.Sub(t.StartTime), t.StartTime, t.EndTime)\n}", "func (d ExecDetails) String() string {\n\tparts := make([]string, 0, 6)\n\tif d.ProcessTime > 0 {\n\t\tparts = append(parts, fmt.Sprintf(\"process_time:%v\", d.ProcessTime))\n\t}\n\tif d.WaitTime > 0 {\n\t\tparts = append(parts, fmt.Sprintf(\"wait_time:%v\", d.WaitTime))\n\t}\n\tif d.BackoffTime > 0 {\n\t\tparts = append(parts, fmt.Sprintf(\"backoff_time:%v\", d.BackoffTime))\n\t}\n\tif d.RequestCount > 0 {\n\t\tparts = append(parts, fmt.Sprintf(\"request_count:%d\", d.RequestCount))\n\t}\n\tif d.TotalKeys > 0 {\n\t\tparts = append(parts, fmt.Sprintf(\"total_keys:%d\", d.TotalKeys))\n\t}\n\tif d.ProcessedKeys > 0 {\n\t\tparts = append(parts, fmt.Sprintf(\"processed_keys:%d\", d.ProcessedKeys))\n\t}\n\treturn strings.Join(parts, \" \")\n}" ]
[ "0.731785", "0.71303135", "0.69172883", "0.66541773", "0.6599185", "0.6460193", "0.64140147", "0.6366368", "0.6177817", "0.60876465", "0.6058911", "0.60517734", "0.6033677", "0.6018531", "0.6002297", "0.60005015", "0.5999122", "0.5949123", "0.59454554", "0.593246", "0.59209394", "0.58954245", "0.5893672", "0.58863926", "0.5871257", "0.58701456", "0.58665997", "0.58620757", "0.5848263", "0.5844587", "0.5838606", "0.5832522", "0.5818001", "0.5798533", "0.5780486", "0.5769621", "0.5734285", "0.5728462", "0.57235134", "0.56941795", "0.56758934", "0.5672962", "0.5671155", "0.5668278", "0.5668278", "0.5667766", "0.56625867", "0.564984", "0.56376565", "0.5635962", "0.5633522", "0.5623889", "0.560784", "0.5605073", "0.56044084", "0.5599739", "0.55929244", "0.55855817", "0.5584243", "0.5577542", "0.55738187", "0.5550562", "0.55366415", "0.55080265", "0.5507205", "0.5496081", "0.5496081", "0.54912835", "0.5490452", "0.5484759", "0.548474", "0.54812247", "0.54795736", "0.5470233", "0.5458862", "0.5458351", "0.54520047", "0.5451233", "0.54501784", "0.54461354", "0.5440931", "0.54400736", "0.5439808", "0.54375535", "0.54269594", "0.54269594", "0.54234266", "0.5420978", "0.54166096", "0.5415093", "0.540769", "0.5402782", "0.54009753", "0.53989434", "0.53911", "0.5389003", "0.5387679", "0.53842", "0.53769845", "0.5376858" ]
0.77329624
0
MemString returns r.AllocedBytesPerOp and r.AllocsPerOp in the same format as 'go test'.
func (r BenchmarkResult) MemString() string {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r BenchmarkResult) AllocsPerOp() int64 {}", "func (r BenchmarkResult) AllocedBytesPerOp() int64 {}", "func GetMemStats() string {\n\tvar memstats runtime.MemStats\n\truntime.ReadMemStats(&memstats)\n\treturn fmt.Sprintf(\"Alloc: %s, Sys: %s, GC: %d, PauseTotalNs: %dns\", humanize.Bytes(memstats.Alloc), humanize.Bytes(memstats.Sys), memstats.NumGC, memstats.PauseTotalNs)\n}", "func printMemUsage() string {\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\t// For info on each, see: https://golang.org/pkg/runtime/#MemStats\n\treturn fmt.Sprintf(\"Alloc = %v MiB\\tTotalAlloc = %v MiB\\tSys = %v MiB\\tNumGC = %v\\n\", bToMb(m.Alloc),\n\t\tbToMb(m.TotalAlloc), bToMb(m.Sys), m.NumGC)\n}", "func (ins *ArrayAlloc) String() string {\n\treturn fmt.Sprintf(\"%s = %s with %s elements\", ins.Result, ins.Kind, ins.Size)\n}", "func MemUsage() string {\n\tvar ms runtime.MemStats\n\truntime.ReadMemStats(&ms)\n\n\treturn fmt.Sprintf(\"Alloc = %v MiB\\totalAlloc = %v MiB\\tSys = %v MiB\\n\",\n\t\tbToMb(ms.Alloc), bToMb(ms.TotalAlloc), bToMb(ms.Sys))\n}", "func (r BenchmarkResult) String() string {}", "func PrintMemUsage() string {\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\t// For info on each, see: https://golang.org/pkg/runtime/#MemStats\n\treturn fmt.Sprintf(\"[ Heap Allocations: %vMb, OS Memory: %vMb, Num. GC cycles: %v ]\", bToMb(m.HeapAlloc), bToMb(m.Sys), m.NumGC)\n}", "func MBUsed() float64 {\n var m runtime.MemStats\n runtime.ReadMemStats(&m)\n return float64(m.TotalAlloc) / BytesPerMBF \n}", "func (s String) Memory() uint64 {\n\treturn s.Key.memory + s.memory\n}", "func PrintMemUsage() {\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\n\tfmt.Printf(\"Alloc = %v MiB\", m.Alloc/1024/1024)\n\tfmt.Printf(\" TotalAlloc = %v MiB\", m.TotalAlloc/1024/1024)\n\tfmt.Printf(\" Sys = %v MiB\", m.Sys/1024/1024)\n\tfmt.Printf(\" NumGC = %v\\n\", m.NumGC)\n}", "func PrintMemUsage() {\n\tvar m runtime.MemStats\n\truntime.GC()\n\truntime.ReadMemStats(&m)\n\t// For info on each, see: https://golang.org/pkg/runtime/#MemStats\n\tfmt.Print(\"Alloc = \", humanize.Bytes(m.Alloc))\n\tfmt.Print(\"\\tTotalAlloc = \", humanize.Bytes(m.TotalAlloc))\n\tfmt.Print(\"\\tSys = \", humanize.Bytes(m.Sys))\n\tfmt.Print(\"\\tGCSys = \", humanize.Bytes(m.GCSys))\n\tfmt.Print(\"\\tNumGC = \", m.NumGC)\n\tfmt.Println(\"\\tTimeGC =\", m.PauseTotalNs/uint64(time.Millisecond), \"ms\")\n}", "func TellMemUsage() string {\n\tvar memStats runtime.MemStats\n\truntime.ReadMemStats(&memStats)\n\tresponseMsg := fmt.Sprintf(\n\t\t\"\\n`Memory allocated: %v MiB\\nTotal allocated: %v MiB\\nSys Memory allocated: %v MiB\\n\"+\n\t\t\t\"Number of GCs: %v`\",\n\t\tmemStats.Alloc/1024/1024, memStats.TotalAlloc/1024/1024, memStats.Sys/1024/1024,\n\t\tmemStats.NumGC)\n\n\treturn responseMsg\n}", "func PrintMemUsage() {\r\n\tvar m runtime.MemStats\r\n\truntime.ReadMemStats(&m)\r\n\t// For info on each, see: https://golang.org/pkg/runtime/#MemStats\r\n\tfmt.Printf(\"Alloc = %v MiB\", bToMb(m.Alloc))\r\n\tfmt.Printf(\"\\tTotalAlloc = %v MiB\", bToMb(m.TotalAlloc))\r\n\tfmt.Printf(\"\\tSys = %v MiB\", bToMb(m.Sys))\r\n\tfmt.Printf(\"\\tNumGC = %v\\n\", m.NumGC)\r\n}", "func (s StatsEntry) MemPerc() string {\n\tif s.err != nil {\n\t\treturn fmt.Sprintf(\"--\")\n\t}\n\treturn fmt.Sprintf(\"%.2f%%\", s.memoryPercentage)\n}", "func getMemory(cinfo info.ContainerInfo) (jsonString string, err error) {\n\tvar temp string = \"\"\n\tfor _, cstat := range cinfo.Stats {\n\t\tmem := Memory{Container: cinfo.Name,\n\t\t\tUsage: cstat.Memory.Usage,\n\t\t\tWorkingSet: cstat.Memory.WorkingSet,\n\t\t\tContainerData: cstat.Memory.ContainerData,\n\t\t}\n\n\t\ttempJsonString, err := json.Marshal(mem)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\n\t\ttemp = temp +string(tempJsonString)\n\t}\n\treturn temp, nil\n}", "func PhysicalMemoryOfAppMachine()(membytes int64, err error) {\n\tmembytes = 0\n\terr = nil\n\tcmd := exec.Command(\"tr\", \"a-z\", \"A-Z\")\n\tcmd = exec.Command(\"free\")\n\t//cmd.Stdin = strings.NewReader(\"some input\")\n\tcmd.Stdin = strings.NewReader(\"uselessArg\")\n\tvar out bytes.Buffer\n\tcmd.Stdout = &out\n\terr = cmd.Run()\n\tif err != nil {\n\t\tlog.Fatal(\"PhysicalMemoryOfAppMachine: \",err)\n\t}\n\t//fmt.Printf(\"\\nfree says1: %q\\n\", out.String())\n\t\n\ts1 := out.String()\n\ts2 := strings.Split(s1,\"\\n\")\n\tif( len(s2) > 1 ){\n\t\t//fmt.Printf(\"\\n free says2: %q\\n\", s2[1] ) \n\t\twords := strings.Fields( s2[1] )\t\n\t\t//fmt.Printf(\"\\n free says3: %q\\n\", words[1] ) \n\t\tmembytes,err = strconv.ParseInt( words[1],10,64 )\n\t\tmembytes = membytes >> 10\t\t// MB\n\t\t//membytes = membytes >> 10\t\t// GB\n\t\t\n\t} else {\n\t\terr = errors.New(\"could not parse output of free command - windows no worki\")\n\t}\n\n\treturn\n\n}", "func print_stats(){\nfmt.Print(\"\\nMemory usage statistics:\\n\")\nfmt.Printf(\"%v names\\n\",len(name_dir))\nfmt.Printf(\"%v replacement texts\\n\",len(text_info))\n}", "func TestMemoryLayout(t *testing.T) {\n\tm4 := M4{\n\t\t11, 12, 13, 14,\n\t\t21, 22, 23, 24,\n\t\t31, 32, 33, 34,\n\t\t41, 42, 43, 44}\n\toneFloat := uint64(unsafe.Sizeof(m4.X0))\n\tfourFloats := oneFloat * 4\n\tmema, _ := strconv.ParseUint(fmt.Sprintf(\"%d\", &(m4.X0)), 0, 64)\n\tmemb, _ := strconv.ParseUint(fmt.Sprintf(\"%d\", &(m4.Y0)), 0, 64) // next value.\n\tif memb-mema != oneFloat {\n\t\tt.Errorf(\"Next value should be %d bytes. Was %d\", oneFloat, memb-mema)\n\t}\n\tmemc, _ := strconv.ParseUint(fmt.Sprintf(\"%d\", &(m4.X1)), 0, 64) // next row.\n\tif memc-mema != fourFloats {\n\t\tt.Errorf(\"Next row should be %d bytes. Was %d\", fourFloats, memc-mema)\n\t}\n}", "func PrintMemUsage() {\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\t// For info on each, see: https://golang.org/pkg/runtime/#MemStats\n\tlog.Printf(\"Alloc = %v MiB\", bToMb(m.Alloc))\n\tlog.Printf(\"TotalAlloc = %v MiB\", bToMb(m.TotalAlloc))\n\tlog.Printf(\"Sys = %v MiB\", bToMb(m.Sys))\n\tlog.Printf(\"NumGC = %v\", m.NumGC)\n}", "func PrintMemUsage() {\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\t// For info on each, see: https://golang.org/pkg/runtime/#MemStats\n\tfmt.Printf(\"Alloc = %v MiB\", bToMb(m.Alloc))\n\tfmt.Printf(\"\\tTotalAlloc = %v MiB\", bToMb(m.TotalAlloc))\n\tfmt.Printf(\"\\tSys = %v MiB\", bToMb(m.Sys))\n\tfmt.Printf(\"\\tNumGC = %v\\n\", m.NumGC)\n}", "func (obj *ServerMemoryInfoImpl) String() string {\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"ServerMemoryInfoImpl:{\")\n\tbuffer.WriteString(fmt.Sprintf(\"ProcessMemory: '%+v'\", obj.processMemory))\n\tbuffer.WriteString(fmt.Sprintf(\", SharedMemory: '%+v'\", obj.sharedMemory))\n\tbuffer.WriteString(\"}\")\n\treturn buffer.String()\n}", "func parseMemoryTxt(s string) (bts uint64, hs string, err error) {\n\ts = strings.TrimSpace(s)\n\n\tswitch {\n\tcase strings.HasSuffix(s, \"m\"): // suffix 'm' means megabytes\n\t\tns := s[:len(s)-1]\n\t\tvar mib float64\n\t\tmib, err = strconv.ParseFloat(ns, 64)\n\t\tif err != nil {\n\t\t\treturn 0, \"\", err\n\t\t}\n\t\tbts = uint64(mib) * 1024 * 1024\n\n\tcase strings.HasSuffix(s, \"g\"): // gigabytes\n\t\tns := s[:len(s)-1]\n\t\tvar gib float64\n\t\tgib, err = strconv.ParseFloat(ns, 64)\n\t\tif err != nil {\n\t\t\treturn 0, \"\", err\n\t\t}\n\t\tbts = uint64(gib) * 1024 * 1024 * 1024\n\n\tcase strings.HasSuffix(s, \"t\"): // terabytes\n\t\tns := s[:len(s)-1]\n\t\tvar tib float64\n\t\ttib, err = strconv.ParseFloat(ns, 64)\n\t\tif err != nil {\n\t\t\treturn 0, \"\", err\n\t\t}\n\t\tbts = uint64(tib) * 1024 * 1024 * 1024 * 1024\n\n\tdefault:\n\t\tvar kib float64\n\t\tkib, err = strconv.ParseFloat(s, 64)\n\t\tif err != nil {\n\t\t\treturn 0, \"\", err\n\t\t}\n\t\tbts = uint64(kib) * 1024\n\t}\n\n\ths = humanize.Bytes(bts)\n\treturn\n}", "func rawDataSize(c *Cmd) int {\n\t// First calculate the size of the C.goclone_cmd, then add each of the\n\t// strings, or arrays to the size so we know how much space to allocate.\n\tdataSize := int(unsafe.Sizeof(C.goclone_cmd{}))\n\tdataSize += len(c.Path) + 1\n\tdataSize += (len(c.Args) + 1) * ptrSize\n\tfor _, s := range c.Args {\n\t\tdataSize += len(s) + 1\n\t}\n\tdataSize += (len(c.Env) + 1) * ptrSize\n\tfor _, s := range c.Env {\n\t\tdataSize += len(s) + 1\n\t}\n\tdataSize += len(c.Dir) + 1\n\tif c.SysProcAttr != nil {\n\t\tdataSize += len(c.SysProcAttr.Chroot) + 1\n\t} else {\n\t\tdataSize += 1\n\t}\n\tdataSize += (len(c.ExtraFiles) + 3) * intSize\n\tif c.SysProcAttr != nil && c.SysProcAttr.Credential != nil {\n\t\tdataSize += len(c.SysProcAttr.Credential.Groups) * gidSize\n\t}\n\tdataSize += (len(c.CgroupsTasksFiles) + 1) * ptrSize\n\tfor _, s := range c.CgroupsTasksFiles {\n\t\tdataSize += len(s) + 1\n\t}\n\tdataSize += len(c.IPCNameSpace) + 1\n\tdataSize += len(c.MountNameSpace) + 1\n\tdataSize += len(c.NetworkNameSpace) + 1\n\tdataSize += len(c.PIDNameSpace) + 1\n\tdataSize += len(c.UserNameSpace) + 1\n\tdataSize += len(c.UTSNameSpace) + 1\n\n\tdataSize += len(c.Hostname) + 1\n\n\treturn dataSize\n}", "func (s StatsEntry) MemUsage() string {\n\tif s.err != nil {\n\t\treturn fmt.Sprintf(\"-- / --\")\n\t}\n\n\treturn fmt.Sprintf(\"%s / %s\", units.BytesSize(s.memory), units.BytesSize(s.memoryLimit))\n}", "func CalculateGpuSummary() string {\n\tvar GpuFreeMemorys []string\n\tfor _, g := range GPUs {\n\t\telement := strings.Join(\n\t\t\t[]string{\n\t\t\t\tstrconv.FormatInt(int64(g.ID), 10),\n\t\t\t\tstrconv.FormatInt(int64(g.FreeMemory), 10)},\n\t\t\t\"_\")\n\t\tGpuFreeMemorys = append(GpuFreeMemorys, element)\n\t}\n\treturn strings.Join(GpuFreeMemorys, \".\")\n}", "func TestMemory_WMISimple(t *testing.T) {\n\tif os.Getenv(\"TEST_MEM\") == \"\" {\n\t\tt.Skip(\"Skipping TestMemory_WMISimple; $TEST_MEM is not set\")\n\t}\n\n\tstart := time.Now()\n\tfmt.Printf(\"Benchmark Iterations: %d (Private Memory should stabilize around 7MB after ~3000)\\n\", memReps)\n\n\tvar privateMB, allocMB, allocTotalMB float64\n\tfor i := 0; i < memReps; i++ {\n\t\tprivateMB, allocMB, allocTotalMB = getMemoryUsageMB(t)\n\t\tif i%1000 == 0 {\n\t\t\tfmt.Printf(\"Time: %4ds Count: %5d \", time.Now().Sub(start)/time.Second, i)\n\t\t\tprintlnMemUsage(privateMB, allocMB, allocTotalMB)\n\t\t}\n\t}\n\n\tfmt.Printf(\"Final Time: %4ds \", time.Now().Sub(start)/time.Second)\n\tprintlnMemUsage(privateMB, allocMB, allocTotalMB)\n}", "func (r MemRegion) String() string {\n\tperm := r.perms.String()\n\tend := r.base + r.size - 1\n\n\tret := fmt.Sprintf(\"%-12s [0x%08x-0x%08x] {%3s} in:\\\"%s\\\" out:\\\"%s\\\"\",\n\t\tr.name, r.base, end, perm, r.inputFile, r.outputFile)\n\n\treturn ret\n}", "func TestMemory_WbemConnection(t *testing.T) {\n\tif os.Getenv(\"TEST_MEM\") == \"\" {\n\t\tt.Skip(\"Skipping TestMemory_WbemConnection; $TEST_MEM is not set\")\n\t}\n\ts, err := ConnectSWbemServices()\n\tif err != nil {\n\t\tt.Fatalf(\"InitializeSWbemServices: %s\", err)\n\t}\n\n\tstart := time.Now()\n\tfmt.Printf(\"Benchmark Iterations: %d (Private Memory should stabilize around 7MB after ~3000)\\n\", memReps)\n\n\tvar privateMB, allocMB, allocTotalMB float64\n\tfor i := 0; i < memReps; i++ {\n\t\tprivateMB, allocMB, allocTotalMB = wbemConnGetMemoryUsageMB(t, s)\n\t\tif i%100 == 0 {\n\t\t\tfmt.Printf(\"Time: %4ds Count: %5d \", time.Now().Sub(start)/time.Second, i)\n\t\t\tprintlnMemUsage(privateMB, allocMB, allocTotalMB)\n\t\t}\n\t}\n\n\terrClose := s.Close()\n\tif errClose != nil {\n\t\tt.Fatalf(\"Close: %s\", err)\n\t}\n\n\tfmt.Printf(\"Final Time: %4ds \", time.Now().Sub(start)/time.Second)\n\tprintlnMemUsage(privateMB, allocMB, allocTotalMB)\n}", "func (c *Config) GetAutoscalerBufferMemory() string {\n\treturn c.member.GetString(varAutoscalerBufferMemory)\n}", "func RamUsage() {\r\n v, _ := mem.VirtualMemory()\r\n fmt.Printf(\"RAM{ Total: %v, Free:%v, UsedPercent:%f%%}\\n\", v.Total, v.Free, v.UsedPercent)\r\n}", "func printMemoryUsage() {\n\truntime.GC()\n\truntime.ReadMemStats(&mem)\n\tlog.Printf(\"%s: %dkb\", \"mem usage\", mem.HeapAlloc/1024)\n}", "func Bytes(s uint64) string {\n\treturn humanateBytes(s, 1000, nameSizes, 1, nil)\n}", "func (av AttributeBufferPoolOperations) String() string {\n\tswitch av {\n\tcase AttributeBufferPoolOperationsReadAheadRnd:\n\t\treturn \"read_ahead_rnd\"\n\tcase AttributeBufferPoolOperationsReadAhead:\n\t\treturn \"read_ahead\"\n\tcase AttributeBufferPoolOperationsReadAheadEvicted:\n\t\treturn \"read_ahead_evicted\"\n\tcase AttributeBufferPoolOperationsReadRequests:\n\t\treturn \"read_requests\"\n\tcase AttributeBufferPoolOperationsReads:\n\t\treturn \"reads\"\n\tcase AttributeBufferPoolOperationsWaitFree:\n\t\treturn \"wait_free\"\n\tcase AttributeBufferPoolOperationsWriteRequests:\n\t\treturn \"write_requests\"\n\t}\n\treturn \"\"\n}", "func TestGetMemPages(t *testing.T) {\n\ttype testcase struct {\n\t\tname string\n\t\tmr *MemoryReader\n\t\tstart uint64\n\t\tend uint64\n\t\texpectedError error\n\t}\n\n\tpid, err := getTestImgPID()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Create a temporary empty memory pages file for testing\n\ttmpFilePath := filepath.Join(os.TempDir(), \"pages-0.img\")\n\ttmpFile, err := os.Create(tmpFilePath)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tdefer func() {\n\t\ttmpFile.Close()\n\t\tif err := os.Remove(tmpFile.Name()); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}()\n\n\tmr, err := NewMemoryReader(testImgsDir, pid, sysPageSize)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\ttestCases := []testcase{\n\t\t{\n\t\t\tname: \"Zero memory area size\",\n\t\t\tmr: &MemoryReader{\n\t\t\t\tcheckpointDir: testImgsDir,\n\t\t\t\tpid: pid,\n\t\t\t\tpageSize: sysPageSize,\n\t\t\t\tpagesID: mr.pagesID,\n\t\t\t\tpagemapEntries: mr.GetPagemapEntries(),\n\t\t\t},\n\t\t\tstart: 0,\n\t\t\tend: 0,\n\t\t\texpectedError: nil,\n\t\t},\n\t\t{\n\t\t\tname: \"Valid pagemap entry 1\",\n\t\t\tmr: &MemoryReader{\n\t\t\t\tcheckpointDir: testImgsDir,\n\t\t\t\tpid: pid,\n\t\t\t\tpageSize: sysPageSize,\n\t\t\t\tpagesID: mr.pagesID,\n\t\t\t\tpagemapEntries: mr.GetPagemapEntries(),\n\t\t\t},\n\t\t\tstart: mr.pagemapEntries[0].GetVaddr(),\n\t\t\tend: mr.pagemapEntries[0].GetVaddr() + uint64(uint32(sysPageSize)*mr.pagemapEntries[0].GetNrPages()),\n\t\t\texpectedError: nil,\n\t\t},\n\t\t{\n\t\t\tname: \"Valid pagemap entry 2\",\n\t\t\tmr: &MemoryReader{\n\t\t\t\tcheckpointDir: testImgsDir,\n\t\t\t\tpid: pid,\n\t\t\t\tpageSize: sysPageSize,\n\t\t\t\tpagesID: mr.pagesID,\n\t\t\t\tpagemapEntries: mr.GetPagemapEntries(),\n\t\t\t},\n\t\t\tstart: mr.pagemapEntries[1].GetVaddr(),\n\t\t\tend: mr.pagemapEntries[1].GetVaddr() + uint64(uint32(sysPageSize)*mr.pagemapEntries[1].GetNrPages()),\n\t\t\texpectedError: nil,\n\t\t},\n\t\t{\n\t\t\tname: \"Invalid pages file\",\n\t\t\tmr: &MemoryReader{\n\t\t\t\tcheckpointDir: testImgsDir,\n\t\t\t\tpid: pid,\n\t\t\t\tpageSize: sysPageSize,\n\t\t\t\tpagesID: mr.pagesID + 1,\n\t\t\t\tpagemapEntries: mr.GetPagemapEntries(),\n\t\t\t},\n\t\t\tstart: mr.pagemapEntries[0].GetVaddr(),\n\t\t\tend: mr.pagemapEntries[0].GetVaddr() + uint64(uint32(sysPageSize)*mr.pagemapEntries[0].GetNrPages()),\n\t\t\texpectedError: errors.New(\"no such file or directory\"),\n\t\t},\n\t\t{\n\t\t\tname: \"Empty pages file\",\n\t\t\tmr: &MemoryReader{\n\t\t\t\tcheckpointDir: os.TempDir(),\n\t\t\t\tpid: pid,\n\t\t\t\tpageSize: sysPageSize,\n\t\t\t\tpagesID: 0,\n\t\t\t\tpagemapEntries: mr.GetPagemapEntries(),\n\t\t\t},\n\t\t\tstart: mr.pagemapEntries[1].GetVaddr(),\n\t\t\tend: mr.pagemapEntries[1].GetVaddr() + uint64(uint32(sysPageSize)*mr.pagemapEntries[1].GetNrPages()),\n\t\t\texpectedError: errors.New(\"EOF\"),\n\t\t},\n\t}\n\n\tfor _, tc := range testCases {\n\t\tt.Run(tc.name, func(t *testing.T) {\n\t\t\tbuff, err := tc.mr.GetMemPages(tc.start, tc.end)\n\t\t\tif err != nil && tc.expectedError != nil {\n\t\t\t\tif !strings.Contains(err.Error(), tc.expectedError.Error()) {\n\t\t\t\t\tt.Errorf(\"Expected error: %v, got error: %v\", tc.expectedError, err)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif tc.expectedError == nil && buff == nil {\n\t\t\t\tt.Errorf(\"Returned memory chunk is expected to be non-empty\")\n\t\t\t}\n\t\t})\n\t}\n}", "func (s *memStat) Name() string { return \"memfile\" }", "func PrintMemStats(m *runtime.MemStats, mstats, ostats, astats, gc bool, pauses int) {\n\tif mstats {\n\t\tfmt.Printf(\"Alloc=%h, TotalAlloc=%h, Sys=%h, Lookups=%h, Mallocs=%h, Frees=%h\\n\",\n\t\t\thu(m.Alloc, \"B\"), hu(m.TotalAlloc, \"B\"), hu(m.Sys, \"B\"), hu(m.Lookups, \"\"), hu(m.Mallocs, \"\"), hu(m.Frees, \"\"))\n\t\tfmt.Printf(\"HeapAlloc=%h, HeapSys=%h, HeapIdle=%h, HeapInuse=%h, HeapReleased=%h, HeapObjects=%h, StackInuse=%h, StackSys=%h\\n\",\n\t\t\thu(m.HeapAlloc, \"B\"), hu(m.HeapSys, \"B\"), hu(m.HeapIdle, \"B\"), hu(m.HeapInuse, \"B\"), hu(m.HeapReleased, \"B\"),\n\t\t\thu(m.HeapObjects, \"\"), hu(m.StackInuse, \"B\"), hu(m.StackSys, \"B\"))\n\t\tif ostats {\n\t\t\tfmt.Printf(\"MSpanInuse=%d, MSpanSys=%d, m.MCacheInuse=%d, MCacheSys=%d, BuckHashSys=%d, GCSys=%d, OtherSys=%d\\n\",\n\t\t\t\tm.MSpanInuse, m.MSpanSys, m.MCacheInuse, m.MCacheSys, m.BuckHashSys, m.GCSys, m.OtherSys)\n\t\t}\n\n\t\tt1 := time.Unix(0, int64(m.LastGC))\n\t\t//t2 := time.Now()\n\t\t//t3 := time.Unix(int64(0), int64(m.PauseTotalNs))\n\t\tet := time.Duration(int64(m.PauseTotalNs)) // Since(t3)\n\t\tfmt.Printf(\"NextGC=%h, NumGC=%d, LastGC=%s, PauseTotalNs=%v, NumForcedGC=%d, GCCPUFraction=%0.2f\\n\",\n\t\t\thu(m.NextGC, \"B\"), m.NumGC, t1.Format(\"15:04:05.99\"), et, m.NumForcedGC, m.GCCPUFraction)\n\t}\n\tfmt.Printf(\"\\n\")\n\n\tif astats {\n\t\tfor i, b := range m.BySize {\n\t\t\tif b.Mallocs == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfmt.Printf(\"BySize[%d]: Size=%d, Malloc=%d, Frees=%d\\n\", i, b.Size, b.Mallocs, b.Frees)\n\t\t}\n\t\tfmt.Printf(\"\\n\")\n\t}\n\n\tif gc {\n\t\tPrintCircularBuffer(\"PauseNs\", pauses, int(m.NumGC), true, m.PauseNs)\n\t\tPrintCircularBuffer(\"PauseEnd\", pauses, int(m.NumGC), false, m.PauseEnd)\n\t\tfmt.Printf(\"\\n\")\n\t}\n}", "func (s *Stats) GetMemoryInfo(logMemory, logGoMemory bool) {\n\n if logGoMemory {\n if s.GoInfo == nil {\n s.initGoInfo()\n }\n\n runtime.ReadMemStats(s.GoInfo.Memory.mem)\n s.GoInfo.GoRoutines = runtime.NumGoroutine()\n s.GoInfo.Memory.Alloc = s.GoInfo.Memory.mem.Alloc\n s.GoInfo.Memory.HeapAlloc = s.GoInfo.Memory.mem.HeapAlloc\n s.GoInfo.Memory.HeapSys = s.GoInfo.Memory.mem.HeapSys\n\n if s.GoInfo.Memory.LastGC != s.GoInfo.Memory.mem.LastGC {\n s.GoInfo.Memory.LastGC = s.GoInfo.Memory.mem.LastGC\n s.GoInfo.Memory.NumGC = s.GoInfo.Memory.mem.NumGC - s.GoInfo.Memory.lastNumGC\n s.GoInfo.Memory.lastNumGC = s.GoInfo.Memory.mem.NumGC\n s.GoInfo.Memory.LastGCPauseDuration = s.GoInfo.Memory.mem.PauseNs[(s.GoInfo.Memory.mem.NumGC+255)%256]\n } else {\n s.GoInfo.Memory.NumGC = 0\n s.GoInfo.Memory.LastGCPauseDuration = 0\n }\n }\n\n if logMemory {\n\n if s.MemInfo == nil {\n s.MemInfo = new(MemInfo)\n }\n\n s.MemInfo.Memory, _ = mem.VirtualMemory()\n s.MemInfo.Swap, _ = mem.SwapMemory()\n }\n}", "func (cg *CGroup) GetMemoryStats() (map[string]uint64, error) {\n\tvar (\n\t\terr error\n\t\tstats string\n\t)\n\n\tout := make(map[string]uint64)\n\n\tversion := cgControllers[\"memory\"]\n\tswitch version {\n\tcase Unavailable:\n\t\treturn nil, ErrControllerMissing\n\tcase V1, V2:\n\t\tstats, err = cg.rw.Get(version, \"memory\", \"memory.stat\")\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, stat := range strings.Split(stats, \"\\n\") {\n\t\tfield := strings.Split(stat, \" \")\n\n\t\tswitch field[0] {\n\t\tcase \"total_active_anon\", \"active_anon\":\n\t\t\tout[\"active_anon\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_active_file\", \"active_file\":\n\t\t\tout[\"active_file\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_inactive_anon\", \"inactive_anon\":\n\t\t\tout[\"inactive_anon\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_inactive_file\", \"inactive_file\":\n\t\t\tout[\"inactive_file\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_unevictable\", \"unevictable\":\n\t\t\tout[\"unevictable\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_writeback\", \"file_writeback\":\n\t\t\tout[\"writeback\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_dirty\", \"file_dirty\":\n\t\t\tout[\"dirty\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_mapped_file\", \"file_mapped\":\n\t\t\tout[\"mapped\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_rss\": // v1 only\n\t\t\tout[\"rss\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_shmem\", \"shmem\":\n\t\t\tout[\"shmem\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\tcase \"total_cache\", \"file\":\n\t\t\tout[\"cache\"], _ = strconv.ParseUint(field[1], 10, 64)\n\t\t}\n\t}\n\n\t// Calculated values\n\tout[\"active\"] = out[\"active_anon\"] + out[\"active_file\"]\n\tout[\"inactive\"] = out[\"inactive_anon\"] + out[\"inactive_file\"]\n\n\treturn out, nil\n}", "func TestJoeFridayGetMemBasic(t *testing.T) {\n\tprof, _ := basic.NewProfiler()\n\tmem, err := prof.Get()\n\tif err != nil {\n\t\tt.Error(err)\n\t\treturn\n\t}\n\tp, err := json.MarshalIndent(mem, \"\", \"\\t\")\n\tif err != nil {\n\t\tt.Error(err)\n\t\treturn\n\t}\n\tt.Logf(\"%s\\n\", string(p))\n}", "func PrintMemUsage(memprofile string) {\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\t// For info on each, see: https://golang.org/pkg/runtime/#MemStats\n\tfmt.Printf(\"Alloc = %v MiB\", bToMb(m.Alloc))\n\tfmt.Printf(\"\\tTotalAlloc = %v MiB\", bToMb(m.TotalAlloc))\n\tfmt.Printf(\"\\tSys = %v MiB\", bToMb(m.Sys))\n\tfmt.Printf(\"\\tNumGC = %v\\n\", m.NumGC)\n\n\tif memprofile != \"\" {\n\t\tf, err := os.Create(memprofile)\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"could not create memory profile: \", err)\n\t\t}\n\t\truntime.GC() // get up-to-date statistics\n\t\tif err := pprof.WriteHeapProfile(f); err != nil {\n\t\t\tlog.Fatal(\"could not write memory profile: \", err)\n\t\t}\n\t\tf.Close()\n\t}\n}", "func TestMemoryTracker(ptr unsafe.Pointer, sz C.size_t, op C.rtloader_mem_ops_t) {\n\tswitch op {\n\tcase C.DATADOG_AGENT_RTLOADER_ALLOCATION:\n\t\tAllocations.Add(1)\n\tcase C.DATADOG_AGENT_RTLOADER_FREE:\n\t\tFrees.Add(1)\n\t}\n}", "func TestMemoryTracker(ptr unsafe.Pointer, sz C.size_t, op C.rtloader_mem_ops_t) {\n\tswitch op {\n\tcase C.DATADOG_AGENT_RTLOADER_ALLOCATION:\n\t\tAllocations.Add(1)\n\tcase C.DATADOG_AGENT_RTLOADER_FREE:\n\t\tFrees.Add(1)\n\t}\n}", "func ExecInfoMemory(s *Shred) (RedisInfoMemory, error) {\n\tvar sum RedisInfoMemory\n\tcmds := s.MapExec(\"INFO\", \"MEMORY\")\n\tfor _, c := range cmds {\n\t\tv, err := c.GetString()\n\t\tif err != nil {\n\t\t\treturn sum, err\n\t\t}\n\t\tr, err := ParseInfoMemory(v)\n\t\tif err != nil {\n\t\t\treturn sum, err\n\t\t}\n\t\tsum.UsedMemory += r.UsedMemory\n\t\tsum.UsedMemoryPeak += r.UsedMemoryPeak\n\t\tsum.UsedMemoryLua += r.UsedMemoryLua\n\t}\n\treturn sum, nil\n}", "func (sys *System) GetProfileMem(ctx *Context) (string, error) {\n\tLog(INFO, ctx, \"System.GetProfileMem\")\n\tbuf := new(bytes.Buffer)\n\terr := pprof.WriteHeapProfile(buf)\n\tif err != nil {\n\t\tLog(ERROR, ctx, \"System.GetProfileMem\", \"error\", err)\n\t\treturn \"\", err\n\t}\n\n\treturn buf.String(), nil\n}", "func Bytes(s uint64) string {\n\tsizes := []string{\"B\", \"kB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\"}\n\treturn humanateBytes(s, 1024, sizes)\n}", "func (av AttributeBufferPoolPages) String() string {\n\tswitch av {\n\tcase AttributeBufferPoolPagesData:\n\t\treturn \"data\"\n\tcase AttributeBufferPoolPagesFree:\n\t\treturn \"free\"\n\tcase AttributeBufferPoolPagesMisc:\n\t\treturn \"misc\"\n\t}\n\treturn \"\"\n}", "func testQueryMem(t *testing.T, dst interface{}, query string) {\n\ts, err := ConnectSWbemServices()\n\tif err != nil {\n\t\tt.Fatalf(\"ConnectSWbemServices: %s\", err)\n\t}\n\n\tstart := time.Now()\n\tfmt.Printf(\"Benchmark Iterations: %d (Private Memory should stabilize around 7MB after ~3000)\\n\", memReps)\n\n\tvar privateMB, allocMB, allocTotalMB float64\n\tfor i := 0; i < memReps; i++ {\n\t\tif err := s.Query(query, dst); err != nil {\n\t\t\tt.Fatalf(\"Failed to perform query %q; %s\", query, err)\n\t\t}\n\n\t\tif i%100 == 0 {\n\t\t\tprivateMB, allocMB, allocTotalMB = wbemConnGetMemoryUsageMB(t, s)\n\t\t\tfmt.Printf(\"Time: %4ds Count: %5d \", time.Now().Sub(start)/time.Second, i)\n\t\t\tprintlnMemUsage(privateMB, allocMB, allocTotalMB)\n\t\t}\n\t}\n\n\tif errClose := s.Close(); errClose != nil {\n\t\tt.Fatalf(\"Close: %s\", errClose)\n\t}\n\n\tfmt.Printf(\"Final Time: %4ds \", time.Now().Sub(start)/time.Second)\n\tprintlnMemUsage(privateMB, allocMB, allocTotalMB)\n}", "func (a *AzureInfoer) GetMemoryAttrName() string {\n\treturn productinfo.Memory\n}", "func BenchmarkToStringUnsafe(b *testing.B) {\n\ttestPayload := []byte(\"falsflasjlifjwpoihejfoiwejow{}{}{}{}jelfjasjfhwaopiehjtopwhtgohrgouahsgkljasdlfjasl;fjals;jdflkndgouwhetopwqhjtojfalsflasjlifjwpoihejfoiwejow{}{}{}{}jelfjasjfhwaopiehjtopwhtgohrgouahsgkljasdlfjasl;fjals;jdflkndgouwhetopwqhjtojfalsflasjlifjwpoihejfoiwejow{}{}{}{}jelfjasjfhwaopiehjtopwhtgohrgouahsgkljasdlfjasl;fjals;jdflkndgouwhetopwqhjtojfalsflasjlifjwpoihejfoiwejow{}{}{}{}jelfjasjfhwaopiehjtopwhtgohrgouahsgkljasdlfjasl;fjals;jdflkndgouwhetopwqhjtojfalsflasjlifjwpoihejfoiwejow{}{}{}{}jelfjasjfhwaopiehjtopwhtgohrgouahsgkljasdlfjasl;fjals;jdflkndgouwhetopwqhjtojfalsflasjlifjwpoihejfoiwejow{}{}{}{}jelfjasjfhwaopiehjtopwhtgohrgouahsgkljasdlfjasl;fjals;jdflkndgouwhetopwqhjtojfalsflasjlifjwpoihejfoiwejow{}{}{}{}jelfjasjfhwaopiehjtopwhtgohrgouahsgkljasdlfjasl;fjals;jdflkndgouwhetopwqhjtoj\")\n\tb.ResetTimer()\n\tb.ReportAllocs()\n\n\tfor i := 0; i < b.N; i++ {\n\t\tres := utils.AsString(testPayload)\n\t\t_ = res\n\t}\n}", "func TestMemory_Services(t *testing.T) {\n\tif os.Getenv(\"TEST_MEM\") == \"\" {\n\t\tt.Skip(\"Skipping TestMemory_Services; $TEST_MEM is not set\")\n\t}\n\ts, err := NewSWbemServices()\n\tif err != nil {\n\t\tt.Fatalf(\"InitializeSWbemServices: %s\", err)\n\t}\n\n\tstart := time.Now()\n\tfmt.Printf(\"Benchmark Iterations: %d (Private Memory should stabilize around 7MB after ~3000)\\n\", memReps)\n\n\tvar privateMB, allocMB, allocTotalMB float64\n\tfor i := 0; i < memReps; i++ {\n\t\tprivateMB, allocMB, allocTotalMB = wbemGetMemoryUsageMB(t, s)\n\t\tif i%100 == 0 {\n\t\t\tfmt.Printf(\"Time: %4ds Count: %5d \", time.Now().Sub(start)/time.Second, i)\n\t\t\tprintlnMemUsage(privateMB, allocMB, allocTotalMB)\n\t\t}\n\t}\n\n\terrClose := s.Close()\n\tif errClose != nil {\n\t\tt.Fatalf(\"Close: %s\", err)\n\t}\n\n\tfmt.Printf(\"Final Time: %4ds \", time.Now().Sub(start)/time.Second)\n\tprintlnMemUsage(privateMB, allocMB, allocTotalMB)\n}", "func (pk PacketBufferPtr) MemSize() int {\n\treturn int(pk.buf.Size()) + PacketBufferStructSize\n}", "func (this *Context) MemoryUsage() string { // {{{\n\tms := &runtime.MemStats{}\n\truntime.ReadMemStats(ms)\n\n\treturn this.MemoryFormat(ms.Alloc)\n}", "func (r *Resources) GetMem() float64 {\n\treturn r.MEMORY\n}", "func BytesSize(bytes float64, format string, prec int) string {\n\n\tif bytes <= 0 {\n\t\treturn \"0\"\n\t}\n\n\t// Default format is decimal: MB, GB\n\tvalue := 1000.0\n\tresFormat := \"\"\n\n\t// Binary format: MiB, GiB\n\tif format == \"binary\" {\n\t\tvalue = 1024.0\n\t\tresFormat = \"i\"\n\t}\n\n\tif bytes < value {\n\t\tstrRes := strconv.FormatFloat(bytes, 'f', prec, 64)\n\t\treturn strings.TrimSuffix(strRes, \".0\") + \"B\"\n\t}\n\n\tdivider, exp := value, 0\n\tfor n := bytes / value; n >= value; n /= value {\n\t\tdivider *= value\n\t\texp++\n\t}\n\n\tstrRes := strconv.FormatFloat(bytes/divider, 'f', prec, 64)\n\tif prec == 0 {\n\t\t\tstrRes = strings.TrimSuffix(strRes, \".0\")\n\t}\n\n\treturn strRes + fmt.Sprintf(\"%c%sB\", \"KMGTPE\"[exp], resFormat)\n}", "func ReadMemStats(ms *MemStats)", "func NumMetaString(n uint64) string {\n\treturn fmt.Sprintf(\"%.1f MiB\", float32(n)/1024.0)\n}", "func (r *RMBSpec) String() string {\n\trFmt := \"[Link: %d, RKey: %d, Virtual Address: %#x]\"\n\treturn fmt.Sprintf(rFmt, r.Link, r.RKey, r.VAddr)\n}", "func TestMultiWriter_WriteStringSingleAlloc(t *testing.T) {\n\tt.Skip(\"skipping on gccgo until we have escape analysis\")\n\tvar sink1, sink2 bytes.Buffer\n\ttype simpleWriter struct { // hide bytes.Buffer's WriteString\n\t\tWriter\n\t}\n\tmw := MultiWriter(simpleWriter{&sink1}, simpleWriter{&sink2})\n\tallocs := int(testing.AllocsPerRun(1000, func() {\n\t\tWriteString(mw, \"foo\")\n\t}))\n\tif allocs != 1 {\n\t\tt.Errorf(\"num allocations = %d; want 1\", allocs)\n\t}\n}", "func Mem(pkg string, mem *ir.Memory, mmap bool) ([]byte, error) {\n\tasset, err := lookupTemplate(\"mem\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ttmpl, err := template.New(\"mem\").Parse(string(asset))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar (\n\t\tmaxOff uint32\n\t\tsizeAtMaxOff int\n\t\tsegmentBytes int\n\t)\n\tif len(mem.Segments) != 0 {\n\t\tfirst := true\n\t\tfor off, b := range mem.Segments {\n\t\t\tsegmentBytes += len(b)\n\t\t\tif first {\n\t\t\t\tmaxOff = off\n\t\t\t\tsizeAtMaxOff = len(b)\n\t\t\t\tfirst = false\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif off > maxOff {\n\t\t\t\tmaxOff = off\n\t\t\t\tsizeAtMaxOff = len(b)\n\t\t\t}\n\t\t}\n\t}\n\tdata := struct {\n\t\tPkg string\n\t\tMem *ir.Memory\n\t\tMMap bool\n\t\tMaxOff uint32\n\t\tSizeAtMaxOff int\n\t\tSegmentBytes int\n\t}{\n\t\tPkg: pkg,\n\t\tMem: mem,\n\t\tMMap: mmap,\n\t\tMaxOff: maxOff,\n\t\tSizeAtMaxOff: sizeAtMaxOff,\n\t\tSegmentBytes: segmentBytes,\n\t}\n\tvar b bytes.Buffer\n\tif err := tmpl.Execute(&b, data); err != nil {\n\t\treturn nil, err\n\t}\n\treturn b.Bytes(), nil\n}", "func (s *memStat) Size() int64 { return s.size }", "func (*Memory) Descriptor() ([]byte, []int) {\n\treturn file_language_agent_JVMMetric_proto_rawDescGZIP(), []int{2}\n}", "func currMemoryAlloc() int {\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\treturn int(m.Alloc)\n}", "func Bytes(s int64) string {\n\tsizes := []string{\"B\", \"K\", \"M\", \"G\", \"T\", \"P\", \"E\"}\n\treturn humanateBytes(s, 1000, sizes)\n}", "func (g *MemoryGenerator) Generate() (metrics.Values, error) {\n\tvar errRet error\n\toutBytes, err := exec.Command(\"top\", \"-bn\", \"1\").Output()\n\tif err != nil {\n\t\tmemoryLogger.Warningf(\"'top -bn 1' command exited with a non-zero status: '%s'\", err)\n\t\terrRet = err\n\t}\n\tret := make(map[string]float64)\n\n\tout := string(outBytes)\n\tlines := strings.Split(out, \"\\n\")\n\n\tfor _, line := range lines {\n\t\tfields := strings.Fields(line)\n\t\tif len(fields) < 1 {\n\t\t\tcontinue\n\t\t}\n\n\t\tif fields[0] == \"Memory:\" {\n\t\t\tfor i := 1; i < len(fields); i += 2 {\n\t\t\t\tv, err := getValue(fields[i])\n\t\t\t\tif err == nil {\n\t\t\t\t\tk := fields[i+1]\n\t\t\t\t\tif strings.HasSuffix(k, \",\") {\n\t\t\t\t\t\tk = k[0 : len(k)-1]\n\t\t\t\t\t}\n\t\t\t\t\tswitch k {\n\t\t\t\t\tcase \"Act\":\n\t\t\t\t\t\tret[\"memory.act\"] = v\n\t\t\t\t\tcase \"Wired\":\n\t\t\t\t\t\tret[\"memory.wired\"] = v\n\t\t\t\t\tcase \"Exec\":\n\t\t\t\t\t\tret[\"memory.exec\"] = v\n\t\t\t\t\tcase \"File\":\n\t\t\t\t\t\tret[\"memory.file\"] = v\n\t\t\t\t\tcase \"Free\":\n\t\t\t\t\t\tret[\"memory.free\"] = v\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\terrRet = err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif fields[0] == \"Swap:\" {\n\t\t\tif v, err := getValue(fields[1]); err == nil {\n\t\t\t\tret[\"memory.swap_total\"] = v\n\t\t\t} else {\n\t\t\t\terrRet = err\n\t\t\t}\n\t\t\tswapFreeIndex := 5\n\t\t\tif len(fields) == 5 {\n\t\t\t\tswapFreeIndex = 3\n\t\t\t}\n\t\t\tif v, err := getValue(fields[swapFreeIndex]); err == nil {\n\t\t\t\tret[\"memory.swap_free\"] = v\n\t\t\t} else {\n\t\t\t\terrRet = err\n\t\t\t}\n\t\t}\n\t}\n\n\tv, err := getTotalMem()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tret[\"memory.total\"] = v\n\n\tif errRet == nil {\n\t\treturn metrics.Values(ret), nil\n\t}\n\treturn nil, errRet\n}", "func (m *logMeasurement) bytes() int {\n\tvar b int\n\tb += len(m.name)\n\tfor k, v := range m.tagSet {\n\t\tb += len(k)\n\t\tb += v.bytes()\n\t}\n\tb += (int(m.cardinality()) * 8)\n\tb += int(unsafe.Sizeof(*m))\n\treturn b\n}", "func SysMem() (total uint64, free uint64, err error) {\n\tf, err := os.Open(\"/proc/meminfo\")\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer f.Close()\n\n\tpending := len(procMemFields)\n\tscan := bufio.NewScanner(f)\n\tfor scan.Scan() {\n\t\tfields := strings.Split(scan.Text(), \":\")\n\t\tif len(fields) != 2 {\n\t\t\tcontinue\n\t\t}\n\n\t\tname := strings.TrimSpace(fields[0])\n\t\tmemKB := strings.Fields(strings.TrimSpace(fields[1]))[0]\n\t\tif _, ok := procMemFields[name]; !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tvar mem uint64\n\t\tmem, err = strconv.ParseUint(memKB, 10, 64)\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"invalid mem field:%s val:%s (%s)\", name, memKB, err)\n\t\t\treturn\n\t\t}\n\n\t\tmem = mem * 1024\n\t\tswitch name {\n\t\tcase \"MemTotal\":\n\t\t\ttotal = mem\n\t\tcase \"MemFree\", \"Buffers\", \"Cached\":\n\t\t\tfree += mem\n\t\t}\n\n\t\tpending--\n\t\tif pending == 0 {\n\t\t\treturn\n\t\t}\n\t}\n\n\tif err = scan.Err(); err != nil {\n\t\treturn\n\t}\n\n\terr = fmt.Errorf(\"unable to get required mem fields\")\n\treturn\n}", "func BenchmarkMarshalManual(b *testing.B) {\n\tvar s1, s2 test.Stat\n\tanalysis.RandomizeValue(&s1)\n\n\tb.ResetTimer()\n\n\tfor n := 0; n < b.N; n++ {\n\t\tbuf := make([]byte, 0, s1.SizeBytes())\n\n\t\t// Marshal\n\t\tbuf = binary.AppendUint64(buf, hostarch.ByteOrder, s1.Dev)\n\t\tbuf = binary.AppendUint64(buf, hostarch.ByteOrder, s1.Ino)\n\t\tbuf = binary.AppendUint64(buf, hostarch.ByteOrder, s1.Nlink)\n\t\tbuf = binary.AppendUint32(buf, hostarch.ByteOrder, s1.Mode)\n\t\tbuf = binary.AppendUint32(buf, hostarch.ByteOrder, s1.UID)\n\t\tbuf = binary.AppendUint32(buf, hostarch.ByteOrder, s1.GID)\n\t\tbuf = binary.AppendUint32(buf, hostarch.ByteOrder, 0)\n\t\tbuf = binary.AppendUint64(buf, hostarch.ByteOrder, s1.Rdev)\n\t\tbuf = binary.AppendUint64(buf, hostarch.ByteOrder, uint64(s1.Size))\n\t\tbuf = binary.AppendUint64(buf, hostarch.ByteOrder, uint64(s1.Blksize))\n\t\tbuf = binary.AppendUint64(buf, hostarch.ByteOrder, uint64(s1.Blocks))\n\t\tbuf = binary.AppendUint64(buf, hostarch.ByteOrder, uint64(s1.ATime.Sec))\n\t\tbuf = binary.AppendUint64(buf, hostarch.ByteOrder, uint64(s1.ATime.Nsec))\n\t\tbuf = binary.AppendUint64(buf, hostarch.ByteOrder, uint64(s1.MTime.Sec))\n\t\tbuf = binary.AppendUint64(buf, hostarch.ByteOrder, uint64(s1.MTime.Nsec))\n\t\tbuf = binary.AppendUint64(buf, hostarch.ByteOrder, uint64(s1.CTime.Sec))\n\t\tbuf = binary.AppendUint64(buf, hostarch.ByteOrder, uint64(s1.CTime.Nsec))\n\n\t\t// Unmarshal\n\t\ts2.Dev = hostarch.ByteOrder.Uint64(buf[0:8])\n\t\ts2.Ino = hostarch.ByteOrder.Uint64(buf[8:16])\n\t\ts2.Nlink = hostarch.ByteOrder.Uint64(buf[16:24])\n\t\ts2.Mode = hostarch.ByteOrder.Uint32(buf[24:28])\n\t\ts2.UID = hostarch.ByteOrder.Uint32(buf[28:32])\n\t\ts2.GID = hostarch.ByteOrder.Uint32(buf[32:36])\n\t\t// Padding: buf[36:40]\n\t\ts2.Rdev = hostarch.ByteOrder.Uint64(buf[40:48])\n\t\ts2.Size = int64(hostarch.ByteOrder.Uint64(buf[48:56]))\n\t\ts2.Blksize = int64(hostarch.ByteOrder.Uint64(buf[56:64]))\n\t\ts2.Blocks = int64(hostarch.ByteOrder.Uint64(buf[64:72]))\n\t\ts2.ATime.Sec = int64(hostarch.ByteOrder.Uint64(buf[72:80]))\n\t\ts2.ATime.Nsec = int64(hostarch.ByteOrder.Uint64(buf[80:88]))\n\t\ts2.MTime.Sec = int64(hostarch.ByteOrder.Uint64(buf[88:96]))\n\t\ts2.MTime.Nsec = int64(hostarch.ByteOrder.Uint64(buf[96:104]))\n\t\ts2.CTime.Sec = int64(hostarch.ByteOrder.Uint64(buf[104:112]))\n\t\ts2.CTime.Nsec = int64(hostarch.ByteOrder.Uint64(buf[112:120]))\n\t}\n\n\tb.StopTimer()\n\n\t// Sanity check, make sure the values were preserved.\n\tif !reflect.DeepEqual(s1, s2) {\n\t\tpanic(fmt.Sprintf(\"Data corruption across marshal/unmarshal cycle:\\nBefore: %+v\\nAfter: %+v\\n\", s1, s2))\n\t}\n}", "func TestMemoryOLE(t *testing.T) {\n\tif os.Getenv(\"TEST_MEM\") == \"\" {\n\t\tt.Skip(\"Skipping TestMemoryOLE; $TEST_MEM is not set\")\n\t}\n\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tt.Error(r)\n\t\t}\n\t}()\n\n\tstart := time.Now()\n\tlimit := 50000000\n\turl := \"http://localhost/slashdot.xml\" //http://rss.slashdot.org/Slashdot/slashdot\"\n\tfmt.Printf(\"Benchmark Iterations: %d (Private Memory should stabilize around 8MB to 12MB after ~2k full or 250k minimal)\\n\", limit)\n\n\t//On Server 2016 or Windows 10 changing leakMemory=true will cause it to leak ~1.5MB per 10000 calls to unknown.QueryInterface\n\tleakMemory := true\n\n\t////////////////////////////////////////\n\t//Start outer section\n\tvar unknown *ole.IUnknown\n\tvar xmlhttp *ole.IDispatch\n\tif !leakMemory {\n\t\tcomshim.Add(1)\n\t\tdefer comshim.Done()\n\n\t\t//fmt.Println(\"CreateObject Microsoft.XMLHTTP\")\n\t\tvar err error\n\t\tunknown, err = oleutil.CreateObject(\"Microsoft.XMLHTTP\")\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\tdefer unknown.Release()\n\n\t\t//Memory leak starts here\n\t\txmlhttp, err = unknown.QueryInterface(ole.IID_IDispatch)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\tdefer xmlhttp.Release()\n\t}\n\t//End outer section\n\t////////////////////////////////////////\n\n\ttotalItems := uint64(0)\n\tfor i := 0; i < limit; i++ {\n\t\tif i%2000 == 0 {\n\t\t\tprivateMB, allocMB, allocTotalMB := getMemoryUsageMB(t)\n\t\t\tfmt.Printf(\"Time: %4ds Count: %7d \", time.Now().Sub(start)/time.Second, i)\n\t\t\tprintlnMemUsage(privateMB, allocMB, allocTotalMB)\n\t\t}\n\t\t//This should use less than 10MB for 1 million iterations if xmlhttp was initialized above\n\t\t//On Server 2016 or Windows 10 changing leakMemory=true above will cause it to leak ~1.5MB per 10000 calls to unknown.QueryInterface\n\t\tcount, err := getRSS(url, xmlhttp, true) //last argument is for Minimal test. Doesn't effect leak just overall allocations/time\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\ttotalItems += uint64(count)\n\t}\n\tprivateMB, allocMB, allocTotalMB := getMemoryUsageMB(t)\n\tfmt.Printf(\"Final totalItems: %d \", totalItems)\n\tprintlnMemUsage(privateMB, allocMB, allocTotalMB)\n\n}", "func (t *SpecTest) String() string { return strings.Join(t.descstack, \" \") }", "func (*MemoryPool) Descriptor() ([]byte, []int) {\n\treturn file_language_agent_JVMMetric_proto_rawDescGZIP(), []int{3}\n}", "func (ml *MemoryLogger) String() string {\n\treturn ml.RingBuffer.String()\n}", "func getCpuMem() (float64, float64) {\n\tvar sumCPU, sumMEM float64\n\tcmd := exec.Command(\"ps\", \"aux\") // ps aux is the command used to get cpu and ram usage\n\tvar out bytes.Buffer\n\tcmd.Stdout = &out //catching the command output\n\terr := cmd.Run() //running the command\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfor {\n\t\tline, err := out.ReadString('\\n') //breaking the output in lines\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\ttokens := strings.Split(line, \" \") //spliting each output line\n\t\tft := make([]string, 0)\n\t\tfor _, t := range tokens {\n\t\t\tif t != \"\" && t != \"\\t\" {\n\t\t\t\tft = append(ft, t) //for each line there is a buffer (ft) that keeps all the parameters\n\t\t\t}\n\t\t}\n\t\tif cpu, err := strconv.ParseFloat(ft[2], 32); err == nil { // parsing the cpu variable, as string, to float\n\t\t\tsumCPU += cpu //all the cpu's used capacity at the instant\n\t\t}\n\t\tif mem, err := strconv.ParseFloat(ft[3], 32); err == nil { // parsing the ram variable, as string, to float\n\t\t\tsumMEM += mem //all the ram's used capacity at the instant\n\t\t}\n\t}\n\tlog.Println(\"Used CPU\", sumCPU/8, \"%\", \" Used Memory RAM\", sumMEM, \"%\")\n\treturn sumCPU / 8, sumMEM //the cpu's total used capacity is splitted by 8 because its the total number of my PC's cores\n\t//otherwise, we would see outputs bigger than 100%\n}", "func benchCode() string {\n consoleCommand := `go test -bench . -benchtime=1s` // Single place to alter the command line command\n output := ``\n\n output += breakspace + cBold + cCyan + \" Golang Function Benchmarks:\" + cClr\n output += breakspace + cYellow + \" > \" + cClr + consoleCommand + breakspace\n\n output += breakspace\n\n testOutput, _ := exec.Command( \"cmd\", \"/c\", consoleCommand ).Output()\n\n // Alternative code:\n //cmd.Stdout = os.Stdout\n //cmd.Run()\n\n return output + statusColorize( string(testOutput) )\n}", "func (c *Context) getMemoryUsage(e *zerolog.Event, level zerolog.Level, message string) {\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\n\te.Str(\"memalloc\", fmt.Sprintf(\"%dMB\", m.Alloc/1024/1024))\n\te.Str(\"memsys\", fmt.Sprintf(\"%dMB\", m.Sys/1024/1024))\n\te.Str(\"numgc\", fmt.Sprintf(\"%d\", m.NumGC))\n\n}", "func (o GetAppTemplateContainerOutput) Memory() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetAppTemplateContainer) string { return v.Memory }).(pulumi.StringOutput)\n}", "func (s Sysinfo) MemFree() uint64 {\n\treturn s.memFree + s.memBuffer\n}", "func SystemInfo() string {\n\n\tvar si SysInfo\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\tsi.AllocMemory = m.Alloc\n\tsi.AllocMemoryMB = btomb(m.Alloc)\n\tsi.TotalAllocMemory = m.TotalAlloc\n\tsi.TotalAllocMemoryMB = btomb(m.TotalAlloc)\n\tsi.TotalSystemMemory = m.Sys\n\tsi.TotalSystemMemoryMB = btomb(m.Sys)\n\tc, _ := cpu.Info()\n\n\tsi.CPUs = c[0].Cores\n\n\tsi.GolangVersion = runtime.Version()\n\tsi.ContainerHostName, _ = os.Hostname()\n\tsi.CurrentUTC = time.Now().UTC()\n\n\tsi.CurrentLocalTime = time.Now().Local()\n\n\tconst (\n\t\tB = 1\n\t\tKB = 1024 * B\n\t\tMB = 1024 * KB\n\t\tGB = 1024 * MB\n\t)\n\n\tv, _ := mem.VirtualMemory()\n\tfmt.Printf(\"Total: %v, Free:%v, UsedPercent:%f%%\\n\", v.Total, v.Free, v.UsedPercent)\n\n\ttype InfoStat struct {\n\t\tHostname string `json:\"hostname\"`\n\t\tUptime uint64 `json:\"uptime\"`\n\t\tBootTime uint64 `json:\"bootTime\"`\n\t\tProcs uint64 `json:\"procs\"` // number of processes\n\t\tOS string `json:\"os\"` // ex: freebsd, linux\n\t\tPlatform string `json:\"platform\"` // ex: ubuntu, linuxmint\n\t\tPlatformFamily string `json:\"platformFamily\"` // ex: debian, rhel\n\t\tPlatformVersion string `json:\"platformVersion\"` // version of the complete OS\n\t\tKernelVersion string `json:\"kernelVersion\"` // version of the OS kernel (if available)\n\t\tVirtualizationSystem string `json:\"virtualizationSystem\"`\n\t\tVirtualizationRole string `json:\"virtualizationRole\"` // guest or host\n\t\tHostID string `json:\"hostid\"` // ex: uuid\n\t}\n\n\tvar his *host.InfoStat\n\this, _ = host.Info()\n\n\tsi.Uptime = his.Uptime\n\n\tsi.OperatingSystem = his.OS\n\tsi.Platform = his.Platform\n\tsi.PlatformFamily = his.PlatformFamily\n\tsi.PlatformVersion = his.PlatformVersion\n\tsi.VirtualSystem = his.VirtualizationSystem\n\tsi.VirtualRole = his.VirtualizationRole\n\tsi.HostID = his.HostID\n\tsi.HostName = his.Hostname\n\tsi.BootTime = strconv.FormatUint(his.BootTime, 10)\n\tsi.KernelVersion = his.KernelVersion\n\n\tsi.UptimeDays = si.Uptime / (60 * 60 * 24)\n\tsi.UptimeHours = (si.Uptime - (si.UptimeDays * 60 * 60 * 24)) / (60 * 60)\n\tsi.UptimeMinutes = ((si.Uptime - (si.UptimeDays * 60 * 60 * 24)) - (si.UptimeHours * 60 * 60)) / 60\n\tinterfaces, err := net.Interfaces()\n\n\tif err == nil {\n\t\tfor i, interfac := range interfaces {\n\t\t\tif interfac.Name == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\taddrs := interfac.Addrs\n\t\t\tsi.NetworkInterfaces[i].Name = interfac.Name\n\t\t\tsi.NetworkInterfaces[i].HardwareAddress = string(interfac.HardwareAddr)\n\t\t\tfor x, addr := range addrs {\n\t\t\t\tif addr.String() != \"\" {\n\t\t\t\t\tsi.NetworkInterfaces[i].IPAddresses[x].IPAddress = addr.String()\n\t\t\t\t} else {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tvar paths [10]string\n\tpaths[0] = \"/\"\n\n\tfor i, path := range paths {\n\t\tdisk := DiskUsage(path)\n\t\tsi.Disk[i].Path = path\n\t\tsi.Disk[i].All = float64(disk.All) / float64(GB)\n\t\tsi.Disk[i].Used = float64(disk.Used) / float64(GB)\n\t\tsi.Disk[i].Free = float64(disk.Free) / float64(GB)\n\t}\n\n\tstrJSON, err := json.Marshal(si)\n\tcheckErr(err)\n\n\treturn string(strJSON)\n}", "func Getpagesize() int", "func Test_QualityOperation_String(t *testing.T) {\n\timg := MakeMockMutableImage()\n\top := &QualityOperation{\n\t\tImage: &img,\n\t\tNewQuality: 95,\n\t}\n\n\tassert.Equal(t, \"Quality\", fmt.Sprintf(\"%s\", op))\n}", "func StrBytes(s string) int64 {\n\tidx := len(s) - 1\n\tnum, _ := strconv.ParseInt(s[:idx], 10, 64)\n\n\tunit := string(s[idx])\n\tswitch unit {\n\tcase \"c\", \"C\":\n\t\treturn num\n\tcase \"k\", \"K\":\n\t\treturn num * KiB\n\tcase \"m\", \"M\":\n\t\treturn num * MiB\n\tcase \"g\", \"G\":\n\t\treturn num * GiB\n\tcase \"t\", \"T\":\n\t\treturn num * TiB\n\t}\n\treturn 0\n}", "func (m *memStats) fmtBytes(b uint64) string {\n\tvar (\n\t\tkb uint64 = 1024\n\t\tmb uint64 = kb * 1024\n\t\tgb uint64 = mb * 1024\n\t)\n\tif b < kb {\n\t\treturn fmt.Sprintf(\"%dB\", b)\n\t}\n\tif b < mb {\n\t\treturn fmt.Sprintf(\"%dKB\", b/kb)\n\t}\n\tif b < gb {\n\t\treturn fmt.Sprintf(\"%dMB\", b/mb)\n\t}\n\treturn fmt.Sprintf(\"%dGB\", b/gb)\n}", "func Test_ResizeOperation_String(t *testing.T) {\n\top := &ResizeOperation{\n\t\tNewWidth: 500,\n\t\tNewHeight: 300,\n\t}\n\n\tassert.Equal(t, \"Resize\", fmt.Sprintf(\"%s\", op))\n}", "func (op BinaryOp) String() string {\n\tif op >= 0 && op < BinaryOp(len(binaryOps)) && binaryOps[op] != \"\" {\n\t\treturn binaryOps[op]\n\t}\n\treturn fmt.Sprintf(\"BinaryOp<%d>\", op)\n}", "func rcMemStats(ctx context.Context, in Params) (out Params, err error) {\n\tout = make(Params)\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\tout[\"Alloc\"] = m.Alloc\n\tout[\"TotalAlloc\"] = m.TotalAlloc\n\tout[\"Sys\"] = m.Sys\n\tout[\"Mallocs\"] = m.Mallocs\n\tout[\"Frees\"] = m.Frees\n\tout[\"HeapAlloc\"] = m.HeapAlloc\n\tout[\"HeapSys\"] = m.HeapSys\n\tout[\"HeapIdle\"] = m.HeapIdle\n\tout[\"HeapInuse\"] = m.HeapInuse\n\tout[\"HeapReleased\"] = m.HeapReleased\n\tout[\"HeapObjects\"] = m.HeapObjects\n\tout[\"StackInuse\"] = m.StackInuse\n\tout[\"StackSys\"] = m.StackSys\n\tout[\"MSpanInuse\"] = m.MSpanInuse\n\tout[\"MSpanSys\"] = m.MSpanSys\n\tout[\"MCacheInuse\"] = m.MCacheInuse\n\tout[\"MCacheSys\"] = m.MCacheSys\n\tout[\"BuckHashSys\"] = m.BuckHashSys\n\tout[\"GCSys\"] = m.GCSys\n\tout[\"OtherSys\"] = m.OtherSys\n\treturn out, nil\n}", "func ProcMeminfo(c *gin.Context) {\n\tres := CmdExec(\"cat /proc/meminfo | head -n 2| awk '{print $2}'\")\n\ttotalMem, _ := strconv.Atoi(res[0])\n\tfreeMem, _ := strconv.Atoi(res[1])\n\tusedMem := totalMem - freeMem\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"totalMem\": totalMem,\n\t\t\"usedMem\": usedMem,\n\t})\n}", "func (m Metric) String() string {\n\tswitch m {\n\tcase MetricCPUPercentAllocation:\n\t\treturn \"cpu_percent_allocation\"\n\tcase MetricGPUPercentAllocation:\n\t\treturn \"gpu_percent_allocation\"\n\tcase MetricMemoryPercentAllocation:\n\t\treturn \"memory_percent_allocation\"\n\tcase MetricEphemeralStoragePercentAllocation:\n\t\treturn \"ephemeral_storage_percent_allocation\"\n\tcase MetricPodPercentAllocation:\n\t\treturn \"pod_percent_allocation\"\n\t}\n\n\treturn \"unknown\"\n}", "func (o *V0037Node) GetAllocMemoryOk() (*int64, bool) {\n\tif o == nil || o.AllocMemory == nil {\n\t\treturn nil, false\n\t}\n\treturn o.AllocMemory, true\n}", "func (av AttributeBufferPoolData) String() string {\n\tswitch av {\n\tcase AttributeBufferPoolDataDirty:\n\t\treturn \"dirty\"\n\tcase AttributeBufferPoolDataClean:\n\t\treturn \"clean\"\n\t}\n\treturn \"\"\n}", "func (s Size) String() string {\n\tt := uint64(s)\n\tswitch {\n\tcase t < 1<<10:\n\t\treturn fmt.Sprintf(\"%d B\", t)\n\tcase t < 1<<20:\n\t\treturn fmt.Sprintf(\"%.1f KiB\", float64(t)/float64(1<<10))\n\tcase t < 1<<30:\n\t\treturn fmt.Sprintf(\"%.1f MiB\", float64(t)/float64(1<<20))\n\tdefault:\n\t\treturn fmt.Sprintf(\"%.1f GiB\", float64(t)/float64(1<<30))\n\t}\n}", "func (r WriteCounter) String() string {\n\treturn fmt.Sprintf(\"There were %v write operations totaling %v bytes\", r.numWrites, r.numBytes)\n}", "func (o AppTemplateContainerOutput) Memory() pulumi.StringOutput {\n\treturn o.ApplyT(func(v AppTemplateContainer) string { return v.Memory }).(pulumi.StringOutput)\n}", "func (p *Param) GetMemoryInfo() error {\n\treturn errors.New(\"Param.GetMemoryInfo() has not been implemented yet.\")\n}", "func Test_DensityOperation_String(t *testing.T) {\n\timg := MakeMockMutableImage()\n\top := &DensityOperation{\n\t\tImage: &img,\n\t\tNewDensity: 2,\n\t}\n\n\tassert.Equal(t, \"Density\", fmt.Sprintf(\"%s\", op))\n}", "func BenchmarkPallocBitsSummarize(b *testing.B) {\n\tpatterns := []uint64{\n\t\t0,\n\t\t^uint64(0),\n\t\t0xaa,\n\t\t0xaaaaaaaaaaaaaaaa,\n\t\t0x80000000aaaaaaaa,\n\t\t0xaaaaaaaa00000001,\n\t\t0xbbbbbbbbbbbbbbbb,\n\t\t0x80000000bbbbbbbb,\n\t\t0xbbbbbbbb00000001,\n\t\t0xcccccccccccccccc,\n\t\t0x4444444444444444,\n\t\t0x4040404040404040,\n\t\t0x4000400040004000,\n\t\t0x1000404044ccaaff,\n\t}\n\tfor _, p := range patterns {\n\t\tbuf := new(PallocBits)\n\t\tfor i := 0; i < len(buf); i++ {\n\t\t\tbuf[i] = p\n\t\t}\n\t\tb.Run(fmt.Sprintf(\"Unpacked%02X\", p), func(b *testing.B) {\n\t\t\tcheckPallocSum(b, buf.Summarize(), SummarizeSlow(buf))\n\t\t\tfor i := 0; i < b.N; i++ {\n\t\t\t\tbuf.Summarize()\n\t\t\t}\n\t\t})\n\t}\n}", "func (o TaskDefinitionOutput) Memory() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *TaskDefinition) pulumi.StringPtrOutput { return v.Memory }).(pulumi.StringPtrOutput)\n}", "func humanBytes(byteCount uint64) string {\n\tconst unit = 1024\n\tif byteCount < unit {\n\t\treturn fmt.Sprintf(\"%d B\", byteCount)\n\t}\n\n\tdiv, exp := int64(unit), 0\n\tfor n := byteCount / unit; n >= unit; n /= unit {\n\t\tdiv *= unit\n\t\texp++\n\t}\n\n\treturn fmt.Sprintf(\"%.1f %ciB\", float64(byteCount)/float64(div), \"KMGTPE\"[exp])\n}", "func Bytes(n int64, decimals int, long bool) string {\n\tpadding := \" \"\n\tlevels := []string{\n\t\t\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", /* \"ZB\", \"YB\" will overflow int64 */\n\t}\n\tif long {\n\t\tlevels = []string{\n\t\t\t\"bytes\", \"kilobyte\", \"megabyte\", \"gigabyte\", \"terabyte\", \"petabyte\", \"exabyte\",\n\t\t}\n\t}\n\n\treturn human(n, levels, 1024, decimals, padding)\n}", "func sizeString(size int64) string {\n\tsizeFloat := float64(size)\n\tfor i, unit := range sizeUnits {\n\t\tbase := math.Pow(1024, float64(i))\n\t\tif sizeFloat < base*1024 {\n\t\t\tvar sizeStr string\n\t\t\tif i == 0 {\n\t\t\t\tsizeStr = strconv.FormatInt(size, 10)\n\t\t\t} else {\n\t\t\t\tvalue := sizeFloat / base\n\t\t\t\tif value < 1000 {\n\t\t\t\t\tsizeStr = fmt.Sprintf(\"%.2f\", value)\n\t\t\t\t} else {\n\t\t\t\t\tsizeStr = fmt.Sprintf(\"%.1f\", value)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn SizeColor[unit] + pad.Left(sizeStr, 6, \" \") + unit + \" \" + Reset\n\t\t}\n\t}\n\treturn strconv.Itoa(int(size))\n}", "func BenchmarkFCString(b *testing.B) {\n\tb.ReportAllocs()\n\tfor i := 0; i < b.N; i++ {\n\t\ttestFCString(b)\n\t}\n}" ]
[ "0.6087171", "0.59305274", "0.5815041", "0.5735228", "0.5709977", "0.54733354", "0.5379671", "0.5365666", "0.53119045", "0.5307708", "0.5279814", "0.52693146", "0.5251053", "0.52317065", "0.52208996", "0.52173585", "0.5215754", "0.5198797", "0.51664555", "0.5164201", "0.5139128", "0.51323", "0.5117404", "0.51103956", "0.50957555", "0.50879997", "0.5062028", "0.5053504", "0.50293255", "0.49910244", "0.49848372", "0.49470574", "0.49409494", "0.4934167", "0.49072844", "0.48837215", "0.4879652", "0.48765212", "0.4871709", "0.48598343", "0.48340768", "0.4822522", "0.4822522", "0.48191562", "0.4818259", "0.48141852", "0.4805815", "0.47987437", "0.47795627", "0.4779508", "0.47713375", "0.47528207", "0.47274038", "0.47214767", "0.47141412", "0.4705591", "0.46785647", "0.46741167", "0.46711197", "0.4670779", "0.4665442", "0.46639413", "0.46615818", "0.4651033", "0.46492404", "0.4644768", "0.46384582", "0.4637189", "0.4629872", "0.46189892", "0.46185458", "0.46170324", "0.45963427", "0.4591141", "0.45840603", "0.45757464", "0.45728493", "0.45724168", "0.45723394", "0.45661926", "0.45600376", "0.4551195", "0.4549562", "0.45428786", "0.45420787", "0.45311534", "0.45284304", "0.4516196", "0.4514044", "0.45125455", "0.45122713", "0.45121908", "0.4507935", "0.45060658", "0.45059615", "0.4503452", "0.4502758", "0.44992742", "0.4491784", "0.4482815" ]
0.6777521
0
RunBenchmarks is an internal function but exported because it is crosspackage; it is part of the implementation of the "go test" command.
func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []InternalBenchmark) {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (bm *DockerBenchmarker) RunBenchmark() {\n\n\t// CIS 4.1 Create a user for the container\n\tbm.CheckNonRootUser()\n\n\t// CIS 4.2 Use trusted base images for containers\n\tbm.CheckTrustedBaseImages()\n\n\t// CIS 4.3 Do not install unnecessary packages in the container\n\tbm.CheckDisallowedPackages()\n\n\t// CIS 4.6 add HEALTHCHECK instruction to the container image\n\tbm.CheckHealthCheck()\n\n\t// CIS 4.7 Do not use update instructions alone in the Dockerfile\n\tbm.CheckRunUpdateOnly()\n\n\t// CIS 4.9 Use COPY instead of ADD in Dockerfile\n\tbm.CheckAdd()\n\n\t// CIS 4.10 Do not store secrets in Dockerfiles\n\tbm.CheckSecretsInsideImage()\n}", "func (t *TestRuntime) RunAPIServerBenchmarks(m *testing.M) int {\n\treturn t.runTests(m, !testing.Verbose())\n}", "func RunBenchmarks(b *testing.B, coll *docstore.Collection) {\n\tdefer coll.Close()\n\tclearCollection(b, coll)\n\tb.Run(\"BenchmarkSingleActionPut\", func(b *testing.B) {\n\t\tbenchmarkSingleActionPut(10, b, coll)\n\t})\n\tb.Run(\"BenchmarkSingleActionGet\", func(b *testing.B) {\n\t\tbenchmarkSingleActionGet(10, b, coll)\n\t})\n\tb.Run(\"BenchmarkActionListPut\", func(b *testing.B) {\n\t\tbenchmarkActionListPut(50, b, coll)\n\t})\n\tb.Run(\"BenchmarkActionListGet\", func(b *testing.B) {\n\t\tbenchmarkActionListGet(100, b, coll)\n\t})\n\tclearCollection(b, coll)\n}", "func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []InternalBenchmark)", "func benchCode() string {\n consoleCommand := `go test -bench . -benchtime=1s` // Single place to alter the command line command\n output := ``\n\n output += breakspace + cBold + cCyan + \" Golang Function Benchmarks:\" + cClr\n output += breakspace + cYellow + \" > \" + cClr + consoleCommand + breakspace\n\n output += breakspace\n\n testOutput, _ := exec.Command( \"cmd\", \"/c\", consoleCommand ).Output()\n\n // Alternative code:\n //cmd.Stdout = os.Stdout\n //cmd.Run()\n\n return output + statusColorize( string(testOutput) )\n}", "func RunBenchmark(b *testing.B, version int, f func(*Anwork, int)) {\n\ta, err := MakeAnwork(version)\n\tif err != nil {\n\t\tb.Fatal(err)\n\t}\n\tdefer a.Close()\n\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tf(a, i)\n\t}\n}", "func (st *buildStatus) runBenchmarkTests() (remoteErr, err error) {\n\tif st.SubName == \"\" {\n\t\treturn nil, fmt.Errorf(\"benchmark tests must run on a subrepo\")\n\t}\n\n\t// Repository under test.\n\t//\n\t// When running benchmarks, there are numerous variables:\n\t//\n\t// * Go experiment version\n\t// * Go baseline version\n\t// * Subrepo experiment version (if benchmarking subrepo)\n\t// * Subrepo baseline version (if benchmarking subrepo)\n\t// * x/benchmarks version (which defines which benchmarks run and how\n\t// regardless of which repo is under test)\n\t//\n\t// For benchmarking of the main Go repo, the first three are used.\n\t// Ideally, the coordinator scheduler would handle the combinatorics on\n\t// testing these. Unfortunately, the coordinator doesn't handle\n\t// three-way combinations. By running Go benchmarks as a \"subrepo test\"\n\t// for x/benchmark, we can at least get the scheduler to handle the\n\t// x/benchmarks version (st.SubRev) and Go experiment version (st.Rev).\n\t// The Go baseline version is simply selected as the most recent\n\t// previous release tag (e.g., 1.18.x on release-branch.go1.18) at the\n\t// time this test runs (st.installBaselineToolchain below).\n\t//\n\t// When benchmarking a subrepo, we want to compare a subrepo experiment\n\t// version vs subrepo baseline version (_not_ compare a single subrepo\n\t// version vs baseline/experiment Go versions). We do need to build the\n\t// subrepo with some version of Go, so we choose to use the latest\n\t// released version at the time of testing (same as Go baseline above).\n\t// We'd like the coordinator to handle the combination of x/benchmarks\n\t// and x/<subrepo>, however the coordinator can't do multiple subrepo\n\t// combinations.\n\t//\n\t// Thus, we run these as typical subrepo builders, which gives us the\n\t// subrepo experiment version and a Go experiment version (which we\n\t// will ignore). The Go baseline version is selected as above, and the\n\t// subrepo baseline version is selected as the latest (non-pre-release)\n\t// tag in the subrepo.\n\t//\n\t// This setup is suboptimal because the caller is installing an\n\t// experiment Go version that we won't use when building the subrepo\n\t// (we'll use the Go baseline version). We'll also end up with\n\t// duplicate runs with identical subrepo experiment/baseline and\n\t// x/benchmarks versions, as builds will trigger on every commit to the\n\t// Go repo. Limiting subrepo builders to release branches can\n\t// significantly reduce the number of Go commit triggers.\n\t//\n\t// TODO(prattmic): Cleaning this up is good future work, but these\n\t// deficiencies are not particularly problematic and avoid the need for\n\t// major changes in other parts of the coordinator.\n\trepo := st.SubName\n\tif repo == \"benchmarks\" {\n\t\trepo = \"go\"\n\t}\n\n\tconst (\n\t\tbaselineDir = \"go-baseline\"\n\t\tbenchmarksDir = \"benchmarks\"\n\t\tsubrepoDir = \"subrepo\"\n\t\tsubrepoBaselineDir = \"subrepo-baseline\"\n\t)\n\n\tworkDir, err := st.bc.WorkDir(st.ctx)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"error discovering workdir for helper %s: %v\", st.bc.IPPort(), err)\n\t\treturn nil, err\n\t}\n\tgoroot := st.conf.FilePathJoin(workDir, \"go\")\n\tbaselineGoroot := st.conf.FilePathJoin(workDir, baselineDir)\n\tgopath := st.conf.FilePathJoin(workDir, \"gopath\")\n\n\t// Install baseline toolchain in addition to the experiment toolchain.\n\ttoolchainBaselineCommit, remoteErr, err := st.installBaselineToolchain(goroot, baselineDir)\n\tif remoteErr != nil || err != nil {\n\t\treturn remoteErr, err\n\t}\n\n\t// Install x/benchmarks.\n\tbenchmarksCommit, remoteErr, err := st.fetchBenchmarksSource(benchmarksDir)\n\tif remoteErr != nil || err != nil {\n\t\treturn remoteErr, err\n\t}\n\n\t// If testing a repo other than Go, install the subrepo and its baseline.\n\tvar subrepoBaselineCommit string\n\tif repo != \"go\" {\n\t\tsubrepoBaselineCommit, remoteErr, err = st.fetchSubrepoAndBaseline(subrepoDir, subrepoBaselineDir)\n\t\tif remoteErr != nil || err != nil {\n\t\t\treturn remoteErr, err\n\t\t}\n\t}\n\n\t// Run golang.org/x/benchmarks/cmd/bench to perform benchmarks.\n\tsp := st.CreateSpan(\"running_benchmark_tests\", st.SubName)\n\tdefer func() { sp.Done(err) }()\n\n\tenv := append(st.conf.Env(),\n\t\t\"BENCH_BASELINE_GOROOT=\"+baselineGoroot,\n\t\t\"BENCH_BRANCH=\"+st.RevBranch,\n\t\t\"BENCH_REPOSITORY=\"+repo,\n\t\t\"GOROOT=\"+goroot,\n\t\t\"GOPATH=\"+gopath, // For module cache storage\n\t)\n\tenv = append(env, st.modulesEnv()...)\n\tif repo != \"go\" {\n\t\tenv = append(env, \"BENCH_SUBREPO_PATH=\"+st.conf.FilePathJoin(workDir, subrepoDir))\n\t\tenv = append(env, \"BENCH_SUBREPO_BASELINE_PATH=\"+st.conf.FilePathJoin(workDir, subrepoBaselineDir))\n\t}\n\trErr, err := st.bc.Exec(st.ctx, \"./go/bin/go\", buildlet.ExecOpts{\n\t\tDebug: true, // make buildlet print extra debug in output for failures\n\t\tOutput: st,\n\t\tDir: benchmarksDir,\n\t\tExtraEnv: env,\n\t\tPath: []string{st.conf.FilePathJoin(\"$WORKDIR\", \"go\", \"bin\"), \"$PATH\"},\n\t\tArgs: []string{\"run\", \"golang.org/x/benchmarks/cmd/bench\"},\n\t})\n\tif err != nil || rErr != nil {\n\t\treturn rErr, err\n\t}\n\n\t// Upload benchmark results on success.\n\tif err := st.uploadBenchResults(toolchainBaselineCommit, subrepoBaselineCommit, benchmarksCommit); err != nil {\n\t\treturn nil, err\n\t}\n\treturn nil, nil\n}", "func MainStart(deps testDeps, tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) *M {}", "func BenchmarkMain(b *testing.B) {\n\tfor n:=0; n < b.N; n++ {\n\t\tmain()\n\t}\n}", "func runBench(dirPath, pattern string) (bstats map[string]*benchStats, err error) {\n\t// default pattern\n\tif pattern == \"\" {\n\t\tpattern = \".\"\n\t}\n\n\t// run benchmarks with tests\n\tout, err := runCmd(\"go\", dirPath, \"test\", \"-bench\", pattern, \"-benchmem\")\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// extract stats\n\tlines := benchStatsRE.FindAllString(out, -1)\n\tif len(lines) == 0 {\n\t\terr = errors.New(\"no benchmarks\")\n\t\treturn\n\t}\n\tbstats = make(map[string]*benchStats, len(lines))\n\n\tfor _, l := range lines {\n\t\tst := &benchStats{\n\t\t\tthroughput: -1,\n\t\t\tmem: -1,\n\t\t\tallocs: -1,\n\t\t}\n\n\t\t// benchmark name\n\t\tname := benchNameRE.FindString(l)\n\t\t// time\n\t\tif ms := benchTimeRE.FindStringSubmatch(l); ms != nil {\n\t\t\tst.time, err = strconv.ParseFloat(ms[1], 64)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tpanic(\"no time data\")\n\t\t}\n\n\t\t// optional throughput\n\t\tif ms := benchThroughputRE.FindStringSubmatch(l); ms != nil {\n\t\t\tst.throughput, err = strconv.ParseFloat(ms[1], 64)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\t// optional mem\n\t\tif ms := benchMemRE.FindStringSubmatch(l); ms != nil {\n\t\t\tst.mem, err = strconv.ParseInt(ms[1], 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tst.allocs, err = strconv.ParseInt(ms[2], 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tbstats[name] = st\n\t}\n\n\treturn bstats, nil\n}", "func addBenchmarkFlags(cmd *cobra.Command) {\n\tcmd.Flags().StringVarP(&benchmark, \"benchmark\", \"b\", \"netperf\", \"benchmark program to use\")\n\tcmd.Flags().StringVarP(&runLabel, \"run-label\", \"l\", \"\", \"benchmark run label\")\n\tcmd.Flags().IntVarP(&benchmarkDuration, \"duration\", \"t\", 30, \"benchmark duration (sec)\")\n\tcmd.Flags().BoolVar(&noCleanup, \"no-cleanup\", false, \"do not perform cleanup (delete created k8s resources, etc.)\")\n\tcmd.Flags().StringVar(&cliAffinity, \"client-affinity\", \"different\", \"client affinity (different: different than server, same: same as server, host=XXXX)\")\n\tcmd.Flags().StringVar(&srvAffinity, \"server-affinity\", \"none\", \"server affinity (none, host=XXXX)\")\n\tcmd.Flags().BoolVar(&collectPerf, \"collect-perf\", false, \"collect performance data using perf\")\n\tcmd.Flags().BoolVar(&cliHost, \"cli-on-host\", false, \"run client on host (enables: HostNetwork, HostIPC, HostPID)\")\n\tcmd.Flags().BoolVar(&srvHost, \"srv-on-host\", false, \"run server on host (enables: HostNetwork, HostIPC, HostPID)\")\n\taddNetperfFlags(cmd)\n}", "func (b *Benchmark) Run() {\n\tb.init()\n\n\tb.trainer.Train()\n}", "func writeBenchmarkResult(method *methodType, c *chk.C, tm timer) {\n\t_, _, testCode := instrumentation.GetPackageAndNameAndBoundaries(method.Info.Func.Pointer())\n\n\tt := method.Info.Type.In(0)\n\tif t.Kind() == reflect.Ptr {\n\t\tt = t.Elem()\n\t}\n\tpName := t.Name()\n\n\ttestTags := opentracing.Tags{\n\t\t\"span.kind\": \"test\",\n\t\t\"test.name\": method.Info.Name,\n\t\t\"test.suite\": pName,\n\t\t\"test.framework\": \"gopkg.in/check.v1\",\n\t\t\"test.language\": \"go\",\n\t\t\"test.type\": \"benchmark\",\n\t}\n\topts := []opentracing.StartSpanOption{\n\t\ttestTags,\n\t\topentracing.StartTime(tm.start),\n\t}\n\n\tif testCode != \"\" {\n\t\ttestTags[\"test.code\"] = testCode\n\t}\n\n\tspan, _ := opentracing.StartSpanFromContextWithTracer(context.Background(), instrumentation.Tracer(), method.Info.Name, opts...)\n\tspan.SetBaggageItem(\"trace.kind\", \"test\")\n\tavg := math.Round((float64(tm.duration.Nanoseconds())/float64(c.N))*100) / 100\n\tmeanAllocsPerOp := math.Round((float64(tm.netAllocs)/float64(c.N))*100) / 100\n\tmeanAllocedBytesPerOp := math.Round((float64(tm.netBytes)/float64(c.N))*100) / 100\n\n\tspan.SetTag(\"benchmark.runs\", c.N)\n\tspan.SetTag(\"benchmark.duration.mean\", avg)\n\tspan.SetTag(\"benchmark.memory.mean_allocations\", meanAllocsPerOp)\n\tspan.SetTag(\"benchmark.memory.mean_bytes_allocations\", meanAllocedBytesPerOp)\n\n\treason := getTestReason(c)\n\tstatus := getTestStatus(c)\n\tswitch status {\n\tcase testSucceeded:\n\t\tif !getTestMustFail(c) {\n\t\t\tspan.SetTag(\"test.status\", tags.TestStatus_PASS)\n\t\t\treason = \"\"\n\t\t} else {\n\t\t\tspan.SetTag(\"test.status\", tags.TestStatus_FAIL)\n\t\t\tspan.SetTag(\"error\", true)\n\t\t}\n\tcase testFailed:\n\t\tif getTestMustFail(c) {\n\t\t\tspan.SetTag(\"test.status\", tags.TestStatus_PASS)\n\t\t\treason = \"\"\n\t\t} else {\n\t\t\tspan.SetTag(\"test.status\", tags.TestStatus_FAIL)\n\t\t\tspan.SetTag(\"error\", true)\n\t\t\tif reason == \"\" {\n\t\t\t\treason = \"Test failed\"\n\t\t\t}\n\t\t}\n\tcase testSkipped:\n\t\tspan.SetTag(\"test.status\", tags.TestStatus_SKIP)\n\tcase testPanicked, testFixturePanicked:\n\t\tspan.SetTag(\"test.status\", tags.TestStatus_FAIL)\n\t\tspan.SetTag(\"error\", true)\n\tcase testMissed:\n\t\tspan.SetTag(\"test.status\", tags.TestStatus_SKIP)\n\tdefault:\n\t\tspan.SetTag(\"test.status\", status)\n\t\tspan.SetTag(\"error\", true)\n\t}\n\n\tif reason != \"\" {\n\t\teventType := tags.EventTestFailure\n\t\tif status == testSkipped {\n\t\t\teventType = tags.EventTestSkip\n\t\t}\n\t\tspan.LogFields(\n\t\t\tlog.String(tags.EventType, eventType),\n\t\t\tlog.String(tags.EventMessage, reason),\n\t\t\tlog.String(\"log.internal_level\", \"Fatal\"),\n\t\t\tlog.String(\"log.logger\", \"testing\"),\n\t\t)\n\t}\n\n\tspan.FinishWithOptions(opentracing.FinishOptions{\n\t\tFinishTime: tm.start.Add(tm.duration),\n\t})\n}", "func (f Factory) RunStoreBenchmarks(b *testing.B) {\n\tb.Run(\"BenchmarkCreateLink\", f.BenchmarkCreateLink)\n\tb.Run(\"BenchmarkCreateLinkParallel\", f.BenchmarkCreateLinkParallel)\n\n\tb.Run(\"FindSegments100\", f.BenchmarkFindSegments100)\n\tb.Run(\"FindSegments1000\", f.BenchmarkFindSegments1000)\n\tb.Run(\"FindSegments10000\", f.BenchmarkFindSegments10000)\n\tb.Run(\"FindSegmentsMapID100\", f.BenchmarkFindSegmentsMapID100)\n\tb.Run(\"FindSegmentsMapID1000\", f.BenchmarkFindSegmentsMapID1000)\n\tb.Run(\"FindSegmentsMapID10000\", f.BenchmarkFindSegmentsMapID10000)\n\tb.Run(\"FindSegmentsMapIDs100\", f.BenchmarkFindSegmentsMapIDs100)\n\tb.Run(\"FindSegmentsMapIDs1000\", f.BenchmarkFindSegmentsMapIDs1000)\n\tb.Run(\"FindSegmentsMapIDs10000\", f.BenchmarkFindSegmentsMapIDs10000)\n\tb.Run(\"FindSegmentsPrevLinkHash100\", f.BenchmarkFindSegmentsPrevLinkHash100)\n\tb.Run(\"FindSegmentsPrevLinkHash1000\", f.BenchmarkFindSegmentsPrevLinkHash1000)\n\tb.Run(\"FindSegmentsPrevLinkHash10000\", f.BenchmarkFindSegmentsPrevLinkHash10000)\n\tb.Run(\"FindSegmentsTags100\", f.BenchmarkFindSegmentsTags100)\n\tb.Run(\"FindSegmentsTags1000\", f.BenchmarkFindSegmentsTags1000)\n\tb.Run(\"FindSegmentsTags10000\", f.BenchmarkFindSegmentsTags10000)\n\tb.Run(\"FindSegmentsMapIDTags100\", f.BenchmarkFindSegmentsMapIDTags100)\n\tb.Run(\"FindSegmentsMapIDTags1000\", f.BenchmarkFindSegmentsMapIDTags1000)\n\tb.Run(\"FindSegmentsMapIDTags10000\", f.BenchmarkFindSegmentsMapIDTags10000)\n\tb.Run(\"FindSegmentsPrevLinkHashTags100\", f.BenchmarkFindSegmentsPrevLinkHashTags100)\n\tb.Run(\"FindSegmentsPrevLinkHashTags1000\", f.BenchmarkFindSegmentsPrevLinkHashTags1000)\n\tb.Run(\"FindSegmentsPrevLinkHashTags10000\", f.BenchmarkFindSegmentsPrevLinkHashTags10000)\n\tb.Run(\"FindSegments100Parallel\", f.BenchmarkFindSegments100Parallel)\n\tb.Run(\"FindSegments1000Parallel\", f.BenchmarkFindSegments1000Parallel)\n\tb.Run(\"FindSegments10000Parallel\", f.BenchmarkFindSegments10000Parallel)\n\tb.Run(\"FindSegmentsMapID100Parallel\", f.BenchmarkFindSegmentsMapID100Parallel)\n\tb.Run(\"FindSegmentsMapID1000Parallel\", f.BenchmarkFindSegmentsMapID1000Parallel)\n\tb.Run(\"FindSegmentsMapID10000Parallel\", f.BenchmarkFindSegmentsMapID10000Parallel)\n\tb.Run(\"FindSegmentsMapIDs100Parallel\", f.BenchmarkFindSegmentsMapIDs100Parallel)\n\tb.Run(\"FindSegmentsMapIDs1000Parallel\", f.BenchmarkFindSegmentsMapIDs1000Parallel)\n\tb.Run(\"FindSegmentsMapIDs10000Parallel\", f.BenchmarkFindSegmentsMapIDs10000Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHash100Parallel\", f.BenchmarkFindSegmentsPrevLinkHash100Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHash1000Parallel\", f.BenchmarkFindSegmentsPrevLinkHash1000Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHash10000ParalleRunBenchmarksl\", f.BenchmarkFindSegmentsPrevLinkHash10000Parallel)\n\tb.Run(\"FindSegmentsTags100Parallel\", f.BenchmarkFindSegmentsTags100Parallel)\n\tb.Run(\"FindSegmentsTags1000Parallel\", f.BenchmarkFindSegmentsTags1000Parallel)\n\tb.Run(\"FindSegmentsTags10000Parallel\", f.BenchmarkFindSegmentsTags10000Parallel)\n\tb.Run(\"FindSegmentsMapIDTags100Parallel\", f.BenchmarkFindSegmentsMapIDTags100Parallel)\n\tb.Run(\"FindSegmentsMapIDTags1000Parallel\", f.BenchmarkFindSegmentsMapIDTags1000Parallel)\n\tb.Run(\"FindSegmentsMapIDTags10000Parallel\", f.BenchmarkFindSegmentsMapIDTags10000Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHashTags100Parallel\", f.BenchmarkFindSegmentsPrevLinkHashTags100Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHashTags1000Parallel\", f.BenchmarkFindSegmentsPrevLinkHashTags1000Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHashTags10000Parallel\", f.BenchmarkFindSegmentsPrevLinkHashTags10000Parallel)\n\n\tb.Run(\"GetMapIDs100\", f.BenchmarkGetMapIDs100)\n\tb.Run(\"GetMapIDs1000\", f.BenchmarkGetMapIDs1000)\n\tb.Run(\"GetMapIDs10000\", f.BenchmarkGetMapIDs10000)\n\tb.Run(\"GetMapIDs100Parallel\", f.BenchmarkGetMapIDs100Parallel)\n\tb.Run(\"GetMapIDs1000Parallel\", f.BenchmarkGetMapIDs1000Parallel)\n\tb.Run(\"GetMapIDs10000Parallel\", f.BenchmarkGetMapIDs10000Parallel)\n\n\tb.Run(\"GetSegment\", f.BenchmarkGetSegment)\n\tb.Run(\"GetSegmentParallel\", f.BenchmarkGetSegmentParallel)\n}", "func RunBenchmark(name string, b *testing.B, f Func, n int) {\n\tb.Run(name, func(b *testing.B) {\n\t\tb.Logf(\"f(%d), loop (b.N) = %d\\n\", n, b.N)\n\t\tfor i := 0; i < b.N; i++ {\n\t\t\tf(n)\n\t\t}\n\t})\n}", "func benchmarkCommand(b *testing.B, cmd string, args ...interface{}) {\n\ttestingSetUp()\n\tdefer testingTearDown()\n\tfor i := 0; i < b.N; i++ {\n\t\tconn := testPool.NewConn()\n\t\tif _, err := conn.Do(cmd, args...); err != nil {\n\t\t\t_ = conn.Close()\n\t\t\tb.Fatal(err)\n\t\t}\n\t\t_ = conn.Close()\n\t}\n}", "func (tc *TestCase) Benchmark(client *QueryClient) error {\n\t_, err := exec(client, tc.Query, tc.BindVars)\n\treturn err\n}", "func BenchmarkRunner_Run(b *testing.B) {\n\tsrv := serverMock()\n\tdefer srv.Close()\n\n\tclient := &http.Client{}\n\tconcurrent := make(chan struct{}, 5)\n\tparser := parsers.NewNasaParser(contextLogger, \"DEMO_KEY\", srv.URL+\"/planetary/apod?api_key=%s&date=%s\", client)\n\trunner := NewRunner(contextLogger, concurrent, parser)\n\n\tfor i := 0; i < b.N; i++ {\n\t\t_, err := runner.Run([]string{\"2019-12-06\", \"2019-12-07\", \"2019-12-10\", \"2019-12-11\", \"2019-12-12\", \"2019-12-14\"})\n\t\tif err != nil {\n\t\t\tb.Fatalf(\"Error: %v\", err)\n\t\t}\n\t}\n}", "func (b *Benchmark) Run(ctx context.Context) (*Result, error) {\n\targs := b.Args()\n\tcmd := testexec.CommandContext(ctx, args[0], args[1:]...)\n\toutput, err := cmd.Output(testexec.DumpLogOnError)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to run the benchmark binary: %s\", b.executable)\n\t}\n\n\tvar ret Result\n\tif err := json.Unmarshal(output, &ret); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to unmarshal output bytes to JSON-based Result\")\n\t}\n\treturn &ret, nil\n}", "func Test() error {\n\tfmt.Println(\"Testing...\")\n\tcmd := exec.Command(\"go\", \"test\", \"-cover\", \"-v\", \"-bench\", \"'.'\", \"-benchmem\", \"./...\")\n\tcmd.Stdout = Stdout\n\tcmd.Stderr = Stderr\n\treturn cmd.Run()\n}", "func SetUpBenchmark(ctx context.Context) (cleanUp func(ctx context.Context), err error) {\n\tconst cleanupTime = 10 * time.Second // time reserved for cleanup on error.\n\n\tvar restoreScaling func(ctx context.Context) error\n\tvar restoreThrottling func(ctx context.Context) error\n\tcleanUp = func(ctx context.Context) {\n\t\tif restoreScaling != nil {\n\t\t\tif err = restoreScaling(ctx); err != nil {\n\t\t\t\ttesting.ContextLog(ctx, \"Failed to restore CPU frequency scaling to original values: \", err)\n\t\t\t}\n\t\t}\n\t\tif restoreThrottling != nil {\n\t\t\tif err = restoreThrottling(ctx); err != nil {\n\t\t\t\ttesting.ContextLog(ctx, \"Failed to restore CPU thermal throttling to original values: \", err)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Run the cleanUp function automatically if we encounter an error.\n\tdoCleanup := cleanUp\n\tdefer func() {\n\t\tif doCleanup != nil {\n\t\t\tdoCleanup(ctx)\n\t\t}\n\t}()\n\n\t// Run all non-cleanup operations with a shorter context. This ensures\n\t// thermal throttling and CPU frequency scaling get re-enabled, even when\n\t// test execution exceeds the maximum time allowed.\n\tctx, cancel := ctxutil.Shorten(ctx, cleanupTime)\n\tdefer cancel()\n\n\t// CPU frequency scaling and thermal throttling might influence our test results.\n\tif restoreScaling, err = disableCPUFrequencyScaling(ctx); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to disable CPU frequency scaling\")\n\t}\n\tif restoreThrottling, err = disableThermalThrottling(ctx); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to disable thermal throttling\")\n\t}\n\n\t// Disarm running the cleanUp function now that we expect the caller to do it.\n\tdoCleanup = nil\n\treturn cleanUp, nil\n}", "func (f Factory) RunKeyValueStoreBenchmarks(b *testing.B) {\n\tb.Run(\"GetValue\", f.BenchmarkGetValue)\n\tb.Run(\"GetValueParallel\", f.BenchmarkGetValueParallel)\n\n\tb.Run(\"SetValue\", f.BenchmarkSetValue)\n\tb.Run(\"SetValueParallel\", f.BenchmarkSetValueParallel)\n\n\tb.Run(\"DeleteValue\", f.BenchmarkDeleteValue)\n\tb.Run(\"DeleteValueParallel\", f.BenchmarkDeleteValueParallel)\n}", "func Benchmark(b *testing.B) {\n\tBenchmarkCoreSimple(b)\n}", "func BenchmarkRun(b *testing.B) {\n\trng := rand.New(rand.NewSource(1))\n\tctx := context.Background()\n\trunGC := func(eng storage.Engine, old bool, spec randomRunGCTestSpec) (Info, error) {\n\t\trunGCFunc := Run\n\t\tif old {\n\t\t\trunGCFunc = runGCOld\n\t\t}\n\t\tsnap := eng.NewSnapshot()\n\t\tpolicy := zonepb.GCPolicy{TTLSeconds: spec.ttl}\n\t\treturn runGCFunc(ctx, spec.ds.desc(), snap, spec.now,\n\t\t\tCalculateThreshold(spec.now, policy), intentAgeThreshold,\n\t\t\tpolicy,\n\t\t\tNoopGCer{},\n\t\t\tfunc(ctx context.Context, intents []roachpb.Intent) error {\n\t\t\t\treturn nil\n\t\t\t},\n\t\t\tfunc(ctx context.Context, txn *roachpb.Transaction) error {\n\t\t\t\treturn nil\n\t\t\t})\n\t}\n\tmakeTest := func(old bool, spec randomRunGCTestSpec) func(b *testing.B) {\n\t\treturn func(b *testing.B) {\n\t\t\teng := storage.NewDefaultInMemForTesting()\n\t\t\tdefer eng.Close()\n\t\t\tms := spec.ds.dist(b.N, rng).setupTest(b, eng, *spec.ds.desc())\n\t\t\tb.SetBytes(int64(float64(ms.Total()) / float64(b.N)))\n\t\t\tb.ResetTimer()\n\t\t\t_, err := runGC(eng, old, spec)\n\t\t\tb.StopTimer()\n\t\t\trequire.NoError(b, err)\n\t\t}\n\t}\n\tspecsWithTTLs := func(\n\t\tds distSpec, now hlc.Timestamp, ttls []int32,\n\t) (specs []randomRunGCTestSpec) {\n\t\tfor _, ttl := range ttls {\n\t\t\tspecs = append(specs, randomRunGCTestSpec{\n\t\t\t\tds: ds,\n\t\t\t\tnow: now,\n\t\t\t\tttl: ttl,\n\t\t\t})\n\t\t}\n\t\treturn specs\n\t}\n\tts100 := hlc.Timestamp{WallTime: (100 * time.Second).Nanoseconds()}\n\tttls := []int32{0, 25, 50, 75, 100}\n\tspecs := specsWithTTLs(fewVersionsTinyRows, ts100, ttls)\n\tspecs = append(specs, specsWithTTLs(someVersionsMidSizeRows, ts100, ttls)...)\n\tspecs = append(specs, specsWithTTLs(lotsOfVersionsMidSizeRows, ts100, ttls)...)\n\tfor _, old := range []bool{true, false} {\n\t\tb.Run(fmt.Sprintf(\"old=%v\", old), func(b *testing.B) {\n\t\t\tfor _, spec := range specs {\n\t\t\t\tb.Run(fmt.Sprint(spec.ds), makeTest(old, spec))\n\t\t\t}\n\t\t})\n\t}\n}", "func (b *Benchmark) Run() {\n\tfor _, gpu := range b.gpus {\n\t\tb.driver.SelectGPU(b.context, gpu)\n\t\tb.queues = append(b.queues, b.driver.CreateCommandQueue(b.context))\n\t}\n\n\tif b.NumIterations == 0 || b.NumIterations > b.NumNodes {\n\t\tb.NumIterations = b.NumNodes\n\t}\n\n\tb.initMem()\n\tb.exec()\n}", "func Run(workers []Worker, duration time.Duration) *Result {\n\tdebug = os.Getenv(\"DEBUG\") != \"\"\n\tc := len(workers)\n\tlog.Printf(\"starting benchmark: concurrency: %d, time: %s, GOMAXPROCS: %d\", c, duration, runtime.GOMAXPROCS(0))\n\tstartCh := make(chan bool, c)\n\treadyCh := make(chan bool, c)\n\tvar stopFlag int32\n\tscoreCh := make(chan int, c)\n\tvar wg sync.WaitGroup\n\n\t// spawn worker goroutines\n\tfor i, w := range workers {\n\t\tdebugLog(\"spwan worker[%d]\", i)\n\t\tgo func(n int, worker Worker) {\n\t\t\twg.Add(1)\n\t\t\tdefer wg.Done()\n\t\t\tscore := 0\n\t\t\tworker.Setup()\n\t\t\treadyCh <- true // ready of worker:n\n\t\t\t<-startCh // notified go benchmark from Runner\n\t\t\tdebugLog(\"worker[%d] starting Benchmark()\", n)\n\t\t\tfor atomic.LoadInt32(&stopFlag) == 0 {\n\t\t\t\tscore += worker.Process()\n\t\t\t}\n\t\t\tscoreCh <- score\n\t\t\tdebugLog(\"worker[%d] done Benchmark() score: %d\", n, score)\n\t\t\tworker.Teardown()\n\t\t\tdebugLog(\"worker[%d] exit\", n)\n\t\t}(i, w)\n\t}\n\n\t// wait for ready of workres\n\tdebugLog(\"waiting for all workers finish Setup()\")\n\tfor i := 0; i < c; i++ {\n\t\t<-readyCh\n\t}\n\n\t// notify \"start\" to workers\n\tclose(startCh)\n\tstart := time.Now()\n\n\t// wait for catching signal or timed out\n\tsignalCh := make(chan os.Signal, 1)\n\tsignal.Notify(signalCh, TrapSignals...)\n\tselect {\n\tcase s := <-signalCh:\n\t\tswitch sig := s.(type) {\n\t\tcase syscall.Signal:\n\t\t\tlog.Printf(\"Got signal: %s(%d)\", sig, sig)\n\t\tdefault:\n\t\t\tlog.Printf(\"interrupted %s\", s)\n\t\t\tbreak\n\t\t}\n\tcase <-time.After(duration):\n\t\tdebugLog(\"timed out\")\n\t\tbreak\n\t}\n\n\t// notify \"stop\" to workers\n\tatomic.StoreInt32(&stopFlag, 1)\n\n\t// collect scores from workers\n\ttotalScore := 0\n\tfor i := 0; i < c; i++ {\n\t\ttotalScore += <-scoreCh\n\t}\n\tend := time.Now()\n\telapsed := end.Sub(start)\n\tlog.Printf(\"done benchmark: score %d, elapsed %s = %f / sec\\n\", totalScore, elapsed, float64(totalScore)/float64(elapsed)*float64(time.Second))\n\n\twg.Wait()\n\treturn &Result{Score: totalScore, Elapsed: elapsed}\n}", "func main() {\n\tbenchMark()\n\tlevelDemo()\n}", "func (tq TestQuery) Benchmark(client *QueryClient) error {\n\t_, err := exec(client, string(tq), nil)\n\treturn err\n}", "func TestAbBenchCommand(t *testing.T) {\n\tvar tool AbTool\n\n\tconfig := &cfg.Config{}\n\tconfig.Ab.Keepalive = false\n\tconfig.Ab.Concurency = 1\n\tconfig.Ab.Requests = 1\n\n\ttool = AbTool{&config.Ab}\n\t_, err := tool.BenchCommand(\"test\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tconfig.Ab.Keepalive = true\n\ttool = AbTool{&config.Ab}\n\t_, err = tool.BenchCommand(\"test\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tconfig.Ab.Concurency = 2\n\ttool = AbTool{&config.Ab}\n\t_, err = tool.BenchCommand(\"test\")\n\tif err == nil {\n\t\tt.Fatal(\"Unexpected result for Requests < Concurency\")\n\t}\n\n\tconfig.Ab.Concurency = 0\n\ttool = AbTool{&config.Ab}\n\t_, err = tool.BenchCommand(\"test\")\n\tif err == nil {\n\t\tt.Fatal(\"Unexpected result for Requests = 0\")\n\t}\n}", "func (api *PrivateLightServerAPI) Benchmark(setups []map[string]interface{}, passCount, length int) ([]map[string]interface{}, error) {\n\tbenchmarks := make([]requestBenchmark, len(setups))\n\tfor i, setup := range setups {\n\t\tif t, ok := setup[\"type\"].(string); ok {\n\t\t\tgetInt := func(field string, def int) int {\n\t\t\t\tif value, ok := setup[field].(float64); ok {\n\t\t\t\t\treturn int(value)\n\t\t\t\t}\n\t\t\t\treturn def\n\t\t\t}\n\t\t\tgetBool := func(field string, def bool) bool {\n\t\t\t\tif value, ok := setup[field].(bool); ok {\n\t\t\t\t\treturn value\n\t\t\t\t}\n\t\t\t\treturn def\n\t\t\t}\n\t\t\tswitch t {\n\t\t\tcase \"header\":\n\t\t\t\tbenchmarks[i] = &benchmarkBlockHeaders{\n\t\t\t\t\tamount: getInt(\"amount\", 1),\n\t\t\t\t\tskip: getInt(\"skip\", 1),\n\t\t\t\t\tbyHash: getBool(\"byHash\", false),\n\t\t\t\t\treverse: getBool(\"reverse\", false),\n\t\t\t\t}\n\t\t\tcase \"body\":\n\t\t\t\tbenchmarks[i] = &benchmarkBodiesOrReceipts{receipts: false}\n\t\t\tcase \"receipts\":\n\t\t\t\tbenchmarks[i] = &benchmarkBodiesOrReceipts{receipts: true}\n\t\t\tcase \"proof\":\n\t\t\t\tbenchmarks[i] = &benchmarkProofsOrCode{code: false}\n\t\t\tcase \"code\":\n\t\t\t\tbenchmarks[i] = &benchmarkProofsOrCode{code: true}\n\t\t\tcase \"cht\":\n\t\t\t\tbenchmarks[i] = &benchmarkHelperTrie{\n\t\t\t\t\tbloom: false,\n\t\t\t\t\treqCount: getInt(\"amount\", 1),\n\t\t\t\t}\n\t\t\tcase \"bloom\":\n\t\t\t\tbenchmarks[i] = &benchmarkHelperTrie{\n\t\t\t\t\tbloom: true,\n\t\t\t\t\treqCount: getInt(\"amount\", 1),\n\t\t\t\t}\n\t\t\tcase \"txSend\":\n\t\t\t\tbenchmarks[i] = &benchmarkTxSend{}\n\t\t\tcase \"txStatus\":\n\t\t\t\tbenchmarks[i] = &benchmarkTxStatus{}\n\t\t\tdefault:\n\t\t\t\treturn nil, ErrUnknownBenchmarkType\n\t\t\t}\n\t\t} else {\n\t\t\treturn nil, ErrUnknownBenchmarkType\n\t\t}\n\t}\n\trs := api.server.protocolManager.runBenchmark(benchmarks, passCount, time.Millisecond*time.Duration(length))\n\tresult := make([]map[string]interface{}, len(setups))\n\tfor i, r := range rs {\n\t\tres := make(map[string]interface{})\n\t\tif r.err == nil {\n\t\t\tres[\"totalCount\"] = r.totalCount\n\t\t\tres[\"avgTime\"] = r.avgTime\n\t\t\tres[\"maxInSize\"] = r.maxInSize\n\t\t\tres[\"maxOutSize\"] = r.maxOutSize\n\t\t} else {\n\t\t\tres[\"error\"] = r.err.Error()\n\t\t}\n\t\tresult[i] = res\n\t}\n\treturn result, nil\n}", "func Main(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) {}", "func (b *Benchmark) Run() {\n\tfor _, l := range b.network.Layers {\n\t\tl.Randomize()\n\t}\n\n\tfor i := 0; i < 100; i++ {\n\t\tb.printLayerParams()\n\t\tb.trainer.Train()\n\t}\n}", "func run(t *testing.T, formatter Formatter, suites ...TCatcher) {\n\tvar (\n\t\tbeforeAllFound, afterAllFound bool\n\t\tbeforeAll, afterAll, before, after reflect.Value\n\t\ttotalPassed, totalFailed, totalPending, totalNoAssertions int\n\t)\n\n\tflag.Parse()\n\n\tfor _, s := range suites {\n\t\tbeforeAll, afterAll, before, after = reflect.Value{}, reflect.Value{}, reflect.Value{}, reflect.Value{}\n\t\ts.SetT(t)\n\t\ts.Reset()\n\n\t\tiType := reflect.TypeOf(s)\n\n\t\tformatter.PrintSuiteName(strings.Split(iType.String(), \".\")[1])\n\n\t\t// search for Before and After methods\n\t\tfor i := 0; i < iType.NumMethod(); i++ {\n\t\t\tmethod := iType.Method(i)\n\t\t\tif ok, _ := regexp.MatchString(\"^BeforeAll\", method.Name); ok {\n\t\t\t\tif !beforeAllFound {\n\t\t\t\t\tbeforeAll = method.Func\n\t\t\t\t\tbeforeAllFound = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ok, _ := regexp.MatchString(\"^AfterAll\", method.Name); ok {\n\t\t\t\tif !afterAllFound {\n\t\t\t\t\tafterAll = method.Func\n\t\t\t\t\tafterAllFound = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ok, _ := regexp.MatchString(\"^Before\", method.Name); ok {\n\t\t\t\tbefore = method.Func\n\t\t\t}\n\t\t\tif ok, _ := regexp.MatchString(\"^After\", method.Name); ok {\n\t\t\t\tafter = method.Func\n\t\t\t}\n\t\t}\n\n\t\tif beforeAll.IsValid() {\n\t\t\tbeforeAll.Call([]reflect.Value{reflect.ValueOf(s)})\n\t\t}\n\n\t\tfor i := 0; i < iType.NumMethod(); i++ {\n\t\t\tmethod := iType.Method(i)\n\t\t\tif ok, _ := regexp.MatchString(*testToRun, method.Name); ok {\n\t\t\t\tif ok, _ := regexp.MatchString(formatter.AllowedMethodsPattern(), method.Name); ok {\n\n\t\t\t\t\ts.SetStatus(&Status{Code: STATUS_NO_ASSERTIONS})\n\n\t\t\t\t\tif before.IsValid() {\n\t\t\t\t\t\tbefore.Call([]reflect.Value{reflect.ValueOf(s)})\n\t\t\t\t\t}\n\n\t\t\t\t\tmethod.Func.Call([]reflect.Value{reflect.ValueOf(s)})\n\n\t\t\t\t\tif after.IsValid() {\n\t\t\t\t\t\tafter.Call([]reflect.Value{reflect.ValueOf(s)})\n\t\t\t\t\t}\n\n\t\t\t\t\tvar info *suiteInfo\n\t\t\t\t\tstatus := s.GetStatus()\n\n\t\t\t\t\tswitch status.Code {\n\t\t\t\t\tcase STATUS_PASS:\n\t\t\t\t\t\tinfo = s.GetInfo()\n\t\t\t\t\t\ttotalPassed++\n\t\t\t\t\tcase STATUS_FAIL:\n\t\t\t\t\t\tinfo = s.GetInfo()\n\t\t\t\t\t\tt.Error(status.ErrorMessage)\n\t\t\t\t\t\ttotalFailed++\n\t\t\t\t\tcase STATUS_PENDING:\n\t\t\t\t\t\tinfo = s.GetInfo()\n\t\t\t\t\t\tinfo.assertions = 0\n\t\t\t\t\t\ttotalPending++\n\t\t\t\t\tcase STATUS_NO_ASSERTIONS:\n\t\t\t\t\t\tinfo = &suiteInfo{0, method.Name}\n\t\t\t\t\t\ttotalNoAssertions++\n\t\t\t\t\t}\n\t\t\t\t\tformatter.PrintStatus(status, info)\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif afterAll.IsValid() {\n\t\t\tafterAll.Call([]reflect.Value{reflect.ValueOf(s)})\n\t\t}\n\t}\n\n\tformatter.PrintFinalReport(totalPassed, totalFailed, totalPending, totalNoAssertions)\n}", "func Main(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample)", "func TestRunTestAllReal(t *testing.T) {\n\tif testing.Short() {\n\t\tt.Skip(\"Skipping test in short mode.\")\n\t}\n\n\ttaskData := agent.TaskData{\n\t\tStringValues: map[string]string{\n\t\t\tCFG_TEST_TYPE: CFG_TYPE_ALL,\n\t\t\tCFG_SERVER_HOST: \"speedtest.nyc.rr.com:8080\",\n\t\t\tCFG_SERVER_ID: \"16976\",\n\t\t},\n\t\tIntValues: map[string]int{\n\t\t\tCFG_SERVER_ID: 16976,\n\t\t\tCFG_TIME_OUT: 5,\n\t\t},\n\t\tFloatValues: map[string]float64{CFG_MAX_SECONDS: 6},\n\t\tIntSlices: map[string][]int{\n\t\t\tCFG_DOWNLOAD_SIZES: {245388, 505544},\n\t\t\tCFG_UPLOAD_SIZES: {32768, 65536},\n\t\t},\n\t}\n\n\tspdTestRunner := SpeedTestRunner{}\n\n\tspTestResults, err := spdTestRunner.Run(taskData)\n\tif err != nil {\n\t\tt.Fatalf(\"Unexpected Error: \\n%s\", err.Error())\n\t}\n\n\tresults := spTestResults.Latency.Seconds()\n\n\tif results <= 0 {\n\t\tt.Errorf(\"Error: Expected a positive Latency result, but got: %f\", results)\n\t} else {\n\t\tfmt.Printf(\"\\nLatency test results for server %d ... %f\\n\", taskData.IntValues[CFG_SERVER_ID], results)\n\t}\n\n\tresults = spTestResults.Download\n\tif results <= 0 {\n\t\tt.Errorf(\"Error: Expected a positive Download result, but got: %f\", results)\n\t} else {\n\t\tfmt.Printf(\"\\nDownload test results for server %d ... %f\\n\", taskData.IntValues[CFG_SERVER_ID], results)\n\t}\n\n\tresults = spTestResults.Upload\n\tif results <= 0 {\n\t\tt.Errorf(\"Error: Expected a positive Upload result, but got: %f\", results)\n\t} else {\n\t\tfmt.Printf(\"\\nUpload test results for server %d ... %f\\n\", taskData.IntValues[CFG_SERVER_ID], results)\n\t}\n}", "func Benchmark(start time.Time, message string, alwaysRun ...bool) {\n\n\t// Check variadic args (used to mimic optional parameters).\n\tif len(alwaysRun) == 1 {\n\t\t// Optionally run benchmark even if user didn't pass flag.\n\t\tbenchmarkFlag = alwaysRun[0]\n\t}\n\n\telapsed := time.Since(start)\n\n\t// If the --benchmark flag is true.\n\tif benchmarkFlag {\n\t\tfmt.Printf(\"%s took %s\\n\", message, elapsed)\n\t}\n}", "func TestDontRun(t *testing.T) {\n\tt.Log(\"This is a Test not a Benchmark!\")\n}", "func Benchmarks(b *testing.B, ctor func() Queue) {\n\tcaps := Detect(ctor())\n\tif !caps.Any(CapQueue) {\n\t\tb.Fatal(\"does not implement any of queue interfaces\")\n\t}\n\tb.Helper()\n\n\tbenchCommon(b, caps, ctor)\n\n\t// blocking implementations\n\n\tif caps.Has(CapBlockSPSC) {\n\t\tb.Run(\"b/SPSC\", func(b *testing.B) { b.Helper(); benchSPSC(b, caps, ctor) })\n\t}\n\tif caps.Has(CapBlockMPSC) {\n\t\tb.Run(\"b/MPSC\", func(b *testing.B) { b.Helper(); benchMPSC(b, caps, ctor) })\n\t}\n\tif caps.Has(CapBlockSPMC) {\n\t\tb.Run(\"b/SPMC\", func(b *testing.B) { b.Helper(); benchSPMC(b, caps, ctor) })\n\t}\n\tif caps.Has(CapBlockMPMC) {\n\t\tb.Run(\"b/MPMC\", func(b *testing.B) { b.Helper(); benchMPMC(b, caps, ctor) })\n\t}\n\n\t// non-blocking implementations\n\n\tif caps.Has(CapNonblockSPSC) {\n\t\tb.Run(\"n/SPSC\", func(b *testing.B) { b.Helper(); benchNonblockSPSC(b, caps, ctor) })\n\t}\n\tif caps.Has(CapNonblockMPSC) {\n\t\tb.Run(\"n/MPSC\", func(b *testing.B) { b.Helper(); benchNonblockMPSC(b, caps, ctor) })\n\t}\n\tif caps.Has(CapNonblockSPMC) {\n\t\tb.Run(\"n/SPMC\", func(b *testing.B) { b.Helper(); benchNonblockSPMC(b, caps, ctor) })\n\t}\n\tif caps.Has(CapNonblockMPMC) {\n\t\tb.Run(\"n/MPMC\", func(b *testing.B) { b.Helper(); benchNonblockMPMC(b, caps, ctor) })\n\t}\n}", "func TestRunMain(t *testing.T) {\n\tmain()\n}", "func benchmark(rounds int) {\n\tfmt.Println(\"Benchmarking\")\n\tvar wg sync.WaitGroup\n\twg.Add(2)\n\n\tstatsCh := make(chan bool)\n\tgo initControllerPubTest(&wg, statsCh, rounds)\n\n\t//Testing:\n\t// Subscriber listening the stats published by the Gnfs\n\tgo initControllerStatsSubTest(&wg, statsCh)\n\twg.Wait()\n}", "func benchmarkCallers(b *testing.B, stackDepth, maxStackDepth int) {\n\t// recurseNThenCallClosure sends to readyDoneSignal once when it's ready, then once more when it's done.\n\treadyDoneSignal := make(chan bool)\n\tgo recurseNThenCallClosure(stackDepth, func() {\n\t\tfor i := 0; i < b.N; i++ {\n\t\t\t// Take our stack trace.\n\t\t\tbuffer := make([]uintptr, maxStackDepth)\n\t\t\t_ = runtime.Callers(1, buffer)\n\t\t}\n\t}, readyDoneSignal)\n\t<-readyDoneSignal // ready\n\tb.ResetTimer()\n\t<-readyDoneSignal // done\n}", "func BenchmarkCompiled(b *testing.B) {\n\tfor _, test := range ilt.TestData {\n\t\tif !test.Bench {\n\t\t\tcontinue\n\t\t}\n\n\t\tfinder := ast.NewFinder(test.Conf())\n\n\t\tbuilder := NewBuilder(finder)\n\t\texpression, _, err := builder.Compile(test.E)\n\t\tif err != nil {\n\t\t\tb.Fatalf(\"compilation of benchmark expression failed: '%v'\", err)\n\t\t\treturn\n\t\t}\n\n\t\tbag := ilt.NewFakeBag(test.I)\n\n\t\tb.Run(test.TestName(), func(bb *testing.B) {\n\t\t\tfor i := 0; i <= bb.N; i++ {\n\t\t\t\t_, _ = expression.Evaluate(bag)\n\t\t\t}\n\t\t})\n\t}\n}", "func TestRun(t *testing.T) {\n\tRun()\n}", "func BenchmarkBuild(b *testing.B) {\n\tgarbleBin := filepath.Join(b.TempDir(), \"garble\")\n\tif runtime.GOOS == \"windows\" {\n\t\tgarbleBin += \".exe\"\n\t}\n\n\tif err := exec.Command(\"go\", \"build\", \"-o=\"+garbleBin).Run(); err != nil {\n\t\tb.Fatalf(\"building garble: %v\", err)\n\t}\n\n\tfor _, name := range [...]string{\"Cache\", \"NoCache\"} {\n\t\tb.Run(name, func(b *testing.B) {\n\t\t\tbuildArgs := []string{\"build\", \"-o=\" + b.TempDir()}\n\t\t\tswitch name {\n\t\t\tcase \"Cache\":\n\t\t\t\tbuildArgs = append(buildArgs, \"./testdata/bench-cache\")\n\n\t\t\t\t// Ensure the build cache is warm,\n\t\t\t\t// for the sake of consistent results.\n\t\t\t\tcmd := exec.Command(garbleBin, buildArgs...)\n\t\t\t\tif out, err := cmd.CombinedOutput(); err != nil {\n\t\t\t\t\tb.Fatalf(\"%v: %s\", err, out)\n\t\t\t\t}\n\t\t\tcase \"NoCache\":\n\t\t\t\tbuildArgs = append(buildArgs, \"./testdata/bench-nocache\")\n\t\t\tdefault:\n\t\t\t\tb.Fatalf(\"unknown name: %q\", name)\n\t\t\t}\n\n\t\t\t// We collect extra metrics.\n\t\t\tvar userTime, systemTime int64\n\n\t\t\tb.ResetTimer()\n\t\t\tb.RunParallel(func(pb *testing.PB) {\n\t\t\t\tfor pb.Next() {\n\t\t\t\t\tcmd := exec.Command(garbleBin, buildArgs...)\n\t\t\t\t\tif name == \"NoCache\" {\n\t\t\t\t\t\tgocache, err := os.MkdirTemp(b.TempDir(), \"gocache-*\")\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\tb.Fatal(err)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcmd.Env = append(os.Environ(), \"GOCACHE=\"+gocache)\n\t\t\t\t\t}\n\t\t\t\t\tif out, err := cmd.CombinedOutput(); err != nil {\n\t\t\t\t\t\tb.Fatalf(\"%v: %s\", err, out)\n\t\t\t\t\t}\n\n\t\t\t\t\tuserTime += int64(cmd.ProcessState.UserTime())\n\t\t\t\t\tsystemTime += int64(cmd.ProcessState.SystemTime())\n\t\t\t\t}\n\t\t\t})\n\t\t\tb.ReportMetric(float64(userTime)/float64(b.N), \"user-ns/op\")\n\t\t\tb.ReportMetric(float64(systemTime)/float64(b.N), \"sys-ns/op\")\n\t\t\tinfo, err := os.Stat(garbleBin)\n\t\t\tif err != nil {\n\t\t\t\tb.Fatal(err)\n\t\t\t}\n\t\t\tb.ReportMetric(float64(info.Size()), \"bin-B\")\n\t\t})\n\t}\n}", "func Run(top *testing.T, name string, f TestFunc, accessories ...*Accessory) {\n\tif _, previouslyCalled := seen.LoadOrStore(fmt.Sprintf(\"%p\", top), nil); !previouslyCalled {\n\t\ttop.Parallel()\n\t}\n\ttop.Run(name, func(mid *testing.T) {\n\t\tmid.Parallel()\n\t\tctx, cancel := context.WithCancel(context.Background())\n\t\tbottom := testhelper.NewT(ctx, mid)\n\t\tcmd := newCiOperatorCommand(bottom)\n\t\ttestDone, cleanupDone := make(chan struct{}), make(chan struct{})\n\t\tdefer func() {\n\t\t\t// signal to the command that we no longer need to be waiting to\n\t\t\t// interrupt it; then wait for the cleanup routine to finish before\n\t\t\t// we consider the test done\n\t\t\tclose(testDone)\n\t\t\t<-cleanupDone\n\t\t}()\n\t\tcmd.testDone = testDone\n\t\tcmd.cleanupDone = cleanupDone\n\n\t\twg := sync.WaitGroup{}\n\t\twg.Add(len(accessories))\n\t\tfor _, accessory := range accessories {\n\t\t\t// binding the accessory to ctx ensures its lifetime is only\n\t\t\t// as long as the test we are running in this specific case\n\t\t\taccessory.RunFromFrameworkRunner(bottom, ctx, false)\n\t\t\tcmd.AddArgs(accessory.ClientFlags()...)\n\t\t\tgo func(a *Accessory) {\n\t\t\t\tdefer wg.Done()\n\t\t\t\ta.Ready(bottom)\n\t\t\t}(accessory)\n\t\t}\n\t\twg.Wait()\n\n\t\tgo func() {\n\t\t\tdefer func() { cancel() }() // stop waiting for errors\n\t\t\tf(bottom, &cmd)\n\t\t}()\n\n\t\tbottom.Wait()\n\t})\n}", "func NewBenchmark(driver *driver.Driver) *Benchmark {\n\tb := new(Benchmark)\n\n\tb.driver = driver\n\tb.ctx = driver.Init()\n\n\t// b.enableLayerVerification(&b.network)\n\n\treturn b\n}", "func Benchmark(fmtt string, args ...string) func() {\n\tstarted := time.Now()\n\treturn func() {\n\t\tTrace.Pipeline(fmt.Sprintf(fmtt, args) + \": \" + string(time.Since(started)))\n\t}\n}", "func RunTest(ctx context.Context, target, location string, nodeIDs []int, limit int, debug, outputJSON bool, runTest runFunc, runOutput runOutputFunc) error {\n\trunReq := &perfops.RunRequest{\n\t\tTarget: target,\n\t\tLocation: location,\n\t\tNodes: nodeIDs,\n\t\tLimit: limit,\n\t}\n\n\tf := NewFormatter(debug && !outputJSON)\n\tf.StartSpinner()\n\ttestID, err := runTest(ctx, runReq)\n\tf.StopSpinner()\n\tif err != nil {\n\t\treturn err\n\t}\n\tres := &RunOutputResult{}\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-time.After(200 * time.Millisecond):\n\t\t\t}\n\t\t\toutput, err := runOutput(ctx, testID)\n\t\t\tres.SetOutput(output, err)\n\t\t\tif err != nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}()\n\n\tif outputJSON {\n\t\tf.StartSpinner()\n\t}\n\tvar o *perfops.RunOutput\n\tfor {\n\t\tselect {\n\t\tcase <-time.After(50 * time.Millisecond):\n\t\t}\n\t\tif o, err = res.Output(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !outputJSON && o != nil {\n\t\t\tPrintOutput(f, o)\n\t\t}\n\t\tif o != nil && o.IsFinished() {\n\t\t\tbreak\n\t\t}\n\t}\n\tif outputJSON {\n\t\tf.StopSpinner()\n\t\tPrintOutputJSON(o)\n\t}\n\treturn nil\n}", "func (b *Benchmark) Verify() {\n\tpanic(\"not implemented\")\n}", "func (b *Benchmark) Verify() {\n\tpanic(\"not implemented\")\n}", "func RunTestsInternal(ctx *kt.Context, suite string) {\n\tconf, ok := suites[suite]\n\tif !ok {\n\t\tctx.Skipf(\"No configuration found for suite '%s'\", suite)\n\t}\n\tctx.Config = conf\n\t// This is run as a sub-test so configuration will work nicely.\n\tctx.Run(\"PreCleanup\", func(ctx *kt.Context) {\n\t\tctx.RunAdmin(func(ctx *kt.Context) {\n\t\t\tcount, err := doCleanup(ctx.Admin, true)\n\t\t\tif count > 0 {\n\t\t\t\tctx.Logf(\"Pre-cleanup removed %d databases from previous test runs\", count)\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\tctx.Fatalf(\"Pre-cleanup failed: %s\", err)\n\t\t\t}\n\t\t})\n\t})\n\tkt.RunSubtests(ctx)\n}", "func (ldx *LxdAudit) Run(args []string) int {\n\t// load audit tests fro benchmark folder\n\tauditTests := ldx.FileLoader.LoadAuditTests(ldx.FilesInfo)\n\t// filter tests by cmd criteria\n\tft := filteredAuditBenchTests(auditTests, ldx.PredicateChain, ldx.PredicateParams)\n\t//execute audit tests and show it in progress bar\n\tcompletedTest := executeTests(ft, ldx.runAuditTest, ldx.log)\n\t// generate output data\n\tui.PrintOutput(completedTest, ldx.OutputGenerator, ldx.log)\n\t// send test results to plugin\n\tsendResultToPlugin(ldx.PlChan, ldx.CompletedChan, completedTest)\n\treturn 0\n}", "func (t *TestRuntime) RunTests(m *testing.M) int {\n\treturn t.runTests(m, !testing.Verbose())\n}", "func PerfTool(ctx context.Context, s *testing.State) {\n\tdbgd, err := debugd.New(ctx)\n\tif err != nil {\n\t\ts.Fatal(\"Failed to connect to debugd D-Bus service: \", err)\n\t}\n\n\trep := s.Param().(testCase).repetition\n\tif rep > 1 {\n\t\t// Stress tests run for the single call only.\n\t\tfor i := 0; i < rep; i++ {\n\t\t\ttestSingleCall(ctx, s, dbgd)\n\t\t}\n\t} else {\n\t\ttestSingleCall(ctx, s, dbgd)\n\t\ttestConsecutiveCalls(ctx, s, dbgd)\n\t\ttestConcurrentCalls(ctx, s, dbgd)\n\t\ttestStopEarly(ctx, s, dbgd)\n\t\ttestSurviveUICrash(ctx, s, dbgd)\n\t\ttestRestoreCPUIdle(ctx, s, dbgd)\n\t}\n}", "func TestBenchlistAdd(t *testing.T) {\n\tvdrs := validators.NewSet()\n\tvdr0 := validators.GenerateRandomValidator(50)\n\tvdr1 := validators.GenerateRandomValidator(50)\n\tvdr2 := validators.GenerateRandomValidator(50)\n\tvdr3 := validators.GenerateRandomValidator(50)\n\tvdr4 := validators.GenerateRandomValidator(50)\n\n\terrs := wrappers.Errs{}\n\terrs.Add(\n\t\tvdrs.AddWeight(vdr0.ID(), vdr0.Weight()),\n\t\tvdrs.AddWeight(vdr1.ID(), vdr1.Weight()),\n\t\tvdrs.AddWeight(vdr2.ID(), vdr2.Weight()),\n\t\tvdrs.AddWeight(vdr3.ID(), vdr3.Weight()),\n\t\tvdrs.AddWeight(vdr4.ID(), vdr4.Weight()),\n\t)\n\tif errs.Errored() {\n\t\tt.Fatal(errs.Err)\n\t}\n\n\tthreshold := 3\n\tduration := time.Minute\n\tmaxPortion := 0.5\n\tbenchIntf, err := NewBenchlist(\n\t\tlogging.NoLog{},\n\t\tvdrs,\n\t\tthreshold,\n\t\tminimumFailingDuration,\n\t\tduration,\n\t\tmaxPortion,\n\t\t\"\",\n\t\tprometheus.NewRegistry(),\n\t)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tb := benchIntf.(*benchlist)\n\tdefer b.timer.Stop()\n\tnow := time.Now()\n\tb.clock.Set(now)\n\n\t// Nobody should be benched at the start\n\tb.lock.Lock()\n\tassert.False(t, b.isBenched(vdr0.ID()))\n\tassert.False(t, b.isBenched(vdr1.ID()))\n\tassert.False(t, b.isBenched(vdr2.ID()))\n\tassert.False(t, b.isBenched(vdr3.ID()))\n\tassert.False(t, b.isBenched(vdr4.ID()))\n\tassert.Len(t, b.failureStreaks, 0)\n\tassert.Equal(t, b.benchedQueue.Len(), 0)\n\tassert.Equal(t, b.benchlistSet.Len(), 0)\n\tb.lock.Unlock()\n\n\t// Register [threshold - 1] failures in a row for vdr0\n\tfor i := 0; i < threshold-1; i++ {\n\t\tb.RegisterFailure(vdr0.ID())\n\t}\n\n\t// Still shouldn't be benched due to not enough consecutive failure\n\tassert.False(t, b.isBenched(vdr0.ID()))\n\tassert.Equal(t, b.benchedQueue.Len(), 0)\n\tassert.Equal(t, b.benchlistSet.Len(), 0)\n\tassert.Len(t, b.failureStreaks, 1)\n\tfs := b.failureStreaks[vdr0.ID()]\n\tassert.Equal(t, threshold-1, fs.consecutive)\n\tassert.True(t, fs.firstFailure.Equal(now))\n\n\t// Register another failure\n\tb.RegisterFailure(vdr0.ID())\n\n\t// Still shouldn't be benched because not enough time (any in this case)\n\t// has passed since the first failure\n\tb.lock.Lock()\n\tassert.False(t, b.isBenched(vdr0.ID()))\n\tassert.Equal(t, b.benchedQueue.Len(), 0)\n\tassert.Equal(t, b.benchlistSet.Len(), 0)\n\tb.lock.Unlock()\n\n\t// Move the time up\n\tnow = now.Add(minimumFailingDuration).Add(time.Second)\n\tb.lock.Lock()\n\tb.clock.Set(now)\n\tb.lock.Unlock()\n\n\t// Register another failure\n\tb.RegisterFailure(vdr0.ID())\n\n\t// Now this validator should be benched\n\tb.lock.Lock()\n\tassert.True(t, b.isBenched(vdr0.ID()))\n\tassert.Equal(t, b.benchedQueue.Len(), 1)\n\tassert.Equal(t, b.benchlistSet.Len(), 1)\n\n\tnext := b.benchedQueue[0]\n\tassert.Equal(t, vdr0.ID(), next.validatorID)\n\tassert.True(t, !next.benchedUntil.After(now.Add(duration)))\n\tassert.True(t, !next.benchedUntil.Before(now.Add(duration/2)))\n\tassert.Len(t, b.failureStreaks, 0)\n\tb.lock.Unlock()\n\n\t// Give another validator [threshold-1] failures\n\tfor i := 0; i < threshold-1; i++ {\n\t\tb.RegisterFailure(vdr1.ID())\n\t}\n\n\t// Advance the time\n\tb.lock.Lock()\n\tnow = now.Add(minimumFailingDuration)\n\tb.lock.Unlock()\n\n\t// Register another failure\n\tb.RegisterResponse(vdr1.ID())\n\n\t// vdr1 shouldn't be benched\n\t// The response should have cleared its consecutive failures\n\tb.lock.Lock()\n\tassert.True(t, b.isBenched(vdr0.ID()))\n\tassert.False(t, b.isBenched(vdr1.ID()))\n\tassert.Equal(t, b.benchedQueue.Len(), 1)\n\tassert.Equal(t, b.benchlistSet.Len(), 1)\n\tassert.Len(t, b.failureStreaks, 0)\n\tb.lock.Unlock()\n\n\t// Register another failure for vdr0, who is benched\n\tb.RegisterFailure(vdr0.ID())\n\n\t// A failure for an already benched validator should not count against it\n\tb.lock.Lock()\n\tassert.Len(t, b.failureStreaks, 0)\n\tb.lock.Unlock()\n}", "func benchmarker(n int, f action) (err error) {\n\tfor i := 0; i < n; i++ {\n\t\tif err = f(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func RunServer(idx uint32) {\n\t// Initialization and establishing peer connections, see comments inside functions\n\tsvr := server.ServerInit(idx, Conf.SvrIp+\":\"+Conf.ProxyPort, Conf.SvrIp+\":\"+Conf.NetworkPort)\n\tsvr.Prologue()\n\n\t// Initiate a command receiver that listens to the benchmark controller\n\treceiver := controller.ReceiverInit(idx, false)\n\treceiver.Connect()\n\treceiver.MsgToController() // Notify the controller this server is ready to benchmark\n\n\t// The receiver does not run on the main server thread,\n\t// since it interrupts the main server thread (to shutdown the server) when cluster benchmarking is done\n\tgo func() {\n\t\treceiver.WaitController()\n\t\ttime.Sleep(2 * time.Second) // Wait inter-server messaging to be completed\n\t\t_ = syscall.Kill(syscall.Getpid(), syscall.SIGINT)\n\t}()\n\n\t// The main task and the exit actions\n\tsvr.ServerMain()\n\tsvr.Epilogue()\n\n\t// Notify the controller that this server has exited\n\treceiver.MsgToController()\n}", "func runTestMain(m *testing.M) int {\n\tisLess, err := test_helpers.IsTarantoolVersionLess(2, 2, 0)\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to extract Tarantool version: %s\", err)\n\t}\n\n\tif isLess {\n\t\tlog.Println(\"Skipping decimal tests...\")\n\t\tisDecimalSupported = false\n\t\treturn m.Run()\n\t} else {\n\t\tisDecimalSupported = true\n\t}\n\n\tinstance, err := test_helpers.StartTarantool(test_helpers.StartOpts{\n\t\tInitScript: \"config.lua\",\n\t\tListen: server,\n\t\tUser: opts.User,\n\t\tPass: opts.Pass,\n\t\tWaitStart: 100 * time.Millisecond,\n\t\tConnectRetry: 10,\n\t\tRetryTimeout: 500 * time.Millisecond,\n\t})\n\tdefer test_helpers.StopTarantoolWithCleanup(instance)\n\n\tif err != nil {\n\t\tlog.Printf(\"Failed to prepare test Tarantool: %s\", err)\n\t\treturn 1\n\t}\n\n\treturn m.Run()\n}", "func Benchmark(f func(b *B)) BenchmarkResult {}", "func (b *Engine) run() {\n\t// mines blocks from difficulty to when it takes longer than 60 seconds to mine block\n\tb.logger.Log(\"Benchmark: starting benchmark\")\n\tdone := false\n\tclose := make(chan struct{})\n\tdifficulty := 10 //! difficulty starts at 10\n\tgo func() {\n\t\tvar wg sync.WaitGroup\n\t\tfor done == false {\n\t\t\tfor i := 0; i < 3; i++ { //? runs 3 difficulties in parralel to increase benchmark speed\n\t\t\t\twg.Add(1)\n\t\t\t\tgo func(myDifficulty int) { //? mines block of myDifficulty 5 times and adds average time and difficulty\n\t\t\t\t\tvar avg []float64\n\t\t\t\t\tvar mu sync.Mutex\n\t\t\t\t\tvar mineWG sync.WaitGroup\n\t\t\t\t\tfor j := 0; j < 5; j++ {\n\t\t\t\t\t\tmineWG.Add(1)\n\t\t\t\t\t\tgo func() {\n\t\t\t\t\t\t\tstart := time.Now()\n\t\t\t\t\t\t\tblock := b.block(uint8(myDifficulty))\n\t\t\t\t\t\t\tend := time.Now()\n\t\t\t\t\t\t\tblock.DeleteFile()\n\t\t\t\t\t\t\tdiff := end.Sub(start).Seconds()\n\t\t\t\t\t\t\tmu.Lock()\n\t\t\t\t\t\t\tavg = append(avg, diff)\n\t\t\t\t\t\t\tmu.Unlock()\n\t\t\t\t\t\t\tmineWG.Done()\n\t\t\t\t\t\t}()\n\t\t\t\t\t}\n\t\t\t\t\tmineWG.Wait()\n\t\t\t\t\tvar avgSum float64\n\t\t\t\t\tfor _, val := range avg {\n\t\t\t\t\t\tavgSum += val\n\t\t\t\t\t}\n\t\t\t\t\taverage := avgSum / float64(len(avg))\n\t\t\t\t\tif average > float64(60) { // a minute\n\t\t\t\t\t\tdone = true\n\t\t\t\t\t\tclose <- struct{}{}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif done == true {\n\t\t\t\t\t\t\twg.Done()\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tb.addBenchmark(NewBenchmark(average, uint8(myDifficulty)))\n\t\t\t\t\t}\n\t\t\t\t\tb.logger.Log(\"Bechmark: completed benchmark for difficulty \" + strconv.FormatInt(int64(myDifficulty), 10))\n\t\t\t\t\twg.Done()\n\t\t\t\t}(difficulty)\n\t\t\t\tdifficulty++\n\t\t\t}\n\t\t\twg.Wait()\n\t\t}\n\t}()\n\n\t<-close //wait for close signal\n\n\tscore := float64(b.GetData()[len(b.GetData())-1].GetDifficulty()) - 10 //! 10 is subtracted to allow the score start from 1 since difficulty starts at 10\n\tscoreDecimal := 1 - b.GetData()[len(b.GetData())-1].GetAvgTime()/100 // determine decimal part of score\n\tb.setScore(score + scoreDecimal)\n\tb.logger.Info(\"Benchmark: benchmark done\")\n}", "func (mc *MultiCase) Benchmark(client *QueryClient) error {\n\tfor _, tcase := range mc.Cases {\n\t\tif err := tcase.Benchmark(client); err != nil {\n\t\t\tclient.Rollback()\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func NewBenchmark(driver *driver.Driver) *Benchmark {\n\tb := new(Benchmark)\n\n\tb.driver = driver\n\tb.context = b.driver.Init()\n\n\tb.network = training.Network{\n\t\tLayers: []layers.Layer{\n\t\t\tsimLayers.CPUToGPULayer{\n\t\t\t\tGPUDriver: b.driver,\n\t\t\t\tGPUCtx: b.context,\n\t\t\t},\n\t\t\tsimLayers.NewFullyConnectedLayer(\n\t\t\t\t2, 2,\n\t\t\t\tb.driver, b.context,\n\t\t\t\tsimLayers.NewTensorOperator(b.driver, b.context),\n\t\t\t),\n\t\t\tsimLayers.NewReluLayer(b.driver, b.context),\n\t\t\tsimLayers.NewFullyConnectedLayer(\n\t\t\t\t2, 2,\n\t\t\t\tb.driver, b.context,\n\t\t\t\tsimLayers.NewTensorOperator(b.driver, b.context),\n\t\t\t),\n\t\t\tsimLayers.GPUToCPULayer{\n\t\t\t\tGPUDriver: b.driver,\n\t\t\t\tGPUCtx: b.context,\n\t\t\t},\n\t\t},\n\t}\n\n\tb.trainer = training.Trainer{\n\t\tDataSource: NewDataSource(),\n\t\tNetwork: b.network,\n\t\tLossFunc: training.SoftmaxCrossEntropy{},\n\t\tOptimizationAlg: optimization.NewAdam(0.01),\n\t\tTester: &training.Tester{\n\t\t\tDataSource: NewDataSource(),\n\t\t\tNetwork: b.network,\n\t\t\tBatchSize: 4,\n\t\t},\n\t\tEpoch: 1,\n\t\tBatchSize: 4,\n\t\tShowBatchInfo: true,\n\t}\n\n\tb.enableLayerVerification(&b.network)\n\n\treturn b\n}", "func main() {\n\ttest_plain_background()\n\ttest_cloud()\n\ttest_enemy()\n\ttest_move_background()\n\ttest_display_score()\n}", "func Benchmark(b benchparse.Benchmark, p plotter.Plotter, xName, yName string, options ...plotOption) error {\n\tpltOptions := &plotOptions{\n\t\tgroupBy: []string{},\n\t\tplotTypes: []string{},\n\t\tfilterExprs: []string{},\n\t}\n\tfor _, opt := range options {\n\t\topt.apply(pltOptions)\n\t}\n\n\tvar (\n\t\tres = b.Results\n\t\terr error\n\t)\n\n\tfor _, expr := range pltOptions.filterExprs {\n\t\tres, err = res.Filter(expr)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tgrouped := res.Group(pltOptions.groupBy)\n\tsplitGrouped, err := splitGroupedResult(grouped, xName, yName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"err splitting grouped results: %w\", err)\n\t}\n\n\tif len(pltOptions.plotTypes) == 0 {\n\t\tplotTypes, err := defaultPlotTypes(splitGrouped)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tpltOptions.plotTypes = plotTypes\n\t}\n\n\tfor i, plotType := range pltOptions.plotTypes {\n\t\tincludeLegend := i == 0\n\t\tswitch plotType {\n\t\tcase ScatterType:\n\t\t\tif err := plotScatter(p, b.Name, xName, yName, splitGrouped, includeLegend); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error creating scatter plot: %w\", err)\n\t\t\t}\n\t\tcase AvgLineType:\n\t\t\tif err := plotAvgLine(p, b.Name, xName, yName, splitGrouped, includeLegend); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error creating average line plot: %w\", err)\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unknown plot type: %s\", plotType)\n\t\t}\n\t}\n\treturn nil\n}", "func Run() error {\n\tappCmd := kingpin.New(\"MesaTracer\", \"MesaTracer is a command line tool used to analyze trace from \" +\n\t\t\"glmark2 and mesa generated by libMesaTracer.so.\")\n\tcmds := make(cmdMap)\n\n\tstackCmd := appCmd.Command(\"stack\", \"Reconstruct the call stack from trace.\")\n\tstackInFile := stackCmd.Flag(\"input\", \"Input trace file.\").Short('i').Default(common.DefaultOutFile).String()\n\tstackOutFile := stackCmd.Flag(\"output\", \"Out stack file.\").Short('o').String()\n\tstackFull := stackCmd.Flag(\"full\", \"Analyze the trace in full mode or not.\").Bool()\n\tcmds[stackCmd.FullCommand()] = func() error {\n\t\treturn stack.CmdStack(*stackInFile, *stackOutFile, *stackFull)\n\t}\n\n\tstatisticCmd := appCmd.Command(\"statistic\", \"Statistics average duration for different calls.\")\n\tstatisticInFile := statisticCmd.Flag(\"input\", \"Input trace file.\").Short('i').Default(common.DefaultOutFile).String()\n\tstatisticOutFile := statisticCmd.Flag(\"output\", \"Out statistic result.\").Short('o').String()\n\tstatisticCallToCompare1 := statisticCmd.Flag(\"call1\", \"The first call to compare.\").Short('f').Default(common.DefaultCallToCompare).String()\n\tstatisticCallToCompare2 := statisticCmd.Flag(\"call2\", \"The second call to compare\").Short('s').String()\n\tcmds[statisticCmd.FullCommand()] = func() error {\n\t\treturn stack.CmdStatistic(*statisticInFile, *statisticOutFile, *statisticCallToCompare1, *statisticCallToCompare2)\n\t}\n\n\tfilterCmd := appCmd.Command(\"filter\", \"Filter the raw trace.\")\n\tfilterInFile := filterCmd.Flag(\"input\", \"Input trace file.\").Short('i').Default(common.DefaultOutFile).String()\n\tfilterOutFile := filterCmd.Flag(\"output\", \"Out filtered trace file\").Short('o').String()\n\tcmds[filterCmd.FullCommand()] = func() error {\n\t\treturn cmdFilter(*filterInFile, *filterOutFile)\n\t}\n\n\ttranslateCmd := appCmd.Command(\"translate\", \"Translate flags into names.\")\n\ttransInFile := translateCmd.Flag(\"input\", \"Input trace file.\").Short('i').Default(common.DefaultOutFile).String()\n\ttransOutFile := translateCmd.Flag(\"output\", \"Out filtered trace file\").Short('o').String()\n\tcmds[translateCmd.FullCommand()] = func() error {\n\t\treturn cmdTranslate(*transInFile, *transOutFile)\n\t}\n\n\ttestCmd := appCmd.Command(\"test\", \"Used to test some functionality.\")\n\ttestFlagMap := testCmd.Command(\"flagMap\", \"Try to extract and printout FlagMap.\")\n\tcmds[testFlagMap.FullCommand()] = func() error {\n\t\tcommon.OutFlagMap()\n\t\treturn nil\n\t}\n\n\tcmd := kingpin.MustParse(appCmd.Parse(os.Args[1:]))\n\tfor key, value := range cmds {\n\t\tif key == cmd {\n\t\t\treturn value()\n\t\t}\n\t}\n\treturn nil\n}", "func getBenchNames(testSuitePath string) (names []string, err error) {\n\tfis, err := ioutil.ReadDir(testSuitePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, fi := range fis {\n\t\tif !regular(fi) {\n\t\t\tcontinue\n\t\t}\n\t\t// read each test file\n\t\tbs, err := ioutil.ReadFile(filepath.Join(testSuitePath, fi.Name()))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tnames = append(names, benchNameRE.FindAllString(string(bs), -1)...)\n\t}\n\n\treturn names, nil\n}", "func Benchmark_11_0_1kB(b *testing.B) { benchmarkNoFaults(12, 1024, b) }", "func NewBenchmark(driver *driver.Driver) *Benchmark {\n\tb := new(Benchmark)\n\tb.driver = driver\n\tb.context = driver.Init()\n\tb.loadProgram()\n\treturn b\n}", "func Run(ctx context.Context, s *testing.State) {\n\t// Reserve time for cleanup\n\tcloseCtx := ctx\n\tctx, cancel := ctxutil.Shorten(ctx, 2*time.Second)\n\tdefer cancel()\n\n\t// Perform initial test setup\n\tsetupVars, err := runSetup(ctx, s)\n\tif err != nil {\n\t\ts.Fatal(\"Failed to run setup: \", err)\n\t}\n\tdefer setupVars.closeBrowser(closeCtx)\n\tdefer setupVars.recorder.Close(closeCtx)\n\n\tif err := muteDevice(ctx, s); err != nil {\n\t\ts.Log(\"(non-error) Failed to mute device: \", err)\n\t}\n\n\t// Execute Test\n\tif err := setupVars.recorder.Run(ctx, func(ctx context.Context) error {\n\t\treturn testBody(ctx, setupVars)\n\t}); err != nil {\n\t\ts.Fatal(\"Failed to conduct the test scenario, or collect the histogram data: \", err)\n\t}\n\n\t// Write out values\n\tpv := perf.NewValues()\n\tif err := setupVars.recorder.Record(ctx, pv); err != nil {\n\t\ts.Fatal(\"Failed to report: \", err)\n\t}\n\tif err := pv.Save(s.OutDir()); err != nil {\n\t\ts.Error(\"Failed to store values: \", err)\n\t}\n}", "func TestAbCommonResults(t *testing.T) {\n\tvar tool AbTool\n\n\tcfg.Cfg.Verbose = true\n\tconfig := &cfg.Config{}\n\tconfig.Ab.Keepalive = false\n\tconfig.Ab.Concurency = 1\n\tconfig.Ab.Requests = 1\n\ttool = AbTool{&config.Ab}\n\tresult, err := tool.BenchCommand(\"test\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\t_ = result.Command()\n\t_ = result.Params()\n\tdata := []byte(\"\")\n\tresult.Parse(data)\n\tdata = []byte(AB_RESULT)\n\tresult.Parse(data)\n}", "func BenchmarkisNotABenchmark(b *testing.B) {\n\tpanic(\"This is not a valid benchmark function.\")\n}", "func MainStart(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) *M", "func run(name string, b *testing.B, count int, fn func(buf *Buffer, r *Reader)) {\r\n\tb.Run(name, func(b *testing.B) {\r\n\t\tbuf := NewBuffer(count * 20)\r\n\t\tr := NewReader()\r\n\t\tb.ReportAllocs()\r\n\t\tb.ResetTimer()\r\n\t\tfor n := 0; n < b.N; n++ {\r\n\t\t\tbuf.Reset(\"test\")\r\n\t\t\tfn(buf, r)\r\n\t\t}\r\n\t})\r\n}", "func (ldx *LxdAudit) runAuditTest(at *models.AuditBench) []*models.AuditBench {\n\tauditRes := make([]*models.AuditBench, 0)\n\tif at.NonApplicable {\n\t\tauditRes = append(auditRes, at)\n\t\treturn auditRes\n\t}\n\t// execute audit test command\n\tcmdEvalResult := ldx.Evaluator.EvalCommand(at.AuditCommand, at.EvalExpr)\n\t// continue with result processing\n\tauditRes = append(auditRes, ldx.ResultProcessor(at, cmdEvalResult.Match)...)\n\treturn auditRes\n}", "func TestMain(t *testing.T) { TestingT(t) }", "func main() {\n\tflag.Parse()\n\t// To test that the sequential version gathers the same blobs in commits\n\tif *test {\n\t\tblobsInCommitsSequential := getBlobsInCommitSequential(false)\n\t\tblobsInCommits := getBlobsInCommit(false)\n\t\tif diff := cmp.Diff(&blobsInCommits, &blobsInCommitsSequential); diff != \"\" {\n\t\t\tfmt.Println(fmt.Errorf(\"blobs mismatch (-want +got):\\n%s\", diff))\n\t\t\tos.Exit(1)\n\t\t}\n\t\tos.Exit(0)\n\t}\n\n\tgo http.ListenAndServe(\":1234\", nil)\n\t// if *cpuprofile != \"\" {\n\t// \tf, err := os.Create(*cpuprofile)\n\t// \tif err != nil {\n\t// \t\tlog.Fatal(err)\n\t// \t}\n\t// \tpprof.StartCPUProfile(f)\n\t// \tdefer pprof.StopCPUProfile()\n\t// }\n\tadditions := GetAdditions(false)\n\t_ = additions\n}", "func Run(config *Settings) {\n\tfileNames, err := config.reader.ReadExecutables()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tvar resMutex = &sync.Mutex{}\n\tres := make([]*google.TestResult, 0)\n\n\tvar tasksWg sync.WaitGroup\n\ttasksWg.Add(len(fileNames))\n\tworkerQueueLimit := make(chan bool, config.workersCount) \n\n\tfor _, line := range fileNames {\n\t\tworkerQueueLimit <- true // try get access to work\n\t\tgo func(file string) {\n\t\t\tdefer tasksWg.Done()\n\t\t\tdefer func() { <-workerQueueLimit }() // decrease working queue\n\n\t\t\tconfig.formatter.ShowSuiteStart(file)\n\n\t\t\tgr, output, err := runGoogleTest(file, config.workingDir)\n\t\t\tif err != nil {\n\t\t\t\tconfig.formatter.ShowSuiteFailure(file, output, err)\n\t\t\t} else {\n\t\t\t\tresMutex.Lock()\n\t\t\t\tdefer resMutex.Unlock()\n\t\t\t\tres = append(res, gr)\n\t\t\t\tconfig.formatter.ShowTests(gr, output)\n\t\t\t}\n\t\t}(line)\n\t}\n\n\ttasksWg.Wait()\n\n\tconfig.formatter.ShowStatistics(res)\n}", "func (runner *suiteRunner) runTest(method *reflect.FuncValue) *C {\n c := runner.forkTest(method)\n <-c.done\n return c\n}", "func TestMain(t *testing.T) {\n}", "func (c *Command) Run(args []string) {\n\tflag.StringVar(&c.Filter, \"f\", \"\", \"regexp to filter tests by name\")\n\tflag.BoolVar(&c.Verbose, \"v\", false, \"print all test names\")\n\tcheck(flag.CommandLine.Parse(args))\n\targs = flag.Args()\n\n\tif len(args) == 0 {\n\t\targs = []string{\".\"}\n\t}\n\n\tokPath, err := util.OKPath()\n\tcheck(err)\n\n\tfor _, arg := range args {\n\t\tpackageName := util.PackageNameFromPath(okPath, arg)\n\t\tif arg == \".\" {\n\t\t\tpackageName = \".\"\n\t\t}\n\t\tanonFunctionName := 0\n\t\tf, _, errs := compiler.Compile(okPath, packageName, true,\n\t\t\t&anonFunctionName, false)\n\t\tutil.CheckErrorsWithExit(errs)\n\n\t\tm := vm.NewVM(\"no-package\")\n\t\tstartTime := time.Now()\n\t\tcheck(m.LoadFile(f))\n\t\terr := m.RunTests(c.Verbose, regexp.MustCompile(c.Filter), packageName)\n\t\telapsed := time.Since(startTime).Milliseconds()\n\t\tcheck(err)\n\n\t\tassertWord := pluralise(\"assert\", m.TotalAssertions)\n\t\tif m.TestsFailed > 0 {\n\t\t\tfmt.Printf(\"%s: %d failed %d passed %d %s (%d ms)\\n\",\n\t\t\t\tpackageName, m.TestsFailed, m.TestsPass,\n\t\t\t\tm.TotalAssertions, assertWord, elapsed)\n\t\t} else {\n\t\t\tfmt.Printf(\"%s: %d passed %d %s (%d ms)\\n\",\n\t\t\t\tpackageName, m.TestsPass,\n\t\t\t\tm.TotalAssertions, assertWord, elapsed)\n\t\t}\n\n\t\tif m.TestsFailed > 0 {\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n}", "func (ts *TestSuite) RunTests() {\n\n\tif len(ts.Tests) == 0 {\n\t\tout.Printf(\"No tests to run\\n\")\n\t\treturn\n\t}\n\n\tstartTime := time.Now()\n\n\t// setup search\n\ts := search.NewSearch()\n\tsl := search.NewSearchLimits()\n\tsl.MoveTime = ts.Time\n\tsl.Depth = ts.Depth\n\tif sl.MoveTime > 0 {\n\t\tsl.TimeControl = true\n\t}\n\n\tout.Printf(\"Running Test Suite\\n\")\n\tout.Printf(\"==================================================================\\n\")\n\tout.Printf(\"EPD File: %s\\n\", ts.FilePath)\n\tout.Printf(\"SearchTime: %d ms\\n\", ts.Time.Milliseconds())\n\tout.Printf(\"MaxDepth: %d\\n\", ts.Depth)\n\tout.Printf(\"Date: %s\\n\", time.Now().Local())\n\tout.Printf(\"No of tests: %d\\n\", len(ts.Tests))\n\tout.Println()\n\n\t// execute all tests and store results in the\n\t// test instance\n\tfor i, t := range ts.Tests {\n\t\tout.Printf(\"Test %d of %d\\nTest: %s -- Target Result %s\\n\", i+1, len(ts.Tests), t.line, t.targetMoves.StringUci())\n\t\tstartTime2 := time.Now()\n\t\trunSingleTest(s, sl, t)\n\t\telapsedTime := time.Since(startTime2)\n\t\tt.nodes = s.NodesVisited()\n\t\tt.time = s.LastSearchResult().SearchTime\n\t\tt.nps = util.Nps(s.NodesVisited(), s.LastSearchResult().SearchTime)\n\t\tout.Printf(\"Test finished in %d ms with result %s (%s) - nps: %d\\n\\n\",\n\t\t\telapsedTime.Milliseconds(), t.rType.String(), t.actual.StringUci(), t.nps)\n\t}\n\n\t// sum up result for report\n\ttr := &SuiteResult{}\n\tfor _, t := range ts.Tests {\n\t\ttr.Counter++\n\t\tswitch t.rType {\n\t\tcase NotTested:\n\t\t\ttr.NotTestedCounter++\n\t\tcase Skipped:\n\t\t\ttr.SkippedCounter++\n\t\tcase Failed:\n\t\t\ttr.FailedCounter++\n\t\tcase Success:\n\t\t\ttr.SuccessCounter++\n\t\t}\n\t\ttr.Nodes += t.nodes\n\t\ttr.Time += t.time\n\t}\n\tts.LastResult = tr\n\n\telapsed := time.Since(startTime)\n\n\t// print report\n\tout.Printf(\"Results for Test Suite\\n\", ts.FilePath)\n\tout.Printf(\"------------------------------------------------------------------------------------------------------------------------------------\\n\")\n\tout.Printf(\"EPD File: %s\\n\", ts.FilePath)\n\tout.Printf(\"SearchTime: %d ms\\n\", ts.Time.Milliseconds())\n\tout.Printf(\"MaxDepth: %d\\n\", ts.Depth)\n\tout.Printf(\"Date: %s\\n\", time.Now().Local())\n\tout.Printf(\"====================================================================================================================================\\n\")\n\tout.Printf(\" %-4s | %-10s | %-8s | %-8s | %-15s | %s | %s\\n\", \" Nr.\", \"Result\", \"Move\", \"Value\", \"Expected Result\", \"Fen\", \"Id\")\n\tout.Printf(\"====================================================================================================================================\\n\")\n\tfor i, t := range ts.Tests {\n\t\tif t.tType == DM {\n\t\t\tout.Printf(\" %-4d | %-10s | %-8s | %-8s | %s%-15d | %s | %s\\n\",\n\t\t\t\ti+1, t.rType.String(), t.actual.StringUci(), t.value.String(), \"dm \", t.mateDepth, t.fen, t.id)\n\t\t} else {\n\t\t\tout.Printf(\" %-4d | %-10s | %-8s | %-8s | %s %-15s | %s | %s\\n\",\n\t\t\t\ti+1, t.rType.String(), t.actual.StringUci(), t.value.String(), t.tType.String(), t.targetMoves.StringUci(), t.fen, t.id)\n\t\t}\n\t}\n\tout.Printf(\"====================================================================================================================================\\n\")\n\tout.Printf(\"Summary:\\n\")\n\tout.Printf(\"EPD File: %s\\n\", ts.FilePath)\n\tout.Printf(\"SearchTime: %d ms\\n\", ts.Time.Milliseconds())\n\tout.Printf(\"MaxDepth: %d\\n\", ts.Depth)\n\tout.Printf(\"Date: %s\\n\", time.Now().Local())\n\tout.Printf(\"Successful: %-3d (%d %%)\\n\", tr.SuccessCounter, 100*tr.SuccessCounter/tr.Counter)\n\tout.Printf(\"Failed: %-3d (%d %%)\\n\", tr.FailedCounter, 100*tr.FailedCounter/tr.Counter)\n\tout.Printf(\"Skipped: %-3d (%d %%)\\n\", tr.SkippedCounter, 100*tr.SkippedCounter/tr.Counter)\n\tout.Printf(\"Not tested: %-3d (%d %%)\\n\", tr.NotTestedCounter, 100*tr.NotTestedCounter/tr.Counter)\n\tout.Printf(\"Test time: %s\\n\", elapsed)\n\tout.Printf(\"Configuration: %s\\n\", config.Settings.String())\n}", "func RunAccelVideoPerfTest(ctx context.Context, s *testing.State, opts encoding.TestOptions, cacheExtractedVideo bool) {\n\tconst (\n\t\t// testLogSuffix is the log name suffix of dumping log from test binary.\n\t\ttestLogSuffix = \"test.log\"\n\t\t// frameStatsSuffix is the log name suffix of frame statistics.\n\t\tframeStatsSuffix = \"frame-data.csv\"\n\t\t// cpuEncodeFrames is the number of encoded frames for CPU usage test. It should be high enouch to run for measurement duration.\n\t\tcpuEncodeFrames = 10000\n\t\t// duration of the interval during which CPU usage and power consumption will be measured.\n\t\tmeasureDuration = 10 * time.Second\n\t\t// time reserved for cleanup.\n\t\tcleanupTime = 5 * time.Second\n\t)\n\n\tcleanUpBenchmark, err := cpu.SetUpBenchmark(ctx)\n\tif err != nil {\n\t\ts.Fatal(\"Failed to set up benchmark mode: \", err)\n\t}\n\tdefer cleanUpBenchmark(ctx)\n\t// Leave a bit of time to clean up benchmark mode.\n\tctx, cancel := ctxutil.Shorten(ctx, cleanupTime)\n\tdefer cancel()\n\n\tschemaName := strings.TrimSuffix(opts.Params.Name, \".vp9.webm\")\n\tif opts.Profile == videotype.H264Prof {\n\t\tschemaName += \"_h264\"\n\t} else {\n\t\tschemaName += \"_vp8\"\n\t}\n\n\tfpsLogPath := getResultFilePath(s.OutDir(), schemaName, \"fullspeed\", testLogSuffix)\n\n\tlatencyLogPath := getResultFilePath(s.OutDir(), schemaName, \"fixedspeed\", testLogSuffix)\n\tcpuLogPath := filepath.Join(s.OutDir(), cpuLog)\n\tpowerLogPath := filepath.Join(s.OutDir(), powerLog)\n\n\tframeStatsPath := getResultFilePath(s.OutDir(), schemaName, \"quality\", frameStatsSuffix)\n\n\trunAccelVideoTest(ctx, s, performanceTest, opts, cacheExtractedVideo,\n\t\t// Run video_encode_accelerator_unittest to get FPS.\n\t\tbinArgs{\n\t\t\ttestFilter: \"EncoderPerf/*/0\",\n\t\t\textraArgs: []string{fmt.Sprintf(\"--output_log=%s\", fpsLogPath)},\n\t\t},\n\t\t// Run video_encode_accelerator_unittest to get encode latency under specified frame rate.\n\t\tbinArgs{\n\t\t\ttestFilter: \"SimpleEncode/*/0\",\n\t\t\textraArgs: []string{fmt.Sprintf(\"--output_log=%s\", latencyLogPath),\n\t\t\t\t\"--run_at_fps\", \"--measure_latency\"},\n\t\t},\n\t\t// Run video_encode_accelerator_unittest to generate SSIM/PSNR scores (objective quality metrics).\n\t\tbinArgs{\n\t\t\ttestFilter: \"SimpleEncode/*/0\",\n\t\t\textraArgs: []string{fmt.Sprintf(\"--frame_stats=%s\", frameStatsPath)},\n\t\t},\n\t\t// Run video_encode_accelerator_unittest to get CPU usage and power consumption under specified frame rate.\n\t\tbinArgs{\n\t\t\ttestFilter: \"SimpleEncode/*/0\",\n\t\t\textraArgs: []string{fmt.Sprintf(\"--num_frames_to_encode=%d\", cpuEncodeFrames),\n\t\t\t\t\"--run_at_fps\"},\n\t\t\tmeasureUsage: true,\n\t\t\tmeasureDuration: measureDuration,\n\t\t},\n\t)\n\n\tp := perf.NewValues()\n\n\tif err := encoding.ReportFPS(p, schemaName, fpsLogPath); err != nil {\n\t\ts.Fatal(\"Failed to report FPS value: \", err)\n\t}\n\n\tif err := encoding.ReportEncodeLatency(p, schemaName, latencyLogPath); err != nil {\n\t\ts.Fatal(\"Failed to report encode latency: \", err)\n\t}\n\n\tif err := encoding.ReportCPUUsage(p, schemaName, cpuLogPath); err != nil {\n\t\ts.Fatal(\"Failed to report CPU usage: \", err)\n\t}\n\n\t// TODO(b/143190876): Don't write value to disk, as this can increase test flakiness.\n\tif _, err := os.Stat(powerLogPath); os.IsNotExist(err) {\n\t\ts.Logf(\"Skipped reporting power consumption because %s does not exist\", powerLog)\n\t} else {\n\t\tif err := encoding.ReportPowerConsumption(p, schemaName, powerLogPath); err != nil {\n\t\t\ts.Fatal(\"Failed to report power consumption: \", err)\n\t\t}\n\t}\n\n\tif err := encoding.ReportFrameStats(p, schemaName, frameStatsPath); err != nil {\n\t\ts.Fatal(\"Failed to report frame stats: \", err)\n\t}\n\tp.Save(s.OutDir())\n}", "func ComputeStats(res *sdk.Result, v *venom.Tests) []string {\n\t// update global stats\n\tfor _, ts := range v.TestSuites {\n\t\tnSkipped := 0\n\t\tfor _, tc := range ts.TestCases {\n\t\t\tnSkipped += len(tc.Skipped)\n\t\t}\n\t\tif ts.Skipped < nSkipped {\n\t\t\tts.Skipped = nSkipped\n\t\t}\n\t\tif ts.Total < len(ts.TestCases)-nSkipped {\n\t\t\tts.Total = len(ts.TestCases) - nSkipped\n\t\t}\n\t\tv.Total += ts.Total\n\t\tv.TotalOK += ts.Total - ts.Failures - ts.Errors\n\t\tv.TotalKO += ts.Failures + ts.Errors\n\t\tv.TotalSkipped += ts.Skipped\n\t}\n\n\tvar nbOK, nbKO, nbSkipped int\n\n\treasons := []string{}\n\treasons = append(reasons, fmt.Sprintf(\"JUnit parser: %d testsuite(s)\", len(v.TestSuites)))\n\n\tfor i, ts := range v.TestSuites {\n\t\tvar nbKOTC, nbFailures, nbErrors, nbSkippedTC int\n\t\tif ts.Name == \"\" {\n\t\t\tts.Name = fmt.Sprintf(\"TestSuite.%d\", i)\n\t\t}\n\t\treasons = append(reasons, fmt.Sprintf(\"JUnit parser: testsuite %s has %d testcase(s)\", ts.Name, len(ts.TestCases)))\n\t\tfor k, tc := range ts.TestCases {\n\t\t\tif tc.Name == \"\" {\n\t\t\t\ttc.Name = fmt.Sprintf(\"TestCase.%d\", k)\n\t\t\t}\n\t\t\tif len(tc.Failures) > 0 {\n\t\t\t\treasons = append(reasons, fmt.Sprintf(\"JUnit parser: testcase %s has %d failure(s)\", tc.Name, len(tc.Failures)))\n\t\t\t\tnbFailures += len(tc.Failures)\n\t\t\t}\n\t\t\tif len(tc.Errors) > 0 {\n\t\t\t\treasons = append(reasons, fmt.Sprintf(\"JUnit parser: testcase %s has %d error(s)\", tc.Name, len(tc.Errors)))\n\t\t\t\tnbErrors += len(tc.Errors)\n\t\t\t}\n\t\t\tif len(tc.Failures) > 0 || len(tc.Errors) > 0 {\n\t\t\t\tnbKOTC++\n\t\t\t} else if len(tc.Skipped) > 0 {\n\t\t\t\tnbSkippedTC += len(tc.Skipped)\n\t\t\t}\n\t\t\tv.TestSuites[i].TestCases[k] = tc\n\t\t}\n\t\tnbOK += len(ts.TestCases) - nbKOTC\n\t\tnbKO += nbKOTC\n\t\tnbSkipped += nbSkippedTC\n\t\tif ts.Failures > nbFailures {\n\t\t\tnbFailures = ts.Failures\n\t\t}\n\t\tif ts.Errors > nbErrors {\n\t\t\tnbErrors = ts.Errors\n\t\t}\n\n\t\tif nbFailures > 0 {\n\t\t\treasons = append(reasons, fmt.Sprintf(\"JUnit parser: testsuite %s has %d failure(s)\", ts.Name, nbFailures))\n\t\t}\n\t\tif nbErrors > 0 {\n\t\t\treasons = append(reasons, fmt.Sprintf(\"JUnit parser: testsuite %s has %d error(s)\", ts.Name, nbErrors))\n\t\t}\n\t\tif nbKOTC > 0 {\n\t\t\treasons = append(reasons, fmt.Sprintf(\"JUnit parser: testsuite %s has %d test(s) failed\", ts.Name, nbKOTC))\n\t\t}\n\t\tif nbSkippedTC > 0 {\n\t\t\treasons = append(reasons, fmt.Sprintf(\"JUnit parser: testsuite %s has %d test(s) skipped\", ts.Name, nbSkippedTC))\n\t\t}\n\t\tv.TestSuites[i] = ts\n\t}\n\n\tif nbKO > v.TotalKO {\n\t\tv.TotalKO = nbKO\n\t}\n\n\tif nbOK != v.TotalOK {\n\t\tv.TotalOK = nbOK\n\t}\n\n\tif nbSkipped != v.TotalSkipped {\n\t\tv.TotalSkipped = nbSkipped\n\t}\n\n\tif v.TotalKO+v.TotalOK != v.Total {\n\t\tv.Total = v.TotalKO + v.TotalOK + v.TotalSkipped\n\t}\n\n\tres.Status = sdk.StatusFail\n\tif v.TotalKO == 0 {\n\t\tres.Status = sdk.StatusSuccess\n\t}\n\treturn reasons\n}", "func BenchmarkSolution(b *testing.B) {\n\tfor name, f := range tests {\n\t\t// TODO: pick a reasonable value for n to benchmark f(n)\n\t\tn := int(math.Pow10(10))\n\t\tRunBenchmark(name, b, f, n)\n\t}\n}", "func TestMain(m *testing.M) {\n\trootDir := \".\"\n\ttestsDir := \"tests\"\n\tdistDir := \"../../../cmd/agent/dist\"\n\n\t// best effort for abs path\n\tif _, fileName, _, ok := runtime.Caller(0); ok {\n\t\trootDir = filepath.Dir(fileName)\n\t\ttestsDir = filepath.Join(rootDir, testsDir)\n\t\tdistDir = filepath.Join(rootDir, distDir)\n\t}\n\tstate := Initialize(rootDir, testsDir, distDir)\n\n\t// testing this package needs an inited aggregator\n\t// to work properly.\n\taggregator.InitAggregatorWithFlushInterval(nil, \"\", \"\", time.Hour)\n\n\tret := m.Run()\n\n\tpython.PyEval_RestoreThread(state)\n\t// benchmarks don't like python.Finalize() for some reason, let's just not call it\n\n\tos.Exit(ret)\n}", "func Benchmark(b *testing.B) {\n\tcfgFilename := getCfgFilename()\n\tcfgs := GetConfigs(cfgFilename)\n\n\tfor i := 0; i < b.N; i++ {\n\t\tshowGitStatuses(cfgs)\n\t}\n}", "func TestTools(t *testing.T) { TestingT(t) }", "func MainCrawl() {\n\t// testFetchURL()\n\t// testFetchlLinks01()\n\t// testFetchlLinks02()\n\n\t// testCrawl01()\n\t// testCrawl02()\n\t// testCrawl03()\n\n\tfmt.Println(\"golang crawl examples DONE.\")\n}", "func (s WebSSHBenchmark) BenchBuilder(ctx context.Context, tc *client.TeleportClient) (WorkloadFunc, error) {\n\tclt, sess, err := tc.LoginWeb(ctx)\n\tif err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\n\twebSess := &webSession{\n\t\twebSession: sess,\n\t\tclt: clt,\n\t}\n\n\t// The web session will expire before the duration of the test\n\t// so launch the renewal loop.\n\tif !time.Now().Add(s.Duration).Before(webSess.expires()) {\n\t\tgo webSess.renew(ctx)\n\t}\n\n\t// Add \"exit\" to ensure that the session terminates after running the command.\n\tcommand := strings.Join(append(s.Command, \"\\r\\nexit\\r\\n\"), \" \")\n\n\tif s.Random {\n\t\tif tc.Host != \"all\" {\n\t\t\treturn nil, trace.BadParameter(\"random ssh bench commands must use the format <user>@all <command>\")\n\t\t}\n\n\t\tservers, err := getServers(ctx, tc)\n\t\tif err != nil {\n\t\t\treturn nil, trace.Wrap(err)\n\t\t}\n\n\t\treturn func(ctx context.Context) error {\n\t\t\treturn trace.Wrap(s.runCommand(ctx, tc, webSess, chooseRandomHost(servers), command))\n\t\t}, nil\n\t}\n\n\treturn func(ctx context.Context) error {\n\t\treturn trace.Wrap(s.runCommand(ctx, tc, webSess, tc.Host, command))\n\t}, nil\n}", "func main() {\n\ttest1()\n\tfmt.Println(\"-----------------------------------\")\n\ttest2()\n\tfmt.Println(\"-----------------------------------\")\n\ttest3()\n}", "func main() {\n\tbigSlowOperation()\n}", "func runBenchmarkReceiver(ctx context.Context) chan interface{} {\n\tchannel := make(chan interface{})\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn\n\t\t\tcase <-channel:\n\t\t\t}\n\t\t}\n\t}()\n\treturn channel\n}", "func main() {\n\tstart := time.Now()\n\n\tdata := readInData()\n\n\t// Can't use go routines because I actually need checkGroupsOfOne to finish before checkGroupsOfTwo\n\t// I'm going to keep a map of what functional dependencies I got from one and then not print them if that's what\n\t// I get from two\n\trelArr := checkGroupsOfOne(data)\n\tcheckGroupOfTwo(data, relArr)\n\n\tt := time.Now()\n\telapsed := t.Sub(start)\n\tfmt.Println(elapsed)\n}", "func CheckBenchmarkFlag(flag bool) {\n\t// If --benchmark flag is passed by user, this will be set to true.\n\tbenchmarkFlag = flag\n}", "func newSuiteRunner(suite interface{}, runConf *RunConf) *suiteRunner {\n var output io.Writer\n var filter string\n\n output = os.Stdout\n\n if runConf != nil {\n if runConf.Output != nil {\n output = runConf.Output\n }\n if runConf.Filter != \"\" {\n filter = runConf.Filter\n }\n }\n\n suiteType := reflect.Typeof(suite)\n suiteNumMethods := suiteType.NumMethod()\n suiteValue := reflect.NewValue(suite)\n\n runner := suiteRunner{suite:suite,\n tracker:newResultTracker(output)}\n runner.tests = make([]*reflect.FuncValue, suiteNumMethods)\n runner.tempDir = new(tempDir)\n testsLen := 0\n\n var filterRegexp *regexp.Regexp\n if filter != \"\" {\n if regexp, err := regexp.Compile(filter); err != nil {\n msg := \"Bad filter expression: \" + err.String()\n runner.tracker.result.RunError = os.NewError(msg)\n return &runner\n } else {\n filterRegexp = regexp\n }\n }\n\n // This map will be used to filter out duplicated methods. This\n // looks like a bug in Go, described on issue 906:\n // http://code.google.com/p/go/issues/detail?id=906\n seen := make(map[uintptr]bool, suiteNumMethods)\n\n // XXX Shouldn't Name() work here? Why does it return an empty string?\n suiteName := suiteType.String()\n if index := strings.LastIndex(suiteName, \".\"); index != -1 {\n suiteName = suiteName[index+1:]\n }\n\n for i := 0; i != suiteNumMethods; i++ {\n funcValue := suiteValue.Method(i)\n funcPC := funcValue.Get()\n if _, found := seen[funcPC]; found {\n continue\n }\n seen[funcPC] = true\n method := suiteType.Method(i)\n switch method.Name {\n case \"SetUpSuite\":\n runner.setUpSuite = funcValue\n case \"TearDownSuite\":\n runner.tearDownSuite = funcValue\n case \"SetUpTest\":\n runner.setUpTest = funcValue\n case \"TearDownTest\":\n runner.tearDownTest = funcValue\n default:\n if isWantedTest(suiteName, method.Name, filterRegexp) {\n runner.tests[testsLen] = funcValue\n testsLen += 1\n }\n }\n }\n\n runner.tests = runner.tests[0:testsLen]\n return &runner\n}", "func RunAllAccelVideoTests(ctx context.Context, s *testing.State, opts encoding.TestOptions, cacheExtractedVideo bool) {\n\tvl, err := logging.NewVideoLogger()\n\tif err != nil {\n\t\ts.Fatal(\"Failed to set values for verbose logging\")\n\t}\n\tdefer vl.Close()\n\n\t// Currently the Intel driver cannot set the VP9 bitrate correctly.\n\t// TODO(b/134538840): Remove after the driver is fixed.\n\ttestFilter := \"\"\n\tif opts.Profile == videotype.VP9Prof {\n\t\ttestFilter = bitrateTestFilter\n\t}\n\n\trunAccelVideoTest(ctx, s, functionalTest, opts, cacheExtractedVideo, binArgs{testFilter: testFilter})\n}", "func Test_Executor_Reaper_And_CmdRun_AreLocked(t *testing.T) {\n\tt.SkipNow()\n\tlog.SetLevel(log.DebugLevel)\n\n\tconfig := Config{\n\t\tPid: -1,\n\t\tDisablePid1Check: true,\n\t}\n\tgo Start(config)\n\n\tvar exitCode int\n\tdefaultFailedCode := 1\n\n\tname := \"/bin/bash\"\n\targs := []string{\n\t\t\"-c\",\n\t\t\"ls -la; /bin/bash -c 'sleep 0.2; exit 1'; exit 2\",\n\t}\n\tlog.Infof(\"run go routines for: %v %#v\", name, args)\n\n\tstopCh := make(chan bool, 10)\n\n\tfor i := 0; i < 10; i++ {\n\t\tgo func() {\n\t\t\tvar outbuf, errbuf bytes.Buffer\n\t\t\tcmd := exec.Command(name, args...)\n\t\t\tcmd.Stdout = &outbuf\n\t\t\tcmd.Stderr = &errbuf\n\n\t\t\terr := Run(cmd)\n\n\t\t\tstdout := outbuf.String()\n\t\t\tstderr := errbuf.String()\n\n\t\t\tif err != nil {\n\t\t\t\t// try to get the exit code\n\t\t\t\tif exitError, ok := err.(*exec.ExitError); ok {\n\t\t\t\t\tws := exitError.Sys().(syscall.WaitStatus)\n\t\t\t\t\texitCode = ws.ExitStatus()\n\t\t\t\t} else {\n\t\t\t\t\t// This will happen (in OSX) if `name` is not available in $PATH,\n\t\t\t\t\t// in this situation, exit code could not be get, and stderr will be\n\t\t\t\t\t// empty string very likely, so we use the default fail code, and format err\n\t\t\t\t\t// to string and set to stderr\n\t\t\t\t\tlog.Debugf(\"Could not get exit code for failed program: %v, %+v\", name, args)\n\t\t\t\t\texitCode = defaultFailedCode\n\t\t\t\t\tif stderr == \"\" {\n\t\t\t\t\t\tstderr = err.Error()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// success, exitCode should be 0 if go is ok\n\t\t\t\tws := cmd.ProcessState.Sys().(syscall.WaitStatus)\n\t\t\t\texitCode = ws.ExitStatus()\n\t\t\t}\n\t\t\tlog.Debugf(\"command result, stdout: %v, stderr: %v, exitCode: %v\", stdout, stderr, exitCode)\n\t\t\tstopCh <- true\n\t\t}()\n\n\t}\n\n\tcounter := 0\nWAIT_LOOP:\n\tfor {\n\t\t<-stopCh\n\t\tlog.Info(\"Got stopCh\")\n\t\tcounter++\n\t\tif counter == 10 {\n\t\t\tbreak WAIT_LOOP\n\t\t}\n\t}\n}", "func TestAll() error {\n\tout, err := sh.Output(\"go\", \"test\", \"./...\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tlog.Print(out)\n\treturn nil\n}", "func Bench(cfg Cfg) Results {\n\t// Synchronization variables for benchEnqueuer and benchDequeuer.\n\tbegin := make(chan struct{})\n\tvar wg sync.WaitGroup\n\n\t// Begin all enqueuers.\n\tenqDiv, enqRem := cfg.Messages/cfg.Enqueuers, cfg.Messages%cfg.Enqueuers\n\tenqTimings := make([]*[]int64, 0, cfg.Enqueuers)\n\tfor i := 0; i < cfg.Enqueuers; i++ {\n\t\tenqueues := enqDiv\n\t\tif enqRem > 0 {\n\t\t\tenqueues++\n\t\t\tenqRem--\n\t\t}\n\t\tbencher := &benchEnqueuer{\n\t\t\tenqImpl: cfg.Impl,\n\t\t\tenqueues: enqueues,\n\t\t\tenqTimings: make([]int64, 0, cfg.Messages),\n\t\t}\n\t\tenqTimings = append(enqTimings, &bencher.enqTimings)\n\t\twg.Add(1)\n\t\tgo bencher.run(begin, &wg)\n\t}\n\n\t// Begin all dequeuers.\n\tdeqDiv, deqRem := cfg.Messages/cfg.Dequeuers, cfg.Messages%cfg.Dequeuers\n\ttimings := make([]*[]int64, 0, cfg.Dequeuers)\n\tdeqTimings := make([]*[]int64, 0, cfg.Dequeuers)\n\tfor i := 0; i < cfg.Dequeuers; i++ {\n\t\tdequeues := deqDiv\n\t\tif deqRem > 0 {\n\t\t\tdequeues++\n\t\t\tdeqRem--\n\t\t}\n\t\tbencher := &benchDequeuer{\n\t\t\tdeqImpl: cfg.Impl,\n\t\t\tdequeues: dequeues,\n\t\t\ttimings: make([]int64, 0, cfg.Messages),\n\t\t\tdeqTimings: make([]int64, 0, cfg.Messages),\n\t\t}\n\t\ttimings = append(timings, &bencher.timings)\n\t\tdeqTimings = append(deqTimings, &bencher.deqTimings)\n\t\twg.Add(1)\n\t\tgo bencher.run(begin, &wg)\n\t}\n\n\tstart := etime.Now()\n\t// Start all enqueuers and dequeuers.\n\tclose(begin)\n\t// Wait for all to finish.\n\twg.Wait()\n\tend := etime.Now()\n\ttotal := end - start - nowOverhead\n\n\tb := Results{\n\t\tGOMAXPROCS: runtime.GOMAXPROCS(0),\n\t\tEnqueuers: cfg.Enqueuers,\n\t\tDequeuers: cfg.Dequeuers,\n\t\tEnqueueTimings: make([][]int64, 0, len(enqTimings)),\n\t\tDequeueTimings: make([][]int64, 0, len(deqTimings)),\n\t\tThroughputTimings: make([][]int64, 0, len(timings)),\n\t\tTotalTiming: total,\n\t}\n\n\tfor _, timingPtr := range enqTimings {\n\t\ttiming := *timingPtr\n\t\tb.EnqueueTimings = append(b.EnqueueTimings, timing)\n\t}\n\tfor _, timingPtr := range deqTimings {\n\t\ttiming := *timingPtr\n\t\tb.DequeueTimings = append(b.DequeueTimings, timing)\n\t}\n\tfor _, timingPtr := range timings {\n\t\ttiming := *timingPtr\n\t\tb.ThroughputTimings = append(b.ThroughputTimings, timing)\n\t}\n\treturn b\n}", "func Benchmark_5_0_1kB(b *testing.B) { benchmarkNoFaults(6, 1024, b) }" ]
[ "0.7102962", "0.68479264", "0.68192446", "0.6644519", "0.6495447", "0.648628", "0.6437044", "0.6397857", "0.6329505", "0.6295027", "0.62487715", "0.6246818", "0.62363374", "0.6189826", "0.6121475", "0.6104994", "0.6038097", "0.59955555", "0.5984933", "0.5976276", "0.5954494", "0.59468675", "0.59236604", "0.590496", "0.5886102", "0.58833355", "0.5841869", "0.57740545", "0.5734025", "0.572763", "0.5719433", "0.57126594", "0.56748813", "0.56444156", "0.5627016", "0.55795175", "0.5571531", "0.5564641", "0.5523009", "0.55212593", "0.55047315", "0.5489212", "0.5486913", "0.5481632", "0.54702723", "0.54700804", "0.5461782", "0.5458671", "0.5443838", "0.5443838", "0.54131466", "0.53728783", "0.5312267", "0.53042895", "0.53017706", "0.5291172", "0.5290325", "0.5254005", "0.52390355", "0.5238715", "0.5237799", "0.52355325", "0.5188654", "0.5175172", "0.51668125", "0.5166675", "0.5150319", "0.5148758", "0.5143933", "0.51152855", "0.5114101", "0.5098054", "0.50925016", "0.5072643", "0.5064108", "0.5063609", "0.5055335", "0.5041809", "0.5040559", "0.5035627", "0.50343966", "0.5033931", "0.50338453", "0.50281155", "0.50275505", "0.50248903", "0.5021489", "0.50199914", "0.5019953", "0.5014365", "0.49979478", "0.49917847", "0.49842894", "0.4982744", "0.49799752", "0.49661282", "0.4965705", "0.49623266", "0.49602872", "0.49580678" ]
0.6874231
1
Run benchmarks f as a subbenchmark with the given name. It reports whether there were any failures. A subbenchmark is like any other benchmark. A benchmark that calls Run at least once will not be measured itself and will be called once with N=1.
func (b *B) Run(name string, f func(b *B)) bool {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func RunBenchmark(name string, b *testing.B, f Func, n int) {\n\tb.Run(name, func(b *testing.B) {\n\t\tb.Logf(\"f(%d), loop (b.N) = %d\\n\", n, b.N)\n\t\tfor i := 0; i < b.N; i++ {\n\t\t\tf(n)\n\t\t}\n\t})\n}", "func RunBenchmark(b *testing.B, version int, f func(*Anwork, int)) {\n\ta, err := MakeAnwork(version)\n\tif err != nil {\n\t\tb.Fatal(err)\n\t}\n\tdefer a.Close()\n\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tf(a, i)\n\t}\n}", "func (t *TestCluster) Run(name string, f func(c TestCluster)) bool {\n\tif t.FailFast && t.hasFailure {\n\t\treturn t.H.Run(name, func(h *harness.H) {\n\t\t\tfunc(c TestCluster) {\n\t\t\t\tc.Skip(\"A previous test has already failed\")\n\t\t\t}(TestCluster{H: h, Cluster: t.Cluster})\n\t\t})\n\t}\n\tt.hasFailure = !t.H.Run(name, func(h *harness.H) {\n\t\tf(TestCluster{H: h, Cluster: t.Cluster})\n\t})\n\treturn !t.hasFailure\n\n}", "func Run(name string, t testing.TB, f func(testing.TB)) {\n\tif tt, ok := t.(*testing.T); ok {\n\t\ttt.Run(name, func(ttt *testing.T) { f(ttt) })\n\t\treturn\n\t}\n\tif tb, ok := t.(*testing.B); ok {\n\t\ttb.Run(name, func(ttb *testing.B) { f(ttb) })\n\t\treturn\n\t}\n\tt.Error(\"invalid test harness\")\n\tt.FailNow()\n}", "func (b *T) Run(name string, f func(t *T)) bool {\n\tsuccess := true\n\tif b.tracker.Active() {\n\t\tsuccess = success && b.t.Run(name, func(t *testing.T) {\n\t\t\tf(&T{t, t, b.tracker.SubTracker()})\n\t\t})\n\t}\n\treturn success\n}", "func (t *T) Run(name string, f interface{}) bool {\n\tt.Helper()\n\tt.validateCallback(f)\n\n\treturn t.T.Run(name, func(test *testing.T) {\n\t\tt.invoke(f, test)\n\t})\n}", "func (r *reporter) Run(name string, f func(t Reporter)) bool {\n\treturn r.runWithRetry(name, f, nil)\n}", "func Benchmark(b *testing.B) {\n\tBenchmarkCoreSimple(b)\n}", "func RunSTest(b int) {\n for i := 0; i < b; i++ {\n if !Stest() {\n os.Exit(1)\n }\n } \n}", "func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []InternalBenchmark) {}", "func Benchmark(f func(b *B)) BenchmarkResult {}", "func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []InternalBenchmark)", "func Benchmark(f func(b *B)) BenchmarkResult", "func Benchmark(b benchparse.Benchmark, p plotter.Plotter, xName, yName string, options ...plotOption) error {\n\tpltOptions := &plotOptions{\n\t\tgroupBy: []string{},\n\t\tplotTypes: []string{},\n\t\tfilterExprs: []string{},\n\t}\n\tfor _, opt := range options {\n\t\topt.apply(pltOptions)\n\t}\n\n\tvar (\n\t\tres = b.Results\n\t\terr error\n\t)\n\n\tfor _, expr := range pltOptions.filterExprs {\n\t\tres, err = res.Filter(expr)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tgrouped := res.Group(pltOptions.groupBy)\n\tsplitGrouped, err := splitGroupedResult(grouped, xName, yName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"err splitting grouped results: %w\", err)\n\t}\n\n\tif len(pltOptions.plotTypes) == 0 {\n\t\tplotTypes, err := defaultPlotTypes(splitGrouped)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tpltOptions.plotTypes = plotTypes\n\t}\n\n\tfor i, plotType := range pltOptions.plotTypes {\n\t\tincludeLegend := i == 0\n\t\tswitch plotType {\n\t\tcase ScatterType:\n\t\t\tif err := plotScatter(p, b.Name, xName, yName, splitGrouped, includeLegend); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error creating scatter plot: %w\", err)\n\t\t\t}\n\t\tcase AvgLineType:\n\t\t\tif err := plotAvgLine(p, b.Name, xName, yName, splitGrouped, includeLegend); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error creating average line plot: %w\", err)\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unknown plot type: %s\", plotType)\n\t\t}\n\t}\n\treturn nil\n}", "func benchmarker(n int, f action) (err error) {\n\tfor i := 0; i < n; i++ {\n\t\tif err = f(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func BenchmarkSolution(b *testing.B) {\n\tfor name, f := range tests {\n\t\t// TODO: pick a reasonable value for n to benchmark f(n)\n\t\tn := int(math.Pow10(10))\n\t\tRunBenchmark(name, b, f, n)\n\t}\n}", "func (st *buildStatus) runBenchmarkTests() (remoteErr, err error) {\n\tif st.SubName == \"\" {\n\t\treturn nil, fmt.Errorf(\"benchmark tests must run on a subrepo\")\n\t}\n\n\t// Repository under test.\n\t//\n\t// When running benchmarks, there are numerous variables:\n\t//\n\t// * Go experiment version\n\t// * Go baseline version\n\t// * Subrepo experiment version (if benchmarking subrepo)\n\t// * Subrepo baseline version (if benchmarking subrepo)\n\t// * x/benchmarks version (which defines which benchmarks run and how\n\t// regardless of which repo is under test)\n\t//\n\t// For benchmarking of the main Go repo, the first three are used.\n\t// Ideally, the coordinator scheduler would handle the combinatorics on\n\t// testing these. Unfortunately, the coordinator doesn't handle\n\t// three-way combinations. By running Go benchmarks as a \"subrepo test\"\n\t// for x/benchmark, we can at least get the scheduler to handle the\n\t// x/benchmarks version (st.SubRev) and Go experiment version (st.Rev).\n\t// The Go baseline version is simply selected as the most recent\n\t// previous release tag (e.g., 1.18.x on release-branch.go1.18) at the\n\t// time this test runs (st.installBaselineToolchain below).\n\t//\n\t// When benchmarking a subrepo, we want to compare a subrepo experiment\n\t// version vs subrepo baseline version (_not_ compare a single subrepo\n\t// version vs baseline/experiment Go versions). We do need to build the\n\t// subrepo with some version of Go, so we choose to use the latest\n\t// released version at the time of testing (same as Go baseline above).\n\t// We'd like the coordinator to handle the combination of x/benchmarks\n\t// and x/<subrepo>, however the coordinator can't do multiple subrepo\n\t// combinations.\n\t//\n\t// Thus, we run these as typical subrepo builders, which gives us the\n\t// subrepo experiment version and a Go experiment version (which we\n\t// will ignore). The Go baseline version is selected as above, and the\n\t// subrepo baseline version is selected as the latest (non-pre-release)\n\t// tag in the subrepo.\n\t//\n\t// This setup is suboptimal because the caller is installing an\n\t// experiment Go version that we won't use when building the subrepo\n\t// (we'll use the Go baseline version). We'll also end up with\n\t// duplicate runs with identical subrepo experiment/baseline and\n\t// x/benchmarks versions, as builds will trigger on every commit to the\n\t// Go repo. Limiting subrepo builders to release branches can\n\t// significantly reduce the number of Go commit triggers.\n\t//\n\t// TODO(prattmic): Cleaning this up is good future work, but these\n\t// deficiencies are not particularly problematic and avoid the need for\n\t// major changes in other parts of the coordinator.\n\trepo := st.SubName\n\tif repo == \"benchmarks\" {\n\t\trepo = \"go\"\n\t}\n\n\tconst (\n\t\tbaselineDir = \"go-baseline\"\n\t\tbenchmarksDir = \"benchmarks\"\n\t\tsubrepoDir = \"subrepo\"\n\t\tsubrepoBaselineDir = \"subrepo-baseline\"\n\t)\n\n\tworkDir, err := st.bc.WorkDir(st.ctx)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"error discovering workdir for helper %s: %v\", st.bc.IPPort(), err)\n\t\treturn nil, err\n\t}\n\tgoroot := st.conf.FilePathJoin(workDir, \"go\")\n\tbaselineGoroot := st.conf.FilePathJoin(workDir, baselineDir)\n\tgopath := st.conf.FilePathJoin(workDir, \"gopath\")\n\n\t// Install baseline toolchain in addition to the experiment toolchain.\n\ttoolchainBaselineCommit, remoteErr, err := st.installBaselineToolchain(goroot, baselineDir)\n\tif remoteErr != nil || err != nil {\n\t\treturn remoteErr, err\n\t}\n\n\t// Install x/benchmarks.\n\tbenchmarksCommit, remoteErr, err := st.fetchBenchmarksSource(benchmarksDir)\n\tif remoteErr != nil || err != nil {\n\t\treturn remoteErr, err\n\t}\n\n\t// If testing a repo other than Go, install the subrepo and its baseline.\n\tvar subrepoBaselineCommit string\n\tif repo != \"go\" {\n\t\tsubrepoBaselineCommit, remoteErr, err = st.fetchSubrepoAndBaseline(subrepoDir, subrepoBaselineDir)\n\t\tif remoteErr != nil || err != nil {\n\t\t\treturn remoteErr, err\n\t\t}\n\t}\n\n\t// Run golang.org/x/benchmarks/cmd/bench to perform benchmarks.\n\tsp := st.CreateSpan(\"running_benchmark_tests\", st.SubName)\n\tdefer func() { sp.Done(err) }()\n\n\tenv := append(st.conf.Env(),\n\t\t\"BENCH_BASELINE_GOROOT=\"+baselineGoroot,\n\t\t\"BENCH_BRANCH=\"+st.RevBranch,\n\t\t\"BENCH_REPOSITORY=\"+repo,\n\t\t\"GOROOT=\"+goroot,\n\t\t\"GOPATH=\"+gopath, // For module cache storage\n\t)\n\tenv = append(env, st.modulesEnv()...)\n\tif repo != \"go\" {\n\t\tenv = append(env, \"BENCH_SUBREPO_PATH=\"+st.conf.FilePathJoin(workDir, subrepoDir))\n\t\tenv = append(env, \"BENCH_SUBREPO_BASELINE_PATH=\"+st.conf.FilePathJoin(workDir, subrepoBaselineDir))\n\t}\n\trErr, err := st.bc.Exec(st.ctx, \"./go/bin/go\", buildlet.ExecOpts{\n\t\tDebug: true, // make buildlet print extra debug in output for failures\n\t\tOutput: st,\n\t\tDir: benchmarksDir,\n\t\tExtraEnv: env,\n\t\tPath: []string{st.conf.FilePathJoin(\"$WORKDIR\", \"go\", \"bin\"), \"$PATH\"},\n\t\tArgs: []string{\"run\", \"golang.org/x/benchmarks/cmd/bench\"},\n\t})\n\tif err != nil || rErr != nil {\n\t\treturn rErr, err\n\t}\n\n\t// Upload benchmark results on success.\n\tif err := st.uploadBenchResults(toolchainBaselineCommit, subrepoBaselineCommit, benchmarksCommit); err != nil {\n\t\treturn nil, err\n\t}\n\treturn nil, nil\n}", "func Benchmark(start time.Time, message string, alwaysRun ...bool) {\n\n\t// Check variadic args (used to mimic optional parameters).\n\tif len(alwaysRun) == 1 {\n\t\t// Optionally run benchmark even if user didn't pass flag.\n\t\tbenchmarkFlag = alwaysRun[0]\n\t}\n\n\telapsed := time.Since(start)\n\n\t// If the --benchmark flag is true.\n\tif benchmarkFlag {\n\t\tfmt.Printf(\"%s took %s\\n\", message, elapsed)\n\t}\n}", "func Run(f func(r Reporter), opts ...Option) bool {\n\tr := run(f, opts...)\n\treturn !r.Failed()\n}", "func RunTest(t *testing.T, name string, f Func, testCases []TestCase) {\n\tt.Run(name, func(t *testing.T) {\n\t\tfor _, test := range testCases {\n\t\t\tif actual := f(test.Input); actual != test.Expected {\n\t\t\t\tt.Errorf(\"\\nfor n=%d, expected: %t, actual: %t\", test.Input, test.Expected, actual)\n\t\t\t}\n\t\t}\n\t})\n}", "func BenchmarkMain(b *testing.B) {\n\tfor n:=0; n < b.N; n++ {\n\t\tmain()\n\t}\n}", "func (tc ScannerTestcase) RunSubset(ctx context.Context, n int) func(*testing.T) {\n\tsort.Slice(tc.Want, pkgSort(tc.Want))\n\treturn func(t *testing.T) {\n\t\tctx := zlog.Test(ctx, t)\n\t\td := tc.Digest()\n\t\tf, err := fetch.Layer(ctx, t, http.DefaultClient, tc.Domain, tc.Name, d)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\tdefer f.Close()\n\t\tl := &claircore.Layer{\n\t\t\tHash: d,\n\t\t}\n\t\tl.SetLocal(f.Name())\n\n\t\tgot, err := tc.Scanner.Scan(ctx, l)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\tt.Logf(\"found %d packages\", len(got))\n\t\tif !cmp.Equal(n, len(got)) {\n\t\t\tt.Error(cmp.Diff(n, len(got)))\n\t\t}\n\n\t\ttype key struct {\n\t\t\tname, hint string\n\t\t}\n\t\tgotMap := make(map[key]*claircore.Package, len(got))\n\t\tfor _, p := range got {\n\t\t\tgotMap[key{\n\t\t\t\tname: p.Name,\n\t\t\t\thint: p.RepositoryHint,\n\t\t\t}] = p\n\t\t}\n\n\t\tfor _, p := range tc.Want {\n\t\t\tg, exists := gotMap[key{\n\t\t\t\tname: p.Name,\n\t\t\t\thint: p.RepositoryHint,\n\t\t\t}]\n\t\t\tif !exists {\n\t\t\t\tt.Error(fmt.Sprintf(\"got is missing package %s with hint %s\", p.Name, p.RepositoryHint))\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif !cmp.Equal(p, g) {\n\t\t\t\tt.Error(cmp.Diff(p, g))\n\t\t\t}\n\t\t}\n\t}\n}", "func (bm *DockerBenchmarker) RunBenchmark() {\n\n\t// CIS 4.1 Create a user for the container\n\tbm.CheckNonRootUser()\n\n\t// CIS 4.2 Use trusted base images for containers\n\tbm.CheckTrustedBaseImages()\n\n\t// CIS 4.3 Do not install unnecessary packages in the container\n\tbm.CheckDisallowedPackages()\n\n\t// CIS 4.6 add HEALTHCHECK instruction to the container image\n\tbm.CheckHealthCheck()\n\n\t// CIS 4.7 Do not use update instructions alone in the Dockerfile\n\tbm.CheckRunUpdateOnly()\n\n\t// CIS 4.9 Use COPY instead of ADD in Dockerfile\n\tbm.CheckAdd()\n\n\t// CIS 4.10 Do not store secrets in Dockerfiles\n\tbm.CheckSecretsInsideImage()\n}", "func Run(ctx context.Context, f Runner, cycle time.Duration, maxErrs int, c clock.Clock) (ret *Results) {\n\t// TODO: ts_mon stuff.\n\tret = &Results{Success: true}\n\n\ttmr := c.NewTimer(ctx)\n\tdefer tmr.Stop()\n\n\tnextCycle := cycle\n\tconsecErrs := 0\n\tlog := logging.Get(ctx)\n\n\trun := func() {\n\t\texpvars.Add(\"Running\", 1)\n\t\tdefer expvars.Add(\"Running\", -1)\n\t\tdefer expvars.Add(\"Runs\", 1)\n\n\t\tt0 := c.Now()\n\t\t// TODO(seanmccullough) Optionally cancel overruns via context.WithTimeout.\n\t\terr := f(ctx)\n\t\tdur := c.Now().Sub(t0)\n\t\tif dur > cycle {\n\t\t\tlog.Errorf(\"Task overran by %v (%v - %v)\", (dur - cycle), dur, cycle)\n\t\t\tret.Overruns++\n\t\t\texpvars.Add(\"Overruns\", 1)\n\t\t}\n\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Got an error: %v\", err)\n\t\t\tret.Errs++\n\t\t\texpvars.Add(\"Errors\", 1)\n\t\t\tif consecErrs++; consecErrs >= maxErrs {\n\t\t\t\tret.Success = false\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tconsecErrs = 0\n\t\t}\n\n\t\tnextCycle = cycle - dur\n\t\ttmr.Reset(nextCycle)\n\t}\n\n\t// Run f at least once.\n\trun()\n\n\t// Keep running f until ctx is done.\n\tfor {\n\t\tif ar := <-tmr.GetC(); ar.Incomplete() {\n\t\t\treturn ret\n\t\t}\n\t\trun()\n\t\tif !ret.Success {\n\t\t\treturn ret\n\t\t}\n\t}\n}", "func Benchmark(t *testing.T, fn Func, sfn func() *optim.Solver, successfrac, avgeval float64) {\n\toptim.Rand = rand.New(rand.NewSource(BenchSeed))\n\tnrun := 44\n\tndrop := 2\n\tnkeep := nrun - 2*ndrop\n\tneval := 0\n\tniter := 0\n\tnsuccess := 0\n\tsum := 0.0\n\n\tsolvs := []*optim.Solver{}\n\tfor i := 0; i < nrun; i++ {\n\t\ts := sfn()\n\n\t\tfor s.Next() {\n\t\t\tif s.Best().Val < fn.Tol() {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif err := s.Err(); err != nil {\n\t\t\tt.Errorf(\"[%v:ERROR] %v\", fn.Name(), err)\n\t\t}\n\n\t\tsolvs = append(solvs, s)\n\t}\n\n\tsort.Sort(byevals(solvs))\n\n\tfor _, s := range solvs[ndrop : len(solvs)-ndrop] {\n\t\tneval += s.Neval()\n\t\tniter += s.Niter()\n\t\tsum += s.Best().Val\n\t\tif s.Best().Val < fn.Tol() {\n\t\t\tnsuccess++\n\t\t}\n\t}\n\n\tfrac := float64(nsuccess) / float64(nkeep)\n\tgotavg := float64(neval) / float64(nkeep)\n\n\tt.Logf(\"[%v] %v/%v runs, %v iters, %v evals, want < %.3f, averaged %.3f\", fn.Name(), nsuccess, nkeep, niter/nkeep, neval/nkeep, fn.Tol(), sum/float64(nkeep))\n\n\tif frac < successfrac {\n\t\tt.Errorf(\" FAIL: only %v/%v runs succeeded, want %v/%v\", nsuccess, nkeep, math.Ceil(successfrac*float64(nkeep)), nkeep)\n\t}\n\n\tif gotavg > avgeval {\n\t\tt.Errorf(\" FAIL: too many evaluations: want %v, averaged %.2f\", avgeval, gotavg)\n\t}\n}", "func perfTest(arg perfArg, f func()) (res perfResult) {\n\t// Pipeline: request generator -> workers -> sampler\n\tendUtil := startUtil()\n\n\t// Generate requests until arg.dur elapses\n\tstop := time.NewTimer(arg.dur)\n\tdefer stop.Stop()\n\tvar send *time.Ticker\n\tif arg.interval > 0 {\n\t\tsend = time.NewTicker(arg.interval)\n\t\tdefer send.Stop()\n\t}\n\trequests := make(chan time.Time, arg.maxq)\n\tgo func() {\n\t\tdefer close(requests)\n\t\tfor {\n\t\t\tif send == nil {\n\t\t\t\t// No request interval: send whenever the queue has space.\n\t\t\t\tselect {\n\t\t\t\tcase <-stop.C:\n\t\t\t\t\treturn\n\t\t\t\tcase requests <- time.Now():\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Attempt to send a request periodically, drop if queue is full.\n\t\t\t\tselect {\n\t\t\t\tcase <-stop.C:\n\t\t\t\t\treturn\n\t\t\t\tcase <-send.C:\n\t\t\t\t}\n\t\t\t\tselect {\n\t\t\t\tcase requests <- time.Now():\n\t\t\t\tdefault:\n\t\t\t\t\tres.drops++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\t// Workers run f until requests closed.\n\tdurations := make(chan time.Duration)\n\tvar wg sync.WaitGroup\n\twg.Add(arg.par)\n\tfor i := 0; i < arg.par; i++ {\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\tfor start := range requests {\n\t\t\t\tqueueTime := time.Since(start)\n\t\t\t\t_ = queueTime // not currently used\n\t\t\t\tstart = time.Now()\n\t\t\t\tf()\n\t\t\t\tdurations <- time.Since(start)\n\t\t\t}\n\t\t}()\n\t}\n\tgo func() {\n\t\twg.Wait()\n\t\tclose(durations)\n\t}()\n\n\t// Sampler populates result with samples.\n\tres.par = arg.par\n\tres.sampler = newSampler()\n\tdefer res.sampler.close()\n\tfor elapsed := range durations {\n\t\tres.sampler.add(elapsed)\n\t}\n\tres.walltime, res.exectime = endUtil()\n\treturn\n}", "func BenchmarkRun(b *testing.B) {\n\trng := rand.New(rand.NewSource(1))\n\tctx := context.Background()\n\trunGC := func(eng storage.Engine, old bool, spec randomRunGCTestSpec) (Info, error) {\n\t\trunGCFunc := Run\n\t\tif old {\n\t\t\trunGCFunc = runGCOld\n\t\t}\n\t\tsnap := eng.NewSnapshot()\n\t\tpolicy := zonepb.GCPolicy{TTLSeconds: spec.ttl}\n\t\treturn runGCFunc(ctx, spec.ds.desc(), snap, spec.now,\n\t\t\tCalculateThreshold(spec.now, policy), intentAgeThreshold,\n\t\t\tpolicy,\n\t\t\tNoopGCer{},\n\t\t\tfunc(ctx context.Context, intents []roachpb.Intent) error {\n\t\t\t\treturn nil\n\t\t\t},\n\t\t\tfunc(ctx context.Context, txn *roachpb.Transaction) error {\n\t\t\t\treturn nil\n\t\t\t})\n\t}\n\tmakeTest := func(old bool, spec randomRunGCTestSpec) func(b *testing.B) {\n\t\treturn func(b *testing.B) {\n\t\t\teng := storage.NewDefaultInMemForTesting()\n\t\t\tdefer eng.Close()\n\t\t\tms := spec.ds.dist(b.N, rng).setupTest(b, eng, *spec.ds.desc())\n\t\t\tb.SetBytes(int64(float64(ms.Total()) / float64(b.N)))\n\t\t\tb.ResetTimer()\n\t\t\t_, err := runGC(eng, old, spec)\n\t\t\tb.StopTimer()\n\t\t\trequire.NoError(b, err)\n\t\t}\n\t}\n\tspecsWithTTLs := func(\n\t\tds distSpec, now hlc.Timestamp, ttls []int32,\n\t) (specs []randomRunGCTestSpec) {\n\t\tfor _, ttl := range ttls {\n\t\t\tspecs = append(specs, randomRunGCTestSpec{\n\t\t\t\tds: ds,\n\t\t\t\tnow: now,\n\t\t\t\tttl: ttl,\n\t\t\t})\n\t\t}\n\t\treturn specs\n\t}\n\tts100 := hlc.Timestamp{WallTime: (100 * time.Second).Nanoseconds()}\n\tttls := []int32{0, 25, 50, 75, 100}\n\tspecs := specsWithTTLs(fewVersionsTinyRows, ts100, ttls)\n\tspecs = append(specs, specsWithTTLs(someVersionsMidSizeRows, ts100, ttls)...)\n\tspecs = append(specs, specsWithTTLs(lotsOfVersionsMidSizeRows, ts100, ttls)...)\n\tfor _, old := range []bool{true, false} {\n\t\tb.Run(fmt.Sprintf(\"old=%v\", old), func(b *testing.B) {\n\t\t\tfor _, spec := range specs {\n\t\t\t\tb.Run(fmt.Sprint(spec.ds), makeTest(old, spec))\n\t\t\t}\n\t\t})\n\t}\n}", "func BenchSegment(ctx context.Context, name string) (stop func())", "func Test_Run(t *testing.T) {\n\tr := taskrunner.New()\n\tf := false\n\n\tr.Run(\"Name\", func(ctx context.Context) {\n\t\tf = true\n\t})\n\tr.Wait()\n\n\tassert.Equal(t, true, f)\n}", "func run(name string, b *testing.B, count int, fn func(buf *Buffer, r *Reader)) {\r\n\tb.Run(name, func(b *testing.B) {\r\n\t\tbuf := NewBuffer(count * 20)\r\n\t\tr := NewReader()\r\n\t\tb.ReportAllocs()\r\n\t\tb.ResetTimer()\r\n\t\tfor n := 0; n < b.N; n++ {\r\n\t\t\tbuf.Reset(\"test\")\r\n\t\t\tfn(buf, r)\r\n\t\t}\r\n\t})\r\n}", "func Run(t *testing.T, text string, f func(*testing.T, G, S), opts ...Option) bool {\n\tt.Helper()\n\tcfg := options(opts).apply()\n\tn := &node{\n\t\ttext: []string{text},\n\t\tseed: defaultZero64(cfg.seed, time.Now().Unix()),\n\t\torder: cfg.order.or(orderSequential),\n\t\tscope: cfg.scope.or(scopeLocal),\n\t\tnest: cfg.nest.or(nestOff),\n\t\tpend: cfg.pend,\n\t\tfocus: cfg.focus,\n\t}\n\treport := cfg.report\n\tplan := n.parse(f)\n\n\tvar specs chan Spec\n\tif report != nil {\n\t\treport.Start(t, plan)\n\t\tspecs = make(chan Spec, plan.Total)\n\t\tdone := make(chan struct{})\n\t\tdefer func() {\n\t\t\tclose(specs)\n\t\t\t<-done\n\t\t}()\n\t\tgo func() {\n\t\t\treport.Specs(t, specs)\n\t\t\tclose(done)\n\t\t}()\n\t}\n\n\treturn n.run(t, func(t *testing.T, n node) {\n\t\tt.Helper()\n\t\tbuffer := &bytes.Buffer{}\n\t\tdefer func() {\n\t\t\tif specs == nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tspecs <- Spec{\n\t\t\t\tText: n.text,\n\t\t\t\tFailed: t.Failed(),\n\t\t\t\tSkipped: t.Skipped(),\n\t\t\t\tFocused: n.focus,\n\t\t\t\tParallel: n.order == orderParallel,\n\t\t\t\tOut: buffer,\n\t\t\t}\n\t\t}()\n\t\tswitch {\n\t\tcase n.pend, plan.HasFocus && !n.focus:\n\t\t\tt.SkipNow()\n\t\tcase n.order == orderParallel:\n\t\t\tt.Parallel()\n\t\t}\n\t\tvar (\n\t\t\tspec, group func()\n\t\t\tbefore, after []func()\n\t\t\tafterIdx int\n\t\t)\n\t\tgroup = func() {}\n\n\t\tf(t, func(_ string, f func(), _ ...Option) {\n\t\t\tswitch {\n\t\t\tcase len(n.loc) == 1, n.loc[0] > 0:\n\t\t\t\tn.loc[0]--\n\t\t\tcase n.loc[0] == 0:\n\t\t\t\tgroup = func() {\n\t\t\t\t\tn.loc = n.loc[1:]\n\t\t\t\t\tafterIdx = 0\n\t\t\t\t\tgroup = func() {}\n\t\t\t\t\tf()\n\t\t\t\t\tgroup()\n\t\t\t\t}\n\t\t\t\tn.loc[0]--\n\t\t\t}\n\t\t}, func(_ string, f func(), opts ...Option) {\n\t\t\tcfg := options(opts).apply()\n\t\t\tswitch {\n\t\t\tcase cfg.out != nil:\n\t\t\t\tcfg.out(buffer)\n\t\t\tcase cfg.before:\n\t\t\t\tbefore = append(before, f)\n\t\t\tcase cfg.after:\n\t\t\t\tafter = insert(after, f, afterIdx)\n\t\t\t\tafterIdx++\n\t\t\tcase spec != nil:\n\t\t\tcase len(n.loc) > 1, n.loc[0] > 0:\n\t\t\t\tn.loc[0]--\n\t\t\tdefault:\n\t\t\t\tspec = f\n\t\t\t}\n\t\t})\n\t\tgroup()\n\n\t\tif spec == nil {\n\t\t\tt.Fatal(\"Failed to locate spec.\")\n\t\t}\n\t\tdefer run(t, after...)\n\t\trun(t, before...)\n\t\trun(t, spec)\n\t})\n}", "func tbRun(t testing.TB, name string, f func(testing.TB)) bool {\n\tswitch tb := t.(type) {\n\tcase *testing.B:\n\t\treturn tb.Run(name, func(b *testing.B) { f(b) })\n\tcase *testing.T:\n\t\treturn tb.Run(name, func(t *testing.T) { f(t) })\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"unexpected %T, want *testing.B or *testing.T\", tb))\n\t}\n}", "func BenchmarkRunner_Run(b *testing.B) {\n\tsrv := serverMock()\n\tdefer srv.Close()\n\n\tclient := &http.Client{}\n\tconcurrent := make(chan struct{}, 5)\n\tparser := parsers.NewNasaParser(contextLogger, \"DEMO_KEY\", srv.URL+\"/planetary/apod?api_key=%s&date=%s\", client)\n\trunner := NewRunner(contextLogger, concurrent, parser)\n\n\tfor i := 0; i < b.N; i++ {\n\t\t_, err := runner.Run([]string{\"2019-12-06\", \"2019-12-07\", \"2019-12-10\", \"2019-12-11\", \"2019-12-12\", \"2019-12-14\"})\n\t\tif err != nil {\n\t\t\tb.Fatalf(\"Error: %v\", err)\n\t\t}\n\t}\n}", "func RunFunc(benchmarkFunc func() int, duration time.Duration, c int) *Result {\n\tworkers := make([]Worker, c)\n\tfor i := 0; i < c; i++ {\n\t\tworkers[i] = &funcWorker{ID: i, benchmarkFunc: benchmarkFunc}\n\t}\n\treturn Run(workers, duration)\n}", "func tbRun(t testing.TB, name string, f func(testing.TB)) bool {\n\tt.Helper()\n\tswitch tb := t.(type) {\n\tcase *testing.B:\n\t\treturn tb.Run(name, func(b *testing.B) {\n\t\t\tb.Helper()\n\t\t\tf(b)\n\t\t})\n\tcase *testing.T:\n\t\treturn tb.Run(name, func(t *testing.T) {\n\t\t\tt.Helper()\n\t\t\tf(t)\n\t\t})\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"unexpected %T, want *testing.B or *testing.T\", tb))\n\t}\n}", "func Benchmark(fmtt string, args ...string) func() {\n\tstarted := time.Now()\n\treturn func() {\n\t\tTrace.Pipeline(fmt.Sprintf(fmtt, args) + \": \" + string(time.Since(started)))\n\t}\n}", "func Benchmark(log Log, path string, n, threads int) (float64, error) {\n\t// Open the log at the location\n\tif err := log.Open(path); err != nil {\n\t\treturn 0.0, err\n\t}\n\tdefer log.Close()\n\n\t// Create the action\n\taction := func() error {\n\t\treturn log.Append([]byte(\"foo\"))\n\t}\n\n\t// Create the parallel constructs\n\tgroup := new(sync.WaitGroup)\n\terrors := make([]error, threads)\n\n\t// Run the specified number of Go routines\n\tstart := time.Now()\n\tfor i := 0; i < threads; i++ {\n\t\tgroup.Add(1)\n\t\tgo func(idx int) {\n\t\t\terrors[idx] = benchmarker(n, action)\n\t\t\tgroup.Done()\n\t\t}(i)\n\t}\n\n\t// Wait for the group to complete\n\tgroup.Wait()\n\ttotalLatency := time.Since(start)\n\n\t// Check for errors\n\tfor _, err := range errors {\n\t\tif err != nil {\n\t\t\treturn 0.0, err\n\t\t}\n\t}\n\n\t// Compute the throughput\n\tthroughput := float64(n*threads) / totalLatency.Seconds()\n\treturn throughput, nil\n}", "func benchmark(rounds int) {\n\tfmt.Println(\"Benchmarking\")\n\tvar wg sync.WaitGroup\n\twg.Add(2)\n\n\tstatsCh := make(chan bool)\n\tgo initControllerPubTest(&wg, statsCh, rounds)\n\n\t//Testing:\n\t// Subscriber listening the stats published by the Gnfs\n\tgo initControllerStatsSubTest(&wg, statsCh)\n\twg.Wait()\n}", "func Run(workers []Worker, duration time.Duration) *Result {\n\tdebug = os.Getenv(\"DEBUG\") != \"\"\n\tc := len(workers)\n\tlog.Printf(\"starting benchmark: concurrency: %d, time: %s, GOMAXPROCS: %d\", c, duration, runtime.GOMAXPROCS(0))\n\tstartCh := make(chan bool, c)\n\treadyCh := make(chan bool, c)\n\tvar stopFlag int32\n\tscoreCh := make(chan int, c)\n\tvar wg sync.WaitGroup\n\n\t// spawn worker goroutines\n\tfor i, w := range workers {\n\t\tdebugLog(\"spwan worker[%d]\", i)\n\t\tgo func(n int, worker Worker) {\n\t\t\twg.Add(1)\n\t\t\tdefer wg.Done()\n\t\t\tscore := 0\n\t\t\tworker.Setup()\n\t\t\treadyCh <- true // ready of worker:n\n\t\t\t<-startCh // notified go benchmark from Runner\n\t\t\tdebugLog(\"worker[%d] starting Benchmark()\", n)\n\t\t\tfor atomic.LoadInt32(&stopFlag) == 0 {\n\t\t\t\tscore += worker.Process()\n\t\t\t}\n\t\t\tscoreCh <- score\n\t\t\tdebugLog(\"worker[%d] done Benchmark() score: %d\", n, score)\n\t\t\tworker.Teardown()\n\t\t\tdebugLog(\"worker[%d] exit\", n)\n\t\t}(i, w)\n\t}\n\n\t// wait for ready of workres\n\tdebugLog(\"waiting for all workers finish Setup()\")\n\tfor i := 0; i < c; i++ {\n\t\t<-readyCh\n\t}\n\n\t// notify \"start\" to workers\n\tclose(startCh)\n\tstart := time.Now()\n\n\t// wait for catching signal or timed out\n\tsignalCh := make(chan os.Signal, 1)\n\tsignal.Notify(signalCh, TrapSignals...)\n\tselect {\n\tcase s := <-signalCh:\n\t\tswitch sig := s.(type) {\n\t\tcase syscall.Signal:\n\t\t\tlog.Printf(\"Got signal: %s(%d)\", sig, sig)\n\t\tdefault:\n\t\t\tlog.Printf(\"interrupted %s\", s)\n\t\t\tbreak\n\t\t}\n\tcase <-time.After(duration):\n\t\tdebugLog(\"timed out\")\n\t\tbreak\n\t}\n\n\t// notify \"stop\" to workers\n\tatomic.StoreInt32(&stopFlag, 1)\n\n\t// collect scores from workers\n\ttotalScore := 0\n\tfor i := 0; i < c; i++ {\n\t\ttotalScore += <-scoreCh\n\t}\n\tend := time.Now()\n\telapsed := end.Sub(start)\n\tlog.Printf(\"done benchmark: score %d, elapsed %s = %f / sec\\n\", totalScore, elapsed, float64(totalScore)/float64(elapsed)*float64(time.Second))\n\n\twg.Wait()\n\treturn &Result{Score: totalScore, Elapsed: elapsed}\n}", "func Benchmark(config *ConfigData, verbose bool) {\n\tnRequests := 5\n\tconcurrency := 1\n\n\tclient := RequestClient{\n\t\tconfig.URL,\n\t\tconfig.Query,\n\t\tconfig.ParamString,\n\t\tconfig.SizeParam,\n\t\tverbose,\n\t}\n\n\tformatter := NewFormatter()\n\n\tch := make(chan time.Duration, concurrency)\n\n\tvaryingSizeRequest := func(size int) []float64 {\n\t\treturn processRun(nRequests, concurrency, ch, func() {\n\t\t\tsendBenchmarkedRequest(&client, config.Fields, size, ch)\n\t\t})\n\t}\n\n\tmin := 1\n\tmax := 15\n\tfor i := min; i <= max; i++ {\n\t\tresults := varyingSizeRequest(i)\n\t\tformatter.AddSizeResults(i, results)\n\n\t\tfmt.Printf(\"For size = %d, results in ms => %v\\n\", i, results)\n\t}\n\n\tformatter.FormatSizes()\n}", "func (mc *MultiCase) Benchmark(client *QueryClient) error {\n\tfor _, tcase := range mc.Cases {\n\t\tif err := tcase.Benchmark(client); err != nil {\n\t\t\tclient.Rollback()\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (b *Benchmark) Run() {\n\tfor _, l := range b.network.Layers {\n\t\tl.Randomize()\n\t}\n\n\tfor i := 0; i < 100; i++ {\n\t\tb.printLayerParams()\n\t\tb.trainer.Train()\n\t}\n}", "func benchmarkCallers(b *testing.B, stackDepth, maxStackDepth int) {\n\t// recurseNThenCallClosure sends to readyDoneSignal once when it's ready, then once more when it's done.\n\treadyDoneSignal := make(chan bool)\n\tgo recurseNThenCallClosure(stackDepth, func() {\n\t\tfor i := 0; i < b.N; i++ {\n\t\t\t// Take our stack trace.\n\t\t\tbuffer := make([]uintptr, maxStackDepth)\n\t\t\t_ = runtime.Callers(1, buffer)\n\t\t}\n\t}, readyDoneSignal)\n\t<-readyDoneSignal // ready\n\tb.ResetTimer()\n\t<-readyDoneSignal // done\n}", "func (c *Command) Run(args []string) {\n\tflag.StringVar(&c.Filter, \"f\", \"\", \"regexp to filter tests by name\")\n\tflag.BoolVar(&c.Verbose, \"v\", false, \"print all test names\")\n\tcheck(flag.CommandLine.Parse(args))\n\targs = flag.Args()\n\n\tif len(args) == 0 {\n\t\targs = []string{\".\"}\n\t}\n\n\tokPath, err := util.OKPath()\n\tcheck(err)\n\n\tfor _, arg := range args {\n\t\tpackageName := util.PackageNameFromPath(okPath, arg)\n\t\tif arg == \".\" {\n\t\t\tpackageName = \".\"\n\t\t}\n\t\tanonFunctionName := 0\n\t\tf, _, errs := compiler.Compile(okPath, packageName, true,\n\t\t\t&anonFunctionName, false)\n\t\tutil.CheckErrorsWithExit(errs)\n\n\t\tm := vm.NewVM(\"no-package\")\n\t\tstartTime := time.Now()\n\t\tcheck(m.LoadFile(f))\n\t\terr := m.RunTests(c.Verbose, regexp.MustCompile(c.Filter), packageName)\n\t\telapsed := time.Since(startTime).Milliseconds()\n\t\tcheck(err)\n\n\t\tassertWord := pluralise(\"assert\", m.TotalAssertions)\n\t\tif m.TestsFailed > 0 {\n\t\t\tfmt.Printf(\"%s: %d failed %d passed %d %s (%d ms)\\n\",\n\t\t\t\tpackageName, m.TestsFailed, m.TestsPass,\n\t\t\t\tm.TotalAssertions, assertWord, elapsed)\n\t\t} else {\n\t\t\tfmt.Printf(\"%s: %d passed %d %s (%d ms)\\n\",\n\t\t\t\tpackageName, m.TestsPass,\n\t\t\t\tm.TotalAssertions, assertWord, elapsed)\n\t\t}\n\n\t\tif m.TestsFailed > 0 {\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n}", "func trySuite(t *testing.T, f func(t *t), times int) {\n\ttee := newT(t)\n\tfor i := 0; i < times; i++ {\n\t\tf(tee)\n\t\tif !tee.failed {\n\t\t\treturn\n\t\t}\n\t\tif i != times-1 {\n\t\t\ttee.failed = false\n\t\t}\n\t\ttime.Sleep(200 * time.Millisecond)\n\t}\n\tif tee.failed {\n\t\tif len(tee.format) > 0 {\n\t\t\tt.Fatalf(tee.format, tee.values...)\n\t\t} else {\n\t\t\tt.Fatal(tee.values...)\n\t\t}\n\t}\n}", "func (s Suite) Run(t *testing.T) bool {\n\tt.Helper()\n\treturn s(\"\", nil, func(c *config) { c.t = t })\n}", "func (t TestCases) Run(fn func(string) (string, string), hideInput bool) {\n\tfor _, test := range t {\n\t\tpart1, part2 := fn(test.Input)\n\t\tpassedPart1 := part1 == test.ExpectedPart1 || test.ExpectedPart1 == \"\"\n\t\tpassedPart2 := part2 == test.ExpectedPart2 || test.ExpectedPart2 == \"\"\n\t\tpassed := passedPart1 && passedPart2\n\n\t\tif !passed && !hideInput {\n\t\t\tfmt.Println(\"Input \", test.Input)\n\t\t}\n\t\tif !passedPart1 {\n\t\t\tfmt.Println(\" - PART1: \", part1, \" but expected \", test.ExpectedPart1)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tif !passedPart2 {\n\t\t\tfmt.Println(\" - PART2: \", part2, \" but expected \", test.ExpectedPart2)\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n}", "func benchmarkCommand(b *testing.B, cmd string, args ...interface{}) {\n\ttestingSetUp()\n\tdefer testingTearDown()\n\tfor i := 0; i < b.N; i++ {\n\t\tconn := testPool.NewConn()\n\t\tif _, err := conn.Do(cmd, args...); err != nil {\n\t\t\t_ = conn.Close()\n\t\t\tb.Fatal(err)\n\t\t}\n\t\t_ = conn.Close()\n\t}\n}", "func BenchmarkSubFibonacci(b *testing.B) {\n\tvar tests = []struct {\n\t\tinput, result int\n\t}{\n\t\t{input: 2, result: 1},\n\t\t{input: 8, result: 21},\n\t\t{input: 10, result: 55},\n\t}\n\tfor _, test := range tests {\n\t\tb.Run(fmt.Sprintf(\"BFibonacci(%d)\", test.input), func(b *testing.B) {\n\t\t\tfor i := 0; i < b.N; i++ {\n\t\t\t\ttestingFunc(b, test.input, test.result)\n\t\t\t}\n\t\t})\n\t}\n}", "func Run(top *testing.T, name string, f TestFunc, accessories ...*Accessory) {\n\tif _, previouslyCalled := seen.LoadOrStore(fmt.Sprintf(\"%p\", top), nil); !previouslyCalled {\n\t\ttop.Parallel()\n\t}\n\ttop.Run(name, func(mid *testing.T) {\n\t\tmid.Parallel()\n\t\tctx, cancel := context.WithCancel(context.Background())\n\t\tbottom := testhelper.NewT(ctx, mid)\n\t\tcmd := newCiOperatorCommand(bottom)\n\t\ttestDone, cleanupDone := make(chan struct{}), make(chan struct{})\n\t\tdefer func() {\n\t\t\t// signal to the command that we no longer need to be waiting to\n\t\t\t// interrupt it; then wait for the cleanup routine to finish before\n\t\t\t// we consider the test done\n\t\t\tclose(testDone)\n\t\t\t<-cleanupDone\n\t\t}()\n\t\tcmd.testDone = testDone\n\t\tcmd.cleanupDone = cleanupDone\n\n\t\twg := sync.WaitGroup{}\n\t\twg.Add(len(accessories))\n\t\tfor _, accessory := range accessories {\n\t\t\t// binding the accessory to ctx ensures its lifetime is only\n\t\t\t// as long as the test we are running in this specific case\n\t\t\taccessory.RunFromFrameworkRunner(bottom, ctx, false)\n\t\t\tcmd.AddArgs(accessory.ClientFlags()...)\n\t\t\tgo func(a *Accessory) {\n\t\t\t\tdefer wg.Done()\n\t\t\t\ta.Ready(bottom)\n\t\t\t}(accessory)\n\t\t}\n\t\twg.Wait()\n\n\t\tgo func() {\n\t\t\tdefer func() { cancel() }() // stop waiting for errors\n\t\t\tf(bottom, &cmd)\n\t\t}()\n\n\t\tbottom.Wait()\n\t})\n}", "func BenchmarkWorknMulti(b *testing.B) {\n\tfoundValues, bob := randomNumMap(6)\n\ttype wrkr func(NumCol, *NumMap) SolLst\n\ttype wrkrTest struct {\n\t\tfc wrkr\n\t\tdesc string\n\t}\n\trunners := []wrkrTest{\n\t\t{workN, \"old\"},\n\t}\n\tfor _, runner := range runners {\n\t\trunFunc := func(tb *testing.B) {\n\t\t\tfor i := 0; i < tb.N; i++ {\n\t\t\t\ttb.StopTimer()\n\t\t\t\tfv := foundValues.Duplicate()\n\t\t\t\ttb.StartTimer()\n\t\t\t\trunner.fc(bob, fv)\n\t\t\t}\n\t\t}\n\t\trunString := runner.desc\n\t\tb.Run(runString, runFunc)\n\t}\n}", "func SubtestStress(t *testing.T, opt Options) {\n\ttmux.SubtestStress(t, opt)\n}", "func (b *Benchmark) Run(ctx context.Context) (*Result, error) {\n\targs := b.Args()\n\tcmd := testexec.CommandContext(ctx, args[0], args[1:]...)\n\toutput, err := cmd.Output(testexec.DumpLogOnError)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to run the benchmark binary: %s\", b.executable)\n\t}\n\n\tvar ret Result\n\tif err := json.Unmarshal(output, &ret); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to unmarshal output bytes to JSON-based Result\")\n\t}\n\treturn &ret, nil\n}", "func RunFailedAtLeast(dur time.Duration, f func() error) func() error {\n\treturn func() (err error) {\n\t\tbegin := time.Now()\n\t\terr = f()\n\t\tif d := time.Now().Sub(begin); err != nil && d <= dur {\n\t\t\ttime.Sleep(dur - d)\n\t\t}\n\t\treturn\n\t}\n}", "func (tc *TestCase) Benchmark(client *QueryClient) error {\n\t_, err := exec(client, tc.Query, tc.BindVars)\n\treturn err\n}", "func (s *SAM) Run(suffix string) bool {\n\tx := s.start\n\tfor _, c := range suffix {\n\t\tx = x.next[c]\n\t\tif x == nil {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn x.t\n}", "func RunSubtests(ctx *Context) {\n\tfor name, fn := range tests {\n\t\tctx.Run(name, fn)\n\t}\n}", "func runBench(dirPath, pattern string) (bstats map[string]*benchStats, err error) {\n\t// default pattern\n\tif pattern == \"\" {\n\t\tpattern = \".\"\n\t}\n\n\t// run benchmarks with tests\n\tout, err := runCmd(\"go\", dirPath, \"test\", \"-bench\", pattern, \"-benchmem\")\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// extract stats\n\tlines := benchStatsRE.FindAllString(out, -1)\n\tif len(lines) == 0 {\n\t\terr = errors.New(\"no benchmarks\")\n\t\treturn\n\t}\n\tbstats = make(map[string]*benchStats, len(lines))\n\n\tfor _, l := range lines {\n\t\tst := &benchStats{\n\t\t\tthroughput: -1,\n\t\t\tmem: -1,\n\t\t\tallocs: -1,\n\t\t}\n\n\t\t// benchmark name\n\t\tname := benchNameRE.FindString(l)\n\t\t// time\n\t\tif ms := benchTimeRE.FindStringSubmatch(l); ms != nil {\n\t\t\tst.time, err = strconv.ParseFloat(ms[1], 64)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tpanic(\"no time data\")\n\t\t}\n\n\t\t// optional throughput\n\t\tif ms := benchThroughputRE.FindStringSubmatch(l); ms != nil {\n\t\t\tst.throughput, err = strconv.ParseFloat(ms[1], 64)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\t// optional mem\n\t\tif ms := benchMemRE.FindStringSubmatch(l); ms != nil {\n\t\t\tst.mem, err = strconv.ParseInt(ms[1], 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tst.allocs, err = strconv.ParseInt(ms[2], 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tbstats[name] = st\n\t}\n\n\treturn bstats, nil\n}", "func (f Factory) RunStoreBenchmarks(b *testing.B) {\n\tb.Run(\"BenchmarkCreateLink\", f.BenchmarkCreateLink)\n\tb.Run(\"BenchmarkCreateLinkParallel\", f.BenchmarkCreateLinkParallel)\n\n\tb.Run(\"FindSegments100\", f.BenchmarkFindSegments100)\n\tb.Run(\"FindSegments1000\", f.BenchmarkFindSegments1000)\n\tb.Run(\"FindSegments10000\", f.BenchmarkFindSegments10000)\n\tb.Run(\"FindSegmentsMapID100\", f.BenchmarkFindSegmentsMapID100)\n\tb.Run(\"FindSegmentsMapID1000\", f.BenchmarkFindSegmentsMapID1000)\n\tb.Run(\"FindSegmentsMapID10000\", f.BenchmarkFindSegmentsMapID10000)\n\tb.Run(\"FindSegmentsMapIDs100\", f.BenchmarkFindSegmentsMapIDs100)\n\tb.Run(\"FindSegmentsMapIDs1000\", f.BenchmarkFindSegmentsMapIDs1000)\n\tb.Run(\"FindSegmentsMapIDs10000\", f.BenchmarkFindSegmentsMapIDs10000)\n\tb.Run(\"FindSegmentsPrevLinkHash100\", f.BenchmarkFindSegmentsPrevLinkHash100)\n\tb.Run(\"FindSegmentsPrevLinkHash1000\", f.BenchmarkFindSegmentsPrevLinkHash1000)\n\tb.Run(\"FindSegmentsPrevLinkHash10000\", f.BenchmarkFindSegmentsPrevLinkHash10000)\n\tb.Run(\"FindSegmentsTags100\", f.BenchmarkFindSegmentsTags100)\n\tb.Run(\"FindSegmentsTags1000\", f.BenchmarkFindSegmentsTags1000)\n\tb.Run(\"FindSegmentsTags10000\", f.BenchmarkFindSegmentsTags10000)\n\tb.Run(\"FindSegmentsMapIDTags100\", f.BenchmarkFindSegmentsMapIDTags100)\n\tb.Run(\"FindSegmentsMapIDTags1000\", f.BenchmarkFindSegmentsMapIDTags1000)\n\tb.Run(\"FindSegmentsMapIDTags10000\", f.BenchmarkFindSegmentsMapIDTags10000)\n\tb.Run(\"FindSegmentsPrevLinkHashTags100\", f.BenchmarkFindSegmentsPrevLinkHashTags100)\n\tb.Run(\"FindSegmentsPrevLinkHashTags1000\", f.BenchmarkFindSegmentsPrevLinkHashTags1000)\n\tb.Run(\"FindSegmentsPrevLinkHashTags10000\", f.BenchmarkFindSegmentsPrevLinkHashTags10000)\n\tb.Run(\"FindSegments100Parallel\", f.BenchmarkFindSegments100Parallel)\n\tb.Run(\"FindSegments1000Parallel\", f.BenchmarkFindSegments1000Parallel)\n\tb.Run(\"FindSegments10000Parallel\", f.BenchmarkFindSegments10000Parallel)\n\tb.Run(\"FindSegmentsMapID100Parallel\", f.BenchmarkFindSegmentsMapID100Parallel)\n\tb.Run(\"FindSegmentsMapID1000Parallel\", f.BenchmarkFindSegmentsMapID1000Parallel)\n\tb.Run(\"FindSegmentsMapID10000Parallel\", f.BenchmarkFindSegmentsMapID10000Parallel)\n\tb.Run(\"FindSegmentsMapIDs100Parallel\", f.BenchmarkFindSegmentsMapIDs100Parallel)\n\tb.Run(\"FindSegmentsMapIDs1000Parallel\", f.BenchmarkFindSegmentsMapIDs1000Parallel)\n\tb.Run(\"FindSegmentsMapIDs10000Parallel\", f.BenchmarkFindSegmentsMapIDs10000Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHash100Parallel\", f.BenchmarkFindSegmentsPrevLinkHash100Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHash1000Parallel\", f.BenchmarkFindSegmentsPrevLinkHash1000Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHash10000ParalleRunBenchmarksl\", f.BenchmarkFindSegmentsPrevLinkHash10000Parallel)\n\tb.Run(\"FindSegmentsTags100Parallel\", f.BenchmarkFindSegmentsTags100Parallel)\n\tb.Run(\"FindSegmentsTags1000Parallel\", f.BenchmarkFindSegmentsTags1000Parallel)\n\tb.Run(\"FindSegmentsTags10000Parallel\", f.BenchmarkFindSegmentsTags10000Parallel)\n\tb.Run(\"FindSegmentsMapIDTags100Parallel\", f.BenchmarkFindSegmentsMapIDTags100Parallel)\n\tb.Run(\"FindSegmentsMapIDTags1000Parallel\", f.BenchmarkFindSegmentsMapIDTags1000Parallel)\n\tb.Run(\"FindSegmentsMapIDTags10000Parallel\", f.BenchmarkFindSegmentsMapIDTags10000Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHashTags100Parallel\", f.BenchmarkFindSegmentsPrevLinkHashTags100Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHashTags1000Parallel\", f.BenchmarkFindSegmentsPrevLinkHashTags1000Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHashTags10000Parallel\", f.BenchmarkFindSegmentsPrevLinkHashTags10000Parallel)\n\n\tb.Run(\"GetMapIDs100\", f.BenchmarkGetMapIDs100)\n\tb.Run(\"GetMapIDs1000\", f.BenchmarkGetMapIDs1000)\n\tb.Run(\"GetMapIDs10000\", f.BenchmarkGetMapIDs10000)\n\tb.Run(\"GetMapIDs100Parallel\", f.BenchmarkGetMapIDs100Parallel)\n\tb.Run(\"GetMapIDs1000Parallel\", f.BenchmarkGetMapIDs1000Parallel)\n\tb.Run(\"GetMapIDs10000Parallel\", f.BenchmarkGetMapIDs10000Parallel)\n\n\tb.Run(\"GetSegment\", f.BenchmarkGetSegment)\n\tb.Run(\"GetSegmentParallel\", f.BenchmarkGetSegmentParallel)\n}", "func RunTest(ctx context.Context, target, location string, nodeIDs []int, limit int, debug, outputJSON bool, runTest runFunc, runOutput runOutputFunc) error {\n\trunReq := &perfops.RunRequest{\n\t\tTarget: target,\n\t\tLocation: location,\n\t\tNodes: nodeIDs,\n\t\tLimit: limit,\n\t}\n\n\tf := NewFormatter(debug && !outputJSON)\n\tf.StartSpinner()\n\ttestID, err := runTest(ctx, runReq)\n\tf.StopSpinner()\n\tif err != nil {\n\t\treturn err\n\t}\n\tres := &RunOutputResult{}\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-time.After(200 * time.Millisecond):\n\t\t\t}\n\t\t\toutput, err := runOutput(ctx, testID)\n\t\t\tres.SetOutput(output, err)\n\t\t\tif err != nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}()\n\n\tif outputJSON {\n\t\tf.StartSpinner()\n\t}\n\tvar o *perfops.RunOutput\n\tfor {\n\t\tselect {\n\t\tcase <-time.After(50 * time.Millisecond):\n\t\t}\n\t\tif o, err = res.Output(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !outputJSON && o != nil {\n\t\t\tPrintOutput(f, o)\n\t\t}\n\t\tif o != nil && o.IsFinished() {\n\t\t\tbreak\n\t\t}\n\t}\n\tif outputJSON {\n\t\tf.StopSpinner()\n\t\tPrintOutputJSON(o)\n\t}\n\treturn nil\n}", "func (b *Benchmark) Run() {\n\tb.init()\n\n\tb.trainer.Train()\n}", "func (t TestCases) Run2(fn func(string) (string, string), tc *testing.T, hideInput bool) {\n\tfor _, test := range t {\n\t\ttc.Run(test.Input, func(t *testing.T) {\n\t\t\tpart1, part2 := fn(test.Input)\n\t\t\tpassedPart1 := part1 == test.ExpectedPart1 || test.ExpectedPart1 == \"\"\n\t\t\tpassedPart2 := part2 == test.ExpectedPart2 || test.ExpectedPart2 == \"\"\n\n\t\t\tif !passedPart1 {\n\t\t\t\tt.Errorf(\"PART1: %q but expected %q\", part1, test.ExpectedPart1)\n\t\t\t}\n\t\t\tif !passedPart2 {\n\t\t\t\tt.Errorf(\"PART2: %q but expected %q\", part2, test.ExpectedPart2)\n\t\t\t}\n\t\t})\n\t}\n}", "func (ts ApisValidatableTestSuite) Run(t *testing.T) {\n\tt.Parallel()\n\tfor k, v := range ts {\n\t\tt.Run(k, v.Run)\n\t}\n}", "func Wrap(t *testing.T, name string, f func(t *T)) bool {\n\ttracker := &tracker{}\n\tsuccess := true\n\tfor tracker.Next() {\n\t\tif tracker.Active() {\n\t\t\ts := t.Run(name, func(t *testing.T) {\n\t\t\t\tf(&T{t, t, tracker.SubTracker()})\n\t\t\t})\n\t\t\tsuccess = success && s\n\t\t}\n\t}\n\treturn success\n}", "func BenchmarkisNotABenchmark(b *testing.B) {\n\tpanic(\"This is not a valid benchmark function.\")\n}", "func TestSubFibonacci(t *testing.T) {\n\tvar tests = []struct {\n\t\tinput, result int\n\t}{\n\t\t{input: 2, result: 1},\n\t\t{input: 8, result: 21},\n\t\t{input: 10, result: 55},\n\t}\n\tfor _, test := range tests {\n\t\tt.Run(fmt.Sprintf(\"Fibonacci(%d)\", test.input), func(t *testing.T) {\n\t\t\ttestingFunc(t, test.input, test.result)\n\t\t})\n\t}\n}", "func (tq TestQuery) Benchmark(client *QueryClient) error {\n\t_, err := exec(client, string(tq), nil)\n\treturn err\n}", "func runIndexTests(t *testing.T, f func(s, sep []rune) int, funcName string, testCases []indexTest) {\n\tfor _, test := range testCases {\n\t\tactual := f(test.s, test.sep)\n\t\tif actual != test.out {\n\t\t\tt.Errorf(\"%s(%q,%q) = %v; want %v\", funcName, test.s, test.sep, actual, test.out)\n\t\t}\n\t}\n}", "func (t *T) Run(name string, fn func(t *T)) {\n\tt.T.Run(name, func(tt *testing.T) {\n\t\ttt.Helper()\n\t\tt := *t\n\t\tt.T = tt\n\t\tu := *t.URL\n\t\tt.URL = &u\n\n\t\tfn(&t)\n\t})\n}", "func Run(t tt, h http.Handler, tcs ...TestCase) {\n\tfor _, tc := range tcs {\n\t\tf := func(t tt) {\n\t\t\trec := httptest.NewRecorder()\n\t\t\treq := httpRequest(&tc.Request)\n\t\t\th.ServeHTTP(rec, req)\n\t\t\tassertResponse(t, rec, &tc.Response)\n\t\t}\n\n\t\tif tc.Name != \"\" {\n\t\t\tt.Run(tc.Name, func(t *testing.T) {\n\t\t\t\tf(t)\n\t\t\t})\n\t\t} else {\n\t\t\tf(t)\n\t\t}\n\t}\n}", "func (api *PrivateLightServerAPI) Benchmark(setups []map[string]interface{}, passCount, length int) ([]map[string]interface{}, error) {\n\tbenchmarks := make([]requestBenchmark, len(setups))\n\tfor i, setup := range setups {\n\t\tif t, ok := setup[\"type\"].(string); ok {\n\t\t\tgetInt := func(field string, def int) int {\n\t\t\t\tif value, ok := setup[field].(float64); ok {\n\t\t\t\t\treturn int(value)\n\t\t\t\t}\n\t\t\t\treturn def\n\t\t\t}\n\t\t\tgetBool := func(field string, def bool) bool {\n\t\t\t\tif value, ok := setup[field].(bool); ok {\n\t\t\t\t\treturn value\n\t\t\t\t}\n\t\t\t\treturn def\n\t\t\t}\n\t\t\tswitch t {\n\t\t\tcase \"header\":\n\t\t\t\tbenchmarks[i] = &benchmarkBlockHeaders{\n\t\t\t\t\tamount: getInt(\"amount\", 1),\n\t\t\t\t\tskip: getInt(\"skip\", 1),\n\t\t\t\t\tbyHash: getBool(\"byHash\", false),\n\t\t\t\t\treverse: getBool(\"reverse\", false),\n\t\t\t\t}\n\t\t\tcase \"body\":\n\t\t\t\tbenchmarks[i] = &benchmarkBodiesOrReceipts{receipts: false}\n\t\t\tcase \"receipts\":\n\t\t\t\tbenchmarks[i] = &benchmarkBodiesOrReceipts{receipts: true}\n\t\t\tcase \"proof\":\n\t\t\t\tbenchmarks[i] = &benchmarkProofsOrCode{code: false}\n\t\t\tcase \"code\":\n\t\t\t\tbenchmarks[i] = &benchmarkProofsOrCode{code: true}\n\t\t\tcase \"cht\":\n\t\t\t\tbenchmarks[i] = &benchmarkHelperTrie{\n\t\t\t\t\tbloom: false,\n\t\t\t\t\treqCount: getInt(\"amount\", 1),\n\t\t\t\t}\n\t\t\tcase \"bloom\":\n\t\t\t\tbenchmarks[i] = &benchmarkHelperTrie{\n\t\t\t\t\tbloom: true,\n\t\t\t\t\treqCount: getInt(\"amount\", 1),\n\t\t\t\t}\n\t\t\tcase \"txSend\":\n\t\t\t\tbenchmarks[i] = &benchmarkTxSend{}\n\t\t\tcase \"txStatus\":\n\t\t\t\tbenchmarks[i] = &benchmarkTxStatus{}\n\t\t\tdefault:\n\t\t\t\treturn nil, ErrUnknownBenchmarkType\n\t\t\t}\n\t\t} else {\n\t\t\treturn nil, ErrUnknownBenchmarkType\n\t\t}\n\t}\n\trs := api.server.protocolManager.runBenchmark(benchmarks, passCount, time.Millisecond*time.Duration(length))\n\tresult := make([]map[string]interface{}, len(setups))\n\tfor i, r := range rs {\n\t\tres := make(map[string]interface{})\n\t\tif r.err == nil {\n\t\t\tres[\"totalCount\"] = r.totalCount\n\t\t\tres[\"avgTime\"] = r.avgTime\n\t\t\tres[\"maxInSize\"] = r.maxInSize\n\t\t\tres[\"maxOutSize\"] = r.maxOutSize\n\t\t} else {\n\t\t\tres[\"error\"] = r.err.Error()\n\t\t}\n\t\tresult[i] = res\n\t}\n\treturn result, nil\n}", "func PerfTool(ctx context.Context, s *testing.State) {\n\tdbgd, err := debugd.New(ctx)\n\tif err != nil {\n\t\ts.Fatal(\"Failed to connect to debugd D-Bus service: \", err)\n\t}\n\n\trep := s.Param().(testCase).repetition\n\tif rep > 1 {\n\t\t// Stress tests run for the single call only.\n\t\tfor i := 0; i < rep; i++ {\n\t\t\ttestSingleCall(ctx, s, dbgd)\n\t\t}\n\t} else {\n\t\ttestSingleCall(ctx, s, dbgd)\n\t\ttestConsecutiveCalls(ctx, s, dbgd)\n\t\ttestConcurrentCalls(ctx, s, dbgd)\n\t\ttestStopEarly(ctx, s, dbgd)\n\t\ttestSurviveUICrash(ctx, s, dbgd)\n\t\ttestRestoreCPUIdle(ctx, s, dbgd)\n\t}\n}", "func run(t *testing.T, formatter Formatter, suites ...TCatcher) {\n\tvar (\n\t\tbeforeAllFound, afterAllFound bool\n\t\tbeforeAll, afterAll, before, after reflect.Value\n\t\ttotalPassed, totalFailed, totalPending, totalNoAssertions int\n\t)\n\n\tflag.Parse()\n\n\tfor _, s := range suites {\n\t\tbeforeAll, afterAll, before, after = reflect.Value{}, reflect.Value{}, reflect.Value{}, reflect.Value{}\n\t\ts.SetT(t)\n\t\ts.Reset()\n\n\t\tiType := reflect.TypeOf(s)\n\n\t\tformatter.PrintSuiteName(strings.Split(iType.String(), \".\")[1])\n\n\t\t// search for Before and After methods\n\t\tfor i := 0; i < iType.NumMethod(); i++ {\n\t\t\tmethod := iType.Method(i)\n\t\t\tif ok, _ := regexp.MatchString(\"^BeforeAll\", method.Name); ok {\n\t\t\t\tif !beforeAllFound {\n\t\t\t\t\tbeforeAll = method.Func\n\t\t\t\t\tbeforeAllFound = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ok, _ := regexp.MatchString(\"^AfterAll\", method.Name); ok {\n\t\t\t\tif !afterAllFound {\n\t\t\t\t\tafterAll = method.Func\n\t\t\t\t\tafterAllFound = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ok, _ := regexp.MatchString(\"^Before\", method.Name); ok {\n\t\t\t\tbefore = method.Func\n\t\t\t}\n\t\t\tif ok, _ := regexp.MatchString(\"^After\", method.Name); ok {\n\t\t\t\tafter = method.Func\n\t\t\t}\n\t\t}\n\n\t\tif beforeAll.IsValid() {\n\t\t\tbeforeAll.Call([]reflect.Value{reflect.ValueOf(s)})\n\t\t}\n\n\t\tfor i := 0; i < iType.NumMethod(); i++ {\n\t\t\tmethod := iType.Method(i)\n\t\t\tif ok, _ := regexp.MatchString(*testToRun, method.Name); ok {\n\t\t\t\tif ok, _ := regexp.MatchString(formatter.AllowedMethodsPattern(), method.Name); ok {\n\n\t\t\t\t\ts.SetStatus(&Status{Code: STATUS_NO_ASSERTIONS})\n\n\t\t\t\t\tif before.IsValid() {\n\t\t\t\t\t\tbefore.Call([]reflect.Value{reflect.ValueOf(s)})\n\t\t\t\t\t}\n\n\t\t\t\t\tmethod.Func.Call([]reflect.Value{reflect.ValueOf(s)})\n\n\t\t\t\t\tif after.IsValid() {\n\t\t\t\t\t\tafter.Call([]reflect.Value{reflect.ValueOf(s)})\n\t\t\t\t\t}\n\n\t\t\t\t\tvar info *suiteInfo\n\t\t\t\t\tstatus := s.GetStatus()\n\n\t\t\t\t\tswitch status.Code {\n\t\t\t\t\tcase STATUS_PASS:\n\t\t\t\t\t\tinfo = s.GetInfo()\n\t\t\t\t\t\ttotalPassed++\n\t\t\t\t\tcase STATUS_FAIL:\n\t\t\t\t\t\tinfo = s.GetInfo()\n\t\t\t\t\t\tt.Error(status.ErrorMessage)\n\t\t\t\t\t\ttotalFailed++\n\t\t\t\t\tcase STATUS_PENDING:\n\t\t\t\t\t\tinfo = s.GetInfo()\n\t\t\t\t\t\tinfo.assertions = 0\n\t\t\t\t\t\ttotalPending++\n\t\t\t\t\tcase STATUS_NO_ASSERTIONS:\n\t\t\t\t\t\tinfo = &suiteInfo{0, method.Name}\n\t\t\t\t\t\ttotalNoAssertions++\n\t\t\t\t\t}\n\t\t\t\t\tformatter.PrintStatus(status, info)\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif afterAll.IsValid() {\n\t\t\tafterAll.Call([]reflect.Value{reflect.ValueOf(s)})\n\t\t}\n\t}\n\n\tformatter.PrintFinalReport(totalPassed, totalFailed, totalPending, totalNoAssertions)\n}", "func (suite FeatureTestSuite) Run(t *testing.T, buildFunc feature.BuildFunc) {\n\tfor _, test := range suite {\n\t\trunTest(t, test, buildFunc)\n\t}\n}", "func (t *TestRun) Failf(format string, a ...interface{}) {\n\tt.Fail(fmt.Sprintf(format, a...))\n}", "func Main(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) {}", "func BenchmarkVersion(b *testing.B) {\n\tb.Run(\"gintest\", func(b *testing.B) {\n\t\t// for i := 0; i < b.N; i++ {\n\t\t// \tsend(b, \"http://127.0.0.1:11000/microgin/version\", \"\")\n\t\t// }\n\n\t\t// 并发测试\n\t\tb.RunParallel(func(pb *testing.PB) {\n\t\t\tfor pb.Next() {\n\t\t\t\tsend(b, \"http://127.0.0.1:11000/microgin/version\", \"\")\n\t\t\t}\n\t\t})\n\t})\n\n\tb.Run(\"beegotest\", func(b *testing.B) {\n\t\t// for i := 0; i < b.N; i++ {\n\t\t// \tsend(b, \"http://127.0.0.1:11001/beegotest\", \"\")\n\t\t// }\n\n\t\t// 并发测试\n\t\tb.RunParallel(func(pb *testing.PB) {\n\t\t\tfor pb.Next() {\n\t\t\t\tsend(b, \"http://127.0.0.1:11001/beegotest\", \"\")\n\t\t\t}\n\t\t})\n\t})\n\n\tb.Run(\"microgin\", func(b *testing.B) {\n\t\t// for i := 0; i < b.N; i++ {\n\t\t// \tsend(b, server+\"/microgin/version\", \"\")\n\t\t// }\n\n\t\t// 并发测试\n\t\tb.RunParallel(func(pb *testing.PB) {\n\t\t\tfor pb.Next() {\n\t\t\t\tsend(b, server+\"/microgin/version\", \"\")\n\t\t\t}\n\t\t})\n\t})\n}", "func (s *suite) runChild(c *suite, reporter Reporter) error {\n\tchildRan := false\n\ts.ctx.onChild = func(child *suite) {\n\t\tif child.equals(c) {\n\t\t\tchild.Run(reporter)\n\t\t\tchildRan = true\n\t\t}\n\t}\n\tdefer func() { s.ctx.onChild = nil }()\n\ts.run(reporter)\n\n\tif !childRan {\n\t\treturn fmt.Errorf(\"Found no child named '%s'\", c.Name)\n\t}\n\treturn nil\n}", "func (runner *suiteRunner) run() *Result {\n if runner.tracker.result.RunError == nil && len(runner.tests) > 0 {\n runner.tracker.start()\n if runner.checkFixtureArgs() {\n if runner.runFixture(runner.setUpSuite) {\n for i := 0; i != len(runner.tests); i++ {\n c := runner.runTest(runner.tests[i])\n if c.status == fixturePanickedSt {\n runner.missTests(runner.tests[i+1:])\n break\n }\n }\n } else {\n runner.missTests(runner.tests)\n }\n runner.runFixture(runner.tearDownSuite)\n } else {\n runner.missTests(runner.tests)\n }\n runner.tracker.waitAndStop()\n runner.tempDir.removeAll()\n }\n return &runner.tracker.result\n}", "func TestHelloSubTest(t *testing.T) {\n\t// 前処理etc\n\n\tt.Run(\"Hoge\", func(t *testing.T) {\n\t\ts := Hello(\"Hoge\")\n\t\twant := \"Hello, Hoge!\"\n\t\tif s != want {\n\t\t\tt.Fatalf(`Hello(\"Hoge\") = %s\"; want \"%s\"`, s, want)\n\t\t}\n\t})\n\tt.Run(\"Moke\", func(t *testing.T) {\n\t\t// さらにネストできる\n\t\tt.Run(\"Fuga\", func(t *testing.T) {\n\t\t\ts := Hello(\"Fuga\")\n\t\t\twant := \"Hello, Fuga!\"\n\t\t\tif s != want {\n\t\t\t\tt.Fatalf(`Hello(\"Fuga\") = %s\"; want \"%s\"`, s, want)\n\t\t\t}\n\t\t})\n\t})\n\n\t// 後処理etc\n}", "func RunBenchmarks(b *testing.B, coll *docstore.Collection) {\n\tdefer coll.Close()\n\tclearCollection(b, coll)\n\tb.Run(\"BenchmarkSingleActionPut\", func(b *testing.B) {\n\t\tbenchmarkSingleActionPut(10, b, coll)\n\t})\n\tb.Run(\"BenchmarkSingleActionGet\", func(b *testing.B) {\n\t\tbenchmarkSingleActionGet(10, b, coll)\n\t})\n\tb.Run(\"BenchmarkActionListPut\", func(b *testing.B) {\n\t\tbenchmarkActionListPut(50, b, coll)\n\t})\n\tb.Run(\"BenchmarkActionListGet\", func(b *testing.B) {\n\t\tbenchmarkActionListGet(100, b, coll)\n\t})\n\tclearCollection(b, coll)\n}", "func testRun(t *testing.T, nfail, nnode, nclients, nthreads, naccesses int) {\n\n\tdesc := fmt.Sprintf(\"F=%v,N=%v,Clients=%v,Threads=%v,Accesses=%v\",\n\t\tnfail, nnode, nclients, nthreads, naccesses)\n\tt.Run(desc, func(t *testing.T) {\n\n\t\t// Create a cancelable context for the test run\n\t\tctx, cancel := context.WithCancel(context.Background())\n\n\t\t// Create an in-memory CAS register representing each node\n\t\tmembers := make([]cas.Store, nnode)\n\t\tmemhist := make([]test.History, nnode)\n\t\tfor i := range members {\n\t\t\tmembers[i] = &cas.Register{}\n\t\t}\n\n\t\t// Create a consensus group Store for each simulated client\n\t\tclients := make([]cas.Store, nclients)\n\t\tfor i := range clients {\n\n\t\t\t// Interpose checking wrappers on the CAS registers\n\t\t\tcheckers := make([]cas.Store, nnode)\n\t\t\tfor i := range checkers {\n\t\t\t\tcheckers[i] = test.Checked(t, &memhist[i],\n\t\t\t\t\tmembers[i])\n\t\t\t}\n\n\t\t\tclients[i] = (&Group{}).Start(ctx, checkers, nfail)\n\t\t}\n\n\t\t// Run a standard torture-test across all the clients\n\t\ttest.Stores(t, nthreads, naccesses, clients...)\n\n\t\t// Shut down all the clients by canceling the context\n\t\tcancel()\n\t})\n}", "func Benchmark_5_0_1kB(b *testing.B) { benchmarkNoFaults(6, 1024, b) }", "func Main(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample)", "func BenchmarkSimpleChecking(b *testing.B) {\n\tcapacity := uint32(1e9)\n\tp := float64(0.001)\n\tsamples := uint32(100000)\n\tfilter, testValues := GenerateExampleFilter(capacity, p, samples)\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tvalue := testValues[rand.Int()%len(testValues)]\n\t\tif !filter.Check(value) {\n\t\t\tb.Error(\"Did not find test value in filter!\")\n\t\t}\n\t}\n}", "func TestAssessRunStatusWithMixedMetrics(t *testing.T) {\n\tf := newFixture(t)\n\tdefer f.Close()\n\tc, _, _ := f.newController(noResyncPeriodFunc)\n\n\trun := v1alpha1.AnalysisRun{\n\t\tSpec: v1alpha1.AnalysisRunSpec{\n\t\t\tMetrics: []v1alpha1.Metric{\n\t\t\t\t{\n\t\t\t\t\tName: \"run-forever\",\n\t\t\t\t\tProvider: v1alpha1.MetricProvider{\n\t\t\t\t\t\tJob: &v1alpha1.JobMetric{},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tName: \"success-metric\",\n\t\t\t\t\tProvider: v1alpha1.MetricProvider{\n\t\t\t\t\t\tJob: &v1alpha1.JobMetric{},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tDryRun: []v1alpha1.DryRun{{\n\t\t\t\tMetricName: \"success-metric\",\n\t\t\t}},\n\t\t},\n\t\tStatus: v1alpha1.AnalysisRunStatus{\n\t\t\tMetricResults: []v1alpha1.MetricResult{\n\t\t\t\t{\n\t\t\t\t\tName: \"run-forever\",\n\t\t\t\t\tInconclusive: 1,\n\t\t\t\t\tDryRun: false,\n\t\t\t\t\tPhase: v1alpha1.AnalysisPhaseRunning,\n\t\t\t\t\tMeasurements: []v1alpha1.Measurement{{\n\t\t\t\t\t\tPhase: v1alpha1.AnalysisPhaseRunning,\n\t\t\t\t\t\tStartedAt: timePtr(metav1.NewTime(time.Now().Add(-60 * time.Second))),\n\t\t\t\t\t}},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tName: \"success-metric\",\n\t\t\t\t\tCount: 1,\n\t\t\t\t\tFailed: 1,\n\t\t\t\t\tDryRun: true,\n\t\t\t\t\tPhase: v1alpha1.AnalysisPhaseSuccessful,\n\t\t\t\t\tMeasurements: []v1alpha1.Measurement{{\n\t\t\t\t\t\tPhase: v1alpha1.AnalysisPhaseFailed,\n\t\t\t\t\t\tStartedAt: timePtr(metav1.NewTime(time.Now().Add(-60 * time.Second))),\n\t\t\t\t\t\tFinishedAt: timePtr(metav1.NewTime(time.Now().Add(-60 * time.Second))),\n\t\t\t\t\t}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tf.provider.On(\"Run\", mock.Anything, mock.Anything, mock.Anything).Return(newMeasurement(v1alpha1.AnalysisPhaseFailed), nil)\n\tf.provider.On(\"Resume\", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(newMeasurement(v1alpha1.AnalysisPhaseSuccessful), nil)\n\n\tnewRun := c.reconcileAnalysisRun(&run)\n\tassert.Equal(t, v1alpha1.AnalysisPhaseInconclusive, newRun.Status.Phase)\n\tassert.Equal(t, \"Metric \\\"run-forever\\\" assessed Inconclusive due to inconclusive (1) > inconclusiveLimit (0)\", newRun.Status.Message)\n}", "func Run(ctx context.Context, tconn *chrome.TestConn, f func(ctx context.Context) error, names ...string) ([]*Histogram, error) {\n\tr, err := StartRecorder(ctx, tconn, names...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := f(ctx); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn r.Histogram(ctx, tconn)\n}", "func writeBenchmarkResult(method *methodType, c *chk.C, tm timer) {\n\t_, _, testCode := instrumentation.GetPackageAndNameAndBoundaries(method.Info.Func.Pointer())\n\n\tt := method.Info.Type.In(0)\n\tif t.Kind() == reflect.Ptr {\n\t\tt = t.Elem()\n\t}\n\tpName := t.Name()\n\n\ttestTags := opentracing.Tags{\n\t\t\"span.kind\": \"test\",\n\t\t\"test.name\": method.Info.Name,\n\t\t\"test.suite\": pName,\n\t\t\"test.framework\": \"gopkg.in/check.v1\",\n\t\t\"test.language\": \"go\",\n\t\t\"test.type\": \"benchmark\",\n\t}\n\topts := []opentracing.StartSpanOption{\n\t\ttestTags,\n\t\topentracing.StartTime(tm.start),\n\t}\n\n\tif testCode != \"\" {\n\t\ttestTags[\"test.code\"] = testCode\n\t}\n\n\tspan, _ := opentracing.StartSpanFromContextWithTracer(context.Background(), instrumentation.Tracer(), method.Info.Name, opts...)\n\tspan.SetBaggageItem(\"trace.kind\", \"test\")\n\tavg := math.Round((float64(tm.duration.Nanoseconds())/float64(c.N))*100) / 100\n\tmeanAllocsPerOp := math.Round((float64(tm.netAllocs)/float64(c.N))*100) / 100\n\tmeanAllocedBytesPerOp := math.Round((float64(tm.netBytes)/float64(c.N))*100) / 100\n\n\tspan.SetTag(\"benchmark.runs\", c.N)\n\tspan.SetTag(\"benchmark.duration.mean\", avg)\n\tspan.SetTag(\"benchmark.memory.mean_allocations\", meanAllocsPerOp)\n\tspan.SetTag(\"benchmark.memory.mean_bytes_allocations\", meanAllocedBytesPerOp)\n\n\treason := getTestReason(c)\n\tstatus := getTestStatus(c)\n\tswitch status {\n\tcase testSucceeded:\n\t\tif !getTestMustFail(c) {\n\t\t\tspan.SetTag(\"test.status\", tags.TestStatus_PASS)\n\t\t\treason = \"\"\n\t\t} else {\n\t\t\tspan.SetTag(\"test.status\", tags.TestStatus_FAIL)\n\t\t\tspan.SetTag(\"error\", true)\n\t\t}\n\tcase testFailed:\n\t\tif getTestMustFail(c) {\n\t\t\tspan.SetTag(\"test.status\", tags.TestStatus_PASS)\n\t\t\treason = \"\"\n\t\t} else {\n\t\t\tspan.SetTag(\"test.status\", tags.TestStatus_FAIL)\n\t\t\tspan.SetTag(\"error\", true)\n\t\t\tif reason == \"\" {\n\t\t\t\treason = \"Test failed\"\n\t\t\t}\n\t\t}\n\tcase testSkipped:\n\t\tspan.SetTag(\"test.status\", tags.TestStatus_SKIP)\n\tcase testPanicked, testFixturePanicked:\n\t\tspan.SetTag(\"test.status\", tags.TestStatus_FAIL)\n\t\tspan.SetTag(\"error\", true)\n\tcase testMissed:\n\t\tspan.SetTag(\"test.status\", tags.TestStatus_SKIP)\n\tdefault:\n\t\tspan.SetTag(\"test.status\", status)\n\t\tspan.SetTag(\"error\", true)\n\t}\n\n\tif reason != \"\" {\n\t\teventType := tags.EventTestFailure\n\t\tif status == testSkipped {\n\t\t\teventType = tags.EventTestSkip\n\t\t}\n\t\tspan.LogFields(\n\t\t\tlog.String(tags.EventType, eventType),\n\t\t\tlog.String(tags.EventMessage, reason),\n\t\t\tlog.String(\"log.internal_level\", \"Fatal\"),\n\t\t\tlog.String(\"log.logger\", \"testing\"),\n\t\t)\n\t}\n\n\tspan.FinishWithOptions(opentracing.FinishOptions{\n\t\tFinishTime: tm.start.Add(tm.duration),\n\t})\n}", "func Run(bTestMode bool) {\n\tvar wg = &sync.WaitGroup{}\n\twg.Add(1)\n\tif bTestMode {\n\t\tgo func(WG *sync.WaitGroup) {\n\t\t\tdefer wg.Done()\n\t\t\tWorker()\n\t\t}(wg)\n\t} else {\n\t\tccutility.WorkerTimer(2, 4, func() {\n\t\t\tWorker()\n\t\t})\n\t}\n\twg.Wait()\n}", "func BenchmarkCoreSimple(b *testing.B) {\n\tfor i := 0; i < b.N; i++ {\n\t\tDoTheThing()\n\t}\n}", "func (b *Benchmark) Run() {\n\tfor _, gpu := range b.gpus {\n\t\tb.driver.SelectGPU(b.context, gpu)\n\t\tb.queues = append(b.queues, b.driver.CreateCommandQueue(b.context))\n\t}\n\n\tif b.NumIterations == 0 || b.NumIterations > b.NumNodes {\n\t\tb.NumIterations = b.NumNodes\n\t}\n\n\tb.initMem()\n\tb.exec()\n}", "func (runner *CpuTestRunner) run(cmd string, args ...string) ([]byte, error) {\n\trunner.executions++\n\n\tif runner.executions%2 == 0 {\n\t\treturn []byte(runner.stat2), runner.err1\n\t} else {\n\t\treturn []byte(runner.stat1), runner.err2\n\t}\n\n}", "func Run(config *Settings) {\n\tfileNames, err := config.reader.ReadExecutables()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tvar resMutex = &sync.Mutex{}\n\tres := make([]*google.TestResult, 0)\n\n\tvar tasksWg sync.WaitGroup\n\ttasksWg.Add(len(fileNames))\n\tworkerQueueLimit := make(chan bool, config.workersCount) \n\n\tfor _, line := range fileNames {\n\t\tworkerQueueLimit <- true // try get access to work\n\t\tgo func(file string) {\n\t\t\tdefer tasksWg.Done()\n\t\t\tdefer func() { <-workerQueueLimit }() // decrease working queue\n\n\t\t\tconfig.formatter.ShowSuiteStart(file)\n\n\t\t\tgr, output, err := runGoogleTest(file, config.workingDir)\n\t\t\tif err != nil {\n\t\t\t\tconfig.formatter.ShowSuiteFailure(file, output, err)\n\t\t\t} else {\n\t\t\t\tresMutex.Lock()\n\t\t\t\tdefer resMutex.Unlock()\n\t\t\t\tres = append(res, gr)\n\t\t\t\tconfig.formatter.ShowTests(gr, output)\n\t\t\t}\n\t\t}(line)\n\t}\n\n\ttasksWg.Wait()\n\n\tconfig.formatter.ShowStatistics(res)\n}", "func (o SysbenchSpecOutput) TestName() pulumi.StringOutput {\n\treturn o.ApplyT(func(v SysbenchSpec) string { return v.TestName }).(pulumi.StringOutput)\n}", "func TestSub(t *testing.T) {\n\tfmt.Println(Sub(2,1))\n}", "func BenchmarkInvoke(b *testing.B) {\n\ttests := []struct {\n\t\tName string\n\t\tFn any\n\t\tOpt *MainInput\n\t\tArgs []any\n\t\tExpected any\n\t}{\n\t\t{\n\t\t\tName: \"Void function\",\n\t\t\tFn: func() {},\n\t\t},\n\t\t{\n\t\t\tName: \"Contexts and errors are allowed and handled\",\n\t\t\tFn: func(ctx context.Context) error { return nil },\n\t\t},\n\t\t{\n\t\t\tName: \"Sum\",\n\t\t\tFn: func(a, b, c int) int { return a + b + c },\n\t\t\tArgs: []any{1, 2, 3},\n\t\t\tExpected: 6,\n\t\t},\n\t\t{\n\t\t\tName: \"Concat\",\n\t\t\tFn: func(a, b, c string) string { return a + b + c },\n\t\t\tArgs: []any{\"a\", \"b\", \"c\"},\n\t\t\tExpected: \"abc\",\n\t\t},\n\t\t{\n\t\t\tName: \"Length (slice type)\",\n\t\t\tFn: func(list []int) (int, error) { return len(list), nil },\n\t\t\tArgs: []any{[]int{1, 2, 3}},\n\t\t\tExpected: 3,\n\t\t},\n\t\t{\n\t\t\tName: \"Emitter\",\n\t\t\tFn: func(emit func(int)) { emit(1) },\n\t\t\tArgs: []any{func(int) {}},\n\t\t},\n\t\t{\n\t\t\tName: \"Side input\",\n\t\t\tFn: func(a int, get func(*int) bool) int {\n\t\t\t\tvar ret int\n\t\t\t\tif !get(&ret) {\n\t\t\t\t\treturn a\n\t\t\t\t}\n\t\t\t\treturn ret\n\t\t\t},\n\t\t\tArgs: []any{1, func(out *int) bool { *out = 2; return true }},\n\t\t\tExpected: 2,\n\t\t},\n\t\t{\n\t\t\tName: \"Sum as Main\",\n\t\t\tFn: func(a, b, c int) int { return a + b + c },\n\t\t\tOpt: &MainInput{Key: FullValue{Elm: 1}},\n\t\t\tArgs: []any{2, 3},\n\t\t\tExpected: 6,\n\t\t},\n\t\t{\n\t\t\tName: \"Sum as Main KV\",\n\t\t\tFn: func(a, b, c int) int { return a + b + c },\n\t\t\tOpt: &MainInput{Key: FullValue{Elm: 1, Elm2: 2}},\n\t\t\tArgs: []any{3},\n\t\t\tExpected: 6,\n\t\t},\n\t\t{\n\t\t\tName: \"EventTime\",\n\t\t\tFn: func(ts typex.EventTime, a int) int { return int(ts.Milliseconds()) + a },\n\t\t\tOpt: &MainInput{Key: FullValue{Elm: 1}},\n\t\t\tExpected: 3,\n\t\t},\n\t\t{\n\t\t\tName: \"Window\",\n\t\t\tFn: func(w typex.Window, a int) int64 { return w.MaxTimestamp().Milliseconds() },\n\t\t\tOpt: &MainInput{Key: FullValue{Elm: 1}},\n\t\t\tExpected: mtime.EndOfGlobalWindowTime.Milliseconds(),\n\t\t},\n\t}\n\n\tfor _, test := range tests {\n\t\tfn, err := funcx.New(reflectx.MakeFunc(test.Fn))\n\t\tif err != nil {\n\t\t\tb.Fatalf(\"function not valid: %v\", err)\n\t\t}\n\n\t\tts := mtime.ZeroTimestamp.Add(2 * time.Millisecond)\n\t\tb.Run(fmt.Sprintf(\"SingleInvoker_%s\", test.Name), func(b *testing.B) {\n\t\t\tfor i := 0; i < b.N; i++ {\n\t\t\t\t_, err := Invoke(context.Background(), typex.NoFiringPane(), window.SingleGlobalWindow, ts, fn, test.Opt, nil, nil, nil, nil, test.Args...)\n\t\t\t\tif err != nil {\n\t\t\t\t\tb.Fatalf(\"Invoke(%v,%v) failed: %v\", fn.Fn.Name(), test.Args, err)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\tb.Run(fmt.Sprintf(\"CachedInvoker_%s\", test.Name), func(b *testing.B) {\n\t\t\tinv := newInvoker(fn)\n\t\t\tfor i := 0; i < b.N; i++ {\n\t\t\t\t_, err := inv.Invoke(context.Background(), typex.NoFiringPane(), window.SingleGlobalWindow, ts, test.Opt, nil, nil, nil, nil, test.Args...)\n\t\t\t\tif err != nil {\n\t\t\t\t\tb.Fatalf(\"Invoke(%v,%v) failed: %v\", fn.Fn.Name(), test.Args, err)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n}", "func run(name string, arg ...string) error {\n\treturn runInDir(\".\", name, arg...)\n}", "func RunSuccessAtLeast(dur time.Duration, f func() error) func() error {\n\treturn func() (err error) {\n\t\tbegin := time.Now()\n\t\terr = f()\n\t\tif d := time.Now().Sub(begin); err == nil && d <= dur {\n\t\t\ttime.Sleep(dur - d)\n\t\t}\n\t\treturn\n\t}\n}", "func benchCode() string {\n consoleCommand := `go test -bench . -benchtime=1s` // Single place to alter the command line command\n output := ``\n\n output += breakspace + cBold + cCyan + \" Golang Function Benchmarks:\" + cClr\n output += breakspace + cYellow + \" > \" + cClr + consoleCommand + breakspace\n\n output += breakspace\n\n testOutput, _ := exec.Command( \"cmd\", \"/c\", consoleCommand ).Output()\n\n // Alternative code:\n //cmd.Stdout = os.Stdout\n //cmd.Run()\n\n return output + statusColorize( string(testOutput) )\n}", "func TestBenchlistAdd(t *testing.T) {\n\tvdrs := validators.NewSet()\n\tvdr0 := validators.GenerateRandomValidator(50)\n\tvdr1 := validators.GenerateRandomValidator(50)\n\tvdr2 := validators.GenerateRandomValidator(50)\n\tvdr3 := validators.GenerateRandomValidator(50)\n\tvdr4 := validators.GenerateRandomValidator(50)\n\n\terrs := wrappers.Errs{}\n\terrs.Add(\n\t\tvdrs.AddWeight(vdr0.ID(), vdr0.Weight()),\n\t\tvdrs.AddWeight(vdr1.ID(), vdr1.Weight()),\n\t\tvdrs.AddWeight(vdr2.ID(), vdr2.Weight()),\n\t\tvdrs.AddWeight(vdr3.ID(), vdr3.Weight()),\n\t\tvdrs.AddWeight(vdr4.ID(), vdr4.Weight()),\n\t)\n\tif errs.Errored() {\n\t\tt.Fatal(errs.Err)\n\t}\n\n\tthreshold := 3\n\tduration := time.Minute\n\tmaxPortion := 0.5\n\tbenchIntf, err := NewBenchlist(\n\t\tlogging.NoLog{},\n\t\tvdrs,\n\t\tthreshold,\n\t\tminimumFailingDuration,\n\t\tduration,\n\t\tmaxPortion,\n\t\t\"\",\n\t\tprometheus.NewRegistry(),\n\t)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tb := benchIntf.(*benchlist)\n\tdefer b.timer.Stop()\n\tnow := time.Now()\n\tb.clock.Set(now)\n\n\t// Nobody should be benched at the start\n\tb.lock.Lock()\n\tassert.False(t, b.isBenched(vdr0.ID()))\n\tassert.False(t, b.isBenched(vdr1.ID()))\n\tassert.False(t, b.isBenched(vdr2.ID()))\n\tassert.False(t, b.isBenched(vdr3.ID()))\n\tassert.False(t, b.isBenched(vdr4.ID()))\n\tassert.Len(t, b.failureStreaks, 0)\n\tassert.Equal(t, b.benchedQueue.Len(), 0)\n\tassert.Equal(t, b.benchlistSet.Len(), 0)\n\tb.lock.Unlock()\n\n\t// Register [threshold - 1] failures in a row for vdr0\n\tfor i := 0; i < threshold-1; i++ {\n\t\tb.RegisterFailure(vdr0.ID())\n\t}\n\n\t// Still shouldn't be benched due to not enough consecutive failure\n\tassert.False(t, b.isBenched(vdr0.ID()))\n\tassert.Equal(t, b.benchedQueue.Len(), 0)\n\tassert.Equal(t, b.benchlistSet.Len(), 0)\n\tassert.Len(t, b.failureStreaks, 1)\n\tfs := b.failureStreaks[vdr0.ID()]\n\tassert.Equal(t, threshold-1, fs.consecutive)\n\tassert.True(t, fs.firstFailure.Equal(now))\n\n\t// Register another failure\n\tb.RegisterFailure(vdr0.ID())\n\n\t// Still shouldn't be benched because not enough time (any in this case)\n\t// has passed since the first failure\n\tb.lock.Lock()\n\tassert.False(t, b.isBenched(vdr0.ID()))\n\tassert.Equal(t, b.benchedQueue.Len(), 0)\n\tassert.Equal(t, b.benchlistSet.Len(), 0)\n\tb.lock.Unlock()\n\n\t// Move the time up\n\tnow = now.Add(minimumFailingDuration).Add(time.Second)\n\tb.lock.Lock()\n\tb.clock.Set(now)\n\tb.lock.Unlock()\n\n\t// Register another failure\n\tb.RegisterFailure(vdr0.ID())\n\n\t// Now this validator should be benched\n\tb.lock.Lock()\n\tassert.True(t, b.isBenched(vdr0.ID()))\n\tassert.Equal(t, b.benchedQueue.Len(), 1)\n\tassert.Equal(t, b.benchlistSet.Len(), 1)\n\n\tnext := b.benchedQueue[0]\n\tassert.Equal(t, vdr0.ID(), next.validatorID)\n\tassert.True(t, !next.benchedUntil.After(now.Add(duration)))\n\tassert.True(t, !next.benchedUntil.Before(now.Add(duration/2)))\n\tassert.Len(t, b.failureStreaks, 0)\n\tb.lock.Unlock()\n\n\t// Give another validator [threshold-1] failures\n\tfor i := 0; i < threshold-1; i++ {\n\t\tb.RegisterFailure(vdr1.ID())\n\t}\n\n\t// Advance the time\n\tb.lock.Lock()\n\tnow = now.Add(minimumFailingDuration)\n\tb.lock.Unlock()\n\n\t// Register another failure\n\tb.RegisterResponse(vdr1.ID())\n\n\t// vdr1 shouldn't be benched\n\t// The response should have cleared its consecutive failures\n\tb.lock.Lock()\n\tassert.True(t, b.isBenched(vdr0.ID()))\n\tassert.False(t, b.isBenched(vdr1.ID()))\n\tassert.Equal(t, b.benchedQueue.Len(), 1)\n\tassert.Equal(t, b.benchlistSet.Len(), 1)\n\tassert.Len(t, b.failureStreaks, 0)\n\tb.lock.Unlock()\n\n\t// Register another failure for vdr0, who is benched\n\tb.RegisterFailure(vdr0.ID())\n\n\t// A failure for an already benched validator should not count against it\n\tb.lock.Lock()\n\tassert.Len(t, b.failureStreaks, 0)\n\tb.lock.Unlock()\n}" ]
[ "0.6889814", "0.6594207", "0.6199323", "0.59165144", "0.5913794", "0.5664615", "0.56288725", "0.55423", "0.5482361", "0.5478386", "0.5464914", "0.54069924", "0.53923553", "0.53124565", "0.5267039", "0.52645284", "0.5264442", "0.52217627", "0.5195152", "0.51781505", "0.5164469", "0.51324", "0.5101489", "0.50897735", "0.50546646", "0.50471866", "0.5038874", "0.5025181", "0.50221735", "0.5013849", "0.5000109", "0.49852887", "0.49641123", "0.49435672", "0.48837534", "0.4850378", "0.4825827", "0.48131788", "0.4808513", "0.48006362", "0.48000476", "0.47888994", "0.4786744", "0.47856703", "0.47853515", "0.47785395", "0.47757414", "0.47532627", "0.4746695", "0.4742686", "0.47336122", "0.4733561", "0.47238123", "0.47202107", "0.47184515", "0.4718141", "0.4705766", "0.47020727", "0.4691981", "0.4686659", "0.4684312", "0.46769765", "0.46701658", "0.46621516", "0.46440354", "0.45789826", "0.45764264", "0.45762962", "0.45741102", "0.4546496", "0.45438394", "0.45338756", "0.45333993", "0.45299274", "0.45272562", "0.45235792", "0.4503464", "0.44914752", "0.44742802", "0.4472701", "0.4471589", "0.44663176", "0.4454765", "0.44530115", "0.44472283", "0.4438785", "0.4426556", "0.44248226", "0.4406304", "0.4402173", "0.44014913", "0.43920097", "0.43862948", "0.4379974", "0.43796626", "0.43601686", "0.43428594", "0.43422094", "0.43404853", "0.43399236" ]
0.512645
22
Next reports whether there are more iterations to execute.
func (pb *PB) Next() bool {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (it *ScriptingReturnValueIterator) Next() bool {\n\tT().Debugf(\"%d return values to iterate\", len(it.values.values))\n\tit.inx++\n\tif it.inx < len(it.values.values) {\n\t\treturn true\n\t} else {\n\t\treturn false\n\t}\n}", "func (i *ResolvedProductIter) Next() bool {\n\tif i.first && i.err != nil {\n\t\ti.first = false\n\t\treturn true\n\t}\n\ti.first = false\n\ti.i++\n\treturn i.i < len(i.page)\n}", "func (si *ScanIterator) Next() bool {\n\treturn si.idx <= len(si.tuples)-1\n}", "func (j *IterableJob) Next() bool {\n\tif !j.finished {\n\t\tj.lock.Lock()\n\t\tcurr := j.pos\n\t\tj.pos++\n\t\tj.lock.Unlock()\n\t\tj.finished = !j.theFunc(curr)\n\t}\n\treturn !j.finished\n}", "func (i *IndexIterator) Next() bool {\n\tfor i.err == nil && i.steps < i.nslots {\n\t\tslot, err := i.readCurrent()\n\n\t\tif err != nil {\n\t\t\ti.err = err\n\t\t\tbreak\n\t\t}\n\n\t\tif slot.lpos == 0 {\n\t\t\ti.steps = i.nslots\n\t\t\tbreak\n\t\t}\n\n\t\ti.steps++\n\t\tif i.cursor++; i.cursor == i.nslots {\n\t\t\ti.cursor = 0\n\t\t}\n\n\t\tif slot.cksum == i.cksum {\n\t\t\ti.current = slot\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (result *Result) HasNext() bool {\n\treturn result.index < len(result.pageValues) || result.pageToken != nil\n}", "func (fr *FakeResult) Next() bool {\n\tif count < 3 {\n\t\tcount++\n\t\treturn true\n\t}\n\tcount = 0\n\treturn false\n}", "func (qi *QueryIterator) HasNext() bool {\n\treturn qi.processedRows < qi.totalRows\n}", "func (result *BufferedResult) HasNext() bool {\n\treturn result.index < len(result.values)\n}", "func (iterator *Iterator) Next() bool {\n\treturn iterator.iterator.Next()\n}", "func (c *counter) next() bool {\n\thasNext := true\n\tif util.EqualsSliceUint(c.state, c.endState) {\n\t\thasNext = false\n\t} else {\n\t\tc.incrementState()\n\t}\n\n\treturn hasNext\n}", "func (iter *Iterator) Next() bool { return iter.impl.Next() }", "func (batcher *DownloadObjectsIterator) Next() bool {\n\tif batcher.inc {\n\t\tbatcher.index++\n\t} else {\n\t\tbatcher.inc = true\n\t}\n\treturn batcher.index < len(batcher.Objects)\n}", "func (db *calcDatabase) next() bool {\n\tmatched, rows := false, len(db.database)\n\tfor !matched && db.row < rows {\n\t\tif db.row++; db.row < rows {\n\t\t\tmatched = db.criteriaEval()\n\t\t}\n\t}\n\treturn matched\n}", "func (batcher *UploadObjectsIterator) Next() bool {\n\tif batcher.inc {\n\t\tbatcher.index++\n\t} else {\n\t\tbatcher.inc = true\n\t}\n\treturn batcher.index < len(batcher.Objects)\n}", "func (i *ArrayIterator) Next() bool {\n\ti.i++\n\treturn i.i <= i.l\n}", "func (iter *CouchDBMockStateRangeQueryIterator) HasNext() bool {\n\tif iter.Closed {\n\t\t// previously called Close()\n\t\treturn false\n\t}\n\tif iter.CurrentIndex >= len(iter.QueryResults) {\n\t\treturn false\n\t}\n\treturn true\n}", "func (it *KVResultsIter) HasNext() bool {\n\tqueryResult, err := it.it.Next()\n\tif err != nil {\n\t\t// Save the error and return true. The caller will get the error when Next is called.\n\t\tit.nextErr = err\n\t\treturn true\n\t}\n\tif queryResult == nil {\n\t\treturn false\n\t}\n\tit.next = queryResult\n\treturn true\n}", "func (it *GridIterator) Next() bool {\n\tif it.p.X < it.max.X {\n\t\tit.p.X++\n\t\tit.i++\n\t\treturn true\n\t}\n\tif it.p.Y < it.max.Y {\n\t\tit.p.Y++\n\t\tit.p.X = 0\n\t\tit.i += it.nlstep\n\t\treturn true\n\t}\n\treturn false\n}", "func (iter *DeleteObjectsIterator) Next() bool {\n\tif iter.inc {\n\t\titer.index++\n\t} else {\n\t\titer.inc = true\n\t}\n\treturn iter.index < len(iter.Objects)\n}", "func (pb *PB) Next() bool", "func (i *Iterator) Next() bool {\n\treturn i.i.Next()\n}", "func Next(it Iterator) bool {\n\treturn neogointernal.Syscall1(\"System.Iterator.Next\", it).(bool)\n}", "func (pager *IntegrationsPager) HasNext() bool {\n\treturn pager.hasNext\n}", "func (i *Iterator) Next() (bool, error) {\n\treturn false, errors.New(\"next failure\")\n}", "func (i *iterator) HasNext() bool {\n\treturn i.index < len(i.sortArr) && i.sortArr[i.index] == i.currentSequence\n}", "func (qr *queryResult) HasNextResultSet() bool { return false }", "func (r *Result) Next() (more bool) {\n\tif r.conn == nil {\n\t\treturn false\n\t}\n\tswitch r.conn.Status() {\n\tcase StatusResultDone:\n\t\treturn false\n\t}\n\treturn !r.val.eof\n}", "func (it *Iterator) Next() {\n\tit.iter.Next()\n\tit.count++\n\tit.skipUnwanted()\n\tif it.refreshRate > 0 && it.count > it.refreshRate {\n\t\tit.Refresh()\n\t\tit.count = 0\n\t}\n}", "func (D DiskIterator) HasNext() bool {\n\treturn D.recordInx > 0\n}", "func (it *iterator) Next() (ok bool) {\n\tit.next <- struct{}{}\n\tselect {\n\tcase it.err = <-it.errCh:\n\t\treturn false\n\tcase it.current, ok = <-it.items:\n\t}\n\treturn\n}", "func (cur *cursor) hasNext() bool {\n\treturn cur.idx < int(cur.nd.count)-1\n}", "func (s *spoolNode) Next(params runParams) (bool, error) {\n\ts.curRowIdx++\n\treturn s.curRowIdx < s.rows.Len(), nil\n}", "func (s *sensorPackage) Next() bool {\n\ts.currentIndex++\n\tif s.currentIndex < s.length {\n\t\treturn true\n\t}\n\ts.currentIndex = 0\n\treturn false\n}", "func (pager *EnterprisesPager) HasNext() bool {\n\treturn pager.hasNext\n}", "func (cr *callResult) HasNextResultSet() bool { return false }", "func (i *MapIterator) Next() bool {\n\ti.i++\n\treturn i.i <= i.l\n}", "func (it *Iterator) Next() bool {\n\tit.n = it.n.next[0]\n\treturn it.n != nil\n}", "func (it *Iterator) Next() bool {\n\tit.n = it.n.next[0]\n\treturn it.n != nil\n}", "func (iter *PermutationIterator) HasNext() bool {\n\treturn iter.iters < iter.max\n}", "func (i *Iterator) Next() bool {\n\ti.n = i.n.atomicLoadNext(0)\n\treturn i.n != nil\n}", "func (smi *SetMatchesIter) Next() (retVal int, ok bool) {\n\tif smi.nextIdx >= len(smi.matches) {\n\t\treturn -1, false\n\t}\n\n\tif smi.matches[smi.nextIdx] {\n\t\tretVal = smi.nextIdx\n\t} else {\n\t\tretVal = -1\n\t}\n\tsmi.nextIdx++\n\n\treturn retVal, true\n}", "func (iterator *combinationIterator) HasNext() bool {\n\treturn iterator.offset < len(*iterator.Permutations)\n}", "func (it *Mcmc5intmcMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (i *couchDBResultsIterator) Next() (bool, error) {\n\tnextCallResult := i.resultRows.Next()\n\n\t// Kivik only guarantees that this value will be set after all the rows have been iterated through.\n\twarningMsg := i.resultRows.Warning()\n\n\tif warningMsg != \"\" {\n\t\tlogger.Warnf(warningMsg)\n\t}\n\n\terr := i.resultRows.Err()\n\tif err != nil {\n\t\treturn nextCallResult, fmt.Errorf(failureDuringIterationOfResultRows, err)\n\t}\n\n\treturn nextCallResult, nil\n}", "func (ts *TokenScanner) hasNext() bool {\n\tif ts.i >= len(ts.tokens) {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func (p *Paginator) HasNext() bool {\n\treturn p.Page() < p.PageNums()\n}", "func (iter *SelectIter) Next() bool {\n\treturn iter.iterx.StructScan(iter.dest)\n}", "func (di *Iterator) Next() bool {\n\tif !di.first {\n\t\tdi.iter.Next()\n\t}\n\tdi.first = false\n\treturn di.iter.Valid()\n}", "func (pager *ConfigurationsPager) HasNext() bool {\n\treturn pager.hasNext\n}", "func (it *NZIter) Done() bool {\n\treturn it.n >= it.g.N()\n}", "func (it InvertingInt32SliceIterator) HasNext() bool {\n\treturn it.cur >= 0\n}", "func (it *Mcmc4intmcMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (it *Mcmc1intmcMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (it *BytesScanner) HasNext() bool {\n\treturn it.index < len(it.source) || it.emitEmptySlice\n}", "func (it *Mcmc2intmcMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (it *Mcmc6intmcMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (i *BytesIterator) Next() bool {\n\ti.i++\n\treturn i.i <= i.l\n}", "func (da *DataFrame) Next() bool {\n\n\tda.chunk++\n\tif da.chunk <= len(da.data[0]) {\n\t\treturn true\n\t}\n\tda.done = true\n\treturn false\n}", "func (it *ArrayListIterator[T]) HasNext() bool {\n\tif it.index+1 < it.list.Size() {\n\t\treturn true\n\t}\n\treturn false\n}", "func (it *Msmsintprp5MetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (pr *PgRows) HasNextResultSet() bool {\n\treturn false\n}", "func (u *UserResultsPage) HasNext() bool {\n\treturn u.NextPage != 0\n}", "func (it *Dppdpp1intsramseccMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (it *Mcmc7intmcMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (iter *Iterator) HasNext() bool {\n\thasNext := false\n\tif iter.index < iter.list.size {\n\t\titer.index++\n\t\thasNext = true\n\t}\n\tif iter.index == 1 {\n\t\titer.currentNode = iter.list.head\n\t} else {\n\t\titer.currentNode = iter.currentNode.next\n\t}\n\treturn hasNext\n}", "func (p *Pagination) HasNext() bool {\n\treturn p.Page+1 <= p.NumPages()\n}", "func (it *Dprdpr1intsramseccMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (it *Msmsintprp4MetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (p *Pagination) hasNext() bool {\n\tif p.CurrentPage*p.Limit >= p.Total {\n\t\treturn false\n\t}\n\treturn true\n}", "func (it *Mcmc5mchintmcMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (it *Mcmc0intmcMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (p *PaginatedResult) next(ctx context.Context, into interface{}) bool {\n\tif !p.first {\n\t\tif p.nextLink == \"\" {\n\t\t\treturn false\n\t\t}\n\t\tp.err = p.goTo(ctx, p.nextLink)\n\t\tif p.err != nil {\n\t\t\treturn false\n\t\t}\n\t}\n\tp.first = false\n\n\tp.err = decodeResp(p.res, into)\n\treturn p.err == nil\n}", "func (it *intervalRollingIter) HasNext() bool {\n\tif it.currIndex >= it.bow.NumRows() {\n\t\treturn false\n\t}\n\tn, valid := it.bow.GetInt64(it.colIndex, it.bow.NumRows()-1)\n\treturn valid && it.currStart <= n\n}", "func (pager *ProjectsPager) HasNext() bool {\n\treturn pager.hasNext\n}", "func (it *Mcmc1mchintmcMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (rs *rowSets) HasNextResultSet() bool {\n\treturn rs.pos+1 < len(rs.sets)\n}", "func (it *Msmsintprp1MetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (pager *DestinationsPager) HasNext() bool {\n\treturn pager.hasNext\n}", "func (it Int32SliceIterator) HasNext() bool {\n\treturn it.cur < len(it.slice)\n}", "func (pager *AccountsPager) HasNext() bool {\n\treturn pager.hasNext\n}", "func (it *Mcmc4mchintmcMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (pager *SecretsPager) HasNext() bool {\n\treturn pager.hasNext\n}", "func (it *Mcmc2mchintmcMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (pager *SecretVersionLocksPager) HasNext() bool {\n\treturn pager.hasNext\n}", "func (pager *SecretLocksPager) HasNext() bool {\n\treturn pager.hasNext\n}", "func (it *Msmsintprp2MetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (it *Dppdpp0intsramseccMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (it *Mxmx1inteccMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (it *Iter) Next(ctx context.Context) bool {\n\t// no more if there is an error\n\tif it.err != nil {\n\t\treturn false\n\t}\n\n\t// advance the iterator\n\tit.n += 1\n\n\t// is there an available item?\n\tif it.n < len(it.items) {\n\t\tit.lastItemID = ngrok.String(it.Item().ID)\n\t\treturn true\n\t}\n\n\t// fetch the next page\n\tresp, err := it.client.list(ctx, &ngrok.Paging{\n\t\tBeforeID: it.lastItemID,\n\t\tLimit: it.limit,\n\t})\n\tif err != nil {\n\t\tit.err = err\n\t\treturn false\n\t}\n\n\t// page with zero items means there are no more\n\tif len(resp.TunnelSessions) == 0 {\n\t\treturn false\n\t}\n\n\tit.n = -1\n\tit.items = resp.TunnelSessions\n\treturn it.Next(ctx)\n}", "func (it *Mcmc6mchintmcMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (r *Rows) Next() bool {\n\treturn r.c.Next(context.TODO())\n}", "func (pager *SourcesPager) HasNext() bool {\n\treturn pager.hasNext\n}", "func (ds *DirSuiteFileIterator) HasNext() bool {\n\treturn len(ds.files) > ds.pos\n}", "func (it *Dppdpp1intreg1MetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (it *Dprdpr1intreg2MetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (wf *WindowFrameCurr) Next(i int64) (int64, bool) {\n\tif i < wf.Include.Beg {\n\t\ti = wf.Include.Beg\n\t} else {\n\t\ti++\n\t}\n\n\tfor _, exclude := range wf.Excludes {\n\t\tif i >= exclude.Beg && i < exclude.End {\n\t\t\ti = exclude.End\n\t\t}\n\t}\n\n\tif i >= wf.Include.End {\n\t\treturn i, false\n\t}\n\n\treturn i, true\n}", "func (it *Dprdpr1intreg1MetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "func (it *HashSetIterator) HasNext() bool {\n\tif it.index+1 < len(it.values) {\n\t\treturn true\n\t}\n\treturn false\n}", "func (it *Dprdpr1intspareMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}" ]
[ "0.7379314", "0.72344273", "0.7204958", "0.7182491", "0.717007", "0.71591055", "0.7146797", "0.7086303", "0.7037553", "0.7003668", "0.6974741", "0.694564", "0.6934344", "0.6910715", "0.6880078", "0.6877245", "0.68726087", "0.68215984", "0.68158257", "0.6791055", "0.67874914", "0.6786206", "0.67557627", "0.67481995", "0.67341423", "0.6731311", "0.67311835", "0.67115885", "0.6708949", "0.6707266", "0.6689587", "0.66839826", "0.6679784", "0.6659855", "0.66433626", "0.6636585", "0.66249317", "0.6623394", "0.6623394", "0.6603182", "0.6597848", "0.6577891", "0.6560893", "0.65594196", "0.6552029", "0.6546382", "0.65448874", "0.65383637", "0.65377814", "0.65319896", "0.6526647", "0.6519016", "0.6516359", "0.6499602", "0.6493471", "0.64907897", "0.6489883", "0.6488662", "0.6481338", "0.6476186", "0.64662284", "0.64659554", "0.64649683", "0.64578575", "0.6455551", "0.6443678", "0.6442323", "0.6440464", "0.6429961", "0.6429019", "0.6427851", "0.64185894", "0.6416236", "0.641623", "0.6416192", "0.64125323", "0.6411915", "0.64099973", "0.6408719", "0.6408476", "0.6407984", "0.64077127", "0.639511", "0.6390928", "0.6390395", "0.63894004", "0.6384341", "0.6383787", "0.63798064", "0.6379024", "0.6376985", "0.63713527", "0.6365457", "0.63644654", "0.63597095", "0.6359082", "0.63511515", "0.6350224", "0.63460535", "0.63455653" ]
0.66290563
36
RunParallel runs a benchmark in parallel. It creates multiple goroutines and distributes b.N iterations among them. The number of goroutines defaults to GOMAXPROCS. To increase parallelism for nonCPUbound benchmarks, call SetParallelism before RunParallel. RunParallel is usually used with the go test cpu flag. The body function will be run in each goroutine. It should set up any goroutinelocal state and then iterate until pb.Next returns false. It should not use the StartTimer, StopTimer, or ResetTimer functions, because they have global effect. It should also not call Run.
func (b *B) RunParallel(body func(*PB)) {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (b *B) RunParallel(body func(*PB))", "func BenchmarkParallelProcess(b *testing.B) {\n\trand.Seed(18)\n\tp := protocols{}\n\tp.tcp = make(map[protos.Protocol]protos.TcpProtocolPlugin)\n\tp.tcp[1] = &TestProtocol{Ports: []int{ServerPort}}\n\ttcp, _ := NewTcp(p)\n\n\tb.ResetTimer()\n\tb.RunParallel(func(pb *testing.PB) {\n\t\tfor pb.Next() {\n\t\t\tpkt := &protos.Packet{\n\t\t\t\tTs: time.Now(),\n\t\t\t\tTuple: common.NewIpPortTuple(4,\n\t\t\t\t\tnet.ParseIP(ServerIp), ServerPort,\n\t\t\t\t\tnet.ParseIP(ClientIp), uint16(rand.Intn(65535))),\n\t\t\t\tPayload: []byte{1, 2, 3, 4},\n\t\t\t}\n\t\t\ttcp.Process(&layers.TCP{}, pkt)\n\t\t}\n\t})\n}", "func benchmarkThrottlerParallel(b *testing.B, qps int64) {\n\tthreadCount := runtime.GOMAXPROCS(0)\n\tthrottler, _ := NewThrottler(\"test\", \"queries\", threadCount, qps, ReplicationLagModuleDisabled)\n\tdefer throttler.Close()\n\tthreadIDs := make(chan int, threadCount)\n\tfor id := 0; id < threadCount; id++ {\n\t\tthreadIDs <- id\n\t}\n\tclose(threadIDs)\n\tb.ResetTimer()\n\n\tb.RunParallel(func(pb *testing.PB) {\n\t\tthreadID := <-threadIDs\n\n\t\tfor pb.Next() {\n\t\t\tbackedOff := 0\n\t\t\tfor {\n\t\t\t\tbackoff := throttler.Throttle(threadID)\n\t\t\t\tif backoff == NotThrottled {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tbackedOff++\n\t\t\t\tif backedOff > 1 {\n\t\t\t\t\tb.Logf(\"did not wait long enough after backoff. threadID = %v, last backoff = %v\", threadID, backoff)\n\t\t\t\t}\n\t\t\t\ttime.Sleep(backoff)\n\t\t\t}\n\t\t}\n\t\tthrottler.ThreadFinished(threadID)\n\t})\n}", "func BenchmarkRunParallel(b *testing.B) {\n\tfp := protofile\n\n\treader, _ := os.Open(fp)\n\tdefer reader.Close()\n\n\tparser := proto.NewParser(reader)\n\tdefinition, _ := parser.Parse()\n\n\tvar (\n\t\tcurrentService *proto.Service\n\t\tcurrentTemplateMap map[string]map[string]string\n\t)\n\n\thandlerService := proto.WithService(func(s *proto.Service) {\n\t\tclearRandoms()\n\t\tif rpc != \"\" && s.Name != rpc {\n\t\t\treturn\n\t\t}\n\t\tcurrentService = s\n\t\tif m, ok := Templates[s.Name]; ok {\n\t\t\tcurrentTemplateMap = m\n\t\t}\n\t})\n\n\thandlerRPC := proto.WithRPC(func(r *proto.RPC) {\n\n\t\tfor _, action := range []string{\"create\", \"update\", \"delete\"} {\n\t\t\tif m, ok := currentTemplateMap[action]; ok {\n\t\t\t\tif t, ok := m[r.Name]; ok {\n\n\t\t\t\t\t// if ovs { // skip unvalid service: useful when various services are defined in a single proto file\n\t\t\t\t\t// \ttokens := strings.Split(service, \".\")\n\t\t\t\t\t// \tsuffix := tokens[len(tokens)-1]\n\t\t\t\t\t// \ttcr := strings.ToLower(currentService)\n\t\t\t\t\t// \tif !strings.HasPrefix(tcr, suffix) {\n\t\t\t\t\t// \t\treturn\n\t\t\t\t\t// \t}\n\t\t\t\t\t// }\n\n\t\t\t\t\t// Retrieve the test template\n\t\t\t\t\ttmpl, err := template.New(r.Name).Parse(t)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\t// range of SetParallelism\n\t\t\t\t\tparallelisms := make([]int, 0)\n\t\t\t\t\tfor i := 0; i <= maxParallelThreads; i += 2 {\n\t\t\t\t\t\tparallelisms = append(parallelisms, int(1<<uint32(i)))\n\t\t\t\t\t}\n\n\t\t\t\t\tfor _, p := range parallelisms {\n\n\t\t\t\t\t\t// Enable error count gathering\n\t\t\t\t\t\tvar gotError chan bool\n\t\t\t\t\t\tvar performed chan int\n\t\t\t\t\t\tvar allDone chan bool\n\n\t\t\t\t\t\tif logFailedCalls {\n\t\t\t\t\t\t\tgotError = make(chan bool)\n\t\t\t\t\t\t\tperformed = make(chan int)\n\t\t\t\t\t\t\tallDone = make(chan bool)\n\t\t\t\t\t\t\tgo func() {\n\t\t\t\t\t\t\t\terrNb := 0\n\t\t\t\t\t\t\t\ttotalNb := 0\n\t\t\t\t\t\t\t\tfor {\n\t\t\t\t\t\t\t\t\tselect {\n\t\t\t\t\t\t\t\t\tcase <-allDone:\n\t\t\t\t\t\t\t\t\t\tresults := float32(errNb) / float32(totalNb) * 100\n\t\t\t\t\t\t\t\t\t\tfmt.Printf(\"Benchmarking %s - %.00f%% error rate\\n\", fmt.Sprintf(\"%s/%v\", r.Name, p), results)\n\t\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\t\tcase nb := <-performed:\n\t\t\t\t\t\t\t\t\t\ttotalNb += nb\n\t\t\t\t\t\t\t\t\tcase <-gotError:\n\t\t\t\t\t\t\t\t\t\terrNb++\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}()\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tb.Run(fmt.Sprintf(\"%s/%v\", r.Name, p), func(b *testing.B) {\n\t\t\t\t\t\t\tb.SetParallelism(p)\n\t\t\t\t\t\t\tb.RunParallel(func(pb *testing.PB) {\n\t\t\t\t\t\t\t\tcounter := 0\n\t\t\t\t\t\t\t\tfor pb.Next() {\n\t\t\t\t\t\t\t\t\tif r.StreamsRequest && !r.StreamsReturns {\n\t\t\t\t\t\t\t\t\t\terr := benchStreamClient(b, action, currentService, r, tmpl)\n\t\t\t\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\t\t\t\tif logFailedCalls {\n\t\t\t\t\t\t\t\t\t\t\t\tgotError <- true\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tcounter = counter + b.N\n\t\t\t\t\t\t\t\t\t} else if !r.StreamsRequest && r.StreamsReturns {\n\t\t\t\t\t\t\t\t\t\terr := benchStreamServer(b, action, currentService, r, tmpl)\n\t\t\t\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\t\t\t\tif logFailedCalls {\n\t\t\t\t\t\t\t\t\t\t\t\tgotError <- true\n\t\t\t\t\t\t\t\t\t\t\t\tcounter++\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tcounter = counter + b.N\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terr := benchCall(b, action, currentService, r, tmpl)\n\t\t\t\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\t\t\t\tif logFailedCalls {\n\t\t\t\t\t\t\t\t\t\t\t\tgotError <- true\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tcounter = counter + b.N\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif logFailedCalls {\n\t\t\t\t\t\t\t\t\tperformed <- counter\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t})\n\t\t\t\t\t\tif logFailedCalls {\n\t\t\t\t\t\t\tallDone <- true\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n\n\tproto.Walk(definition, handlerService, handlerRPC)\n}", "func RunBenchmark(name string, b *testing.B, f Func, n int) {\n\tb.Run(name, func(b *testing.B) {\n\t\tb.Logf(\"f(%d), loop (b.N) = %d\\n\", n, b.N)\n\t\tfor i := 0; i < b.N; i++ {\n\t\t\tf(n)\n\t\t}\n\t})\n}", "func BatchWriteParallelBenchmark(b *testing.B, create CreateFunc, batchSize int) {\n\tdb, destroy, err := create()\n\ttestutil.Fatalf(b, \"CreateFunc error: %v\", err)\n\tdefer func() {\n\t\ttestutil.Fatalf(b, \"db close error: %v\", db.Close(ctx))\n\t\ttestutil.Fatalf(b, \"DestroyFunc error: %v\", destroy())\n\t}()\n\n\tb.RunParallel(func(pb *testing.PB) {\n\t\tkeyBuf := make([]byte, keySize)\n\t\tvalBuf := make([]byte, valSize)\n\t\tfor pb.Next() {\n\t\t\twr, err := db.Writer(ctx)\n\t\t\ttestutil.Fatalf(b, \"writer error: %v\", err)\n\t\t\tfor j := 0; j < batchSize; j++ {\n\t\t\t\ttestutil.RandBytes(keyBuf)\n\t\t\t\ttestutil.RandBytes(valBuf)\n\t\t\t\ttestutil.Fatalf(b, \"write error: %v\", wr.Write(keyBuf, valBuf))\n\t\t\t}\n\t\t\ttestutil.Fatalf(b, \"writer close error: %v\", wr.Close())\n\t\t}\n\t})\n}", "func parallel(count int, procs int, fn func(int, int)) {\n\tvar blockSize int\n\tif count > 0 && procs > 0 {\n\t\tblockSize = count / procs\n\t} else {\n\t\tblockSize = 1\n\t}\n\tif blockSize <= 0 {\n\t\tblockSize = 1\n\t}\n\n\tidx := count\n\tvar wg sync.WaitGroup\n\tfor idx > 0 {\n\t\tstart := idx - blockSize\n\t\tend := idx\n\t\tif start < 0 {\n\t\t\tstart = 0\n\t\t}\n\t\tidx -= blockSize\n\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tfn(start, end)\n\t\t\twg.Done()\n\t\t}()\n\t}\n\twg.Wait()\n}", "func TestPrimeParallel(t *testing.T) {\n\n\t// run each test case\n\tfor i, test := range tests {\n\t\tst := func(t *testing.T) {\n\t\t\tt.Parallel()\n\n\t\t\tt.Logf(\"\\tTest: %d\\t Check weather given number %d is prime\", i, test.input)\n\t\t\t{\n\t\t\t\tisPrime := CheckPrime(test.input)\n\t\t\t\tif isPrime != test.isPrime {\n\t\t\t\t\tt.Errorf(\"\\t%s\\tCould not get expected result\", failed)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tt.Run(fmt.Sprintf(\"check prime\"), st)\n\t}\n}", "func BenchmarkBatchPipeline(b *testing.B) {\n\tnumbers := gen(1_000_000)\n\tb.ReportAllocs()\n\tfor i := 0; i < b.N; i++ {\n\t\tfor range bMultiply(bAdd(bMultiply(numbers, 2), 1), 2) {\n\t\t}\n\t}\n}", "func (b *Benchmark) Run() {\n\tfor _, gpu := range b.gpus {\n\t\tb.driver.SelectGPU(b.context, gpu)\n\t\tb.queues = append(b.queues, b.driver.CreateCommandQueue(b.context))\n\t}\n\n\tif b.NumIterations == 0 || b.NumIterations > b.NumNodes {\n\t\tb.NumIterations = b.NumNodes\n\t}\n\n\tb.initMem()\n\tb.exec()\n}", "func Run(workers []Worker, duration time.Duration) *Result {\n\tdebug = os.Getenv(\"DEBUG\") != \"\"\n\tc := len(workers)\n\tlog.Printf(\"starting benchmark: concurrency: %d, time: %s, GOMAXPROCS: %d\", c, duration, runtime.GOMAXPROCS(0))\n\tstartCh := make(chan bool, c)\n\treadyCh := make(chan bool, c)\n\tvar stopFlag int32\n\tscoreCh := make(chan int, c)\n\tvar wg sync.WaitGroup\n\n\t// spawn worker goroutines\n\tfor i, w := range workers {\n\t\tdebugLog(\"spwan worker[%d]\", i)\n\t\tgo func(n int, worker Worker) {\n\t\t\twg.Add(1)\n\t\t\tdefer wg.Done()\n\t\t\tscore := 0\n\t\t\tworker.Setup()\n\t\t\treadyCh <- true // ready of worker:n\n\t\t\t<-startCh // notified go benchmark from Runner\n\t\t\tdebugLog(\"worker[%d] starting Benchmark()\", n)\n\t\t\tfor atomic.LoadInt32(&stopFlag) == 0 {\n\t\t\t\tscore += worker.Process()\n\t\t\t}\n\t\t\tscoreCh <- score\n\t\t\tdebugLog(\"worker[%d] done Benchmark() score: %d\", n, score)\n\t\t\tworker.Teardown()\n\t\t\tdebugLog(\"worker[%d] exit\", n)\n\t\t}(i, w)\n\t}\n\n\t// wait for ready of workres\n\tdebugLog(\"waiting for all workers finish Setup()\")\n\tfor i := 0; i < c; i++ {\n\t\t<-readyCh\n\t}\n\n\t// notify \"start\" to workers\n\tclose(startCh)\n\tstart := time.Now()\n\n\t// wait for catching signal or timed out\n\tsignalCh := make(chan os.Signal, 1)\n\tsignal.Notify(signalCh, TrapSignals...)\n\tselect {\n\tcase s := <-signalCh:\n\t\tswitch sig := s.(type) {\n\t\tcase syscall.Signal:\n\t\t\tlog.Printf(\"Got signal: %s(%d)\", sig, sig)\n\t\tdefault:\n\t\t\tlog.Printf(\"interrupted %s\", s)\n\t\t\tbreak\n\t\t}\n\tcase <-time.After(duration):\n\t\tdebugLog(\"timed out\")\n\t\tbreak\n\t}\n\n\t// notify \"stop\" to workers\n\tatomic.StoreInt32(&stopFlag, 1)\n\n\t// collect scores from workers\n\ttotalScore := 0\n\tfor i := 0; i < c; i++ {\n\t\ttotalScore += <-scoreCh\n\t}\n\tend := time.Now()\n\telapsed := end.Sub(start)\n\tlog.Printf(\"done benchmark: score %d, elapsed %s = %f / sec\\n\", totalScore, elapsed, float64(totalScore)/float64(elapsed)*float64(time.Second))\n\n\twg.Wait()\n\treturn &Result{Score: totalScore, Elapsed: elapsed}\n}", "func Parallel(ctx context.Context, state *core.BuildState, labels []core.AnnotatedOutputLabel, args []string, numTasks int, outputMode process.OutputMode, remote, env, detach, inTmp bool, dir string) int {\n\tprepareRun()\n\n\tlimiter := make(chan struct{}, numTasks)\n\tvar g errgroup.Group\n\tfor _, label := range labels {\n\t\tlabel := label // capture locally\n\t\tg.Go(func() error {\n\t\t\tlimiter <- struct{}{}\n\t\t\tdefer func() { <-limiter }()\n\n\t\t\terr := runWithOutput(ctx, state, label, args, outputMode, remote, env, detach, inTmp, dir)\n\t\t\tif err != nil && ctx.Err() == nil {\n\t\t\t\tlog.Error(\"Command failed: %s\", err)\n\t\t\t}\n\t\t\treturn err\n\t\t})\n\t}\n\tif err := g.Wait(); err != nil {\n\t\tif ctx.Err() != nil { // Don't error if the context killed the process.\n\t\t\treturn 0\n\t\t}\n\t\treturn err.(*exitError).code\n\t}\n\treturn 0\n}", "func BenchmarkRunner_Run(b *testing.B) {\n\tsrv := serverMock()\n\tdefer srv.Close()\n\n\tclient := &http.Client{}\n\tconcurrent := make(chan struct{}, 5)\n\tparser := parsers.NewNasaParser(contextLogger, \"DEMO_KEY\", srv.URL+\"/planetary/apod?api_key=%s&date=%s\", client)\n\trunner := NewRunner(contextLogger, concurrent, parser)\n\n\tfor i := 0; i < b.N; i++ {\n\t\t_, err := runner.Run([]string{\"2019-12-06\", \"2019-12-07\", \"2019-12-10\", \"2019-12-11\", \"2019-12-12\", \"2019-12-14\"})\n\t\tif err != nil {\n\t\t\tb.Fatalf(\"Error: %v\", err)\n\t\t}\n\t}\n}", "func ParallelRaceCompute(tb testing.TB, count int, fn func() error) {\n\ttb.Helper()\n\tif !race.Enabled {\n\t\ttb.Skip(\n\t\t\t\"This test requires the Race Detector to be enabled.\",\n\t\t\t\"Please run again with -race to run this test.\",\n\t\t)\n\t\treturn\n\t}\n\trequire.NotNil(tb, fn, \"Must have a valid function\")\n\n\tvar (\n\t\tstart = make(chan struct{})\n\t\twg sync.WaitGroup\n\t)\n\tfor i := 0; i < count; i++ {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\n\t\t\t<-start\n\t\t\tassert.NoError(tb, fn(), \"Must not error when executing function\")\n\t\t}()\n\t}\n\tclose(start)\n\n\twg.Wait()\n}", "func (p Parallel) Run() {\n\tvar wg sync.WaitGroup\n\twg.Add(len(p))\n\tfor _, f := range p {\n\t\tgo func(f func()) {\n\t\t\tf()\n\t\t\twg.Done()\n\t\t}(f)\n\t}\n\twg.Wait()\n}", "func BenchmarkAPIRequestPublishManyParallel(b *testing.B) {\n\tapp := NewTestMemoryNode()\n\tjsonData := getNPublishJSON(\"channel\", 1000)\n\tb.ResetTimer()\n\tb.RunParallel(func(pb *testing.PB) {\n\t\tfor pb.Next() {\n\t\t\t_, err := apiv1.ProcessAPIData(app, jsonData)\n\t\t\tif err != nil {\n\t\t\t\tb.Error(err)\n\t\t\t}\n\t\t}\n\t})\n}", "func RunBenchmark(b *testing.B, version int, f func(*Anwork, int)) {\n\ta, err := MakeAnwork(version)\n\tif err != nil {\n\t\tb.Fatal(err)\n\t}\n\tdefer a.Close()\n\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tf(a, i)\n\t}\n}", "func BenchmarkMain(b *testing.B) {\n\tfor n:=0; n < b.N; n++ {\n\t\tmain()\n\t}\n}", "func BenchmarkWorknMulti(b *testing.B) {\n\tfoundValues, bob := randomNumMap(6)\n\ttype wrkr func(NumCol, *NumMap) SolLst\n\ttype wrkrTest struct {\n\t\tfc wrkr\n\t\tdesc string\n\t}\n\trunners := []wrkrTest{\n\t\t{workN, \"old\"},\n\t}\n\tfor _, runner := range runners {\n\t\trunFunc := func(tb *testing.B) {\n\t\t\tfor i := 0; i < tb.N; i++ {\n\t\t\t\ttb.StopTimer()\n\t\t\t\tfv := foundValues.Duplicate()\n\t\t\t\ttb.StartTimer()\n\t\t\t\trunner.fc(bob, fv)\n\t\t\t}\n\t\t}\n\t\trunString := runner.desc\n\t\tb.Run(runString, runFunc)\n\t}\n}", "func BenchmarkNewFetchHTTP_Parallel(b *testing.B) {\n\t// This parent benchmark function runs only once as soon as there is another\n\t// sub-benchmark.\n\n\t// Full integration benchmark test which starts a HTTP file server and uses\n\t// TCP to query it on the localhost.\n\tconst backendURL = \"http://127.0.0.1:8283/cart_example.html\"\n\tconst lenCartExampleHTML = 21601\n\n\t// grpc_server_main also reads the file from the disk so stay conistent when\n\t// running benchmarks.\n\tcmd := esitesting.StartProcess(\"go\", \"run\", \"http_server_main.go\")\n\tgo cmd.Wait() // waits forever until killed\n\tdefer cmd.Process.Kill() // kills the go process but not the main startet server\n\tdefer esitesting.KillZombieProcess(\"http_server_main\")\n\n\t// Wait until http server has been started\n\tfor i := 300; ; i = i + 100 {\n\t\td := time.Duration(i) * time.Millisecond\n\t\ttime.Sleep(d)\n\t\t_, err := http.Get(backendURL)\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"BenchmarkNewFetchHTTP_Parallel: %s => Sleept %s\\n\", err, d)\n\t\t\tcontinue\n\t\t}\n\t\tbreak\n\t}\n\n\tb.Run(\"Insecure\", func(b *testing.B) {\n\n\t\tfh := backend.NewFetchHTTP(backend.DefaultHTTPTransport)\n\t\trfa := &esitag.ResourceArgs{\n\t\t\tExternalReq: getExternalReqWithExtendedHeaders(),\n\t\t\tURL: backendURL,\n\t\t\tTag: esitag.Config{\n\t\t\t\tTimeout: time.Second,\n\t\t\t\tMaxBodySize: 22001,\n\t\t\t},\n\t\t}\n\n\t\tb.ResetTimer()\n\t\tb.ReportAllocs()\n\t\tb.RunParallel(func(pb *testing.PB) {\n\t\t\tvar content []byte\n\t\t\tvar hdr http.Header\n\t\t\tvar err error\n\n\t\t\tfor pb.Next() {\n\t\t\t\thdr, content, err = fh.DoRequest(rfa)\n\t\t\t\tif err != nil {\n\t\t\t\t\tb.Fatalf(\"%+v\", err)\n\t\t\t\t}\n\t\t\t\tif hdr != nil {\n\t\t\t\t\tb.Fatal(\"Header should be nil\")\n\t\t\t\t}\n\t\t\t\tif len(content) != lenCartExampleHTML {\n\t\t\t\t\tb.Fatalf(\"Want %d\\nHave %d\", lenCartExampleHTML, len(content))\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t})\n}", "func Benchmark(log Log, path string, n, threads int) (float64, error) {\n\t// Open the log at the location\n\tif err := log.Open(path); err != nil {\n\t\treturn 0.0, err\n\t}\n\tdefer log.Close()\n\n\t// Create the action\n\taction := func() error {\n\t\treturn log.Append([]byte(\"foo\"))\n\t}\n\n\t// Create the parallel constructs\n\tgroup := new(sync.WaitGroup)\n\terrors := make([]error, threads)\n\n\t// Run the specified number of Go routines\n\tstart := time.Now()\n\tfor i := 0; i < threads; i++ {\n\t\tgroup.Add(1)\n\t\tgo func(idx int) {\n\t\t\terrors[idx] = benchmarker(n, action)\n\t\t\tgroup.Done()\n\t\t}(i)\n\t}\n\n\t// Wait for the group to complete\n\tgroup.Wait()\n\ttotalLatency := time.Since(start)\n\n\t// Check for errors\n\tfor _, err := range errors {\n\t\tif err != nil {\n\t\t\treturn 0.0, err\n\t\t}\n\t}\n\n\t// Compute the throughput\n\tthroughput := float64(n*threads) / totalLatency.Seconds()\n\treturn throughput, nil\n}", "func (a *APITest) Parallel(description string, doAsFns ...func()) {\n\ta.logger.Info(fmt.Sprintf(\"Parallel: %s\", description))\n\tvar wg sync.WaitGroup\n\twg.Add(len(doAsFns))\n\tfor _, doAsFn := range doAsFns {\n\t\tgo func(doAsFn func()) {\n\t\t\tdefer wg.Done()\n\t\t\tdoAsFn()\n\t\t}(doAsFn)\n\t}\n\twg.Wait()\n}", "func parallelize(repos []initialize.Repo, f func(initialize.Repo, context.Context) error) error {\n\tctx := context.Background()\n\tvar eg errgroup.Group\n\tparallelLimit := semaphore.NewWeighted(10)\n\tfor _, r := range repos {\n\t\teg.Add(1)\n\t\tgo func(repo initialize.Repo) {\n\t\t\tparallelLimit.Acquire(ctx, 1)\n\t\t\tdefer parallelLimit.Release(1)\n\t\t\tdefer eg.Done()\n\n\t\t\terr := f(repo, ctx)\n\t\t\tif err != nil {\n\t\t\t\teg.Error(err)\n\t\t\t\treturn\n\t\t\t}\n\t\t}(r)\n\t}\n\n\treturn eg.Wait()\n}", "func BatchParallel(nJobs, nWorkers, batchSize int, worker func(workerId, beginJobId, endJobId int) error) error {\n\tif nWorkers == 1 {\n\t\treturn worker(0, 0, nJobs)\n\t}\n\tc := make(chan batchJob, chanSize)\n\t// producer\n\tgo func() {\n\t\tfor i := 0; i < nJobs; i += batchSize {\n\t\t\tc <- batchJob{beginId: i, endId: mathutil.Min(i+batchSize, nJobs)}\n\t\t}\n\t\tclose(c)\n\t}()\n\t// consumer\n\tvar wg sync.WaitGroup\n\twg.Add(nWorkers)\n\terrs := make([]error, nJobs)\n\tfor j := 0; j < nWorkers; j++ {\n\t\t// start workers\n\t\tgo func(workerId int) {\n\t\t\tdefer wg.Done()\n\t\t\tfor {\n\t\t\t\t// read job\n\t\t\t\tjob, ok := <-c\n\t\t\t\tif !ok {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\t// run job\n\t\t\t\tif err := worker(workerId, job.beginId, job.endId); err != nil {\n\t\t\t\t\terrs[job.beginId] = err\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}(j)\n\t}\n\twg.Wait()\n\t// check errors\n\tfor _, err := range errs {\n\t\tif err != nil {\n\t\t\treturn errors.Trace(err)\n\t\t}\n\t}\n\treturn nil\n}", "func Parallel(nJobs, nWorkers int, worker func(workerId, jobId int) error) error {\n\tif nWorkers == 1 {\n\t\tfor i := 0; i < nJobs; i++ {\n\t\t\tif err := worker(0, i); err != nil {\n\t\t\t\treturn errors.Trace(err)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tc := make(chan int, chanSize)\n\t\t// producer\n\t\tgo func() {\n\t\t\tfor i := 0; i < nJobs; i++ {\n\t\t\t\tc <- i\n\t\t\t}\n\t\t\tclose(c)\n\t\t}()\n\t\t// consumer\n\t\tvar wg sync.WaitGroup\n\t\twg.Add(nWorkers)\n\t\terrs := make([]error, nJobs)\n\t\tfor j := 0; j < nWorkers; j++ {\n\t\t\t// start workers\n\t\t\tgo func(workerId int) {\n\t\t\t\tdefer wg.Done()\n\t\t\t\tfor {\n\t\t\t\t\t// read job\n\t\t\t\t\tjobId, ok := <-c\n\t\t\t\t\tif !ok {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\t// run job\n\t\t\t\t\tif err := worker(workerId, jobId); err != nil {\n\t\t\t\t\t\terrs[jobId] = err\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}(j)\n\t\t}\n\t\twg.Wait()\n\t\t// check errors\n\t\tfor _, err := range errs {\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Trace(err)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func BenchmarkAPIRequestPublishParallel(b *testing.B) {\n\tapp := NewTestMemoryNode()\n\tjsonData := getPublishJSON(\"channel\")\n\tb.ResetTimer()\n\tb.RunParallel(func(pb *testing.PB) {\n\t\tfor pb.Next() {\n\t\t\t_, err := apiv1.ProcessAPIData(app, jsonData)\n\t\t\tif err != nil {\n\t\t\t\tb.Error(err)\n\t\t\t}\n\t\t}\n\t})\n}", "func Benchmark(b *testing.B) {\n\tBenchmarkCoreSimple(b)\n}", "func (t *T) Parallel()", "func Execute(nbIterations int, work func(int, int), maxCpus ...int) {\n\n\tnbTasks := runtime.NumCPU()\n\tif len(maxCpus) == 1 {\n\t\tnbTasks = maxCpus[0]\n\t}\n\tnbIterationsPerCpus := nbIterations / nbTasks\n\n\t// more CPUs than tasks: a CPU will work on exactly one iteration\n\tif nbIterationsPerCpus < 1 {\n\t\tnbIterationsPerCpus = 1\n\t\tnbTasks = nbIterations\n\t}\n\n\tvar wg sync.WaitGroup\n\n\textraTasks := nbIterations - (nbTasks * nbIterationsPerCpus)\n\textraTasksOffset := 0\n\n\tfor i := 0; i < nbTasks; i++ {\n\t\twg.Add(1)\n\t\t_start := i*nbIterationsPerCpus + extraTasksOffset\n\t\t_end := _start + nbIterationsPerCpus\n\t\tif extraTasks > 0 {\n\t\t\t_end++\n\t\t\textraTasks--\n\t\t\textraTasksOffset++\n\t\t}\n\t\tgo func() {\n\t\t\twork(_start, _end)\n\t\t\twg.Done()\n\t\t}()\n\t}\n\n\twg.Wait()\n}", "func (f Factory) BenchmarkGetMapIDsParallel(b *testing.B, numSegments int, segmentFunc SegmentFunc, filterFunc MapFilterFunc) {\n\ta := f.initAdapterB(b)\n\tdefer f.free(a)\n\n\tfor i := 0; i < numSegments; i++ {\n\t\ta.SaveSegment(segmentFunc(b, numSegments, i))\n\t}\n\n\tfilters := make([]*store.MapFilter, b.N)\n\tfor i := 0; i < b.N; i++ {\n\t\tfilters[i] = filterFunc(b, numSegments, i)\n\t}\n\n\tvar counter uint64\n\n\tb.ResetTimer()\n\tlog.SetOutput(ioutil.Discard)\n\n\tb.RunParallel(func(pb *testing.PB) {\n\t\tfor pb.Next() {\n\t\t\ti := int(atomic.AddUint64(&counter, 1) - 1)\n\t\t\tif s, err := a.GetMapIDs(filters[i]); err != nil {\n\t\t\t\tb.Error(err)\n\t\t\t} else if s == nil {\n\t\t\t\tb.Error(\"s = nil want []string\")\n\t\t\t}\n\t\t}\n\t})\n}", "func BenchmarkParallelGetObject100MbXL(b *testing.B) {\n\tbenchmarkGetObject(b, \"XL\", returnGetObjectBenchmarkParallel(100*1024*1024))\n}", "func Parallel(t *testing.T) {\n\tvalue := os.Getenv(\"CI\")\n\tisCI, err := strconv.ParseBool(value)\n\tif !isCI || err != nil {\n\t\tt.Parallel()\n\t}\n}", "func (b *B) SetParallelism(p int)", "func BenchmarkParallelGetObject100KbXL(b *testing.B) {\n\tbenchmarkGetObject(b, \"XL\", returnGetObjectBenchmarkParallel(100*1024))\n}", "func Benchmark(config *ConfigData, verbose bool) {\n\tnRequests := 5\n\tconcurrency := 1\n\n\tclient := RequestClient{\n\t\tconfig.URL,\n\t\tconfig.Query,\n\t\tconfig.ParamString,\n\t\tconfig.SizeParam,\n\t\tverbose,\n\t}\n\n\tformatter := NewFormatter()\n\n\tch := make(chan time.Duration, concurrency)\n\n\tvaryingSizeRequest := func(size int) []float64 {\n\t\treturn processRun(nRequests, concurrency, ch, func() {\n\t\t\tsendBenchmarkedRequest(&client, config.Fields, size, ch)\n\t\t})\n\t}\n\n\tmin := 1\n\tmax := 15\n\tfor i := min; i <= max; i++ {\n\t\tresults := varyingSizeRequest(i)\n\t\tformatter.AddSizeResults(i, results)\n\n\t\tfmt.Printf(\"For size = %d, results in ms => %v\\n\", i, results)\n\t}\n\n\tformatter.FormatSizes()\n}", "func (f Factory) BenchmarkGetMapIDs100Parallel(b *testing.B) {\n\tf.BenchmarkGetMapIDsParallel(b, 100, RandomSegment, RandomPaginationOffset)\n}", "func MandelbrotParallel(c complex128, r float64, img *image.RGBA) {\n\n\tmax := img.Bounds().Max\n\tscale := r / math.Min(float64(max.X), float64(max.Y))\n\n\tvar wg sync.WaitGroup\n\twg.Add(max.Y)\n\n\tc0 := c - complex(r/2, r/2)\n\tfor y := 0; y < max.Y; y++ {\n\t\tcy := c0 + complex(0, float64(y)*scale)\n\n\t\tgo func(y int) {\n\t\t\tfor x := 0; x < max.X; x++ {\n\t\t\t\tcx := complex(float64(x)*scale, 0)\n\n\t\t\t\tit := Julia(cy+cx, maxit)\n\t\t\t\tif it < maxit {\n\t\t\t\t\timg.Set(x, y, white)\n\t\t\t\t} else {\n\t\t\t\t\timg.Set(x, y, black)\n\t\t\t\t}\n\t\t\t}\n\t\t\twg.Done()\n\t\t}(y)\n\t}\n\n\twg.Wait()\n}", "func testParallelismWithBeverages(bm *BeverageMachine, beverageNames []string) {\n\n\tfmt.Printf(\"\\nstarting test: testParallelismWithBeverages\\n\\n\")\n\n\twg := sync.WaitGroup{}\n\tfor i, beverageName := range beverageNames {\n\t\twg.Add(1)\n\t\tgo func(i int, beverageName string) {\n\t\t\tdefer wg.Done()\n\n\t\t\tfmt.Printf(\"thread %d-> start\\n\", i+1)\n\n\t\t\t//1. get an idle dispenser\n\t\t\tdispenser, err := bm.GetIdleDispenser()\n\t\t\tfor err != nil {\n\t\t\t\tfmt.Printf(\"thread %d-> %s, retrying in 2 seconds...\\n\", i+1, err.Error())\n\t\t\t\ttime.Sleep(2 * time.Second)\n\t\t\t\tdispenser, err = bm.GetIdleDispenser()\n\t\t\t}\n\t\t\tfmt.Printf(\"thread %d-> acquired dispenser %d\\n\", i+1, dispenser.GetId())\n\n\t\t\tfmt.Printf(\"thread %d-> starting to prepare %s on dispenser %d...\\n\", i+1, beverageName, dispenser.GetId())\n\n\t\t\t//2. request the beverage from the dispenser\n\t\t\tbeverage, err := bm.RequestBeverage(dispenser, beverageName)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"thread %d-> dispenser %d says: %s\\n\", i+1, dispenser.GetId(), err.Error())\n\t\t\t\tfmt.Printf(\"thread %d-> end\\n\", i+1)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tfmt.Printf(\"thread %d-> successfully served %s on dispenser %d\\n\", i+1, beverage.GetName(), dispenser.GetId())\n\t\t\tfmt.Printf(\"thread %d-> end\\n\", i+1)\n\t\t}(i, beverageName)\n\t}\n\twg.Wait()\n\n\tfmt.Println(\"\\ncompleted test: testParallelismWithBeverages\\n\")\n}", "func NewParallel() *Parallel {\n\tres := new(Parallel)\n\tres.wg = new(sync.WaitGroup)\n\tres.wgChild = new(sync.WaitGroup)\n\tres.pipes = make([]*Pipeline, 0, 10)\n\treturn res\n}", "func (b *Benchmark) Run() {\n\tfor _, l := range b.network.Layers {\n\t\tl.Randomize()\n\t}\n\n\tfor i := 0; i < 100; i++ {\n\t\tb.printLayerParams()\n\t\tb.trainer.Train()\n\t}\n}", "func parallelBatchCall(log log.Logger, getBatch batchCallContextFn, maxRetry int, maxPerBatch int, maxParallel int) batchCallContextFn {\n\treturn func(ctx context.Context, requests []rpc.BatchElem) error {\n\t\treturn fetchBatched(ctx, log, requests, getBatch, maxRetry, maxPerBatch, maxParallel)\n\t}\n}", "func Run(bTestMode bool) {\n\tvar wg = &sync.WaitGroup{}\n\twg.Add(1)\n\tif bTestMode {\n\t\tgo func(WG *sync.WaitGroup) {\n\t\t\tdefer wg.Done()\n\t\t\tWorker()\n\t\t}(wg)\n\t} else {\n\t\tccutility.WorkerTimer(2, 4, func() {\n\t\t\tWorker()\n\t\t})\n\t}\n\twg.Wait()\n}", "func BenchmarkParallelGetObject25MbXL(b *testing.B) {\n\tbenchmarkGetObject(b, \"XL\", returnGetObjectBenchmarkParallel(25*1024*1024))\n}", "func ParallelLoop(ctx Context, numItems, numParallel int, loopFn func(i int) error) error {\n\tloopCh := make(chan interface{})\n\tgo func() {\n\t\tfor i := 0; i < numItems; i++ {\n\t\t\tloopCh <- i\n\t\t}\n\t\tclose(loopCh)\n\t}()\n\treturn ParallelRead(ctx, loopCh, numParallel, func(item interface{}) error {\n\t\treturn loopFn(item.(int))\n\t})\n}", "func BenchmarkSendRequestParallel(b *testing.B) {\n\tb.RunParallel(func(pb *testing.PB) {\n\t\tvar reqBody interface{}\n\t\tfor pb.Next() {\n\t\t\treqBody = rand.Float32()\n\t\t\tresp, err := delayedBatcher.SendRequestWithTimeout(&reqBody, idleTimeout)\n\t\t\tif err != nil {\n\t\t\t\tb.Errorf(\"Unexpected error: %v\", err)\n\t\t\t}\n\t\t\tif resp != reqBody {\n\t\t\t\tb.Error(\"Response not the same\")\n\t\t\t}\n\t\t}\n\t})\n}", "func BenchmarkCompiled(b *testing.B) {\n\tfor _, test := range ilt.TestData {\n\t\tif !test.Bench {\n\t\t\tcontinue\n\t\t}\n\n\t\tfinder := ast.NewFinder(test.Conf())\n\n\t\tbuilder := NewBuilder(finder)\n\t\texpression, _, err := builder.Compile(test.E)\n\t\tif err != nil {\n\t\t\tb.Fatalf(\"compilation of benchmark expression failed: '%v'\", err)\n\t\t\treturn\n\t\t}\n\n\t\tbag := ilt.NewFakeBag(test.I)\n\n\t\tb.Run(test.TestName(), func(bb *testing.B) {\n\t\t\tfor i := 0; i <= bb.N; i++ {\n\t\t\t\t_, _ = expression.Evaluate(bag)\n\t\t\t}\n\t\t})\n\t}\n}", "func Run(ctx context.Context) error {\n\targsLen := len(mngr.args)\n\tmngr.wkrs = make([]*worker, argsLen)\n\tmngr.pbs = make([]*progressbar, argsLen)\n\tmngr.errChs = make([]chan error, argsLen)\n\twg := new(sync.WaitGroup)\n\tfor i := 0; i < argsLen; i++ {\n\t\twg.Add(1)\n\t\targ := mngr.args[i]\n\t\terrCh := make(chan error, 1)\n\t\tmngr.wkrs[i] = newWorker(arg.name, arg.src, arg.dst, errCh)\n\t\tmngr.pbs[i] = newProgressbar(arg.name, arg.src.Size(), arg.dst, errCh)\n\t\tmngr.errChs[i] = errCh\n\t}\n\n\tlimit := make(chan struct{}, mngr.concurrent)\n\tgo func() {\n\t\tfor i := 0; i < argsLen; i++ {\n\t\t\tlimit <- struct{}{}\n\t\t\tgo func(i int) {\n\t\t\t\tdefer wg.Done()\n\t\t\t\tmngr.wkrs[i].run(ctx)\n\t\t\t\tclose(mngr.errChs[i])\n\t\t\t\t<-limit\n\t\t\t}(i)\n\t\t}\n\t}()\n\n\tif mngr.disableProgressbar {\n\t\twg.Wait()\n\t} else {\n\t\tmngr.printProgressbars(wg)\n\t}\n\n\treturn mngr.composeErrors()\n}", "func multiWork(nums []float64) {\n\tch := make(chan float64)\n\tvar wg sync.WaitGroup\n\twg.Add(len(nums))\n\n\tfor i := 0; i < runtime.NumCPU(); i++ {\n\t\tgo poolWorker(ch, &wg)\n\t}\n\n\tfor _, i := range nums {\n\t\tch <- i\n\t}\n\n\twg.Wait()\n\tclose(ch)\n}", "func Benchmark(fmtt string, args ...string) func() {\n\tstarted := time.Now()\n\treturn func() {\n\t\tTrace.Pipeline(fmt.Sprintf(fmtt, args) + \": \" + string(time.Since(started)))\n\t}\n}", "func (b *Benchmark) Run() {\n\tb.init()\n\n\tb.trainer.Train()\n}", "func BenchmarkSolution(b *testing.B) {\n\tfor name, f := range tests {\n\t\t// TODO: pick a reasonable value for n to benchmark f(n)\n\t\tn := int(math.Pow10(10))\n\t\tRunBenchmark(name, b, f, n)\n\t}\n}", "func (p *Parallel) Run() {\n\tfor _, child := range p.children {\n\t\t// this func will never panic\n\t\tgo func(ch *Parallel) {\n\t\t\tch.Run()\n\t\t\tp.wgChild.Done()\n\t\t}(child)\n\t}\n\tp.wgChild.Wait()\n\tp.do()\n\tp.wg.Wait()\n}", "func BenchmarkParallelGetObject10MbXL(b *testing.B) {\n\tbenchmarkGetObject(b, \"XL\", returnGetObjectBenchmarkParallel(10*1024*1024))\n}", "func Benchmark(f func(b *B)) BenchmarkResult", "func BenchmarkParallelGetObject200MbXL(b *testing.B) {\n\tbenchmarkGetObject(b, \"XL\", returnGetObjectBenchmarkParallel(200*1024*1024))\n}", "func init(){\n\truntime.GOMAXPROCS(runtime.NumCPU())\n\t/*\n\tAs of Go 1.5, this code is unnecessary but what is doing is\n\ttelling Go to use all of the Cores available in the OS to\n\trun the following code. You need more than one Core to execute\n\tparallelism\n\t*/\n}", "func BenchmarkParallelGetObject5MbXL(b *testing.B) {\n\tbenchmarkGetObject(b, \"XL\", returnGetObjectBenchmarkParallel(5*1024*1024))\n}", "func NoParallel() TestOptionsFunc {\n\treturn func(_ *testing.T, test *Test) { test.RunOptions.NoParallel = true }\n}", "func ForN(low, high, step, parallelism int, worker interface{}) error {\n\tif low > high {\n\t\treturn fmt.Errorf(\"low (%d) > high (%d)\", low, high)\n\t}\n\tif step <= 0 {\n\t\treturn fmt.Errorf(\"step (%d) must be positive\", step)\n\t}\n\n\ttyp := reflect.TypeOf(worker)\n\tif typ.Kind() != reflect.Func {\n\t\treturn errors.New(\"parallel.ForN worker must be a function.\")\n\t}\n\tif typ.NumIn() != 1 {\n\t\treturn errors.New(\"parallel.ForN worker must have 1 parameter\")\n\t}\n\tif typ.In(0).Kind() != reflect.Int {\n\t\treturn errors.New(\"parallel.ForN worker must have a int param\")\n\t}\n\tif typ.NumOut() > 1 {\n\t\treturn errors.New(\"parallel.ForN worker must return nothing or error\")\n\t}\n\tif typ.NumOut() == 1 && typ.Out(0).Name() != \"error\" {\n\t\treturn errors.New(\"parallel.ForN worker's return type must be error\")\n\t}\n\n\tchin := make(chan int)\n\tchout := make(chan error)\n\tvar wg sync.WaitGroup\n\twg.Add(parallelism)\n\tvar errs string\n\n\tgo func() {\n\t\tfor i := low; i < high; i += step {\n\t\t\tchin <- i\n\t\t}\n\t\tclose(chin)\n\t}()\n\n\tval := reflect.ValueOf(worker)\n\tfor i := 0; i < parallelism; i++ {\n\t\tgo func(val reflect.Value) {\n\t\t\tdefer wg.Done()\n\t\t\tfor input := range chin {\n\t\t\t\tif typ.NumOut() == 0 { // worker returns nothing\n\t\t\t\t\tval.Call([]reflect.Value{reflect.ValueOf(input)})\n\t\t\t\t} else { // worker returns an error\n\t\t\t\t\tr := val.Call([]reflect.Value{reflect.ValueOf(input)})\n\t\t\t\t\tif r[0].Interface() != nil {\n\t\t\t\t\t\tchout <- r[0].Interface().(error)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}(val)\n\t}\n\n\tgo func() {\n\t\twg.Wait()\n\t\tclose(chout)\n\t}()\n\n\tfor e := range chout {\n\t\terrs += e.Error() + \"\\n\"\n\t}\n\tif len(errs) > 0 {\n\t\treturn errors.New(errs)\n\t}\n\treturn nil\n}", "func (f Factory) BenchmarkGetMapIDs10000Parallel(b *testing.B) {\n\tf.BenchmarkGetMapIDsParallel(b, 10000, RandomSegment, RandomPaginationOffset)\n}", "func BenchmarkStreamPipeline(b *testing.B) {\n\tb.ReportAllocs()\n\tnumbers := gen(1_000_000)\n\tfor i := 0; i < b.N; i++ {\n\t\tfor _, num := range numbers {\n\t\t\tsMultiply(sAdd(sMultiply(num, 2), 1), 2)\n\t\t}\n\t}\n}", "func (p Parallel) NumWorkers() int {\n\ti := int(p)\n\tif i > 0 {\n\t\treturn i\n\t}\n\treturn runtime.GOMAXPROCS(0)\n}", "func Benchmark(f func(b *B)) BenchmarkResult {}", "func BenchmarkParallelGetObject10KbXL(b *testing.B) {\n\tbenchmarkGetObject(b, \"XL\", returnGetObjectBenchmarkParallel(10*1024))\n}", "func do_bench_loop(tid int, msg string, niter int, nsmtpiter int, npopiter int) error {\n\tr := rand.New(rand.NewSource(time.Now().UnixNano()))\n\tfor l := 0; l < niter; l++ {\n\t\tfor i := 0; i < nsmtpiter; i++ {\n\t\t\tu := uint64(r.Int()) % mailboat.NumUsers\n\t\t\tmailboat.Deliver(u, []byte(msg))\n\t\t}\n\t\tfor i := 0; i < npopiter; i++ {\n\t\t\tu := uint64(r.Int()) % mailboat.NumUsers\n\t\t\tmsgs := mailboat.Pickup(u)\n\t\t\tfor _, m := range msgs {\n\t\t\t\tmailboat.Delete(u, m.Id)\n\t\t\t}\n\t\t\tmailboat.Unlock(u)\n\t\t}\n\t}\n\treturn nil\n}", "func parallelize(functions ...func()) {\n\n\t//New WaitGroup for handle goRoutines\n\tvar waitGroup sync.WaitGroup\n\n\t//Add length of goRoutines to run\n\twaitGroup.Add(len(functions))\n\n\t//End of Functions wait for goRoutines to finish=(functionsGoRoutines.length==0)\n\tdefer waitGroup.Wait()\n\n\t//Foreach of functions to execute in goRoutines\n\tfor _, function := range functions {\n\t\tgo func(copy func()) {\n\n\t\t\t//functionsGoRoutines.length -1\n\t\t\tdefer waitGroup.Done()\n\t\t\tcopy()\n\t\t}(function)\n\t}\n}", "func BenchmarkParallelGet(b *testing.B) {\n\treq := &gomemcached.MCRequest{\n\t\tOpcode: gomemcached.GET,\n\t\tKey: []byte(\"k\"),\n\t\tVBucket: 3,\n\t}\n\tbenchmarkParallelCmd(b, req)\n}", "func BenchmarkParallelGetObject1MbXL(b *testing.B) {\n\tbenchmarkGetObject(b, \"XL\", returnGetObjectBenchmarkParallel(1024*1024))\n}", "func (t *Tester) TestFuncMakeParallel() {\n\tfmt.Println(\"Testing Multiple Function Creation in Parallel\")\n\trunners := 5\n\tmeasurement := \"Parallel Function Creation\"\n\trecord := func(len float64) {\n\t\tt.aggregator.RecordValue(measurement, len)\n\t}\n\ttoRun := func(args ...string) {\n\t\tif len(args) < 2 {\n\t\t\tpanic(\"Not enough args to create function\")\n\t\t}\n\t\tname := args[0]\n\t\tlocation := args[1]\n\t\tutil.CreateFunction(name, location)\n\t}\n\tt.aggregator.InitRecord(measurement)\n\tt.aggregator.AssignGraph(\"Creation\", measurement)\n\t// Doing this here to avoid race condition\n\tfor i := 0; i < samples; i++ {\n\t\tfor j := 0; j < runners; j++ {\n\t\t\tt.functions = append(t.functions, fmt.Sprintf(\"parallel%v-%v\", i, j))\n\t\t}\n\t}\n\tfor i := 0; i < samples; i++ {\n\t\targs := []string{fmt.Sprintf(\"parallel%v\", i), testFunc}\n\t\tutil.SyncRunRunners(toRun, record, runners, true, args...)\n\t}\n}", "func benchmark(rounds int) {\n\tfmt.Println(\"Benchmarking\")\n\tvar wg sync.WaitGroup\n\twg.Add(2)\n\n\tstatsCh := make(chan bool)\n\tgo initControllerPubTest(&wg, statsCh, rounds)\n\n\t//Testing:\n\t// Subscriber listening the stats published by the Gnfs\n\tgo initControllerStatsSubTest(&wg, statsCh)\n\twg.Wait()\n}", "func RunBenchmarks(b *testing.B, coll *docstore.Collection) {\n\tdefer coll.Close()\n\tclearCollection(b, coll)\n\tb.Run(\"BenchmarkSingleActionPut\", func(b *testing.B) {\n\t\tbenchmarkSingleActionPut(10, b, coll)\n\t})\n\tb.Run(\"BenchmarkSingleActionGet\", func(b *testing.B) {\n\t\tbenchmarkSingleActionGet(10, b, coll)\n\t})\n\tb.Run(\"BenchmarkActionListPut\", func(b *testing.B) {\n\t\tbenchmarkActionListPut(50, b, coll)\n\t})\n\tb.Run(\"BenchmarkActionListGet\", func(b *testing.B) {\n\t\tbenchmarkActionListGet(100, b, coll)\n\t})\n\tclearCollection(b, coll)\n}", "func BenchmarkRun(b *testing.B) {\n\trng := rand.New(rand.NewSource(1))\n\tctx := context.Background()\n\trunGC := func(eng storage.Engine, old bool, spec randomRunGCTestSpec) (Info, error) {\n\t\trunGCFunc := Run\n\t\tif old {\n\t\t\trunGCFunc = runGCOld\n\t\t}\n\t\tsnap := eng.NewSnapshot()\n\t\tpolicy := zonepb.GCPolicy{TTLSeconds: spec.ttl}\n\t\treturn runGCFunc(ctx, spec.ds.desc(), snap, spec.now,\n\t\t\tCalculateThreshold(spec.now, policy), intentAgeThreshold,\n\t\t\tpolicy,\n\t\t\tNoopGCer{},\n\t\t\tfunc(ctx context.Context, intents []roachpb.Intent) error {\n\t\t\t\treturn nil\n\t\t\t},\n\t\t\tfunc(ctx context.Context, txn *roachpb.Transaction) error {\n\t\t\t\treturn nil\n\t\t\t})\n\t}\n\tmakeTest := func(old bool, spec randomRunGCTestSpec) func(b *testing.B) {\n\t\treturn func(b *testing.B) {\n\t\t\teng := storage.NewDefaultInMemForTesting()\n\t\t\tdefer eng.Close()\n\t\t\tms := spec.ds.dist(b.N, rng).setupTest(b, eng, *spec.ds.desc())\n\t\t\tb.SetBytes(int64(float64(ms.Total()) / float64(b.N)))\n\t\t\tb.ResetTimer()\n\t\t\t_, err := runGC(eng, old, spec)\n\t\t\tb.StopTimer()\n\t\t\trequire.NoError(b, err)\n\t\t}\n\t}\n\tspecsWithTTLs := func(\n\t\tds distSpec, now hlc.Timestamp, ttls []int32,\n\t) (specs []randomRunGCTestSpec) {\n\t\tfor _, ttl := range ttls {\n\t\t\tspecs = append(specs, randomRunGCTestSpec{\n\t\t\t\tds: ds,\n\t\t\t\tnow: now,\n\t\t\t\tttl: ttl,\n\t\t\t})\n\t\t}\n\t\treturn specs\n\t}\n\tts100 := hlc.Timestamp{WallTime: (100 * time.Second).Nanoseconds()}\n\tttls := []int32{0, 25, 50, 75, 100}\n\tspecs := specsWithTTLs(fewVersionsTinyRows, ts100, ttls)\n\tspecs = append(specs, specsWithTTLs(someVersionsMidSizeRows, ts100, ttls)...)\n\tspecs = append(specs, specsWithTTLs(lotsOfVersionsMidSizeRows, ts100, ttls)...)\n\tfor _, old := range []bool{true, false} {\n\t\tb.Run(fmt.Sprintf(\"old=%v\", old), func(b *testing.B) {\n\t\t\tfor _, spec := range specs {\n\t\t\t\tb.Run(fmt.Sprint(spec.ds), makeTest(old, spec))\n\t\t\t}\n\t\t})\n\t}\n}", "func (r *reporter) Parallel() {\n\tr.m.Lock()\n\tif r.isParallel {\n\t\tif r.retryPolicy != nil {\n\t\t\tr.m.Unlock()\n\t\t\treturn\n\t\t}\n\t\tpanic(\"reporter: Reporter.Parallel called multiple times\")\n\t}\n\tr.isParallel = true\n\tr.durationMeasurer.stop()\n\tdefer r.durationMeasurer.start()\n\tr.m.Unlock()\n\n\t// Retry attempts can not be executed in parallel.\n\tif r.retryable {\n\t\tr.parent.Parallel()\n\t\treturn\n\t}\n\n\tif r.context.verbose {\n\t\tr.context.printf(\"=== PAUSE %s\\n\", r.goTestName)\n\t}\n\tr.done <- true // Release calling test.\n\t<-r.parent.barrier // Wait for the parent test to complete.\n\tr.context.waitParallel()\n\n\tif r.context.verbose {\n\t\tr.context.printf(\"=== CONT %s\\n\", r.goTestName)\n\t}\n}", "func init() {\n\truntime.GOMAXPROCS(runtime.NumCPU()) // Use all CPU cores\n}", "func main(){\n\tjobs := make(chan int, 100) //buffered chanel of ints\n\tresult := make(chan int, 100)\n\tvar wg sync.WaitGroup //the mutex\n\twg.Add(1)\n\n\tfibo := 50 //how many numbers we want to calculate\n\n\tgo worker(jobs, result) //parallel workers\n\tgo worker(jobs, result) //parallel workers\n\tgo worker(jobs, result) //parallel workers\n\tgo worker(jobs, result) //parallel workers\n\n\tfor i:=1; i<=fibo; i++ {\n\t\tjobs <- i\n\t}\n\tclose(jobs)\n\n\tgo func() {\n\t\tfor i:=1; i<=fibo; i++ {\n\t\t\tfmt.Printf(\"Number is %v and the result: %+v\\n\", i, <-result)\n\t\t}\n\t\twg.Done()\n\t}()\n\n\twg.Wait()\n\treturn\n}", "func (b *Engine) run() {\n\t// mines blocks from difficulty to when it takes longer than 60 seconds to mine block\n\tb.logger.Log(\"Benchmark: starting benchmark\")\n\tdone := false\n\tclose := make(chan struct{})\n\tdifficulty := 10 //! difficulty starts at 10\n\tgo func() {\n\t\tvar wg sync.WaitGroup\n\t\tfor done == false {\n\t\t\tfor i := 0; i < 3; i++ { //? runs 3 difficulties in parralel to increase benchmark speed\n\t\t\t\twg.Add(1)\n\t\t\t\tgo func(myDifficulty int) { //? mines block of myDifficulty 5 times and adds average time and difficulty\n\t\t\t\t\tvar avg []float64\n\t\t\t\t\tvar mu sync.Mutex\n\t\t\t\t\tvar mineWG sync.WaitGroup\n\t\t\t\t\tfor j := 0; j < 5; j++ {\n\t\t\t\t\t\tmineWG.Add(1)\n\t\t\t\t\t\tgo func() {\n\t\t\t\t\t\t\tstart := time.Now()\n\t\t\t\t\t\t\tblock := b.block(uint8(myDifficulty))\n\t\t\t\t\t\t\tend := time.Now()\n\t\t\t\t\t\t\tblock.DeleteFile()\n\t\t\t\t\t\t\tdiff := end.Sub(start).Seconds()\n\t\t\t\t\t\t\tmu.Lock()\n\t\t\t\t\t\t\tavg = append(avg, diff)\n\t\t\t\t\t\t\tmu.Unlock()\n\t\t\t\t\t\t\tmineWG.Done()\n\t\t\t\t\t\t}()\n\t\t\t\t\t}\n\t\t\t\t\tmineWG.Wait()\n\t\t\t\t\tvar avgSum float64\n\t\t\t\t\tfor _, val := range avg {\n\t\t\t\t\t\tavgSum += val\n\t\t\t\t\t}\n\t\t\t\t\taverage := avgSum / float64(len(avg))\n\t\t\t\t\tif average > float64(60) { // a minute\n\t\t\t\t\t\tdone = true\n\t\t\t\t\t\tclose <- struct{}{}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif done == true {\n\t\t\t\t\t\t\twg.Done()\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tb.addBenchmark(NewBenchmark(average, uint8(myDifficulty)))\n\t\t\t\t\t}\n\t\t\t\t\tb.logger.Log(\"Bechmark: completed benchmark for difficulty \" + strconv.FormatInt(int64(myDifficulty), 10))\n\t\t\t\t\twg.Done()\n\t\t\t\t}(difficulty)\n\t\t\t\tdifficulty++\n\t\t\t}\n\t\t\twg.Wait()\n\t\t}\n\t}()\n\n\t<-close //wait for close signal\n\n\tscore := float64(b.GetData()[len(b.GetData())-1].GetDifficulty()) - 10 //! 10 is subtracted to allow the score start from 1 since difficulty starts at 10\n\tscoreDecimal := 1 - b.GetData()[len(b.GetData())-1].GetAvgTime()/100 // determine decimal part of score\n\tb.setScore(score + scoreDecimal)\n\tb.logger.Info(\"Benchmark: benchmark done\")\n}", "func CommonIsPrimeBenchmark(b *testing.B, checker primes.Checker) {\n\tfor i := 0; i < b.N; i++ {\n\t\tfor j := 0; j < 1000; j++ {\n\t\t\tchecker.IsPrime(j)\n\t\t}\n\t}\n}", "func BenchmarkParallelGetObject50MbXL(b *testing.B) {\n\tbenchmarkGetObject(b, \"XL\", returnGetObjectBenchmarkParallel(50*1024*1024))\n}", "func ParallelWork(ctx Context, numParallel int, genWorkFn GenWorkFn, doWorkFn WorkFn) error {\n\tworkChan := make(chan interface{})\n\tgenErrCh := Async(func() error {\n\t\tdefer close(workChan)\n\t\treturn genWorkFn(workChan)\n\t})\n\treadErrCh := Async(func() error {\n\t\treturn ParallelRead(ctx, workChan, numParallel, doWorkFn)\n\t})\n\n\treturn WaitForErrorChannels(ctx, genErrCh, readErrCh)\n}", "func (s *Scene) RenderParallel(img *image.RGBA, n int) {\n\tvar wg sync.WaitGroup\n\twg.Add(n)\n\n\tfor _, col := range ToColumns(img.Bounds(), n) {\n\t\tsub := img.SubImage(col).(*image.RGBA)\n\n\t\t// Render!\n\t\tgo func() {\n\t\t\ts.Render(sub)\n\t\t\twg.Done()\n\t\t}()\n\t}\n\n\twg.Wait()\n}", "func BenchmarkCoreSimple(b *testing.B) {\n\tfor i := 0; i < b.N; i++ {\n\t\tDoTheThing()\n\t}\n}", "func (api *PrivateLightServerAPI) Benchmark(setups []map[string]interface{}, passCount, length int) ([]map[string]interface{}, error) {\n\tbenchmarks := make([]requestBenchmark, len(setups))\n\tfor i, setup := range setups {\n\t\tif t, ok := setup[\"type\"].(string); ok {\n\t\t\tgetInt := func(field string, def int) int {\n\t\t\t\tif value, ok := setup[field].(float64); ok {\n\t\t\t\t\treturn int(value)\n\t\t\t\t}\n\t\t\t\treturn def\n\t\t\t}\n\t\t\tgetBool := func(field string, def bool) bool {\n\t\t\t\tif value, ok := setup[field].(bool); ok {\n\t\t\t\t\treturn value\n\t\t\t\t}\n\t\t\t\treturn def\n\t\t\t}\n\t\t\tswitch t {\n\t\t\tcase \"header\":\n\t\t\t\tbenchmarks[i] = &benchmarkBlockHeaders{\n\t\t\t\t\tamount: getInt(\"amount\", 1),\n\t\t\t\t\tskip: getInt(\"skip\", 1),\n\t\t\t\t\tbyHash: getBool(\"byHash\", false),\n\t\t\t\t\treverse: getBool(\"reverse\", false),\n\t\t\t\t}\n\t\t\tcase \"body\":\n\t\t\t\tbenchmarks[i] = &benchmarkBodiesOrReceipts{receipts: false}\n\t\t\tcase \"receipts\":\n\t\t\t\tbenchmarks[i] = &benchmarkBodiesOrReceipts{receipts: true}\n\t\t\tcase \"proof\":\n\t\t\t\tbenchmarks[i] = &benchmarkProofsOrCode{code: false}\n\t\t\tcase \"code\":\n\t\t\t\tbenchmarks[i] = &benchmarkProofsOrCode{code: true}\n\t\t\tcase \"cht\":\n\t\t\t\tbenchmarks[i] = &benchmarkHelperTrie{\n\t\t\t\t\tbloom: false,\n\t\t\t\t\treqCount: getInt(\"amount\", 1),\n\t\t\t\t}\n\t\t\tcase \"bloom\":\n\t\t\t\tbenchmarks[i] = &benchmarkHelperTrie{\n\t\t\t\t\tbloom: true,\n\t\t\t\t\treqCount: getInt(\"amount\", 1),\n\t\t\t\t}\n\t\t\tcase \"txSend\":\n\t\t\t\tbenchmarks[i] = &benchmarkTxSend{}\n\t\t\tcase \"txStatus\":\n\t\t\t\tbenchmarks[i] = &benchmarkTxStatus{}\n\t\t\tdefault:\n\t\t\t\treturn nil, ErrUnknownBenchmarkType\n\t\t\t}\n\t\t} else {\n\t\t\treturn nil, ErrUnknownBenchmarkType\n\t\t}\n\t}\n\trs := api.server.protocolManager.runBenchmark(benchmarks, passCount, time.Millisecond*time.Duration(length))\n\tresult := make([]map[string]interface{}, len(setups))\n\tfor i, r := range rs {\n\t\tres := make(map[string]interface{})\n\t\tif r.err == nil {\n\t\t\tres[\"totalCount\"] = r.totalCount\n\t\t\tres[\"avgTime\"] = r.avgTime\n\t\t\tres[\"maxInSize\"] = r.maxInSize\n\t\t\tres[\"maxOutSize\"] = r.maxOutSize\n\t\t} else {\n\t\t\tres[\"error\"] = r.err.Error()\n\t\t}\n\t\tresult[i] = res\n\t}\n\treturn result, nil\n}", "func (c *Context) Parallel() {\n\tc.T.Parallel()\n}", "func BenchmarkTChannelFetchBatch(\n\taddress string,\n\tn, connectionsPerHost, concurrency, batchLen int,\n\tnextRequest bench.RequestGenerator,\n\tready chan<- struct{},\n\tstart <-chan struct{},\n\tdone chan<- []error,\n) {\n\tlb := newClientRoundRobinLB(address, connectionsPerHost)\n\tdefer lb.closeAll()\n\n\tworkers := bench.NewWorkerPool(concurrency)\n\n\tfetchRequestPool := sync.Pool{\n\t\tNew: func() interface{} {\n\t\t\treturn &node.FetchBatchRequest{}\n\t\t},\n\t}\n\n\tvar errLock sync.Mutex\n\tvar errs []error\n\n\tready <- struct{}{}\n\t<-start\n\n\tvar wg sync.WaitGroup\n\tfor i := 0; i < n; i++ {\n\t\tdesc := nextRequest()\n\n\t\twg.Add(1)\n\t\tworkers.Go(func() {\n\t\t\tvar batchesWg sync.WaitGroup\n\n\t\t\tidsLen := len(desc.IDs)\n\n\t\t\tfor j := 0; j < idsLen; j += batchLen {\n\t\t\t\tdesc := desc\n\t\t\t\tj := j\n\n\t\t\t\tbatchesWg.Add(1)\n\t\t\t\tworkers.Go(func() {\n\t\t\t\t\treq := fetchRequestPool.Get().(*node.FetchBatchRequest)\n\t\t\t\t\treq.StartUnixMs = desc.StartUnixMs\n\t\t\t\t\treq.EndUnixMs = desc.EndUnixMs\n\n\t\t\t\t\tk := minInt(j+batchLen, idsLen)\n\t\t\t\t\treq.Ids = desc.IDs[j:k]\n\n\t\t\t\t\ttctx, _ := thrift.NewContext(24 * time.Hour)\n\t\t\t\t\t_, err := lb.get().client.FetchBatch(tctx, req)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\terrLock.Lock()\n\t\t\t\t\t\terrs = append(errs, err)\n\t\t\t\t\t\terrLock.Unlock()\n\t\t\t\t\t}\n\t\t\t\t\tfetchRequestPool.Put(req)\n\t\t\t\t\tbatchesWg.Done()\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tbatchesWg.Wait()\n\t\t\twg.Done()\n\t\t})\n\t}\n\n\twg.Wait()\n\n\tdone <- errs\n}", "func BenchmarkConcurrentTaskRoutine(t *testing.B) {\n\tt.StartTimer()\n\tsum := 0\n\tvar wg sync.WaitGroup\n\tfor i := 0; i < 10000; i++ {\n\t\tgo func(i int) {\n\t\t\tdefer func() {\n\t\t\t\twg.Done()\n\t\t\t}()\n\t\t\ttime.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)\n\t\t\tsum += 1\n\t\t\twg.Add(1)\n\t\t}(i)\n\t}\n\twg.Wait()\n}", "func TestMemory_WMIConcurrent(t *testing.T) {\n\tif os.Getenv(\"TEST_MEM\") == \"\" {\n\t\tt.Skip(\"Skipping TestMemory_WMIConcurrent; $TEST_MEM is not set\")\n\t}\n\n\tfmt.Println(\"Total Iterations:\", memReps)\n\tfmt.Println(\"No panics mean it succeeded. Other errors are OK. Private Memory should stabilize after ~1500 iterations.\")\n\truntime.GOMAXPROCS(2)\n\n\tstart := time.Now()\n\tvar wg sync.WaitGroup\n\twg.Add(2)\n\tgo func() {\n\t\tfor i := 0; i < memReps; i++ {\n\t\t\tif i%500 == 0 {\n\t\t\t\tprivateMB, allocMB, allocTotalMB := getMemoryUsageMB(t)\n\t\t\t\tfmt.Printf(\"Time: %4ds Count: %5d \", time.Now().Sub(start)/time.Second, i)\n\t\t\t\tprintlnMemUsage(privateMB, allocMB, allocTotalMB)\n\t\t\t}\n\t\t\tvar dst []Win32_PerfRawData_PerfDisk_LogicalDisk\n\t\t\tq := CreateQuery(&dst, \"\")\n\t\t\terr := Query(q, &dst)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(\"ERROR disk\", err)\n\t\t\t}\n\t\t}\n\t\twg.Done()\n\t}()\n\tgo func() {\n\t\tfor i := 0; i > -memReps; i-- {\n\t\t\tvar dst []Win32_OperatingSystem\n\t\t\tq := CreateQuery(&dst, \"\")\n\t\t\terr := Query(q, &dst)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(\"ERROR OS\", err)\n\t\t\t}\n\t\t}\n\t\twg.Done()\n\t}()\n\twg.Wait()\n\tfmt.Printf(\"Final Time: %4ds\\n\", time.Now().Sub(start)/time.Second)\n}", "func BenchmarkRSWAESManyN8_T1000000000(b *testing.B) {\n\tsolveRSWAESConcurrentBench(uint64(1000000000), uint64(8), b)\n\treturn\n}", "func BenchmarkParallelGetObject500MbXL(b *testing.B) {\n\tbenchmarkGetObject(b, \"XL\", returnGetObjectBenchmarkParallel(500*1024*1024))\n}", "func benchmarkCommand(b *testing.B, cmd string, args ...interface{}) {\n\ttestingSetUp()\n\tdefer testingTearDown()\n\tfor i := 0; i < b.N; i++ {\n\t\tconn := testPool.NewConn()\n\t\tif _, err := conn.Do(cmd, args...); err != nil {\n\t\t\t_ = conn.Close()\n\t\t\tb.Fatal(err)\n\t\t}\n\t\t_ = conn.Close()\n\t}\n}", "func BenchmarkParallelGetObject1GbXL(b *testing.B) {\n\tbenchmarkGetObject(b, \"XL\", returnGetObjectBenchmarkParallel(1024*1024*1024))\n}", "func Parallel() *parallel {\n\tp := new(parallel)\n\tp.init()\n\treturn p\n}", "func BenchmarkFib(b *testing.B) {\n\tb.Run(\"Fib1\", func(b *testing.B) {\n\t\tfor i := 0; i < b.N; i++ {\n\t\t\tfib1(20)\n\t\t}\n\t})\n\tb.Run(\"Fib2\", func(b *testing.B) {\n\t\tfor i := 0; i < b.N; i++ {\n\t\t\tfib2(20)\n\t\t}\n\t})\n\tb.Run(\"Fib3\", func(b *testing.B) {\n\t\tfor i := 0; i < b.N; i++ {\n\t\t\tfib3(20)\n\t\t}\n\t})\n}", "func BenchmarkSave100(b *testing.B) {\n\ttestingSetUp()\n\tdefer testingTearDown()\n\n\tmodels := createTestModels(100)\n\tb.ResetTimer()\n\n\tfor i := 0; i < b.N; i++ {\n\t\tb.StopTimer()\n\t\tt := testPool.NewTransaction()\n\t\tfor _, model := range models {\n\t\t\tt.Save(testModels, model)\n\t\t}\n\t\tb.StartTimer()\n\t\tif err := t.Exec(); err != nil {\n\t\t\tb.Fatal(err)\n\t\t}\n\t}\n}", "func threadsPoolManager(tPoolNum chan int) {\n\t// So that we run only 10 at a time\n\tfor counter := 0; counter < 100; counter++ {\n\t\ttPoolNum <- counter\n\t}\n}", "func BenchmarkRSWAESManyN8_T5000000(b *testing.B) {\n\tsolveRSWAESConcurrentBench(uint64(5000000), uint64(8), b)\n\treturn\n}", "func (mc *MultiCase) Benchmark(client *QueryClient) error {\n\tfor _, tcase := range mc.Cases {\n\t\tif err := tcase.Benchmark(client); err != nil {\n\t\t\tclient.Rollback()\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func BatchWriteBenchmark(b *testing.B, create CreateFunc, batchSize int) {\n\tdb, destroy, err := create()\n\ttestutil.Fatalf(b, \"CreateFunc error: %v\", err)\n\tdefer func() {\n\t\ttestutil.Fatalf(b, \"db close error: %v\", db.Close(ctx))\n\t\ttestutil.Fatalf(b, \"DestroyFunc error: %v\", destroy())\n\t}()\n\n\tkeyBuf := make([]byte, keySize)\n\tvalBuf := make([]byte, valSize)\n\tfor i := 0; i < b.N; i++ {\n\t\twr, err := db.Writer(ctx)\n\t\ttestutil.Fatalf(b, \"writer error: %v\", err)\n\t\tfor j := 0; j < batchSize; j++ {\n\t\t\ttestutil.RandBytes(keyBuf)\n\t\t\ttestutil.RandBytes(valBuf)\n\t\t\ttestutil.Fatalf(b, \"write error: %v\", wr.Write(keyBuf, valBuf))\n\t\t}\n\t\ttestutil.Fatalf(b, \"writer close error: %v\", wr.Close())\n\t}\n}", "func TestGoroutineParallelism2(t *testing.T) {\n\t//testGoroutineParallelism2(t, false, false)\n\ttestGoroutineParallelism2(t, true, false)\n\ttestGoroutineParallelism2(t, false, true)\n\ttestGoroutineParallelism2(t, true, true)\n}", "func BenchmarkRSWAESManyN8_T50000000000(b *testing.B) {\n\tsolveRSWAESConcurrentBench(uint64(5000000000), uint64(8), b)\n\treturn\n}", "func BenchmarkEncode(b *testing.B) {\n\tfor _, test := range testValidMessages {\n\t\tfor _, want := range test.decodeTo {\n\t\t\topts := proto.MarshalOptions{AllowPartial: *allowPartial}\n\t\t\tb.Run(fmt.Sprintf(\"%s (%T)\", test.desc, want), func(b *testing.B) {\n\t\t\t\tb.RunParallel(func(pb *testing.PB) {\n\t\t\t\t\tfor pb.Next() {\n\t\t\t\t\t\t_, err := opts.Marshal(want)\n\t\t\t\t\t\tif err != nil && !test.partial {\n\t\t\t\t\t\t\tb.Fatal(err)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\t}\n}" ]
[ "0.68615395", "0.59649223", "0.59426546", "0.5708616", "0.5655967", "0.55070496", "0.5472788", "0.5407767", "0.54075474", "0.5368487", "0.5323917", "0.52809924", "0.5219718", "0.5215668", "0.51870924", "0.5168363", "0.51524377", "0.51412904", "0.51335984", "0.5094116", "0.508722", "0.49887484", "0.49798468", "0.496348", "0.49601504", "0.48716822", "0.48709038", "0.48654783", "0.48540914", "0.4802111", "0.48004922", "0.47954497", "0.47344923", "0.47115818", "0.470873", "0.47012445", "0.46896228", "0.4687376", "0.46861067", "0.4674386", "0.46688485", "0.46442905", "0.46244532", "0.4614703", "0.4606475", "0.45998976", "0.45910293", "0.45670316", "0.45552295", "0.45526853", "0.4546414", "0.4541668", "0.45408982", "0.4530296", "0.452716", "0.45241517", "0.45164526", "0.45099276", "0.45085853", "0.45019612", "0.4499147", "0.4488066", "0.44843325", "0.4481989", "0.44695255", "0.44648984", "0.4456162", "0.44558853", "0.44530043", "0.44283563", "0.4423652", "0.4413063", "0.4404891", "0.44039074", "0.43956843", "0.43811312", "0.43733004", "0.43731016", "0.43721607", "0.43721175", "0.43714684", "0.43685785", "0.435794", "0.4349893", "0.4345694", "0.43444857", "0.4332725", "0.4329783", "0.4327405", "0.43193364", "0.43167785", "0.4312119", "0.429405", "0.42932314", "0.42900977", "0.4286751", "0.428507", "0.42827952", "0.42773634", "0.4274033" ]
0.6838596
1
Benchmark benchmarks a single function. It is useful for creating custom benchmarks that do not use the "go test" command. If f depends on testing flags, then Init must be used to register those flags before calling Benchmark and before calling flag.Parse. If f calls Run, the result will be an estimate of running all its subbenchmarks that don't call Run in sequence in a single benchmark.
func Benchmark(f func(b *B)) BenchmarkResult {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func RunBenchmark(b *testing.B, version int, f func(*Anwork, int)) {\n\ta, err := MakeAnwork(version)\n\tif err != nil {\n\t\tb.Fatal(err)\n\t}\n\tdefer a.Close()\n\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tf(a, i)\n\t}\n}", "func RunBenchmark(name string, b *testing.B, f Func, n int) {\n\tb.Run(name, func(b *testing.B) {\n\t\tb.Logf(\"f(%d), loop (b.N) = %d\\n\", n, b.N)\n\t\tfor i := 0; i < b.N; i++ {\n\t\t\tf(n)\n\t\t}\n\t})\n}", "func Benchmark(f func(b *B)) BenchmarkResult", "func Benchmark(b *testing.B) {\n\tBenchmarkCoreSimple(b)\n}", "func RunFunc(benchmarkFunc func() int, duration time.Duration, c int) *Result {\n\tworkers := make([]Worker, c)\n\tfor i := 0; i < c; i++ {\n\t\tworkers[i] = &funcWorker{ID: i, benchmarkFunc: benchmarkFunc}\n\t}\n\treturn Run(workers, duration)\n}", "func benchmarker(n int, f action) (err error) {\n\tfor i := 0; i < n; i++ {\n\t\tif err = f(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func Benchmark(start time.Time, message string, alwaysRun ...bool) {\n\n\t// Check variadic args (used to mimic optional parameters).\n\tif len(alwaysRun) == 1 {\n\t\t// Optionally run benchmark even if user didn't pass flag.\n\t\tbenchmarkFlag = alwaysRun[0]\n\t}\n\n\telapsed := time.Since(start)\n\n\t// If the --benchmark flag is true.\n\tif benchmarkFlag {\n\t\tfmt.Printf(\"%s took %s\\n\", message, elapsed)\n\t}\n}", "func BenchmarkMain(b *testing.B) {\n\tfor n:=0; n < b.N; n++ {\n\t\tmain()\n\t}\n}", "func (b *Benchmark) Run() {\n\tb.init()\n\n\tb.trainer.Train()\n}", "func BenchmarkSolution(b *testing.B) {\n\tfor name, f := range tests {\n\t\t// TODO: pick a reasonable value for n to benchmark f(n)\n\t\tn := int(math.Pow10(10))\n\t\tRunBenchmark(name, b, f, n)\n\t}\n}", "func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []InternalBenchmark) {}", "func Benchmark(fmtt string, args ...string) func() {\n\tstarted := time.Now()\n\treturn func() {\n\t\tTrace.Pipeline(fmt.Sprintf(fmtt, args) + \": \" + string(time.Since(started)))\n\t}\n}", "func (t *TestCluster) Run(name string, f func(c TestCluster)) bool {\n\tif t.FailFast && t.hasFailure {\n\t\treturn t.H.Run(name, func(h *harness.H) {\n\t\t\tfunc(c TestCluster) {\n\t\t\t\tc.Skip(\"A previous test has already failed\")\n\t\t\t}(TestCluster{H: h, Cluster: t.Cluster})\n\t\t})\n\t}\n\tt.hasFailure = !t.H.Run(name, func(h *harness.H) {\n\t\tf(TestCluster{H: h, Cluster: t.Cluster})\n\t})\n\treturn !t.hasFailure\n\n}", "func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []InternalBenchmark)", "func (t *T) Run(name string, f interface{}) bool {\n\tt.Helper()\n\tt.validateCallback(f)\n\n\treturn t.T.Run(name, func(test *testing.T) {\n\t\tt.invoke(f, test)\n\t})\n}", "func Run(name string, t testing.TB, f func(testing.TB)) {\n\tif tt, ok := t.(*testing.T); ok {\n\t\ttt.Run(name, func(ttt *testing.T) { f(ttt) })\n\t\treturn\n\t}\n\tif tb, ok := t.(*testing.B); ok {\n\t\ttb.Run(name, func(ttb *testing.B) { f(ttb) })\n\t\treturn\n\t}\n\tt.Error(\"invalid test harness\")\n\tt.FailNow()\n}", "func Init(cmd *cobra.Command) {\n\tapi.RegisterBenchmark(&benchEthBlockNumber{})\n\tapi.RegisterBenchmark(&benchNetVersion{})\n\tapi.RegisterBenchmark(&benchEthGetBlockByNumber{})\n}", "func (api *PrivateLightServerAPI) Benchmark(setups []map[string]interface{}, passCount, length int) ([]map[string]interface{}, error) {\n\tbenchmarks := make([]requestBenchmark, len(setups))\n\tfor i, setup := range setups {\n\t\tif t, ok := setup[\"type\"].(string); ok {\n\t\t\tgetInt := func(field string, def int) int {\n\t\t\t\tif value, ok := setup[field].(float64); ok {\n\t\t\t\t\treturn int(value)\n\t\t\t\t}\n\t\t\t\treturn def\n\t\t\t}\n\t\t\tgetBool := func(field string, def bool) bool {\n\t\t\t\tif value, ok := setup[field].(bool); ok {\n\t\t\t\t\treturn value\n\t\t\t\t}\n\t\t\t\treturn def\n\t\t\t}\n\t\t\tswitch t {\n\t\t\tcase \"header\":\n\t\t\t\tbenchmarks[i] = &benchmarkBlockHeaders{\n\t\t\t\t\tamount: getInt(\"amount\", 1),\n\t\t\t\t\tskip: getInt(\"skip\", 1),\n\t\t\t\t\tbyHash: getBool(\"byHash\", false),\n\t\t\t\t\treverse: getBool(\"reverse\", false),\n\t\t\t\t}\n\t\t\tcase \"body\":\n\t\t\t\tbenchmarks[i] = &benchmarkBodiesOrReceipts{receipts: false}\n\t\t\tcase \"receipts\":\n\t\t\t\tbenchmarks[i] = &benchmarkBodiesOrReceipts{receipts: true}\n\t\t\tcase \"proof\":\n\t\t\t\tbenchmarks[i] = &benchmarkProofsOrCode{code: false}\n\t\t\tcase \"code\":\n\t\t\t\tbenchmarks[i] = &benchmarkProofsOrCode{code: true}\n\t\t\tcase \"cht\":\n\t\t\t\tbenchmarks[i] = &benchmarkHelperTrie{\n\t\t\t\t\tbloom: false,\n\t\t\t\t\treqCount: getInt(\"amount\", 1),\n\t\t\t\t}\n\t\t\tcase \"bloom\":\n\t\t\t\tbenchmarks[i] = &benchmarkHelperTrie{\n\t\t\t\t\tbloom: true,\n\t\t\t\t\treqCount: getInt(\"amount\", 1),\n\t\t\t\t}\n\t\t\tcase \"txSend\":\n\t\t\t\tbenchmarks[i] = &benchmarkTxSend{}\n\t\t\tcase \"txStatus\":\n\t\t\t\tbenchmarks[i] = &benchmarkTxStatus{}\n\t\t\tdefault:\n\t\t\t\treturn nil, ErrUnknownBenchmarkType\n\t\t\t}\n\t\t} else {\n\t\t\treturn nil, ErrUnknownBenchmarkType\n\t\t}\n\t}\n\trs := api.server.protocolManager.runBenchmark(benchmarks, passCount, time.Millisecond*time.Duration(length))\n\tresult := make([]map[string]interface{}, len(setups))\n\tfor i, r := range rs {\n\t\tres := make(map[string]interface{})\n\t\tif r.err == nil {\n\t\t\tres[\"totalCount\"] = r.totalCount\n\t\t\tres[\"avgTime\"] = r.avgTime\n\t\t\tres[\"maxInSize\"] = r.maxInSize\n\t\t\tres[\"maxOutSize\"] = r.maxOutSize\n\t\t} else {\n\t\t\tres[\"error\"] = r.err.Error()\n\t\t}\n\t\tresult[i] = res\n\t}\n\treturn result, nil\n}", "func New(exec string, opts ...option) *Benchmark {\n\tret := &Benchmark{\n\t\texecutable: exec,\n\t}\n\tfor _, opt := range opts {\n\t\topt(ret)\n\t}\n\treturn ret\n}", "func (bm *DockerBenchmarker) RunBenchmark() {\n\n\t// CIS 4.1 Create a user for the container\n\tbm.CheckNonRootUser()\n\n\t// CIS 4.2 Use trusted base images for containers\n\tbm.CheckTrustedBaseImages()\n\n\t// CIS 4.3 Do not install unnecessary packages in the container\n\tbm.CheckDisallowedPackages()\n\n\t// CIS 4.6 add HEALTHCHECK instruction to the container image\n\tbm.CheckHealthCheck()\n\n\t// CIS 4.7 Do not use update instructions alone in the Dockerfile\n\tbm.CheckRunUpdateOnly()\n\n\t// CIS 4.9 Use COPY instead of ADD in Dockerfile\n\tbm.CheckAdd()\n\n\t// CIS 4.10 Do not store secrets in Dockerfiles\n\tbm.CheckSecretsInsideImage()\n}", "func Run(t *testing.T, text string, f func(*testing.T, G, S), opts ...Option) bool {\n\tt.Helper()\n\tcfg := options(opts).apply()\n\tn := &node{\n\t\ttext: []string{text},\n\t\tseed: defaultZero64(cfg.seed, time.Now().Unix()),\n\t\torder: cfg.order.or(orderSequential),\n\t\tscope: cfg.scope.or(scopeLocal),\n\t\tnest: cfg.nest.or(nestOff),\n\t\tpend: cfg.pend,\n\t\tfocus: cfg.focus,\n\t}\n\treport := cfg.report\n\tplan := n.parse(f)\n\n\tvar specs chan Spec\n\tif report != nil {\n\t\treport.Start(t, plan)\n\t\tspecs = make(chan Spec, plan.Total)\n\t\tdone := make(chan struct{})\n\t\tdefer func() {\n\t\t\tclose(specs)\n\t\t\t<-done\n\t\t}()\n\t\tgo func() {\n\t\t\treport.Specs(t, specs)\n\t\t\tclose(done)\n\t\t}()\n\t}\n\n\treturn n.run(t, func(t *testing.T, n node) {\n\t\tt.Helper()\n\t\tbuffer := &bytes.Buffer{}\n\t\tdefer func() {\n\t\t\tif specs == nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tspecs <- Spec{\n\t\t\t\tText: n.text,\n\t\t\t\tFailed: t.Failed(),\n\t\t\t\tSkipped: t.Skipped(),\n\t\t\t\tFocused: n.focus,\n\t\t\t\tParallel: n.order == orderParallel,\n\t\t\t\tOut: buffer,\n\t\t\t}\n\t\t}()\n\t\tswitch {\n\t\tcase n.pend, plan.HasFocus && !n.focus:\n\t\t\tt.SkipNow()\n\t\tcase n.order == orderParallel:\n\t\t\tt.Parallel()\n\t\t}\n\t\tvar (\n\t\t\tspec, group func()\n\t\t\tbefore, after []func()\n\t\t\tafterIdx int\n\t\t)\n\t\tgroup = func() {}\n\n\t\tf(t, func(_ string, f func(), _ ...Option) {\n\t\t\tswitch {\n\t\t\tcase len(n.loc) == 1, n.loc[0] > 0:\n\t\t\t\tn.loc[0]--\n\t\t\tcase n.loc[0] == 0:\n\t\t\t\tgroup = func() {\n\t\t\t\t\tn.loc = n.loc[1:]\n\t\t\t\t\tafterIdx = 0\n\t\t\t\t\tgroup = func() {}\n\t\t\t\t\tf()\n\t\t\t\t\tgroup()\n\t\t\t\t}\n\t\t\t\tn.loc[0]--\n\t\t\t}\n\t\t}, func(_ string, f func(), opts ...Option) {\n\t\t\tcfg := options(opts).apply()\n\t\t\tswitch {\n\t\t\tcase cfg.out != nil:\n\t\t\t\tcfg.out(buffer)\n\t\t\tcase cfg.before:\n\t\t\t\tbefore = append(before, f)\n\t\t\tcase cfg.after:\n\t\t\t\tafter = insert(after, f, afterIdx)\n\t\t\t\tafterIdx++\n\t\t\tcase spec != nil:\n\t\t\tcase len(n.loc) > 1, n.loc[0] > 0:\n\t\t\t\tn.loc[0]--\n\t\t\tdefault:\n\t\t\t\tspec = f\n\t\t\t}\n\t\t})\n\t\tgroup()\n\n\t\tif spec == nil {\n\t\t\tt.Fatal(\"Failed to locate spec.\")\n\t\t}\n\t\tdefer run(t, after...)\n\t\trun(t, before...)\n\t\trun(t, spec)\n\t})\n}", "func perfTest(arg perfArg, f func()) (res perfResult) {\n\t// Pipeline: request generator -> workers -> sampler\n\tendUtil := startUtil()\n\n\t// Generate requests until arg.dur elapses\n\tstop := time.NewTimer(arg.dur)\n\tdefer stop.Stop()\n\tvar send *time.Ticker\n\tif arg.interval > 0 {\n\t\tsend = time.NewTicker(arg.interval)\n\t\tdefer send.Stop()\n\t}\n\trequests := make(chan time.Time, arg.maxq)\n\tgo func() {\n\t\tdefer close(requests)\n\t\tfor {\n\t\t\tif send == nil {\n\t\t\t\t// No request interval: send whenever the queue has space.\n\t\t\t\tselect {\n\t\t\t\tcase <-stop.C:\n\t\t\t\t\treturn\n\t\t\t\tcase requests <- time.Now():\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Attempt to send a request periodically, drop if queue is full.\n\t\t\t\tselect {\n\t\t\t\tcase <-stop.C:\n\t\t\t\t\treturn\n\t\t\t\tcase <-send.C:\n\t\t\t\t}\n\t\t\t\tselect {\n\t\t\t\tcase requests <- time.Now():\n\t\t\t\tdefault:\n\t\t\t\t\tres.drops++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\t// Workers run f until requests closed.\n\tdurations := make(chan time.Duration)\n\tvar wg sync.WaitGroup\n\twg.Add(arg.par)\n\tfor i := 0; i < arg.par; i++ {\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\tfor start := range requests {\n\t\t\t\tqueueTime := time.Since(start)\n\t\t\t\t_ = queueTime // not currently used\n\t\t\t\tstart = time.Now()\n\t\t\t\tf()\n\t\t\t\tdurations <- time.Since(start)\n\t\t\t}\n\t\t}()\n\t}\n\tgo func() {\n\t\twg.Wait()\n\t\tclose(durations)\n\t}()\n\n\t// Sampler populates result with samples.\n\tres.par = arg.par\n\tres.sampler = newSampler()\n\tdefer res.sampler.close()\n\tfor elapsed := range durations {\n\t\tres.sampler.add(elapsed)\n\t}\n\tres.walltime, res.exectime = endUtil()\n\treturn\n}", "func Run(f func(r Reporter), opts ...Option) bool {\n\tr := run(f, opts...)\n\treturn !r.Failed()\n}", "func Run(fn WorkerFn, n int) *Function {\n\tf := &Function{\n\t\tfn: fn,\n\t\tn: n,\n\t\tresHandler: dummyResHandler,\n\t\terrHandler: dummyErrHandler,\n\t}\n\tf.Reset()\n\treturn f\n}", "func (b *T) Run(name string, f func(t *T)) bool {\n\tsuccess := true\n\tif b.tracker.Active() {\n\t\tsuccess = success && b.t.Run(name, func(t *testing.T) {\n\t\t\tf(&T{t, t, b.tracker.SubTracker()})\n\t\t})\n\t}\n\treturn success\n}", "func SetUpBenchmark(ctx context.Context) (cleanUp func(ctx context.Context), err error) {\n\tconst cleanupTime = 10 * time.Second // time reserved for cleanup on error.\n\n\tvar restoreScaling func(ctx context.Context) error\n\tvar restoreThrottling func(ctx context.Context) error\n\tcleanUp = func(ctx context.Context) {\n\t\tif restoreScaling != nil {\n\t\t\tif err = restoreScaling(ctx); err != nil {\n\t\t\t\ttesting.ContextLog(ctx, \"Failed to restore CPU frequency scaling to original values: \", err)\n\t\t\t}\n\t\t}\n\t\tif restoreThrottling != nil {\n\t\t\tif err = restoreThrottling(ctx); err != nil {\n\t\t\t\ttesting.ContextLog(ctx, \"Failed to restore CPU thermal throttling to original values: \", err)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Run the cleanUp function automatically if we encounter an error.\n\tdoCleanup := cleanUp\n\tdefer func() {\n\t\tif doCleanup != nil {\n\t\t\tdoCleanup(ctx)\n\t\t}\n\t}()\n\n\t// Run all non-cleanup operations with a shorter context. This ensures\n\t// thermal throttling and CPU frequency scaling get re-enabled, even when\n\t// test execution exceeds the maximum time allowed.\n\tctx, cancel := ctxutil.Shorten(ctx, cleanupTime)\n\tdefer cancel()\n\n\t// CPU frequency scaling and thermal throttling might influence our test results.\n\tif restoreScaling, err = disableCPUFrequencyScaling(ctx); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to disable CPU frequency scaling\")\n\t}\n\tif restoreThrottling, err = disableThermalThrottling(ctx); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to disable thermal throttling\")\n\t}\n\n\t// Disarm running the cleanUp function now that we expect the caller to do it.\n\tdoCleanup = nil\n\treturn cleanUp, nil\n}", "func (b *Benchmark) Run() {\n\tfor _, l := range b.network.Layers {\n\t\tl.Randomize()\n\t}\n\n\tfor i := 0; i < 100; i++ {\n\t\tb.printLayerParams()\n\t\tb.trainer.Train()\n\t}\n}", "func Run(ctx context.Context, f Runner, cycle time.Duration, maxErrs int, c clock.Clock) (ret *Results) {\n\t// TODO: ts_mon stuff.\n\tret = &Results{Success: true}\n\n\ttmr := c.NewTimer(ctx)\n\tdefer tmr.Stop()\n\n\tnextCycle := cycle\n\tconsecErrs := 0\n\tlog := logging.Get(ctx)\n\n\trun := func() {\n\t\texpvars.Add(\"Running\", 1)\n\t\tdefer expvars.Add(\"Running\", -1)\n\t\tdefer expvars.Add(\"Runs\", 1)\n\n\t\tt0 := c.Now()\n\t\t// TODO(seanmccullough) Optionally cancel overruns via context.WithTimeout.\n\t\terr := f(ctx)\n\t\tdur := c.Now().Sub(t0)\n\t\tif dur > cycle {\n\t\t\tlog.Errorf(\"Task overran by %v (%v - %v)\", (dur - cycle), dur, cycle)\n\t\t\tret.Overruns++\n\t\t\texpvars.Add(\"Overruns\", 1)\n\t\t}\n\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Got an error: %v\", err)\n\t\t\tret.Errs++\n\t\t\texpvars.Add(\"Errors\", 1)\n\t\t\tif consecErrs++; consecErrs >= maxErrs {\n\t\t\t\tret.Success = false\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tconsecErrs = 0\n\t\t}\n\n\t\tnextCycle = cycle - dur\n\t\ttmr.Reset(nextCycle)\n\t}\n\n\t// Run f at least once.\n\trun()\n\n\t// Keep running f until ctx is done.\n\tfor {\n\t\tif ar := <-tmr.GetC(); ar.Incomplete() {\n\t\t\treturn ret\n\t\t}\n\t\trun()\n\t\tif !ret.Success {\n\t\t\treturn ret\n\t\t}\n\t}\n}", "func CheckBenchmarkFlag(flag bool) {\n\t// If --benchmark flag is passed by user, this will be set to true.\n\tbenchmarkFlag = flag\n}", "func (r *reporter) Run(name string, f func(t Reporter)) bool {\n\treturn r.runWithRetry(name, f, nil)\n}", "func Run(f func(ctx context.Context, log *zap.Logger) error) {\n\tlog, err := zap.NewDevelopment()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer func() { _ = log.Sync() }()\n\t// No graceful shutdown.\n\tctx := context.Background()\n\tif err := f(ctx, log); err != nil {\n\t\tlog.Fatal(\"Run failed\", zap.Error(err))\n\t}\n\t// Done.\n}", "func NewBenchmark(driver *driver.Driver) *Benchmark {\n\tb := new(Benchmark)\n\n\tb.driver = driver\n\tb.ctx = driver.Init()\n\n\t// b.enableLayerVerification(&b.network)\n\n\treturn b\n}", "func NewBenchmark(serverAddr url.URL, options BenchmarkOptions) *Benchmark {\n\tbenchmark := &Benchmark{\n\t\tserverAddr: serverAddr,\n\t\tstats: NewStats(options),\n\t\toptions: options,\n\t}\n\n\tif options.MinPayloadSize == options.MaxPayloadSize {\n\t\tbenchmark.staticPayload = make([]byte, options.MinPayloadSize)\n\t}\n\n\treturn benchmark\n}", "func (t *Test) Run(fn func(ctx TestContext)) {\n\tstart := time.Now()\n\n\tscopes.CI.Infof(\"=== BEGIN: Test: '%s[%s]' ===\", rt.SuiteContext().Settings().TestID, t.t.Name())\n\tdefer func() {\n\t\tend := time.Now()\n\t\tscopes.CI.Infof(\"=== DONE: Test: '%s[%s] (%v)' ===\", rt.SuiteContext().Settings().TestID, t.t.Name(), end.Sub(start))\n\t}()\n\n\tctx := NewContext(t.t, t.labels...)\n\tdefer ctx.Done(t.t)\n\tfn(ctx)\n}", "func (f MonitorFunc) Stats(cb func(name string, val float64)) { f(cb) }", "func (b *Benchmark) Run(ctx context.Context) (*Result, error) {\n\targs := b.Args()\n\tcmd := testexec.CommandContext(ctx, args[0], args[1:]...)\n\toutput, err := cmd.Output(testexec.DumpLogOnError)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to run the benchmark binary: %s\", b.executable)\n\t}\n\n\tvar ret Result\n\tif err := json.Unmarshal(output, &ret); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to unmarshal output bytes to JSON-based Result\")\n\t}\n\treturn &ret, nil\n}", "func Run(ctx context.Context, tconn *chrome.TestConn, f func(ctx context.Context) error, names ...string) ([]*Histogram, error) {\n\tr, err := StartRecorder(ctx, tconn, names...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := f(ctx); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn r.Histogram(ctx, tconn)\n}", "func BenchmarkFib(b *testing.B) {\n\tb.Run(\"Fib1\", func(b *testing.B) {\n\t\tfor i := 0; i < b.N; i++ {\n\t\t\tfib1(20)\n\t\t}\n\t})\n\tb.Run(\"Fib2\", func(b *testing.B) {\n\t\tfor i := 0; i < b.N; i++ {\n\t\t\tfib2(20)\n\t\t}\n\t})\n\tb.Run(\"Fib3\", func(b *testing.B) {\n\t\tfor i := 0; i < b.N; i++ {\n\t\t\tfib3(20)\n\t\t}\n\t})\n}", "func addBenchmarkFlags(cmd *cobra.Command) {\n\tcmd.Flags().StringVarP(&benchmark, \"benchmark\", \"b\", \"netperf\", \"benchmark program to use\")\n\tcmd.Flags().StringVarP(&runLabel, \"run-label\", \"l\", \"\", \"benchmark run label\")\n\tcmd.Flags().IntVarP(&benchmarkDuration, \"duration\", \"t\", 30, \"benchmark duration (sec)\")\n\tcmd.Flags().BoolVar(&noCleanup, \"no-cleanup\", false, \"do not perform cleanup (delete created k8s resources, etc.)\")\n\tcmd.Flags().StringVar(&cliAffinity, \"client-affinity\", \"different\", \"client affinity (different: different than server, same: same as server, host=XXXX)\")\n\tcmd.Flags().StringVar(&srvAffinity, \"server-affinity\", \"none\", \"server affinity (none, host=XXXX)\")\n\tcmd.Flags().BoolVar(&collectPerf, \"collect-perf\", false, \"collect performance data using perf\")\n\tcmd.Flags().BoolVar(&cliHost, \"cli-on-host\", false, \"run client on host (enables: HostNetwork, HostIPC, HostPID)\")\n\tcmd.Flags().BoolVar(&srvHost, \"srv-on-host\", false, \"run server on host (enables: HostNetwork, HostIPC, HostPID)\")\n\taddNetperfFlags(cmd)\n}", "func Benchmark(b *testing.B) {\n\tcfgFilename := getCfgFilename()\n\tcfgs := GetConfigs(cfgFilename)\n\n\tfor i := 0; i < b.N; i++ {\n\t\tshowGitStatuses(cfgs)\n\t}\n}", "func Benchmark(log Log, path string, n, threads int) (float64, error) {\n\t// Open the log at the location\n\tif err := log.Open(path); err != nil {\n\t\treturn 0.0, err\n\t}\n\tdefer log.Close()\n\n\t// Create the action\n\taction := func() error {\n\t\treturn log.Append([]byte(\"foo\"))\n\t}\n\n\t// Create the parallel constructs\n\tgroup := new(sync.WaitGroup)\n\terrors := make([]error, threads)\n\n\t// Run the specified number of Go routines\n\tstart := time.Now()\n\tfor i := 0; i < threads; i++ {\n\t\tgroup.Add(1)\n\t\tgo func(idx int) {\n\t\t\terrors[idx] = benchmarker(n, action)\n\t\t\tgroup.Done()\n\t\t}(i)\n\t}\n\n\t// Wait for the group to complete\n\tgroup.Wait()\n\ttotalLatency := time.Since(start)\n\n\t// Check for errors\n\tfor _, err := range errors {\n\t\tif err != nil {\n\t\t\treturn 0.0, err\n\t\t}\n\t}\n\n\t// Compute the throughput\n\tthroughput := float64(n*threads) / totalLatency.Seconds()\n\treturn throughput, nil\n}", "func NewBenchmark(driver *driver.Driver) *Benchmark {\n\tb := new(Benchmark)\n\tb.driver = driver\n\tb.context = driver.Init()\n\tb.loadProgram()\n\treturn b\n}", "func Run(top *testing.T, name string, f TestFunc, accessories ...*Accessory) {\n\tif _, previouslyCalled := seen.LoadOrStore(fmt.Sprintf(\"%p\", top), nil); !previouslyCalled {\n\t\ttop.Parallel()\n\t}\n\ttop.Run(name, func(mid *testing.T) {\n\t\tmid.Parallel()\n\t\tctx, cancel := context.WithCancel(context.Background())\n\t\tbottom := testhelper.NewT(ctx, mid)\n\t\tcmd := newCiOperatorCommand(bottom)\n\t\ttestDone, cleanupDone := make(chan struct{}), make(chan struct{})\n\t\tdefer func() {\n\t\t\t// signal to the command that we no longer need to be waiting to\n\t\t\t// interrupt it; then wait for the cleanup routine to finish before\n\t\t\t// we consider the test done\n\t\t\tclose(testDone)\n\t\t\t<-cleanupDone\n\t\t}()\n\t\tcmd.testDone = testDone\n\t\tcmd.cleanupDone = cleanupDone\n\n\t\twg := sync.WaitGroup{}\n\t\twg.Add(len(accessories))\n\t\tfor _, accessory := range accessories {\n\t\t\t// binding the accessory to ctx ensures its lifetime is only\n\t\t\t// as long as the test we are running in this specific case\n\t\t\taccessory.RunFromFrameworkRunner(bottom, ctx, false)\n\t\t\tcmd.AddArgs(accessory.ClientFlags()...)\n\t\t\tgo func(a *Accessory) {\n\t\t\t\tdefer wg.Done()\n\t\t\t\ta.Ready(bottom)\n\t\t\t}(accessory)\n\t\t}\n\t\twg.Wait()\n\n\t\tgo func() {\n\t\t\tdefer func() { cancel() }() // stop waiting for errors\n\t\t\tf(bottom, &cmd)\n\t\t}()\n\n\t\tbottom.Wait()\n\t})\n}", "func benchCode() string {\n consoleCommand := `go test -bench . -benchtime=1s` // Single place to alter the command line command\n output := ``\n\n output += breakspace + cBold + cCyan + \" Golang Function Benchmarks:\" + cClr\n output += breakspace + cYellow + \" > \" + cClr + consoleCommand + breakspace\n\n output += breakspace\n\n testOutput, _ := exec.Command( \"cmd\", \"/c\", consoleCommand ).Output()\n\n // Alternative code:\n //cmd.Stdout = os.Stdout\n //cmd.Run()\n\n return output + statusColorize( string(testOutput) )\n}", "func (q *Query) Run(ctx context.Context, f func(*pb.TestResult) error) error {\n\tif q.PageSize > 0 {\n\t\tpanic(\"PageSize is specified when Query.Run\")\n\t}\n\treturn q.run(ctx, f)\n}", "func Benchmark(t *testing.T, fn Func, sfn func() *optim.Solver, successfrac, avgeval float64) {\n\toptim.Rand = rand.New(rand.NewSource(BenchSeed))\n\tnrun := 44\n\tndrop := 2\n\tnkeep := nrun - 2*ndrop\n\tneval := 0\n\tniter := 0\n\tnsuccess := 0\n\tsum := 0.0\n\n\tsolvs := []*optim.Solver{}\n\tfor i := 0; i < nrun; i++ {\n\t\ts := sfn()\n\n\t\tfor s.Next() {\n\t\t\tif s.Best().Val < fn.Tol() {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif err := s.Err(); err != nil {\n\t\t\tt.Errorf(\"[%v:ERROR] %v\", fn.Name(), err)\n\t\t}\n\n\t\tsolvs = append(solvs, s)\n\t}\n\n\tsort.Sort(byevals(solvs))\n\n\tfor _, s := range solvs[ndrop : len(solvs)-ndrop] {\n\t\tneval += s.Neval()\n\t\tniter += s.Niter()\n\t\tsum += s.Best().Val\n\t\tif s.Best().Val < fn.Tol() {\n\t\t\tnsuccess++\n\t\t}\n\t}\n\n\tfrac := float64(nsuccess) / float64(nkeep)\n\tgotavg := float64(neval) / float64(nkeep)\n\n\tt.Logf(\"[%v] %v/%v runs, %v iters, %v evals, want < %.3f, averaged %.3f\", fn.Name(), nsuccess, nkeep, niter/nkeep, neval/nkeep, fn.Tol(), sum/float64(nkeep))\n\n\tif frac < successfrac {\n\t\tt.Errorf(\" FAIL: only %v/%v runs succeeded, want %v/%v\", nsuccess, nkeep, math.Ceil(successfrac*float64(nkeep)), nkeep)\n\t}\n\n\tif gotavg > avgeval {\n\t\tt.Errorf(\" FAIL: too many evaluations: want %v, averaged %.2f\", avgeval, gotavg)\n\t}\n}", "func NewBenchmarkStat(benchmark bmark.Benchmark, options ...StatType) BenchmarkStat {\n\tbs := BenchmarkStat{benchmark: benchmark}\n\titerations := benchmark.GetIterations()\n\tunits := benchmark.GetUnits()\n\tfunction := benchmark.GetFunction()\n\tfmt.Printf(\"\\nDescription: %s\\n\", color.GreenString(benchmark.GetDesc()))\n\tfmt.Printf(\"Statistics for %s with %d iterations and %v units.\\n\", bmark.GetFunctionName(function), iterations, units)\n\n\tvar m map[string]time.Duration = benchmark.GetStates()\n\tparseOptions(&bs, options, m)\n\n\t// Start the main benchmark\n\t//benchmark.Main()\n\tbs.options = options\n\treturn bs\n}", "func (mc *MultiCase) Benchmark(client *QueryClient) error {\n\tfor _, tcase := range mc.Cases {\n\t\tif err := tcase.Benchmark(client); err != nil {\n\t\t\tclient.Rollback()\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func BenchmarkRun(b *testing.B) {\n\trng := rand.New(rand.NewSource(1))\n\tctx := context.Background()\n\trunGC := func(eng storage.Engine, old bool, spec randomRunGCTestSpec) (Info, error) {\n\t\trunGCFunc := Run\n\t\tif old {\n\t\t\trunGCFunc = runGCOld\n\t\t}\n\t\tsnap := eng.NewSnapshot()\n\t\tpolicy := zonepb.GCPolicy{TTLSeconds: spec.ttl}\n\t\treturn runGCFunc(ctx, spec.ds.desc(), snap, spec.now,\n\t\t\tCalculateThreshold(spec.now, policy), intentAgeThreshold,\n\t\t\tpolicy,\n\t\t\tNoopGCer{},\n\t\t\tfunc(ctx context.Context, intents []roachpb.Intent) error {\n\t\t\t\treturn nil\n\t\t\t},\n\t\t\tfunc(ctx context.Context, txn *roachpb.Transaction) error {\n\t\t\t\treturn nil\n\t\t\t})\n\t}\n\tmakeTest := func(old bool, spec randomRunGCTestSpec) func(b *testing.B) {\n\t\treturn func(b *testing.B) {\n\t\t\teng := storage.NewDefaultInMemForTesting()\n\t\t\tdefer eng.Close()\n\t\t\tms := spec.ds.dist(b.N, rng).setupTest(b, eng, *spec.ds.desc())\n\t\t\tb.SetBytes(int64(float64(ms.Total()) / float64(b.N)))\n\t\t\tb.ResetTimer()\n\t\t\t_, err := runGC(eng, old, spec)\n\t\t\tb.StopTimer()\n\t\t\trequire.NoError(b, err)\n\t\t}\n\t}\n\tspecsWithTTLs := func(\n\t\tds distSpec, now hlc.Timestamp, ttls []int32,\n\t) (specs []randomRunGCTestSpec) {\n\t\tfor _, ttl := range ttls {\n\t\t\tspecs = append(specs, randomRunGCTestSpec{\n\t\t\t\tds: ds,\n\t\t\t\tnow: now,\n\t\t\t\tttl: ttl,\n\t\t\t})\n\t\t}\n\t\treturn specs\n\t}\n\tts100 := hlc.Timestamp{WallTime: (100 * time.Second).Nanoseconds()}\n\tttls := []int32{0, 25, 50, 75, 100}\n\tspecs := specsWithTTLs(fewVersionsTinyRows, ts100, ttls)\n\tspecs = append(specs, specsWithTTLs(someVersionsMidSizeRows, ts100, ttls)...)\n\tspecs = append(specs, specsWithTTLs(lotsOfVersionsMidSizeRows, ts100, ttls)...)\n\tfor _, old := range []bool{true, false} {\n\t\tb.Run(fmt.Sprintf(\"old=%v\", old), func(b *testing.B) {\n\t\t\tfor _, spec := range specs {\n\t\t\t\tb.Run(fmt.Sprint(spec.ds), makeTest(old, spec))\n\t\t\t}\n\t\t})\n\t}\n}", "func Statsf(category string, format string, params ...interface{}) {\n\tDefaultLogger.Statsf(category, format, params...)\n}", "func benchmark(funcName string, number int, w http.ResponseWriter) {\n listofTime := [41]int64{}\n\n for j := 0; j < 40; j++ {\n start := time.Now().UnixNano()\n factorial(number)\n\n // End time\n end := time.Now().UnixNano()\n // Results\n difference := end - start\n listofTime[j] = difference\n\n }\n // Average Time\n sum := int64(0)\n for i := 0; i < len(listofTime); i++ {\n // adding the values of\n // array to the variable sum\n sum += listofTime[i]\n }\n // avg to find the average\n avg := (float64(sum)) / (float64(len(listofTime)))\n\n // Throughput Rate\n throughput := 40/avg\n\n // Response\n fmt.Fprintf(w, \"Time taken by %s function is %v ops/ns \\n\", funcName, throughput)\n}", "func Timing(f func()) int64 {\n\tnow := time.Now().UnixNano()\n\tf()\n\n\treturn time.Now().UnixNano() - now\n}", "func (tc *TestCase) Benchmark(client *QueryClient) error {\n\t_, err := exec(client, tc.Query, tc.BindVars)\n\treturn err\n}", "func (tq TestQuery) Benchmark(client *QueryClient) error {\n\t_, err := exec(client, string(tq), nil)\n\treturn err\n}", "func (wtc *Watcher) Run(f func(*Watcher) error) {\n\tgo func() {\n\t\tfor {\n\t\t\tt := wtc.nextTimer()\n\t\t\t<-t.C\n\t\t\tif err := f(wtc); err != nil {\n\t\t\t\tlogger.Printf(\"RunPeriod, %s\", err)\n\t\t\t}\n\t\t}\n\t}()\n}", "func Call(f func()) {\n\tcheckRun()\n\tdone := make(chan struct{})\n\tcallQueue <- func() {\n\t\tf()\n\t\tdone <- struct{}{}\n\t}\n\t<-done\n}", "func BenchmarkFactory(b *testing.B) {\n\trnd := random.New(random.CryptoSeed{})\n\n\tconst makeCount = 2\n\tb.Run(\"cached\", func(b *testing.B) {\n\t\tf := &random.Factory{}\n\t\tb.ResetTimer()\n\n\t\tfor i := 0; i < b.N; i++ {\n\t\t\tfor i := 0; i < makeCount; i++ {\n\t\t\t\t_ = f.Make(rnd, int(0))\n\t\t\t}\n\t\t}\n\t})\n\tb.Run(\"clean\", func(b *testing.B) {\n\t\tfor i := 0; i < b.N; i++ {\n\t\t\tf := &random.Factory{}\n\t\t\tfor i := 0; i < makeCount; i++ {\n\t\t\t\t_ = f.Make(rnd, int(0))\n\t\t\t}\n\t\t}\n\t})\n}", "func Start(f func(time.Duration) string) *Stopwatch {\n\ts := New(f)\n\ts.Start()\n\n\treturn s\n}", "func simplyRun(f func()) {\n\tgo f()\n}", "func Benchmark(b benchparse.Benchmark, p plotter.Plotter, xName, yName string, options ...plotOption) error {\n\tpltOptions := &plotOptions{\n\t\tgroupBy: []string{},\n\t\tplotTypes: []string{},\n\t\tfilterExprs: []string{},\n\t}\n\tfor _, opt := range options {\n\t\topt.apply(pltOptions)\n\t}\n\n\tvar (\n\t\tres = b.Results\n\t\terr error\n\t)\n\n\tfor _, expr := range pltOptions.filterExprs {\n\t\tres, err = res.Filter(expr)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tgrouped := res.Group(pltOptions.groupBy)\n\tsplitGrouped, err := splitGroupedResult(grouped, xName, yName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"err splitting grouped results: %w\", err)\n\t}\n\n\tif len(pltOptions.plotTypes) == 0 {\n\t\tplotTypes, err := defaultPlotTypes(splitGrouped)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tpltOptions.plotTypes = plotTypes\n\t}\n\n\tfor i, plotType := range pltOptions.plotTypes {\n\t\tincludeLegend := i == 0\n\t\tswitch plotType {\n\t\tcase ScatterType:\n\t\t\tif err := plotScatter(p, b.Name, xName, yName, splitGrouped, includeLegend); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error creating scatter plot: %w\", err)\n\t\t\t}\n\t\tcase AvgLineType:\n\t\t\tif err := plotAvgLine(p, b.Name, xName, yName, splitGrouped, includeLegend); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error creating average line plot: %w\", err)\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unknown plot type: %s\", plotType)\n\t\t}\n\t}\n\treturn nil\n}", "func Benchmark(config *ConfigData, verbose bool) {\n\tnRequests := 5\n\tconcurrency := 1\n\n\tclient := RequestClient{\n\t\tconfig.URL,\n\t\tconfig.Query,\n\t\tconfig.ParamString,\n\t\tconfig.SizeParam,\n\t\tverbose,\n\t}\n\n\tformatter := NewFormatter()\n\n\tch := make(chan time.Duration, concurrency)\n\n\tvaryingSizeRequest := func(size int) []float64 {\n\t\treturn processRun(nRequests, concurrency, ch, func() {\n\t\t\tsendBenchmarkedRequest(&client, config.Fields, size, ch)\n\t\t})\n\t}\n\n\tmin := 1\n\tmax := 15\n\tfor i := min; i <= max; i++ {\n\t\tresults := varyingSizeRequest(i)\n\t\tformatter.AddSizeResults(i, results)\n\n\t\tfmt.Printf(\"For size = %d, results in ms => %v\\n\", i, results)\n\t}\n\n\tformatter.FormatSizes()\n}", "func Test_Run(t *testing.T) {\n\tr := taskrunner.New()\n\tf := false\n\n\tr.Run(\"Name\", func(ctx context.Context) {\n\t\tf = true\n\t})\n\tr.Wait()\n\n\tassert.Equal(t, true, f)\n}", "func (suite FeatureTestSuite) Run(t *testing.T, buildFunc feature.BuildFunc) {\n\tfor _, test := range suite {\n\t\trunTest(t, test, buildFunc)\n\t}\n}", "func BenchmarkRunner_Run(b *testing.B) {\n\tsrv := serverMock()\n\tdefer srv.Close()\n\n\tclient := &http.Client{}\n\tconcurrent := make(chan struct{}, 5)\n\tparser := parsers.NewNasaParser(contextLogger, \"DEMO_KEY\", srv.URL+\"/planetary/apod?api_key=%s&date=%s\", client)\n\trunner := NewRunner(contextLogger, concurrent, parser)\n\n\tfor i := 0; i < b.N; i++ {\n\t\t_, err := runner.Run([]string{\"2019-12-06\", \"2019-12-07\", \"2019-12-10\", \"2019-12-11\", \"2019-12-12\", \"2019-12-14\"})\n\t\tif err != nil {\n\t\t\tb.Fatalf(\"Error: %v\", err)\n\t\t}\n\t}\n}", "func BenchmarkInvoke(b *testing.B) {\n\ttests := []struct {\n\t\tName string\n\t\tFn any\n\t\tOpt *MainInput\n\t\tArgs []any\n\t\tExpected any\n\t}{\n\t\t{\n\t\t\tName: \"Void function\",\n\t\t\tFn: func() {},\n\t\t},\n\t\t{\n\t\t\tName: \"Contexts and errors are allowed and handled\",\n\t\t\tFn: func(ctx context.Context) error { return nil },\n\t\t},\n\t\t{\n\t\t\tName: \"Sum\",\n\t\t\tFn: func(a, b, c int) int { return a + b + c },\n\t\t\tArgs: []any{1, 2, 3},\n\t\t\tExpected: 6,\n\t\t},\n\t\t{\n\t\t\tName: \"Concat\",\n\t\t\tFn: func(a, b, c string) string { return a + b + c },\n\t\t\tArgs: []any{\"a\", \"b\", \"c\"},\n\t\t\tExpected: \"abc\",\n\t\t},\n\t\t{\n\t\t\tName: \"Length (slice type)\",\n\t\t\tFn: func(list []int) (int, error) { return len(list), nil },\n\t\t\tArgs: []any{[]int{1, 2, 3}},\n\t\t\tExpected: 3,\n\t\t},\n\t\t{\n\t\t\tName: \"Emitter\",\n\t\t\tFn: func(emit func(int)) { emit(1) },\n\t\t\tArgs: []any{func(int) {}},\n\t\t},\n\t\t{\n\t\t\tName: \"Side input\",\n\t\t\tFn: func(a int, get func(*int) bool) int {\n\t\t\t\tvar ret int\n\t\t\t\tif !get(&ret) {\n\t\t\t\t\treturn a\n\t\t\t\t}\n\t\t\t\treturn ret\n\t\t\t},\n\t\t\tArgs: []any{1, func(out *int) bool { *out = 2; return true }},\n\t\t\tExpected: 2,\n\t\t},\n\t\t{\n\t\t\tName: \"Sum as Main\",\n\t\t\tFn: func(a, b, c int) int { return a + b + c },\n\t\t\tOpt: &MainInput{Key: FullValue{Elm: 1}},\n\t\t\tArgs: []any{2, 3},\n\t\t\tExpected: 6,\n\t\t},\n\t\t{\n\t\t\tName: \"Sum as Main KV\",\n\t\t\tFn: func(a, b, c int) int { return a + b + c },\n\t\t\tOpt: &MainInput{Key: FullValue{Elm: 1, Elm2: 2}},\n\t\t\tArgs: []any{3},\n\t\t\tExpected: 6,\n\t\t},\n\t\t{\n\t\t\tName: \"EventTime\",\n\t\t\tFn: func(ts typex.EventTime, a int) int { return int(ts.Milliseconds()) + a },\n\t\t\tOpt: &MainInput{Key: FullValue{Elm: 1}},\n\t\t\tExpected: 3,\n\t\t},\n\t\t{\n\t\t\tName: \"Window\",\n\t\t\tFn: func(w typex.Window, a int) int64 { return w.MaxTimestamp().Milliseconds() },\n\t\t\tOpt: &MainInput{Key: FullValue{Elm: 1}},\n\t\t\tExpected: mtime.EndOfGlobalWindowTime.Milliseconds(),\n\t\t},\n\t}\n\n\tfor _, test := range tests {\n\t\tfn, err := funcx.New(reflectx.MakeFunc(test.Fn))\n\t\tif err != nil {\n\t\t\tb.Fatalf(\"function not valid: %v\", err)\n\t\t}\n\n\t\tts := mtime.ZeroTimestamp.Add(2 * time.Millisecond)\n\t\tb.Run(fmt.Sprintf(\"SingleInvoker_%s\", test.Name), func(b *testing.B) {\n\t\t\tfor i := 0; i < b.N; i++ {\n\t\t\t\t_, err := Invoke(context.Background(), typex.NoFiringPane(), window.SingleGlobalWindow, ts, fn, test.Opt, nil, nil, nil, nil, test.Args...)\n\t\t\t\tif err != nil {\n\t\t\t\t\tb.Fatalf(\"Invoke(%v,%v) failed: %v\", fn.Fn.Name(), test.Args, err)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\tb.Run(fmt.Sprintf(\"CachedInvoker_%s\", test.Name), func(b *testing.B) {\n\t\t\tinv := newInvoker(fn)\n\t\t\tfor i := 0; i < b.N; i++ {\n\t\t\t\t_, err := inv.Invoke(context.Background(), typex.NoFiringPane(), window.SingleGlobalWindow, ts, test.Opt, nil, nil, nil, nil, test.Args...)\n\t\t\t\tif err != nil {\n\t\t\t\t\tb.Fatalf(\"Invoke(%v,%v) failed: %v\", fn.Fn.Name(), test.Args, err)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n}", "func BenchmarkCallerAndVFmt(b *testing.B) {\n\tfor i := 0; i < b.N; i++ {\n\t\tfmt.Fprint(ioutil.Discard, stack.Caller(0))\n\t}\n}", "func (t TestCases) Run(fn func(string) (string, string), hideInput bool) {\n\tfor _, test := range t {\n\t\tpart1, part2 := fn(test.Input)\n\t\tpassedPart1 := part1 == test.ExpectedPart1 || test.ExpectedPart1 == \"\"\n\t\tpassedPart2 := part2 == test.ExpectedPart2 || test.ExpectedPart2 == \"\"\n\t\tpassed := passedPart1 && passedPart2\n\n\t\tif !passed && !hideInput {\n\t\t\tfmt.Println(\"Input \", test.Input)\n\t\t}\n\t\tif !passedPart1 {\n\t\t\tfmt.Println(\" - PART1: \", part1, \" but expected \", test.ExpectedPart1)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tif !passedPart2 {\n\t\t\tfmt.Println(\" - PART2: \", part2, \" but expected \", test.ExpectedPart2)\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n}", "func (e *experiment) Run(s ...interface{}) ([]interface{}, ExperimentError) {\n\t// check input first\n\tif len(s) != e.currentFunc.Type().NumIn() {\n\t\treturn nil, fmt.Errorf(\"Number of inputs (%d) is incorrect\", len(s))\n\t}\n\n\tinput := make([]reflect.Value, len(s))\n\tfor i, arg := range s {\n\t\tif t1, t2 := reflect.ValueOf(arg).Type(), e.currentFunc.Type().In(i); t1 != t2 {\n\t\t\treturn nil, fmt.Errorf(\"Incorrect argument type (%d): %s. Expected type %s\", i, t1, t2)\n\t\t}\n\t\tinput[i] = reflect.ValueOf(arg)\n\t}\n\n\tc := make(chan *funcResult, 1)\n\tgo func(ex *experiment) {\n\t\tstart := time.Now()\n\t\tr := ex.improvedFunc.Call(input)\n\t\td := time.Since(start)\n\n\t\toutput := make([]interface{}, len(r))\n\t\tfor i, a := range r {\n\t\t\toutput[i] = a.Interface()\n\t\t}\n\t\tres := &funcResult{\n\t\t\toutput,\n\t\t\td,\n\t\t}\n\n\t\tc <- res\n\t}(e)\n\n\tstart := time.Now()\n\tr := e.currentFunc.Call(input)\n\tcurDuration := time.Since(start)\n\n\t// TODO perhaps use reflect.ValueOf(e.currentFunc).Type().Out()?\n\toutput := make([]interface{}, len(r))\n\tfor i, a := range r {\n\t\toutput[i] = a.Interface()\n\t}\n\n\tvar funcRes *funcResult\n\tselect {\n\tcase funcRes = <-c:\n\tcase <-time.After(e.timeout):\n\t}\n\n\tif funcRes == nil {\n\t\tlog.Printf(\"No experiment outcome, improved func took too long\\n\")\n\t\treturn output, nil\n\t}\n\n\timpr := funcRes.result\n\timprDuration := funcRes.duration\n\n\t// TODO use metrics iso printouts\n\tif imprDuration < curDuration {\n\t\tlog.Printf(\"Improved faster (%s vs. %s)\", curDuration, imprDuration)\n\t} else {\n\t\tlog.Printf(\"Current faster (%s vs. %s)\", curDuration, imprDuration)\n\t}\n\t//\tfmt.Printf(\"Current functionality duration: %s\\n\", curDuration)\n\t//\tfmt.Printf(\"Improved functionality duration: %s\\n\", imprDuration)\n\n\tif !eq(output, impr) {\n\t\tlog.Printf(\"ERROR current result != improvement result for input %+v, choosing current functionality (%+v != %+v)\\n\", s, output, impr)\n\t\treturn output, nil\n\t}\n\n\t// TODO scale improved func up (or down)\n\tif e.r.Intn(100) < e.scaling {\n\t\tlog.Printf(\"Chose improved functionality\\n\")\n\t\treturn impr, nil\n\t}\n\n\tlog.Printf(\"Chose current functionality\\n\")\n\treturn output, nil\n}", "func Run(bTestMode bool) {\n\tvar wg = &sync.WaitGroup{}\n\twg.Add(1)\n\tif bTestMode {\n\t\tgo func(WG *sync.WaitGroup) {\n\t\t\tdefer wg.Done()\n\t\t\tWorker()\n\t\t}(wg)\n\t} else {\n\t\tccutility.WorkerTimer(2, 4, func() {\n\t\t\tWorker()\n\t\t})\n\t}\n\twg.Wait()\n}", "func (f Factory) RunStoreBenchmarks(b *testing.B) {\n\tb.Run(\"BenchmarkCreateLink\", f.BenchmarkCreateLink)\n\tb.Run(\"BenchmarkCreateLinkParallel\", f.BenchmarkCreateLinkParallel)\n\n\tb.Run(\"FindSegments100\", f.BenchmarkFindSegments100)\n\tb.Run(\"FindSegments1000\", f.BenchmarkFindSegments1000)\n\tb.Run(\"FindSegments10000\", f.BenchmarkFindSegments10000)\n\tb.Run(\"FindSegmentsMapID100\", f.BenchmarkFindSegmentsMapID100)\n\tb.Run(\"FindSegmentsMapID1000\", f.BenchmarkFindSegmentsMapID1000)\n\tb.Run(\"FindSegmentsMapID10000\", f.BenchmarkFindSegmentsMapID10000)\n\tb.Run(\"FindSegmentsMapIDs100\", f.BenchmarkFindSegmentsMapIDs100)\n\tb.Run(\"FindSegmentsMapIDs1000\", f.BenchmarkFindSegmentsMapIDs1000)\n\tb.Run(\"FindSegmentsMapIDs10000\", f.BenchmarkFindSegmentsMapIDs10000)\n\tb.Run(\"FindSegmentsPrevLinkHash100\", f.BenchmarkFindSegmentsPrevLinkHash100)\n\tb.Run(\"FindSegmentsPrevLinkHash1000\", f.BenchmarkFindSegmentsPrevLinkHash1000)\n\tb.Run(\"FindSegmentsPrevLinkHash10000\", f.BenchmarkFindSegmentsPrevLinkHash10000)\n\tb.Run(\"FindSegmentsTags100\", f.BenchmarkFindSegmentsTags100)\n\tb.Run(\"FindSegmentsTags1000\", f.BenchmarkFindSegmentsTags1000)\n\tb.Run(\"FindSegmentsTags10000\", f.BenchmarkFindSegmentsTags10000)\n\tb.Run(\"FindSegmentsMapIDTags100\", f.BenchmarkFindSegmentsMapIDTags100)\n\tb.Run(\"FindSegmentsMapIDTags1000\", f.BenchmarkFindSegmentsMapIDTags1000)\n\tb.Run(\"FindSegmentsMapIDTags10000\", f.BenchmarkFindSegmentsMapIDTags10000)\n\tb.Run(\"FindSegmentsPrevLinkHashTags100\", f.BenchmarkFindSegmentsPrevLinkHashTags100)\n\tb.Run(\"FindSegmentsPrevLinkHashTags1000\", f.BenchmarkFindSegmentsPrevLinkHashTags1000)\n\tb.Run(\"FindSegmentsPrevLinkHashTags10000\", f.BenchmarkFindSegmentsPrevLinkHashTags10000)\n\tb.Run(\"FindSegments100Parallel\", f.BenchmarkFindSegments100Parallel)\n\tb.Run(\"FindSegments1000Parallel\", f.BenchmarkFindSegments1000Parallel)\n\tb.Run(\"FindSegments10000Parallel\", f.BenchmarkFindSegments10000Parallel)\n\tb.Run(\"FindSegmentsMapID100Parallel\", f.BenchmarkFindSegmentsMapID100Parallel)\n\tb.Run(\"FindSegmentsMapID1000Parallel\", f.BenchmarkFindSegmentsMapID1000Parallel)\n\tb.Run(\"FindSegmentsMapID10000Parallel\", f.BenchmarkFindSegmentsMapID10000Parallel)\n\tb.Run(\"FindSegmentsMapIDs100Parallel\", f.BenchmarkFindSegmentsMapIDs100Parallel)\n\tb.Run(\"FindSegmentsMapIDs1000Parallel\", f.BenchmarkFindSegmentsMapIDs1000Parallel)\n\tb.Run(\"FindSegmentsMapIDs10000Parallel\", f.BenchmarkFindSegmentsMapIDs10000Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHash100Parallel\", f.BenchmarkFindSegmentsPrevLinkHash100Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHash1000Parallel\", f.BenchmarkFindSegmentsPrevLinkHash1000Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHash10000ParalleRunBenchmarksl\", f.BenchmarkFindSegmentsPrevLinkHash10000Parallel)\n\tb.Run(\"FindSegmentsTags100Parallel\", f.BenchmarkFindSegmentsTags100Parallel)\n\tb.Run(\"FindSegmentsTags1000Parallel\", f.BenchmarkFindSegmentsTags1000Parallel)\n\tb.Run(\"FindSegmentsTags10000Parallel\", f.BenchmarkFindSegmentsTags10000Parallel)\n\tb.Run(\"FindSegmentsMapIDTags100Parallel\", f.BenchmarkFindSegmentsMapIDTags100Parallel)\n\tb.Run(\"FindSegmentsMapIDTags1000Parallel\", f.BenchmarkFindSegmentsMapIDTags1000Parallel)\n\tb.Run(\"FindSegmentsMapIDTags10000Parallel\", f.BenchmarkFindSegmentsMapIDTags10000Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHashTags100Parallel\", f.BenchmarkFindSegmentsPrevLinkHashTags100Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHashTags1000Parallel\", f.BenchmarkFindSegmentsPrevLinkHashTags1000Parallel)\n\tb.Run(\"FindSegmentsPrevLinkHashTags10000Parallel\", f.BenchmarkFindSegmentsPrevLinkHashTags10000Parallel)\n\n\tb.Run(\"GetMapIDs100\", f.BenchmarkGetMapIDs100)\n\tb.Run(\"GetMapIDs1000\", f.BenchmarkGetMapIDs1000)\n\tb.Run(\"GetMapIDs10000\", f.BenchmarkGetMapIDs10000)\n\tb.Run(\"GetMapIDs100Parallel\", f.BenchmarkGetMapIDs100Parallel)\n\tb.Run(\"GetMapIDs1000Parallel\", f.BenchmarkGetMapIDs1000Parallel)\n\tb.Run(\"GetMapIDs10000Parallel\", f.BenchmarkGetMapIDs10000Parallel)\n\n\tb.Run(\"GetSegment\", f.BenchmarkGetSegment)\n\tb.Run(\"GetSegmentParallel\", f.BenchmarkGetSegmentParallel)\n}", "func RunTest(t *testing.T, name string, f Func, testCases []TestCase) {\n\tt.Run(name, func(t *testing.T) {\n\t\tfor _, test := range testCases {\n\t\t\tif actual := f(test.Input); actual != test.Expected {\n\t\t\t\tt.Errorf(\"\\nfor n=%d, expected: %t, actual: %t\", test.Input, test.Expected, actual)\n\t\t\t}\n\t\t}\n\t})\n}", "func (g *Glimit) Run(f func()) {\n\tg.c <- struct{}{}\n\tgo func() {\n\t\tf()\n\t\t<-g.c\n\t}()\n}", "func (b *B) Run(name string, f func(b *B)) bool {}", "func (c *ConcurrentLimit) Run(f func()) {\n\t// we push to start, and pop to finish\n\tc.c <- true\n\tf()\n\t<-c.c\n}", "func RunBenchmarks(b *testing.B, coll *docstore.Collection) {\n\tdefer coll.Close()\n\tclearCollection(b, coll)\n\tb.Run(\"BenchmarkSingleActionPut\", func(b *testing.B) {\n\t\tbenchmarkSingleActionPut(10, b, coll)\n\t})\n\tb.Run(\"BenchmarkSingleActionGet\", func(b *testing.B) {\n\t\tbenchmarkSingleActionGet(10, b, coll)\n\t})\n\tb.Run(\"BenchmarkActionListPut\", func(b *testing.B) {\n\t\tbenchmarkActionListPut(50, b, coll)\n\t})\n\tb.Run(\"BenchmarkActionListGet\", func(b *testing.B) {\n\t\tbenchmarkActionListGet(100, b, coll)\n\t})\n\tclearCollection(b, coll)\n}", "func Test0(par0 bool) {\n}", "func (fa *_FeatureA) InitFunc() {\n\tready, err := Subscribe(_TestFeatureB, 5*time.Second)\n\tif err != nil {\n\t\tfa.t.Fatalf(\"subscribe feature B failed: %v\", err)\n\t}\n\tif ready {\n\t\tfa.mode = 1\n\t} else {\n\t\tfa.mode = 2\n\t}\n\n}", "func NewBenchmark(driver *driver.Driver) *Benchmark {\n\tb := new(Benchmark)\n\n\tb.driver = driver\n\tb.context = b.driver.Init()\n\n\tb.network = training.Network{\n\t\tLayers: []layers.Layer{\n\t\t\tsimLayers.CPUToGPULayer{\n\t\t\t\tGPUDriver: b.driver,\n\t\t\t\tGPUCtx: b.context,\n\t\t\t},\n\t\t\tsimLayers.NewFullyConnectedLayer(\n\t\t\t\t2, 2,\n\t\t\t\tb.driver, b.context,\n\t\t\t\tsimLayers.NewTensorOperator(b.driver, b.context),\n\t\t\t),\n\t\t\tsimLayers.NewReluLayer(b.driver, b.context),\n\t\t\tsimLayers.NewFullyConnectedLayer(\n\t\t\t\t2, 2,\n\t\t\t\tb.driver, b.context,\n\t\t\t\tsimLayers.NewTensorOperator(b.driver, b.context),\n\t\t\t),\n\t\t\tsimLayers.GPUToCPULayer{\n\t\t\t\tGPUDriver: b.driver,\n\t\t\t\tGPUCtx: b.context,\n\t\t\t},\n\t\t},\n\t}\n\n\tb.trainer = training.Trainer{\n\t\tDataSource: NewDataSource(),\n\t\tNetwork: b.network,\n\t\tLossFunc: training.SoftmaxCrossEntropy{},\n\t\tOptimizationAlg: optimization.NewAdam(0.01),\n\t\tTester: &training.Tester{\n\t\t\tDataSource: NewDataSource(),\n\t\t\tNetwork: b.network,\n\t\t\tBatchSize: 4,\n\t\t},\n\t\tEpoch: 1,\n\t\tBatchSize: 4,\n\t\tShowBatchInfo: true,\n\t}\n\n\tb.enableLayerVerification(&b.network)\n\n\treturn b\n}", "func main() {\n\tf1()\n\tf2()\n}", "func Run(name string, initFunc Init, opts ...BinaryOpts) {\n\tvar config Config\n\tfor _, o := range opts {\n\t\to(&config)\n\t}\n\n\tctx := context.Background()\n\tctx = log.WithLogger(ctx, log.G(ctx).WithField(\"runtime\", name))\n\n\tif err := run(ctx, nil, initFunc, name, config); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"%s: %s\", name, err)\n\t\tos.Exit(1)\n\t}\n}", "func BenchmarkCoreSimple(b *testing.B) {\n\tfor i := 0; i < b.N; i++ {\n\t\tDoTheThing()\n\t}\n}", "func (b *Benchmark) Run() {\n\tfor _, gpu := range b.gpus {\n\t\tb.driver.SelectGPU(b.context, gpu)\n\t\tb.queues = append(b.queues, b.driver.CreateCommandQueue(b.context))\n\t}\n\n\tif b.NumIterations == 0 || b.NumIterations > b.NumNodes {\n\t\tb.NumIterations = b.NumNodes\n\t}\n\n\tb.initMem()\n\tb.exec()\n}", "func CommonIsPrimeBenchmark(b *testing.B, checker primes.Checker) {\n\tfor i := 0; i < b.N; i++ {\n\t\tfor j := 0; j < 1000; j++ {\n\t\t\tchecker.IsPrime(j)\n\t\t}\n\t}\n}", "func (r RunFunc) Run(ctx context.Context) {\n\tr(ctx)\n}", "func RunF(format string, args ...interface{}) error {\n\treturn Run(fmt.Sprintf(format, args...))\n}", "func NewBench(concurrency int, duration time.Duration, rps int, fn benchmarkFn) *Bench {\n\tb := &Bench{\n\t\tconcurrentRuns: concurrency,\n\t\tduration: duration,\n\t\tfn: fn,\n\t\trps: rps,\n\t}\n\n\tb.timers = make(map[string]*hdrhistogram.Histogram)\n\tb.counters = make(map[string]int64)\n\n\tfor i := 0; i < b.concurrentRuns; i++ {\n\t\tb.runContexts = append(b.runContexts, newContext(i+1))\n\t}\n\n\treturn b\n}", "func Run() {\n\tfor key, val := range funcMap {\n\t\targs := funcArgs[key]\n\t\tcall(val, args)\n\t}\n}", "func New(configFile string) (Bench, error) {\n\tb := Bench{}\n\tvar err error\n\tif b.config, err = config(configFile); err != nil {\n\t\treturn b, err\n\t}\n\treturn b, nil\n}", "func (t *Test) Run(ctx context.Context, opts ...TestOption) (*TestResult, error) {\n\tparsedOpts := &testOptions{\n\t\tvars: &starlark.Dict{},\n\t}\n\tfor _, opt := range opts {\n\t\topt.applyTest(parsedOpts)\n\t}\n\n\tthread := &starlark.Thread{\n\t\tPrint: skyPrint,\n\t}\n\tthread.SetLocal(\"context\", ctx)\n\n\tassertModule := assertmodule.AssertModule()\n\ttestCtx := &starlarkstruct.Module{\n\t\tName: \"skycfg_test_ctx\",\n\t\tMembers: starlark.StringDict(map[string]starlark.Value{\n\t\t\t\"vars\": parsedOpts.vars,\n\t\t\t\"assert\": assertModule,\n\t\t}),\n\t}\n\targs := starlark.Tuple([]starlark.Value{testCtx})\n\n\tresult := TestResult{\n\t\tTestName: t.Name(),\n\t}\n\n\tstartTime := time.Now()\n\t_, err := starlark.Call(thread, t.callable, args, nil)\n\tresult.Duration = time.Since(startTime)\n\tif err != nil {\n\t\t// if there is no assertion error, there was something wrong with the execution itself\n\t\tif len(assertModule.Failures) == 0 {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// there should only be one failure, because each test run gets its own *TestContext\n\t\t// and each assertion failure halts execution.\n\t\tif len(assertModule.Failures) > 1 {\n\t\t\tpanic(\"A test run should only have one assertion failure. Something went wrong with the test infrastructure.\")\n\t\t}\n\t\tresult.Failure = assertModule.Failures[0]\n\t}\n\n\treturn &result, nil\n}", "func BenchmarkCompiled(b *testing.B) {\n\tfor _, test := range ilt.TestData {\n\t\tif !test.Bench {\n\t\t\tcontinue\n\t\t}\n\n\t\tfinder := ast.NewFinder(test.Conf())\n\n\t\tbuilder := NewBuilder(finder)\n\t\texpression, _, err := builder.Compile(test.E)\n\t\tif err != nil {\n\t\t\tb.Fatalf(\"compilation of benchmark expression failed: '%v'\", err)\n\t\t\treturn\n\t\t}\n\n\t\tbag := ilt.NewFakeBag(test.I)\n\n\t\tb.Run(test.TestName(), func(bb *testing.B) {\n\t\t\tfor i := 0; i <= bb.N; i++ {\n\t\t\t\t_, _ = expression.Evaluate(bag)\n\t\t\t}\n\t\t})\n\t}\n}", "func Run(ctx context.Context, fun TaskFunc) error {\n\tctx, cancel := context.WithCancel(ctx)\n\tdefer cancel()\n\treturn waitFor(Start(ctx, fun))\n}", "func Run(fn interface{}, args ...string) error {\n\tfd, err := parseFuncDesc(fn)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := fd.parseArgs(args); err != nil {\n\t\treturn err\n\t}\n\treturn fd.call()\n}", "func SetFunc(t testingT, f func() time.Time) bool {\n\tt.Helper()\n\tname, ok := funcName(1)\n\tif !ok {\n\t\treturn false\n\t}\n\ttimeMap.Store(name, f)\n\n\tt.Cleanup(func() {\n\t\ttimeMap.Delete(name)\n\t})\n\n\treturn true\n}", "func (f Factory) RunKeyValueStoreBenchmarks(b *testing.B) {\n\tb.Run(\"GetValue\", f.BenchmarkGetValue)\n\tb.Run(\"GetValueParallel\", f.BenchmarkGetValueParallel)\n\n\tb.Run(\"SetValue\", f.BenchmarkSetValue)\n\tb.Run(\"SetValueParallel\", f.BenchmarkSetValueParallel)\n\n\tb.Run(\"DeleteValue\", f.BenchmarkDeleteValue)\n\tb.Run(\"DeleteValueParallel\", f.BenchmarkDeleteValueParallel)\n}", "func RunTrueAndFalse(t *testing.T, name string, fn func(t *testing.T, b bool)) {\n\tfor _, b := range []bool{false, true} {\n\t\tt.Run(fmt.Sprintf(\"%s=%t\", name, b), func(t *testing.T) {\n\t\t\tfn(t, b)\n\t\t})\n\t}\n}", "func RunTest(ctx context.Context, target, location string, nodeIDs []int, limit int, debug, outputJSON bool, runTest runFunc, runOutput runOutputFunc) error {\n\trunReq := &perfops.RunRequest{\n\t\tTarget: target,\n\t\tLocation: location,\n\t\tNodes: nodeIDs,\n\t\tLimit: limit,\n\t}\n\n\tf := NewFormatter(debug && !outputJSON)\n\tf.StartSpinner()\n\ttestID, err := runTest(ctx, runReq)\n\tf.StopSpinner()\n\tif err != nil {\n\t\treturn err\n\t}\n\tres := &RunOutputResult{}\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-time.After(200 * time.Millisecond):\n\t\t\t}\n\t\t\toutput, err := runOutput(ctx, testID)\n\t\t\tres.SetOutput(output, err)\n\t\t\tif err != nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}()\n\n\tif outputJSON {\n\t\tf.StartSpinner()\n\t}\n\tvar o *perfops.RunOutput\n\tfor {\n\t\tselect {\n\t\tcase <-time.After(50 * time.Millisecond):\n\t\t}\n\t\tif o, err = res.Output(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !outputJSON && o != nil {\n\t\t\tPrintOutput(f, o)\n\t\t}\n\t\tif o != nil && o.IsFinished() {\n\t\t\tbreak\n\t\t}\n\t}\n\tif outputJSON {\n\t\tf.StopSpinner()\n\t\tPrintOutputJSON(o)\n\t}\n\treturn nil\n}", "func BenchmarkBuild(b *testing.B) {\n\tgarbleBin := filepath.Join(b.TempDir(), \"garble\")\n\tif runtime.GOOS == \"windows\" {\n\t\tgarbleBin += \".exe\"\n\t}\n\n\tif err := exec.Command(\"go\", \"build\", \"-o=\"+garbleBin).Run(); err != nil {\n\t\tb.Fatalf(\"building garble: %v\", err)\n\t}\n\n\tfor _, name := range [...]string{\"Cache\", \"NoCache\"} {\n\t\tb.Run(name, func(b *testing.B) {\n\t\t\tbuildArgs := []string{\"build\", \"-o=\" + b.TempDir()}\n\t\t\tswitch name {\n\t\t\tcase \"Cache\":\n\t\t\t\tbuildArgs = append(buildArgs, \"./testdata/bench-cache\")\n\n\t\t\t\t// Ensure the build cache is warm,\n\t\t\t\t// for the sake of consistent results.\n\t\t\t\tcmd := exec.Command(garbleBin, buildArgs...)\n\t\t\t\tif out, err := cmd.CombinedOutput(); err != nil {\n\t\t\t\t\tb.Fatalf(\"%v: %s\", err, out)\n\t\t\t\t}\n\t\t\tcase \"NoCache\":\n\t\t\t\tbuildArgs = append(buildArgs, \"./testdata/bench-nocache\")\n\t\t\tdefault:\n\t\t\t\tb.Fatalf(\"unknown name: %q\", name)\n\t\t\t}\n\n\t\t\t// We collect extra metrics.\n\t\t\tvar userTime, systemTime int64\n\n\t\t\tb.ResetTimer()\n\t\t\tb.RunParallel(func(pb *testing.PB) {\n\t\t\t\tfor pb.Next() {\n\t\t\t\t\tcmd := exec.Command(garbleBin, buildArgs...)\n\t\t\t\t\tif name == \"NoCache\" {\n\t\t\t\t\t\tgocache, err := os.MkdirTemp(b.TempDir(), \"gocache-*\")\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\tb.Fatal(err)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcmd.Env = append(os.Environ(), \"GOCACHE=\"+gocache)\n\t\t\t\t\t}\n\t\t\t\t\tif out, err := cmd.CombinedOutput(); err != nil {\n\t\t\t\t\t\tb.Fatalf(\"%v: %s\", err, out)\n\t\t\t\t\t}\n\n\t\t\t\t\tuserTime += int64(cmd.ProcessState.UserTime())\n\t\t\t\t\tsystemTime += int64(cmd.ProcessState.SystemTime())\n\t\t\t\t}\n\t\t\t})\n\t\t\tb.ReportMetric(float64(userTime)/float64(b.N), \"user-ns/op\")\n\t\t\tb.ReportMetric(float64(systemTime)/float64(b.N), \"sys-ns/op\")\n\t\t\tinfo, err := os.Stat(garbleBin)\n\t\t\tif err != nil {\n\t\t\t\tb.Fatal(err)\n\t\t\t}\n\t\t\tb.ReportMetric(float64(info.Size()), \"bin-B\")\n\t\t})\n\t}\n}", "func (s MockInputsBoolsHelper) RunTests(t testRunner, testSet []bool, testFunc func(t *testing.T, index int, f bool)) {\n\tif test, ok := t.(helper); ok {\n\t\ttest.Helper()\n\t}\n\n\ttest := internal.GetTest(t)\n\tif test == nil {\n\t\tt.Error(internal.ErrCanNotRunIfNotBuiltinTesting)\n\t\treturn\n\t}\n\n\tfor i, v := range testSet {\n\t\ttest.Run(fmt.Sprint(v), func(t *testing.T) {\n\t\t\tt.Helper()\n\n\t\t\ttestFunc(t, i, v)\n\t\t})\n\t}\n}", "func BenchmarkParser(b *testing.B) {\n\texpr := \"n%10==1&&n%100!=11?0:n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?1:2\"\n\tfor i := 0; i < b.N; i++ {\n\t\t_, err := parse(expr)\n\t\tif err != nil {\n\t\t\tb.Fatal(err)\n\t\t}\n\t}\n}", "func TestProfileSingleConfiguration(t *testing.T) {\n\n\tt.Skip(\"Skipping TestProfileSingleConfiguration\")\n\n\tvar (\n\t\tservedTh uint64\n\t\tpinnedFuncNum int\n\t\tisSyncOffload bool = true\n\t\timages = getImages(t)\n\t)\n\n\tlog.SetLevel(log.InfoLevel)\n\n\tcheckInputValidation(t)\n\n\tcreateResultsDir()\n\n\tfuncPool = NewFuncPool(!isSaveMemoryConst, servedTh, pinnedFuncNum, isTestModeConst)\n\n\tbootVMs(t, images, 0, *vmNum)\n\n\tserveMetrics := loadAndProfile(t, images, *vmNum, *targetRPS, isSyncOffload)\n\n\ttearDownVMs(t, images, *vmNum, isSyncOffload)\n\n\tdumpMetrics(t, []map[string]float64{serveMetrics}, \"bench.csv\")\n}" ]
[ "0.7261395", "0.71153", "0.6746831", "0.5840778", "0.5818933", "0.5759226", "0.56847936", "0.54754686", "0.5460697", "0.54217684", "0.53978", "0.53957176", "0.5385811", "0.5306742", "0.52589774", "0.5240582", "0.52340424", "0.52124375", "0.5198126", "0.51899254", "0.5184448", "0.51469505", "0.5105641", "0.5085813", "0.50803024", "0.5049664", "0.50059277", "0.49869624", "0.49839795", "0.49797818", "0.49766862", "0.49752873", "0.497141", "0.49637085", "0.49425712", "0.49320266", "0.4919909", "0.48815945", "0.48314908", "0.48147672", "0.48066783", "0.4800145", "0.47790828", "0.47680226", "0.47655362", "0.47610286", "0.47529745", "0.47487202", "0.47389683", "0.4736092", "0.46907917", "0.4690731", "0.4682098", "0.46775466", "0.46596196", "0.46548602", "0.46459714", "0.46390998", "0.46377012", "0.4636804", "0.46189052", "0.46125126", "0.4602606", "0.45781496", "0.456803", "0.45658806", "0.45519897", "0.45482746", "0.45349362", "0.45215464", "0.452009", "0.44908598", "0.44780096", "0.44723654", "0.4471942", "0.44650835", "0.44599015", "0.4452507", "0.4447047", "0.44459015", "0.44387424", "0.44197595", "0.44073963", "0.44018772", "0.43997455", "0.4398957", "0.43936378", "0.43793532", "0.4361027", "0.43485722", "0.43384624", "0.43365437", "0.43222013", "0.43214625", "0.43148458", "0.4310682", "0.43102667", "0.4306943", "0.4303594", "0.42978707" ]
0.6789741
2
Coverage reports the current code coverage as a fraction in the range [0, 1]. If coverage is not enabled, Coverage returns 0. When running a large set of sequential test cases, checking Coverage after each one can be useful for identifying which test cases exercise new code paths. It is not a replacement for the reports generated by 'go test cover' and 'go tool cover'.
func Coverage() float64 {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Coverage() error {\n\tmg.Deps(Test)\n\treturn sh.Run(\"go\", \"tool\", \"cover\", \"-html=coverage.out\")\n}", "func (c CoverageProfile) CoveragePercent() float64 {\n\tif total := c.TotalLines(); total != 0 {\n\t\treturn 100. * float64(c.TotalCoveredLines()) / float64(total)\n\t}\n\treturn 0\n}", "func Coverage() error {\n\tif _, err := os.Stat(\"./coverage.out\"); err != nil {\n\t\treturn fmt.Errorf(\"run mage test befor checking the code coverage\")\n\t}\n\treturn sh.RunV(\"go\", \"tool\", \"cover\", \"-html=coverage.out\")\n}", "func (g Go) Coverage(ctx context.Context) error {\n\tmg.CtxDeps(ctx, g.CheckVersion, g.Cover)\n\tgf, err := goFiles()\n\tif err != nil {\n\t\treturn err\n\t}\n\tneed, _ := target.Path(\"coverage.out\", gf...)\n\tif need {\n\t\tmg.Deps(g.Test)\n\t}\n\treturn goCover(\"-html=coverage.out\")\n}", "func Coverage() float64", "func (g Go) Cover(ctx context.Context) error {\n\tmg.CtxDeps(ctx, g.CheckVersion)\n\tgf, err := goFiles()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif need, _ := target.Path(\"coverage.out\", gf...); need {\n\t\tmg.Deps(g.Test)\n\t}\n\treturn goCover(strings.Split(CoverArgs, \" \")...)\n}", "func Cover() error {\n\tmg.Deps(getEnvironment, Clean, GetBuildName)\n\tfmt.Println(fmt.Sprintf(\"Testing with coverage gpsa... \"))\n\tfmt.Println(\"# ########################################################################################\")\n\n\terr := gobuildhelpers.CoverTestFolders(gpsaBuildContext.PackagesToTest, gpsaBuildContext.LogDir, \"TestCoverage.log\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Println(\"# ########################################################################################\")\n\treturn nil\n}", "func performCoverage(path string, info os.FileInfo, err error) error {\n\tif err == nil && info.IsDir() && hasGoFile(path) && !fileIgnore.MatchString(path) {\n\t\tpath = \"./\" + path\n\t\tlog.Println(path)\n\t\texec.Command(\"go\", \"test\", \"-covermode=count\", \"-coverprofile=\"+path+\"/\"+covTmpFile, path).Output()\n\t}\n\treturn nil\n}", "func computeCoverage(stdOut string) string {\n\tnn := coverageMatch.FindAllString(stdOut, -1)\n\ttotal := float64(0.00)\n\tcount := float64(0.00)\n\tfor _, n := range nn {\n\t\tn = strings.TrimSpace(n)\n\t\tn = strings.Trim(n, \"%\")\n\t\tf, err := strconv.ParseFloat(n, 64)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\ttotal += f\n\t\tcount++\n\t}\n\n\t// to prevent divide by 0\n\tif count < 1.0 {\n\t\tcount = 1.00\n\t}\n\t// rounding to 2\n\treturn fmt.Sprintf(\"%.2f%%\", (total / count))\n}", "func TestCoverage(t *testing.T) {\n\tvar valid int\n\tvar invalid int\n\tfilepath.Walk(\"workdir/corpus\", func(path string, info os.FileInfo, err error) error {\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif info.IsDir() {\n\t\t\treturn nil\n\t\t}\n\n\t\tdata, err := ioutil.ReadFile(path)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\n\t\tr := graphql.Do(graphql.Params{\n\t\t\tSchema: testutil.StarWarsSchema,\n\t\t\tRequestString: string(data),\n\t\t})\n\t\tif len(r.Errors) == 0 {\n\t\t\tvalid++\n\t\t} else {\n\t\t\tinvalid++\n\t\t}\n\t\treturn nil\n\t})\n\tfmt.Println(valid, \"valid\", invalid, \"invalid\")\n}", "func (id NodeID) Coverage() (uint64, uint64) {\n\treturn id.Index << id.Level, (id.Index + 1) << id.Level\n}", "func (c *Coverage) RunLocal(change scm.Change, options *Options, tmpDir string) (CoverageProfile, error) {\n\ttestPkgs := change.Indirect().TestPackages()\n\ttype result struct {\n\t\tfile string\n\t\terr error\n\t}\n\tresults := make(chan *result)\n\tfor i, tp := range testPkgs {\n\t\tgo func(index int, testPkg string) {\n\t\t\tsettings := c.SettingsForPkg(testPkg)\n\t\t\t// Skip coverage if disabled for this directory.\n\t\t\tif settings.MinCoverage == 0 {\n\t\t\t\tresults <- nil\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tp := filepath.Join(tmpDir, fmt.Sprintf(\"test%d.cov\", index))\n\t\t\targs := []string{\n\t\t\t\t\"go\", \"test\", \"-v\", \"-covermode=count\",\n\t\t\t\t\"-coverprofile\", p,\n\t\t\t\t\"-timeout\", fmt.Sprintf(\"%ds\", options.MaxDuration),\n\t\t\t\ttestPkg,\n\t\t\t}\n\t\t\tout, exitCode, duration, _ := options.Capture(change.Repo(), args...)\n\t\t\tif duration > time.Second {\n\t\t\t\tlog.Printf(\"%s was slow: %s\", args, round(duration, time.Millisecond))\n\t\t\t}\n\t\t\tif exitCode != 0 {\n\t\t\t\tresults <- &result{err: fmt.Errorf(\"%s %s failed:\\n%s\", strings.Join(args, \" \"), testPkg, processStackTrace(out))}\n\t\t\t\treturn\n\t\t\t}\n\t\t\tresults <- &result{file: p}\n\t\t}(i, tp)\n\t}\n\n\t// Sends to coveralls.io if applicable. Do not write to disk unless needed.\n\tvar f readWriteSeekCloser\n\tvar err error\n\tif c.isGoverallsEnabled() {\n\t\tif f, err = os.Create(filepath.Join(tmpDir, \"profile.cov\")); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\tf = &buffer{}\n\t}\n\n\t// Aggregate all results.\n\tcounts := map[string]int{}\n\tfor i := 0; i < len(testPkgs); i++ {\n\t\tresult := <-results\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif result == nil {\n\t\t\tcontinue\n\t\t}\n\t\tif result.err != nil {\n\t\t\terr = result.err\n\t\t\tcontinue\n\t\t}\n\t\tif err2 := loadRawCoverage(result.file, counts); err == nil {\n\t\t\t// Wait for all tests to complete before returning.\n\t\t\terr = err2\n\t\t}\n\t}\n\tif err != nil {\n\t\tf.Close()\n\t\treturn nil, err\n\t}\n\treturn loadMergeAndClose(f, counts, change)\n}", "func (c CoverageProfile) Passes(s *CoverageSettings) (string, bool) {\n\tif c.TotalLines() == 0 {\n\t\treturn \"no Go code\", true\n\t}\n\tpercent := c.CoveragePercent()\n\tprefix := fmt.Sprintf(\"%3.1f%% (%d/%d)\", percent, c.TotalCoveredLines(), c.TotalLines())\n\tsuffix := fmt.Sprintf(\"; Functions: %d untested / %d partially / %d completely\", c.NonCoveredFuncs(), c.PartiallyCoveredFuncs(), c.CoveredFuncs())\n\tif percent < s.MinCoverage {\n\t\treturn fmt.Sprintf(\"%s < %.1f%% (min)%s\", prefix, s.MinCoverage, suffix), false\n\t}\n\tif s.MaxCoverage > 0 && percent > s.MaxCoverage {\n\t\treturn fmt.Sprintf(\"%s > %.1f%% (max)%s\", prefix, s.MaxCoverage, suffix), false\n\t}\n\treturn fmt.Sprintf(\"%s >= %.1f%%%s\", prefix, s.MinCoverage, suffix), true\n}", "func (c *Coverage) RunGlobal(change scm.Change, options *Options, tmpDir string) (CoverageProfile, error) {\n\tcoverPkg := \"\"\n\tfor i, p := range change.All().Packages() {\n\t\tif s := c.SettingsForPkg(p); s.MinCoverage != 0 {\n\t\t\tif i != 0 {\n\t\t\t\tcoverPkg += \",\"\n\t\t\t}\n\t\t\tcoverPkg += p\n\t\t}\n\t}\n\n\t// This part is similar to Test.Run() except that it passes a unique\n\t// -coverprofile file name, so that all the files can later be merged into a\n\t// single file.\n\ttestPkgs := change.All().TestPackages()\n\ttype result struct {\n\t\tfile string\n\t\terr error\n\t}\n\tresults := make(chan *result)\n\tfor index, tp := range testPkgs {\n\t\tf := filepath.Join(tmpDir, fmt.Sprintf(\"test%d.cov\", index))\n\t\tgo func(f string, testPkg string) {\n\t\t\t// Maybe fallback to 'pkg + \"/...\"' and post process to remove\n\t\t\t// uninteresting directories. The rationale is that it will eventually\n\t\t\t// blow up the OS specific command argument length.\n\t\t\targs := []string{\n\t\t\t\t\"go\", \"test\", \"-v\", \"-covermode=count\", \"-coverpkg\", coverPkg,\n\t\t\t\t\"-coverprofile\", f,\n\t\t\t\t\"-timeout\", fmt.Sprintf(\"%ds\", options.MaxDuration),\n\t\t\t\ttestPkg,\n\t\t\t}\n\t\t\tout, exitCode, duration, err := options.Capture(change.Repo(), args...)\n\t\t\tif duration > time.Second {\n\t\t\t\tlog.Printf(\"%s was slow: %s\", args, round(duration, time.Millisecond))\n\t\t\t}\n\t\t\tif exitCode != 0 {\n\t\t\t\terr = fmt.Errorf(\"%s %s failed:\\n%s\", strings.Join(args, \" \"), testPkg, processStackTrace(out))\n\t\t\t}\n\t\t\tresults <- &result{f, err}\n\t\t}(f, tp)\n\t}\n\n\t// Sends to coveralls.io if applicable. Do not write to disk unless needed.\n\tvar f readWriteSeekCloser\n\tvar err error\n\tif c.isGoverallsEnabled() {\n\t\tif f, err = os.Create(filepath.Join(tmpDir, \"profile.cov\")); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\tf = &buffer{}\n\t}\n\n\t// Aggregate all results.\n\tcounts := map[string]int{}\n\tfor i := 0; i < len(testPkgs); i++ {\n\t\tresult := <-results\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif result.err != nil {\n\t\t\terr = result.err\n\t\t\tcontinue\n\t\t}\n\t\tif err2 := loadRawCoverage(result.file, counts); err == nil {\n\t\t\t// Wait for all tests to complete before returning.\n\t\t\terr = err2\n\t\t}\n\t}\n\tif err != nil {\n\t\tf.Close()\n\t\treturn nil, err\n\t}\n\treturn loadMergeAndClose(f, counts, change)\n}", "func Test() error {\n\treturn test(\"-coverprofile=coverage.out\", \"./...\")\n}", "func TestCoverHTML() error {\n\tmg.Deps(getDep)\n\tconst (\n\t\tcoverAll = \"coverage-all.out\"\n\t\tcover = \"coverage.out\"\n\t)\n\tf, err := os.Create(coverAll)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\tif _, err := f.Write([]byte(\"mode: count\")); err != nil {\n\t\treturn err\n\t}\n\tpkgs, err := packages()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, pkg := range pkgs {\n\t\tif err := sh.Run(goexe, \"test\", \"-coverprofile=\"+cover, \"-covermode=count\", pkg); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tb, err := ioutil.ReadFile(cover)\n\t\tif err != nil {\n\t\t\tif os.IsNotExist(err) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t\tidx := bytes.Index(b, []byte{'\\n'})\n\t\tb = b[idx+1:]\n\t\tif _, err := f.Write(b); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif err := f.Close(); err != nil {\n\t\treturn err\n\t}\n\treturn sh.Run(goexe, \"tool\", \"cover\", \"-html=\"+coverAll)\n}", "func TestCoverHTML() error {\n\tconst (\n\t\tcoverAll = \"coverage-all.out\"\n\t\tcover = \"coverage.out\"\n\t)\n\tf, err := os.Create(coverAll)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\tif _, err := f.Write([]byte(\"mode: count\")); err != nil {\n\t\treturn err\n\t}\n\tpkgs, err := packages()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, pkg := range pkgs {\n\t\tif err := sh.Run(goexe, \"test\", \"-coverprofile=\"+cover, pkg); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tb, err := ioutil.ReadFile(cover)\n\t\tif err != nil {\n\t\t\tif os.IsNotExist(err) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t\tidx := bytes.Index(b, []byte{'\\n'})\n\t\tb = b[idx+1:]\n\t\tif _, err := f.Write(b); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif err := f.Close(); err != nil {\n\t\treturn err\n\t}\n\treturn sh.Run(goexe, \"tool\", \"cover\", \"-html=\"+coverAll)\n}", "func getPackageCoverage(currentPath string, info os.FileInfo, err error) (string, error) {\n\tif os.IsNotExist(err) {\n\t\treturn \"\", nil\n\t}\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tfileName := info.Name()\n\n\tif fileName == \".git\" {\n\t\tvf(\"%q skipping dir; .git\", currentPath)\n\t\treturn \"\", filepath.SkipDir\n\t}\n\tif strings.HasPrefix(fileName, \"_\") {\n\t\tvf(\"%q skipping dir; '_' prefix\", currentPath)\n\t\treturn \"\", filepath.SkipDir\n\t}\n\tif fileName == \"vendor\" {\n\t\tvf(\"%q skipping dir; vendor\", currentPath)\n\t\treturn \"\", filepath.SkipDir\n\t}\n\n\tif !dirHasGlob(currentPath, \"*.go\") {\n\t\tvf(\"%q skipping dir; no *.go files\", currentPath)\n\t\treturn \"\", nil\n\t}\n\n\tfor _, include := range includes {\n\t\tif matches := glob(include, currentPath); !matches { // note the !\n\t\t\tvf(\"%q skipping dir; include no match: %s\", currentPath, include)\n\t\t\treturn \"\", nil\n\t\t}\n\t}\n\n\tfor _, exclude := range excludes {\n\t\tif matches := glob(exclude, currentPath); matches {\n\t\t\tvf(\"%q skipping dir; exclude match: %s\", currentPath, exclude)\n\t\t\treturn \"\", nil\n\t\t}\n\t}\n\n\tpackageCoverReport := filepath.Join(currentPath, \"profile.cov\")\n\terr = removeIfExists(packageCoverReport)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvar output []byte\n\toutput, err = execCoverage(currentPath)\n\tif err != nil {\n\t\tverrf(\"error running coverage\")\n\t\tfmt.Fprintln(os.Stderr, string(output))\n\t\treturn \"\", err\n\t}\n\n\tcoverage := extractCoverage(string(output))\n\tfmt.Fprintf(os.Stdout, \"%s: %v%%\\n\", currentPath, colorCoverage(parseCoverage(coverage)))\n\n\tif enforce != nil && *enforce {\n\t\tvf(\"enforcing coverage minimums\")\n\t\terr = enforceCoverage(currentPath, coverage)\n\t\tif err != nil {\n\t\t\treturn packageCoverReport, err\n\t\t}\n\t}\n\n\tif update != nil && *update {\n\t\tfmt.Fprintf(os.Stdout, \"%q updating coverage\\n\", currentPath)\n\t\terr = writeCoverage(currentPath, coverage)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\treturn packageCoverReport, nil\n}", "func (c CoverageProfile) TotalCoveredLines() int {\n\ttotal := 0\n\tfor _, f := range c {\n\t\ttotal += f.Covered\n\t}\n\treturn total\n}", "func Check() (err error) {\n\tcover, err := coverage.Coverage()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to generate coverage %w\", err)\n\t}\n\n\tsb := &strings.Builder{}\n\tfailed, err := coverage.FormatCoverageReport(coverageOptions, cover, sb)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to format report %w\", err)\n\t}\n\n\tif failed {\n\t\t// TODO: This needs to change if tests are failing\n\t\treturn fmt.Errorf(\"package test coverage too low, expected minimum %.f%%\\n%s\", coverageOptions.Threshold, sb)\n\t}\n\n\treturn\n}", "func TestCoverHTML() error {\n\tconst (\n\t\tcoverAll = \"coverage-all.out\"\n\t\tcover = \"coverage.out\"\n\t)\n\tf, err := os.Create(coverAll)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\tif _, err := f.Write([]byte(\"mode: count\")); err != nil {\n\t\treturn err\n\t}\n\tpkgs, err := hugoPackages()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, pkg := range pkgs {\n\t\tif err := sh.Run(goexe, \"test\", \"-coverprofile=\"+cover, \"-covermode=count\", pkg); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tb, err := os.ReadFile(cover)\n\t\tif err != nil {\n\t\t\tif os.IsNotExist(err) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t\tidx := bytes.Index(b, []byte{'\\n'})\n\t\tb = b[idx+1:]\n\t\tif _, err := f.Write(b); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif err := f.Close(); err != nil {\n\t\treturn err\n\t}\n\treturn sh.Run(goexe, \"tool\", \"cover\", \"-html=\"+coverAll)\n}", "func (f *FuncExtent) coverage(profile *Profile) (num, den int64) {\n\t// We could avoid making this n^2 overall by doing a single scan\n\t// and annotating the functions, but the sizes of the data\n\t// structures is never very large and the scan is almost\n\t// instantaneous.\n\tvar covered, total int64\n\t// The blocks are sorted, so we can stop counting as soon as we\n\t// reach the end of the relevant block.\n\tfor _, b := range profile.Blocks {\n\t\tif b.StartLine > f.endLine || (b.StartLine == f.endLine && b.StartCol >= f.endCol) {\n\t\t\t// Past the end of the function.\n\t\t\tbreak\n\t\t}\n\t\tif b.EndLine < f.startLine || (b.EndLine == f.startLine && b.EndCol <= f.startCol) {\n\t\t\t// Before the beginning of the function\n\t\t\tcontinue\n\t\t}\n\t\ttotal += int64(b.NumStmt)\n\t\tif b.Count > 0 {\n\t\t\tcovered += int64(b.NumStmt)\n\t\t}\n\t}\n\treturn covered, total\n}", "func SampleCoverage(value float32, invert bool) {\n\tsyscall.Syscall(gpSampleCoverage, 2, uintptr(math.Float32bits(value)), boolToUintptr(invert), 0)\n}", "func (d *Dao) GetCoverage(c context.Context, commitID, pkg string) (cov float64, err error) {\n\tvar (\n\t\tcount = strings.Count(pkg, \"/\")\n\t\tfile = &ut.File{}\n\t)\n\tif len(pkg) == 0 {\n\t\terr = fmt.Errorf(\"The pkg should not be empty\")\n\t\treturn\n\t}\n\tif pkg[len(pkg)-1] != '/' {\n\t\tcount++\n\t}\n\terr = d.DB.Select(`commit_id,substring_index(name,\"/\",?) as pkg,round(sum(covered_statements)/sum(statements)*100,2) as coverage`, count).Group(fmt.Sprintf(`commit_id,substring_index(name,\"/\",%d)`, count)).Having(\"commit_id=? and pkg=?\", commitID, pkg).First(file).Error\n\tif err == gorm.ErrRecordNotFound {\n\t\tcov, err = 0.00, nil\n\t\treturn\n\t} else if err != nil {\n\t\tlog.Error(\"dao.GetCoverage commitID(%s) pkg(%s) error(%v)\", commitID, pkg, err)\n\t\treturn\n\t}\n\tcov = file.Coverage\n\treturn\n}", "func (Report) Func() error {\n\treturn coverage.Report()\n}", "func (c *Covet) ReportFileCoverage(w io.Writer, f File, options ReportFileCoverageOptions) error {\n\tname := path.Join(c.options.GoCoverageBaseDir, f.Name)\n\tr, err := c.options.FS.Open(name)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer r.Close()\n\n\tchunks, err := DiffChunks(f, r)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, chunk := range chunks {\n\t\tfmt.Fprintln(w, \"Coverage:\", chunk.FirstLine, \"to\", chunk.LastLine)\n\t\tfor _, line := range chunk.Lines {\n\t\t\tswitch {\n\t\t\tcase strings.HasPrefix(line, \"+\"):\n\t\t\t\tline = color.GreenString(line)\n\t\t\tcase strings.HasPrefix(line, \"-\"):\n\t\t\t\tline = color.RedString(line)\n\t\t\t}\n\t\t\tfmt.Fprintln(w, line)\n\t\t}\n\t}\n\treturn nil\n}", "func cover(repo, goversion string, priority bool) error {\n\tsetInProgress(repo, goversion, priority)\n\n\tstdOut, stdErr, err := run(goversion, repo)\n\tif err != nil {\n\t\terrLogger.Println(err.Error())\n\t\tif len(stdErr) == 0 {\n\t\t\tstdErr = err.Error()\n\t\t}\n\t}\n\n\tunsetInProgress(repo, goversion, priority)\n\n\tobj := &Object{\n\t\tRepo: repo,\n\t\tTag: goversion,\n\t\tCover: stdErr,\n\t\tOutput: false,\n\t\tAddedAt: time.Now(),\n\t}\n\n\tif stdOut != \"\" {\n\t\tobj.Cover = computeCoverage(stdOut)\n\t\tobj.Output = true\n\t}\n\n\trerr := redisCodec.Set(&cache.Item{\n\t\tKey: repoFullName(repo, goversion, priority),\n\t\tObject: obj,\n\t\tExpiration: cacheExpiry,\n\t})\n\tif rerr != nil {\n\t\terrLogger.Println(rerr)\n\t}\n\t// if priority is true, then the request was not pushed to the Q channel,\n\t// So cleanup of channel is not required\n\tif !priority {\n\t\t<-qChan\n\t}\n\n\tif err == nil && obj.Cover == \"\" {\n\t\treturn ErrNoTest\n\t}\n\n\treturn err\n}", "func (c *Client) CoverageContract(ctx context.Context, path string) (*http.Response, error) {\n\treq, err := c.NewCoverageContractRequest(ctx, path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn c.Client.Do(ctx, req)\n}", "func Test() error {\n\treturn sh.RunV(\"go\", \"test\", \"-v\", \"-cover\", \"./...\", \"-coverprofile=coverage.out\")\n}", "func (c CoverageProfile) CoveredFuncs() int {\n\ttotal := 0\n\tfor _, f := range c {\n\t\tif f.Total == f.Covered {\n\t\t\ttotal++\n\t\t}\n\t}\n\treturn total\n}", "func Calc(profiles []Profile) float64 {\n\tvar total, covered int64\n\tfor _, p := range profiles {\n\t\tfor _, v := range p.Blocks {\n\t\t\ttotal += int64(v.NumStmt)\n\t\t\tif v.Count > 0 {\n\t\t\t\tcovered += int64(v.NumStmt)\n\t\t\t}\n\t\t}\n\t}\n\tif total == 0 {\n\t\treturn 0\n\t}\n\treturn float64(covered) / float64(total)\n}", "func (d *Client) StartPreciseCoverage() *StartPreciseCoverageRequest {\n\treturn &StartPreciseCoverageRequest{opts: make(map[string]interface{}), client: d.Client}\n}", "func matchCoverage(covs []tt.Coverage) matcherFunc {\n\treturn func(gid fonts.GID, value uint16) bool {\n\t\t_, covered := covs[value].Index(gid)\n\t\treturn covered\n\t}\n}", "func SampleCoverage(value float32, invert bool) {\n\tC.glowSampleCoverage(gpSampleCoverage, (C.GLfloat)(value), (C.GLboolean)(boolToInt(invert)))\n}", "func SampleCoverage(value float32, invert bool) {\n\tC.glowSampleCoverage(gpSampleCoverage, (C.GLfloat)(value), (C.GLboolean)(boolToInt(invert)))\n}", "func SampleCoverage(value float32, invert bool) {\n\tgl.SampleCoverage(value, invert)\n}", "func collateCoverage(path string, info os.FileInfo, err error) error {\n\tif err == nil && !info.IsDir() && strings.Contains(path, covTmpFile) {\n\t\tcontentsB, err := ioutil.ReadFile(path)\n\t\tcheck(err)\n\t\tcontents := strings.Replace(string(contentsB), \"mode: count\\n\", \"\", 1)\n\t\tf, err := os.OpenFile(outputFilename, os.O_APPEND|os.O_WRONLY, 0600)\n\t\tcheck(err)\n\t\t_, err = f.WriteString(contents)\n\t\tcheck(err)\n\t\tf.Close()\n\t}\n\treturn nil\n}", "func parseFullCoverProfile(pwd string, path string) (covered, total int, err error) {\n\tvf(\"parsing coverage profile: %q\", path)\n\tfiles, err := cover.ParseProfiles(path)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar fileCovered, numLines int\n\n\tfor _, file := range files {\n\t\tfileCovered = 0\n\n\t\tfor _, block := range file.Blocks {\n\t\t\tnumLines = block.EndLine - block.StartLine\n\n\t\t\ttotal += numLines\n\t\t\tif block.Count != 0 {\n\t\t\t\tfileCovered += numLines\n\t\t\t}\n\t\t}\n\n\t\tvf(\"processing coverage profile: %q result: %s (%d/%d lines)\", path, file.FileName, fileCovered, numLines)\n\t\tcovered += fileCovered\n\t}\n\n\treturn\n}", "func (b *Balance) Cover(c *Balance) bool {\n\treturn b.a0 >= c.a0 && b.a1 >= c.a1\n}", "func (c *Covet) DiffCoverageFiles() []File {\n\tvar coveredFiles []File\n\tfileNames, coveredSpans, uncoveredSpans := c.coveredAndUncovered()\n\tfor file := range fileNames {\n\t\tcovered := coveredSpans[file]\n\t\tuncovered := uncoveredSpans[file]\n\n\t\tcoveredFile := File{Name: file}\n\t\tfor _, s := range covered {\n\t\t\tfor i := s.Start; i < s.End; i++ {\n\t\t\t\tcoveredFile.Lines = append(coveredFile.Lines, Line{\n\t\t\t\t\tCovered: true,\n\t\t\t\t\tLineNumber: uint(i),\n\t\t\t\t})\n\t\t\t}\n\t\t\tcoveredFile.Covered += uint(s.Len())\n\t\t}\n\t\tfor _, s := range uncovered {\n\t\t\tfor i := s.Start; i < s.End; i++ {\n\t\t\t\tcoveredFile.Lines = append(coveredFile.Lines, Line{\n\t\t\t\t\tCovered: false,\n\t\t\t\t\tLineNumber: uint(i),\n\t\t\t\t})\n\t\t\t}\n\t\t\tcoveredFile.Uncovered += uint(s.Len())\n\t\t}\n\t\tsort.Slice(coveredFile.Lines, func(a, b int) bool {\n\t\t\treturn coveredFile.Lines[a].LineNumber < coveredFile.Lines[b].LineNumber\n\t\t})\n\t\tcoveredFiles = append(coveredFiles, coveredFile)\n\t}\n\treturn coveredFiles\n}", "func (mr *MockTestClientMockRecorder) GetTestRunCodeCoverage(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"GetTestRunCodeCoverage\", reflect.TypeOf((*MockTestClient)(nil).GetTestRunCodeCoverage), arg0, arg1)\n}", "func (c *Coverage) RunProfile(change scm.Change, options *Options) (profile CoverageProfile, err error) {\n\t// go test accepts packages, not files.\n\tvar testPkgs []string\n\tif c.UseGlobalInference {\n\t\ttestPkgs = change.All().TestPackages()\n\t} else {\n\t\ttestPkgs = change.Indirect().TestPackages()\n\t}\n\tif len(testPkgs) == 0 {\n\t\t// Sir, there's no test.\n\t\treturn nil, nil\n\t}\n\n\ttmpDir, err2 := ioutil.TempDir(\"\", \"pre-commit-go\")\n\tif err2 != nil {\n\t\treturn nil, err2\n\t}\n\tdefer func() {\n\t\terr2 := internal.RemoveAll(tmpDir)\n\t\tif err == nil {\n\t\t\terr = err2\n\t\t}\n\t}()\n\n\tif c.UseGlobalInference {\n\t\tprofile, err = c.RunGlobal(change, options, tmpDir)\n\t} else {\n\t\tprofile, err = c.RunLocal(change, options, tmpDir)\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif c.isGoverallsEnabled() {\n\t\t// Please send a pull request if the following doesn't work for you on your\n\t\t// favorite CI system.\n\t\tcmd := []string{\n\t\t\t\"goveralls\", \"-coverprofile\", filepath.Join(tmpDir, \"profile.cov\"),\n\t\t}\n\t\tif len(c.IgnorePathPatterns) > 0 {\n\t\t\tcmd = append(cmd, \"-ignore\", strings.Join(c.IgnorePathPatterns, \",\"))\n\t\t}\n\t\tout, _, _, err2 := options.Capture(change.Repo(), cmd...)\n\t\t// Don't fail the build.\n\t\tif err2 != nil {\n\t\t\tfmt.Printf(\"%s\", out)\n\t\t}\n\t}\n\treturn profile, nil\n}", "func (t *testFuncs) Covered() string {\n\treturn \"\"\n}", "func NewCoverageCommand(config *cnf.Config, logger *logrus.Logger) *cobra.Command {\n\tvar (\n\t\texclude []string\n\t\tlast time.Duration\n\t\tnoCache bool\n\t\treplMode bool\n\t)\n\n\tcommand := cobra.Command{\n\t\tUse: \"coverage\",\n\t\tShort: \"calculates metrics coverage by queries\",\n\t\tLong: \"Calculates metrics coverage by queries.\",\n\n\t\tPreRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif config.Grafana.URL == \"\" {\n\t\t\t\treturn errors.New(\"please provide Grafana API endpoint\")\n\t\t\t}\n\t\t\tif config.Grafana.Dashboard == \"\" {\n\t\t\t\treturn errors.New(\"please provide a dashboard unique identifier\")\n\t\t\t}\n\t\t\tif config.Graphite.URL == \"\" {\n\t\t\t\treturn errors.New(\"please provide Graphite API endpoint\")\n\t\t\t}\n\t\t\tif config.Graphite.Prefix == \"\" {\n\t\t\t\treturn errors.New(\"please provide metric prefix\")\n\t\t\t}\n\t\t\tif prefix := config.Graphite.Prefix; !model.Metric(prefix).Valid() {\n\t\t\t\treturn errors.Errorf(\"invalid metric prefix: %s; it must be simple, e.g. apps.services.name\", prefix)\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tprinter := new(presenter.Printer)\n\t\t\tif err := printer.SetOutput(cmd.OutOrStdout()).SetFormat(config.Output.Format); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tprinter.SetPrefix(config.Graphite.Prefix)\n\n\t\t\tindicator := progress.New()\n\n\t\t\tvar (\n\t\t\t\tmetrics model.Metrics\n\t\t\t\tdashboard *model.Dashboard\n\t\t\t)\n\n\t\t\tg, ctx := errgroup.WithContext(cmd.Context())\n\t\t\tg.Go(func() error {\n\t\t\t\tvar provider cache.Graphite\n\t\t\t\tprovider, err := graphite.New(config.Graphite.URL, &http.Client{Timeout: config.Graphite.Timeout}, logger, indicator)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif !noCache {\n\t\t\t\t\tprovider = cache.Decorate(provider, afero.NewOsFs(), logger)\n\t\t\t\t}\n\n\t\t\t\tmetrics, err = provider.Fetch(ctx, config.Graphite.Prefix, last)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tmetrics = metrics.Exclude(new(model.Queries).Convert(exclude).MustMatchers()...)\n\t\t\t\treturn nil\n\t\t\t})\n\t\t\tg.Go(func() error {\n\t\t\t\tprovider, err := grafana.New(config.Grafana.URL, &http.Client{Timeout: config.Grafana.Timeout}, logger, indicator)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tdashboard, err = provider.Fetch(ctx, config.Grafana.Dashboard)\n\t\t\t\treturn err\n\t\t\t})\n\t\t\tif err := g.Wait(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tqueries, err := dashboard.Queries(model.Config{\n\t\t\t\tSkipRaw: false,\n\t\t\t\tSkipDuplicates: false,\n\t\t\t\tNeedSorting: true,\n\t\t\t\tUnpack: true,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\treporter := model.NewCoverageReporter(queries)\n\n\t\t\tif !replMode {\n\t\t\t\tmetrics := metrics.Filter(config.FilterQuery().MustCompile()).Sort()\n\t\t\t\treturn printer.PrintCoverageReport(reporter.CoverageReport(metrics))\n\t\t\t}\n\t\t\tmetrics.Sort()\n\t\t\tprompt.New(\n\t\t\t\trepl.Prefix(config.Graphite.Prefix, repl.NewCoverageReportExecutor(metrics, reporter, printer, logger)),\n\t\t\t\trepl.NewMetricsCompleter(config.Graphite.Prefix, metrics),\n\t\t\t).Run()\n\t\t\treturn nil\n\t\t},\n\t}\n\n\tflags := command.Flags()\n\tflags.StringArrayVar(&exclude, \"exclude\", nil, \"queries to exclude metrics from coverage, e.g. *.median\")\n\tflags.DurationVar(&last, \"last\", xtime.Day, \"the last interval to fetch\")\n\tflags.BoolVar(&noCache, \"no-cache\", false, \"disable caching\")\n\tflags.BoolVar(&replMode, \"repl\", false, \"enable repl mode\")\n\n\treturn &command\n}", "func SampleCoverage(value float32, invert bool) {\n C.glowSampleCoverage(gpSampleCoverage, (C.GLfloat)(value), (C.GLboolean)(boolToInt(invert)))\n}", "func (covList *CoverageList) Ratio() float32 {\n\tcovList.summarize()\n\treturn covList.Coverage.Ratio()\n}", "func (s Coverage) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (o DeliveryPipelineSerialPipelineStageStrategyCanaryCustomCanaryDeploymentPhaseConfigOutput) Percentage() pulumi.IntOutput {\n\treturn o.ApplyT(func(v DeliveryPipelineSerialPipelineStageStrategyCanaryCustomCanaryDeploymentPhaseConfig) int {\n\t\treturn v.Percentage\n\t}).(pulumi.IntOutput)\n}", "func testPanic() {\n\tdefer func() {\n\t\trecover()\n\t}()\n\tcheck(LINE, 1)\n\tpanic(\"should not get next line\")\n\tcheck(LINE, 0) // this is GoCover.Count[panicIndex]\n\t// The next counter is in testSimple and it will be non-zero.\n\t// If the panic above does not trigger a counter, the test will fail\n\t// because GoCover.Count[panicIndex] will be the one in testSimple.\n}", "func (c *Covet) DiffCovered() float64 {\n\t_, coveredSpans, uncoveredSpans := c.coveredAndUncovered()\n\tvar coveredTotal, uncoveredTotal float64\n\tfor _, spans := range coveredSpans {\n\t\tfor _, s := range spans {\n\t\t\tcoveredTotal += float64(s.Len())\n\t\t}\n\t}\n\tfor _, spans := range uncoveredSpans {\n\t\tfor _, s := range spans {\n\t\t\tuncoveredTotal += float64(s.Len())\n\t\t}\n\t}\n\treturn coveredTotal / (coveredTotal + uncoveredTotal)\n}", "func SetSampleCoverage(value Float, invert Boolean) {\n\tcvalue, _ := (C.GLfloat)(value), cgoAllocsUnknown\n\tcinvert, _ := (C.GLboolean)(invert), cgoAllocsUnknown\n\tC.glSampleCoverage(cvalue, cinvert)\n}", "func TestCoverageReviewer_AddCoverageReview(t *testing.T) {\n\t/*\n\t\trp := mocks.ReviewProcess{}\n\t\trp.On(\"Start\", \"any\")\n\n\t\tcoverageReviewer{nil, nil, rp, 0.7}\n\t*/\n}", "func Parse(options Options) (covet *Covet, err error) {\n\tdefer func() { err = errors.Wrap(err, \"covet\") }()\n\tif !hackpadfs.ValidPath(options.DiffBaseDir) {\n\t\treturn nil, errors.Errorf(\"invalid diff base directory FS path: %s\", options.DiffBaseDir)\n\t}\n\tif !hackpadfs.ValidPath(options.GoCoveragePath) {\n\t\treturn nil, errors.Errorf(\"invalid coverage FS path: %s\", options.GoCoveragePath)\n\t}\n\tif options.GoCoverageBaseDir == \"\" {\n\t\toptions.GoCoverageBaseDir = path.Dir(options.GoCoveragePath)\n\t}\n\tif !hackpadfs.ValidPath(options.GoCoverageBaseDir) {\n\t\treturn nil, errors.Errorf(\"invalid coverage base directory FS path: %s\", options.GoCoverageBaseDir)\n\t}\n\tif options.FS == nil {\n\t\toptions.FS, err = fspath.WorkingDirectoryFS()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tif options.Diff == nil {\n\t\treturn nil, errors.New(\"diff reader must not be nil\")\n\t}\n\n\tdiffFiles, _, err := gitdiff.Parse(options.Diff)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcoverageFile, err := options.FS.Open(options.GoCoveragePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer coverageFile.Close()\n\tcoverageFiles, err := cover.ParseProfilesFromReader(coverageFile)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcovet = &Covet{\n\t\toptions: options,\n\t\taddedLines: make(map[string][]span.Span),\n\t\tcoveredLines: make(map[string][]span.Span),\n\t\tuncoveredLines: make(map[string][]span.Span),\n\t}\n\t_, err = covet.coverageToDiffRel()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcovet.addDiff(diffFiles)\n\tif err := covet.addCoverage(options.FS, options.GoCoverageBaseDir, coverageFiles); err != nil {\n\t\treturn nil, err\n\t}\n\treturn covet, nil\n}", "func (m *manager) test(event fsnotify.Event) {\n\tlogrus.Info(\"testing...\")\n\tm.gil.Do(func() {\n\t\tdefer func() {\n\t\t\tm.gil = &sync.Once{}\n\t\t}()\n\n\t\tm.buildTransaction(func() error {\n\t\t\ttime.Sleep(m.BuildDelay * time.Millisecond)\n\t\t\tnow := time.Now()\n\t\t\tlogrus.Infof(\"retesting on: %s\", event.Name)\n\n\t\t\tif _, err := os.Stat(\"test-coverage\"); err != nil {\n\t\t\t\tos.Mkdir(\"test-coverage\", 0700)\n\t\t\t}\n\n\t\t\t{\n\t\t\t\targs := []string{\n\t\t\t\t\t\"test\",\n\t\t\t\t\t\"./...\",\n\t\t\t\t\t\"-coverprofile=test-coverage/c.out\",\n\t\t\t\t}\n\t\t\t\tcmd := exec.Command(\"go\", args...)\n\n\t\t\t\tif err := m.runAndListen(cmd); err != nil {\n\t\t\t\t\tfmt.Println(err)\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\t{\n\t\t\t\targs := []string{\n\t\t\t\t\t\"tool\",\n\t\t\t\t\t\"cover\",\n\t\t\t\t\t\"-html=test-coverage/c.out\",\n\t\t\t\t\t\"-o=test-coverage/index.html\",\n\t\t\t\t}\n\t\t\t\tcmd := exec.Command(\"go\", args...)\n\n\t\t\t\tif err := m.runAndListen(cmd); err != nil {\n\t\t\t\t\tfmt.Println(err)\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogrus.Infof(\"building completed (time: %s)\", time.Since(now))\n\t\t\treturn nil\n\t\t})\n\n\t})\n}", "func (c CoverageProfile) PartiallyCoveredFuncs() int {\n\ttotal := 0\n\tfor _, f := range c {\n\t\tif f.Covered != 0 && f.Total != f.Covered {\n\t\t\ttotal++\n\t\t}\n\t}\n\treturn total\n}", "func NewTestCoverageReport() TestCoverageReport {\n\treturn TestCoverageReport{\n\t\tItems: nil,\n\t\tseen: map[string]struct{}{},\n\t}\n}", "func (r *Repository) CodesCover(lon, lat float64) []int {\n\tr.mutex.Lock()\n\n\tvar cc []int\n\n\tfor c, crs := range r.codes {\n\t\tif crs.Contains(lon, lat) {\n\t\t\tcc = append(cc, c)\n\t\t}\n\t}\n\n\tr.mutex.Unlock()\n\n\treturn cc\n}", "func TestGetCPUPercent(t *testing.T) {\n\t// setup the faking of `cpu.Percent()`\n\toldcpuPercent := cpuPercent\n\tcpuPercent = func(interval time.Duration, percpu bool) ([]float64, error) {\n\t\tret := []float64{100}\n\t\treturn ret, nil\n\t}\n\n\t// test\n\texpected := 100\n\tactual, err := getCPUPercent()\n\n\tassert.NoError(t, err, \"`getCPUPercent()` should not have returned an error\")\n\tassert.Equal(t, expected, actual, \"`getCPUPercent` should be equal to --> 100\")\n\n\t// teardown\n\tcpuPercent = oldcpuPercent\n}", "func loadRawCoverage(file string, counts map[string]int) error {\n\tf, err := os.Open(file)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\ts := bufio.NewScanner(f)\n\t// Strip the first line.\n\ts.Scan()\n\tif line := s.Text(); line != \"mode: count\" {\n\t\treturn fmt.Errorf(\"malformed %s: %s\", file, line)\n\t}\n\tfor s.Scan() {\n\t\tline := s.Text()\n\t\titems := rsplitn(line, \" \", 2)\n\t\tif len(items) != 2 {\n\t\t\treturn fmt.Errorf(\"malformed %s\", file)\n\t\t}\n\t\tif items[0] == \"total:\" {\n\t\t\t// Skip last line.\n\t\t\tcontinue\n\t\t}\n\t\tcount, err := strconv.Atoi(items[1])\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tcounts[items[0]] += int(count)\n\t}\n\treturn err\n}", "func mergeCoverage(counts map[string]int, out io.Writer) error {\n\tstms := make([]string, 0, len(counts))\n\tfor k := range counts {\n\t\tstms = append(stms, k)\n\t}\n\tsort.Strings(stms)\n\tif _, err := io.WriteString(out, \"mode: count\\n\"); err != nil {\n\t\treturn err\n\t}\n\tfor _, stm := range stms {\n\t\tif _, err := fmt.Fprintf(out, \"%s %d\\n\", stm, counts[stm]); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (cs *CoverService) Count(opts ...Option) (int, error) {\n\tct, err := cs.client.getCount(cs.end, opts...)\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"cannot count Covers\")\n\t}\n\n\treturn ct, nil\n}", "func updateChildCoverage(output map[string]*coverage) {\n\tfor pkgOuter, coverageOuter := range output {\n\t\tfor pkgInner, coverageInner := range output {\n\t\t\tif pkgOuter == pkgInner {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif isChild(pkgOuter, pkgInner) {\n\t\t\t\tcoverageOuter.childStatements += coverageInner.selfStatements\n\t\t\t\tcoverageOuter.childCovered += coverageInner.selfCovered\n\t\t\t}\n\t\t}\n\t}\n}", "func GetCodeCoverageStatistics(build *Build) ([]CodeCoverageStatistic, error) {\n\turl := fmt.Sprintf(\"https://%s.visualstudio.com/%s/_apis/test/codecoverage?api-version=5.0-preview.1&flags=7&buildId=%v\", TenantName, ProjectName, build.ID)\n\tbody, err := rest.Get(url, accessToken)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar codeCoverageList codeCoverageList\n\tif err := json.Unmarshal(body, &codeCoverageList); err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to unmarshal Code Coverage JSON, %v\", err)\n\t}\n\n\tif codeCoverageList.Count == 0 {\n\t\treturn nil, fmt.Errorf(\"No Code Coverage Results for build %v\", build.ID)\n\t}\n\n\tif codeCoverageList.Count > 1 {\n\t\treturn nil, fmt.Errorf(\"Expected 1 Code Coverage result but found %v\", codeCoverageList.Count)\n\t}\n\n\tvar ret []CodeCoverageStatistic\n\tfor _, module := range codeCoverageList.Value[0].Modules {\n\t\tret = append(ret, module.CoverageStatistic)\n\t}\n\treturn ret, nil\n}", "func TestRace() error {\n\tif os.Getenv(\"CI\") != \"\" {\n\t\treturn sh.RunV(mg.GoCmd(), \"test\", \"-race\", \"-coverprofile=coverage.txt\", \"-covermode=atomic\", \"./...\")\n\t}\n\treturn sh.RunV(mg.GoCmd(), \"test\", \"-race\", \"./...\")\n}", "func (res *Results) CalculatePct(pct int) float64 {\n slice := res.copyTook()\n\n l := len(slice)\n switch l {\n case 0:\n return float64(0)\n case 1:\n return slice[0]\n case 2:\n return slice[1]\n }\n\n index := int(math.Floor(((float64(l)/100)*float64(pct))+0.5) - 1)\n return slice[index]\n}", "func testCoproReport(t *testing.T, c *TestContext) {\n\tt.Run(\"CoproReport\", func(t *testing.T) {\n\t\ttestGetCoproReport(t, c)\n\t})\n}", "func CITests(c *checker.CheckRequest) checker.CheckResult {\n\tprs, err := c.RepoClient.ListMergedPRs()\n\tif err != nil {\n\t\te := sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf(\"RepoClient.ListMergedPRs: %v\", err))\n\t\treturn checker.CreateRuntimeErrorResult(CheckCITests, e)\n\t}\n\n\tusedSystem := unknown\n\ttotalMerged := 0\n\ttotalTested := 0\n\tfor index := range prs {\n\t\tpr := &prs[index]\n\t\tif pr.MergedAt.IsZero() {\n\t\t\tcontinue\n\t\t}\n\t\ttotalMerged++\n\n\t\tvar foundCI bool\n\n\t\t// Github Statuses.\n\t\tif usedSystem != githubCheckRuns {\n\t\t\tprSuccessStatus, err := prHasSuccessStatus(pr, c)\n\t\t\tif err != nil {\n\t\t\t\treturn checker.CreateRuntimeErrorResult(CheckCITests, err)\n\t\t\t}\n\t\t\tif prSuccessStatus {\n\t\t\t\ttotalTested++\n\t\t\t\tfoundCI = true\n\t\t\t\tusedSystem = githubStatuses\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\t// Github Check Runs.\n\t\tif usedSystem != githubStatuses {\n\t\t\tprCheckSuccessful, err := prHasSuccessfulCheck(pr, c)\n\t\t\tif err != nil {\n\t\t\t\treturn checker.CreateRuntimeErrorResult(CheckCITests, err)\n\t\t\t}\n\t\t\tif prCheckSuccessful {\n\t\t\t\ttotalTested++\n\t\t\t\tfoundCI = true\n\t\t\t\tusedSystem = githubCheckRuns\n\t\t\t}\n\t\t}\n\n\t\tif !foundCI {\n\t\t\tc.Dlogger.Debug3(&checker.LogMessage{\n\t\t\t\tText: fmt.Sprintf(\"merged PR without CI test: %d\", pr.Number),\n\t\t\t})\n\t\t}\n\t}\n\n\tif totalMerged == 0 {\n\t\treturn checker.CreateInconclusiveResult(CheckCITests, \"no pull request found\")\n\t}\n\n\treason := fmt.Sprintf(\"%d out of %d merged PRs checked by a CI test\", totalTested, totalMerged)\n\treturn checker.CreateProportionalScoreResult(CheckCITests, reason, totalTested, totalMerged)\n}", "func (covList *CoverageList) summarize() {\n\tcovList.NumCoveredStmts = 0\n\tcovList.NumAllStmts = 0\n\tfor _, item := range covList.Group {\n\t\tcovList.NumCoveredStmts += item.NumCoveredStmts\n\t\tcovList.NumAllStmts += item.NumAllStmts\n\t}\n}", "func (t Test) Unit() error {\n\tmg.Deps(t.GenerateModules)\n\treturn sh.RunWithV(ENV, \"go\", \"test\", \"-v\", \"-short\", \"-coverprofile=coverage.txt\", \"-covermode=atomic\", \"./...\")\n}", "func init() {\n\t// Initialize cobra and viper\n\tcobra.OnInitialize(readConfig)\n\tviper.SetEnvPrefix(\"overcover\")\n\n\t// Set up the flags\n\trootCmd.Flags().StringVarP(&config, \"config\", \"c\", os.Getenv(\"OVERCOVER_CONFIG\"), \"Configuration file to read. All command line options may be set through the configuration file.\")\n\t_, readOnlyDefault := os.LookupEnv(\"OVERCOVER_READONLY\")\n\trootCmd.Flags().BoolVarP(&readOnly, \"readonly\", \"r\", readOnlyDefault, \"Used to indicate that the configuration file should only be read, not written.\")\n\trootCmd.Flags().Float64P(\"threshold\", \"t\", 0, \"Set the minimum threshold for coverage; coverage below this threshold will result in an error.\")\n\trootCmd.Flags().StringVarP(&coverprofile, \"coverprofile\", \"p\", os.Getenv(\"OVERCOVER_COVERPROFILE\"), \"Specify the coverage profile file to read.\")\n\trootCmd.Flags().Float64P(\"min-headroom\", \"m\", 0, \"Set the minimum headroom. If the threshold is raised, it will be raised to the current coverage minus this value.\")\n\trootCmd.Flags().Float64P(\"max-headroom\", \"M\", 0, \"Set the maximum headroom. If the coverage is more than the threshold plus this value, the threshold will be raised.\")\n\trootCmd.Flags().StringArrayVarP(&buildArgs, \"build-arg\", \"b\", getBuildArgDefault(), \"Add a build argument. Build arguments are used to select source files for later coverage checking.\")\n\t_, detailedDefault := os.LookupEnv(\"OVERCOVER_DETAILED\")\n\trootCmd.Flags().BoolVarP(&detailed, \"detailed\", \"d\", detailedDefault, \"Used to request per-file detailed coverage data be emitted. May be used in conjunction with --summary.\")\n\t_, summaryDefault := os.LookupEnv(\"OVERCOVER_SUMMARY\")\n\trootCmd.Flags().BoolVarP(&summary, \"summary\", \"s\", summaryDefault, \"Used to request per-package summary coverage data be emitted. May be used in conjunction with --detailed.\")\n\n\t// Bind them to viper\n\t_ = viper.BindPFlag(\"threshold\", rootCmd.Flags().Lookup(\"threshold\"))\n\t_ = viper.BindEnv(\"threshold\")\n\t_ = viper.BindPFlag(\"min_headroom\", rootCmd.Flags().Lookup(\"min-headroom\"))\n\t_ = viper.BindEnv(\"min_headroom\")\n\t_ = viper.BindPFlag(\"max_headroom\", rootCmd.Flags().Lookup(\"max-headroom\"))\n\t_ = viper.BindEnv(\"max_headroom\")\n}", "func (c CoverageProfile) TotalLines() int {\n\ttotal := 0\n\tfor _, f := range c {\n\t\ttotal += f.Total\n\t}\n\treturn total\n}", "func (d *Client) TakePreciseCoverage() *TakePreciseCoverageRequest {\n\treturn &TakePreciseCoverageRequest{opts: make(map[string]interface{}), client: d.Client}\n}", "func (mr *MockTestClientMockRecorder) GetBuildCodeCoverage(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"GetBuildCodeCoverage\", reflect.TypeOf((*MockTestClient)(nil).GetBuildCodeCoverage), arg0, arg1)\n}", "func TestSum(t *testing.T) {\n\trequire.Equal(t, int64(2), coverme.Sum(1, 1))\n}", "func repoCoverStatus(repo, tag string, priority bool) (bool, error) {\n\t// Check if cover run is already in progress for the given repo and tag\n\terr := redisRing.HGet(inProgrsKey, repoFullName(repo, tag, priority)).Err()\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\terrMsg := err.Error()\n\tif errMsg != \"redis: nil\" {\n\t\terrLogger.Println(errMsg)\n\t}\n\n\treturn false, err\n}", "func (c CoverageProfile) NonCoveredFuncs() int {\n\ttotal := 0\n\tfor _, f := range c {\n\t\tif f.Covered == 0 {\n\t\t\ttotal++\n\t\t}\n\t}\n\treturn total\n}", "func GetCoverageIndex(params WCSParams, config *Config) (int, error) {\n\tif params.Coverages != nil {\n\t\tproduct := params.Coverages[0]\n\t\tfor i := range config.Layers {\n\t\t\tif config.Layers[i].Name == product {\n\t\t\t\treturn i, nil\n\t\t\t}\n\t\t}\n\t\treturn -1, fmt.Errorf(\"%s not found in config Layers\", product)\n\t}\n\treturn -1, fmt.Errorf(\"WCS request doesn't specify a product\")\n}", "func TestMaintenanceCodecov(t *testing.T) {\n\t// For Codecov - this does not test anything\n\tf := NewFactory()\n\tv, command := config.Viperize(f.AddFlags)\n\t// Lets speed up the maintenance ticker..\n\tcommand.ParseFlags([]string{\n\t\t\"--badger.maintenance-interval=10ms\",\n\t})\n\tf.InitFromViper(v, zap.NewNop())\n\tmFactory := metricstest.NewFactory(0)\n\tf.Initialize(mFactory, zap.NewNop())\n\tdefer f.Close()\n\n\twaiter := func() {\n\t\tfor sleeps := 0; sleeps < 8; sleeps++ {\n\t\t\t// Wait for the scheduler\n\t\t\ttime.Sleep(time.Duration(50) * time.Millisecond)\n\t\t}\n\t}\n\n\terr := f.store.Close()\n\tassert.NoError(t, err)\n\twaiter() // This should trigger the logging of error\n}", "func (dc *Chain) Test(currentAdditions []gitrepo.Addition, talismanRC *talismanrc.TalismanRC, result *helpers.DetectionResults) {\n\twd, _ := os.Getwd()\n\trepo := gitrepo.RepoLocatedAt(wd)\n\tallAdditions := repo.TrackedFilesAsAdditions()\n\thasher := utility.MakeHasher(dc.mode, wd)\n\tcalculator := checksumcalculator.NewChecksumCalculator(hasher, append(allAdditions, currentAdditions...))\n\tcc := helpers.NewChecksumCompare(calculator, hasher, talismanRC)\n\tlog.Printf(\"Number of files to scan: %d\\n\", len(currentAdditions))\n\tlog.Printf(\"Number of detectors: %d\\n\", len(dc.detectors))\n\ttotal := len(currentAdditions) * len(dc.detectors)\n\tprogressBar := utility.GetProgressBar(os.Stdout, \"Talisman Scan\")\n\tprogressBar.Start(total)\n\tfor _, v := range dc.detectors {\n\t\tv.Test(cc, currentAdditions, talismanRC, result, func() {\n\t\t\tprogressBar.Increment()\n\t\t})\n\t}\n\tprogressBar.Finish()\n}", "func main() {\n\tgeneric.AddToInlineRegistry(\"sync/pipelinecoverage\", coverage.Sync)\n\n\tstart.Start()\n}", "func (o Scorecard) RunTests(ctx context.Context) (testOutput v1alpha3.Test, err error) {\n\n\terr = o.TestRunner.Initialize(ctx)\n\tif err != nil {\n\t\treturn testOutput, err\n\t}\n\n\ttests := o.selectTests()\n\tif len(tests) == 0 {\n\t\treturn testOutput, nil\n\t}\n\n\tfor _, test := range tests {\n\t\tresult, err := o.TestRunner.RunTest(ctx, test)\n\t\tif err != nil {\n\t\t\tresult = convertErrorToStatus(test.Name, err)\n\t\t}\n\t\ttestOutput.Status.Results = append(testOutput.Status.Results, result.Results...)\n\t}\n\n\tif !o.SkipCleanup {\n\t\terr = o.TestRunner.Cleanup(ctx)\n\t\tif err != nil {\n\t\t\treturn testOutput, err\n\t\t}\n\t}\n\treturn testOutput, nil\n}", "func (gc *LinearConverter) LatitudeCoverage() float64 {\n\treturn gc.MaxLatitude() - gc.MinLatitude()\n}", "func RunPresubmit(p *gcs.PreSubmit, arts *artifacts.LocalArtifacts) (bool, error) {\n\tlog.Println(\"starting PreSubmit.RunPresubmit(...)\")\n\n\t// concerned files is a collection of all the files whose coverage change will be reported\n\tvar concernedFiles map[string]bool\n\n\tif p.GithubClient != nil {\n\t\tconcernedFiles = githubUtil.GetConcernedFiles(&p.GithubPr, \"\")\n\t\tif len(concernedFiles) == 0 {\n\t\t\tlog.Printf(\"List of concerned committed files is empty, \" +\n\t\t\t\t\"don't need to run coverage profile in presubmit\\n\")\n\t\t\treturn false, nil\n\t\t}\n\t}\n\n\tgNew := calc.CovList(arts.ProfileReader(), arts.KeyProfileCreator(),\n\t\tconcernedFiles, p.CovThreshold)\n\terr := line.CreateLineCovFile(arts)\n\tline.GenerateLineCovLinks(p, gNew)\n\n\tbase := gcs.NewPostSubmit(p.Ctx, p.Client, p.Bucket,\n\t\tp.PostSubmitJob, gcs.ArtifactsDirNameOnGcs, arts.ProfileName())\n\tgBase := calc.CovList(base.ProfileReader(), nil, concernedFiles, p.CovThreshold)\n\tchanges := calc.NewGroupChanges(gBase, gNew)\n\n\tpostContent, isEmpty, isCoverageLow := changes.ContentForGithubPost(concernedFiles)\n\n\tio.Write(&postContent, arts.Directory(), \"bot-post\")\n\n\tif !isEmpty && p.GithubClient != nil {\n\t\terr = p.GithubPr.CleanAndPostComment(postContent)\n\t}\n\n\tlog.Println(\"completed PreSubmit.RunPresubmit(...)\")\n\treturn isCoverageLow, err\n}", "func (ct *cpuTracker) CumulativeUtilization(currentTime time.Time) float64 {\n\tct.lock.Lock()\n\tdefer ct.lock.Unlock()\n\n\treturn ct.cumulativeMeter.Read(currentTime)\n}", "func TestConvergence(t *testing.T) {\n\tdefer leaktest.AfterTest(t)\n\t// 100 milliseconds to accommodate race tests on slower hardware.\n\tverifyConvergence(10, 8, 100*time.Millisecond, t)\n}", "func RegisterCover(c Cover) {}", "func (o Node) Cover(pokemonType int) bool {\n\tif Effectiveness[o.Type][pokemonType] == 20 {\n\t\treturn true\n\t}\n\tfor o.Parent != nil {\n\t\to = *o.Parent\n\t\tif Effectiveness[o.Type][pokemonType] == 20 {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func ProcessProfile(profile CoverageProfile, settings *CoverageSettings) (string, error) {\n\tout := \"\"\n\tmaxLoc := 0\n\tmaxName := 0\n\tfor _, item := range profile {\n\t\tif item.Percent < 100. {\n\t\t\tif l := len(item.SourceRef); l > maxLoc {\n\t\t\t\tmaxLoc = l\n\t\t\t}\n\t\t\tif l := len(item.Name); l > maxName {\n\t\t\t\tmaxName = l\n\t\t\t}\n\t\t}\n\t}\n\tfor _, item := range profile {\n\t\tif item.Percent < 100. {\n\t\t\tmissing := \"\"\n\t\t\t// Don't bother printing missing lines if coverage is 0.\n\t\t\tif len(item.Missing) != 0 && item.Percent > 0 {\n\t\t\t\tmissing = \" \" + rangeToString(item.Missing)\n\t\t\t}\n\t\t\tout += fmt.Sprintf(\"%-*s %-*s %4.1f%% (%d/%d)%s\\n\", maxLoc, item.SourceRef, maxName, item.Name, item.Percent, item.Covered, item.Total, missing)\n\t\t}\n\t}\n\tresult, success := profile.Passes(settings)\n\tout += result + \"\\n\"\n\tif !success {\n\t\treturn out, errors.New(result)\n\t}\n\treturn out, nil\n}", "func (Report) HTML() error {\n\treturn coverage.HTMLReport()\n}", "func repoCover(repo, imageTag string) (*Object, error) {\n\tobj := &Object{\n\t\tRepo: repo,\n\t\tTag: imageTag,\n\t}\n\n\tif !goversionSupported(imageTag) {\n\t\tobj.Cover = ErrImgUnSupported.Error()\n\t\treturn obj, ErrImgUnSupported\n\t}\n\n\terr := redisCodec.Get(repoFullName(repo, imageTag, false), &obj)\n\tif err == nil {\n\t\t// Check if repo is about to expire, if yes then start cover run again to refresh cache.\n\t\t// This will help repositories with frequent requests to have the coverage details updated\n\t\t// and available all the time (if re-run is completed on time)\n\t\tnow := time.Now()\n\t\taddedAt := obj.AddedAt\n\t\taddedAt = addedAt.Add(cacheExpiry)\n\t\tdelta := addedAt.Sub(now)\n\t\tif delta > 0 && delta < refreshWindow {\n\t\t\t// In case of repos getting frequent checks, the re-run request will not\n\t\t\t// be queued and will be run immediately as high priority\n\t\t\tinprogress, _ := repoCoverStatus(obj.Repo, obj.Tag, true)\n\t\t\tif !inprogress {\n\t\t\t\tgo cover(obj.Repo, obj.Tag, true)\n\t\t\t}\n\t\t}\n\t\treturn obj, nil\n\t}\n\terrMsg := err.Error()\n\tif errMsg != \"cache: key is missing\" {\n\t\terrLogger.Println(errMsg)\n\t}\n\n\treturn checkAndPush(obj)\n}", "func (v *VaccineSummary) VaccinatedPercent() float64 {\n\treturn float64(v.Summary.FirstDose) / KeralaPopulation * 100\n}", "func CheckPercentageSumForCycle(cycle int, delegatedContracts []DelegatedContract) float64{\n var sum float64\n sum = 0\n for x := 0; x < len(delegatedContracts); x++{\n counter := 0\n for y := 0; y < len(delegatedContracts[x].Contracts); y++{\n if (delegatedContracts[x].Contracts[y].Cycle == cycle){\n break\n }\n counter = counter + 1\n }\n\n sum = sum + delegatedContracts[x].Contracts[counter].SharePercentage\n }\n return sum\n}", "func (d *Client) StopPreciseCoverage() *StopPreciseCoverageRequest {\n\treturn &StopPreciseCoverageRequest{opts: make(map[string]interface{}), client: d.Client}\n}", "func (manager *Manager) PercentageComplete() float32 {\n\tswitch manager.state {\n\tcase notRunningState:\n\tcase runningState:\n\t\treturn manager.percentageComplete\n\tdefault:\n\t}\n\n\treturn 1.0\n}", "func (o DeliveryPipelineSerialPipelineStageStrategyCanaryCanaryDeploymentOutput) Percentages() pulumi.IntArrayOutput {\n\treturn o.ApplyT(func(v DeliveryPipelineSerialPipelineStageStrategyCanaryCanaryDeployment) []int { return v.Percentages }).(pulumi.IntArrayOutput)\n}", "func Percent(value int64, total int64) float64 {\n\tif total == 0 {\n\t\treturn 0\n\t}\n\treturn (float64(value) / float64(total)) * 100\n}", "func (a *Analytics) TestProtecionNumber() {\n\tfmt.Println(\"Test: protection number\")\n\n\tf, w := createFileWithWriter(\"results_protection.csv\")\n\tdefer f.Close()\n\n\tt := &trees.Tree{}\n\n\t_, err := w.WriteString(\"k,v\\n\")\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tcounter := make(map[int]int)\n\n\tfor r := 0; r < 1000000; r++ {\n\t\tif r%100000 == 0 {\n\t\t\tfmt.Printf(\"Progress: %d\\n\", r)\n\t\t}\n\n\t\tt.Generate(500)\n\t\tmin, _ := t.Stats()\n\n\t\tcounter[min]++\n\t}\n\n\tfor k, v := range counter {\n\t\t_, err := w.WriteString(fmt.Sprintf(\"%d,%d\\n\", k, v))\n\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\n\t\tw.Flush()\n\t}\n}", "func GolangTest(t *testing.T, pkgs []string, o *Options) {\n\tSkipWithoutQEMU(t)\n\t// TODO: support arm\n\tif TestArch() != \"amd64\" && TestArch() != \"arm64\" {\n\t\tt.Skipf(\"test not supported on %s\", TestArch())\n\t}\n\n\tvmCoverProfile, ok := os.LookupEnv(\"UROOT_QEMU_COVERPROFILE\")\n\tif !ok {\n\t\tt.Log(\"QEMU test coverage is not collected unless UROOT_QEMU_COVERPROFILE is set\")\n\t}\n\n\tif o == nil {\n\t\to = &Options{}\n\t}\n\n\t// Create a temporary directory.\n\tif len(o.TmpDir) == 0 {\n\t\ttmpDir, err := os.MkdirTemp(\"\", \"uroot-integration\")\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\to.TmpDir = tmpDir\n\t}\n\n\tif o.BuildOpts.UrootSource == \"\" {\n\t\tsourcePath, ok := os.LookupEnv(\"UROOT_SOURCE\")\n\t\tif !ok {\n\t\t\tt.Fatal(\"This test needs UROOT_SOURCE set to the absolute path of the checked out u-root source\")\n\t\t}\n\t\to.BuildOpts.UrootSource = sourcePath\n\t}\n\n\t// Set up u-root build options.\n\tenv := gbbgolang.Default(gbbgolang.DisableCGO(), gbbgolang.WithGOARCH(TestArch()))\n\to.BuildOpts.Env = env\n\n\t// Statically build tests and add them to the temporary directory.\n\tvar tests []string\n\ttestDir := filepath.Join(o.TmpDir, \"tests\")\n\n\tif len(vmCoverProfile) > 0 {\n\t\tf, err := os.Create(filepath.Join(o.TmpDir, \"coverage.profile\"))\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"Could not create coverage file %v\", err)\n\t\t}\n\t\tif err := f.Close(); err != nil {\n\t\t\tt.Fatalf(\"Could not close coverage.profile: %v\", err)\n\t\t}\n\t}\n\n\tfor _, pkg := range pkgs {\n\t\tpkgDir := filepath.Join(testDir, pkg)\n\t\tif err := os.MkdirAll(pkgDir, 0o755); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\ttestFile := filepath.Join(pkgDir, fmt.Sprintf(\"%s.test\", path.Base(pkg)))\n\n\t\targs := []string{\n\t\t\t\"test\",\n\t\t\t\"-gcflags=all=-l\",\n\t\t\t\"-ldflags\", \"-s -w\",\n\t\t\t\"-c\", pkg,\n\t\t\t\"-o\", testFile,\n\t\t}\n\t\tif len(vmCoverProfile) > 0 {\n\t\t\targs = append(args, \"-covermode=atomic\")\n\t\t}\n\n\t\tcmd := env.GoCmd(args...)\n\t\tif stderr, err := cmd.CombinedOutput(); err != nil {\n\t\t\tt.Fatalf(\"could not build %s: %v\\n%s\", pkg, err, string(stderr))\n\t\t}\n\n\t\t// When a package does not contain any tests, the test\n\t\t// executable is not generated, so it is not included in the\n\t\t// `tests` list.\n\t\tif _, err := os.Stat(testFile); !os.IsNotExist(err) {\n\t\t\ttests = append(tests, pkg)\n\n\t\t\tpkgs, err := lookupPkgs(o.BuildOpts.Env, \"\", pkg)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"Failed to look up package %q: %v\", pkg, err)\n\t\t\t}\n\n\t\t\t// One directory = one package in standard Go, so\n\t\t\t// finding the first file's parent directory should\n\t\t\t// find us the package directory.\n\t\t\tvar dir string\n\t\t\tfor _, p := range pkgs {\n\t\t\t\tif len(p.GoFiles) > 0 {\n\t\t\t\t\tdir = filepath.Dir(p.GoFiles[0])\n\t\t\t\t}\n\t\t\t}\n\t\t\tif dir == \"\" {\n\t\t\t\tt.Fatalf(\"Could not find package directory for %q\", pkg)\n\t\t\t}\n\n\t\t\t// Optimistically copy any files in the pkg's\n\t\t\t// directory, in case e.g. a testdata dir is there.\n\t\t\tif err := copyRelativeFiles(dir, filepath.Join(testDir, pkg)); err != nil {\n\t\t\t\tt.Fatal(err)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Create the CPIO and start QEMU.\n\to.BuildOpts.AddBusyBoxCommands(\"github.com/u-root/u-root/cmds/core/*\")\n\to.BuildOpts.AddCommands(uroot.BinaryCmds(\"cmd/test2json\")...)\n\n\t// Specify the custom gotest uinit.\n\to.Uinit = \"github.com/u-root/u-root/integration/testcmd/gotest/uinit\"\n\n\ttc := json2test.NewTestCollector()\n\tserial := []io.Writer{\n\t\t// Collect JSON test events in tc.\n\t\tjson2test.EventParser(tc),\n\t\t// Write non-JSON output to log.\n\t\tJSONLessTestLineWriter(t, \"serial\"),\n\t}\n\tif o.QEMUOpts.SerialOutput != nil {\n\t\tserial = append(serial, o.QEMUOpts.SerialOutput)\n\t}\n\to.QEMUOpts.SerialOutput = uio.MultiWriteCloser(serial...)\n\tif len(vmCoverProfile) > 0 {\n\t\to.QEMUOpts.KernelArgs += \" uroot.uinitargs=-coverprofile=/testdata/coverage.profile\"\n\t}\n\n\tq, cleanup := QEMUTest(t, o)\n\tdefer cleanup()\n\n\tif err := q.Expect(\"TESTS PASSED MARKER\"); err != nil {\n\t\tt.Errorf(\"Waiting for 'TESTS PASSED MARKER' signal: %v\", err)\n\t}\n\n\tif len(vmCoverProfile) > 0 {\n\t\tcov, err := os.Open(filepath.Join(o.TmpDir, \"coverage.profile\"))\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"No coverage file shared from VM: %v\", err)\n\t\t}\n\n\t\tout, err := os.OpenFile(vmCoverProfile, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0644)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"Could not open vmcoverageprofile: %v\", err)\n\t\t}\n\n\t\tif _, err := io.Copy(out, cov); err != nil {\n\t\t\tt.Fatalf(\"Error copying coverage: %s\", err)\n\t\t}\n\t\tif err := out.Close(); err != nil {\n\t\t\tt.Fatalf(\"Could not close vmcoverageprofile: %v\", err)\n\t\t}\n\t\tif err := cov.Close(); err != nil {\n\t\t\tt.Fatalf(\"Could not close coverage.profile: %v\", err)\n\t\t}\n\t}\n\n\t// TODO: check that tc.Tests == tests\n\tfor pkg, test := range tc.Tests {\n\t\tswitch test.State {\n\t\tcase json2test.StateFail:\n\t\t\tt.Errorf(\"Test %v failed:\\n%v\", pkg, test.FullOutput)\n\t\tcase json2test.StateSkip:\n\t\t\tt.Logf(\"Test %v skipped\", pkg)\n\t\tcase json2test.StatePass:\n\t\t\t// Nothing.\n\t\tdefault:\n\t\t\tt.Errorf(\"Test %v left in state %v:\\n%v\", pkg, test.State, test.FullOutput)\n\t\t}\n\t}\n}", "func (t *transfer) Percentage() int {\n\t// catch zero values\n\tif t.progress == 0 || t.size == 0 {\n\t\treturn 0\n\t}\n\t// calculate\n\treturn int(100.0 * (float32(t.progress) / float32(t.size)))\n}", "func KillAgentTestServicesRetrieveCoverage(client *rancher.Client) error {\n\tclusters, err := client.Steve.SteveType(clusters.ProvisioningSteveResourceType).ListAll(nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, cluster := range clusters.Data {\n\t\tclusterStatus := &apiv1.ClusterStatus{}\n\t\terr = v1.ConvertToK8sType(cluster.Status, clusterStatus)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tclusterID := clusterStatus.ClusterName\n\t\tif clusterID != localCluster {\n\t\t\tdynamicClient, err := client.GetDownStreamClusterClient(clusterID)\n\t\t\tif err != nil {\n\t\t\t\tlogrus.Errorf(\"could not connect to downstream cluster\")\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tpods, err := dynamicClient.Resource(podGroupVersionResource).Namespace(cattleSystemNameSpace).List(context.Background(), metav1.ListOptions{})\n\t\t\tif err != nil {\n\t\t\t\tlogrus.Errorf(\"could not list pods\")\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tvar podNames []string\n\t\t\tfor _, pod := range pods.Items {\n\t\t\t\tif strings.Contains(pod.GetName(), \"cattle-cluster-agent\") {\n\t\t\t\t\tpodNames = append(podNames, pod.GetName())\n\t\t\t\t}\n\t\t\t}\n\n\t\t\terr = killTestServices(client, clusterID, podNames)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\terr = checkServiceIsRunning(dynamicClient)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\terr = retrieveCodeCoverageFile(client, clusterID, agentCoverFile, podNames)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}" ]
[ "0.7348242", "0.71339047", "0.7077023", "0.70469147", "0.7039095", "0.66986245", "0.64924324", "0.63718826", "0.63314337", "0.6119978", "0.5918472", "0.58236927", "0.580131", "0.5723934", "0.56657857", "0.5625121", "0.5540426", "0.54250145", "0.542137", "0.53964365", "0.5395117", "0.537481", "0.5317526", "0.53061193", "0.52650726", "0.5135992", "0.51309025", "0.51253575", "0.51147497", "0.5080049", "0.5069407", "0.5067684", "0.49806008", "0.49557397", "0.49557397", "0.49487168", "0.49284494", "0.49078518", "0.48999983", "0.4888741", "0.48761424", "0.48721045", "0.48360285", "0.48320565", "0.4771083", "0.4744841", "0.47022653", "0.46867386", "0.467276", "0.46727577", "0.46629548", "0.46085632", "0.45640606", "0.45438403", "0.45291954", "0.4509953", "0.44964844", "0.4477275", "0.44653165", "0.44453394", "0.44399348", "0.44200113", "0.4409748", "0.43799126", "0.4374736", "0.43697298", "0.43541753", "0.43398052", "0.43366972", "0.4334408", "0.43334693", "0.43267927", "0.43170106", "0.43148494", "0.43078274", "0.4298843", "0.42775926", "0.426429", "0.42594105", "0.42539063", "0.42078194", "0.42070177", "0.42030895", "0.41706377", "0.41703433", "0.41234654", "0.41132975", "0.4111755", "0.4105716", "0.40866923", "0.40846983", "0.40781543", "0.40725225", "0.4063043", "0.4058218", "0.405602", "0.4050491", "0.40476647", "0.4040077", "0.4035735" ]
0.6979682
5
RegisterCover records the coverage data accumulators for the tests. NOTE: This function is internal to the testing infrastructure and may change. It is not covered (yet) by the Go 1 compatibility guidelines.
func RegisterCover(c Cover) {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func RegisterCover(c Cover)", "func Cover() error {\n\tmg.Deps(getEnvironment, Clean, GetBuildName)\n\tfmt.Println(fmt.Sprintf(\"Testing with coverage gpsa... \"))\n\tfmt.Println(\"# ########################################################################################\")\n\n\terr := gobuildhelpers.CoverTestFolders(gpsaBuildContext.PackagesToTest, gpsaBuildContext.LogDir, \"TestCoverage.log\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Println(\"# ########################################################################################\")\n\treturn nil\n}", "func Coverage() error {\n\tmg.Deps(Test)\n\treturn sh.Run(\"go\", \"tool\", \"cover\", \"-html=coverage.out\")\n}", "func (g Go) Cover(ctx context.Context) error {\n\tmg.CtxDeps(ctx, g.CheckVersion)\n\tgf, err := goFiles()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif need, _ := target.Path(\"coverage.out\", gf...); need {\n\t\tmg.Deps(g.Test)\n\t}\n\treturn goCover(strings.Split(CoverArgs, \" \")...)\n}", "func Coverage() error {\n\tif _, err := os.Stat(\"./coverage.out\"); err != nil {\n\t\treturn fmt.Errorf(\"run mage test befor checking the code coverage\")\n\t}\n\treturn sh.RunV(\"go\", \"tool\", \"cover\", \"-html=coverage.out\")\n}", "func (g Go) Coverage(ctx context.Context) error {\n\tmg.CtxDeps(ctx, g.CheckVersion, g.Cover)\n\tgf, err := goFiles()\n\tif err != nil {\n\t\treturn err\n\t}\n\tneed, _ := target.Path(\"coverage.out\", gf...)\n\tif need {\n\t\tmg.Deps(g.Test)\n\t}\n\treturn goCover(\"-html=coverage.out\")\n}", "func TestRedisRegister(t *testing.T) {\n\tMysqlDropAll()\n\tMysqlRegister()\n\n\tMysqlInitData()\n\n\tRedisRegister()\n\tRedisInitData()\n\n\t//InitResourceDirs()\n\n\tRedisUnRegister()\n\tMysqlUnRegister()\n}", "func(m *Monitor) RegisterCounter(nameSpace, subSystem, name string, labelNames []string) {\n\tif !m.readOnly {\n\t\tif m.instance != nameSpace {\n\t\t\tpanic(fmt.Sprintf(\"invaid name space %s\", nameSpace))\n\t\t}\n\t\tif len(labelNames) > 0 {\n\t\t\tcounter := prometheus.NewCounterVec(\n\t\t\t\tprometheus.CounterOpts{\n\t\t\t\t\tNamespace: nameSpace,\n\t\t\t\t\tSubsystem: subSystem,\n\t\t\t\t\tName: name,\n\t\t\t\t}, labelNames)\n\t\t\tif _, ok := m.counters.LoadOrStore(MKey{nameSpace, subSystem, name}, counter); ok {\n\t\t\t\tpanic(fmt.Sprintf(\"repeated registration counter for %s %s %s\", nameSpace, subSystem, name))\n\t\t\t} else {\n\t\t\t\tm.pusher.Collector(counter)\n\t\t\t}\n\t\t} else {\n\t\t\tcounter := prometheus.NewCounter(\n\t\t\t\tprometheus.CounterOpts{\n\t\t\t\t\tNamespace: nameSpace,\n\t\t\t\t\tSubsystem: subSystem,\n\t\t\t\t\tName: name,\n\t\t\t\t})\n\t\t\tif _, ok := m.counters.LoadOrStore(MKey{nameSpace, subSystem, name}, counter); ok {\n\t\t\t\tpanic(fmt.Sprintf(\"repeated registration counter for %s %s %s\", nameSpace, subSystem, name))\n\t\t\t} else {\n\t\t\t\tm.pusher.Collector(counter)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tpanic(\"monitor already start\")\n\t}\n}", "func (mr *MockKubeNamespaceClientMockRecorder) Register() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockKubeNamespaceClient)(nil).Register))\n}", "func Register(pvLister PVLister, pvcLister PVCLister) {\n\tregisterMetrics.Do(func() {\n\t\tprometheus.MustRegister(newPVAndPVCCountCollector(pvLister, pvcLister))\n\t\tprometheus.MustRegister(volumeOperationMetric)\n\t\tprometheus.MustRegister(volumeOperationErrorsMetric)\n\t})\n}", "func (mr *MockHubMockRecorder) Register(c interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockHub)(nil).Register), c)\n}", "func (mr *MockCAClientMockRecorder) Register(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockCAClient)(nil).Register), arg0)\n}", "func (mr *MockLedgerClientMockRecorder) Register(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockLedgerClient)(nil).Register), varargs...)\n}", "func TestCoverage(t *testing.T) {\n\tvar valid int\n\tvar invalid int\n\tfilepath.Walk(\"workdir/corpus\", func(path string, info os.FileInfo, err error) error {\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif info.IsDir() {\n\t\t\treturn nil\n\t\t}\n\n\t\tdata, err := ioutil.ReadFile(path)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\n\t\tr := graphql.Do(graphql.Params{\n\t\t\tSchema: testutil.StarWarsSchema,\n\t\t\tRequestString: string(data),\n\t\t})\n\t\tif len(r.Errors) == 0 {\n\t\t\tvalid++\n\t\t} else {\n\t\t\tinvalid++\n\t\t}\n\t\treturn nil\n\t})\n\tfmt.Println(valid, \"valid\", invalid, \"invalid\")\n}", "func (mr *MockLinkerdDiscoveryEmitterMockRecorder) Register() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockLinkerdDiscoveryEmitter)(nil).Register))\n}", "func (m *MockClusterRegistrationClient) Register(ctx context.Context, remoteConfig clientcmd.ClientConfig, remoteClusterName, remoteWriteNamespace, remoteContextName, discoverySource string, registerOpts cluster_registration.ClusterRegisterOpts) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\", ctx, remoteConfig, remoteClusterName, remoteWriteNamespace, remoteContextName, discoverySource, registerOpts)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func TestRegister(t *testing.T) {\n\n\tfabricCAClient, err := NewFabricCAClient(org1, configImp, cryptoSuiteProvider)\n\tif err != nil {\n\t\tt.Fatalf(\"NewFabricCAClient returned error: %v\", err)\n\t}\n\tuser := mocks.NewMockUser(\"test\")\n\t// Register with nil request\n\t_, err = fabricCAClient.Register(user, nil)\n\tif err == nil {\n\t\tt.Fatalf(\"Expected error with nil request\")\n\t}\n\tif err.Error() != \"registration request required\" {\n\t\tt.Fatalf(\"Expected error registration request required. Got: %s\", err.Error())\n\t}\n\n\t//Register with nil user\n\t_, err = fabricCAClient.Register(nil, &ca.RegistrationRequest{})\n\tif err == nil {\n\t\tt.Fatalf(\"Expected error with nil user\")\n\t}\n\tif !strings.Contains(err.Error(), \"failed to create request for signing identity\") {\n\t\tt.Fatalf(\"Expected error failed to create request for signing identity. Got: %s\", err.Error())\n\t}\n\t// Register with nil user cert and key\n\t_, err = fabricCAClient.Register(user, &ca.RegistrationRequest{})\n\tif err == nil {\n\t\tt.Fatalf(\"Expected error without user enrolment information\")\n\t}\n\tif !strings.Contains(err.Error(), \"failed to create request for signing identity\") {\n\t\tt.Fatalf(\"Expected error failed to create request for signing identity. Got: %s\", err.Error())\n\t}\n\n\tuser.SetEnrollmentCertificate(readCert(t))\n\tkey, err := cryptosuite.GetDefault().KeyGen(cryptosuite.GetECDSAP256KeyGenOpts(true))\n\tif err != nil {\n\t\tt.Fatalf(\"KeyGen return error %v\", err)\n\t}\n\tuser.SetPrivateKey(key)\n\t// Register without registration name parameter\n\t_, err = fabricCAClient.Register(user, &ca.RegistrationRequest{})\n\tif !strings.Contains(err.Error(), \"failed to register user\") {\n\t\tt.Fatalf(\"Expected error failed to register user. Got: %s\", err.Error())\n\t}\n\n\t// Register with valid request\n\tvar attributes []ca.Attribute\n\tattributes = append(attributes, ca.Attribute{Key: \"test1\", Value: \"test2\"})\n\tattributes = append(attributes, ca.Attribute{Key: \"test2\", Value: \"test3\"})\n\tsecret, err := fabricCAClient.Register(user, &ca.RegistrationRequest{Name: \"test\",\n\t\tAffiliation: \"test\", Attributes: attributes})\n\tif err != nil {\n\t\tt.Fatalf(\"fabricCAClient Register return error %v\", err)\n\t}\n\tif secret != \"mockSecretValue\" {\n\t\tt.Fatalf(\"fabricCAClient Register return wrong value %s\", secret)\n\t}\n}", "func StartRegister(ctx context.Context, network string, color string, env map[string]string, verbose bool) tc.Container {\n\t// Start a register container\n\treq := tc.ContainerRequest{\n\t\tImage: \"consensys/fc-retrieval/register:latest\",\n\t\tNetworks: []string{network},\n\t\tEnv: env,\n\t\tNetworkMode: container.NetworkMode(networkMode),\n\t\tNetworkAliases: map[string][]string{network: {\"register\"}},\n\t\tWaitingFor: wait.ForLog(\"Serving register at\"),\n\t\tAutoRemove: true,\n\t}\n\tregisterC, err := tc.GenericContainer(ctx, tc.GenericContainerRequest{\n\t\tContainerRequest: req,\n\t\tStarted: true,\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif verbose {\n\t\tg := &logConsumer{name: fmt.Sprintf(\"register\"), color: color}\n\t\terr = registerC.StartLogProducer(ctx)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tregisterC.FollowOutput(g)\n\t}\n\treturn registerC\n}", "func (ms *MetricStorage) RegisterCounter(name string) frontreport.MetricCounter {\n\treturn metrics.NewRegisteredCounter(name, ms.registry)\n}", "func (mr *MockRoutingRuleClientMockRecorder) Register() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockRoutingRuleClient)(nil).Register))\n}", "func (mr *MockClusterRegistrationClientMockRecorder) Register(ctx, remoteConfig, remoteClusterName, remoteWriteNamespace, remoteContextName, discoverySource, registerOpts interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockClusterRegistrationClient)(nil).Register), ctx, remoteConfig, remoteClusterName, remoteWriteNamespace, remoteContextName, discoverySource, registerOpts)\n}", "func (m *MockLedgerClient) Register(arg0 context.Context, arg1 *ledger.RegisterRequest, arg2 ...grpc.CallOption) (*ledger.RegisterResult, error) {\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"Register\", varargs...)\n\tret0, _ := ret[0].(*ledger.RegisterResult)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (mmRegisterResult *mClientMockRegisterResult) Inspect(f func(ctx context.Context, request insolar.Reference, result RequestResult)) *mClientMockRegisterResult {\n\tif mmRegisterResult.mock.inspectFuncRegisterResult != nil {\n\t\tmmRegisterResult.mock.t.Fatalf(\"Inspect function is already set for ClientMock.RegisterResult\")\n\t}\n\n\tmmRegisterResult.mock.inspectFuncRegisterResult = f\n\n\treturn mmRegisterResult\n}", "func TestInstructionAddReg(t *testing.T) {\n\tchipCfg := GetDefaultConfig()\n\tchip, _, _ := NewCHIP8(chipCfg)\n\n\tchip.Reg[0x0] = 0x00\n\tchip.Reg[0x1] = 0x01\n\tchip.Reg[0x2] = 0xff\n\tchip.Reg[0x3] = 0x04\n\n\tchip.WriteShort(0x200, 0x8014)\n\tchip.WriteShort(0x202, 0x8234)\n\n\tvar tests = []struct {\n\t\tPC uint16\n\t\tregIdx uint8\n\t\tregVal uint8\n\t\tcarry uint8\n\t}{\n\t\t{0x202, 0x0, 0x01, 0x0},\n\t\t{0x204, 0x2, 0x03, 0x1},\n\t}\n\n\tfor i, want := range tests {\n\t\tchip.StepEmulation()\n\n\t\tif chip.PC != want.PC {\n\t\t\tt.Errorf(\"test %d: chip.PC = 0x%x; want 0x%x\", i, chip.PC, want.PC)\n\t\t}\n\n\t\tif chip.Reg[want.regIdx] != want.regVal {\n\t\t\tt.Errorf(\"test %d: chip.Reg[0x%x] = 0x%x; want 0x%x\", i, want.regIdx, chip.Reg[want.regIdx], want.regVal)\n\t\t}\n\n\t\tif chip.Reg[0xf] != want.carry {\n\t\t\tt.Errorf(\"test %d: chip.Reg[0xf] = 0x%x; want 0x%x\", i, chip.Reg[0xf], want.carry)\n\t\t}\n\t}\n}", "func (mr *MockUsersRepoInterfaceMockRecorder) Register(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockUsersRepoInterface)(nil).Register), arg0)\n}", "func Register() {\n\tdefer trace()()\n\tif !conf.UCMConfig.ServiceDiscovery.Enabled {\n\t\treturn\n\t}\n\n\t//prepare for consul registration\n\treg := consul.CatalogRegistration{\n\t\tNode: hostname,\n\t\tAddress: hostip[0],\n\t\tDatacenter: conf.UCMConfig.ServiceDiscovery.Datacenter,\n\t\tService: &consul.AgentService{\n\t\t\tID: conf.UCMConfig.ServiceDiscovery.ServiceID,\n\t\t\tService: conf.UCMConfig.ServiceDiscovery.RegisterServiceName,\n\t\t\tTags: metadataToTags(),\n\t\t\tPort: conf.UCMConfig.Service.ListenPort,\n\t\t\tAddress: hostip[0],\n\t\t},\n\t\tCheck: &consul.AgentCheck{\n\t\t\tNode: hostname,\n\t\t\tCheckID: \"service:\" + conf.UCMConfig.ServiceDiscovery.ServiceID,\n\t\t\tName: conf.UCMConfig.ServiceDiscovery.ServiceID + \" health check\",\n\t\t\tStatus: consul.HealthPassing,\n\t\t\tServiceID: conf.UCMConfig.ServiceDiscovery.ServiceID,\n\t\t},\n\t}\n\n\t//Get the Consul client\n\tcconfig := consul.DefaultNonPooledConfig()\n\tcconfig.Address = conf.UCMConfig.ServiceDiscovery.GetAddress()\n\tclient, err := consul.NewClient(cconfig)\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\tcatalog := client.Catalog()\n\n\t//make the API call to register\n\tw, err := catalog.Register(&reg, &consul.WriteOptions{})\n\tif err != nil {\n\t\tlog.Error(err)\n\t} else {\n\t\tlog.Infof(\"OK: Consul registration succeeded after %d ns.\", w.RequestTime.Nanoseconds())\n\t}\n}", "func registerAndInstrumentMetrics(ctl *controller) error {\n\t// register application metrics\n\terr := registerNebraskaMetrics()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\trefreshInterval := getMetricsRefreshInterval()\n\n\tmetricsTicker := time.Tick(refreshInterval)\n\n\tgo func() {\n\t\tfor {\n\t\t\t<-metricsTicker\n\t\t\terr := calculateMetrics(ctl)\n\t\t\tif err != nil {\n\t\t\t\tlogger.Error().Err(err).Msg(\"registerAndInstrumentMetrics updating the metrics\")\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn nil\n}", "func (mr *MockISubKeyBucketMockRecorder) Register(receiver interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockISubKeyBucket)(nil).Register), receiver)\n}", "func Register() {\n\tregisterConstMetrics()\n\t{{[- if .API.Enabled ]}}\n\tregisterGRPCMetrics()\n\t{{[- end ]}}\n\t{{[- if .Storage.Enabled ]}}\n\tregisterDatabaseMetrics()\n\t{{[- end ]}}\n\tregisterBusinessMetrics()\n}", "func (mr *MockRecoverer) Ecrecover(data []byte, sig Signature) ([]byte, error) {\n\treturn wutil.Ecrecover(data, sig)\n}", "func (c *mockMediatorClient) Register(connectionID string) error {\n\tif c.RegisterErr != nil {\n\t\treturn c.RegisterErr\n\t}\n\n\treturn nil\n}", "func (m *MockCAClient) Register(arg0 *api.RegistrationRequest) (string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\", arg0)\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *TestCoverageReport) addCCAPIReport(r model.Report) {\n\tfor _, i := range r.Items {\n\t\tif (i.Kind != model.ReportKindMethod) && (i.Kind != model.ReportKindFunction) {\n\t\t\t// Only collect methods and functions, and nothing else.\n\t\t\tcontinue\n\t\t}\n\t\tn := i.Name\n\t\tif _, ok := m.seen[n]; ok {\n\t\t\t// Skip seen elements.\n\t\t\tcontinue\n\t\t}\n\t\tci := TestCoverageReportItem{\n\t\t\tName: n,\n\t\t\tKind: kindCCAPI,\n\t\t}\n\t\tm.Items = append(m.Items, ci)\n\t\tm.seen[n] = struct{}{}\n\t}\n}", "func cover(repo, goversion string, priority bool) error {\n\tsetInProgress(repo, goversion, priority)\n\n\tstdOut, stdErr, err := run(goversion, repo)\n\tif err != nil {\n\t\terrLogger.Println(err.Error())\n\t\tif len(stdErr) == 0 {\n\t\t\tstdErr = err.Error()\n\t\t}\n\t}\n\n\tunsetInProgress(repo, goversion, priority)\n\n\tobj := &Object{\n\t\tRepo: repo,\n\t\tTag: goversion,\n\t\tCover: stdErr,\n\t\tOutput: false,\n\t\tAddedAt: time.Now(),\n\t}\n\n\tif stdOut != \"\" {\n\t\tobj.Cover = computeCoverage(stdOut)\n\t\tobj.Output = true\n\t}\n\n\trerr := redisCodec.Set(&cache.Item{\n\t\tKey: repoFullName(repo, goversion, priority),\n\t\tObject: obj,\n\t\tExpiration: cacheExpiry,\n\t})\n\tif rerr != nil {\n\t\terrLogger.Println(rerr)\n\t}\n\t// if priority is true, then the request was not pushed to the Q channel,\n\t// So cleanup of channel is not required\n\tif !priority {\n\t\t<-qChan\n\t}\n\n\tif err == nil && obj.Cover == \"\" {\n\t\treturn ErrNoTest\n\t}\n\n\treturn err\n}", "func NewTestCoverageReport() TestCoverageReport {\n\treturn TestCoverageReport{\n\t\tItems: nil,\n\t\tseen: map[string]struct{}{},\n\t}\n}", "func (g *Group) Register(units ...Unit) []bool {\n\tg.log = logger.GetLogger(g.name)\n\thasRegistered := make([]bool, len(units))\n\tfor idx := range units {\n\t\tif !g.configured {\n\t\t\t// if RunConfig has been called we can no longer register Config\n\t\t\t// phases of Units\n\t\t\tif c, ok := units[idx].(Config); ok {\n\t\t\t\tg.c = append(g.c, c)\n\t\t\t\thasRegistered[idx] = true\n\t\t\t}\n\t\t}\n\t\tif p, ok := units[idx].(PreRunner); ok {\n\t\t\tg.p = append(g.p, p)\n\t\t\thasRegistered[idx] = true\n\t\t}\n\t\tif s, ok := units[idx].(Service); ok {\n\t\t\tg.s = append(g.s, s)\n\t\t\thasRegistered[idx] = true\n\t\t}\n\t}\n\treturn hasRegistered\n}", "func (Report) Func() error {\n\treturn coverage.Report()\n}", "func (mr *MockAccountMockRecorder) Register(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockAccount)(nil).Register), arg0, arg1)\n}", "func Register(r adapter.Registrar) {\n\tr.RegisterMetricsBuilder(newBuilder())\n}", "func Register(name string, fn testFunc) {\n\ttests[name] = fn\n}", "func (mr *MockVirtualServiceClientMockRecorder) Register() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockVirtualServiceClient)(nil).Register))\n}", "func (tc *ConsulE2ETest) TestConsulRegistration(f *framework.F) {\n\tt := f.T()\n\tr := require.New(t)\n\n\tnomadClient := tc.Nomad()\n\tjobId := \"consul\" + uuid.Short()\n\ttc.jobIds = append(tc.jobIds, jobId)\n\n\tallocations := e2eutil.RegisterAndWaitForAllocs(f.T(), nomadClient, consulJobBasic, jobId, \"\")\n\trequire.Equal(t, 3, len(allocations))\n\tallocIDs := e2eutil.AllocIDsFromAllocationListStubs(allocations)\n\te2eutil.WaitForAllocsRunning(t, tc.Nomad(), allocIDs)\n\n\texpectedTags := []string{\n\t\t\"cache\",\n\t\t\"global\",\n\t}\n\n\t// Assert services get registered\n\te2eutil.RequireConsulRegistered(r, tc.Consul(), consulNamespace, \"consul-example\", 3)\n\tservices, _, err := tc.Consul().Catalog().Service(\"consul-example\", \"\", nil)\n\trequire.NoError(t, err)\n\tfor _, s := range services {\n\t\t// If we've made it this far the tags should *always* match\n\t\trequire.ElementsMatch(t, expectedTags, s.ServiceTags)\n\t}\n\n\t// Stop the job\n\te2eutil.WaitForJobStopped(t, nomadClient, jobId)\n\n\t// Verify that services were de-registered in Consul\n\te2eutil.RequireConsulDeregistered(r, tc.Consul(), consulNamespace, \"consul-example\")\n}", "func (m *UnsyncListMock) AddClaimsMinimockCounter() uint64 {\n\treturn atomic.LoadUint64(&m.AddClaimsCounter)\n}", "func Coverage() float64 {}", "func (m *Metrics) MustRegister(metrics ...prometheus.Collector) {\n\tm.reg.MustRegister(metrics...)\n}", "func Register(t Tracer) {\n\ttracer = t\n}", "func TestCoverHTML() error {\n\tmg.Deps(getDep)\n\tconst (\n\t\tcoverAll = \"coverage-all.out\"\n\t\tcover = \"coverage.out\"\n\t)\n\tf, err := os.Create(coverAll)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\tif _, err := f.Write([]byte(\"mode: count\")); err != nil {\n\t\treturn err\n\t}\n\tpkgs, err := packages()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, pkg := range pkgs {\n\t\tif err := sh.Run(goexe, \"test\", \"-coverprofile=\"+cover, \"-covermode=count\", pkg); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tb, err := ioutil.ReadFile(cover)\n\t\tif err != nil {\n\t\t\tif os.IsNotExist(err) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t\tidx := bytes.Index(b, []byte{'\\n'})\n\t\tb = b[idx+1:]\n\t\tif _, err := f.Write(b); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif err := f.Close(); err != nil {\n\t\treturn err\n\t}\n\treturn sh.Run(goexe, \"tool\", \"cover\", \"-html=\"+coverAll)\n}", "func TestCoverHTML() error {\n\tconst (\n\t\tcoverAll = \"coverage-all.out\"\n\t\tcover = \"coverage.out\"\n\t)\n\tf, err := os.Create(coverAll)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\tif _, err := f.Write([]byte(\"mode: count\")); err != nil {\n\t\treturn err\n\t}\n\tpkgs, err := packages()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, pkg := range pkgs {\n\t\tif err := sh.Run(goexe, \"test\", \"-coverprofile=\"+cover, pkg); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tb, err := ioutil.ReadFile(cover)\n\t\tif err != nil {\n\t\t\tif os.IsNotExist(err) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t\tidx := bytes.Index(b, []byte{'\\n'})\n\t\tb = b[idx+1:]\n\t\tif _, err := f.Write(b); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif err := f.Close(); err != nil {\n\t\treturn err\n\t}\n\treturn sh.Run(goexe, \"tool\", \"cover\", \"-html=\"+coverAll)\n}", "func (id NodeID) Coverage() (uint64, uint64) {\n\treturn id.Index << id.Level, (id.Index + 1) << id.Level\n}", "func (m *MockHub) Register(c ws.Client) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Register\", c)\n}", "func (m *ClientMock) MinimockRegisterResultInspect() {\n\tfor _, e := range m.RegisterResultMock.expectations {\n\t\tif mm_atomic.LoadUint64(&e.Counter) < 1 {\n\t\t\tm.t.Errorf(\"Expected call to ClientMock.RegisterResult with params: %#v\", *e.params)\n\t\t}\n\t}\n\n\t// if default expectation was set then invocations count should be greater than zero\n\tif m.RegisterResultMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterRegisterResultCounter) < 1 {\n\t\tif m.RegisterResultMock.defaultExpectation.params == nil {\n\t\t\tm.t.Error(\"Expected call to ClientMock.RegisterResult\")\n\t\t} else {\n\t\t\tm.t.Errorf(\"Expected call to ClientMock.RegisterResult with params: %#v\", *m.RegisterResultMock.defaultExpectation.params)\n\t\t}\n\t}\n\t// if func was set then invocations count should be greater than zero\n\tif m.funcRegisterResult != nil && mm_atomic.LoadUint64(&m.afterRegisterResultCounter) < 1 {\n\t\tm.t.Error(\"Expected call to ClientMock.RegisterResult\")\n\t}\n}", "func (i Uint8) Register(comment []string, registrator FieldRegistrator) {\n\tregistrator.AddUint8(comment, i.Name())\n}", "func RegisterGinkgoAlert(test, team, contact, slack, email string, threshold int) {\n\tma := GetMetricAlerts()\n\ttestAlert := MetricAlert{\n\t\tName: test,\n\t\tTeamOwner: team,\n\t\tPrimaryContact: contact,\n\t\tSlackChannel: slack,\n\t\tEmail: email,\n\t\tFailureThreshold: threshold,\n\t}\n\tma.AddAlert(testAlert)\n}", "func MustRegister(registerer prometheus.Registerer) {\n\tregisterer.MustRegister(\n\t\tcommandCircuitOpen,\n\t\tcommandErrorPercentage,\n\t\tcommandErrors,\n\t\tcommandRequests,\n\t\tcommandRollingEvents,\n\t\tcommandConcurrentExecutions,\n\t\tcommandMaxConcurrentExecutions,\n\t\tcommandReportingHosts,\n\n\t\tlatencyTotal,\n\t\tlatencyExecute,\n\n\t\tthreadPoolCurrentCorePoolSize,\n\t\tthreadPoolCurrentLargestPoolSize,\n\t\tthreadPoolCurrentActiveCount,\n\t\tthreadPoolCurrentMaximumPoolSize,\n\t\tthreadPoolCurrentQueueSize,\n\t\tthreadPoolCurrentTaskCount,\n\t\tthreadPoolCurrentCompletedTaskCount,\n\t\tthreadPoolRollingMaxActiveThreads,\n\t\tthreadPoolRollingCountCommandRejections,\n\t\tthreadPoolReportingHosts,\n\t\tthreadPoolCurrentPoolSize,\n\t\tthreadPoolRollingCountThreadsExecuted,\n\t)\n}", "func performCoverage(path string, info os.FileInfo, err error) error {\n\tif err == nil && info.IsDir() && hasGoFile(path) && !fileIgnore.MatchString(path) {\n\t\tpath = \"./\" + path\n\t\tlog.Println(path)\n\t\texec.Command(\"go\", \"test\", \"-covermode=count\", \"-coverprofile=\"+path+\"/\"+covTmpFile, path).Output()\n\t}\n\treturn nil\n}", "func (d *DirectorySpec) RegisterMetric(\n\tpath string,\n\tmetric interface{},\n\tunit units.Unit,\n\tdescription string) error {\n\treturn (*directory)(d).registerMetric(newPathSpec(path), metric, nil, unit, description)\n}", "func register() {\n\tapimetrics.Register()\n\tcachermetrics.Register()\n\tetcd3metrics.Register()\n\tflowcontrolmetrics.Register()\n\tpeerproxymetrics.Register()\n}", "func (r *Registry) RegisterTypeEncoder(valueType reflect.Type, enc ValueEncoder) {\n\tr.typeEncoders.Store(valueType, enc)\n}", "func RegisterReport(report Report) error {\n\tif _, found := reportMap[report.Name()]; found {\n\t\treturn fmt.Errorf(\"a report with that name (%s) already exists\", report.Name())\n\t}\n\treportMap[report.Name()] = report\n\tglog.Infof(\"Registered %#v at %s\", report, report.Name())\n\treturn nil\n}", "func (p *PromMetrics) register() {\n\tp.registry.MustRegister(p.nodeDrainTotal)\n\tp.registry.MustRegister(p.nodeDrainFail)\n\tp.registry.MustRegister(p.nodeReapTotal)\n\tp.registry.MustRegister(p.nodeReapFail)\n}", "func (m *MockRoutingRuleClient) Register() error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\")\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func register(reg *prometheus.Registry) {\n\treg.MustRegister(\n\t\tdroppedBatchVec,\n\t\tdroppedBytesVec,\n\t\trotateVec,\n\t\tputVec,\n\t\tgetVec,\n\t\tputBytesVec,\n\t\twakeupVec,\n\t\tgetBytesVec,\n\n\t\tcapVec,\n\t\tbatchSizeVec,\n\t\tmaxDataVec,\n\t\tsizeVec,\n\t\tdatafilesVec,\n\n\t\tgetLatencyVec,\n\t\tputLatencyVec)\n}", "func NewCover(upstream, policyPath string) (*KubeCover, error) {\n\t// step: parse and validate the upstreams\n\tlocation, err := url.Parse(upstream)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid upstrem url, %s\", err)\n\t}\n\n\tservice := new(KubeCover)\n\tservice.upstream = location\n\n\tglog.Infof(\"kubernetes api: %s\", service.upstream.String())\n\n\t// step: create the policy controller\n\tacl, err := policy.NewController(policyPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tservice.acl = acl\n\n\t// step: create the gin router\n\trouter := gin.Default()\n\trouter.Use(service.proxyHandler())\n\n\t// step: handle operations related to replication controllers]\n\treplicationEndpoint := \"/api/v1/namespaces/:namespace/replicationcontrollers\"\n\treplicationUpdateEndpoint := \"/api/v1/namespaces/:namespace/replicationcontrollers/:name\"\n\trouter.POST(replicationEndpoint, service.handleReplicationController)\n\trouter.PATCH(replicationUpdateEndpoint, service.handleReplicationController)\n\trouter.PUT(replicationUpdateEndpoint, service.handleReplicationController)\n\n\t// step: handle the post operations\n\tpodEndpoint := \"/api/v1/namespaces/:namespace/pods\"\n\tpodUpdate := \"/api/v1/namespaces/:namespace/pods/:name\"\n\trouter.POST(podEndpoint, service.handlePods)\n\trouter.PATCH(podUpdate, service.handlePods)\n\trouter.PUT(podUpdate, service.handlePods)\n\n\tservice.engine = router\n\n\t// step: create and setup the reverse proxy\n\tservice.proxy = httputil.NewSingleHostReverseProxy(service.upstream)\n\tservice.proxy.Transport = buildTransport()\n\n\treturn service, nil\n}", "func (f *contentSpecMgr) Reg(contentType string, spec ContentResolver, unitTest ...bool) {\n\terr := f._reg(contentType, spec)\n\tif err != nil && len(unitTest) == 0 {\n\t\tdebug.Assert(false)\n\t\tcos.ExitLog(err)\n\t}\n}", "func (suite *BinPackingTestSuite) TestRegister() {\n\trankers[DeFrag] = nil\n\tregister(DeFrag, nil)\n\tsuite.Nil(rankers[DeFrag])\n\tregister(DeFrag, NewDeFragRanker)\n\tsuite.Nil(rankers[DeFrag])\n\tdelete(rankers, DeFrag)\n\tregister(DeFrag, NewDeFragRanker)\n\tsuite.NotNil(rankers[DeFrag])\n}", "func (m *SignatureKeyHolderMock) WriteToMinimockCounter() uint64 {\n\treturn atomic.LoadUint64(&m.WriteToCounter)\n}", "func TestCoverageReviewer_AddCoverageReview(t *testing.T) {\n\t/*\n\t\trp := mocks.ReviewProcess{}\n\t\trp.On(\"Start\", \"any\")\n\n\t\tcoverageReviewer{nil, nil, rp, 0.7}\n\t*/\n}", "func (_m *IService) RegisterMix(info models.MixRegistrationInfo) {\n\t_m.Called(info)\n}", "func TestRegisterTrack(t *testing.T) {\n\tfmt.Println(\"Running test TestRegisterTrack\")\n\n\trequest := struct {\n\t\tURL string `json:\"url\"`\n\t}{\"http://skypolaris.org/wp-content/uploads/IGS%20Files/Madrid%20to%20Jerez.igc\"}\n\tvar response struct {\n\t\tID int `json:\"id\"`\n\t}\n\n\t// Add two tracks\n\tif err := sendPostRequest(\"/api/igc\", request, &response); err != nil {\n\t\tt.Fatalf(err.Error())\n\t}\n\n\tif response.ID != 0 {\n\t\tt.Fatalf(\"Expected ID to be 0\")\n\t}\n\n\tif err := sendPostRequest(\"/api/igc\", request, &response); err != nil {\n\t\tt.Fatalf(err.Error())\n\t}\n\n\tif response.ID != 1 {\n\t\tt.Fatalf(\"Expected ID to be 1\")\n\t}\n}", "func (mmRegisterResult *ClientMock) RegisterResultBeforeCounter() uint64 {\n\treturn mm_atomic.LoadUint64(&mmRegisterResult.beforeRegisterResultCounter)\n}", "func (rm ReportManager) RegisterReport(rId string, rTitle string, checker Checker) {\n}", "func (d *DirectorySpec) RegisterMetricInRegion(\n\tpath string,\n\tmetric interface{},\n\tr *Region,\n\tunit units.Unit,\n\tdescription string) error {\n\treturn (*directory)(d).registerMetric(newPathSpec(path), metric, (*region)(r), unit, description)\n}", "func (f *FuncExtent) coverage(profile *Profile) (num, den int64) {\n\t// We could avoid making this n^2 overall by doing a single scan\n\t// and annotating the functions, but the sizes of the data\n\t// structures is never very large and the scan is almost\n\t// instantaneous.\n\tvar covered, total int64\n\t// The blocks are sorted, so we can stop counting as soon as we\n\t// reach the end of the relevant block.\n\tfor _, b := range profile.Blocks {\n\t\tif b.StartLine > f.endLine || (b.StartLine == f.endLine && b.StartCol >= f.endCol) {\n\t\t\t// Past the end of the function.\n\t\t\tbreak\n\t\t}\n\t\tif b.EndLine < f.startLine || (b.EndLine == f.startLine && b.EndCol <= f.startCol) {\n\t\t\t// Before the beginning of the function\n\t\t\tcontinue\n\t\t}\n\t\ttotal += int64(b.NumStmt)\n\t\tif b.Count > 0 {\n\t\t\tcovered += int64(b.NumStmt)\n\t\t}\n\t}\n\treturn covered, total\n}", "func (mmOnConsensusFinished *mGatewayMockOnConsensusFinished) Inspect(f func(ctx context.Context, report mm_network.Report)) *mGatewayMockOnConsensusFinished {\n\tif mmOnConsensusFinished.mock.inspectFuncOnConsensusFinished != nil {\n\t\tmmOnConsensusFinished.mock.t.Fatalf(\"Inspect function is already set for GatewayMock.OnConsensusFinished\")\n\t}\n\n\tmmOnConsensusFinished.mock.inspectFuncOnConsensusFinished = f\n\n\treturn mmOnConsensusFinished\n}", "func (m *MockUserController) Register(context *gin.Context) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Register\", context)\n}", "func (c *Cluster) RegisterMetrics() {\n\n\tfor _, m := range *c.Machines {\n\t\tm.RegisterMetrics()\n\t}\n}", "func (_e *MockDataCoord_Expecter) Register() *MockDataCoord_Register_Call {\n\treturn &MockDataCoord_Register_Call{Call: _e.mock.On(\"Register\")}\n}", "func TestCoverHTML() error {\n\tconst (\n\t\tcoverAll = \"coverage-all.out\"\n\t\tcover = \"coverage.out\"\n\t)\n\tf, err := os.Create(coverAll)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\tif _, err := f.Write([]byte(\"mode: count\")); err != nil {\n\t\treturn err\n\t}\n\tpkgs, err := hugoPackages()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, pkg := range pkgs {\n\t\tif err := sh.Run(goexe, \"test\", \"-coverprofile=\"+cover, \"-covermode=count\", pkg); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tb, err := os.ReadFile(cover)\n\t\tif err != nil {\n\t\t\tif os.IsNotExist(err) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t\tidx := bytes.Index(b, []byte{'\\n'})\n\t\tb = b[idx+1:]\n\t\tif _, err := f.Write(b); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif err := f.Close(); err != nil {\n\t\treturn err\n\t}\n\treturn sh.Run(goexe, \"tool\", \"cover\", \"-html=\"+coverAll)\n}", "func RegisterTests(f *framework.Framework) {\n\tRegistryTest(f)\n}", "func (_m *MockEncoderPool) EXPECT() *MockEncoderPoolMockRecorder {\n\treturn _m.recorder\n}", "func matchCoverage(covs []tt.Coverage) matcherFunc {\n\treturn func(gid fonts.GID, value uint16) bool {\n\t\t_, covered := covs[value].Index(gid)\n\t\treturn covered\n\t}\n}", "func SetupRecordedMetricsTest() (func(), error) {\n\tviews := obsreport.Configure(configtelemetry.LevelNormal)\n\terr := view.Register(views...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn func() {\n\t\tview.Unregister(views...)\n\t}, err\n}", "func (ag *Aggregator) Register(name string, rep Reporter) {\n\tag.mu.Lock()\n\tdefer ag.mu.Unlock()\n\tif _, ok := ag.reporters[name]; ok {\n\t\tpanic(\"reporter named \" + name + \" is already registered\")\n\t}\n\tag.reporters[name] = rep\n\n}", "func (tqsc *Controller) Register() {\n}", "func TestHoldingRegisters(t *testing.T) {\n\ts := sugar.New(t)\n\n\ts.Title(\"4X table test: FC3, FC6, FC16\")\n\n\ts.Assert(\"`4X Table: 60000` Read/Write uint16 value test: FC6, FC3\", func(logf sugar.Log) bool {\n\t\t// =============== write part ==============\n\t\twriteReq := WriteReqBuilder(6, 10, 60000)\n\t\twriteReqStr, _ := json.Marshal(writeReq) // marshal to json string\n\t\tlogf(\"req: %s\", string(writeReqStr))\n\t\tgo publisher(string(writeReqStr))\n\t\t_, s1 := subscriber()\n\t\tlogf(\"res: %s\", s1)\n\n\t\t// parse resonse\n\t\tvar r1 psmb.DMbtcpRes\n\t\tif err := json.Unmarshal([]byte(s1), &r1); err != nil {\n\t\t\tfmt.Println(\"json err:\", err)\n\t\t}\n\t\t// check reponse\n\t\tif r1.Status != \"ok\" {\n\t\t\treturn false\n\t\t}\n\n\t\t// =============== read part ==============\n\t\treadReq := ReadReqBuilder(3, 10, 1)\n\t\treadReqStr, _ := json.Marshal(readReq) // marshal to json string\n\t\tlogf(\"req: %s\", string(readReqStr))\n\t\tgo publisher(string(readReqStr))\n\t\t_, s2 := subscriber()\n\t\tlogf(\"res: %s\", s2)\n\n\t\t// parse resonse\n\t\tvar r2 psmb.DMbtcpRes\n\t\tif err := json.Unmarshal([]byte(s2), &r2); err != nil {\n\t\t\tfmt.Println(\"json err:\", err)\n\t\t}\n\t\t// check reponse\n\t\tif r2.Status != \"ok\" {\n\t\t\treturn false\n\t\t}\n\t\tif r2.Data[0] != 60000 {\n\t\t\treturn false\n\t\t}\n\t\treturn true\n\t})\n\n\ts.Assert(\"`4X Table: 30000` Read/Write int16 value test: FC6, FC3\", func(logf sugar.Log) bool {\n\t\t// =============== write part ==============\n\t\twriteReq := WriteReqBuilder(6, 10, 30000)\n\t\twriteReqStr, _ := json.Marshal(writeReq) // marshal to json string\n\t\tgo publisher(string(writeReqStr))\n\t\t_, s1 := subscriber()\n\t\tlogf(\"req: %s\", string(writeReqStr))\n\t\tlogf(\"res: %s\", s1)\n\n\t\t// parse resonse\n\t\tvar r1 psmb.DMbtcpRes\n\t\tif err := json.Unmarshal([]byte(s1), &r1); err != nil {\n\t\t\tfmt.Println(\"json err:\", err)\n\t\t}\n\t\t// check reponse\n\t\tif r1.Status != \"ok\" {\n\t\t\treturn false\n\t\t}\n\n\t\t// =============== read part ==============\n\t\treadReq := ReadReqBuilder(3, 10, 1)\n\t\treadReqStr, _ := json.Marshal(readReq) // marshal to json string\n\t\tgo publisher(string(readReqStr))\n\t\t_, s2 := subscriber()\n\t\tlogf(\"req: %s\", string(readReqStr))\n\t\tlogf(\"res: %s\", s2)\n\n\t\t// parse resonse\n\t\tvar r2 psmb.DMbtcpRes\n\t\tif err := json.Unmarshal([]byte(s2), &r2); err != nil {\n\t\t\tfmt.Println(\"json err:\", err)\n\t\t}\n\t\t// check reponse\n\t\tif r2.Status != \"ok\" {\n\t\t\treturn false\n\t\t}\n\t\tif r2.Data[0] != 30000 {\n\t\t\treturn false\n\t\t}\n\t\treturn true\n\t})\n\n\t/*\n\t\ts.Assert(\"`4X Table: -20000` Read/Write int16 value test: FC6, FC3\", func(logf sugar.Log) bool {\n\t\t\t// =============== write part ==============\n\t\t\twriteReq := WriteReqBuilder(6, 10, uint16(-20000))\n\t\t\twriteReqStr, _ := json.Marshal(writeReq) // marshal to json string\n\t\t\tgo publisher(string(writeReqStr))\n\t\t\t_, s1 := subscriber()\n\t\t\tlogf(\"req: %s\", string(writeReqStr))\n\t\t\tlogf(\"res: %s\", s1)\n\n\t\t\t// parse resonse\n\t\t\tvar r1 DMbtcpRes\n\t\t\tif err := json.Unmarshal([]byte(s1), &r1); err != nil {\n\t\t\t\tfmt.Println(\"json err:\", err)\n\t\t\t}\n\t\t\t// check reponse\n\t\t\tif r1.Status != \"ok\" {\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\t// =============== read part ==============\n\t\t\treadReq := ReadReqBuilder(3, 10, 1)\n\t\t\treadReqStr, _ := json.Marshal(readReq) // marshal to json string\n\t\t\tgo publisher(string(readReqStr))\n\t\t\t_, s2 := subscriber()\n\t\t\tlogf(\"req: %s\", string(readReqStr))\n\t\t\tlogf(\"res: %s\", s2)\n\n\t\t\t// parse resonse\n\t\t\tvar r2 DMbtcpRes\n\t\t\tif err := json.Unmarshal([]byte(s2), &r2); err != nil {\n\t\t\t\tfmt.Println(\"json err:\", err)\n\t\t\t}\n\t\t\t// check reponse\n\t\t\tif r2.Status != \"ok\" {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif r2.Data[0] != 0xB1E0 {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\t*/\n\n\ts.Assert(\"`4X Table` Multiple read/write test: FC16, FC3\", func(logf sugar.Log) bool {\n\t\t// =============== write part ==============\n\t\twriteReq := WriteMultiReqBuilder(16, 10, 10,\n\t\t\t[]uint16{1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000})\n\n\t\twriteReqStr, _ := json.Marshal(writeReq) // marshal to json string\n\t\tgo publisher(string(writeReqStr))\n\t\t_, s1 := subscriber()\n\t\tlogf(\"req: %s\", string(writeReqStr))\n\t\tlogf(\"res: %s\", s1)\n\n\t\t// parse resonse\n\t\tvar r1 psmb.DMbtcpRes\n\t\tif err := json.Unmarshal([]byte(s1), &r1); err != nil {\n\t\t\tfmt.Println(\"json err:\", err)\n\t\t}\n\t\t// check reponse\n\t\tif r1.Status != \"ok\" {\n\t\t\treturn false\n\t\t}\n\n\t\t// =============== read part ==============\n\t\treadReq := ReadReqBuilder(3, 10, 10)\n\t\treadReqStr, _ := json.Marshal(readReq) // marshal to json string\n\t\tgo publisher(string(readReqStr))\n\t\t_, s2 := subscriber()\n\t\tlogf(\"req: %s\", string(readReqStr))\n\t\tlogf(\"res: %s\", s2)\n\n\t\t// parse resonse\n\t\tvar r2 psmb.DMbtcpRes\n\t\tif err := json.Unmarshal([]byte(s2), &r2); err != nil {\n\t\t\tfmt.Println(\"json err:\", err)\n\t\t}\n\t\t// check reponse\n\t\tif r2.Status != \"ok\" {\n\t\t\treturn false\n\t\t}\n\n\t\tvar index uint16\n\t\tdata := writeReq.Data.([]uint16)\n\t\tfor index = 0; index < readReq.Len; index++ {\n\t\t\tif data[index] != r2.Data[index] {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\treturn true\n\t})\n\n}", "func Test_CollectMetrics11(t *testing.T) {\n\tassert := assert.New(t)\n\tconfig := getTestConfig(1, 1)\n\tconfig.DataFunc = config.GetTestData1\n\n\tres := config.CollectMetrics()\n\t// assert.Nil(res)\n\tassert.Equal(res, []cmd.MetricData{{Name: \"m1\", Help: \"h1\", MetricType: \"gauge\", Stats: []cmd.MetricRecord{{Value: 999, Labels: []string{\"l00\"}, LabelValues: []string{\"lv00\"}}}}})\n}", "func (mmAddNext *mForkingDigesterMockAddNext) Inspect(f func(digest longbits.FoldableReader)) *mForkingDigesterMockAddNext {\n\tif mmAddNext.mock.inspectFuncAddNext != nil {\n\t\tmmAddNext.mock.t.Fatalf(\"Inspect function is already set for ForkingDigesterMock.AddNext\")\n\t}\n\n\tmmAddNext.mock.inspectFuncAddNext = f\n\n\treturn mmAddNext\n}", "func (mr *MockUserControllerMockRecorder) Register(context interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockUserController)(nil).Register), context)\n}", "func (_Posminer *PosminerCallerSession) Registers(arg0 common.Address) (struct {\n\tMinerPool common.Address\n\tRegistryTime *big.Int\n\tPayTime *big.Int\n\tRegister string\n}, error) {\n\treturn _Posminer.Contract.Registers(&_Posminer.CallOpts, arg0)\n}", "func (m *MockLinkerdDiscoveryEmitter) Register() error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\")\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func RegisterTests(f *framework.Framework) {\n\tContainerDeployerTests(f)\n\tManifestDeployerTests(f)\n\thelmcharts.RegisterTests(f)\n\tblueprints.RegisterTests(f)\n\tmanagement.RegisterTests(f)\n}", "func (a *Airlock) RegisterMetrics() error {\n\tif a == nil {\n\t\treturn errors.New(\"nil Airlock\")\n\t}\n\n\tcollectors := []prometheus.Collector{\n\t\tconfigGroupsGauge,\n\t\tconfigSlotsGauge,\n\t\tdatabaseLocksGauge,\n\t\tdatabaseSlotsGauge,\n\t}\n\tfor _, collector := range collectors {\n\t\tif err := prometheus.Register(collector); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tconfigGroupsGauge.Set(float64(len(a.LockGroups)))\n\tfor group, maxSlots := range a.LockGroups {\n\t\tconfigSlotsGauge.WithLabelValues(group).Set(float64(maxSlots))\n\t}\n\n\treturn nil\n}", "func (p *TestProvider) Register(addr string, c Client) {\n\tp.clients[addr] = c\n}", "func (g *Graph) RegisterReference(ref git.Reference, walked bool, groups []RefGroupSymbol) {\n\tg.historyLock.Lock()\n\tg.historySize.recordReference(g, ref)\n\tfor _, group := range groups {\n\t\tg.historySize.recordReferenceGroup(g, group)\n\t}\n\tg.historyLock.Unlock()\n\n\tif walked {\n\t\tg.pathResolver.RecordReference(ref)\n\t}\n}", "func (mmRegisterIncomingRequest *mClientMockRegisterIncomingRequest) Inspect(f func(ctx context.Context, request *record.IncomingRequest)) *mClientMockRegisterIncomingRequest {\n\tif mmRegisterIncomingRequest.mock.inspectFuncRegisterIncomingRequest != nil {\n\t\tmmRegisterIncomingRequest.mock.t.Fatalf(\"Inspect function is already set for ClientMock.RegisterIncomingRequest\")\n\t}\n\n\tmmRegisterIncomingRequest.mock.inspectFuncRegisterIncomingRequest = f\n\n\treturn mmRegisterIncomingRequest\n}", "func (r *Registry) Register(ds ...*Object) {\n\tr.Lock()\n\tdefer r.Unlock()\n\tr.initDataStores()\n\n\tfor _, obj := range ds {\n\t\tname := obj.Name\n\t\tr.dataStores[name] = obj\n\t\tr.dataStores[name].Enabled = true\n\t}\n}", "func Register(coder Coder) {\n\tif coder.Code() == 0 {\n\t\tpanic(\"code `0` is reserved by `github.com/kevinlincg/errors` as unknownCode error code\")\n\t}\n\n\tcodeMux.Lock()\n\tdefer codeMux.Unlock()\n\n\tcodes[coder.Code()] = coder\n}", "func RegisterReportedCasesAPI(router *httprouter.Router, sqlDB *gorm.DB) {\n\t// Validation\n\tvar err error\n\tswitch {\n\tcase sqlDB == nil:\n\t\terr = errors.New(\"sqlDB must not be nil\")\n\tcase router == nil:\n\t\terr = errors.New(\"router must not be nil\")\n\t}\n\thandleError(err)\n\n\treportAPI := &reportAPI{\n\t\tsqlDB: sqlDB,\n\t}\n\n\t// Auto migration\n\terr = reportAPI.sqlDB.AutoMigrate(&ReportedCase{}).Error\n\thandleError(err)\n\n\trouter.GET(\"/rest/v1/cases/reported/:caseId\", reportAPI.GetReport)\n\trouter.GET(\"/rest/v1/cases/reported\", reportAPI.ListReport)\n\trouter.POST(\"/rest/v1/cases/reported\", reportAPI.AddReport)\n\trouter.PATCH(\"/rest/v1/cases/reported/:caseId/attend\", reportAPI.MarkAttended)\n}", "func TestMetricsRecorder(t *testing.T) {\n\tdefer leaktest.AfterTest(t)()\n\n\t// Fake descriptors and stats for status summaries.\n\tnodeDesc := roachpb.NodeDescriptor{\n\t\tNodeID: roachpb.NodeID(1),\n\t}\n\tstoreDesc1 := roachpb.StoreDescriptor{\n\t\tStoreID: roachpb.StoreID(1),\n\t\tCapacity: roachpb.StoreCapacity{\n\t\t\tCapacity: 100,\n\t\t\tAvailable: 50,\n\t\t},\n\t}\n\tstoreDesc2 := roachpb.StoreDescriptor{\n\t\tStoreID: roachpb.StoreID(2),\n\t\tCapacity: roachpb.StoreCapacity{\n\t\t\tCapacity: 200,\n\t\t\tAvailable: 75,\n\t\t},\n\t}\n\tstats := engine.MVCCStats{\n\t\tLiveBytes: 1,\n\t\tKeyBytes: 2,\n\t\tValBytes: 3,\n\t\tIntentBytes: 4,\n\t\tLiveCount: 5,\n\t\tKeyCount: 6,\n\t\tValCount: 7,\n\t\tIntentCount: 8,\n\t\tIntentAge: 9,\n\t\tGCBytesAge: 10,\n\t\tLastUpdateNanos: 1 * 1E9,\n\t}\n\n\t// Create some registries and add them to the recorder (two at node-level,\n\t// two at store-level).\n\treg1 := metric.NewRegistry()\n\treg2 := metric.NewRegistry()\n\tstore1 := fakeStore{\n\t\tstoreID: roachpb.StoreID(1),\n\t\tstats: stats,\n\t\tdesc: storeDesc1,\n\t\tregistry: metric.NewRegistry(),\n\t}\n\tstore2 := fakeStore{\n\t\tstoreID: roachpb.StoreID(2),\n\t\tstats: stats,\n\t\tdesc: storeDesc2,\n\t\tregistry: metric.NewRegistry(),\n\t}\n\tmanual := hlc.NewManualClock(100)\n\trecorder := NewMetricsRecorder(hlc.NewClock(manual.UnixNano))\n\trecorder.AddNodeRegistry(\"one.%s\", reg1)\n\trecorder.AddNodeRegistry(\"two.%s\", reg1)\n\trecorder.AddStore(store1)\n\trecorder.AddStore(store2)\n\trecorder.NodeStarted(nodeDesc, 50)\n\n\t// Ensure the metric system's view of time does not advance during this test\n\t// as the test expects time to not advance too far which would age the actual\n\t// data (e.g. in histogram's) unexpectedly.\n\tdefer metric.TestingSetNow(func() time.Time {\n\t\treturn time.Unix(0, manual.UnixNano()).UTC()\n\t})()\n\n\t// Create a flat array of registries, along with metadata for each, to help\n\t// generate expected results.\n\tregList := []struct {\n\t\treg *metric.Registry\n\t\tprefix string\n\t\tsource int64\n\t}{\n\t\t{\n\t\t\treg: reg1,\n\t\t\tprefix: \"cr.node.one.\",\n\t\t\tsource: 1,\n\t\t},\n\t\t{\n\t\t\treg: reg2,\n\t\t\tprefix: \"cr.node.two.\",\n\t\t\tsource: 1,\n\t\t},\n\t\t{\n\t\t\treg: store1.registry,\n\t\t\tprefix: \"cr.store.\",\n\t\t\tsource: int64(store1.storeID),\n\t\t},\n\t\t{\n\t\t\treg: store2.registry,\n\t\t\tprefix: \"cr.store.\",\n\t\t\tsource: int64(store2.storeID),\n\t\t},\n\t}\n\n\t// Every registry will have the following metrics.\n\tmetricNames := []struct {\n\t\tname string\n\t\ttyp string\n\t\tval int64\n\t}{\n\t\t{\"testGauge\", \"gauge\", 20},\n\t\t{\"testCounter\", \"counter\", 5},\n\t\t{\"testRate\", \"rate\", 2},\n\t\t{\"testHistogram\", \"histogram\", 10},\n\t\t{\"testLatency\", \"latency\", 10},\n\n\t\t// Stats needed for store summaries.\n\t\t{\"ranges\", \"counter\", 1},\n\t\t{\"ranges.leader\", \"gauge\", 1},\n\t\t{\"ranges.replicated\", \"gauge\", 1},\n\t\t{\"ranges.available\", \"gauge\", 1},\n\t}\n\n\t// Add the above metrics to each registry. At the same time, generate\n\t// expected time series results.\n\tvar expected []ts.TimeSeriesData\n\taddExpected := func(prefix, name string, source, time, val int64) {\n\t\texpect := ts.TimeSeriesData{\n\t\t\tName: prefix + name,\n\t\t\tSource: strconv.FormatInt(source, 10),\n\t\t\tDatapoints: []*ts.TimeSeriesDatapoint{\n\t\t\t\t{\n\t\t\t\t\tTimestampNanos: time,\n\t\t\t\t\tValue: float64(val),\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t\texpected = append(expected, expect)\n\t}\n\n\tfor _, data := range metricNames {\n\t\tfor _, reg := range regList {\n\t\t\tswitch data.typ {\n\t\t\tcase \"gauge\":\n\t\t\t\treg.reg.Gauge(data.name).Update(data.val)\n\t\t\t\taddExpected(reg.prefix, data.name, reg.source, 100, data.val)\n\t\t\tcase \"counter\":\n\t\t\t\treg.reg.Counter(data.name).Inc(data.val)\n\t\t\t\taddExpected(reg.prefix, data.name, reg.source, 100, data.val)\n\t\t\tcase \"rate\":\n\t\t\t\treg.reg.Rates(data.name).Add(data.val)\n\t\t\t\taddExpected(reg.prefix, data.name+\"-count\", reg.source, 100, data.val)\n\t\t\t\tfor _, scale := range metric.DefaultTimeScales {\n\t\t\t\t\t// Rate data is subject to timing errors in tests. Zero out\n\t\t\t\t\t// these values.\n\t\t\t\t\taddExpected(reg.prefix, data.name+sep+scale.Name(), reg.source, 100, 0)\n\t\t\t\t}\n\t\t\tcase \"histogram\":\n\t\t\t\treg.reg.Histogram(data.name, time.Second, 1000, 2).RecordValue(data.val)\n\t\t\t\tfor _, q := range recordHistogramQuantiles {\n\t\t\t\t\taddExpected(reg.prefix, data.name+q.suffix, reg.source, 100, data.val)\n\t\t\t\t}\n\t\t\tcase \"latency\":\n\t\t\t\treg.reg.Latency(data.name).RecordValue(data.val)\n\t\t\t\t// Latency is simply three histograms (at different resolution\n\t\t\t\t// time scales).\n\t\t\t\tfor _, scale := range metric.DefaultTimeScales {\n\t\t\t\t\tfor _, q := range recordHistogramQuantiles {\n\t\t\t\t\t\taddExpected(reg.prefix, data.name+sep+scale.Name()+q.suffix, reg.source, 100, data.val)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tactual := recorder.GetTimeSeriesData()\n\n\t// Zero-out timing-sensitive rate values from actual data.\n\tfor _, act := range actual {\n\t\tmatch, err := regexp.MatchString(`testRate-\\d+m`, act.Name)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\tif match {\n\t\t\tact.Datapoints[0].Value = 0.0\n\t\t}\n\t}\n\n\t// Actual comparison is simple: sort the resulting arrays by time and name,\n\t// and use reflect.DeepEqual.\n\tsort.Sort(byTimeAndName(actual))\n\tsort.Sort(byTimeAndName(expected))\n\tif a, e := actual, expected; !reflect.DeepEqual(a, e) {\n\t\tt.Errorf(\"recorder did not yield expected time series collection; diff:\\n %v\", pretty.Diff(e, a))\n\t}\n\n\t// **** STATUS SUMMARY TESTING\n\t// Generate an expected node summary and two store summaries. The\n\t// information here is relatively simple in our test.\n\texpectedNodeSummary := &NodeStatus{\n\t\tDesc: nodeDesc,\n\t\tStartedAt: 50,\n\t\tUpdatedAt: 100,\n\t\tStoreIDs: []roachpb.StoreID{\n\t\t\troachpb.StoreID(1),\n\t\t\troachpb.StoreID(2),\n\t\t},\n\t\tRangeCount: 2,\n\t\tLeaderRangeCount: 2,\n\t\tAvailableRangeCount: 2,\n\t\tReplicatedRangeCount: 2,\n\t}\n\texpectedStoreSummaries := []storage.StoreStatus{\n\t\t{\n\t\t\tDesc: storeDesc1,\n\t\t\tNodeID: roachpb.NodeID(1),\n\t\t\tStartedAt: 50,\n\t\t\tUpdatedAt: 100,\n\t\t\tRangeCount: 1,\n\t\t\tLeaderRangeCount: 1,\n\t\t\tAvailableRangeCount: 1,\n\t\t\tReplicatedRangeCount: 1,\n\t\t\tStats: stats,\n\t\t},\n\t\t{\n\t\t\tDesc: storeDesc2,\n\t\t\tNodeID: roachpb.NodeID(1),\n\t\t\tStartedAt: 50,\n\t\t\tUpdatedAt: 100,\n\t\t\tRangeCount: 1,\n\t\t\tLeaderRangeCount: 1,\n\t\t\tAvailableRangeCount: 1,\n\t\t\tReplicatedRangeCount: 1,\n\t\t\tStats: stats,\n\t\t},\n\t}\n\tfor _, ss := range expectedStoreSummaries {\n\t\texpectedNodeSummary.Stats.Add(ss.Stats)\n\t}\n\n\tnodeSummary, storeSummaries := recorder.GetStatusSummaries()\n\tif nodeSummary == nil {\n\t\tt.Fatalf(\"recorder did not return nodeSummary.\")\n\t}\n\tif storeSummaries == nil {\n\t\tt.Fatalf(\"recorder did not return storeSummaries.\")\n\t}\n\n\tsort.Sort(byStoreDescID(storeSummaries))\n\tsort.Sort(byStoreID(nodeSummary.StoreIDs))\n\tif a, e := nodeSummary, expectedNodeSummary; !reflect.DeepEqual(a, e) {\n\t\tt.Errorf(\"recorder did not produce expected NodeSummary; diff:\\n %v\", pretty.Diff(e, a))\n\t}\n\tif a, e := storeSummaries, expectedStoreSummaries; !reflect.DeepEqual(a, e) {\n\t\tt.Errorf(\"recorder did not produce expected StoreSummaries; diff:\\n %v\", pretty.Diff(e, a))\n\t}\n}", "func (m *manager) test(event fsnotify.Event) {\n\tlogrus.Info(\"testing...\")\n\tm.gil.Do(func() {\n\t\tdefer func() {\n\t\t\tm.gil = &sync.Once{}\n\t\t}()\n\n\t\tm.buildTransaction(func() error {\n\t\t\ttime.Sleep(m.BuildDelay * time.Millisecond)\n\t\t\tnow := time.Now()\n\t\t\tlogrus.Infof(\"retesting on: %s\", event.Name)\n\n\t\t\tif _, err := os.Stat(\"test-coverage\"); err != nil {\n\t\t\t\tos.Mkdir(\"test-coverage\", 0700)\n\t\t\t}\n\n\t\t\t{\n\t\t\t\targs := []string{\n\t\t\t\t\t\"test\",\n\t\t\t\t\t\"./...\",\n\t\t\t\t\t\"-coverprofile=test-coverage/c.out\",\n\t\t\t\t}\n\t\t\t\tcmd := exec.Command(\"go\", args...)\n\n\t\t\t\tif err := m.runAndListen(cmd); err != nil {\n\t\t\t\t\tfmt.Println(err)\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\t{\n\t\t\t\targs := []string{\n\t\t\t\t\t\"tool\",\n\t\t\t\t\t\"cover\",\n\t\t\t\t\t\"-html=test-coverage/c.out\",\n\t\t\t\t\t\"-o=test-coverage/index.html\",\n\t\t\t\t}\n\t\t\t\tcmd := exec.Command(\"go\", args...)\n\n\t\t\t\tif err := m.runAndListen(cmd); err != nil {\n\t\t\t\t\tfmt.Println(err)\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogrus.Infof(\"building completed (time: %s)\", time.Since(now))\n\t\t\treturn nil\n\t\t})\n\n\t})\n}" ]
[ "0.69105786", "0.5583642", "0.5470768", "0.53251094", "0.50624096", "0.4801176", "0.4700892", "0.46729824", "0.4500442", "0.44995344", "0.44930428", "0.44729605", "0.44596648", "0.44516873", "0.4412019", "0.44031498", "0.43717226", "0.43647137", "0.43597794", "0.43418637", "0.4341158", "0.433546", "0.43328506", "0.43050343", "0.42970708", "0.42901257", "0.42617458", "0.42510065", "0.42383024", "0.42289728", "0.4217313", "0.42169622", "0.4206057", "0.4200937", "0.4197501", "0.41954693", "0.41895482", "0.41831604", "0.41771957", "0.41687572", "0.41507912", "0.4136438", "0.41270974", "0.41071865", "0.41039693", "0.4101729", "0.4101257", "0.40985683", "0.40978536", "0.4091046", "0.40763378", "0.4071807", "0.40703556", "0.40519696", "0.4048313", "0.4040813", "0.4033923", "0.40326625", "0.40246794", "0.40239373", "0.4019811", "0.40168992", "0.40157723", "0.40130568", "0.40043515", "0.3999285", "0.39985296", "0.39936876", "0.3989573", "0.39828512", "0.39702016", "0.3966455", "0.39635116", "0.3951889", "0.39470443", "0.39422423", "0.39415765", "0.39395636", "0.39246503", "0.39141756", "0.39129326", "0.39121807", "0.39117295", "0.39109167", "0.3910879", "0.39090863", "0.3905853", "0.39044043", "0.39011914", "0.38992605", "0.389892", "0.3896236", "0.3884116", "0.38836616", "0.38832435", "0.38810903", "0.38700724", "0.38670784", "0.38651964", "0.38645592" ]
0.6839271
1
RunExamples is an internal function but exported because it is crosspackage; it is part of the implementation of the "go test" command.
func RunExamples(matchString func(pat, str string) (bool, error), examples []InternalExample) (ok bool) {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func RunExamples(matchString func(pat, str string) (bool, error), examples []InternalExample) (ok bool) {\n\t_, ok = runExamples(matchString, examples)\n\treturn ok\n}", "func execExamples(arity int, p *gop.Context) {\n\targs := p.GetArgs(arity)\n\tconv := func(args []interface{}) []*ast.File {\n\t\tret := make([]*ast.File, len(args))\n\t\tfor i, arg := range args {\n\t\t\tret[i] = arg.(*ast.File)\n\t\t}\n\t\treturn ret\n\t}\n\tret := doc.Examples(conv(args[0:])...)\n\tp.Ret(arity, ret)\n}", "func (suite *PouchHelpSuite) TestExample(c *check.C) {\n\tcmd := exec.Command(\"ls\")\n\terr := cmd.Run()\n\tc.Assert(err, check.IsNil)\n}", "func TestExamples(t *testing.T) {\n\ttests := []struct {\n\t\tname string\n\t\targs []string\n\t}{\n\t\t{\n\t\t\tname: \"example/author\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/author/schema.sql\",\n\t\t\t\t\"--query-glob\", \"example/author/query.sql\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"example/complex_params\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/complex_params/schema.sql\",\n\t\t\t\t\"--query-glob\", \"example/complex_params/query.sql\",\n\t\t\t\t\"--go-type\", \"int8=int\",\n\t\t\t\t\"--go-type\", \"int4=int\",\n\t\t\t\t\"--go-type\", \"text=string\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"example/composite\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/composite/schema.sql\",\n\t\t\t\t\"--query-glob\", \"example/composite/query.sql\",\n\t\t\t\t\"--go-type\", \"int8=int\",\n\t\t\t\t\"--go-type\", \"int4=int\",\n\t\t\t\t\"--go-type\", \"text=string\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"example/enums\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/enums/schema.sql\",\n\t\t\t\t\"--query-glob\", \"example/enums/query.sql\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"internal/pg\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/author/schema.sql\", // force docker usage\n\t\t\t\t\"--query-glob\", \"internal/pg/query.sql\",\n\t\t\t\t\"--acronym\", \"oid\",\n\t\t\t\t\"--acronym\", \"oids=OIDs\",\n\t\t\t\t\"--go-type\", \"text=string\",\n\t\t\t\t\"--go-type\", \"_int8=[]int\",\n\t\t\t\t\"--go-type\", \"_text=[]string\",\n\t\t\t\t\"--go-type\", \"_float4=[]float32\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"example/device\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/device/schema.sql\",\n\t\t\t\t\"--query-glob\", \"example/device/query.sql\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"example/erp star glob\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/erp/*.sql\",\n\t\t\t\t\"--query-glob\", \"example/erp/order/*.sql\",\n\t\t\t\t\"--acronym\", \"mrr\",\n\t\t\t\t\"--go-type\", \"tenant_id=int\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"example/erp question marks\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/erp/??_schema.sql\",\n\t\t\t\t\"--query-glob\", \"example/erp/order/*.sql\",\n\t\t\t\t\"--acronym\", \"mrr\",\n\t\t\t\t\"--go-type\", \"tenant_id=int\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"example/go_pointer_types\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/go_pointer_types/schema.sql\",\n\t\t\t\t\"--query-glob\", \"example/go_pointer_types/query.sql\",\n\t\t\t\t\"--go-type\", \"int8=*int\",\n\t\t\t\t\"--go-type\", \"int4=*int\",\n\t\t\t\t\"--go-type\", \"text=*string\",\n\t\t\t\t\"--go-type\", \"_int8=[]int\",\n\t\t\t\t\"--go-type\", \"_int4=[]int\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"example/ltree\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/ltree/schema.sql\",\n\t\t\t\t\"--query-glob\", \"example/ltree/query.sql\",\n\t\t\t\t\"--go-type\", \"ltree=github.com/jackc/pgtype.Text\",\n\t\t\t\t\"--go-type\", \"_ltree=github.com/jackc/pgtype.TextArray\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"example/syntax\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/syntax/schema.sql\",\n\t\t\t\t\"--query-glob\", \"example/syntax/query.sql\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"example/custom_types\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/custom_types/schema.sql\",\n\t\t\t\t\"--query-glob\", \"example/custom_types/query.sql\",\n\t\t\t\t\"--go-type\", \"text=github.com/jschaf/pggen/example/custom_types/mytype.String\",\n\t\t\t\t\"--go-type\", \"int8=github.com/jschaf/pggen/example/custom_types.CustomInt\",\n\t\t\t\t\"--go-type\", \"my_int=int\",\n\t\t\t\t\"--go-type\", \"_my_int=[]int\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"example/pgcrypto\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/pgcrypto/schema.sql\",\n\t\t\t\t\"--query-glob\", \"example/pgcrypto/query.sql\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"example/separate_out_dir\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/separate_out_dir/schema.sql\",\n\t\t\t\t\"--query-glob\", \"example/separate_out_dir/alpha/query.sql\",\n\t\t\t\t\"--query-glob\", \"example/separate_out_dir/alpha/alpha/query.sql\",\n\t\t\t\t\"--query-glob\", \"example/separate_out_dir/bravo/query.sql\",\n\t\t\t\t\"--output-dir\", \"example/separate_out_dir/out\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"example/void\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/void/schema.sql\",\n\t\t\t\t\"--query-glob\", \"example/void/query.sql\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"example/nested\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/nested/schema.sql\",\n\t\t\t\t\"--query-glob\", \"example/nested/query.sql\",\n\t\t\t\t\"--go-type\", \"int4=int\",\n\t\t\t\t\"--go-type\", \"text=string\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"example/domain\",\n\t\t\targs: []string{\n\t\t\t\t\"--schema-glob\", \"example/domain/schema.sql\",\n\t\t\t\t\"--query-glob\", \"example/domain/query.sql\",\n\t\t\t},\n\t\t},\n\t}\n\tif *update {\n\t\t// update only disables the assertions. Running the tests causes pggen\n\t\t// to overwrite generated code.\n\t\tt.Log(\"updating integration test generated files\")\n\t}\n\tpggen := compilePggen(t)\n\t// Start a single Docker container to use for all tests. Each test will create\n\t// a new database in the Postgres cluster.\n\tctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\n\tdefer cancel()\n\tdocker, err := pgdocker.Start(ctx, nil, zaptest.NewLogger(t).Sugar())\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer errs.CaptureT(t, func() error { return docker.Stop(ctx) }, \"stop docker\")\n\tmainConnStr, err := docker.ConnString()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tt.Log(\"started dockerized postgres: \" + mainConnStr)\n\tconn, err := pgx.Connect(ctx, mainConnStr)\n\tdefer errs.CaptureT(t, func() error { return conn.Close(ctx) }, \"close conn\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tfor _, tt := range tests {\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tdbName := \"pggen_example_\" + strconv.FormatInt(int64(rand.Int31()), 36)\n\t\t\tif _, err = conn.Exec(ctx, `CREATE DATABASE `+dbName); err != nil {\n\t\t\t\tt.Fatal(err)\n\t\t\t}\n\t\t\tconnStr := mainConnStr + \" dbname=\" + dbName\n\t\t\targs := append(tt.args, \"--postgres-connection\", connStr)\n\t\t\trunPggen(t, pggen, args...)\n\t\t\tif !*update {\n\t\t\t\tassertNoDiff(t)\n\t\t\t}\n\t\t})\n\t}\n}", "func (suite *PouchAPIHelpSuite) TestExample(c *check.C) {\n}", "func CheckExamples(cmd *cobra.Command) []error {\n\tfmt.Fprint(os.Stdout, \" ↳ checking examples\\n\")\n\tcmdPath := cmd.CommandPath()\n\texamples := cmd.Example\n\terrors := []error{}\n\tif len(examples) > 0 {\n\t\tfor _, line := range strings.Split(examples, \"\\n\") {\n\t\t\tif !strings.HasPrefix(line, templates.Indentation) {\n\t\t\t\terrors = append(errors, fmt.Errorf(`command %q: examples are not normalized, make sure you are calling templates.Examples (from pkg/cmd/templates) before assigning cmd.Example`, cmdPath))\n\t\t\t}\n\t\t\tif trimmed := strings.TrimSpace(line); strings.HasPrefix(trimmed, \"//\") {\n\t\t\t\terrors = append(errors, fmt.Errorf(`command %q: we use # to start comments in examples instead of //`, cmdPath))\n\t\t\t}\n\t\t}\n\t}\n\treturn errors\n}", "func TestExamples(t *testing.T) {\n\tmatches, err := filepath.Glob(\"examples/*.md\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tfor _, match := range matches {\n\t\tm := match\n\t\tt.Run(m, func(t *testing.T) {\n\t\t\tblob, err := ioutil.ReadFile(m)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(err)\n\t\t\t}\n\t\t\tvar sql, goc string\n\t\t\tvar captureSQL, captureGo bool\n\t\t\tfor _, line := range strings.Split(string(blob), \"\\n\") {\n\t\t\t\tif strings.HasPrefix(line, \"```sql\") {\n\t\t\t\t\tcaptureSQL = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif strings.HasPrefix(line, \"```go\") {\n\t\t\t\t\tcaptureGo = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif strings.HasPrefix(line, \"```\") {\n\t\t\t\t\tcaptureSQL = false\n\t\t\t\t\tcaptureGo = false\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif captureSQL {\n\t\t\t\t\tsql += line + \"\\n\"\n\t\t\t\t}\n\t\t\t\tif captureGo {\n\t\t\t\t\tgoc += line + \"\\n\"\n\t\t\t\t}\n\t\t\t}\n\t\t\tif _, err := pg.Parse(sql); err != nil {\n\t\t\t\tt.Errorf(\"could not parse SQL: %s\", err)\n\t\t\t}\n\t\t\tif _, err := format.Source([]byte(goc)); err != nil {\n\t\t\t\tt.Errorf(\"could not format Go: %s\", err)\n\t\t\t}\n\t\t})\n\t}\n}", "func UsageExamples() string {\n\treturn os.Args[0] + ` foo foo1 --p 6458532619907689287` + \"\\n\" +\n\t\t\"\"\n}", "func UsageExamples() string {\n\treturn os.Args[0] + ` want-go get-simple-card-list` + \"\\n\" +\n\t\t\"\"\n}", "func main() {\n\tprintln()\n\tdefer println()\n\n\tdir := flag.String(\"dir\", \"\", \"Directory to test.\")\n\toss := flag.Bool(\"oss\", true, \"Test oss examples.\")\n\tpro := flag.Bool(\"pro\", false, \"Test pro examples.\")\n\tflag.Parse()\n\n\tlog.SetHandler(cli.Default)\n\n\tif *dir != \"\" {\n\t\tif err := testExample(*dir); err != nil {\n\t\t\tlog.Fatalf(\"error: %s\", err)\n\t\t}\n\t\treturn\n\t}\n\n\tif *oss {\n\t\tif err := testExamples(\"oss\"); err != nil {\n\t\t\tlog.Fatalf(\"error: %s\", err)\n\t\t}\n\t}\n\n\tif *pro {\n\t\tif err := testExamples(\"pro\"); err != nil {\n\t\t\tlog.Fatalf(\"error: %s\", err)\n\t\t}\n\t}\n}", "func UsageExamples() string {\n\treturn os.Args[0] + ` neat-thing neat-thing-today` + \"\\n\" +\n\t\t\"\"\n}", "func TestExamples(t *testing.T) {\n\tconfigurations, err := ioutil.ReadDir(exampleConfigurationDir)\n\tif err != nil {\n\t\tutil.Die(t, err)\n\t}\n\n\tfor _, configuration := range configurations {\n\t\tname := configuration.Name()\n\n\t\ttest := func(t *testing.T) {\n\t\t\t// Install any prerequisites.\n\t\t\tprerequisitesPath := path.Join(exampleConfigurationDir, name, exampleConfigurationPrerequisites)\n\n\t\t\tif _, err := os.Stat(prerequisitesPath); err == nil {\n\t\t\t\tobjects := util.MustReadYAMLObjects(t, prerequisitesPath)\n\n\t\t\t\tutil.MustCreateResources(t, clients, \"default\", objects)\n\n\t\t\t\tfor i := range objects {\n\t\t\t\t\tobject := objects[i]\n\n\t\t\t\t\tdefer util.DeleteResource(clients, \"default\", object)\n\t\t\t\t}\n\n\t\t\t\t// Hack, we need a better way of synchronizing the readiness of\n\t\t\t\t// resources such as these. For example, a dynamic admission controller\n\t\t\t\t// installed in this phase may not have started e.g. still pulling\n\t\t\t\t// the image, when the service instance is created. The service\n\t\t\t\t// instance then misses all its defaults and collapses in a heap.\n\t\t\t\t// Also we need the clients to sync in the mean time in order to\n\t\t\t\t// see the new CRD types. Make this synchronous.\n\t\t\t\ttime.Sleep(time.Minute)\n\t\t\t}\n\n\t\t\t// Create a clean namespace to test in, we can clean up everything\n\t\t\t// by just deleting it and letting the cascade do its thing.\n\t\t\tnamespace := util.MustCreateResource(t, clients, \"\", util.MustGetNamespace(t))\n\n\t\t\tdefer util.DeleteResource(clients, \"\", namespace)\n\n\t\t\t// Install the service broker configuration for the example.\n\t\t\t// * Tests example passes CRD validation.\n\t\t\tconfigurationPath := path.Join(exampleConfigurationDir, name, exampleConfigurationSpecification)\n\n\t\t\tobjects := util.MustReadYAMLObjects(t, configurationPath)\n\t\t\tserviceBrokerConfiguration := util.MustFindResource(t, objects, \"servicebroker.couchbase.com/v1alpha1\", \"ServiceBrokerConfig\", exampleDefaultResourceName)\n\n\t\t\tutil.MustCreateResources(t, clients, namespace.GetName(), objects)\n\n\t\t\t// Install the service broker, we need to check that the service broker\n\t\t\t// flags the configuration as valid and the deployment is available.\n\t\t\t// As the namespace is ephemeral we need to watch out for any resources\n\t\t\t// that usually refer to \"default\" explicitly.\n\t\t\t// * Tests service broker comes up in Kubernetes.\n\t\t\t// * Tests example passses service broker validation.\n\t\t\tcaCertificate, serverCertificate, serverKey := util.MustGenerateServiceBrokerTLS(t, namespace.GetName())\n\n\t\t\tobjects = util.MustReadYAMLObjects(t, exampleBrokerConfiguration)\n\t\t\tserviceBrokerSecret := util.MustFindResource(t, objects, \"v1\", \"Secret\", exampleDefaultResourceName)\n\t\t\tserviceBrokerRoleBinding := util.MustFindResource(t, objects, \"rbac.authorization.k8s.io/v1\", \"RoleBinding\", exampleDefaultResourceName)\n\t\t\tserviceBrokerDeployment := util.MustFindResource(t, objects, \"apps/v1\", \"Deployment\", exampleDefaultResourceName)\n\n\t\t\t// Override the service broker TLS secret data.\n\t\t\tdata := map[string]interface{}{\n\t\t\t\t\"token\": base64.StdEncoding.EncodeToString([]byte(token)),\n\t\t\t\t\"username\": base64.StdEncoding.EncodeToString([]byte(username)),\n\t\t\t\t\"password\": base64.StdEncoding.EncodeToString([]byte(password)),\n\t\t\t\t\"tls-certificate\": base64.StdEncoding.EncodeToString(serverCertificate),\n\t\t\t\t\"tls-private-key\": base64.StdEncoding.EncodeToString(serverKey),\n\t\t\t}\n\n\t\t\tif err := unstructured.SetNestedField(serviceBrokerSecret.Object, data, \"data\"); err != nil {\n\t\t\t\tutil.Die(t, err)\n\t\t\t}\n\n\t\t\t// Override the service broker role binding namespace.\n\t\t\tsubjects := []interface{}{\n\t\t\t\tmap[string]interface{}{\n\t\t\t\t\t\"kind\": \"ServiceAccount\",\n\t\t\t\t\t\"name\": exampleDefaultResourceName,\n\t\t\t\t\t\"namespace\": namespace.GetName(),\n\t\t\t\t},\n\t\t\t}\n\n\t\t\tif err := unstructured.SetNestedField(serviceBrokerRoleBinding.Object, subjects, \"subjects\"); err != nil {\n\t\t\t\tutil.Die(t, err)\n\t\t\t}\n\n\t\t\t// Set the pull policy so we use the cached version.\n\t\t\tif err := unstructured.SetNestedField(serviceBrokerDeployment.Object, \"IfNotPresent\", \"spec\", \"template\", \"spec\", \"imagePullPolicy\"); err != nil {\n\t\t\t\tutil.Die(t, err)\n\t\t\t}\n\n\t\t\tutil.MustCreateResources(t, clients, namespace.GetName(), objects)\n\n\t\t\tutil.MustWaitFor(t, util.ResourceCondition(clients, namespace.GetName(), serviceBrokerConfiguration, string(v1.ConfigurationValid), string(v1.ConditionTrue)), time.Minute)\n\t\t\tutil.MustWaitFor(t, util.ResourceCondition(clients, namespace.GetName(), serviceBrokerDeployment, string(appsv1.DeploymentAvailable), string(corev1.ConditionTrue)), time.Minute)\n\n\t\t\t// Register the service broker with the service catalog.\n\t\t\t// We replaced the service broker configuration with new TLS due to the\n\t\t\t// namespace change, do the same here.\n\t\t\t// * Tests the service catalog can talk to the service broker.\n\t\t\tobjects = util.MustReadYAMLObjects(t, exampleClusterServiceBroker)\n\t\t\tclusterServiceBroker := util.MustFindResource(t, objects, \"servicecatalog.k8s.io/v1beta1\", \"ClusterServiceBroker\", exampleDefaultResourceName)\n\n\t\t\tif err := unstructured.SetNestedField(clusterServiceBroker.Object, fmt.Sprintf(\"https://%s.%s\", exampleDefaultResourceName, namespace.GetName()), \"spec\", \"url\"); err != nil {\n\t\t\t\tutil.Die(t, err)\n\t\t\t}\n\n\t\t\tif err := unstructured.SetNestedField(clusterServiceBroker.Object, base64.StdEncoding.EncodeToString(caCertificate), \"spec\", \"caBundle\"); err != nil {\n\t\t\t\tutil.Die(t, err)\n\t\t\t}\n\n\t\t\tif err := unstructured.SetNestedField(clusterServiceBroker.Object, namespace.GetName(), \"spec\", \"authInfo\", \"basic\", \"secretRef\", \"namespace\"); err != nil {\n\t\t\t\tutil.Die(t, err)\n\t\t\t}\n\n\t\t\tutil.MustCreateResources(t, clients, namespace.GetName(), objects)\n\n\t\t\tdefer util.DeleteResource(clients, \"\", clusterServiceBroker)\n\n\t\t\tutil.MustWaitFor(t, util.ResourceCondition(clients, namespace.GetName(), clusterServiceBroker, \"Ready\", \"True\"), time.Minute)\n\n\t\t\t// Create the service instance.\n\t\t\t// * Tests the configuration provisions.\n\t\t\tserviceInstancePath := path.Join(exampleConfigurationDir, name, exampleConfigurationServiceInstance)\n\n\t\t\tobjects = util.MustReadYAMLObjects(t, serviceInstancePath)\n\t\t\tserviceInstance := util.MustFindResource(t, objects, \"servicecatalog.k8s.io/v1beta1\", \"ServiceInstance\", exampleDefaultServiceInstanceName)\n\n\t\t\tutil.MustCreateResources(t, clients, namespace.GetName(), objects)\n\n\t\t\tutil.MustWaitFor(t, util.ResourceCondition(clients, namespace.GetName(), serviceInstance, \"Ready\", \"True\"), 10*time.Minute)\n\n\t\t\t// Create the service binding if one exists.\n\t\t\t// * Tests the configuration provisions.\n\t\t\tserviceBindingPath := path.Join(exampleConfigurationDir, name, exampleConfigurationServiceBinding)\n\t\t\tif _, err := os.Stat(serviceBindingPath); err == nil {\n\t\t\t\tobjects = util.MustReadYAMLObjects(t, serviceBindingPath)\n\t\t\t\tserviceBinding := util.MustFindResource(t, objects, \"servicecatalog.k8s.io/v1beta1\", \"ServiceBinding\", exampleDefaultServiceBindingName)\n\n\t\t\t\tutil.MustCreateResources(t, clients, namespace.GetName(), objects)\n\n\t\t\t\tutil.MustWaitFor(t, util.ResourceCondition(clients, namespace.GetName(), serviceBinding, \"Ready\", \"True\"), 5*time.Minute)\n\n\t\t\t\t// Delete the service binding.\n\t\t\t\t// * Tests the service binding is deprovisioned cleanly.\n\t\t\t\tutil.DeleteResource(clients, namespace.GetName(), serviceBinding)\n\t\t\t}\n\n\t\t\t// Delete the service instance.\n\t\t\t// * Tests the service instance is deprovisioned cleanly.\n\t\t\tutil.DeleteResource(clients, namespace.GetName(), serviceInstance)\n\t\t}\n\n\t\tt.Run(\"TestExample-\"+name, test)\n\t}\n}", "func UsageExamples() string {\n\treturn os.Args[0] + ` organization list` + \"\\n\" +\n\t\tos.Args[0] + ` step list --id \"Quaerat aut.\"` + \"\\n\" +\n\t\tos.Args[0] + ` walkthrough list --id \"Aut ad doloribus possimus deleniti magni quia.\"` + \"\\n\" +\n\t\t\"\"\n}", "func TestExampleTestSuite(t *testing.T) {\n\tsuite.Run(t, new(ExampleTestSuite))\n}", "func writeExamplesFile(g *generateInfo) error {\n\tcode := g.API.ExamplesGoCode()\n\tif len(code) > 0 {\n\t\treturn writeGoFile(filepath.Join(g.PackageDir, \"examples_test.go\"),\n\t\t\tcodeLayout,\n\t\t\t\"\",\n\t\t\tg.API.PackageName()+\"_test\",\n\t\t\tcode,\n\t\t)\n\t}\n\treturn nil\n}", "func TestRun(t *testing.T) {\n\tRun()\n}", "func FilterExamples(description string, lang string) string {\n\tif description == \"\" {\n\t\treturn \"\"\n\t}\n\n\tsource := []byte(description)\n\tparsed := schema.ParseDocs(source)\n\tfilterExamples(source, parsed, lang)\n\treturn schema.RenderDocsToString(source, parsed)\n}", "func TestParseExamples(t *testing.T) {\n\ts := runtime.NewScheme()\n\n\tif err := scheme.AddToScheme(s); err != nil {\n\t\tt.Fatalf(\"failed to add builtin scheme: %s\", err)\n\t}\n\n\tif err := v1alpha1.AddToScheme(s); err != nil {\n\t\tt.Fatalf(\"failed to add service-api scheme: %s\", err)\n\t}\n\n\tdecoder := serializer.NewCodecFactory(s).UniversalDeserializer()\n\n\tfor _, filename := range findExamples(t, \".\") {\n\t\tt.Run(filename, func(t *testing.T) {\n\t\t\tfor n, buf := range decodeExample(t, filename) {\n\t\t\t\tobj, vers, err := decoder.Decode(buf, nil, nil)\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Errorf(\"failed to decode YAML object #%d from %q: %s\", n, filename, err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tmetaObj, err := meta.Accessor(obj)\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Errorf(\"invalid type for decoded object: %s\", err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tt.Logf(\"decoded YAML object #%d as name=%q group=%q version=%q kind=%q\\n\",\n\t\t\t\t\tn, objectName(metaObj), vers.Group, vers.Version, vers.Kind)\n\t\t\t}\n\t\t})\n\t}\n}", "func Example() {\n\tprintln(main.Simple())\n\t// Output:\n\t// hello world\n}", "func TestRunMain(t *testing.T) {\n\tmain()\n}", "func UsageExamples() string {\n\treturn os.Args[0] + ` recorder record-data --body '{\n \"name\": \"duration\",\n \"service\": \"lambda\",\n \"value\": 0.06173619203715241\n }'` + \"\\n\" +\n\t\t\"\"\n}", "func PrintUsageExamples() {\n\tprintln(\"Examples:\")\n\tprintln()\n\tprintln(\" vanieth -n 3 'ABC'\")\n\tprintln(\" Find 3 addresses that have `ABC` at the beginning.\")\n\tprintln()\n\tprintln(\" vanieth -t 5 'ABC'\")\n\tprintln(\" Find as many address that have `ABC` at the beginning as possible within 5 seconds.\")\n\tprintln()\n\tprintln(\" vanieth -c 'ABC'\")\n\tprintln(\" Find any address that has `ABC` at the beginning of any of the first 10 contract addresses.\")\n\tprintln()\n\tprintln(\" vanieth -cd1 '00+AB'\")\n\tprintln(\" Find any address that has `AB` after 2 or more `0` chars in the first contract address.\")\n\tprintln()\n\tprintln(\" vanieth '.*ABC'\")\n\tprintln(\" Find a single address that contains `ABC` anywhere.\")\n\tprintln()\n\tprintln(\" vanieth '.*DEF$'\")\n\tprintln(\" Find a single address that contains `DEF` at the end.\")\n\tprintln()\n\tprintln(\" vanieth -i 'A.*A$'\")\n\tprintln(\" Find a single address that contains either `A` or `a` at both the start and end.\")\n\tprintln()\n\tprintln(\" vanieth -ld1 '.*ABC'\")\n\tprintln(\" Find a single address that contains `ABC` anywhere, and also list the first contract address.\")\n\tprintln()\n\tprintln(\" vanieth -ld5 --key=0x349fbc254ff918305ae51967acc1e17cfbd1b7c7e84ef8fa670b26f3be6146ba\")\n\tprintln(\" List the details and first five contract address for the supplied private key.\")\n\tprintln()\n\tprintln(\" vanieth -l --scan=0x950024ae4d9934c65c9fd04249e0f383910d27f2\")\n\tprintln(\" Show the first 10 contract addresses of the supplied address.\")\n\tprintln()\n}", "func examples(ex interface{}) (*gherkin.Examples, bool) {\n\tt, ok := ex.(*gherkin.Examples)\n\treturn t, ok\n}", "func examples(ex interface{}) (*gherkin.Examples, bool) {\n\tt, ok := ex.(*gherkin.Examples)\n\treturn t, ok\n}", "func loadRawExamples() {\n\t// load chef_run's for reuse\n\trawruns = make(map[string][]byte)\n\truns := []string{\n\t\t\"../../ingest-service/examples/chef_client_run.json\",\n\t\t\"../../ingest-service/examples/converge-bad-report.json\",\n\t\t\"../../ingest-service/examples/converge-failure-report.json\",\n\t\t\"../../ingest-service/examples/converge-success-report.json\",\n\t}\n\tfor _, r := range runs {\n\t\t// load chef_run json into memory, so that we do not count the json generation\n\t\tcontent, err := ioutil.ReadFile(r)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\trawruns[r] = content\n\t}\n\n\t// load chef_action's for reuse\n\trawactions = make(map[string][]byte)\n\tactions := []string{\n\t\t\"bag_create\",\n\t\t\"bag_create\",\n\t\t\"bag_delete\",\n\t\t\"client_create\",\n\t\t\"cookbookartifactversion_update\",\n\t\t\"environment_create\",\n\t\t\"environment_delete\",\n\t\t\"environment_update\",\n\t\t\"group_create\",\n\t\t\"group_update\",\n\t\t\"item_bag_create\",\n\t\t\"item_bag_update\",\n\t\t\"node_create\",\n\t\t\"node_delete\",\n\t\t\"org_create\",\n\t\t\"permission_update_container\",\n\t\t\"permission_update_cookbook\",\n\t\t\"permission_update_environment\",\n\t\t\"policy_update\",\n\t\t\"user_associate\",\n\t\t\"user_create\",\n\t\t\"user_invite\",\n\t\t\"user_update\",\n\t\t\"version_cookbook_create\",\n\t\t\"version_cookbook_update\",\n\t}\n\tfor _, a := range actions {\n\t\tcontent, err := ioutil.ReadFile(fmt.Sprintf(\"../../ingest-service/examples/actions/%s.json\", a))\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\trawactions[a] = content\n\t}\n\n\t// load liveness's for reuse\n\trawliveness = make(map[string][]byte)\n\tliveness := []string{\n\t\t\"liveness_ping\",\n\t}\n\tfor _, l := range liveness {\n\t\tcontent, err := ioutil.ReadFile(fmt.Sprintf(\"../../ingest-service/examples/%s.json\", l))\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\trawliveness[l] = content\n\t}\n\n\t// load report's for reuse\n\trawreports = make(map[string][]byte)\n\treports := []string{\n\t\t\"compliance-failure-big-report\",\n\t\t\"compliance-success-tiny-report\",\n\t}\n\tfor _, r := range reports {\n\t\tcontent, err := ioutil.ReadFile(fmt.Sprintf(\"../../compliance-service/ingest/examples/%s.json\", r))\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\trawreports[r] = content\n\t}\n}", "func GetExamples(pageNum int, pageSize int, maps interface{}) ([]Example, error) {\n\tvar (\n\t\texamples []Example\n\t\terr error\n\t)\n\n\tif pageSize > 0 && pageNum > 0 {\n\t\terr = db.Where(maps).Find(&examples).Offset(pageNum).Limit(pageSize).Error\n\t} else {\n\t\terr = db.Where(maps).Find(&examples).Error\n\t}\n\n\tif err != nil && err != gorm.ErrRecordNotFound {\n\t\treturn nil, err\n\t}\n\n\treturn examples, nil\n}", "func TestAll() error {\n\tout, err := sh.Output(\"go\", \"test\", \"./...\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tlog.Print(out)\n\treturn nil\n}", "func doTests(t *testing.T, tests []string) {\n\tdoTestsParam(t, tests, TestParams{\n\t\textensions: parser.CommonExtensions,\n\t})\n}", "func (test Test) Run(t *testing.T) {\n\tt.Logf(\"Starting test %v\", t.Name())\n\tt.Helper()\n\t// Double negative cannot be helped, this is intended to mitigate test failures where a global\n\t// resource is manipulated, e.g.: the default AWS security group.\n\tif !test.RunOptions.NoParallel {\n\t\tt.Parallel()\n\t}\n\tt.Run(\"Python\", func(t *testing.T) {\n\t\trunOpts := integration.ProgramTestOptions{}\n\t\tif test.RunOptions != nil {\n\t\t\trunOpts = *test.RunOptions\n\t\t}\n\t\tconvertOpts := test.Options\n\t\tif test.Python != nil {\n\t\t\tconvertOpts = convertOpts.With(*test.Python)\n\t\t}\n\n\t\ttargetTest := targetTest{\n\t\t\trunOpts: &runOpts,\n\t\t\tconvertOpts: &convertOpts,\n\t\t\tprojectName: test.ProjectName,\n\t\t\tlanguage: \"python\",\n\t\t\truntime: \"python\",\n\t\t}\n\t\ttargetTest.Run(t)\n\t})\n\tt.Run(\"TypeScript\", func(t *testing.T) {\n\t\trunOpts := integration.ProgramTestOptions{}\n\t\tif test.RunOptions != nil {\n\t\t\trunOpts = *test.RunOptions\n\t\t}\n\t\tconvertOpts := test.Options\n\t\tif test.TypeScript != nil {\n\t\t\tconvertOpts = convertOpts.With(*test.TypeScript)\n\t\t}\n\n\t\ttargetTest := targetTest{\n\t\t\trunOpts: &runOpts,\n\t\t\tconvertOpts: &convertOpts,\n\t\t\tprojectName: test.ProjectName,\n\t\t\tlanguage: \"typescript\",\n\t\t\truntime: \"nodejs\",\n\t\t}\n\t\ttargetTest.Run(t)\n\t})\n}", "func (Test) GenerateExampleModules() error {\n\tpattern := filepath.Join(\"examples\", \"module\", \"*\", \"*.go\")\n\tif err := compileWasmModules(pattern); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (s *crdExampleLister) CrdExamples(namespace string) CrdExampleNamespaceLister {\n\treturn crdExampleNamespaceLister{indexer: s.indexer, namespace: namespace}\n}", "func initExamples(obj exampler, attr *expr.AttributeExpr, r *expr.ExampleGenerator) {\n\texamples := attr.ExtractUserExamples()\n\tswitch {\n\tcase len(examples) > 1:\n\t\trefs := make(map[string]*ExampleRef, len(examples))\n\t\tfor _, ex := range examples {\n\t\t\texample := &Example{\n\t\t\t\tSummary: ex.Summary,\n\t\t\t\tDescription: ex.Description,\n\t\t\t\tValue: ex.Value,\n\t\t\t}\n\t\t\trefs[ex.Summary] = &ExampleRef{Value: example}\n\t\t}\n\t\tobj.setExamples(refs)\n\t\treturn\n\tcase len(examples) > 0:\n\t\tobj.setExample(examples[0].Value)\n\tdefault:\n\t\tobj.setExample(attr.Example(r))\n\t}\n}", "func RunTests(opts Options) {\n\tif opts.Cleanup {\n\t\terr := CleanupTests(opts.Driver, opts.DSN, opts.Verbose)\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Cleanup failed: %s\\n\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tos.Exit(0)\n\t}\n\t_ = flag.Set(\"test.run\", opts.Match)\n\tif opts.Verbose {\n\t\t_ = flag.Set(\"test.v\", \"true\")\n\t}\n\ttests := []testing.InternalTest{\n\t\t{\n\t\t\tName: \"MainTest\",\n\t\t\tF: func(t *testing.T) {\n\t\t\t\tTest(t, opts.Driver, opts.DSN, opts.Suites, opts.RW)\n\t\t\t},\n\t\t},\n\t}\n\n\tmainStart(tests)\n}", "func main() {\n\terr := highLevelExample()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func TestFrameworkExample(t *testing.T) {\n\tScenario(t, \"test example without setup and teardown\", func() {\n\t\ta := 0\n\t\tCase(\"add with verify\", func() {\n\t\t\ta = a + 1\n\t\t\tVerify(a, Equal, 1)\n\t\t})\n\t\tCase(\"add without verify\", func() {\n\t\t\ta = a + 1\n\t\t})\n\t\tCase(\"only verify\", func() {\n\t\t\tVerify(a, Equal, 2)\n\t\t})\n\t})\n}", "func RunSubtests(ctx *Context) {\n\tfor name, fn := range tests {\n\t\tctx.Run(name, fn)\n\t}\n}", "func RunTestCases(t *testing.T, testcases *[]TestCase, ctx *TestContext) {\n\tcontext := ctx\n\tif context == nil {\n\t\tcontext = &TestContext{\n\t\t\tNameIDMap: make(map[string]string),\n\t\t\tNameObjectMap: make(map[string]interface{}),\n\t\t}\n\t}\n\n\tfor _, tc := range *testcases {\n\t\tTestLog = t\n\n\t\tif true { //tc.Enabled){\n\n\t\t\tt.Logf(\"======Begin to run test case: %s \\n\", tc.Name)\n\n\t\t\t//If test case name is like sleep_500, then it would sleep 500ms\n\t\t\tmethod := strings.ToLower(tc.Method)\n\t\t\tif strings.Contains(method, \"sleep\") {\n\t\t\t\tsleep, _ := strconv.Atoi(method[6:])\n\t\t\t\tt.Logf(\"Sleep %d mill-secondes\", sleep)\n\t\t\t\ttime.Sleep(time.Duration(sleep) * time.Millisecond)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tvar runner TestExecuter\n\t\t\tif tc.Executer != nil {\n\t\t\t\trunner = tc.Executer()\n\t\t\t} else {\n\t\t\t\tt.Fatalf(\"No Executer specified in test cases\")\n\t\t\t}\n\t\t\tt.Run(tc.Name, testcaseFunc(runner, context, &tc))\n\n\t\t}\n\t}\n}", "func (client ModelClient) ExamplesMethod(ctx context.Context, appID uuid.UUID, versionID string, modelID string, skip *int32, take *int32) (result ListLabelTextObject, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/ModelClient.ExamplesMethod\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.Response.Response != nil {\n\t\t\t\tsc = result.Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tif err := validation.Validate([]validation.Validation{\n\t\t{TargetValue: skip,\n\t\t\tConstraints: []validation.Constraint{{Target: \"skip\", Name: validation.Null, Rule: false,\n\t\t\t\tChain: []validation.Constraint{{Target: \"skip\", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}},\n\t\t{TargetValue: take,\n\t\t\tConstraints: []validation.Constraint{{Target: \"take\", Name: validation.Null, Rule: false,\n\t\t\t\tChain: []validation.Constraint{{Target: \"take\", Name: validation.InclusiveMaximum, Rule: int64(500), Chain: nil},\n\t\t\t\t\t{Target: \"take\", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil},\n\t\t\t\t}}}}}); err != nil {\n\t\treturn result, validation.NewError(\"authoring.ModelClient\", \"ExamplesMethod\", err.Error())\n\t}\n\n\treq, err := client.ExamplesMethodPreparer(ctx, appID, versionID, modelID, skip, take)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"authoring.ModelClient\", \"ExamplesMethod\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresp, err := client.ExamplesMethodSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\terr = autorest.NewErrorWithError(err, \"authoring.ModelClient\", \"ExamplesMethod\", resp, \"Failure sending request\")\n\t\treturn\n\t}\n\n\tresult, err = client.ExamplesMethodResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"authoring.ModelClient\", \"ExamplesMethod\", resp, \"Failure responding to request\")\n\t}\n\n\treturn\n}", "func (c *Command) Run(args []string) {\n\tflag.StringVar(&c.Filter, \"f\", \"\", \"regexp to filter tests by name\")\n\tflag.BoolVar(&c.Verbose, \"v\", false, \"print all test names\")\n\tcheck(flag.CommandLine.Parse(args))\n\targs = flag.Args()\n\n\tif len(args) == 0 {\n\t\targs = []string{\".\"}\n\t}\n\n\tokPath, err := util.OKPath()\n\tcheck(err)\n\n\tfor _, arg := range args {\n\t\tpackageName := util.PackageNameFromPath(okPath, arg)\n\t\tif arg == \".\" {\n\t\t\tpackageName = \".\"\n\t\t}\n\t\tanonFunctionName := 0\n\t\tf, _, errs := compiler.Compile(okPath, packageName, true,\n\t\t\t&anonFunctionName, false)\n\t\tutil.CheckErrorsWithExit(errs)\n\n\t\tm := vm.NewVM(\"no-package\")\n\t\tstartTime := time.Now()\n\t\tcheck(m.LoadFile(f))\n\t\terr := m.RunTests(c.Verbose, regexp.MustCompile(c.Filter), packageName)\n\t\telapsed := time.Since(startTime).Milliseconds()\n\t\tcheck(err)\n\n\t\tassertWord := pluralise(\"assert\", m.TotalAssertions)\n\t\tif m.TestsFailed > 0 {\n\t\t\tfmt.Printf(\"%s: %d failed %d passed %d %s (%d ms)\\n\",\n\t\t\t\tpackageName, m.TestsFailed, m.TestsPass,\n\t\t\t\tm.TotalAssertions, assertWord, elapsed)\n\t\t} else {\n\t\t\tfmt.Printf(\"%s: %d passed %d %s (%d ms)\\n\",\n\t\t\t\tpackageName, m.TestsPass,\n\t\t\t\tm.TotalAssertions, assertWord, elapsed)\n\t\t}\n\n\t\tif m.TestsFailed > 0 {\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n}", "func (t TestCases) Run(fn func(string) (string, string), hideInput bool) {\n\tfor _, test := range t {\n\t\tpart1, part2 := fn(test.Input)\n\t\tpassedPart1 := part1 == test.ExpectedPart1 || test.ExpectedPart1 == \"\"\n\t\tpassedPart2 := part2 == test.ExpectedPart2 || test.ExpectedPart2 == \"\"\n\t\tpassed := passedPart1 && passedPart2\n\n\t\tif !passed && !hideInput {\n\t\t\tfmt.Println(\"Input \", test.Input)\n\t\t}\n\t\tif !passedPart1 {\n\t\t\tfmt.Println(\" - PART1: \", part1, \" but expected \", test.ExpectedPart1)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tif !passedPart2 {\n\t\t\tfmt.Println(\" - PART2: \", part2, \" but expected \", test.ExpectedPart2)\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n}", "func (g *Ginkgo) Run() error {\n\tg.Point.SetTestStart()\n\t// use the test bin rather than compile the directory b/c the compile will happen in a sub dir which is another module\n\ttestFile := fmt.Sprintf(\"test/e2e/%s/%s.test\", g.Config.Orchestrator, g.Config.Orchestrator)\n\n\targs := []string{\"-slowSpecThreshold\", \"180\", \"-r\", \"-v\"}\n\tif g.Config.GinkgoParallel {\n\t\targs = append(args, \"-p\")\n\t}\n\tif g.Config.GinkgoFailFast {\n\t\targs = append(args, \"-failFast\")\n\t}\n\tif g.Config.GinkgoFocus != \"\" {\n\t\targs = append(args, \"-focus\")\n\t\targs = append(args, g.Config.GinkgoFocus)\n\t}\n\tif g.Config.GinkgoSkip != \"\" {\n\t\targs = append(args, \"-skip\")\n\t\targs = append(args, g.Config.GinkgoSkip)\n\t}\n\targs = append(args, testFile)\n\tvar cmd = exec.Command(\"ginkgo\", args...)\n\n\tutil.PrintCommand(cmd)\n\tcmd.Stdout = os.Stdout\n\tcmd.Stderr = os.Stderr\n\terr := cmd.Start()\n\tif err != nil {\n\t\tg.Point.RecordTestError()\n\t\tlog.Printf(\"Error while trying to start ginkgo:%s\\n\", err)\n\t\treturn err\n\t}\n\n\terr = cmd.Wait()\n\tif err != nil {\n\t\tg.Point.RecordTestError()\n\t\tkubectl := exec.Command(\"k\", \"get\", \"all\", \"--all-namespaces\", \"-o\", \"wide\")\n\t\tutil.PrintCommand(kubectl)\n\t\tkubectl.CombinedOutput()\n\t\tkubectl = exec.Command(\"k\", \"get\", \"nodes\", \"-o\", \"wide\")\n\t\tutil.PrintCommand(kubectl)\n\t\tkubectl.CombinedOutput()\n\t\treturn err\n\t}\n\tg.Point.RecordTestSuccess()\n\treturn nil\n}", "func TestNested(t *testing.T) {\n\tif nestedVerbose {\n\t\tfmt.Printf(\"This will take a while...\\n\")\n\t}\n\tnExamples := int(math.Pow(nActions, nPositions))\n\tif !nestedParallel {\n\t\tfor x := 0; x < nExamples; x++ {\n\t\t\tif nestedVerbose {\n\t\t\t\tfmt.Printf(\"\\r\")\n\t\t\t\tdumpActions(x)\n\t\t\t}\n\t\t\texampleNested(t, x, nil)\n\t\t}\n\t} else {\n\t\tc := make(chan struct{})\n\t\tfor x := 0; x < nExamples; x++ {\n\t\t\tif x >= runtime.GOMAXPROCS(0) {\n\t\t\t\t<-c\n\t\t\t}\n\t\t\tif nestedVerbose {\n\t\t\t\tfmt.Printf(\"\\r\")\n\t\t\t\tdumpActions(x)\n\t\t\t}\n\t\t\tgo exampleNested(t, x, c)\n\t\t}\n\t\tfor i := 0; i < runtime.GOMAXPROCS(0); i++ {\n\t\t\t<-c\n\t\t}\n\t}\n\tif nestedVerbose {\n\t\tfmt.Printf(\"\\n\")\n\t}\n}", "func Run(t *testing.T, s suite.TestingSuite) {\n\tsuite.Run(t, s)\n}", "func init() { //nolint\n\ttestSample := TestCase{\n\t\tName: \"should load libraries from the provided path [E2E-CLI-049]\",\n\t\tArgs: args{\n\t\t\tArgs: []cmdArgs{\n\t\t\t\t[]string{\"scan\", \"--silent\", \"-q\", \"../assets/queries\", \"-p\", \"fixtures/samples/terraform-single.tf\",\n\t\t\t\t\t\"--libraries-path\", \"fixtures/samples/libraries\"},\n\n\t\t\t\t[]string{\"scan\", \"--silent\", \"-q\", \"../assets/queries\", \"-p\", \"fixtures/samples/positive.yaml\",\n\t\t\t\t\t\"--libraries-path\", \"fixtures/samples/libraries\"},\n\n\t\t\t\t[]string{\"scan\", \"--silent\", \"-q\", \"../assets/queries\", \"-p\", \"fixtures/samples/positive.yaml\",\n\t\t\t\t\t\"--libraries-path\", \"fixtures/samples/not-exists-folder\"},\n\t\t\t},\n\t\t},\n\t\tWantStatus: []int{0, 50, 126},\n\t}\n\n\tTests = append(Tests, testSample)\n}", "func GetExamples(w http.ResponseWriter, r *http.Request) *appError {\n rendering.JSON(w, http.StatusOK, config.Examples)\n\n return nil\n}", "func MainStart(deps testDeps, tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) *M {}", "func Run(dataDir string) {\n\t// Note: Add new puzzles here.\n\tpuzzles := []runner.Puzzle{\n\t\t{\"AOC 2016.01\", \"aoc/2016/day1.txt\", p01.Solve, \"161\", \"110\"},\n\t\t{\"AOC 2016.02\", \"aoc/2016/day2.txt\", p02.Solve, \"69642\", \"8CB23\"},\n\t\t{\"AOC 2016.03\", \"aoc/2016/day3.txt\", p03.Solve, \"1032\", \"1838\"},\n\t\t{\"AOC 2016.04\", \"aoc/2016/day4.txt\", p04.Solve, \"137896\", \"501\"},\n\t}\n\trunner.Run(dataDir, puzzles)\n}", "func (suite FeatureTestSuite) Run(t *testing.T, buildFunc feature.BuildFunc) {\n\tfor _, test := range suite {\n\t\trunTest(t, test, buildFunc)\n\t}\n}", "func (s MockInputsBoolsHelper) RunTests(t testRunner, testSet []bool, testFunc func(t *testing.T, index int, f bool)) {\n\tif test, ok := t.(helper); ok {\n\t\ttest.Helper()\n\t}\n\n\ttest := internal.GetTest(t)\n\tif test == nil {\n\t\tt.Error(internal.ErrCanNotRunIfNotBuiltinTesting)\n\t\treturn\n\t}\n\n\tfor i, v := range testSet {\n\t\ttest.Run(fmt.Sprint(v), func(t *testing.T) {\n\t\t\tt.Helper()\n\n\t\t\ttestFunc(t, i, v)\n\t\t})\n\t}\n}", "func (s *SmokeTest) Run(f *flag.FlagSet, args []string) (err error) {\n\ti2cID := f.String(\"i2c\", \"\", \"I²C bus to use\")\n\ti2cAddr := f.Uint(\"ia\", 0x76, \"I²C bus address to use; either 0x76 (BMx280, the default) or 0x77 (BMP180)\")\n\tspiID := f.String(\"spi\", \"\", \"SPI port to use\")\n\trecord := f.Bool(\"r\", false, \"record operation (for playback unit testing)\")\n\tf.Parse(args)\n\tif f.NArg() != 0 {\n\t\tf.Usage()\n\t\treturn errors.New(\"unrecognized arguments\")\n\t}\n\n\ti2cBus, err2 := i2creg.Open(*i2cID)\n\tif err2 != nil {\n\t\treturn err2\n\t}\n\tdefer func() {\n\t\tif err2 := i2cBus.Close(); err == nil {\n\t\t\terr = err2\n\t\t}\n\t}()\n\n\tspiPort, err2 := spireg.Open(*spiID)\n\tif err2 != nil {\n\t\treturn err2\n\t}\n\tdefer func() {\n\t\tif err2 := spiPort.Close(); err == nil {\n\t\t\terr = err2\n\t\t}\n\t}()\n\tif !*record {\n\t\treturn run(i2cBus, uint16(*i2cAddr), spiPort)\n\t}\n\n\ti2cRecorder := i2ctest.Record{Bus: i2cBus}\n\tspiRecorder := spitest.Record{Port: spiPort}\n\terr = run(&i2cRecorder, uint16(*i2cAddr), &spiRecorder)\n\tif len(i2cRecorder.Ops) != 0 {\n\t\tfmt.Printf(\"I²C recorder Addr: 0x%02X\\n\", i2cRecorder.Ops[0].Addr)\n\t} else {\n\t\tfmt.Print(\"I²C recorder\\n\")\n\t}\n\tfor _, op := range i2cRecorder.Ops {\n\t\tfmt.Print(\" W: \")\n\t\tfor i, b := range op.W {\n\t\t\tif i != 0 {\n\t\t\t\tfmt.Print(\", \")\n\t\t\t}\n\t\t\tfmt.Printf(\"0x%02X\", b)\n\t\t}\n\t\tfmt.Print(\"\\n R: \")\n\t\tfor i, b := range op.R {\n\t\t\tif i != 0 {\n\t\t\t\tfmt.Print(\", \")\n\t\t\t}\n\t\t\tfmt.Printf(\"0x%02X\", b)\n\t\t}\n\t\tfmt.Print(\"\\n\")\n\t}\n\tfmt.Print(\"\\nSPI recorder\\n\")\n\tfor _, op := range spiRecorder.Ops {\n\t\tfmt.Print(\" W: \")\n\t\tif len(op.R) != 0 {\n\t\t\t// Read data.\n\t\t\tfmt.Printf(\"0x%02X\\n R: \", op.W[0])\n\t\t\t// first byte is dummy.\n\t\t\tfor i, b := range op.R[1:] {\n\t\t\t\tif i != 0 {\n\t\t\t\t\tfmt.Print(\", \")\n\t\t\t\t}\n\t\t\t\tfmt.Printf(\"0x%02X\", b)\n\t\t\t}\n\t\t} else {\n\t\t\t// Write-only command.\n\t\t\tfor i, b := range op.W {\n\t\t\t\tif i != 0 {\n\t\t\t\t\tfmt.Print(\", \")\n\t\t\t\t}\n\t\t\t\tfmt.Printf(\"0x%02X\", b)\n\t\t\t}\n\t\t\tfmt.Print(\"\\n R: \")\n\t\t}\n\t\tfmt.Print(\"\\n\")\n\t}\n\treturn err\n}", "func TestSolution(t *testing.T) {\n\tfor test, f := range tests {\n\t\tRunTest(t, test, f, SampleTestCases)\n\t}\n}", "func RunTests(ctx context.Context, w io.Writer, path string) error {\n\tif path == \"\" || path == \".\" {\n\t\tvar err error\n\t\tpath, err = os.Getwd()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tfiles, err := getTestFiles(ctx, path)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor i := range files {\n\t\terr = runFile(ctx, &files[i])\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\terr = Report(w, files)\n\treturn err\n}", "func loadExamples(path string) []*Example {\n\tfp, err := os.Open(path)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer fp.Close()\n\n\tvar examples []*Example\n\tif err := json.NewDecoder(fp).Decode(&examples); err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn examples\n}", "func Test(t *testing.T, p prog.Program, cases ...Case) {\n\tt.Helper()\n\tfor _, c := range cases {\n\t\tt.Run(strings.Join(c.args, \" \"), func(t *testing.T) {\n\t\t\tt.Helper()\n\t\t\tr := run(p, c.args, c.stdin)\n\t\t\tif r.exitCode != c.want.exitCode {\n\t\t\t\tt.Errorf(\"got exit code %v, want %v\", r.exitCode, c.want.exitCode)\n\t\t\t}\n\t\t\tif !matchOutput(r.stdout, c.want.stdout) {\n\t\t\t\tt.Errorf(\"got stdout %v, want %v\", r.stdout, c.want.stdout)\n\t\t\t}\n\t\t\tif !matchOutput(r.stderr, c.want.stderr) {\n\t\t\t\tt.Errorf(\"got stderr %v, want %v\", r.stderr, c.want.stderr)\n\t\t\t}\n\t\t})\n\t}\n}", "func ExecTest() {\n\tHelloTest()\n\n\tVarTest()\n\tEnumTest()\n\n\tOpTestArithmetic()\n\tOpTestRelation()\n\tOpTestBoolean()\n\tOpTestBit()\n\tOpTestAssign()\n\tOpTestPriority()\n\tOpTestOther()\n\n\tLoopTest()\n\n\tArrayOneDimTest()\n\tArrayTwoDimTest()\n\n\tPointerTest()\n\tPtrArrayTest()\n\tPtr2PtrTest()\n\tPtrParamTest()\n\n\tFuncTest()\n\tFuncArrayParamTest()\n\tFuncMultiReturnTest()\n\tFuncRecurTest()\n\tFuncClosureTest()\n\n\tRangeTest()\n\tStructTest()\n\tSliceTest()\n\tTypeCastTest()\n\tMapTest()\n\n\tInterfaceTest()\n\n\tMethodTest()\n\tErrorTest()\n}", "func (b *Base) ExamplesHelp() string {\n\tif b.Examples == \"\" {\n\t\treturn \"\"\n\t}\n\treturn fmt.Sprintf(\"Examples:\\n%s\", strings.Trim(b.Examples, \"\\n\"))\n}", "func RunTests(m *testing.M, version *int) {\n\tflag.IntVar(version, \"v\", 0, \"The anwork version that should be used with these tests\")\n\tflag.Parse()\n\n\tif *version == 0 {\n\t\tpanic(\"Version (-v) must be passed with a legitimate anwork version number\")\n\t}\n\n\tos.Exit(m.Run())\n}", "func (suite *AddCommandTestSuite) TestExecuteWithMultipleURLs() {\n\n}", "func main() {\n\ttest_plain_background()\n\ttest_cloud()\n\ttest_enemy()\n\ttest_move_background()\n\ttest_display_score()\n}", "func RunBuiltinTests(t *testing.T, resourceType string) {\n\t// Get a list of all test cases\n\tbox := packr.NewBox(\"./assets/\" + resourceType)\n\tfilesInBox := box.List()\n\tfor _, file := range filesInBox {\n\t\tif isTestCase(file) {\n\t\t\tabsolutePath, _ := filepath.Abs(\"./assets/\" + resourceType + \"/\" + file)\n\t\t\tts, err := loadTestSuite(absolutePath)\n\t\t\tif err != nil {\n\t\t\t\tassert.Nil(t, err, \"Cannot load test case\")\n\t\t\t}\n\t\t\trunTestSuite(t, ts)\n\t\t}\n\t}\n}", "func TestMain(t *testing.T) {\n}", "func main() {\n\tapp := getRootCmd()\n\n\t// ignore error so we don't exit non-zero and break gfmrun README example tests\n\t_ = app.Execute()\n}", "func (m *Master) Example(args *ExampleArgs, reply *ExampleReply) error {\n\treply.Y = args.X + 1\n\treturn nil\n\t//return errors.New(\"test error 1\")\n}", "func MainHello() {\n\t// hello(\"zheng\", \"jin\")\n\t// intFormatTest()\n\t// returnVarsTest()\n\n\t// intVarsTest()\n\t// stringVarsTest()\n\t// arrayVarsTest()\n\t// sliceVarsTest()\n\t// mapVarsTest01()\n\t// mapVarsTest02()\n\n\t// switchTest()\n\t// controlTest()\n\t// argsTest()\n\n\t// innerFuncTest()\n\t// funcVarsTest()\n\t// funcClosureTest()\n\n\t// varTypeCheckTest()\n\t// objectTest()\n\n\tfmt.Println(\"golang hello examples DONE.\")\n}", "func (p *DefaultPipeline) TransformTFExamples(tfs ...transform.TFExampleTransformation) *DefaultPipeline {\n\treturn p.WithTFExamplesStage(func(r core.TFExampleReader) core.TFExampleReader {\n\t\treturn transform.NewTFExampleTransformer(r, tfs...)\n\t})\n}", "func executeTests(t *testing.T, tests ...testExecution) {\n\tctx := setupTestRequirements(t)\n\tdefer ctx.Cleanup()\n\n\tsetupComplianceOperatorCluster(t, ctx)\n\n\t// get global framework variables\n\tf := framework.Global\n\n\tns, err := ctx.GetNamespace()\n\tif err != nil {\n\t\tt.Fatalf(\"could not get namespace: %v\", err)\n\t}\n\n\tfor _, test := range tests {\n\t\tt.Run(test.Name, func(t *testing.T) {\n\t\t\tif err := test.TestFn(t, f, ctx, ns); err != nil {\n\t\t\t\tt.Error(err)\n\t\t\t}\n\t\t})\n\n\t}\n}", "func TestAllTask() {\n\tif noTestsFlag {\n\t\tlog.Println(\"*** Skipping: notests\")\n\t\treturn\n\t}\n\trunCmd(\"./pkg/pac/make.sh\")\n\trunCmd(\"go\", \"test\", \"-tags=\\\"net databases\\\"\",\n\t\t\"./cmd/...\", \"./pkg/...\")\n}", "func RunTest(ctx context.Context, target, location string, nodeIDs []int, limit int, debug, outputJSON bool, runTest runFunc, runOutput runOutputFunc) error {\n\trunReq := &perfops.RunRequest{\n\t\tTarget: target,\n\t\tLocation: location,\n\t\tNodes: nodeIDs,\n\t\tLimit: limit,\n\t}\n\n\tf := NewFormatter(debug && !outputJSON)\n\tf.StartSpinner()\n\ttestID, err := runTest(ctx, runReq)\n\tf.StopSpinner()\n\tif err != nil {\n\t\treturn err\n\t}\n\tres := &RunOutputResult{}\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-time.After(200 * time.Millisecond):\n\t\t\t}\n\t\t\toutput, err := runOutput(ctx, testID)\n\t\t\tres.SetOutput(output, err)\n\t\t\tif err != nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}()\n\n\tif outputJSON {\n\t\tf.StartSpinner()\n\t}\n\tvar o *perfops.RunOutput\n\tfor {\n\t\tselect {\n\t\tcase <-time.After(50 * time.Millisecond):\n\t\t}\n\t\tif o, err = res.Output(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !outputJSON && o != nil {\n\t\t\tPrintOutput(f, o)\n\t\t}\n\t\tif o != nil && o.IsFinished() {\n\t\t\tbreak\n\t\t}\n\t}\n\tif outputJSON {\n\t\tf.StopSpinner()\n\t\tPrintOutputJSON(o)\n\t}\n\treturn nil\n}", "func init() { //nolint\n\ttestSample := TestCase{\n\t\tName: \"should exclude provided queries [E2E-CLI-020]\",\n\t\tArgs: args{\n\t\t\tArgs: []cmdArgs{\n\t\t\t\t[]string{\"scan\", \"--exclude-queries\", \"15ffbacc-fa42-4f6f-a57d-2feac7365caa,0a494a6a-ebe2-48a0-9d77-cf9d5125e1b3\", \"-s\",\n\t\t\t\t\t\"-q\", \"../assets/queries\", \"-p\", \"fixtures/samples/terraform-single.tf\"},\n\t\t\t},\n\t\t},\n\t\tWantStatus: []int{20},\n\t}\n\n\tTests = append(Tests, testSample)\n}", "func TestRun(t *testing.T) {\n\tsandbox, cleanup := cmdtest.TestSetupWithSandbox(t, false)\n\tdefer cleanup()\n\n\t// first add the test repo index\n\t_, err := cmdtest.AddLocalRepo(sandbox, \"LocalTestRepo\", filepath.Join(sandbox.TestDataPath, \"dev.local-index.yaml\"))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tstacksList := cmdtest.GetEnvStacksList()\n\n\tif stacksList == \"dev.local/starter\" {\n\t\tt.Skip()\n\t}\n\n\t// appsody init nodejs-express\n\t_, err = cmdtest.RunAppsody(sandbox, \"init\", \"nodejs-express\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// appsody run\n\trunChannel := make(chan error)\n\tgo func() {\n\t\t_, err = cmdtest.RunAppsody(sandbox, \"run\")\n\t\trunChannel <- err\n\t\tclose(runChannel)\n\t}()\n\n\t// defer the appsody stop to close the docker container\n\tdefer func() {\n\t\t_, err = cmdtest.RunAppsody(sandbox, \"stop\")\n\t\tif err != nil {\n\t\t\tt.Logf(\"Ignoring error running appsody stop: %s\", err)\n\t\t}\n\t\t// wait for the appsody command/goroutine to finish\n\t\trunErr := <-runChannel\n\t\tif runErr != nil {\n\t\t\tt.Logf(\"Ignoring error from the appsody command: %s\", runErr)\n\t\t}\n\t}()\n\n\thealthCheckFrequency := 2 // in seconds\n\thealthCheckTimeout := 60 // in seconds\n\thealthCheckWait := 0\n\thealthCheckOK := false\n\tfor !(healthCheckOK || healthCheckWait >= healthCheckTimeout) {\n\t\tselect {\n\t\tcase err = <-runChannel:\n\t\t\t// appsody run exited, probably with an error\n\t\t\tt.Fatalf(\"appsody run quit unexpectedly: %s\", err)\n\t\tcase <-time.After(time.Duration(healthCheckFrequency) * time.Second):\n\t\t\t// check the health endpoint\n\t\t\thealthCheckWait += healthCheckFrequency\n\t\t\tresp, err := http.Get(\"http://localhost:3000/health\")\n\t\t\tif err != nil {\n\t\t\t\tt.Logf(\"Health check error. Ignore and retry: %s\", err)\n\t\t\t} else {\n\t\t\t\tresp.Body.Close()\n\t\t\t\tif resp.StatusCode != 200 {\n\t\t\t\t\tt.Logf(\"Health check response code %d. Ignore and retry.\", resp.StatusCode)\n\t\t\t\t} else {\n\t\t\t\t\tt.Logf(\"Health check OK\")\n\t\t\t\t\t// may want to check body\n\t\t\t\t\thealthCheckOK = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif !healthCheckOK {\n\t\tt.Errorf(\"Did not receive an OK health check within %d seconds.\", healthCheckTimeout)\n\t}\n}", "func runTestScenarios(t *testing.T, tests []testCase) {\n\trunTestScenariosWithInput(t, tests, nil)\n}", "func RunGinkgoTests(t *testing.T, name string) {\n\t// Setup logging\n\tlog.SetFlags(log.LstdFlags)\n\tlog.SetOutput(ginkgo.GinkgoWriter)\n\tgomega.RegisterFailHandler(ginkgo.Fail)\n\tginkgo.RunSpecs(t, name)\n}", "func TestDoQuestions(t *testing.T) {\n\tquestions := parseQuestions(\"test\")\n\tdoQuestions(questions, 3)\n}", "func TestExamplesComplete(t *testing.T) {\n\tt.Parallel()\n\n\tterraformOptions := &terraform.Options{\n\t\t// The path to where our Terraform code is located\n\t\tTerraformDir: \"../../examples/complete\",\n\t\tUpgrade: true,\n\t\t// Variables to pass to our Terraform code using -var-file options\n\t\tVarFiles: []string{\"fixtures.us-east-2.tfvars\"},\n\t}\n\n\t// At the end of the test, run `terraform destroy` to clean up any resources that were created\n\tdefer terraform.Destroy(t, terraformOptions)\n\n\t// This will run `terraform init` and `terraform apply` and fail the test if there are any errors\n\tterraform.InitAndApply(t, terraformOptions)\n\n\t// Run `terraform output` to get the value of an output variable\n\toutput := terraform.Output(t, terraformOptions, \"map\")\n\n\tkey1Result := strings.Contains(output, \"/production/test/master/company\")\n\tvalue1Result := strings.Contains(output, \"Amazon\")\n\tkey2Result := strings.Contains(output, \"/production/test/master/users\")\n\tvalue2Result := strings.Contains(output, \"John,Todd\")\n\n\t// Verify we're getting back the outputs we expect\n\tassert.True(t, key1Result, \"The 'map' output should contain the /production/test/master/company key\")\n\tassert.True(t, value1Result, \"The /production/test/master/company key's value should be 'Amazon'\")\n\n\tassert.True(t, key2Result, \"The 'map' output should contain the /production/test/master/users key\")\n\tassert.True(t, value2Result, \"The /production/test/master/users key's value should be 'John,Todd'\")\n}", "func RunTestsInternal(ctx *kt.Context, suite string) {\n\tconf, ok := suites[suite]\n\tif !ok {\n\t\tctx.Skipf(\"No configuration found for suite '%s'\", suite)\n\t}\n\tctx.Config = conf\n\t// This is run as a sub-test so configuration will work nicely.\n\tctx.Run(\"PreCleanup\", func(ctx *kt.Context) {\n\t\tctx.RunAdmin(func(ctx *kt.Context) {\n\t\t\tcount, err := doCleanup(ctx.Admin, true)\n\t\t\tif count > 0 {\n\t\t\t\tctx.Logf(\"Pre-cleanup removed %d databases from previous test runs\", count)\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\tctx.Fatalf(\"Pre-cleanup failed: %s\", err)\n\t\t\t}\n\t\t})\n\t})\n\tkt.RunSubtests(ctx)\n}", "func main() {\n\t// Init close channel used to stop the example.\n\texampleFinished := make(chan struct{}, 1)\n\n\t// Start Agent with ExamplePlugin, REST, prometheus plugin & FlavorLocal (reused cn-infra plugins).\n\tagent := local.NewAgent(local.WithPlugins(func(flavor *local.FlavorLocal) []*core.NamedPlugin {\n\t\thttpPlugin := &rest.Plugin{}\n\n\t\trest.DeclareHTTPPortFlag(\"http\")\n\t\thttpPlugDeps := *flavor.InfraDeps(\"http\", local.WithConf())\n\t\thttpPlugin.Deps.Log = httpPlugDeps.Log\n\t\thttpPlugin.Deps.PluginConfig = httpPlugDeps.PluginConfig\n\t\thttpPlugin.Deps.PluginName = httpPlugDeps.PluginName\n\n\t\tprometheusPlugin := &prom.Plugin{}\n\t\tprometheusPlugin.Deps.PluginInfraDeps = *flavor.InfraDeps(\"prometheus\")\n\t\tprometheusPlugin.Deps.HTTP = httpPlugin\n\n\t\texamplePlug := &ExamplePlugin{}\n\t\texamplePlug.Deps.PluginInfraDeps = *flavor.InfraDeps(\"prometheus-example\")\n\t\texamplePlug.Deps.Prometheus = prometheusPlugin\n\n\t\treturn []*core.NamedPlugin{\n\t\t\t{httpPlugin.PluginName, httpPlugin},\n\t\t\t{prometheusPlugin.PluginName, prometheusPlugin},\n\t\t\t{examplePlug.PluginName, examplePlug}}\n\t}))\n\tcore.EventLoopWithInterrupt(agent, exampleFinished)\n}", "func TestSubprocessExample_UseWithCommandCollector(t *testing.T) {\n\tres := td.RunTestSteps(t, false, func(ctx context.Context) error {\n\t\tmock := exec.CommandCollector{}\n\t\t// In other code, this would be exec.NewContext(ctx, mock.Run), but that doesn't work with\n\t\t// task driver's setup.\n\t\t// TODO(borenet) Could this be done automatically by teaching taskdriver about RunFn?\n\t\tctx = td.WithExecRunFn(ctx, mock.Run)\n\t\terr := subprocessExample(ctx)\n\t\tif err != nil {\n\t\t\tassert.NoError(t, err)\n\t\t\treturn err\n\t\t}\n\t\trequire.Len(t, mock.Commands(), 2)\n\t\tcmd := mock.Commands()[0]\n\t\tassert.Equal(t, \"llamasay\", cmd.Name)\n\t\tassert.Equal(t, []string{\"hello\", \"world\"}, cmd.Args)\n\n\t\tcmd = mock.Commands()[1]\n\t\tassert.Equal(t, \"bearsay\", cmd.Name)\n\t\tassert.Equal(t, []string{\"good\", \"night\", \"moon\"}, cmd.Args)\n\t\treturn nil\n\t})\n\trequire.Empty(t, res.Errors)\n\trequire.Empty(t, res.Exceptions)\n}", "func (r *Runner) Run() []error {\n\tif len(r.Sources) < 1 {\n\t\tr.log.Warn(\"no sources given\")\n\t\treturn nil\n\t}\n\n\tres := []*runResult{}\n\n\tsourcesStart := time.Now()\n\n\tfor i, sourceFile := range r.Sources {\n\t\tsourceBytes, err := os.ReadFile(sourceFile)\n\t\tif err != nil {\n\t\t\tres = append(res, &runResult{Retcode: -1, Error: err})\n\t\t\tcontinue\n\t\t}\n\n\t\tres = append(res, r.checkSource(i, sourceFile, string(sourceBytes))...)\n\t}\n\n\tif !r.noExec && r.Count > 0 && len(res) != r.Count {\n\t\tr.log.WithFields(logrus.Fields{\n\t\t\t\"expected\": r.Count,\n\t\t\t\"actual\": len(res),\n\t\t}).Error(\"mismatched example count\")\n\n\t\treturn []error{fmt.Errorf(\"example count %d != expected %d\", len(res), r.Count)}\n\t}\n\n\tif len(res) == 0 {\n\t\treturn []error{}\n\t}\n\n\terrs := []error{}\n\n\tfor _, result := range res {\n\t\tif result == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tif result.Stdout != \"\" || result.Stderr != \"\" {\n\t\t\tr.log.WithFields(logrus.Fields{\n\t\t\t\t\"source\": result.Runnable.SourceFile,\n\t\t\t\t\"stdout\": result.Stdout,\n\t\t\t\t\"stderr\": result.Stderr,\n\t\t\t}).Debug(\"captured output\")\n\t\t}\n\n\t\tif result.Error != nil {\n\t\t\tif v, ok := result.Error.(*skipErr); ok {\n\t\t\t\tr.log.WithFields(logrus.Fields{\n\t\t\t\t\t\"source\": result.Runnable.SourceFile,\n\t\t\t\t\t\"line\": result.Runnable.LineOffset,\n\t\t\t\t\t\"reason\": v.Reason,\n\t\t\t\t}).Debug(\"skipped example\")\n\t\t\t} else {\n\t\t\t\terrs = append(errs, result.Error)\n\t\t\t}\n\t\t}\n\t}\n\n\tr.log.WithFields(logrus.Fields{\n\t\t\"source_count\": len(r.Sources),\n\t\t\"example_count\": len(res),\n\t\t\"error_count\": len(errs),\n\t\t\"time\": time.Since(sourcesStart),\n\t}).Info(\"done\")\n\n\treturn errs\n}", "func (suite *AddCommandTestSuite) TestExecuteWhenMultipleTracksFound() {\n\n}", "func runTests(t *testing.T, tests []test) {\n\tfor _, tt := range tests {\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tresp := executeRequest(tt.method, tt.url, serialize(tt.req), tt.asAdmin)\n\t\t\tif resp.StatusCode != tt.want {\n\t\t\t\tt.Errorf(\"Unexpected status code %d\", resp.StatusCode)\n\t\t\t}\n\n\t\t\tif tt.body != \"\" {\n\t\t\t\tbodyBytes, err := ioutil.ReadAll(resp.Body)\n\t\t\t\tdefer resp.Body.Close()\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Errorf(\"Error loading body\")\n\t\t\t\t}\n\t\t\t\tif tt.body != string(bodyBytes) {\n\t\t\t\t\tt.Errorf(\"Unexpected body '%s', expected '%s'\", bodyBytes, tt.body)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n}", "func TestSimpleRun(t *testing.T) {\n\tctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\n\tdefer cancel()\n\n\tns := \"sonobuoy-\" + strings.ToLower(t.Name())\n\tdefer cleanup(t, ns)\n\n\targs := fmt.Sprintf(\"run --image-pull-policy IfNotPresent --wait -p testImage/yaml/job-junit-passing-singlefile.yaml -n %v\", ns)\n\terr, _, stderr := runSonobuoyCommandWithContext(ctx, t, args)\n\n\tif err != nil {\n\t\tt.Errorf(\"Sonobuoy exited with an error: %q\\n\", err)\n\t\tt.Log(stderr.String())\n\t}\n}", "func (s *SmokeTest) Run(f *flag.FlagSet, args []string) (err error) {\n\ts.delay = 2 * time.Second\n\ti2cID := f.String(\"i2c\", \"\", \"I²C bus to use\")\n\tspiID := f.String(\"spi\", \"\", \"SPI port to use\")\n\tdcName := f.String(\"dc\", \"\", \"DC pin to use in 4-wire SPI mode\")\n\n\tw := f.Int(\"w\", 128, \"Display width\")\n\th := f.Int(\"h\", 64, \"Display height\")\n\trotated := f.Bool(\"rotated\", false, \"Rotate the displays by 180°\")\n\n\trecord := f.Bool(\"record\", false, \"record operation (for playback unit testing)\")\n\tf.Parse(args)\n\tif f.NArg() != 0 {\n\t\tf.Usage()\n\t\treturn errors.New(\"unrecognized arguments\")\n\t}\n\n\ti2cBus, err2 := i2creg.Open(*i2cID)\n\tif err2 != nil {\n\t\treturn err2\n\t}\n\tdefer func() {\n\t\tif err2 := i2cBus.Close(); err == nil {\n\t\t\terr = err2\n\t\t}\n\t}()\n\n\tspiPort, err2 := spireg.Open(*spiID)\n\tif err2 != nil {\n\t\treturn err2\n\t}\n\tdefer func() {\n\t\tif err2 := spiPort.Close(); err == nil {\n\t\t\terr = err2\n\t\t}\n\t}()\n\n\tvar dc gpio.PinOut\n\tif len(*dcName) != 0 {\n\t\tdc = gpioreg.ByName(*dcName)\n\t}\n\tif !*record {\n\t\treturn s.run(i2cBus, spiPort, dc, *w, *h, *rotated)\n\t}\n\n\ti2cRecorder := i2ctest.Record{Bus: i2cBus}\n\tspiRecorder := spitest.Record{Port: spiPort}\n\terr = s.run(&i2cRecorder, &spiRecorder, dc, *w, *h, *rotated)\n\tif len(i2cRecorder.Ops) != 0 {\n\t\tfmt.Printf(\"I²C recorder Addr: 0x%02X\\n\", i2cRecorder.Ops[0].Addr)\n\t} else {\n\t\tfmt.Print(\"I²C recorder\\n\")\n\t}\n\tfor _, op := range i2cRecorder.Ops {\n\t\tfmt.Print(\" W: \")\n\t\tfor i, b := range op.W {\n\t\t\tif i != 0 {\n\t\t\t\tfmt.Print(\", \")\n\t\t\t}\n\t\t\tfmt.Printf(\"0x%02X\", b)\n\t\t}\n\t\tfmt.Print(\"\\n R: \")\n\t\tfor i, b := range op.R {\n\t\t\tif i != 0 {\n\t\t\t\tfmt.Print(\", \")\n\t\t\t}\n\t\t\tfmt.Printf(\"0x%02X\", b)\n\t\t}\n\t\tfmt.Print(\"\\n\")\n\t}\n\tfmt.Print(\"\\nSPI recorder\\n\")\n\tfor _, op := range spiRecorder.Ops {\n\t\tfmt.Print(\" W: \")\n\t\tif len(op.R) != 0 {\n\t\t\t// Read data.\n\t\t\tfmt.Printf(\"0x%02X\\n R: \", op.W[0])\n\t\t\t// first byte is dummy.\n\t\t\tfor i, b := range op.R[1:] {\n\t\t\t\tif i != 0 {\n\t\t\t\t\tfmt.Print(\", \")\n\t\t\t\t}\n\t\t\t\tfmt.Printf(\"0x%02X\", b)\n\t\t\t}\n\t\t} else {\n\t\t\t// Write-only command.\n\t\t\tfor i, b := range op.W {\n\t\t\t\tif i != 0 {\n\t\t\t\t\tfmt.Print(\", \")\n\t\t\t\t}\n\t\t\t\tfmt.Printf(\"0x%02X\", b)\n\t\t\t}\n\t\t\tfmt.Print(\"\\n R: \")\n\t\t}\n\t\tfmt.Print(\"\\n\")\n\t}\n\treturn err\n}", "func (t *Test) Run() error {\n\treturn t.Wrap(t.run)\n}", "func (tc ScannerTestcase) Run(ctx context.Context) func(*testing.T) {\n\tsort.Slice(tc.Want, pkgSort(tc.Want))\n\treturn func(t *testing.T) {\n\t\tctx := zlog.Test(ctx, t)\n\t\td := tc.Digest()\n\t\tn, err := fetch.Layer(ctx, t, http.DefaultClient, tc.Domain, tc.Name, d)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\tdefer n.Close()\n\t\tl := &claircore.Layer{\n\t\t\tHash: d,\n\t\t}\n\t\tl.SetLocal(n.Name())\n\n\t\tgot, err := tc.Scanner.Scan(ctx, l)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\tsort.Slice(got, pkgSort(got))\n\t\tt.Logf(\"found %d packages\", len(got))\n\t\tif !cmp.Equal(tc.Want, got) {\n\t\t\tt.Error(cmp.Diff(tc.Want, got))\n\t\t}\n\t}\n}", "func runTestScenariosWithInputAndProcessedOutput(t *testing.T, tests []testCase, input *os.File, processOutput processOutput) {\n\tfor _, tc := range tests {\n\t\tt.Run(tc.name, func(t *testing.T) {\n\t\t\tcmd := exec.Command(binaryPath, tc.args...)\n\n\t\t\tif input != nil {\n\t\t\t\tcmd.Stdin = input\n\t\t\t}\n\n\t\t\toutput, err := cmd.CombinedOutput()\n\t\t\tif (err != nil) != tc.wantErr {\n\t\t\t\tt.Fatalf(\"%s\\nexpected (err != nil) to be %v, but got %v. err: %v\", output, tc.wantErr, err != nil, err)\n\t\t\t}\n\t\t\tactual := string(output)\n\n\t\t\tif processOutput != nil {\n\t\t\t\tactual = processOutput(actual)\n\t\t\t}\n\n\t\t\tgolden := newGoldenFile(t, tc.golden)\n\n\t\t\tif *update {\n\t\t\t\tgolden.write(actual)\n\t\t\t}\n\t\t\texpected := golden.load()\n\t\t\tif !reflect.DeepEqual(expected, actual) {\n\t\t\t\tt.Fatalf(\"Expected: %v Actual: %v\", expected, actual)\n\t\t\t}\n\t\t})\n\t}\n}", "func RunExam() {\n\tvarConst()\n\tcondition(0, 10)\n\tcondition(1, 10)\n\tcondition(1, 0)\n\tswitchCase(0)\n\tswitchCase(2)\n\tswitchCase(3)\n\tforLoop()\n\tfuncTest()\n\tanonyFuncTest()\n\t// closure\n\trunClosure()\n\t// slice\n\trunSlice()\n\t// map\n\trunMap()\n}", "func Run(top *testing.T, name string, f TestFunc, accessories ...*Accessory) {\n\tif _, previouslyCalled := seen.LoadOrStore(fmt.Sprintf(\"%p\", top), nil); !previouslyCalled {\n\t\ttop.Parallel()\n\t}\n\ttop.Run(name, func(mid *testing.T) {\n\t\tmid.Parallel()\n\t\tctx, cancel := context.WithCancel(context.Background())\n\t\tbottom := testhelper.NewT(ctx, mid)\n\t\tcmd := newCiOperatorCommand(bottom)\n\t\ttestDone, cleanupDone := make(chan struct{}), make(chan struct{})\n\t\tdefer func() {\n\t\t\t// signal to the command that we no longer need to be waiting to\n\t\t\t// interrupt it; then wait for the cleanup routine to finish before\n\t\t\t// we consider the test done\n\t\t\tclose(testDone)\n\t\t\t<-cleanupDone\n\t\t}()\n\t\tcmd.testDone = testDone\n\t\tcmd.cleanupDone = cleanupDone\n\n\t\twg := sync.WaitGroup{}\n\t\twg.Add(len(accessories))\n\t\tfor _, accessory := range accessories {\n\t\t\t// binding the accessory to ctx ensures its lifetime is only\n\t\t\t// as long as the test we are running in this specific case\n\t\t\taccessory.RunFromFrameworkRunner(bottom, ctx, false)\n\t\t\tcmd.AddArgs(accessory.ClientFlags()...)\n\t\t\tgo func(a *Accessory) {\n\t\t\t\tdefer wg.Done()\n\t\t\t\ta.Ready(bottom)\n\t\t\t}(accessory)\n\t\t}\n\t\twg.Wait()\n\n\t\tgo func() {\n\t\t\tdefer func() { cancel() }() // stop waiting for errors\n\t\t\tf(bottom, &cmd)\n\t\t}()\n\n\t\tbottom.Wait()\n\t})\n}", "func main() {\r\n\t//scenario1()\r\n\t//scenario2()\r\n\t//scenario3()\r\n\t//scenario4()\r\n}", "func TestRun(t *testing.T) {\n\tsuite.Run(t, new(CategoryTestSuite))\n\tsuite.Run(t, new(ProductTestSuite))\n}", "func Test() error {\n\tfmt.Println(\"Testing...\")\n\tcmd := exec.Command(\"go\", \"test\", \"-cover\", \"-v\", \"-bench\", \"'.'\", \"-benchmem\", \"./...\")\n\tcmd.Stdout = Stdout\n\tcmd.Stderr = Stderr\n\treturn cmd.Run()\n}", "func Run(ctx context.Context, s *testing.State) {\n\t// Reserve time for cleanup\n\tcloseCtx := ctx\n\tctx, cancel := ctxutil.Shorten(ctx, 2*time.Second)\n\tdefer cancel()\n\n\t// Perform initial test setup\n\tsetupVars, err := runSetup(ctx, s)\n\tif err != nil {\n\t\ts.Fatal(\"Failed to run setup: \", err)\n\t}\n\tdefer setupVars.closeBrowser(closeCtx)\n\tdefer setupVars.recorder.Close(closeCtx)\n\n\tif err := muteDevice(ctx, s); err != nil {\n\t\ts.Log(\"(non-error) Failed to mute device: \", err)\n\t}\n\n\t// Execute Test\n\tif err := setupVars.recorder.Run(ctx, func(ctx context.Context) error {\n\t\treturn testBody(ctx, setupVars)\n\t}); err != nil {\n\t\ts.Fatal(\"Failed to conduct the test scenario, or collect the histogram data: \", err)\n\t}\n\n\t// Write out values\n\tpv := perf.NewValues()\n\tif err := setupVars.recorder.Record(ctx, pv); err != nil {\n\t\ts.Fatal(\"Failed to report: \", err)\n\t}\n\tif err := pv.Save(s.OutDir()); err != nil {\n\t\ts.Error(\"Failed to store values: \", err)\n\t}\n}", "func TestExample(t *testing.T) {\n\tinstance := &RestExample{\n\t\tpost: make(map[string]string),\n\t\twatch: make(map[string]chan string),\n\t}\n\n\tinstance.HandleCreateHello(HelloArg{\n\t\tTo: \"rest\",\n\t\tPost: \"rest is powerful\",\n\t})\n\n\tresp, err := rest.SetTest(instance, map[string]string{\"to\": \"rest\"}, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\targ := instance.HandleHello()\n\tif resp.Code != http.StatusOK {\n\t\tt.Error(\"should return ok\")\n\t}\n\tif arg.To != \"rest\" {\n\t\tt.Error(\"arg.To should be rest\")\n\t}\n\tif arg.Post != \"rest is powerful\" {\n\t\tt.Error(\"arg.Post should be 'rest is powerful'\")\n\t}\n\n\tresp, err = rest.SetTest(instance, map[string]string{\"to\": \"123\"}, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\targ = instance.HandleHello()\n\tif resp.Code != http.StatusNotFound {\n\t\tt.Error(\"should return not found\")\n\t}\n}", "func (t *TestRuntime) RunTests(m *testing.M) int {\n\treturn t.runTests(m, !testing.Verbose())\n}", "func TestExecute(t *testing.T) {\n\tctx := context.Background()\n\n\t// Clear pre-existing golden files to avoid leaving stale ones around.\n\tif *updateGoldens {\n\t\tfiles, err := filepath.Glob(filepath.Join(*goldensDir, \"*.golden.json\"))\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\tfor _, f := range files {\n\t\t\tif err := os.Remove(f); err != nil {\n\t\t\t\tt.Fatal(err)\n\t\t\t}\n\t\t}\n\t}\n\n\ttestCases := []struct {\n\t\tname string\n\t\tflags testsharderFlags\n\t\ttestSpecs []build.TestSpec\n\t\ttestDurations []build.TestDuration\n\t\ttestList []build.TestListEntry\n\t\tmodifiers []testsharder.TestModifier\n\t\tpackageRepos []build.PackageRepo\n\t\taffectedTests []string\n\t}{\n\t\t{\n\t\t\tname: \"no tests\",\n\t\t},\n\t\t{\n\t\t\tname: \"mixed device types\",\n\t\t\ttestSpecs: []build.TestSpec{\n\t\t\t\tfuchsiaTestSpec(\"foo\"),\n\t\t\t\thostTestSpec(\"bar\"),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"multiply\",\n\t\t\tflags: testsharderFlags{\n\t\t\t\ttargetDurationSecs: 5,\n\t\t\t},\n\t\t\ttestSpecs: []build.TestSpec{\n\t\t\t\tfuchsiaTestSpec(\"foo\"),\n\t\t\t\tfuchsiaTestSpec(\"bar\"),\n\t\t\t},\n\t\t\tmodifiers: []testsharder.TestModifier{\n\t\t\t\t{\n\t\t\t\t\tName: \"foo\",\n\t\t\t\t\tTotalRuns: 50,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tName: \"bar\",\n\t\t\t\t},\n\t\t\t},\n\t\t\ttestDurations: []build.TestDuration{\n\t\t\t\t{\n\t\t\t\t\tName: \"*\",\n\t\t\t\t\tMedianDuration: time.Millisecond,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"affected tests\",\n\t\t\ttestSpecs: []build.TestSpec{\n\t\t\t\tfuchsiaTestSpec(\"affected-hermetic\"),\n\t\t\t\tfuchsiaTestSpec(\"not-affected\"),\n\t\t\t},\n\t\t\ttestList: []build.TestListEntry{\n\t\t\t\ttestListEntry(\"affected-hermetic\", true),\n\t\t\t\ttestListEntry(\"not-affected\", false),\n\t\t\t},\n\t\t\taffectedTests: []string{\n\t\t\t\tpackageURL(\"affected-hermetic\"),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"affected nonhermetic tests\",\n\t\t\ttestSpecs: []build.TestSpec{\n\t\t\t\tfuchsiaTestSpec(\"affected-nonhermetic\"),\n\t\t\t\tfuchsiaTestSpec(\"not-affected\"),\n\t\t\t},\n\t\t\taffectedTests: []string{\n\t\t\t\tpackageURL(\"affected-nonhermetic\"),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"target test count\",\n\t\t\tflags: testsharderFlags{\n\t\t\t\ttargetTestCount: 2,\n\t\t\t},\n\t\t\ttestSpecs: []build.TestSpec{\n\t\t\t\tfuchsiaTestSpec(\"foo1\"),\n\t\t\t\tfuchsiaTestSpec(\"foo2\"),\n\t\t\t\tfuchsiaTestSpec(\"foo3\"),\n\t\t\t\tfuchsiaTestSpec(\"foo4\"),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"sharding by time\",\n\t\t\tflags: testsharderFlags{\n\t\t\t\ttargetDurationSecs: int((4 * time.Minute).Seconds()),\n\t\t\t\tperTestTimeoutSecs: int((10 * time.Minute).Seconds()),\n\t\t\t},\n\t\t\ttestSpecs: []build.TestSpec{\n\t\t\t\tfuchsiaTestSpec(\"slow\"),\n\t\t\t\tfuchsiaTestSpec(\"fast1\"),\n\t\t\t\tfuchsiaTestSpec(\"fast2\"),\n\t\t\t\tfuchsiaTestSpec(\"fast3\"),\n\t\t\t},\n\t\t\ttestDurations: []build.TestDuration{\n\t\t\t\t{\n\t\t\t\t\tName: \"*\",\n\t\t\t\t\tMedianDuration: 2 * time.Second,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tName: packageURL(\"slow\"),\n\t\t\t\t\tMedianDuration: 5 * time.Minute,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"max shards per env\",\n\t\t\tflags: testsharderFlags{\n\t\t\t\t// Given expected test durations of 4 minutes for each test it's\n\t\t\t\t// impossible to satisfy both the target shard duration and the\n\t\t\t\t// max shards per environment, so the target shard duration\n\t\t\t\t// should effectively be ignored.\n\t\t\t\ttargetDurationSecs: int((5 * time.Minute).Seconds()),\n\t\t\t\tmaxShardsPerEnvironment: 2,\n\t\t\t\tskipUnaffected: true,\n\t\t\t},\n\t\t\ttestSpecs: []build.TestSpec{\n\t\t\t\tfuchsiaTestSpec(\"affected1\"),\n\t\t\t\tfuchsiaTestSpec(\"affected2\"),\n\t\t\t\tfuchsiaTestSpec(\"affected3\"),\n\t\t\t\tfuchsiaTestSpec(\"affected4\"),\n\t\t\t\tfuchsiaTestSpec(\"unaffected1\"),\n\t\t\t\tfuchsiaTestSpec(\"unaffected2\"),\n\t\t\t\tfuchsiaTestSpec(\"nonhermetic1\"),\n\t\t\t\tfuchsiaTestSpec(\"nonhermetic2\"),\n\t\t\t},\n\t\t\ttestDurations: []build.TestDuration{\n\t\t\t\t{\n\t\t\t\t\tName: \"*\",\n\t\t\t\t\tMedianDuration: 4 * time.Minute,\n\t\t\t\t},\n\t\t\t},\n\t\t\taffectedTests: []string{\n\t\t\t\tpackageURL(\"affected1\"),\n\t\t\t\tpackageURL(\"affected2\"),\n\t\t\t\tpackageURL(\"affected3\"),\n\t\t\t\tpackageURL(\"affected4\"),\n\t\t\t},\n\t\t\ttestList: []build.TestListEntry{\n\t\t\t\ttestListEntry(\"affected1\", true),\n\t\t\t\ttestListEntry(\"affected2\", true),\n\t\t\t\ttestListEntry(\"affected3\", true),\n\t\t\t\ttestListEntry(\"affected4\", true),\n\t\t\t\ttestListEntry(\"unaffected1\", true),\n\t\t\t\ttestListEntry(\"unaffected2\", true),\n\t\t\t\ttestListEntry(\"nonhermetic1\", false),\n\t\t\t\ttestListEntry(\"nonhermetic2\", false),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"hermetic deps\",\n\t\t\tflags: testsharderFlags{\n\t\t\t\thermeticDeps: true,\n\t\t\t},\n\t\t\ttestSpecs: []build.TestSpec{\n\t\t\t\tfuchsiaTestSpec(\"foo\"),\n\t\t\t\tfuchsiaTestSpec(\"bar\"),\n\t\t\t\tfuchsiaTestSpec(\"baz\"),\n\t\t\t},\n\t\t\tpackageRepos: []build.PackageRepo{\n\t\t\t\t{\n\t\t\t\t\tPath: \"pkg_repo1\",\n\t\t\t\t\tBlobs: filepath.Join(\"pkg_repo1\", \"blobs\"),\n\t\t\t\t\tTargets: filepath.Join(\"pkg_repo1\", \"targets.json\"),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"ffx deps\",\n\t\t\tflags: testsharderFlags{\n\t\t\t\tffxDeps: true,\n\t\t\t},\n\t\t\ttestSpecs: []build.TestSpec{\n\t\t\t\tfuchsiaTestSpec(\"foo\"),\n\t\t\t\tfuchsiaTestSpec(\"bar\"),\n\t\t\t\tfuchsiaTestSpec(\"baz\"),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"multiply affected test\",\n\t\t\tflags: testsharderFlags{\n\t\t\t\taffectedTestsMultiplyThreshold: 3,\n\t\t\t\ttargetDurationSecs: int(2 * time.Minute.Seconds()),\n\t\t\t},\n\t\t\ttestSpecs: []build.TestSpec{\n\t\t\t\tfuchsiaTestSpec(\"multiplied-affected-test\"),\n\t\t\t\tfuchsiaTestSpec(\"affected-test\"),\n\t\t\t\tfuchsiaTestSpec(\"unaffected-test\"),\n\t\t\t},\n\t\t\ttestDurations: []build.TestDuration{\n\t\t\t\t{\n\t\t\t\t\tName: \"*\",\n\t\t\t\t\tMedianDuration: time.Second,\n\t\t\t\t},\n\t\t\t},\n\t\t\taffectedTests: []string{\n\t\t\t\tpackageURL(\"multiplied-affected-test\"),\n\t\t\t\tpackageURL(\"affected-test\"),\n\t\t\t},\n\t\t\tmodifiers: []testsharder.TestModifier{\n\t\t\t\t{\n\t\t\t\t\tName: \"multiplied-affected-test\",\n\t\t\t\t\tTotalRuns: 100,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"test list with tags\",\n\t\t\ttestSpecs: []build.TestSpec{\n\t\t\t\tfuchsiaTestSpec(\"hermetic-test\"),\n\t\t\t\tfuchsiaTestSpec(\"nonhermetic-test\"),\n\t\t\t},\n\t\t\ttestList: []build.TestListEntry{\n\t\t\t\ttestListEntry(\"hermetic-test\", true),\n\t\t\t\ttestListEntry(\"nonhermetic-test\", false),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"skip unaffected tests\",\n\t\t\tflags: testsharderFlags{\n\t\t\t\tskipUnaffected: true,\n\t\t\t},\n\t\t\ttestSpecs: []build.TestSpec{\n\t\t\t\tfuchsiaTestSpec(\"affected-hermetic-test\"),\n\t\t\t\tfuchsiaTestSpec(\"unaffected-hermetic-test\"),\n\t\t\t\tfuchsiaTestSpec(\"affected-nonhermetic-test\"),\n\t\t\t\tfuchsiaTestSpec(\"unaffected-nonhermetic-test\"),\n\t\t\t},\n\t\t\ttestList: []build.TestListEntry{\n\t\t\t\ttestListEntry(\"affected-hermetic-test\", true),\n\t\t\t\ttestListEntry(\"unaffected-hermetic-test\", true),\n\t\t\t\ttestListEntry(\"affected-nonhermetic-test\", false),\n\t\t\t\ttestListEntry(\"unaffected-nonhermetic-test\", false),\n\t\t\t},\n\t\t\taffectedTests: []string{\n\t\t\t\tfuchsiaTestSpec(\"affected-hermetic-test\").Name,\n\t\t\t\tfuchsiaTestSpec(\"affected-nonhermetic-test\").Name,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"run all tests if no affected tests\",\n\t\t\tflags: testsharderFlags{\n\t\t\t\tskipUnaffected: true,\n\t\t\t},\n\t\t\ttestSpecs: []build.TestSpec{\n\t\t\t\tfuchsiaTestSpec(\"affected-hermetic-test\"),\n\t\t\t\tfuchsiaTestSpec(\"unaffected-hermetic-test\"),\n\t\t\t\tfuchsiaTestSpec(\"affected-nonhermetic-test\"),\n\t\t\t\tfuchsiaTestSpec(\"unaffected-nonhermetic-test\"),\n\t\t\t},\n\t\t\ttestList: []build.TestListEntry{\n\t\t\t\ttestListEntry(\"affected-hermetic-test\", true),\n\t\t\t\ttestListEntry(\"unaffected-hermetic-test\", true),\n\t\t\t\ttestListEntry(\"affected-nonhermetic-test\", false),\n\t\t\t\ttestListEntry(\"unaffected-nonhermetic-test\", false),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"multiply unaffected hermetic tests\",\n\t\t\tflags: testsharderFlags{\n\t\t\t\tskipUnaffected: true,\n\t\t\t},\n\t\t\ttestSpecs: []build.TestSpec{\n\t\t\t\tfuchsiaTestSpec(\"unaffected-hermetic-test\"),\n\t\t\t\tfuchsiaTestSpec(\"affected-nonhermetic-test\"),\n\t\t\t\tfuchsiaTestSpec(\"unaffected-hermetic-multiplied-test\"),\n\t\t\t},\n\t\t\ttestList: []build.TestListEntry{\n\t\t\t\ttestListEntry(\"unaffected-hermetic-test\", true),\n\t\t\t\ttestListEntry(\"affected-nonhermetic-test\", false),\n\t\t\t\ttestListEntry(\"unaffected-hermetic-multiplied-test\", true),\n\t\t\t},\n\t\t\taffectedTests: []string{\n\t\t\t\tfuchsiaTestSpec(\"affected-nonhermetic-test\").Name,\n\t\t\t},\n\t\t\tmodifiers: []testsharder.TestModifier{\n\t\t\t\t{\n\t\t\t\t\tName: \"unaffected-hermetic-multiplied-test\",\n\t\t\t\t\tTotalRuns: 100,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"various modifiers\",\n\t\t\tflags: testsharderFlags{\n\t\t\t\ttargetDurationSecs: 5,\n\t\t\t},\n\t\t\ttestSpecs: []build.TestSpec{\n\t\t\t\tfuchsiaTestSpec(\"foo\"),\n\t\t\t\tfuchsiaTestSpec(\"bar\"),\n\t\t\t\tfuchsiaTestSpec(\"baz\"),\n\t\t\t},\n\t\t\tmodifiers: []testsharder.TestModifier{\n\t\t\t\t// default modifier\n\t\t\t\t{\n\t\t\t\t\tName: \"*\",\n\t\t\t\t\tTotalRuns: -1,\n\t\t\t\t\tMaxAttempts: 2,\n\t\t\t\t},\n\t\t\t\t// multiplier\n\t\t\t\t{\n\t\t\t\t\tName: \"foo\",\n\t\t\t\t\tMaxAttempts: 1,\n\t\t\t\t},\n\t\t\t\t// change maxAttempts (but multiplier takes precedence)\n\t\t\t\t{\n\t\t\t\t\tName: \"foo\",\n\t\t\t\t\tTotalRuns: -1,\n\t\t\t\t\tMaxAttempts: 1,\n\t\t\t\t},\n\t\t\t\t// change maxAttempts, set affected\n\t\t\t\t{\n\t\t\t\t\tName: \"bar\",\n\t\t\t\t\tAffected: true,\n\t\t\t\t\tTotalRuns: -1,\n\t\t\t\t\tMaxAttempts: 1,\n\t\t\t\t},\n\t\t\t},\n\t\t\ttestList: []build.TestListEntry{\n\t\t\t\ttestListEntry(\"foo\", false),\n\t\t\t\ttestListEntry(\"bar\", true),\n\t\t\t\ttestListEntry(\"baz\", false),\n\t\t\t},\n\t\t\ttestDurations: []build.TestDuration{\n\t\t\t\t{\n\t\t\t\t\tName: \"*\",\n\t\t\t\t\tMedianDuration: time.Millisecond,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tfor _, tc := range testCases {\n\t\tt.Run(tc.name, func(t *testing.T) {\n\t\t\tgoldenBasename := strings.ReplaceAll(tc.name, \" \", \"_\") + \".golden.json\"\n\t\t\tgoldenFile := filepath.Join(*goldensDir, goldenBasename)\n\n\t\t\tif *updateGoldens {\n\t\t\t\ttc.flags.outputFile = goldenFile\n\t\t\t} else {\n\t\t\t\ttc.flags.outputFile = filepath.Join(t.TempDir(), goldenBasename)\n\t\t\t}\n\n\t\t\ttc.flags.buildDir = t.TempDir()\n\t\t\tif len(tc.modifiers) > 0 {\n\t\t\t\ttc.flags.modifiersPath = writeTempJSONFile(t, tc.modifiers)\n\t\t\t}\n\t\t\tif len(tc.affectedTests) > 0 {\n\t\t\t\t// Add a newline to the end of the file to test that it still calculates the\n\t\t\t\t// correct number of affected tests even with extra whitespace.\n\t\t\t\ttc.flags.affectedTestsPath = writeTempFile(t, strings.Join(tc.affectedTests, \"\\n\")+\"\\n\")\n\t\t\t}\n\t\t\tif tc.flags.ffxDeps {\n\t\t\t\tsdkManifest := map[string]interface{}{\n\t\t\t\t\t\"atoms\": []interface{}{},\n\t\t\t\t}\n\t\t\t\tsdkManifestPath := filepath.Join(tc.flags.buildDir, \"sdk\", \"manifest\", \"core\")\n\t\t\t\tif err := os.MkdirAll(filepath.Dir(sdkManifestPath), os.ModePerm); err != nil {\n\t\t\t\t\tt.Fatal(err)\n\t\t\t\t}\n\t\t\t\tif err := jsonutil.WriteToFile(sdkManifestPath, sdkManifest); err != nil {\n\t\t\t\t\tt.Fatal(err)\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Write test-list.json.\n\t\t\tif err := jsonutil.WriteToFile(\n\t\t\t\tfilepath.Join(tc.flags.buildDir, testListPath),\n\t\t\t\tbuild.TestList{Data: tc.testList, SchemaID: \"experimental\"},\n\t\t\t); err != nil {\n\t\t\t\tt.Fatal(err)\n\t\t\t}\n\t\t\twriteDepFiles(t, tc.flags.buildDir, tc.testSpecs)\n\t\t\tfor _, repo := range tc.packageRepos {\n\t\t\t\tif err := os.MkdirAll(filepath.Join(tc.flags.buildDir, repo.Path), 0o700); err != nil {\n\t\t\t\t\tt.Fatal(err)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tm := &fakeModules{\n\t\t\t\ttestSpecs: tc.testSpecs,\n\t\t\t\ttestDurations: tc.testDurations,\n\t\t\t\tpackageRepositories: tc.packageRepos,\n\t\t\t}\n\t\t\tif err := execute(ctx, tc.flags, m); err != nil {\n\t\t\t\tt.Fatal(err)\n\t\t\t}\n\n\t\t\tif !*updateGoldens {\n\t\t\t\twant := readShards(t, goldenFile)\n\t\t\t\tgot := readShards(t, tc.flags.outputFile)\n\t\t\t\tif diff := cmp.Diff(want, got); diff != \"\" {\n\t\t\t\t\tt.Errorf(strings.Join([]string{\n\t\t\t\t\t\t\"Golden file mismatch!\",\n\t\t\t\t\t\t\"To fix, run `tools/integration/testsharder/update_goldens.sh\",\n\t\t\t\t\t\tdiff,\n\t\t\t\t\t}, \"\\n\"))\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n}", "func Run(\n\tdao DAO,\n\tstatements, setupStatements, teardownStatements, solutions []Statement,\n\tselectedQuestions []string,\n) ([]TestResult, error) {\n\tvar testResult = []TestResult{}\n\n\ti := 0\n\tresults, errs, err := dao.ExecuteStatements(setupStatements, teardownStatements, statements)\n\tsolutionResults, _, err := dao.ExecuteStatements(setupStatements, teardownStatements, solutions)\n\ttestcases := ConvertTablesToTestCases(solutionResults)\n\n\tif err != nil {\n\t\treturn testResult, err\n\t}\n\n\tfor _, expected := range testcases {\n\t\tif !stringInSlice(expected.Index, selectedQuestions) && len(selectedQuestions) > 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif i >= len(results) {\n\t\t\ttestResult = append(\n\t\t\t\ttestResult,\n\t\t\t\tTestResult{\n\t\t\t\t\tExpected: expected,\n\t\t\t\t\tActual: Result{},\n\t\t\t\t\tPass: false,\n\t\t\t\t},\n\t\t\t)\n\t\t\ti++\n\t\t\tcontinue\n\t\t}\n\t\ttable := results[i]\n\t\terr := errs[i]\n\t\t// Query has syntax error\n\t\tif err != nil {\n\t\t\ttestResult = append(\n\t\t\t\ttestResult,\n\t\t\t\tTestResult{\n\t\t\t\t\tExpected: expected,\n\t\t\t\t\tActual: table,\n\t\t\t\t\tPass: false,\n\t\t\t\t\tError: err,\n\t\t\t\t},\n\t\t\t)\n\t\t\ti++\n\t\t\tcontinue\n\t\t}\n\t\tif !reflect.DeepEqual(table.Content, expected.Content) {\n\t\t\ttestResult = append(\n\t\t\t\ttestResult,\n\t\t\t\tTestResult{\n\t\t\t\t\tExpected: expected,\n\t\t\t\t\tActual: table,\n\t\t\t\t\tPass: false,\n\t\t\t\t},\n\t\t\t)\n\t\t} else {\n\t\t\ttestResult = append(\n\t\t\t\ttestResult,\n\t\t\t\tTestResult{\n\t\t\t\t\tExpected: expected,\n\t\t\t\t\tActual: table,\n\t\t\t\t\tPass: true,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\ti++\n\t}\n\n\treturn testResult, nil\n}", "func Run(t *testing.T, configOpt core.ConfigProvider, sdkOpts ...fabsdk.Option) {\n\tsetupAndRun(t, true, configOpt, e2eTest, sdkOpts...)\n}", "func (ldx *LxdAudit) Run(args []string) int {\n\t// load audit tests fro benchmark folder\n\tauditTests := ldx.FileLoader.LoadAuditTests(ldx.FilesInfo)\n\t// filter tests by cmd criteria\n\tft := filteredAuditBenchTests(auditTests, ldx.PredicateChain, ldx.PredicateParams)\n\t//execute audit tests and show it in progress bar\n\tcompletedTest := executeTests(ft, ldx.runAuditTest, ldx.log)\n\t// generate output data\n\tui.PrintOutput(completedTest, ldx.OutputGenerator, ldx.log)\n\t// send test results to plugin\n\tsendResultToPlugin(ldx.PlChan, ldx.CompletedChan, completedTest)\n\treturn 0\n}", "func Test(t *testing.T, command Runner, testCases []Case) {\n\tt.Helper()\n\n\tfor _, tc := range testCases {\n\t\tt.Run(tc.Name, func(t *testing.T) {\n\t\t\tt.Helper() // TODO: make Helper working for subtests: issue #24128\n\n\t\t\tstdout := &bytes.Buffer{}\n\t\t\tstderr := &bytes.Buffer{}\n\n\t\t\tcommand.SetStdout(stdout)\n\t\t\tcommand.SetStderr(stderr)\n\n\t\t\tm := newMatch(t, tc.wantFail)\n\n\t\t\tif tc.WantFile != \"\" {\n\t\t\t\tif !m.removeFile(tc.WantFile) {\n\t\t\t\t\ttc.WantFile = \"\" // stop testing File match\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar gotErr string\n\t\t\tgotPanic := m.run(func() {\n\t\t\t\tif err := command.Run(tc.Args); err != nil {\n\t\t\t\t\tgotErr = err.Error()\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tif tc.WantFile != \"\" {\n\t\t\t\tif gotFile, ext, ok := m.getFile(tc.WantFile); ok {\n\t\t\t\t\tm.match(\"File golden\"+ext, gotFile, \"golden\"+ext)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tm.match(\"WantStdout\", stdout.String(), tc.WantStdout)\n\t\t\tm.match(\"WantStderr\", stderr.String(), tc.WantStderr)\n\t\t\tm.match(\"WantPanic\", gotPanic, tc.WantPanic)\n\t\t\tm.match(\"WantErr\", gotErr, tc.WantErr)\n\t\t\tm.equal(\"WantExitCode\", command.ExitCode(), tc.WantExitCode)\n\n\t\t\tm.done()\n\t\t})\n\t}\n}", "func TestRunCommands(t *testing.T) {\n\n\t// Read the user structure from the test file\n\tusr, _ := myusr.Current()\n\tusers := configuration.ReadUsersYAML(usr.HomeDir + \"/CONFIG/TOD/users/users.yaml\")\n\n\t// configuration\n\tconf := &configuration.Config{}\n\tconf.Port = 22\n\tconf.Protocol = \"tcp\"\n\tconf.Timeout = 10\n\tconf.LogCommand = \"/tmp\"\n\tconf.CPUMax = 25.0\n\tconf.MemoryMax = 30.0\n\tconf.ExcludeLoaded = true\n\tconf.WorkTimer = true\n\tconf.WorkTime = 120\n\tconf.HostsMax = 5\n\tconf.Stdin = true\n\n\t// read command from the example configuration\n\tcmds := configuration.UsersToDispatcher(*users)\n\n\t// replicate the command in the example\n\tcommands := make([]commands.Command, 121)\n\tfor i := range commands {\n\t\tcommands[i] = cmds[0]\n\t}\n\n\t// Create the list of commands and hosts\n\thsts := new(host.Hosts)\n\thosts := make([]*host.Host, len(hostnames))\n\tfor i, hst := range hostnames {\n\t\t// Create the host object in the slice\n\t\thosts[i] = &host.Host{\n\t\t\tHostname: hst,\n\t\t}\n\t}\n\thsts.Hosts = hosts\n\n\t// display\n\tformatter.ColoredPrintln(\n\t\tformatter.Blue,\n\t\tfalse,\n\t\t\"All data initialized !\",\n\t)\n\n\t// Create dispatcher\n\tdispatcher := New(conf, hsts)\n\n\t// Dispatch commands on hosts\n\thsts.Dispatcher(\n\t\tcommands,\n\t\tconf.HostsMax,\n\t\ttrue,\n\t)\n\n\t// display\n\tformatter.ColoredPrintln(\n\t\tformatter.Blue,\n\t\tfalse,\n\t\t\"Dispatching the commands on hosts done !\",\n\t)\n\n\t// Run commands in concurrent\n\tdispatcher.RunCommands(len(commands))\n\n\t// display\n\tformatter.ColoredPrintln(\n\t\tformatter.Blue,\n\t\tfalse,\n\t\t\"Commands done !\",\n\t)\n}", "func runExample() {\n\tll := DoublyLinkedList{}\n\tll.Add(10)\n\tll.Add(91)\n\tll.Add(22)\n\tll.Add(183)\n\tll.Add(4)\n\tll.Add(23)\n\tll.PrintList()\n\tll.PrintListReverse()\n\n\tll.Remove(183)\n\tll.PrintList()\n\n\tll.Remove(23)\n\tll.PrintList()\n\n\tll.Remove(10)\n\tll.PrintList()\n}" ]
[ "0.764823", "0.73474324", "0.6862852", "0.6840609", "0.660363", "0.65557784", "0.6547067", "0.6374077", "0.63478315", "0.63422245", "0.6229371", "0.6192121", "0.6175554", "0.6041606", "0.6032973", "0.59743", "0.58787906", "0.5873177", "0.5837253", "0.5771184", "0.5759049", "0.5690626", "0.56685877", "0.56685877", "0.566444", "0.56427044", "0.55895233", "0.55786175", "0.55578065", "0.5541426", "0.5516801", "0.5506497", "0.550602", "0.5501226", "0.5500644", "0.54838467", "0.5479194", "0.54768956", "0.5474988", "0.5458115", "0.5456099", "0.5443582", "0.54338735", "0.54329777", "0.5406802", "0.5401236", "0.53951997", "0.53855556", "0.5371213", "0.5367325", "0.5364332", "0.53529215", "0.5349155", "0.5337896", "0.5317748", "0.53043354", "0.52915466", "0.5284369", "0.5280794", "0.52655", "0.52623796", "0.5259944", "0.5253145", "0.52506655", "0.52420413", "0.52261746", "0.5225013", "0.5221441", "0.5216297", "0.52159363", "0.5209791", "0.52067024", "0.5190436", "0.518771", "0.51874703", "0.5185041", "0.51716095", "0.516915", "0.51682323", "0.51644707", "0.51633126", "0.51623625", "0.5156498", "0.51530284", "0.5152802", "0.51513505", "0.5148391", "0.51483697", "0.5142794", "0.51426077", "0.51396024", "0.51377755", "0.5133966", "0.5133846", "0.5132476", "0.5132018", "0.5130671", "0.51302576", "0.5123093", "0.5121664" ]
0.7366353
1
Validate checks the default configuration of a proxy configuration.
func (opts *ProxyOptions) Validate() error { if !strings.HasPrefix(opts.RemotePrefix, "/") { opts.RemotePrefix = "/" + opts.RemotePrefix } catcher := grip.NewBasicCatcher() catcher.NewWhen(len(opts.TargetPool) == 0 && opts.FindTarget == nil, "must specify a way to resolve target host") catcher.NewWhen(len(opts.TargetPool) >= 1 && opts.FindTarget != nil, "cannot specify more than one target resolution option") return catcher.Resolve() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *ProxyServerConfig) CheckAndSetDefaults() error {\n\tif c.AccessPoint == nil {\n\t\treturn trace.BadParameter(\"missing AccessPoint\")\n\t}\n\tif c.AuthClient == nil {\n\t\treturn trace.BadParameter(\"missing AuthClient\")\n\t}\n\tif c.Authorizer == nil {\n\t\treturn trace.BadParameter(\"missing Authorizer\")\n\t}\n\tif c.Tunnel == nil {\n\t\treturn trace.BadParameter(\"missing Tunnel\")\n\t}\n\tif c.TLSConfig == nil {\n\t\treturn trace.BadParameter(\"missing TLSConfig\")\n\t}\n\tif c.Clock == nil {\n\t\tc.Clock = clockwork.NewRealClock()\n\t}\n\tif c.ServerID == \"\" {\n\t\treturn trace.BadParameter(\"missing ServerID\")\n\t}\n\tif c.LockWatcher == nil {\n\t\treturn trace.BadParameter(\"missing LockWatcher\")\n\t}\n\tif c.Limiter == nil {\n\t\t// Empty config means no connection limit.\n\t\tconnLimiter, err := limiter.NewLimiter(limiter.Config{})\n\t\tif err != nil {\n\t\t\treturn trace.Wrap(err)\n\t\t}\n\n\t\tc.Limiter = connLimiter\n\t}\n\treturn nil\n}", "func validateKubeProxy(conf *operv1.NetworkSpec) []error {\n\tout := []error{}\n\tp := conf.KubeProxyConfig\n\tif p == nil {\n\t\treturn out\n\t}\n\n\tif p.IptablesSyncPeriod != \"\" {\n\t\t_, err := time.ParseDuration(p.IptablesSyncPeriod)\n\t\tif err != nil {\n\t\t\tout = append(out, errors.Errorf(\"IptablesSyncPeriod is not a valid duration (%v)\", err))\n\t\t}\n\t}\n\n\tif p.BindAddress != \"\" {\n\t\tif net.ParseIP(p.BindAddress) == nil {\n\t\t\tout = append(out, errors.Errorf(\"BindAddress must be a valid IP address\"))\n\t\t}\n\t}\n\n\t// Don't allow ports to be overridden\n\tif p.ProxyArguments != nil {\n\t\tif val, ok := p.ProxyArguments[\"metrics-port\"]; ok {\n\t\t\tif !(len(val) == 1 && val[0] == \"9101\") {\n\t\t\t\tout = append(out, errors.Errorf(\"kube-proxy --metrics-port must be 9101\"))\n\t\t\t}\n\t\t}\n\n\t\tif val, ok := p.ProxyArguments[\"healthz-port\"]; ok {\n\t\t\tif !(len(val) == 1 && val[0] == \"10256\") {\n\t\t\t\tout = append(out, errors.Errorf(\"kube-proxy --healthz-port must be 10256\"))\n\t\t\t}\n\t\t}\n\t}\n\n\treturn out\n}", "func TestInvalidProxyConfig(t *testing.T) {\n\n\t// proxy.handler not set\n\tinvalidConfig := []byte(`\nproxy:\n host: http://proxy.example.com\n`)\n\t_, err := LoadAndValidateYaml(invalidConfig)\n\tif err == nil || !strings.Contains(err.Error(), \"handler\") {\n\t\tt.Errorf(\"Expected proxy handler error. Got: %s\", err.Error())\n\t}\n\n\t// proxy.listen not set\n\tinvalidConfig = []byte(`\nproxy:\n handler: http\n host: proxy.example.com\n`)\n\t_, err = LoadAndValidateYaml(invalidConfig)\n\tif err == nil || !strings.Contains(err.Error(), \"host:port\") {\n\t\tt.Errorf(\"Expected proxy host error. Got: %s\", err.Error())\n\t}\n\n\tinvalidConfig = []byte(`\nproxy:\n handler: http\n host: proxy.example.com\n listen: :8000\n`)\n\t_, err = LoadAndValidateYaml(invalidConfig)\n\n\tif err == nil || !strings.Contains(err.Error(), \"proxy.host\") {\n\t\tt.Errorf(\"Expected proxy host error. Got: %s\", err.Error())\n\t}\n}", "func (m *HttpConnectionManager_ProxyStatusConfig) Validate() error {\n\treturn m.validate(false)\n}", "func (s *OpenconfigInterfaces_Interfaces_Interface_Tunnel_Ipv4_ProxyArp_Config) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigInterfaces_Interfaces_Interface_Tunnel_Ipv4_ProxyArp_Config\"], s, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func TestNewProxyClientBrokenConfig(t *testing.T) {\n\tassert := assert.New(t)\n\n\t// empty config\n\tvar config = []byte(`{}`)\n\tviper.ReadConfig(bytes.NewBuffer(config))\n\tclient, err := NewProxyClient()\n\n\tassert.Nil(client)\n\tassert.EqualError(err, \"username is required\")\n\n\t// http_protocol set\n\tviper.ReadConfig(bytes.NewBuffer([]byte(`{\n\t\t\"username\": \"testuser\"\n\t}`)))\n\tclient, err = NewProxyClient()\n\tassert.Nil(client)\n\tassert.EqualError(err, \"password is required\")\n}", "func FillKubeProxyDefaults(conf, previous *operv1.NetworkSpec) {\n\tif conf.DeployKubeProxy == nil {\n\t\tv := ShouldDeployKubeProxy(conf)\n\t\tconf.DeployKubeProxy = &v\n\t}\n\n\tif !*conf.DeployKubeProxy {\n\t\treturn\n\t}\n\n\tif conf.KubeProxyConfig == nil {\n\t\tconf.KubeProxyConfig = &operv1.ProxyConfig{}\n\t}\n\n\tif conf.KubeProxyConfig.BindAddress == \"\" {\n\t\tconf.KubeProxyConfig.BindAddress = \"0.0.0.0\"\n\t}\n}", "func (t *OpenconfigInterfaces_Interfaces_Interface_RoutedVlan_Ipv4_ProxyArp_Config) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigInterfaces_Interfaces_Interface_RoutedVlan_Ipv4_ProxyArp_Config\"], t, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func ValidateKubeProxyConfiguration(internalcfg *kubeadmapi.ClusterConfiguration, _ *field.Path) field.ErrorList {\n\tallErrs := field.ErrorList{}\n\tif internalcfg.ComponentConfigs.KubeProxy == nil {\n\t\treturn allErrs\n\t}\n\treturn proxyvalidation.Validate(internalcfg.ComponentConfigs.KubeProxy)\n}", "func ValidateProxySpec(ctx context.Context, client client.Client, instance *storagev1.CSIPowerMaxRevProxy) error {\n\tproxySpec := instance.Spec\n\terr := checkIfSecretExists(ctx, client, proxySpec.TLSSecret, instance.Namespace)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Validate the mode\n\tswitch proxySpec.RevProxy.Mode {\n\tcase \"\":\n\t\tfallthrough\n\tcase \"Linked\":\n\t\treturn validateLinkedProxySpec(ctx, client, instance)\n\tcase \"StandAlone\":\n\t\treturn validateStandAloneProxySpec(ctx, client, instance)\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown mode specified\")\n\t}\n}", "func (a *Agent) applyProxyConfigDefaults(p *structs.ConnectManagedProxy) (map[string]interface{}, error) {\n\tif p == nil || p.ProxyService == nil {\n\t\t// Should never happen but protect from panic\n\t\treturn nil, fmt.Errorf(\"invalid proxy state\")\n\t}\n\n\t// Lookup the target service\n\ttarget := a.State.Service(p.TargetServiceID)\n\tif target == nil {\n\t\t// Can happen during deregistration race between proxy and scheduler.\n\t\treturn nil, fmt.Errorf(\"unknown target service ID: %s\", p.TargetServiceID)\n\t}\n\n\t// Merge globals defaults\n\tconfig := make(map[string]interface{})\n\tfor k, v := range a.config.ConnectProxyDefaultConfig {\n\t\tif _, ok := config[k]; !ok {\n\t\t\tconfig[k] = v\n\t\t}\n\t}\n\n\t// Copy config from the proxy\n\tfor k, v := range p.Config {\n\t\tconfig[k] = v\n\t}\n\n\t// Set defaults for anything that is still not specified but required.\n\t// Note that these are not included in the content hash. Since we expect\n\t// them to be static in general but some like the default target service\n\t// port might not be. In that edge case services can set that explicitly\n\t// when they re-register which will be caught though.\n\tif _, ok := config[\"bind_port\"]; !ok {\n\t\tconfig[\"bind_port\"] = p.ProxyService.Port\n\t}\n\tif _, ok := config[\"bind_address\"]; !ok {\n\t\t// Default to binding to the same address the agent is configured to\n\t\t// bind to.\n\t\tconfig[\"bind_address\"] = a.config.BindAddr.String()\n\t}\n\tif _, ok := config[\"local_service_address\"]; !ok {\n\t\t// Default to localhost and the port the service registered with\n\t\tconfig[\"local_service_address\"] = fmt.Sprintf(\"127.0.0.1:%d\", target.Port)\n\t}\n\n\t// Basic type conversions for expected types.\n\tif raw, ok := config[\"bind_port\"]; ok {\n\t\tswitch v := raw.(type) {\n\t\tcase float64:\n\t\t\t// Common since HCL/JSON parse as float64\n\t\t\tconfig[\"bind_port\"] = int(v)\n\n\t\t\t// NOTE(mitchellh): No default case since errors and validation\n\t\t\t// are handled by the ServiceDefinition.Validate function.\n\t\t}\n\t}\n\n\treturn config, nil\n}", "func (c *Config) validate() error {\n\t/* Metrics */\n\n\t// Users can omit the metrics block entirely to disable metrics reporting.\n\tif c.Metrics != nil && c.Metrics.Statsd != nil {\n\t\tif c.Metrics.Statsd.Address == \"\" {\n\t\t\treturn fmt.Errorf(\"config: missing metrics statsd address\")\n\t\t}\n\n\t\tif c.Metrics.Statsd.SampleRate < 0 || c.Metrics.Statsd.SampleRate > 1 {\n\t\t\treturn fmt.Errorf(\"config: statsd sample rate must be in range [0.0, 1.0]\")\n\t\t}\n\t}\n\n\t/* Listener */\n\n\tif c.Listener == nil {\n\t\treturn fmt.Errorf(\"config: missing top-level listener config key\")\n\t}\n\n\tif c.Listener.TCP == nil && c.Listener.UDP == nil {\n\t\treturn fmt.Errorf(\"config: at least one TCP or UDP listener must be specified\")\n\t}\n\n\tif c.Listener.TCP != nil && c.Listener.TCP.Address == \"\" {\n\t\treturn fmt.Errorf(\"config: missing TCP server listening address\")\n\t}\n\n\tif c.Listener.UDP != nil && c.Listener.UDP.Address == \"\" {\n\t\treturn fmt.Errorf(\"config: missing UDP server listening address\")\n\t}\n\n\t/* Upstream */\n\n\tif c.Upstream == nil {\n\t\treturn fmt.Errorf(\"config: missing top-level upstream config key\")\n\t}\n\n\t// Validate the load balancing policy, only if provided (empty signifies default).\n\tif c.Upstream.LoadBalancingPolicy != \"\" {\n\t\tif _, ok := network.ParseLoadBalancingPolicy(c.Upstream.LoadBalancingPolicy); !ok {\n\t\t\treturn fmt.Errorf(\n\t\t\t\t\"config: unknown load balancing policy: policy=%s\",\n\t\t\t\tc.Upstream.LoadBalancingPolicy,\n\t\t\t)\n\t\t}\n\t}\n\n\tif len(c.Upstream.Servers) == 0 {\n\t\treturn fmt.Errorf(\"config: no upstream servers specified\")\n\t}\n\n\tfor idx, server := range c.Upstream.Servers {\n\t\tif server.Address == \"\" {\n\t\t\treturn fmt.Errorf(\"config: missing server address: idx=%d\", idx)\n\t\t}\n\n\t\tif server.ServerName == \"\" {\n\t\t\treturn fmt.Errorf(\"config: missing server TLS hostname: idx=%d\", idx)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (s *OpenconfigInterfaces_Interfaces_Interface_RoutedVlan_Ipv4_ProxyArp_Config) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigInterfaces_Interfaces_Interface_RoutedVlan_Ipv4_ProxyArp_Config\"], s, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (m *TunnelConfig) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateIPAddress(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateSharedSecret(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (c *ServiceConfig) Validate() error {\n\tif c.Name == \"\" {\n\t\treturn errors.New(\"Name must be set\")\n\t}\n\n\tif c.ID == \"\" {\n\t\treturn errors.New(\"ID must be set\")\n\t}\n\n\tif c.Network == \"\" {\n\t\treturn errors.New(\"nginx.network must be set\")\n\t}\n\n\t//calculate max parameter length\n\tmax := len(c.Ports)\n\n\tif l := len(c.ListenIPs); l > max {\n\t\tmax = l\n\t}\n\tif l := len(c.ListenPorts); l > max {\n\t\tmax = l\n\t}\n\tif l := len(c.ListenProtos); l > max {\n\t\tmax = l\n\t}\n\n\t//verify parameter lengths\n\tif l := len(c.Ports); l == 1 {\n\t\tfor i := 1; i < max; i++ {\n\t\t\tc.Ports = append(c.Ports, c.Ports[0])\n\t\t}\n\t} else if l < max {\n\t\treturn fmt.Errorf(\"nginx.port length mismatch. Expected %d or 1, got %d\", max, l)\n\t}\n\n\tif l := len(c.ListenIPs); l == 1 {\n\t\tfor i := 1; i < max; i++ {\n\t\t\tc.ListenIPs = append(c.ListenIPs, c.ListenIPs[0])\n\t\t}\n\t} else if l < max {\n\t\treturn fmt.Errorf(\"nginx.listenIP length mismatch. Expected %d or 1, got %d\", max, l)\n\t}\n\n\tif l := len(c.ListenPorts); l == 1 {\n\t\tfor i := 1; i < max; i++ {\n\t\t\tc.ListenPorts = append(c.ListenPorts, c.ListenPorts[0])\n\t\t}\n\t} else if l < max {\n\t\treturn fmt.Errorf(\"nginx.listenPort length mismatch. Expected %d or 1, got %d\", max, l)\n\t}\n\n\tif l := len(c.ListenProtos); l == 1 {\n\t\tfor i := 1; i < max; i++ {\n\t\t\tc.ListenProtos = append(c.ListenProtos, c.ListenProtos[0])\n\t\t}\n\t} else if l < max {\n\t\treturn fmt.Errorf(\"nginx.listenProto length mismatch. Expected %d or 1, got %d\", max, l)\n\t}\n\n\treturn nil\n}", "func (cfg *Config) Validate() error {\n\tif len(cfg.Scrapers) == 0 {\n\t\treturn errors.New(\"must specify at least one scraper\")\n\t}\n\treturn nil\n}", "func (t *OpenconfigInterfaces_Interfaces_Interface_Subinterfaces_Subinterface_Ipv4_ProxyArp_Config) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigInterfaces_Interfaces_Interface_Subinterfaces_Subinterface_Ipv4_ProxyArp_Config\"], t, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (s *OpenconfigInterfaces_Interfaces_Interface_Subinterfaces_Subinterface_Ipv4_ProxyArp_Config) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigInterfaces_Interfaces_Interface_Subinterfaces_Subinterface_Ipv4_ProxyArp_Config\"], s, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *Config) Validate() error {\n\tif c.Addr == \"\" {\n\t\treturn fmt.Errorf(\"Address of the curator can not be empty\")\n\t}\n\treturn nil\n}", "func ValidateStandaloneKubeProxy(conf *operv1.NetworkSpec) []error {\n\tif ShouldDeployKubeProxy(conf) {\n\t\treturn validateKubeProxy(conf)\n\t}\n\treturn nil\n}", "func (cfg *Config) Validate() error {\n\tif cfg.HTTPServerSettings == nil && cfg.GRPCServerSettings == nil {\n\t\treturn errAtLeastOneProtocol\n\t}\n\n\tif cfg.Source.File != \"\" && cfg.Source.Remote != nil {\n\t\treturn errTooManySources\n\t}\n\n\tif cfg.Source.File == \"\" && cfg.Source.Remote == nil {\n\t\treturn errNoSources\n\t}\n\n\treturn nil\n}", "func (cfg *Config) Validate() error {\n\tif cfg.HTTPServerSettings == nil && cfg.GRPCServerSettings == nil {\n\t\treturn errAtLeastOneProtocol\n\t}\n\n\tif cfg.Source.File != \"\" && cfg.Source.Remote != nil {\n\t\treturn errTooManySources\n\t}\n\n\tif cfg.Source.File == \"\" && cfg.Source.Remote == nil {\n\t\treturn errNoSources\n\t}\n\n\treturn nil\n}", "func (web *webConfig) validateAndSetDefaults() {\n\t// Validate the Address\n\tif len(web.Address) == 0 {\n\t\tweb.Address = DefaultAddress\n\t}\n\t// Validate the Port\n\tif web.Port == 0 {\n\t\tweb.Port = DefaultPort\n\t} else if web.Port < 0 || web.Port > math.MaxUint16 {\n\t\tpanic(fmt.Sprintf(\"invalid port: value should be between %d and %d\", 0, math.MaxUint16))\n\t}\n\t// Validate the ContextRoot\n\tif len(web.ContextRoot) == 0 {\n\t\tweb.ContextRoot = DefaultContextRoot\n\t} else {\n\t\ttrimmedContextRoot := strings.Trim(web.ContextRoot, \"/\")\n\t\tif len(trimmedContextRoot) == 0 {\n\t\t\tweb.ContextRoot = DefaultContextRoot\n\t\t\treturn\n\t\t}\n\t\trootContextURL, err := url.Parse(trimmedContextRoot)\n\t\tif err != nil {\n\t\t\tpanic(\"invalid context root:\" + err.Error())\n\t\t}\n\t\tif rootContextURL.Path != trimmedContextRoot {\n\t\t\tpanic(\"invalid context root: too complex\")\n\t\t}\n\t\tweb.ContextRoot = \"/\" + strings.Trim(rootContextURL.Path, \"/\") + \"/\"\n\t}\n}", "func (c *Config) Validate() error {\n\tif c.Address == \"\" {\n\t\treturn errors.New(\"the address of mockserver is required\")\n\t}\n\treturn nil\n}", "func ValidateNoProxyFormat(noProxy string) error {\n\tdomains := strings.Split(noProxy, \",\")\n\tfor _, s := range domains {\n\t\ts = strings.TrimPrefix(s, \".\")\n\t\tif govalidator.IsIP(s) {\n\t\t\tcontinue\n\t\t}\n\n\t\tif govalidator.IsCIDR(s) {\n\t\t\tcontinue\n\t\t}\n\n\t\tif govalidator.IsDNSName(s) {\n\t\t\tcontinue\n\t\t}\n\t\treturn errors.Errorf(\"NO Proxy format is not valid: '%s'. \"+\n\t\t\t\"NO Proxy is a comma-separated list of destination domain names, domains, IP addresses or other network CIDRs. \"+\n\t\t\t\"A domain can be prefaced with '.' to include all subdomains of that domain.\", noProxy)\n\t}\n\treturn nil\n}", "func DefaultProxyConf(proxyType string) ProxyConf {\n\tconf := NewConfByType(proxyType)\n\tif conf != nil {\n\t\tconf.SetDefaultValues()\n\t}\n\treturn conf\n}", "func (configuration DatabaseConfiguration) AreSeparatedProxiesConfigured() bool {\n\tcounts := configuration.RoleCounts\n\treturn counts.GrvProxies > 0 || counts.CommitProxies > 0\n}", "func (proxyConfig *ProxyConfig) ParseConfig(proxyConfigMap ProxyConfigMap, k8sUtils k8sutils.UtilsInterface) error {\n\tproxyMode := proxyConfigMap.Mode\n\tproxyConfig.Mode = proxyMode\n\tproxyConfig.Port = proxyConfigMap.Port\n\tfmt.Printf(\"ConfigMap: %v\\n\", proxyConfigMap)\n\tif proxyMode == Linked {\n\t\tconfig := proxyConfigMap.LinkConfig\n\t\tif config == nil {\n\t\t\treturn fmt.Errorf(\"proxy mode is specified as Linked but unable to parse config\")\n\t\t}\n\t\tif config.Primary.URL == \"\" {\n\t\t\treturn fmt.Errorf(\"must provide Primary url\")\n\t\t}\n\t\tprimaryURL, err := url.Parse(config.Primary.URL)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tprimaryManagementServer := ManagementServer{\n\t\t\tURL: *primaryURL,\n\t\t\tSkipCertificateValidation: config.Primary.SkipCertificateValidation,\n\t\t\tLimits: config.Primary.Limits,\n\t\t}\n\t\tif config.Primary.CertSecret != \"\" {\n\t\t\tprimaryCertFile, err := k8sUtils.GetCertFileFromSecretName(config.Primary.CertSecret)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tprimaryManagementServer.CertFile = primaryCertFile\n\t\t\tprimaryManagementServer.CertSecret = config.Primary.CertSecret\n\t\t}\n\t\tlinkedProxyConfig := LinkedProxyConfig{\n\t\t\tPrimary: &primaryManagementServer,\n\t\t}\n\t\tif config.Backup.URL != \"\" {\n\t\t\tbackupURL, err := url.Parse(config.Backup.URL)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tbackupManagementServer := ManagementServer{\n\t\t\t\tURL: *backupURL,\n\t\t\t\tSkipCertificateValidation: config.Backup.SkipCertificateValidation,\n\t\t\t\tLimits: config.Backup.Limits,\n\t\t\t}\n\t\t\tif config.Backup.CertSecret != \"\" {\n\t\t\t\tbackupCertFile, err := k8sUtils.GetCertFileFromSecretName(config.Backup.CertSecret)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tbackupManagementServer.CertFile = backupCertFile\n\t\t\t\tbackupManagementServer.CertSecret = config.Backup.CertSecret\n\t\t\t}\n\t\t\tlinkedProxyConfig.Backup = &backupManagementServer\n\t\t}\n\t\tproxyConfig.LinkProxyConfig = &linkedProxyConfig\n\t} else if proxyMode == StandAlone {\n\t\tconfig := proxyConfigMap.StandAloneConfig\n\t\tif config == nil {\n\t\t\treturn fmt.Errorf(\"proxy mode is specified as StandAlone but unable to parse config\")\n\t\t}\n\t\tvar proxy StandAloneProxyConfig\n\t\tproxy.managedArrays = make(map[string]*StorageArray)\n\t\tproxy.managementServers = make(map[url.URL]*ManagementServer)\n\t\tproxy.proxyCredentials = make(map[string]*ProxyUser)\n\t\tstorageArrayIdentifiers := make(map[url.URL][]string)\n\t\tipAddresses := make([]string, 0)\n\t\tfor _, mgmtServer := range config.ManagementServerConfig {\n\t\t\tipAddresses = append(ipAddresses, mgmtServer.URL)\n\t\t}\n\t\tfor _, array := range config.StorageArrayConfig {\n\t\t\tif array.PrimaryURL == \"\" {\n\t\t\t\treturn fmt.Errorf(\"primary URL not configured for array: %s\", array.StorageArrayID)\n\t\t\t}\n\t\t\tif !utils.IsStringInSlice(ipAddresses, array.PrimaryURL) {\n\t\t\t\treturn fmt.Errorf(\"primary URL: %s for array: %s not present among management URL addresses\",\n\t\t\t\t\tarray.PrimaryURL, array)\n\t\t\t}\n\t\t\tif array.BackupURL != \"\" {\n\t\t\t\tif !utils.IsStringInSlice(ipAddresses, array.BackupURL) {\n\t\t\t\t\treturn fmt.Errorf(\"backup URL: %s for array: %s is not in the list of management URL addresses. Ignoring it\",\n\t\t\t\t\t\tarray.BackupURL, array)\n\t\t\t\t}\n\t\t\t}\n\t\t\tprimaryURL, err := url.Parse(array.PrimaryURL)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tbackupURL := &url.URL{}\n\t\t\tif array.BackupURL != \"\" {\n\t\t\t\tbackupURL, err = url.Parse(array.BackupURL)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\tproxy.managedArrays[array.StorageArrayID] = &StorageArray{\n\t\t\t\tStorageArrayIdentifier: array.StorageArrayID,\n\t\t\t\tPrimaryURL: *primaryURL,\n\t\t\t\tSecondaryURL: *backupURL,\n\t\t\t}\n\t\t\t// adding Primary and Backup URl to storageArrayIdentifier, later to be used in management server\n\t\t\tif _, ok := storageArrayIdentifiers[*primaryURL]; ok {\n\t\t\t\tstorageArrayIdentifiers[*primaryURL] = append(storageArrayIdentifiers[*primaryURL], array.StorageArrayID)\n\t\t\t} else {\n\t\t\t\tstorageArrayIdentifiers[*primaryURL] = []string{array.StorageArrayID}\n\t\t\t}\n\t\t\tif _, ok := storageArrayIdentifiers[*backupURL]; ok {\n\t\t\t\tstorageArrayIdentifiers[*backupURL] = append(storageArrayIdentifiers[*backupURL], array.StorageArrayID)\n\t\t\t} else {\n\t\t\t\tstorageArrayIdentifiers[*backupURL] = []string{array.StorageArrayID}\n\t\t\t}\n\n\t\t\t// Reading proxy credentials for the array\n\t\t\tif len(array.ProxyCredentialSecrets) > 0 {\n\t\t\t\tproxy.managedArrays[array.StorageArrayID].ProxyCredentialSecrets = make(map[string]ProxyCredentialSecret)\n\t\t\t\tfor _, secret := range array.ProxyCredentialSecrets {\n\t\t\t\t\tproxyCredentials, err := k8sUtils.GetCredentialsFromSecretName(secret)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tproxyCredentialSecret := &ProxyCredentialSecret{\n\t\t\t\t\t\tCredentials: *proxyCredentials,\n\t\t\t\t\t\tCredentialSecret: secret,\n\t\t\t\t\t}\n\t\t\t\t\tproxy.managedArrays[array.StorageArrayID].ProxyCredentialSecrets[secret] = *proxyCredentialSecret\n\t\t\t\t\tproxy.updateProxyCredentials(*proxyCredentials, array.StorageArrayID)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor _, managementServer := range config.ManagementServerConfig {\n\t\t\tvar arrayCredentials common.Credentials\n\t\t\tif managementServer.ArrayCredentialSecret != \"\" {\n\t\t\t\tcredentials, err := k8sUtils.GetCredentialsFromSecretName(managementServer.ArrayCredentialSecret)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tarrayCredentials = *credentials\n\t\t\t}\n\t\t\tmgmtURL, err := url.Parse(managementServer.URL)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tvar certFile string\n\t\t\tif managementServer.CertSecret != \"\" {\n\t\t\t\tcertFile, err = k8sUtils.GetCertFileFromSecretName(managementServer.CertSecret)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\tproxy.managementServers[*mgmtURL] = &ManagementServer{\n\t\t\t\tURL: *mgmtURL,\n\t\t\t\tStorageArrayIdentifiers: storageArrayIdentifiers[*mgmtURL],\n\t\t\t\tSkipCertificateValidation: managementServer.SkipCertificateValidation,\n\t\t\t\tCertFile: certFile,\n\t\t\t\tCertSecret: managementServer.CertSecret,\n\t\t\t\tCredentials: arrayCredentials,\n\t\t\t\tCredentialSecret: managementServer.ArrayCredentialSecret,\n\t\t\t\tLimits: managementServer.Limits,\n\t\t\t}\n\t\t}\n\t\tproxyConfig.StandAloneProxyConfig = &proxy\n\t} else {\n\t\treturn fmt.Errorf(\"unknown proxy mode: %s specified\", string(proxyMode))\n\t}\n\tif proxyConfig.LinkProxyConfig == nil && proxyConfig.StandAloneProxyConfig == nil {\n\t\treturn fmt.Errorf(\"no configuration provided for the proxy\")\n\t}\n\treturn nil\n}", "func VerifyClientProxy(source []byte) (err error) {\n\t_, _, err = frpconfig.LoadAllProxyConfsFromIni(\"\", source, nil)\n\treturn\n}", "func (c *ProxyConfig) SetDefaults() {\n\tif c.ProxyName == \"\" {\n\t\tc.ProxyName = \"h2-proxy\"\n\t}\n\n\tif c.ProxyAddres == \"\" {\n\t\tc.ProxyAddres = \"0.0.0.0:50060\"\n\t}\n\n\tif c.IdleTimeout == 0 {\n\t\t// value in minutes\n\t\tc.IdleTimeout = 300\n\t}\n\n\tif c.DNSConfig == nil {\n\t\tc.DNSConfig = &DNSConfig{\n\t\t\t// value in seconds\n\t\t\tRefreshRate: 60,\n\t\t\tNeedRefresh: true,\n\t\t\tBalancerAlg: \"none\",\n\t\t}\n\t}\n}", "func (c *Config) Validate() error {\n\tvar err error\n\tif c.Endpoint == \"\" {\n\t\terr = multierr.Append(err, errors.New(\"no manager endpoint was specified\"))\n\t\treturn err\n\t}\n\n\tres, err := url.Parse(c.Endpoint)\n\tif err != nil {\n\t\terr = multierr.Append(err, fmt.Errorf(\"unable to parse url %s: %w\", c.Endpoint, err))\n\t\treturn err\n\t}\n\n\tif res.Scheme != \"http\" && res.Scheme != \"https\" {\n\t\terr = multierr.Append(err, errors.New(\"url scheme must be http or https\"))\n\t}\n\n\tif c.Username == \"\" {\n\t\terr = multierr.Append(err, errors.New(\"username not provided and is required\"))\n\t}\n\n\tif c.Password == \"\" {\n\t\terr = multierr.Append(err, errors.New(\"password not provided and is required\"))\n\t}\n\treturn err\n}", "func (scc *ServiceCustomConfig) Validate() error {\n\n\tif len(scc.MyserviceInfo.Host) == 0 {\n\t\treturn errors.New(\"host setting for service not configured\")\n\t}\n\tif scc.MyserviceInfo.Port == 0 {\n\t\treturn errors.New(\"port setting for service not configured\")\n\t}\n\n\tif len(scc.CommandClientInfo.Host) == 0 {\n\t\treturn errors.New(\"host setting for Core Command client not configured\")\n\t}\n\tif scc.CommandClientInfo.Port == 0 {\n\t\treturn errors.New(\"port setting for Core Command client not configured\")\n\t}\n\n\tif len(scc.NotificationClientInfo.Host) == 0 {\n\t\treturn errors.New(\"host setting for Core Command client not configured\")\n\t}\n\tif scc.NotificationClientInfo.Port == 0 {\n\t\treturn errors.New(\"port setting for Core Command client not configured\")\n\t}\n\n\tif len(scc.SchedulerClientInfo.Host) == 0 {\n\t\treturn errors.New(\"host setting for Scheduler client not configured\")\n\t}\n\tif scc.SchedulerClientInfo.Port == 0 {\n\t\treturn errors.New(\"port setting for Scheduler client not configured\")\n\t}\n\n\tif len(scc.RuleEngineClientInfo.Host) == 0 {\n\t\treturn errors.New(\"host setting for Rule Engine client not configured\")\n\t}\n\tif scc.RuleEngineClientInfo.Port == 0 {\n\t\treturn errors.New(\"port setting for Rule Engine client not configured\")\n\t}\n\n\treturn nil\n}", "func (c *ServerConfig) checkAndSetDefaults() error {\n\tif c.Log == nil {\n\t\tc.Log = logrus.New()\n\t}\n\tc.Log = c.Log.WithField(\n\t\ttrace.Component,\n\t\tteleport.Component(teleport.ComponentProxy, \"peer\"),\n\t)\n\n\tif c.AccessCache == nil {\n\t\treturn trace.BadParameter(\"missing access cache\")\n\t}\n\n\tif c.Listener == nil {\n\t\treturn trace.BadParameter(\"missing listener\")\n\t}\n\n\tif c.ClusterDialer == nil {\n\t\treturn trace.BadParameter(\"missing cluster dialer server\")\n\t}\n\n\tif c.ClusterName == \"\" {\n\t\treturn trace.BadParameter(\"missing cluster name\")\n\t}\n\n\tif c.TLSConfig == nil {\n\t\treturn trace.BadParameter(\"missing tls config\")\n\t}\n\n\tif len(c.TLSConfig.Certificates) == 0 {\n\t\treturn trace.BadParameter(\"missing tls certificate\")\n\t}\n\n\tc.TLSConfig = c.TLSConfig.Clone()\n\tc.TLSConfig.ClientAuth = tls.RequireAndVerifyClientCert\n\n\tif c.getConfigForClient == nil {\n\t\tc.getConfigForClient = getConfigForClient(c.TLSConfig, c.AccessCache, c.Log, c.ClusterName)\n\t}\n\tc.TLSConfig.GetConfigForClient = c.getConfigForClient\n\n\tif c.service == nil {\n\t\tc.service = &proxyService{\n\t\t\tc.ClusterDialer,\n\t\t\tc.Log,\n\t\t}\n\t}\n\n\treturn nil\n}", "func validateConfig() (*config.Configuration, error) {\n\tconfig := &config.Configuration{}\n\tif *redisUseSentinel {\n\t\tif *redisAddr != \"\" {\n\t\t\treturn config, fmt.Errorf(\"Cannot specify Redis address when redis-use-sentinel is true\")\n\t\t}\n\t\tif len(*redisSentinelAddrs) == 0 || *redisSentinelMaster == \"\" {\n\t\t\treturn config, fmt.Errorf(\"Both redis-sentinel-addrs and redis-sentinel-master are required when redis-use-sentinel is true\")\n\t\t}\n\t\tfmt.Printf(\"Using Redis Sentinel config: %s - Master: %s\\n\", strings.Join(*redisSentinelAddrs, \",\"), *redisSentinelMaster)\n\t} else {\n\t\tif *redisAddr == \"\" {\n\t\t\treturn config, fmt.Errorf(\"Redis address is required\")\n\t\t}\n\t\tif len(*redisSentinelAddrs) > 0 || *redisSentinelMaster != \"\" {\n\t\t\treturn config, fmt.Errorf(\"Cannot specify redis-sentinel-addrs orredis-sentinel-master when redis-use-sentinel is false\")\n\t\t}\n\t\tfmt.Printf(\"Using Redis config: %s\\n\", *redisAddr)\n\t}\n\tconfig.UseSentinel = *redisUseSentinel\n\tconfig.SentinelAddrs = *redisSentinelAddrs\n\tconfig.SentinelMaster = *redisSentinelMaster\n\tconfig.RedisAddr = *redisAddr\n\tconfig.BindAddr = *bindAddr\n\n\treturn config, nil\n}", "func (c *Config) CheckAndSetDefaults() error {\n\tif c.Service == \"\" {\n\t\treturn trace.BadParameter(\"service name cannot be empty\")\n\t}\n\n\tif c.Client == nil && c.ExporterURL == \"\" {\n\t\treturn trace.BadParameter(\"exporter URL cannot be empty\")\n\t}\n\n\tif c.DialTimeout <= 0 {\n\t\tc.DialTimeout = DefaultExporterDialTimeout\n\t}\n\n\tif c.Logger == nil {\n\t\tc.Logger = logrus.WithField(trace.Component, teleport.ComponentTracing)\n\t}\n\n\tif c.Client != nil {\n\t\treturn nil\n\t}\n\n\t// first check if a network address is specified, if it was, default\n\t// to using grpc. If provided a URL, ensure that it is valid\n\th, _, err := net.SplitHostPort(c.ExporterURL)\n\tif err != nil || h == \"file\" {\n\t\texporterURL, err := url.Parse(c.ExporterURL)\n\t\tif err != nil {\n\t\t\treturn trace.BadParameter(\"failed to parse exporter URL: %v\", err)\n\t\t}\n\t\tc.exporterURL = exporterURL\n\t\treturn nil\n\t}\n\n\tc.exporterURL = &url.URL{\n\t\tScheme: \"grpc\",\n\t\tHost: c.ExporterURL,\n\t}\n\treturn nil\n}", "func (cfg config) Validate() {\n\tif v, exists := cfg[\"tls_min_version\"]; exists {\n\t\tvar t tlsMinVersionOption\n\t\terr := t.Set(fmt.Sprintf(\"%v\", v))\n\t\tif err == nil {\n\t\t\tnewVal := fmt.Sprintf(\"%v\", t.Get())\n\t\t\tif newVal != \"0\" {\n\t\t\t\tcfg[\"tls_min_version\"] = newVal\n\t\t\t} else {\n\t\t\t\tdelete(cfg, \"tls_min_version\")\n\t\t\t}\n\t\t} else {\n\t\t\tlogFatal(\"failed parsing tls_min_version %+v\", v)\n\t\t}\n\t}\n\tif v, exists := cfg[\"log_level\"]; exists {\n\t\tvar t lg.LogLevel\n\t\terr := t.Set(fmt.Sprintf(\"%v\", v))\n\t\tif err == nil {\n\t\t\tcfg[\"log_level\"] = t\n\t\t} else {\n\t\t\tlogFatal(\"failed parsing log_level %+v\", v)\n\t\t}\n\t}\n}", "func (s *OpenconfigInterfaces_Interfaces_Interface_Tunnel_Config) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigInterfaces_Interfaces_Interface_Tunnel_Config\"], s, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func ValidateConfiguration(configuration *schema.Configuration, validator *schema.StructValidator) {\n\tif configuration.Host == \"\" {\n\t\tconfiguration.Host = \"0.0.0.0\"\n\t}\n\n\tif configuration.Port == 0 {\n\t\tconfiguration.Port = defaultPort\n\t}\n\n\tif configuration.TLSKey != \"\" && configuration.TLSCert == \"\" {\n\t\tvalidator.Push(fmt.Errorf(\"No TLS certificate provided, please check the \\\"tls_cert\\\" which has been configured\"))\n\t} else if configuration.TLSKey == \"\" && configuration.TLSCert != \"\" {\n\t\tvalidator.Push(fmt.Errorf(\"No TLS key provided, please check the \\\"tls_key\\\" which has been configured\"))\n\t}\n\n\tif configuration.CertificatesDirectory != \"\" {\n\t\tinfo, err := os.Stat(configuration.CertificatesDirectory)\n\t\tif err != nil {\n\t\t\tvalidator.Push(fmt.Errorf(\"Error checking certificate directory: %v\", err))\n\t\t} else if !info.IsDir() {\n\t\t\tvalidator.Push(fmt.Errorf(\"The path %s specified for certificate_directory is not a directory\", configuration.CertificatesDirectory))\n\t\t}\n\t}\n\n\tif configuration.JWTSecret == \"\" {\n\t\tvalidator.Push(fmt.Errorf(\"Provide a JWT secret using \\\"jwt_secret\\\" key\"))\n\t}\n\n\tif configuration.DefaultRedirectionURL != \"\" {\n\t\t_, err := url.ParseRequestURI(configuration.DefaultRedirectionURL)\n\t\tif err != nil {\n\t\t\tvalidator.Push(fmt.Errorf(\"Unable to parse default redirection url\"))\n\t\t}\n\t}\n\n\tValidateTheme(configuration, validator)\n\n\tif configuration.TOTP == nil {\n\t\tconfiguration.TOTP = &schema.DefaultTOTPConfiguration\n\t}\n\n\tValidateLogging(configuration, validator)\n\n\tValidateTOTP(configuration.TOTP, validator)\n\n\tValidateAuthenticationBackend(&configuration.AuthenticationBackend, validator)\n\n\tValidateAccessControl(&configuration.AccessControl, validator)\n\n\tValidateRules(configuration.AccessControl, validator)\n\n\tValidateSession(&configuration.Session, validator)\n\n\tif configuration.Regulation == nil {\n\t\tconfiguration.Regulation = &schema.DefaultRegulationConfiguration\n\t}\n\n\tValidateRegulation(configuration.Regulation, validator)\n\n\tValidateServer(&configuration.Server, validator)\n\n\tValidateStorage(configuration.Storage, validator)\n\n\tif configuration.Notifier == nil {\n\t\tvalidator.Push(fmt.Errorf(\"A notifier configuration must be provided\"))\n\t} else {\n\t\tValidateNotifier(configuration.Notifier, validator)\n\t}\n\n\tValidateIdentityProviders(&configuration.IdentityProviders, validator)\n}", "func ValidateDefault(args []string) error {\n\n\tif len(args) == 0 {\n\t\treturn errors.New(missingArguments)\n\t}\n\n\tif err := validateURL(args[0]); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (rules *ClientConfigLoadingRules) IsDefaultConfig(config *restclient.Config) bool {\n\tif rules.DefaultClientConfig == nil {\n\t\treturn false\n\t}\n\tdefaultConfig, err := rules.DefaultClientConfig.ClientConfig()\n\tif err != nil {\n\t\treturn false\n\t}\n\treturn reflect.DeepEqual(config, defaultConfig)\n}", "func (cfg *Config) Validate() error {\n\tif !cfg.LogDataEnabled && !cfg.ProfilingDataEnabled {\n\t\treturn errors.New(`either \"log_data_enabled\" or \"profiling_data_enabled\" has to be true`)\n\t}\n\tif cfg.HTTPClientSettings.Endpoint == \"\" {\n\t\treturn errors.New(`requires a non-empty \"endpoint\"`)\n\t}\n\t_, err := cfg.getURL()\n\tif err != nil {\n\t\treturn fmt.Errorf(`invalid \"endpoint\": %w`, err)\n\t}\n\tif cfg.Token == \"\" {\n\t\treturn errors.New(`requires a non-empty \"token\"`)\n\t}\n\n\tif cfg.MaxContentLengthLogs > maxContentLengthLogsLimit {\n\t\treturn fmt.Errorf(`requires \"max_content_length_logs\" <= %d`, maxContentLengthLogsLimit)\n\t}\n\n\tif cfg.MaxContentLengthMetrics > maxContentLengthMetricsLimit {\n\t\treturn fmt.Errorf(`requires \"max_content_length_metrics\" <= %d`, maxContentLengthMetricsLimit)\n\t}\n\n\tif cfg.MaxContentLengthTraces > maxContentLengthTracesLimit {\n\t\treturn fmt.Errorf(`requires \"max_content_length_traces\" <= %d`, maxContentLengthTracesLimit)\n\t}\n\n\tif cfg.MaxEventSize > maxMaxEventSize {\n\t\treturn fmt.Errorf(`requires \"max_event_size\" <= %d`, maxMaxEventSize)\n\t}\n\n\tif err := cfg.QueueSettings.Validate(); err != nil {\n\t\treturn fmt.Errorf(\"sending_queue settings has invalid configuration: %w\", err)\n\t}\n\treturn nil\n}", "func ShouldDeployKubeProxy(conf *operv1.NetworkSpec) bool {\n\tswitch conf.DefaultNetwork.Type {\n\tcase operv1.NetworkTypeOpenShiftSDN:\n\t\treturn false\n\tcase operv1.NetworkTypeOVNKubernetes:\n\t\treturn false\n\tcase operv1.NetworkTypeKuryr:\n\t\treturn false\n\tdefault:\n\t\treturn true\n\t}\n}", "func (c *Config) validate() error {\n\tif c.iface == \"\" {\n\t\treturn errors.New(\"the iface must be set\")\n\t}\n\tif c.protocal != \"\" && c.protocal != \"tcp\" && c.protocal != \"udp\" {\n\t\treturn errors.New(\"the protocl must be set to tcp or udp or both\")\n\t}\n\treturn nil\n}", "func (d *DialReq) CheckAndSetDefaults() error {\n\tif d.ConnType == \"\" {\n\t\td.ConnType = types.NodeTunnel\n\t}\n\n\tif d.Address == \"\" && d.ServerID == \"\" {\n\t\treturn trace.BadParameter(\"serverID or address required\")\n\t}\n\treturn nil\n}", "func checkTunnelConfig(config TunnelConfig) TunnelConfig {\n\tif config.ResendInterval <= 0 {\n\t\tconfig.ResendInterval = DefaultTunnelConfig.ResendInterval\n\t}\n\n\tif config.HeartbeatInterval <= 0 {\n\t\tconfig.HeartbeatInterval = DefaultTunnelConfig.HeartbeatInterval\n\t}\n\n\tif config.ResponseTimeout <= 0 {\n\t\tconfig.ResponseTimeout = DefaultTunnelConfig.ResponseTimeout\n\t}\n\n\treturn config\n}", "func (o MustGatherSpecOutput) ProxyConfig() MustGatherSpecProxyConfigPtrOutput {\n\treturn o.ApplyT(func(v MustGatherSpec) *MustGatherSpecProxyConfig { return v.ProxyConfig }).(MustGatherSpecProxyConfigPtrOutput)\n}", "func validate(cfg Settings) error {\n\tif len(cfg.Selectors) == 0 {\n\t\treturn errors.New(\"no selectors configured\")\n\t}\n\tif cfg.ServiceTLS {\n\t\treturn errors.New(\"TLS mode not yet implemented\")\n\t}\n\n\treturn nil\n}", "func (c *Config) Validate() error {\n\tvar allErrs error\n\n\tif c.Endpoint == \"\" {\n\t\treturn multierr.Append(allErrs, errEmptyEndpoint)\n\t}\n\n\thost, portStr, err := net.SplitHostPort(c.Endpoint)\n\tif err != nil {\n\t\treturn multierr.Append(allErrs, fmt.Errorf(\"%w: %s\", errBadEndpoint, err.Error()))\n\t}\n\n\tif host == \"\" {\n\t\tallErrs = multierr.Append(allErrs, errBadEndpoint)\n\t}\n\n\tport, err := strconv.ParseInt(portStr, 10, 32)\n\tif err != nil {\n\t\tallErrs = multierr.Append(allErrs, fmt.Errorf(\"%w: %s\", errBadPort, err.Error()))\n\t}\n\n\tif port < 0 || port > 65535 {\n\t\tallErrs = multierr.Append(allErrs, fmt.Errorf(\"%w: %d\", errBadPort, port))\n\t}\n\n\tif c.Username != \"\" && c.Password == \"\" {\n\t\tallErrs = multierr.Append(allErrs, errEmptyPassword)\n\t}\n\n\tif c.Password != \"\" && c.Username == \"\" {\n\t\tallErrs = multierr.Append(allErrs, errEmptyUsername)\n\t}\n\tif c.Timeout.Milliseconds() < 0 {\n\t\tallErrs = multierr.Append(allErrs, fmt.Errorf(\"%w: must be positive\", errNegativeTimeout))\n\t}\n\n\tif c.TLS != nil {\n\t\t_, err := c.TLS.LoadTLSConfig()\n\t\tif err != nil {\n\t\t\tallErrs = multierr.Append(allErrs, fmt.Errorf(\"%w: %s\", errFailedTLSLoad, err.Error()))\n\t\t}\n\t}\n\n\tif c.TLS != nil && c.TLSName == \"\" {\n\t\tallErrs = multierr.Append(allErrs, fmt.Errorf(\"%w: when using TLS\", errEmptyEndpointTLSName))\n\t}\n\n\treturn allErrs\n}", "func (c *TLSServerConfig) CheckAndSetDefaults() error {\n\tif err := c.APIConfig.CheckAndSetDefaults(); err != nil {\n\t\treturn trace.Wrap(err)\n\t}\n\tif c.Listener == nil {\n\t\treturn trace.BadParameter(\"missing parameter Listener\")\n\t}\n\tif c.TLS == nil {\n\t\treturn trace.BadParameter(\"missing parameter TLS\")\n\t}\n\tc.TLS.ClientAuth = tls.VerifyClientCertIfGiven\n\tif c.TLS.ClientCAs == nil {\n\t\treturn trace.BadParameter(\"missing parameter TLS.ClientCAs\")\n\t}\n\tif c.TLS.RootCAs == nil {\n\t\treturn trace.BadParameter(\"missing parameter TLS.RootCAs\")\n\t}\n\tif len(c.TLS.Certificates) == 0 {\n\t\treturn trace.BadParameter(\"missing parameter TLS.Certificates\")\n\t}\n\tif c.AccessPoint == nil {\n\t\treturn trace.BadParameter(\"missing parameter AccessPoint\")\n\t}\n\tif c.Component == \"\" {\n\t\tc.Component = teleport.ComponentAuth\n\t}\n\tif c.Metrics == nil {\n\t\tc.Metrics = &Metrics{}\n\t}\n\treturn nil\n}", "func getProxyURL() (bool, *url.URL) {\n\t// Grab the list of HTTP proxies from the configuration\n\tlog.Debug(\"Attempting to use one of the proxies defined in the configuration file\")\n\thttpProxyStringMap := viper.GetStringMap(\"HTTPProxies\")\n\n\t// This will be set to the URL to use or remain nil\n\tvar proxyURL *url.URL\n\n\t// Try each proxy and use it if it's available\n\tfor proxyAlias, httpProxy := range httpProxyStringMap {\n\t\tproxyURLString := httpProxy.(map[string]interface{})[\"proxyurl\"]\n\t\tif proxyURLString == nil {\n\t\t\tlog.Warnf(\"The proxy entry %s needs a ProxyURL in the configuration file: %s\", proxyAlias, httpProxy)\n\t\t\tcontinue\n\t\t}\n\n\t\tlog.Debugf(\"Checking access to proxy: %s\", proxyURLString)\n\n\t\tvar parseError error\n\t\tproxyURL, parseError = url.Parse(proxyURLString.(string))\n\t\tif parseError != nil {\n\t\t\tlog.Debugf(\"Skipping proxy URL that couldn't be parsed: %s\", parseError)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Get the proxy hostname\n\t\tproxyHost := proxyURL.Hostname()\n\n\t\t// Try looking up the hostname IP\n\t\tlog.Debugf(\"Looking up IP address for: %s\", proxyHost)\n\t\t_, lookupError := net.LookupHost(proxyHost)\n\t\tif lookupError != nil {\n\t\t\tlog.Debugf(\"Skipping proxy because the IP lookup failed: %s\", proxyHost)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Get the proxy hostname\n\t\tproxyPort := proxyURL.Port()\n\n\t\t// Try connecting to the proxy port\n\t\tlog.Debugf(\"Attempting to connect to %s on port %s\", proxyHost, proxyPort)\n\t\tconnection, dialError := net.Dial(\"tcp\", proxyHost+\":\"+proxyPort)\n\t\tif dialError != nil {\n\t\t\tlog.Debugf(\"Unable to connect to proxy %s on port %s\", proxyHost, proxyPort)\n\t\t\tcontinue\n\t\t}\n\t\terr := connection.Close()\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Unable to close connection to proxy host: %s\", err)\n\t\t}\n\n\t\t// Set the no proxy based on this config... this may be futile, need more research\n\t\tnoProxy := httpProxy.(map[string]interface{})[\"noproxy\"]\n\t\tif noProxy != nil {\n\t\t\tlog.Debugf(\"Setting NO_PROXY to %s\", noProxy)\n\t\t\terr := os.Setenv(\"NO_PROXY\", noProxy.(string))\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatalf(\"Unable to set NO_PROXY environment variable: %s\", err)\n\t\t\t}\n\t\t}\n\n\t\t// If we made it this far, the proxy is usable\n\t\tlog.Infof(\"Found a working proxy from the configuration file: %s on port %s\", proxyHost, proxyPort)\n\t\treturn true, proxyURL\n\t}\n\n\treturn false, proxyURL\n}", "func (s *OpenconfigInterfaces_Interfaces_Interface_Tunnel_Ipv4_Config) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigInterfaces_Interfaces_Interface_Tunnel_Ipv4_Config\"], s, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *Config) Validate() error {\n\tif c.ServerConf.RestAPIPort < 0 || c.ServerConf.RestAPIPort > 65535 {\n\t\treturn errors.New(\"invalid restful port: \" + strconv.Itoa(c.ServerConf.RestAPIPort))\n\t}\n\n\t// remove \"/\"\n\tc.ZeekConf.LogDir = processDirName(c.ZeekConf.LogDir)\n\tc.ZeekConf.PcapDir = processDirName(c.ZeekConf.PcapDir)\n\tc.ZeekConf.ExtractedFileDir = processDirName(c.ZeekConf.ExtractedFileDir)\n\tc.SeaweedfsConf.ExtractedFileDir = processDirName(c.SeaweedfsConf.ExtractedFileDir)\n\n\tif c.SeaweedfsConf.Retries < 1 {\n\t\treturn errors.New(\"seaweedfs post retry times < 1\")\n\t}\n\treturn nil\n}", "func (o *YurttunnelServerOptions) validate() error {\n\tif len(o.bindAddr) == 0 {\n\t\treturn fmt.Errorf(\"%s's bind address can't be empty\",\n\t\t\tprojectinfo.GetServerName())\n\t}\n\treturn nil\n}", "func checkConf(cfg *ClientConf) error {\n if len(cfg.BaseURI) == 0 {\n return errors.New(\"BaseURI is not defined\")\n }\n // if the protocol is not specified, the add http as default\n // this is to avoid the server producing empty responses if no protocol is specified in the URI\n if !strings.HasPrefix(strings.ToLower(cfg.BaseURI), \"http\") {\n log.Warn().Msgf(\"no protocol defined for Onix URI '%s', 'http://' will be added to it\", cfg.BaseURI)\n cfg.BaseURI = fmt.Sprintf(\"http://%s\", cfg.BaseURI)\n }\n\n if len(cfg.Username) == 0 {\n return errors.New(\"username is not defined\")\n }\n if len(cfg.Password) == 0 {\n return errors.New(\"password is not defined\")\n }\n\n // if timeout is zero, it never timeout so is not good\n if cfg.Timeout == 0*time.Second {\n // set a default timeout of 30 secs\n cfg.Timeout = 30 * time.Second\n }\n return nil\n}", "func (o *TunnelServerOptions) validate() error {\n\tif len(o.bindAddr) == 0 {\n\t\treturn fmt.Errorf(\"%s's bind address can't be empty\",\n\t\t\tversion.GetServerName())\n\t}\n\treturn nil\n}", "func (c *Config) Validate() error {\n\tswitch {\n\tcase c.SkipValidation:\n\t\treturn nil\n\tcase c.Address == \"\":\n\t\treturn errors.New(\"address cannot be empty\")\n\tcase len(c.DNSNames) == 0:\n\t\treturn errors.New(\"dnsNames cannot be empty\")\n\tcase c.AuthorityConfig == nil:\n\t\treturn errors.New(\"authority cannot be nil\")\n\t}\n\n\t// Options holds the RA/CAS configuration.\n\tra := c.AuthorityConfig.Options\n\t// The default RA/CAS requires root, crt and key.\n\tif ra.Is(cas.SoftCAS) {\n\t\tswitch {\n\t\tcase c.Root.HasEmpties():\n\t\t\treturn errors.New(\"root cannot be empty\")\n\t\tcase c.IntermediateCert == \"\":\n\t\t\treturn errors.New(\"crt cannot be empty\")\n\t\tcase c.IntermediateKey == \"\":\n\t\t\treturn errors.New(\"key cannot be empty\")\n\t\t}\n\t}\n\n\t// Validate address (a port is required)\n\tif _, _, err := net.SplitHostPort(c.Address); err != nil {\n\t\treturn errors.Errorf(\"invalid address %s\", c.Address)\n\t}\n\n\tif c.TLS == nil {\n\t\tc.TLS = &DefaultTLSOptions\n\t} else {\n\t\tif len(c.TLS.CipherSuites) == 0 {\n\t\t\tc.TLS.CipherSuites = DefaultTLSOptions.CipherSuites\n\t\t}\n\t\tif c.TLS.MaxVersion == 0 {\n\t\t\tc.TLS.MaxVersion = DefaultTLSOptions.MaxVersion\n\t\t}\n\t\tif c.TLS.MinVersion == 0 {\n\t\t\tc.TLS.MinVersion = DefaultTLSOptions.MinVersion\n\t\t}\n\t\tif c.TLS.MinVersion > c.TLS.MaxVersion {\n\t\t\treturn errors.New(\"tls minVersion cannot exceed tls maxVersion\")\n\t\t}\n\t\tc.TLS.Renegotiation = c.TLS.Renegotiation || DefaultTLSOptions.Renegotiation\n\t}\n\n\t// Validate KMS options, nil is ok.\n\tif err := c.KMS.Validate(); err != nil {\n\t\treturn err\n\t}\n\n\t// Validate RA/CAS options, nil is ok.\n\tif err := ra.Validate(); err != nil {\n\t\treturn err\n\t}\n\n\t// Validate ssh: nil is ok\n\tif err := c.SSH.Validate(); err != nil {\n\t\treturn err\n\t}\n\n\t// Validate templates: nil is ok\n\tif err := c.Templates.Validate(); err != nil {\n\t\treturn err\n\t}\n\n\t// Validate crl config: nil is ok\n\tif err := c.CRL.Validate(); err != nil {\n\t\treturn err\n\t}\n\n\treturn c.AuthorityConfig.Validate(c.GetAudiences())\n}", "func (config Configuration) Valid() error {\n\tif config.Issuer == \"\" {\n\t\treturn errors.New(\"authproxy/oidc: issuer is empty\")\n\t}\n\tif config.AuthorizationEndpoint == \"\" {\n\t\treturn errors.New(\"authproxy/oidc: authorization_endpoint is empty\")\n\t}\n\tif config.JWKSURI == \"\" {\n\t\treturn errors.New(\"authproxy/oidc: jwks_uri is empty\")\n\t}\n\tif len(config.ResponseTypesSupported) == 0 {\n\t\treturn errors.New(\"authproxy/oidc: response_types_supported is empty\")\n\t}\n\tif len(config.SubjectTypesSupported) == 0 {\n\t\treturn errors.New(\"authproxy/oidc: subject_types_supported is empty\")\n\t}\n\tif len(config.IDTokenSigningAlgValuesSupported) == 0 {\n\t\treturn errors.New(\"authproxy/oidc: id_token_signing_alg_values_supported is empty\")\n\t}\n\n\treturn nil\n}", "func (b *BaseOptions) Check() {\n\n\t// Check port first\n\tif b.port > 65535 {\n\t\tlog.Fatal(\"Invalid port: \", b.port)\n\t}\n\n\t// Update settings from config and config from parameters\n\tb.updateFromConfig()\n\tif b.domain == \"\" {\n\t\tlog.Fatal(\"-domain is mandatory\")\n\t}\n\n}", "func (c *WebListenerConfig) CheckAndSetDefaults() error {\n\tif c.Listener == nil {\n\t\treturn trace.BadParameter(\"missing parameter Listener\")\n\t}\n\tif c.ReadDeadline == 0 {\n\t\tc.ReadDeadline = defaults.HandshakeReadDeadline\n\t}\n\tif c.Clock == nil {\n\t\tc.Clock = clockwork.NewRealClock()\n\t}\n\treturn nil\n}", "func (m *LocalReplyConfig) Validate() error {\n\treturn m.validate(false)\n}", "func validateConfig() {\n\tif viper.Get(\"project\") == \"\" {\n\t\tlog.Fatal(\"Error: --project is required\")\n\t}\n\tif viper.Get(\"region\") == \"\" {\n\t\tlog.Fatal(\"Error: --region is required, e.g. us-west1\")\n\t}\n}", "func (cfg *Config) Validate() error {\n\tchecks := []struct {\n\t\tbad bool\n\t\terrMsg string\n\t}{\n\t\t{cfg.AuthorizeURL == \"\", \"no authorizeURL specified\"},\n\t\t{cfg.TokenURL == \"\", \"no tokenURL specified\"},\n\t\t{cfg.ClientID == \"\", \"no clientID specified\"},\n\t\t{cfg.ClientSecret == \"\" && !cfg.AllowEmptyClientSecret, \"no clientSecret specified\"},\n\t\t{cfg.RedirectURL == \"\", \"no redirectURL specified\"},\n\t\t{cfg.SessionSecurityKey == \"\", \"no SessionSecurityKey specified\"},\n\t\t{cfg.APIServerURL == \"\", \"no apiServerURL specified\"},\n\t}\n\n\tfor _, check := range checks {\n\t\tif check.bad {\n\t\t\treturn fmt.Errorf(\"invalid config: %s\", check.errMsg)\n\t\t}\n\t}\n\treturn nil\n}", "func (cfg *Config) Validate() error {\n\tif len(cfg.Key) == 0 {\n\t\treturn trace.BadParameter(`etcd: missing \"prefix\" parameter`)\n\t}\n\t// Make sure the prefix starts with a '/'.\n\tif cfg.Key[0] != '/' {\n\t\tcfg.Key = \"/\" + cfg.Key\n\t}\n\tif len(cfg.Nodes) == 0 {\n\t\treturn trace.BadParameter(`etcd: missing \"peers\" parameter`)\n\t}\n\tif !cfg.Insecure {\n\t\tif cfg.TLSCAFile == \"\" {\n\t\t\treturn trace.BadParameter(`etcd: missing \"tls_ca_file\" parameter`)\n\t\t}\n\t}\n\tif cfg.BufferSize == 0 {\n\t\tcfg.BufferSize = backend.DefaultBufferCapacity\n\t}\n\tif cfg.DialTimeout == 0 {\n\t\tcfg.DialTimeout = apidefaults.DefaultIOTimeout\n\t}\n\tif cfg.PasswordFile != \"\" {\n\t\tout, err := os.ReadFile(cfg.PasswordFile)\n\t\tif err != nil {\n\t\t\treturn trace.ConvertSystemError(err)\n\t\t}\n\t\t// trim newlines as passwords in files tend to have newlines\n\t\tcfg.Password = strings.TrimSpace(string(out))\n\t}\n\n\tif cfg.ClientPoolSize < 1 {\n\t\tcfg.ClientPoolSize = defaultClientPoolSize\n\t}\n\treturn nil\n}", "func (s *OpenconfigInterfaces_Interfaces_Interface_Tunnel_Ipv4_ProxyArp) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigInterfaces_Interfaces_Interface_Tunnel_Ipv4_ProxyArp\"], s, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (m *GatewayConfiguration) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateAPIs(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validatePolicies(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateScopes(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateServices(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (c *Config) Validate() (err error) {\n\t// Handle queue size\n\tif c.QueueSize <= 0 {\n\t\tc.QueueSize = defaultQueueSize\n\t}\n\n\t// Handle the number of workers\n\tif c.Workers <= 0 {\n\t\tc.Workers = runtime.NumCPU()\n\t}\n\n\t// Handle the addr\n\tif c.Addr == \"\" {\n\t\tc.Addr = defaultAddr\n\t}\n\n\t// Handle the metrics addr\n\tif c.MetricsAddr == \"\" {\n\t\tc.MetricsAddr = defaultMetricsAddr\n\t}\n\n\t// Handle the log level\n\tif c.LogLevel == \"\" {\n\t\tc.LogLevel = \"info\"\n\t} else {\n\t\tc.LogLevel = strings.ToLower(c.LogLevel)\n\t\tif _, ok := logLevels[c.LogLevel]; !ok {\n\t\t\treturn Errorf(ErrInvalidConfig, \"%q is an invalid log level, use trace, debug, info, caution, status, warn, or silent\", c.LogLevel)\n\t\t}\n\t}\n\tc.setLogLevel()\n\n\t// Handle the caution threshold\n\tif c.CautionThreshold == 0 {\n\t\tc.CautionThreshold = out.DefaultCautionThreshold\n\t}\n\tc.setCautionThreshold()\n\n\treturn nil\n}", "func (c Config) Validate() error {\n\tvar errs []string\n\toops := func(err string) {\n\t\terrs = append(errs, err)\n\t}\n\n\tif c.BtcAddresses == \"\" {\n\t\toops(\"btc_addresses missing\")\n\t}\n\tif _, err := os.Stat(c.BtcAddresses); os.IsNotExist(err) {\n\t\toops(\"btc_addresses file does not exist\")\n\t}\n\tif c.SkyAddresses == \"\" {\n\t\toops(\"sky_addresses missing\")\n\t}\n\tif _, err := os.Stat(c.SkyAddresses); os.IsNotExist(err) {\n\t\toops(\"sky file does not exist\")\n\t}\n\n\tif !c.Dummy.Sender {\n\t\tif c.SkyRPC.Address == \"\" {\n\t\t\toops(\"sky_rpc.address missing\")\n\t\t}\n\n\t\t// test if skycoin node rpc service is reachable\n\t\tconn, err := net.Dial(\"tcp\", c.SkyRPC.Address)\n\t\tif err != nil {\n\t\t\toops(fmt.Sprintf(\"sky_rpc.address connect failed: %v\", err))\n\t\t} else {\n\t\t\tif err := conn.Close(); err != nil {\n\t\t\t\tlog.Printf(\"Failed to close test connection to sky_rpc.address: %v\", err)\n\t\t\t}\n\t\t}\n\t}\n\n\tif !c.Dummy.Scanner {\n\t\tif c.BtcScanner.Enabled {\n\t\t\tif c.BtcRPC.Server == \"\" {\n\t\t\t\toops(\"btc_rpc.server missing\")\n\t\t\t}\n\n\t\t\tif c.BtcRPC.User == \"\" {\n\t\t\t\toops(\"btc_rpc.user missing\")\n\t\t\t}\n\t\t\tif c.BtcRPC.Pass == \"\" {\n\t\t\t\toops(\"btc_rpc.pass missing\")\n\t\t\t}\n\t\t\tif c.BtcRPC.Cert == \"\" {\n\t\t\t\toops(\"btc_rpc.cert missing\")\n\t\t\t}\n\n\t\t\tif _, err := os.Stat(c.BtcRPC.Cert); os.IsNotExist(err) {\n\t\t\t\toops(\"btc_rpc.cert file does not exist\")\n\t\t\t}\n\t\t}\n\t}\n\n\tif c.BtcScanner.ConfirmationsRequired < 0 {\n\t\toops(\"btc_scanner.confirmations_required must be >= 0\")\n\t}\n\tif c.BtcScanner.InitialScanHeight < 0 {\n\t\toops(\"btc_scanner.initial_scan_height must be >= 0\")\n\t}\n\n\texchangeErrs := c.BoxExchanger.validate()\n\tfor _, err := range exchangeErrs {\n\t\toops(err.Error())\n\t}\n\t//\n\t//if !c.Dummy.Sender {\n\t//\texchangeErrs := c.BoxExchanger.validateWallet()\n\t//\tfor _, err := range exchangeErrs {\n\t//\t\toops(err.Error())\n\t//\t}\n\t//}\n\n\tif err := c.Web.Validate(); err != nil {\n\t\toops(err.Error())\n\t}\n\n\tif len(errs) == 0 {\n\t\treturn nil\n\t}\n\n\treturn errors.New(strings.Join(errs, \"\\n\"))\n}", "func (c *Config) Validate() error {\n\tlogrus.Trace(\"validating config configuration\")\n\n\t// verify server is provided\n\tif len(c.Server) == 0 {\n\t\treturn fmt.Errorf(\"no config server provided\")\n\t}\n\n\t// check to make sure it's a valid url\n\t_, err := url.ParseRequestURI(c.Server)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s is not a valid url\", c.Server)\n\t}\n\n\t// verify token is provided\n\tif len(c.Token) == 0 {\n\t\treturn fmt.Errorf(\"no config token provided\")\n\t}\n\n\treturn nil\n}", "func (c *configuration) validateConfig() error {\n\tif c.Provider == \"\" {\n\t\treturn errors.New(msgConfigNoProvider)\n\t}\n\n\tif len(c.Servers) == 0 {\n\t\treturn errors.New(msgConfigNoServers)\n\t}\n\n\tfor i, srv := range c.Servers {\n\t\tif srv.FabricIface == \"\" {\n\t\t\treturn errors.Errorf(\n\t\t\t\tmsgConfigServerNoIface+\" for I/O service %d\", i)\n\t\t}\n\t}\n\n\treturn nil\n}", "func validateConfig(args ArgCollection) error {\n\texpectedKeys := []string{}\n\tconfigFileRequired := false\n\tif args.ProviderFlag == \"custom\" {\n\t\tconfigFileRequired = true\n\t\texpectedKeys = append(expectedKeys, []string{\"providers.custom.insecure\", \"providers.custom.endpoint_format\", \"providers.custom.regions\", \"providers.custom.address_style\"}...)\n\t}\n\tif args.WriteToDB {\n\t\tconfigFileRequired = true\n\t\texpectedKeys = append(expectedKeys, []string{\"db.uri\"}...)\n\t}\n\tif args.UseMq {\n\t\tconfigFileRequired = true\n\t\texpectedKeys = append(expectedKeys, []string{\"mq.queue_name\", \"mq.uri\"}...)\n\t}\n\t// User didn't give any arguments that require the config file\n\tif !configFileRequired {\n\t\treturn nil\n\t}\n\n\t// Try to find and read config file\n\tif err := viper.ReadInConfig(); err != nil {\n\t\tif _, ok := err.(viper.ConfigFileNotFoundError); ok {\n\t\t\treturn errors.New(\"config file not found\")\n\t\t} else {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Verify all expected keys are in the config file\n\tfor _, k := range expectedKeys {\n\t\tif !viper.IsSet(k) {\n\t\t\treturn fmt.Errorf(\"config file missing key: %s\", k)\n\t\t}\n\t}\n\treturn nil\n}", "func (cfg *Config) ApplyDefaults() {\n\tif cfg.Role == \"\" {\n\t\tcfg.Role = \"client\"\n\t}\n\n\tif cfg.Addr == \"\" {\n\t\tcfg.Addr = \"localhost:8787\"\n\t}\n\n\tif cfg.UIAddr == \"\" {\n\t\tcfg.UIAddr = \"localhost:16823\"\n\t}\n\n\tif cfg.CloudConfig == \"\" {\n\t\tcfg.CloudConfig = fmt.Sprintf(\"https://s3.amazonaws.com/lantern_config/cloud.%v.yaml.gz\", countryPlaceholder)\n\t}\n\n\t// Default country\n\tif cfg.Country == \"\" {\n\t\tcfg.Country = *country\n\t}\n\n\t// Make sure we always have a stats config\n\tif cfg.Stats == nil {\n\t\tcfg.Stats = &statreporter.Config{}\n\t}\n\n\tif cfg.Stats.StatshubAddr == \"\" {\n\t\tcfg.Stats.StatshubAddr = *statshubAddr\n\t}\n\n\tif cfg.Client != nil && cfg.Role == \"client\" {\n\t\tcfg.applyClientDefaults()\n\t}\n\n\tif cfg.ProxiedSites == nil {\n\t\tlog.Debugf(\"Adding empty proxiedsites\")\n\t\tcfg.ProxiedSites = &proxiedsites.Config{\n\t\t\tDelta: &proxiedsites.Delta{\n\t\t\t\tAdditions: []string{},\n\t\t\t\tDeletions: []string{},\n\t\t\t},\n\t\t\tCloud: []string{},\n\t\t}\n\t}\n\n\tif cfg.ProxiedSites.Cloud == nil || len(cfg.ProxiedSites.Cloud) == 0 {\n\t\tlog.Debugf(\"Loading default cloud proxiedsites\")\n\t\tcfg.ProxiedSites.Cloud = defaultProxiedSites\n\t}\n\n\tif cfg.TrustedCAs == nil || len(cfg.TrustedCAs) == 0 {\n\t\tcfg.TrustedCAs = defaultTrustedCAs\n\t}\n}", "func validateConfig(conf *Config) {\n\t// Hopefully lxc package derives this correctly\n\tif conf.LXCPath == \"\" {\n\t\tconf.LXCPath = lxc.DefaultConfigPath()\n\t}\n\n\t// Generate \"Docker-style\" container names if it is not provided\n\tif conf.Name == \"\" {\n\t\tconf.Name = randomdata.SillyName()\n\t}\n}", "func (c *Config) CheckAndSetDefaults() error {\n\tvar errors []error\n\tif c.Address == \"\" {\n\t\terrors = append(errors, trace.BadParameter(\"address must be provided\"))\n\t}\n\tif c.CAFile == \"\" {\n\t\terrors = append(errors, trace.BadParameter(\"CA file path must be provided\"))\n\t}\n\tif c.CertFile == \"\" {\n\t\terrors = append(errors, trace.BadParameter(\"certificate file path must be provided\"))\n\t}\n\tif c.KeyFile == \"\" {\n\t\terrors = append(errors, trace.BadParameter(\"key file path must be provided\"))\n\t}\n\treturn trace.NewAggregate(errors...)\n}", "func (c *DefaultConfig) validate() error {\n\tif c.ClusterID == \"\" {\n\t\treturn errors.New(\"must set ClusterID when ClusterIDSource was set to 'config'\")\n\t}\n\treturn nil\n}", "func CheckProxy(useProxy bool, trustedProxies []string) func(http.Handler) http.Handler {\n\tp := ProxyChecker{\n\t\tErrorFunc: defaultErrorFunc,\n\t\tUseProxy: useProxy,\n\t\tTrustedProxies: trustedProxies,\n\t}\n\treturn p.Handle\n}", "func validateConfig(config *ProviderConfig) error {\n\t// Validate the inputs\n\tif config == nil {\n\t\treturn fmt.Errorf(\"missing config\")\n\t}\n\tif config.Service == nil {\n\t\treturn fmt.Errorf(\"missing service\")\n\t}\n\tif config.Service.Service == \"\" {\n\t\treturn fmt.Errorf(\"missing service name\")\n\t}\n\tif config.Service.ServiceVersion == \"\" {\n\t\treturn fmt.Errorf(\"missing service version\")\n\t}\n\tif config.Service.ResourceType == \"\" {\n\t\treturn fmt.Errorf(\"missing service resource type\")\n\t}\n\tif config.Handlers == nil && len(config.Service.Capabilities) != 0 {\n\t\treturn fmt.Errorf(\"missing handlers\")\n\t}\n\tfor c := range config.Service.Capabilities {\n\t\tif _, ok := config.Handlers[c]; !ok {\n\t\t\treturn fmt.Errorf(\"missing handler for '%s' capability\", c)\n\t\t}\n\t}\n\tif config.ResourceGroup == \"\" {\n\t\treturn fmt.Errorf(\"missing resource group\")\n\t}\n\tif config.Token == \"\" {\n\t\tconfig.Token = os.Getenv(\"ATLAS_TOKEN\")\n\t}\n\tif config.Token == \"\" {\n\t\treturn fmt.Errorf(\"missing token\")\n\t}\n\n\t// Default the endpoint\n\tif config.Endpoint == \"\" {\n\t\tconfig.Endpoint = DefaultEndpoint\n\t\tif end := os.Getenv(\"SCADA_ENDPOINT\"); end != \"\" {\n\t\t\tconfig.Endpoint = end\n\t\t}\n\t}\n\treturn nil\n}", "func (r RequestDrivenWebServiceHttpConfig) validate() error {\n\tif err := r.HealthCheckConfiguration.validate(); err != nil {\n\t\treturn err\n\t}\n\treturn r.Private.validate()\n}", "func (c *Config) Validate() error {\n\tvar errs []error\n\n\tif len(c.Hosts) == 0 {\n\t\terrs = append(errs, fmt.Errorf(\"missing hosts\"))\n\t}\n\tif c.Port == \"\" {\n\t\terrs = append(errs, fmt.Errorf(\"missing port\"))\n\t}\n\n\treturn apierrors.NewAggregate(errs)\n}", "func (c *Config) validate() error {\n\tif len(c.Port) == 0 {\n\t\treturn errors.New(\"missing port\")\n\t}\n\n\terr := c.BackendServerConfigs.validate()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"invalid backend servers configuration\")\n\t}\n\n\treturn nil\n}", "func (o MustGatherSpecPtrOutput) ProxyConfig() MustGatherSpecProxyConfigPtrOutput {\n\treturn o.ApplyT(func(v *MustGatherSpec) *MustGatherSpecProxyConfig {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.ProxyConfig\n\t}).(MustGatherSpecProxyConfigPtrOutput)\n}", "func (proxy *proxyService) validateProxyServerRules(\n\tw gohttp.ResponseWriter, r *gohttp.Request,\n) bool {\n\n\tif r.Method == \"CONNECT\" {\n\t\tgohttp.Error(w, \"CONNECT is not supported.\", 405)\n\t\treturn false\n\t}\n\n\tif !r.URL.IsAbs() {\n\t\terrMsg := \"This is a proxy server. Non-proxy requests aren't allowed.\"\n\t\tgohttp.Error(w, errMsg, 500)\n\t\treturn false\n\t}\n\n\treturn true\n}", "func (t *OpenconfigQos_Qos_ForwardingGroups_ForwardingGroup_Config) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigQos_Qos_ForwardingGroups_ForwardingGroup_Config\"], t, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *APIGatewayConfiguration) ValidateCfg() (err error) {\n\texception.Block{\n\t\tTry: func() {\n\t\t\tc.validateConfig()\n\t\t},\n\t\tCatch: func(e error) {\n\t\t\terr = e\n\t\t},\n\t}.Do()\n\n\treturn\n}", "func (c CopyConfig) Validate() error {\n\tif err := c.GitilesConfig.Validate(); err != nil {\n\t\treturn skerr.Wrap(err)\n\t}\n\tif len(c.Copies) == 0 {\n\t\treturn skerr.Fmt(\"Copies are required\")\n\t}\n\tfor _, copy := range c.Copies {\n\t\tif err := copy.Validate(); err != nil {\n\t\t\treturn skerr.Wrap(err)\n\t\t}\n\t}\n\treturn nil\n}", "func (c Config) Validate() error {\n\tif c.CollectorEndpoint == \"\" && c.AgentEndpoint == \"\" {\n\t\treturn xerrors.New(\"jaeger: either collector endpoint or agent endpoint must be configured\")\n\t}\n\tif c.ServiceName == \"\" {\n\t\treturn xerrors.New(\"jaeger: service name must not be blank\")\n\t}\n\n\treturn nil\n}", "func (cfg *Config) Validate() error {\n\tif cfg.Key == \"\" {\n\t\treturn errors.New(\"missing DigitalOcean access key\")\n\t}\n\n\treturn nil\n}", "func DefaultProxyArgs() []string {\n\treturn []string{\n\t\t\"-l\", \"/codis/log/$(POD_NAMESPACE)_$(POD_NAME).log\",\n\t\t\"-c\", \"/data/service/codis/config-default/proxy.toml\",\n\t\t\"--session_auth\", \"$(SESSION_AUTH)\",\n\t\t\"--host-admin\", fmt.Sprintf(\"$(POD_IP):%v\", DefaultProxyHostPort),\n\t\t\"--host-proxy\", fmt.Sprintf(\"$(POD_IP):%v\", DefaultProxyPort),\n\t\t\"--zookeeper\", \"$(ZK_ADDR)\",\n\t\t\"--product_name\", \"$(PRODUCT_NAME)\",\n\t\t\"--pidfile\", \"/tmp/proxy.pid\",\n\t}\n}", "func (r RequestDrivenWebServiceConfig) validate() error {\n\tvar err error\n\tif err = r.ImageConfig.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"image\": %w`, err)\n\t}\n\tif err = r.InstanceConfig.validate(); err != nil {\n\t\treturn err\n\t}\n\tif err = r.RequestDrivenWebServiceHttpConfig.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"http\": %w`, err)\n\t}\n\tif err = r.PublishConfig.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"publish\": %w`, err)\n\t}\n\tif err = r.Network.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"network\": %w`, err)\n\t}\n\tif r.Network.VPC.Placement.PlacementString != nil &&\n\t\t*r.Network.VPC.Placement.PlacementString != PrivateSubnetPlacement {\n\t\treturn fmt.Errorf(`placement %q is not supported for %s`,\n\t\t\t*r.Network.VPC.Placement.PlacementString, manifestinfo.RequestDrivenWebServiceType)\n\t}\n\tif err = r.Observability.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"observability\": %w`, err)\n\t}\n\treturn nil\n}", "func (h *HealthzConfig) CheckAndSetDefaults() error {\n\tif h == nil {\n\t\treturn nil\n\t}\n\n\tvar errors []error\n\tif h.AccessKey == \"\" {\n\t\terrors = append(errors, trace.BadParameter(\"access-key is required\"))\n\t}\n\tif h.SecretAccessKey == \"\" {\n\t\terrors = append(errors, trace.BadParameter(\"secret-access-key is required\"))\n\t}\n\tif h.Endpoint == \"\" {\n\t\th.Endpoint = defaults.HealthzEndpoint\n\t}\n\treturn trace.NewAggregate(errors...)\n}", "func (cfg Config) Validate() error {\n\treturn validation.ValidateStruct(\n\t\t&cfg,\n\t\tvalidation.Field(&cfg.NodeID, validation.Required),\n\t\tvalidation.Field(&cfg.ListenAddr, validation.Required, is.Host),\n\t\tvalidation.Field(&cfg.DataDir, validation.Required),\n\t\tvalidation.Field(&cfg.CompactionEnabled, validation.Required),\n\t\tvalidation.Field(&cfg.Peers),\n\t)\n}", "func (s *OpenconfigInterfaces_Interfaces_Interface_Tunnel_Ipv4_Neighbors_Neighbor_Config) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigInterfaces_Interfaces_Interface_Tunnel_Ipv4_Neighbors_Neighbor_Config\"], s, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (cfg Config) Validate() error {\n\tvar errs []string\n\tif cfg.Releaser == nil {\n\t\terrs = append(errs, \"releaser not supplied\")\n\t}\n\tif cfg.History == nil {\n\t\terrs = append(errs, \"history DB not supplied\")\n\t}\n\tif len(errs) > 0 {\n\t\treturn errors.New(\"invalid: \" + strings.Join(errs, \"; \"))\n\t}\n\treturn nil\n}", "func (c Config) Validate() error {\n\tif c.ServiceName == \"\" {\n\t\treturn xerrors.New(\"ocagent: service name must not be blank\")\n\t}\n\treturn nil\n}", "func ValidateTLSConfig(config *schema.TLS, configDefault *schema.TLS) (err error) {\n\tif configDefault == nil {\n\t\treturn errors.New(\"must provide configDefault\")\n\t}\n\n\tif config == nil {\n\t\treturn\n\t}\n\n\tif config.ServerName == \"\" {\n\t\tconfig.ServerName = configDefault.ServerName\n\t}\n\n\tif config.MinimumVersion.Value == 0 {\n\t\tconfig.MinimumVersion.Value = configDefault.MinimumVersion.Value\n\t}\n\n\tif config.MaximumVersion.Value == 0 {\n\t\tconfig.MaximumVersion.Value = configDefault.MaximumVersion.Value\n\t}\n\n\tif config.MinimumVersion.MinVersion() < tls.VersionTLS10 {\n\t\treturn errors.New(\"option 'minimum_version' is invalid: minimum version is TLS1.0 but SSL3.0 was configured\")\n\t}\n\n\tif config.MinimumVersion.MinVersion() > config.MaximumVersion.MaxVersion() {\n\t\treturn fmt.Errorf(\"option combination of 'minimum_version' and 'maximum_version' is invalid: minimum version %s is greater than the maximum version %s\", config.MinimumVersion.String(), config.MaximumVersion.String())\n\t}\n\n\tif (config.CertificateChain.HasCertificates() || config.PrivateKey != nil) && !config.CertificateChain.EqualKey(config.PrivateKey) {\n\t\treturn errors.New(\"option 'certificates' is invalid: provided certificate does not contain the public key for the private key provided\")\n\t}\n\n\treturn nil\n}", "func (config *Config) Validate() error {\n\tif len(config.NsqLookupdAddress) == 0 {\n\t\treturn fmt.Errorf(\"parameter NsqLookupdAddress missing\")\n\t}\n\tif len(config.NsqdAddress) == 0 {\n\t\treturn fmt.Errorf(\"parameter NsqdAddress missing\")\n\t}\n\tif len(config.BotName) == 0 {\n\t\treturn fmt.Errorf(\"parameter BotName missing\")\n\t}\n\tif len(config.BambooUrl) == 0 {\n\t\treturn fmt.Errorf(\"parameter BambooUrl missing\")\n\t}\n\tif len(config.BambooUsername) == 0 {\n\t\treturn fmt.Errorf(\"parameter BambooUsername missing\")\n\t}\n\tif len(config.BambooPassword) == 0 {\n\t\treturn fmt.Errorf(\"parameter AuthUrl missing\")\n\t}\n\tif len(config.BambooPassword) == 0 {\n\t\treturn fmt.Errorf(\"parameter AuthApplicationName missing\")\n\t}\n\tif len(config.BambooPassword) == 0 {\n\t\treturn fmt.Errorf(\"parameter AuthApplicationPassword missing\")\n\t}\n\tif len(config.BambooPassword) == 0 {\n\t\treturn fmt.Errorf(\"parameter BambooPassword missing\")\n\t}\n\tif len(config.Prefix) == 0 {\n\t\treturn fmt.Errorf(\"parameter Prefix missing\")\n\t}\n\treturn nil\n}", "func Validate(e legacyconfigv1.MasterConfig) error {\n\tif len(e.ProjectConfig.DefaultNodeSelector) == 0 {\n\t\treturn errors.New(\"DefaultNodeSelector can't be empty\")\n\t}\n\n\treturn nil\n}", "func (n NetworkConfig) validate() error {\n\tif n.IsEmpty() {\n\t\treturn nil\n\t}\n\tif err := n.VPC.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"vpc\": %w`, err)\n\t}\n\tif err := n.Connect.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"connect\": %w`, err)\n\t}\n\treturn nil\n}", "func (l LoadBalancedWebServiceConfig) validate() error {\n\tvar err error\n\tif l.HTTPOrBool.Disabled() && l.NLBConfig.IsEmpty() {\n\t\treturn &errAtLeastOneFieldMustBeSpecified{\n\t\t\tmissingFields: []string{\"http\", \"nlb\"},\n\t\t}\n\t}\n\tif err = l.validateGracePeriod(); err != nil {\n\t\treturn fmt.Errorf(`validate \"grace_period\": %w`, err)\n\t}\n\tif l.HTTPOrBool.Disabled() && (!l.Count.AdvancedCount.Requests.IsEmpty() || !l.Count.AdvancedCount.ResponseTime.IsEmpty()) {\n\t\treturn errors.New(`scaling based on \"nlb\" requests or response time is not supported`)\n\t}\n\tif err = l.ImageConfig.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"image\": %w`, err)\n\t}\n\tif err = l.ImageOverride.validate(); err != nil {\n\t\treturn err\n\t}\n\tif err = l.HTTPOrBool.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"http\": %w`, err)\n\t}\n\tif err = l.TaskConfig.validate(); err != nil {\n\t\treturn err\n\t}\n\tif err = l.Logging.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"logging\": %w`, err)\n\t}\n\tfor k, v := range l.Sidecars {\n\t\tif err = v.validate(); err != nil {\n\t\t\treturn fmt.Errorf(`validate \"sidecars[%s]\": %w`, k, err)\n\t\t}\n\t}\n\tif err = l.Network.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"network\": %w`, err)\n\t}\n\tif err = l.PublishConfig.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"publish\": %w`, err)\n\t}\n\tfor ind, taskDefOverride := range l.TaskDefOverrides {\n\t\tif err = taskDefOverride.validate(); err != nil {\n\t\t\treturn fmt.Errorf(`validate \"taskdef_overrides[%d]\": %w`, ind, err)\n\t\t}\n\t}\n\tif l.TaskConfig.IsWindows() {\n\t\tif err = validateWindows(validateWindowsOpts{\n\t\t\tefsVolumes: l.Storage.Volumes,\n\t\t\treadOnlyFS: l.Storage.ReadonlyRootFS,\n\t\t}); err != nil {\n\t\t\treturn fmt.Errorf(\"validate Windows: %w\", err)\n\t\t}\n\t}\n\tif l.TaskConfig.IsARM() {\n\t\tif err = validateARM(validateARMOpts{\n\t\t\tSpot: l.Count.AdvancedCount.Spot,\n\t\t\tSpotFrom: l.Count.AdvancedCount.Range.RangeConfig.SpotFrom,\n\t\t}); err != nil {\n\t\t\treturn fmt.Errorf(\"validate ARM: %w\", err)\n\t\t}\n\t}\n\tif err = l.NLBConfig.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"nlb\": %w`, err)\n\t}\n\tif err = l.DeployConfig.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"deployment\": %w`, err)\n\t}\n\treturn nil\n}", "func (c NetworkLoadBalancerConfiguration) validate() error {\n\tif c.IsEmpty() {\n\t\treturn nil\n\t}\n\tif err := c.Listener.validate(); err != nil {\n\t\treturn err\n\t}\n\tif err := c.Aliases.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"alias\": %w`, err)\n\t}\n\tif !c.Aliases.IsEmpty() {\n\t\tfor _, advancedAlias := range c.Aliases.AdvancedAliases {\n\t\t\tif advancedAlias.HostedZone != nil {\n\t\t\t\treturn fmt.Errorf(`\"hosted_zone\" is not supported for Network Load Balancer`)\n\t\t\t}\n\t\t}\n\t}\n\tfor idx, listener := range c.AdditionalListeners {\n\t\tif err := listener.validate(); err != nil {\n\t\t\treturn fmt.Errorf(`validate \"additional_listeners[%d]\": %w`, idx, err)\n\t\t}\n\t}\n\treturn nil\n}", "func (c *Config) Validate(defaultLogDir *string) (resErr error) {\n\tvar errBuf bytes.Buffer\n\tdefer func() {\n\t\ts := errBuf.String()\n\t\tif s != \"\" {\n\t\t\tresErr = errors.Newf(\"%s\", s)\n\t\t}\n\t}()\n\n\tbt, bf := true, false\n\n\t// If the default directory was not specified, use the one\n\t// provided by the environment.\n\tif c.FileDefaults.Dir == nil {\n\t\tc.FileDefaults.Dir = defaultLogDir\n\t}\n\t// Normalize the directory.\n\tif err := normalizeDir(&c.FileDefaults.Dir); err != nil {\n\t\tfmt.Fprintf(&errBuf, \"file-defaults: %v\\n\", err)\n\t}\n\t// No severity -> default INFO.\n\tif c.FileDefaults.Filter == logpb.Severity_UNKNOWN {\n\t\tc.FileDefaults.Filter = logpb.Severity_INFO\n\t}\n\tif c.FluentDefaults.Filter == logpb.Severity_UNKNOWN {\n\t\tc.FluentDefaults.Filter = logpb.Severity_INFO\n\t}\n\t// Sinks are not auditable by default.\n\tif c.FileDefaults.Auditable == nil {\n\t\tc.FileDefaults.Auditable = &bf\n\t}\n\tif c.FluentDefaults.Auditable == nil {\n\t\tc.FluentDefaults.Auditable = &bf\n\t}\n\t// File sinks are buffered by default.\n\tif c.FileDefaults.BufferedWrites == nil {\n\t\tc.FileDefaults.BufferedWrites = &bt\n\t}\n\t// No format -> populate defaults.\n\tif c.FileDefaults.Format == nil {\n\t\ts := DefaultFileFormat\n\t\tc.FileDefaults.Format = &s\n\t}\n\tif c.FluentDefaults.Format == nil {\n\t\ts := DefaultFluentFormat\n\t\tc.FluentDefaults.Format = &s\n\t}\n\t// No redaction markers -> default keep them.\n\tif c.FileDefaults.Redactable == nil {\n\t\tc.FileDefaults.Redactable = &bt\n\t}\n\tif c.FluentDefaults.Redactable == nil {\n\t\tc.FluentDefaults.Redactable = &bt\n\t}\n\t// No redaction specification -> default false.\n\tif c.FileDefaults.Redact == nil {\n\t\tc.FileDefaults.Redact = &bf\n\t}\n\tif c.FluentDefaults.Redact == nil {\n\t\tc.FluentDefaults.Redact = &bf\n\t}\n\t// No criticality -> default true for files, false for fluent.\n\tif c.FileDefaults.Criticality == nil {\n\t\tc.FileDefaults.Criticality = &bt\n\t}\n\tif c.FluentDefaults.Criticality == nil {\n\t\tc.FluentDefaults.Criticality = &bf\n\t}\n\n\t// Validate and fill in defaults for file sinks.\n\tfor prefix, fc := range c.Sinks.FileGroups {\n\t\tif fc == nil {\n\t\t\tfc = &FileSinkConfig{}\n\t\t\tc.Sinks.FileGroups[prefix] = fc\n\t\t}\n\t\tfc.prefix = prefix\n\t\tif err := c.validateFileSinkConfig(fc, defaultLogDir); err != nil {\n\t\t\tfmt.Fprintf(&errBuf, \"file group %q: %v\\n\", prefix, err)\n\t\t}\n\t}\n\n\t// Validate and defaults for fluent.\n\tfor serverName, fc := range c.Sinks.FluentServers {\n\t\tif fc == nil {\n\t\t\tfc = &FluentSinkConfig{}\n\t\t\tc.Sinks.FluentServers[serverName] = fc\n\t\t}\n\t\tfc.serverName = serverName\n\t\tif err := c.validateFluentSinkConfig(fc); err != nil {\n\t\t\tfmt.Fprintf(&errBuf, \"fluent server %q: %v\\n\", serverName, err)\n\t\t}\n\t}\n\n\t// Defaults for stderr.\n\tc.inheritCommonDefaults(&c.Sinks.Stderr.CommonSinkConfig, &c.FileDefaults.CommonSinkConfig)\n\tif c.Sinks.Stderr.Filter == logpb.Severity_UNKNOWN {\n\t\tc.Sinks.Stderr.Filter = logpb.Severity_NONE\n\t}\n\tif c.Sinks.Stderr.Auditable != nil {\n\t\tif *c.Sinks.Stderr.Auditable {\n\t\t\tif *c.Sinks.Stderr.Format == \"crdb-v1-tty\" {\n\t\t\t\tf := \"crdb-v1-tty-count\"\n\t\t\t\tc.Sinks.Stderr.Format = &f\n\t\t\t}\n\t\t\tc.Sinks.Stderr.Criticality = &bt\n\t\t}\n\t\tc.Sinks.Stderr.Auditable = nil\n\t}\n\tc.Sinks.Stderr.Channels.Sort()\n\n\t// fileSinks maps channels to files.\n\tfileSinks := make(map[logpb.Channel]*FileSinkConfig)\n\t// fluentSinks maps channels to fluent servers.\n\tfluentSinks := make(map[logpb.Channel]*FluentSinkConfig)\n\n\t// Check that no channel is listed by more than one file sink,\n\t// and every file has at least one channel.\n\tfor _, fc := range c.Sinks.FileGroups {\n\t\tif len(fc.Channels.Channels) == 0 {\n\t\t\tfmt.Fprintf(&errBuf, \"file group %q: no channel selected\\n\", fc.prefix)\n\t\t}\n\t\tfc.Channels.Sort()\n\t\tfor _, ch := range fc.Channels.Channels {\n\t\t\tif prev := fileSinks[ch]; prev != nil {\n\t\t\t\tprevPrefix := prev.prefix\n\t\t\t\tif prevPrefix == \"\" {\n\t\t\t\t\tprevPrefix = \"debug\"\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(&errBuf, \"file group %q: channel %s already captured by group %q\\n\",\n\t\t\t\t\tfc.prefix, ch, prevPrefix)\n\t\t\t} else {\n\t\t\t\tfileSinks[ch] = fc\n\t\t\t}\n\t\t}\n\t}\n\n\t// Check that no channel is listed by more than one fluent sink, and\n\t// every sink has at least one channel.\n\tfor _, fc := range c.Sinks.FluentServers {\n\t\tif len(fc.Channels.Channels) == 0 {\n\t\t\tfmt.Fprintf(&errBuf, \"fluent server %q: no channel selected\\n\", fc.serverName)\n\t\t}\n\t\tfc.Channels.Sort()\n\t\tfor _, ch := range fc.Channels.Channels {\n\t\t\tif prev := fluentSinks[ch]; prev != nil {\n\t\t\t\tfmt.Fprintf(&errBuf, \"fluent server %q: channel %s already captured by server %q\\n\",\n\t\t\t\t\tfc.serverName, ch, prev.serverName)\n\t\t\t} else {\n\t\t\t\tfluentSinks[ch] = fc\n\t\t\t}\n\t\t}\n\t}\n\n\t// If capture-stray-errors was enabled, then perform some additional\n\t// validation on it.\n\tif c.CaptureFd2.Enable {\n\t\tif c.CaptureFd2.MaxGroupSize == nil {\n\t\t\tc.CaptureFd2.MaxGroupSize = &c.FileDefaults.MaxGroupSize\n\t\t}\n\t\tif c.CaptureFd2.Dir == nil {\n\t\t\t// No directory specified; inherit defaults.\n\t\t\tc.CaptureFd2.Dir = c.FileDefaults.Dir\n\t\t} else {\n\t\t\t// Directory was specified: normalize it.\n\t\t\tif err := normalizeDir(&c.CaptureFd2.Dir); err != nil {\n\t\t\t\tfmt.Fprintf(&errBuf, \"stray error capture: %v\\n\", err)\n\t\t\t}\n\t\t}\n\t\tif c.CaptureFd2.Dir == nil {\n\t\t\t// After normalization, no directory was left: disable the fd2\n\t\t\t// capture.\n\t\t\tc.CaptureFd2.Enable = false\n\t\t}\n\t}\n\tif !c.CaptureFd2.Enable {\n\t\tif c.Sinks.Stderr.Filter != logpb.Severity_NONE && *c.Sinks.Stderr.Redactable {\n\t\t\tfmt.Fprintln(&errBuf,\n\t\t\t\t\"stderr.redactable cannot be set if capture-stray-errors.enable is unset\")\n\t\t}\n\t\t// Not enabled: erase all fields so it gets omitted when pretty-printing.\n\t\tc.CaptureFd2 = CaptureFd2Config{}\n\t}\n\n\t// If there is no file group for DEV yet, create one.\n\tdevch := logpb.Channel_DEV\n\tif def := fileSinks[devch]; def == nil {\n\t\tfc := &FileSinkConfig{\n\t\t\tChannels: ChannelList{Channels: []logpb.Channel{devch}},\n\t\t}\n\t\tfc.prefix = \"default\"\n\t\tif err := c.validateFileSinkConfig(fc, defaultLogDir); err != nil {\n\t\t\tfmt.Fprintln(&errBuf, err)\n\t\t}\n\t\tif c.Sinks.FileGroups == nil {\n\t\t\tc.Sinks.FileGroups = make(map[string]*FileSinkConfig)\n\t\t}\n\t\tc.Sinks.FileGroups[fc.prefix] = fc\n\t\tfileSinks[devch] = fc\n\t}\n\n\t// For every remaining channel without a sink, add it to the DEV sink.\n\tdevFile := fileSinks[devch]\n\tfor _, ch := range channelValues {\n\t\tif fileSinks[ch] == nil {\n\t\t\tdevFile.Channels.Channels = append(devFile.Channels.Channels, ch)\n\t\t}\n\t}\n\tdevFile.Channels.Sort()\n\n\t// fileGroupNames collects the names of file groups. We need this to\n\t// store this sorted in c.Sinks.sortedFileGroupNames later.\n\tfileGroupNames := make([]string, 0, len(c.Sinks.FileGroups))\n\t// Elide all the file sinks without a directory or with severity set\n\t// to NONE. Also collect the remaining names for sorting below.\n\tfor prefix, fc := range c.Sinks.FileGroups {\n\t\tif fc.Dir == nil || fc.Filter == logpb.Severity_NONE {\n\t\t\tdelete(c.Sinks.FileGroups, prefix)\n\t\t} else {\n\t\t\tfileGroupNames = append(fileGroupNames, prefix)\n\t\t}\n\t}\n\n\t// serverNames collects the names of the servers. We need this to\n\t// store this sorted in c.Sinks.sortedServerNames later.\n\tserverNames := make([]string, 0, len(c.Sinks.FluentServers))\n\t// Elide all the file sinks without a directory or with severity set\n\t// to NONE. Also collect the remaining names for sorting below.\n\tfor serverName, fc := range c.Sinks.FluentServers {\n\t\tif fc.Filter == logpb.Severity_NONE {\n\t\t\tdelete(c.Sinks.FluentServers, serverName)\n\t\t} else {\n\t\t\tserverNames = append(serverNames, serverName)\n\t\t}\n\t}\n\n\t// Remember the sorted names, so we get deterministic output in\n\t// export.\n\tsort.Strings(fileGroupNames)\n\tc.Sinks.sortedFileGroupNames = fileGroupNames\n\tsort.Strings(serverNames)\n\tc.Sinks.sortedServerNames = serverNames\n\n\treturn nil\n}" ]
[ "0.6642014", "0.65776545", "0.6576133", "0.65689003", "0.62941796", "0.6183459", "0.60884404", "0.6012993", "0.6012026", "0.5981353", "0.59771043", "0.5960726", "0.5947902", "0.59138715", "0.5907313", "0.5835956", "0.579558", "0.57797164", "0.57753634", "0.5757942", "0.57508796", "0.57508796", "0.57253903", "0.5713429", "0.56986594", "0.56941473", "0.56672984", "0.565432", "0.5647007", "0.56267184", "0.5622102", "0.5618327", "0.56139755", "0.5573077", "0.55685306", "0.5547485", "0.5546187", "0.55418503", "0.55414724", "0.5527936", "0.5525892", "0.5524168", "0.5511302", "0.5494118", "0.5487694", "0.54870707", "0.5485948", "0.5479892", "0.54786545", "0.54736197", "0.54648554", "0.545871", "0.543537", "0.54340965", "0.54314005", "0.54302216", "0.5424395", "0.54205555", "0.5418414", "0.54152", "0.5414837", "0.5402945", "0.540242", "0.53998846", "0.5399107", "0.5398145", "0.5379672", "0.53682566", "0.5366392", "0.5364093", "0.53581625", "0.535749", "0.5357037", "0.53507596", "0.53450197", "0.53372335", "0.53290164", "0.5328783", "0.5314101", "0.52953464", "0.5290845", "0.529053", "0.5277339", "0.5273576", "0.5267095", "0.52631074", "0.52568436", "0.52550274", "0.52444947", "0.5242206", "0.523833", "0.523745", "0.5228254", "0.52247995", "0.521956", "0.5219507", "0.5219437", "0.5211684", "0.5211494", "0.5210483" ]
0.6594782
1
parseTag parses a tag string from the struct field and unmarshals into a Tag struct.
func parseTag(raw string) (*Tag, error) { var tag = new(Tag) raw = strings.Replace(raw, "`", "", -1) raw = reflect.StructTag(raw).Get("sql") // if the tag indicates the field should // be skipped we can exit right away. if strings.TrimSpace(raw) == "-" { tag.Skip = true return tag, nil } // otherwise wrap the string in curly braces // so that we can use the Yaml parser. raw = fmt.Sprintf("{ %s }", raw) // unmarshals the Yaml formatted string into // the Tag structure. var err = yaml.Unmarshal([]byte(raw), tag) return tag, err }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func parseTag(f reflect.StructField, tag string) (string, tagOptions) {\n\treturn splitTags(getTagValues(f, tag))\n}", "func ParseTag(raw string) (*Tag, error) {\n\tvar tag = new(Tag)\n\n\traw = strings.TrimSpace(topAndTail(strings.TrimSpace(raw)))\n\tstructTag := reflect.StructTag(raw)\n\tvalue := strings.TrimSpace(structTag.Get(TagKey))\n\n\tif value == \"-\" {\n\t\ttag.Skip = true\n\t\treturn tag, nil\n\t}\n\n\t// wrap the string in curly braces so that we can use the Yaml parser.\n\tyamlValue := fmt.Sprintf(\"{ %s }\", value)\n\n\t// unmarshals the Yaml formatted string into the Tag structure.\n\tvar err = yaml.Unmarshal([]byte(yamlValue), tag)\n\tif err != nil {\n\t\treturn tag, err\n\t}\n\n\tnormalize(tag)\n\treturn tag, validate(tag)\n}", "func ParseTag(str string) Tag {\n\t// sanitize text\n\tstr = sanitizeText(str)\n\n\t// detect split type\n\thasSpace := strings.ContainsRune(str, ' ')\n\thasDash := strings.ContainsRune(str, '-')\n\tvar spl []string\n\tswitch {\n\tcase hasSpace && hasDash:\n\t\t// this is rare enough that I dont want to bother optimizing it\n\t\tspl = strings.Split(strings.Replace(str, \" \", \"-\", -1), \"-\")\n\tcase hasSpace:\n\t\tspl = strings.Split(str, \" \")\n\tcase hasDash:\n\t\tspl = strings.Split(str, \"-\")\n\t}\n\n\t// generate tag\n\treturn Tag{\n\t\tRaw: str,\n\t\tParts: spl,\n\t\tIsDash: hasDash && !hasSpace,\n\t}\n}", "func (p *Parser) parseTag(f *ast.Field) (*types.Tag, error) {\n\t// tag not exist and this is not error (maybe inner type will contain it)\n\tif f.Tag == nil {\n\t\treturn nil, nil\n\t}\n\n\tvar targetTag string\n\n\ttags := strings.Trim(f.Tag.Value, \"`\")\n\tfor _, tag := range strings.Fields(tags) {\n\t\tif strings.HasPrefix(tag, \"env:\") {\n\t\t\ttargetTag = tag\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif targetTag == \"\" {\n\t\treturn nil, errors.New(\"tag not found\")\n\t}\n\n\trawBody := strings.Split(targetTag, `\"`)\n\tif len(rawBody) != 3 { // env:, rawBody, _\n\t\treturn nil, errors.New(\"invalid tag\")\n\t}\n\n\ttagBody := rawBody[1]\n\tenvVar := tagBody[:len(tagBody)-1]\n\taction := tagBody[len(tagBody)-1:]\n\n\tswitch action {\n\tcase types.Want, types.Must, types.Secret:\n\t\treturn &types.Tag{EnvVar: envVar, Action: action}, nil\n\tdefault:\n\t\treturn nil, errors.New(\"invalid tag format\")\n\t}\n}", "func parseStructTag(data string, attrs *map[string]bool, tags *map[string]string) {\n\tattr := make(map[string]bool)\n\ttag := make(map[string]string)\n\tfor _, v := range strings.Split(data, defaultStructTagDelim) {\n\t\tv = strings.TrimSpace(v)\n\t\tif supportedTag[v] == 1 {\n\t\t\tattr[v] = true\n\t\t} else if i := strings.Index(v, \"(\"); i > 0 && strings.Index(v, \")\") == len(v)-1 {\n\t\t\tname := v[:i]\n\t\t\tif supportedTag[name] == 2 {\n\t\t\t\tv = v[i+1 : len(v)-1]\n\t\t\t\ttag[name] = v\n\t\t\t}\n\t\t}\n\t}\n\t*attrs = attr\n\t*tags = tag\n}", "func (e *Event) ParseTag() *TagList {\n\tvar s *C.GstTagList\n\tC.gst_event_parse_tag(e.g(), &s)\n\tr := new(TagList)\n\tr.SetPtr(glib.Pointer(s))\n\treturn r\n}", "func parseTag(stag StructTag) map[string]string {\n\ttag := string(stag)\n\tm := make(map[string]string)\n\tfor tag != \"\" {\n\t\ti := 0\n\t\tfor i < len(tag) && tag[i] == ' ' {\n\t\t\ti += 1\n\t\t}\n\t\ttag = tag[i:]\n\t\tif tag == \"\" {\n\t\t\tbreak\n\t\t}\n\n\t\ti = 0\n\t\tfor i < len(tag) && tag[i] > ' ' && tag[i] != ':' && tag[i] != '\"' && tag[i] != 0x7f {\n\t\t\ti++\n\t\t}\n\t\tif i == 0 || i+1 >= len(tag) || tag[i] != ':' || tag[i+1] != '\"' {\n\t\t\tbreak\n\t\t}\n\t\tname := string(tag[:i])\n\t\ttag = tag[i+1:]\n\n\t\ti = 1\n\t\tfor i < len(tag) && tag[i] != '\"' {\n\t\t\tif tag[i] == '\\\\' {\n\t\t\t\ti++\n\t\t\t}\n\t\t\ti++\n\t\t}\n\t\tif i >= len(tag) {\n\t\t\tbreak\n\t\t}\n\t\tqvalue := string(tag[:i+1])\n\t\ttag = tag[i+1:]\n\n\t\tvalue, err := strconv.Unquote(qvalue)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t\tm[name] = value\n\t\t}\n\t\treturn m\n\t}\n\treturn m\n}", "func Parse(tagStr string) Tags {\n\tif strings.HasPrefix(tagStr, \"`\") {\n\t\ttagStr = tagStr[1:]\n\t}\n\n\tif strings.HasSuffix(tagStr, \"`\") {\n\t\ttagStr = tagStr[:len(tagStr)-1]\n\t}\n\ttagStr = strings.TrimSpace(tagStr)\n\treturn mapFieldTags(tagStr)\n}", "func SetTag(tag string) {\n\tstructtag.Tag = tag\n}", "func parseTag(tag string) (string, string) {\n\tx := strings.Split(tag, \":\")\n\tif len(x) != 2 {\n\t\treturn x[0], \"\"\n\t}\n\treturn x[0], x[1]\n}", "func parseTag(key string, t reflect.StructTag) (name string, omit bool) {\n\ts := t.Get(key)\n\tparts := strings.Split(s, \",\")\n\tif parts[0] == \"-\" {\n\t\treturn \"\", true\n\t}\n\treturn parts[0], false\n}", "func ParseTag(tagName string) (major, minor, patch int, ok bool) {\n\tconst prefix = \"go\"\n\tif !strings.HasPrefix(tagName, prefix) {\n\t\treturn 0, 0, 0, false\n\t}\n\tv := strings.SplitN(tagName[len(prefix):], \".\", 4)\n\tif len(v) > 3 {\n\t\treturn 0, 0, 0, false\n\t}\n\tmajor, ok = parse0To999(v[0])\n\tif !ok || major == 0 {\n\t\treturn 0, 0, 0, false\n\t}\n\tif len(v) == 2 || len(v) == 3 {\n\t\tminor, ok = parse0To999(v[1])\n\t\tif !ok {\n\t\t\treturn 0, 0, 0, false\n\t\t}\n\t}\n\tif len(v) == 3 {\n\t\tpatch, ok = parse0To999(v[2])\n\t\tif !ok {\n\t\t\treturn 0, 0, 0, false\n\t\t}\n\t}\n\treturn major, minor, patch, true\n}", "func ParseTag(tag string) (string, TagOptions) {\n\tif idx := strings.Index(tag, \",\"); idx != -1 {\n\t\treturn tag[:idx], parseOptions(tag[idx+1:])\n\t}\n\treturn tag, make(TagOptions, 0)\n}", "func ParseTagging(src string) *Tagging {\n\tvar res Tagging\n\tseps := strings.SplitN(src, \":\", 2)\n\tres.Name = seps[0]\n\tif len(seps) == 2 {\n\t\tres.Versions = strings.Split(seps[1], \",\")\n\t}\n\treturn &res\n}", "func parseTag(tag string) tagOptions {\n\topts := tagOptions{}\n\tfor _, token := range strings.Split(tag, \",\") {\n\t\tif token == varintOption {\n\t\t\topts[varintOption] = 1\n\t\t\tcontinue\n\t\t}\n\n\t\tparts := strings.Split(token, \"=\")\n\t\tif len(parts[0]) == 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\tif len(parts) == 1 {\n\t\t\tcontinue\n\t\t}\n\n\t\tif parts[0] == \"head\" && parts[1] == headOptionNone {\n\t\t\topts[parts[0]] = headValueNoHead\n\t\t} else if parts[0] == \"head\" && parts[1] == headOptionVarint {\n\t\t\topts[parts[0]] = headValueVarint\n\t\t} else if val, err := strconv.Atoi(parts[1]); err == nil && val >= 0 {\n\t\t\topts[parts[0]] = uint(val)\n\t\t}\n\t}\n\treturn opts\n}", "func parseTags(st reflect.StructTag) tags {\n\ts := st.Get(ndrNameSpace)\n\tt := tags{\n\t\tValues: []string{},\n\t\tMap: make(map[string]string),\n\t}\n\tif s != \"\" {\n\t\tndrTags := strings.Trim(s, `\"`)\n\t\tfor _, tag := range strings.Split(ndrTags, \",\") {\n\t\t\tif strings.Contains(tag, \":\") {\n\t\t\t\tm := strings.SplitN(tag, \":\", 2)\n\t\t\t\tt.Map[m[0]] = m[1]\n\t\t\t} else {\n\t\t\t\tt.Values = append(t.Values, tag)\n\t\t\t}\n\t\t}\n\t}\n\treturn t\n}", "func parseTag(tag string) (string, tagOptions) {\n\ts := strings.Split(tag, \",\")\n\treturn s[0], s[1:]\n}", "func (_e *MockPlcTagHandler_Expecter) ParseTag(tagAddress interface{}) *MockPlcTagHandler_ParseTag_Call {\n\treturn &MockPlcTagHandler_ParseTag_Call{Call: _e.mock.On(\"ParseTag\", tagAddress)}\n}", "func (s *DbRecorder) parseTag(fieldName, tag string) []string {\n\tparts := strings.Split(tag, \",\")\n\tif len(parts) == 0 {\n\t\treturn []string{fieldName}\n\t}\n\treturn parts\n}", "func parseTag(tag string) (string, tagOptions) {\n\tif idx := strings.Index(tag, \",\"); idx != -1 {\n\t\treturn tag[:idx], tagOptions(strings.Split(tag[idx+1:], \",\"))\n\t}\n\treturn tag, tagOptions([]string{})\n}", "func parseTagFlag(tagFlag string) (tag string, err error) {\n\ttags := strings.Fields(tagFlag)\n\tif len(tags) != 1 {\n\t\treturn \"\", fmt.Errorf(\"%q is not a valid single build tag, but %q\", tagFlag, tags)\n\t}\n\treturn tags[0], nil\n}", "func (n *nestedTypeData) FromTag(tag reflect.StructTag) error {\n\traw, ok := tag.Lookup(\"fidl\")\n\tif !ok {\n\t\treturn nil\n\t}\n\tsplit := strings.Split(raw, \",\")\n\tif split[0] == \"*\" {\n\t\tn.nullable = true\n\t\tsplit = split[1:]\n\t}\n\tvar maxElems []*int\n\tfor _, e := range split {\n\t\tif e == \"\" {\n\t\t\tmaxElems = append(maxElems, nil)\n\t\t\tcontinue\n\t\t}\n\t\ti, err := strconv.ParseInt(e, 0, 64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tval := int(i)\n\t\tmaxElems = append(maxElems, &val)\n\t}\n\tn.maxElems = maxElems\n\treturn nil\n}", "func validateStructTag(tag string) error {\n\t// This code is based on the StructTag.Get code in package reflect.\n\n\tn := 0\n\tfor ; tag != \"\"; n++ {\n\t\tif n > 0 && tag != \"\" && tag[0] != ' ' {\n\t\t\t// More restrictive than reflect, but catches likely mistakes\n\t\t\t// like `x:\"foo\",y:\"bar\"`, which parses as `x:\"foo\" ,y:\"bar\"` with second key \",y\".\n\t\t\treturn errTagSpace\n\t\t}\n\t\t// Skip leading space.\n\t\ti := 0\n\t\tfor i < len(tag) && tag[i] == ' ' {\n\t\t\ti++\n\t\t}\n\t\ttag = tag[i:]\n\t\tif tag == \"\" {\n\t\t\tbreak\n\t\t}\n\n\t\t// Scan to colon. A space, a quote or a control character is a syntax error.\n\t\t// Strictly speaking, control chars include the range [0x7f, 0x9f], not just\n\t\t// [0x00, 0x1f], but in practice, we ignore the multi-byte control characters\n\t\t// as it is simpler to inspect the tag's bytes than the tag's runes.\n\t\ti = 0\n\t\tfor i < len(tag) && tag[i] > ' ' && tag[i] != ':' && tag[i] != '\"' && tag[i] != 0x7f {\n\t\t\ti++\n\t\t}\n\t\tif i == 0 {\n\t\t\treturn errTagKeySyntax\n\t\t}\n\t\tif i+1 >= len(tag) || tag[i] != ':' {\n\t\t\treturn errTagSyntax\n\t\t}\n\t\tif tag[i+1] != '\"' {\n\t\t\treturn errTagValueSyntax\n\t\t}\n\t\tkey := tag[:i]\n\t\ttag = tag[i+1:]\n\n\t\t// Scan quoted string to find value.\n\t\ti = 1\n\t\tfor i < len(tag) && tag[i] != '\"' {\n\t\t\tif tag[i] == '\\\\' {\n\t\t\t\ti++\n\t\t\t}\n\t\t\ti++\n\t\t}\n\t\tif i >= len(tag) {\n\t\t\treturn errTagValueSyntax\n\t\t}\n\t\tqvalue := tag[:i+1]\n\t\ttag = tag[i+1:]\n\n\t\tvalue, err := strconv.Unquote(qvalue)\n\t\tif err != nil {\n\t\t\treturn errTagValueSyntax\n\t\t}\n\n\t\tif !checkTagSpaces[key] {\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch key {\n\t\tcase \"xml\":\n\t\t\t// If the first or last character in the XML tag is a space, it is\n\t\t\t// suspicious.\n\t\t\tif strings.Trim(value, \" \") != value {\n\t\t\t\treturn errTagValueSpace\n\t\t\t}\n\n\t\t\t// If there are multiple spaces, they are suspicious.\n\t\t\tif strings.Count(value, \" \") > 1 {\n\t\t\t\treturn errTagValueSpace\n\t\t\t}\n\n\t\t\t// If there is no comma, skip the rest of the checks.\n\t\t\tcomma := strings.IndexRune(value, ',')\n\t\t\tif comma < 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// If the character before a comma is a space, this is suspicious.\n\t\t\tif comma > 0 && value[comma-1] == ' ' {\n\t\t\t\treturn errTagValueSpace\n\t\t\t}\n\t\t\tvalue = value[comma+1:]\n\t\tcase \"json\":\n\t\t\t// JSON allows using spaces in the name, so skip it.\n\t\t\tcomma := strings.IndexRune(value, ',')\n\t\t\tif comma < 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tvalue = value[comma+1:]\n\t\t}\n\n\t\tif strings.IndexByte(value, ' ') >= 0 {\n\t\t\treturn errTagValueSpace\n\t\t}\n\t}\n\treturn nil\n}", "func parseTag(tag string) (string, tagOptions) {\n\tif idx := strings.Index(tag, \",\"); idx != -1 {\n\t\treturn tag[:idx], tagOptions(tag[idx+1:])\n\t}\n\treturn tag, tagOptions(\"\")\n}", "func parseTag(tag string) (string, tagOptions) {\n\tif idx := strings.Index(tag, \",\"); idx != -1 {\n\t\treturn tag[:idx], tagOptions(tag[idx+1:])\n\t}\n\treturn tag, tagOptions(\"\")\n}", "func (p *Parser) parseRefTag(tag string, tagstr string, fieldtyp reflect.StructField, ptrval reflect.Value, index int) uint {\n\tvar value uint\n\tvar err error\n\n\tstrlen := len(tagstr)\n\tif strlen > 2 && tagstr[strlen-2:] == \"()\" {\n\t\tmethodname := tagstr[:strlen-2]\n\t\tif meth, ok := ptrval.Type().MethodByName(methodname); ok {\n\t\t\t// TODO: check signature\n\t\t\tctxval := reflect.ValueOf(p)\n\t\t\tvar result reflect.Value\n\t\t\tif index >= 0 {\n\t\t\t\tindexval := reflect.ValueOf(index)\n\t\t\t\tresult = meth.Func.Call([]reflect.Value{ptrval, ctxval, indexval})[0]\n\t\t\t} else {\n\t\t\t\tresult = meth.Func.Call([]reflect.Value{ptrval, ctxval})[0]\n\t\t\t}\n\t\t\tvalue, err = p.extractUint(result)\n\t\t\tif err != nil {\n\t\t\t\tp.RaiseError2(\"Error trying to parse '%v' as an integer. Referenced from a `%v` tag in '%v'.\", result, tag, ptrval.Type())\n\t\t\t}\n\t\t} else {\n\t\t\tp.RaiseError2(\"Method '%v()' for '%v' not found. Referenced from a `%v` tag.\", methodname, ptrval.Type(), tag)\n\t\t}\n\t} else {\n\t\tif fieldval := ptrval.Elem().FieldByName(tagstr); fieldval.Kind() != reflect.Invalid {\n\t\t\tvalue, err = p.extractUint(fieldval)\n\t\t\tif err != nil {\n\t\t\t\tp.RaiseError2(\"Error trying to parse '%v' as an integer. Referenced from a `%v` tag in '%v'.\", fieldval, tag, ptrval.Type())\n\t\t\t}\n\t\t} else {\n\t\t\tp.RaiseError2(\"Field '%v' for '%v %v' not found. Referenced from a `%v` tag.\", tagstr, fieldtyp.Name, fieldtyp.Type, tag)\n\t\t}\n\t}\n\treturn value\n}", "func (c *Config) GetTag(structType reflect.Type, field reflect.StructField) (*Tag, error) {\n\tif c.TagName == \"\" {\n\t\treturn nil, nil\n\t}\n\tsname := structType.Name()\n\tif sname != \"\" {\n\t\tkey := structType.PkgPath() + \".\" + structType.Name() + \".\" + field.Name\n\t\tt, ok := c.CachedTags.Load(key)\n\t\tif ok {\n\t\t\treturn t.(*Tag), nil\n\t\t}\n\t\ttag, err := c.TagParser(c, field.Tag.Get(c.TagName))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tc.CachedTags.Store(key, tag)\n\t\treturn tag, nil\n\t}\n\treturn c.TagParser(c, field.Tag.Get(c.TagName))\n}", "func (s *StructField) Tag(k string) string {\n\treturn s.field.Tag.Get(k)\n}", "func mapFieldTags(tag string) []StructTag {\n\tvar res []StructTag\n\n\tfor tag != \"\" {\n\t\t// Skip leading space.\n\t\ti := 0\n\t\tfor i < len(tag) && tag[i] == ' ' {\n\t\t\ti++\n\t\t}\n\t\ttag = tag[i:]\n\t\tif tag == \"\" {\n\t\t\tbreak\n\t\t}\n\n\t\t// Scan to colon. A space, a quote or a control character is a syntax error.\n\t\t// Strictly speaking, control chars include the range [0x7f, 0x9f], not just\n\t\t// [0x00, 0x1f], but in practice, we ignore the multi-byte control characters\n\t\t// as it is simpler to inspect the tag's bytes than the tag's runes.\n\t\ti = 0\n\t\tfor i < len(tag) && tag[i] > ' ' && tag[i] != ':' && tag[i] != '\"' && tag[i] != 0x7f {\n\t\t\ti++\n\t\t}\n\t\tif i == 0 || i+1 >= len(tag) || tag[i] != ':' || tag[i+1] != '\"' {\n\t\t\tbreak\n\t\t}\n\t\tname := string(tag[:i])\n\t\ttag = tag[i+1:]\n\n\t\t// Scan quoted string to find value.\n\t\ti = 1\n\t\tfor i < len(tag) && tag[i] != '\"' {\n\t\t\tif tag[i] == '\\\\' {\n\t\t\t\ti++\n\t\t\t}\n\t\t\ti++\n\t\t}\n\t\tif i >= len(tag) {\n\t\t\tbreak\n\t\t}\n\t\tqvalue := string(tag[:i+1])\n\t\ttag = tag[i+1:]\n\n\t\tvalue, err := strconv.Unquote(qvalue)\n\t\tif err != nil {\n\t\t\treturn nil // does this ever happen with the check above?\n\t\t}\n\n\t\t//dunno why this has a broken name, the original code seems to have this as a defacto-bug\n\t\tif strings.HasPrefix(name, \",\") {\n\t\t\tname = name[1:]\n\t\t}\n\n\t\ttag := StructTag{\n\t\t\tName: name,\n\t\t\tValues: strings.Split(value, \",\"),\n\t\t}\n\n\t\tfor i, v := range tag.Values {\n\t\t\ttag.Values[i] = strings.TrimSpace(v)\n\t\t}\n\n\t\tres = append(res, tag)\n\t}\n\n\treturn res\n}", "func Parse(rawtags string) (meta Tag, err error) {\n\tif len(rawtags) == 0 {\n\t\treturn\n\t}\n\ttags, err := structtag.Parse(rawtags)\n\tif err != nil {\n\t\treturn\n\t}\n\tif err = parseJSONTag(tags, &meta); err != nil {\n\t\treturn\n\t}\n\tif err = parseOAPITag(tags, &meta); err != nil {\n\t\treturn\n\t}\n\treturn\n}", "func (_m *MockPlcTagHandler) ParseTag(tagAddress string) (model.PlcTag, error) {\n\tret := _m.Called(tagAddress)\n\n\tvar r0 model.PlcTag\n\tvar r1 error\n\tif rf, ok := ret.Get(0).(func(string) (model.PlcTag, error)); ok {\n\t\treturn rf(tagAddress)\n\t}\n\tif rf, ok := ret.Get(0).(func(string) model.PlcTag); ok {\n\t\tr0 = rf(tagAddress)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(model.PlcTag)\n\t\t}\n\t}\n\n\tif rf, ok := ret.Get(1).(func(string) error); ok {\n\t\tr1 = rf(tagAddress)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func GetStructTag(typeData interface{}, tagName string) (string, error) {\n\tfield, ok := reflect.TypeOf(typeData).Elem().FieldByName(tagName)\n\tif !ok {\n\t\treturn \"\", ErrorsNew(\"can't get Tag\")\n\t}\n\treturn string(field.Tag), nil\n}", "func parseFieldTags(f reflect.StructField) fieldTags {\n\tvar ret fieldTags\n\n\tfor i, s := range strings.Split(f.Tag.Get(\"json\"), \",\") {\n\t\tswitch {\n\t\tcase i == 0 && s == \"-\":\n\t\t\tret.omit = true\n\t\tcase i == 0:\n\t\t\tret.name = s\n\t\tcase s == \"omitempty\":\n\t\t\tret.omitEmpty = true\n\t\tcase s == \"!omitempty\":\n\t\t\tret.noOmitEmpty = true\n\t\tcase s == \"string\":\n\t\t\tret.asString = true\n\t\tcase s == \"required\":\n\t\t\tret.required = true\n\t\tcase s == \"intern\":\n\t\t\tret.intern = true\n\t\tcase s == \"nocopy\":\n\t\t\tret.noCopy = true\n\t\t}\n\t}\n\n\treturn ret\n}", "func FromTag(tagName string) structmap.Behavior {\n\treturn behavior.New(func(field *structmap.FieldPart) error {\n\t\tname, _ := structmap.ParseTag(field.Tag.Get(tagName))\n\t\tif name != \"\" {\n\t\t\tfield.Name = name\n\t\t}\n\n\t\treturn nil\n\t})\n}", "func parseURITag(v reflect.StructTag) string {\n\tif tag := v.Get(uriTag); tag != \"\" {\n\t\treturn tag\n\t}\n\treturn strings.Split(v.Get(jsonTag), \",\")[0]\n}", "func (t *Tag) UnmarshalJSON(dat []byte) error {\n\t// get string\n\tvar str string\n\terr := json.Unmarshal(dat, &str)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// parse tag\n\t*t = ParseTag(str)\n\n\treturn nil\n}", "func getTag(t *reflect.Type, field string, tagName string) {\n var (\n tagVal string\n err error\n )\n fieldVal, ok := (*t).FieldByName(field)\n if ok {\n tagVal = fieldVal.Tag.Get(tagName)\n } else {\n err = errors.New(\"no field named:\" + field)\n }\n\n fmt.Printf(\"get struct[%s] tag[%s]: %s, error:%v\\n\", field, tagName, tagVal, err)\n fmt.Println(\"\")\n}", "func (p *Parse) Tag(finalState *TableState) string {\n\tif finalState == nil {\n\t\treturn \"\"\n\t}\n\treturn finalState.Rb.Terms[0].Value\n}", "func ParseTagKey(tag string) (string, error) {\n\ts, _, _, err := parseTagKey(tag)\n\treturn s, err\n}", "func (d *Decoder) NextTag() (key, value []byte, err error) {\n\tif ok, err := d.advanceToSection(tagSection); err != nil {\n\t\treturn nil, nil, err\n\t} else if !ok {\n\t\treturn nil, nil, nil\n\t}\n\tif d.ensure(1) && fieldSeparatorSpace.get(d.at(0)) {\n\t\td.take(fieldSeparatorSpace)\n\t\td.section = fieldSection\n\t\treturn nil, nil, nil\n\t}\n\ttagKey, i0, err := d.takeEsc(tagKeyChars, &tagKeyEscapes.revTable)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tif len(tagKey) == 0 || !d.ensure(1) || d.at(0) != '=' {\n\t\tif !d.ensure(1) {\n\t\t\treturn nil, nil, d.syntaxErrorf(i0, \"empty tag name\")\n\t\t}\n\t\tif len(tagKey) > 0 {\n\t\t\treturn nil, nil, d.syntaxErrorf(i0, \"expected '=' after tag key %q, but got %q instead\", tagKey, d.at(0))\n\t\t}\n\t\treturn nil, nil, d.syntaxErrorf(i0, \"expected tag key or field but found %q instead\", d.at(0))\n\t}\n\td.advance(1)\n\ttagVal, i0, err := d.takeEsc(tagValChars, &tagValEscapes.revTable)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tif len(tagVal) == 0 {\n\t\treturn nil, nil, d.syntaxErrorf(i0, \"expected tag value after tag key %q, but none found\", tagKey)\n\t}\n\tif !d.ensure(1) {\n\t\t// There's no more data after the tag value. Instead of returning an error\n\t\t// immediately, advance to the field section and return the tag and value.\n\t\t// This means that we'll see all the tags even when there's no value,\n\t\t// and it also allows a client to parse the tags in isolation even when there\n\t\t// are no keys. We'll return an error if the client tries to read values from here.\n\t\td.section = fieldSection\n\t\treturn tagKey, tagVal, nil\n\t}\n\tif err := d.advanceTagComma(); err != nil {\n\t\treturn nil, nil, err\n\t}\n\treturn tagKey, tagVal, nil\n}", "func parseTags(t reflect.StructField, o *Option, prefix string) error {\n\to.name = strings.ToLower(prefix + t.Name)\n\to.oType = t.Type.Kind()\n\tif tag, exists := t.Tag.Lookup(\"getconf\"); exists {\n\t\tif tag = strings.TrimSpace(tag); tag != \"\" {\n\t\t\tif tag == \"-\" {\n\t\t\t\treturn errors.New(\"untrack\")\n\t\t\t}\n\n\t\t\tname, opts := parseTag(tag)\n\t\t\tif name != \"\" {\n\t\t\t\to.name = strings.ToLower(prefix + name)\n\t\t\t}\n\t\t\tk := strings.Split(opts, \",\")\n\n\t\t\tfor _, sk := range k {\n\t\t\t\tif sk == \"\" {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tkey, value := getKeyValFromTagOption(sk)\n\t\t\t\tswitch key {\n\t\t\t\tcase \"default\":\n\t\t\t\t\to.defValue = value\n\t\t\t\t\to.value = getTypedValue(o.defValue, o.oType)\n\t\t\t\t\to.updatedAt = time.Now().UTC()\n\t\t\t\t\to.lastSetBy = \"default\"\n\t\t\t\tcase \"info\":\n\t\t\t\t\to.usage = value\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func parseTag(tag string) (string, string) {\n\tif idx := strings.Index(tag, \",\"); idx != -1 {\n\t\treturn tag[:idx], strings.TrimSpace(tag[idx+1:])\n\t}\n\treturn tag, \"\"\n}", "func (p *Parser) FromStruct(ptr any) error {\n\tv := reflect.ValueOf(ptr)\n\tif v.Kind() != reflect.Ptr {\n\t\treturn errNotPtrValue\n\t}\n\n\tif !v.IsNil() {\n\t\tv = v.Elem()\n\t}\n\n\tt := v.Type()\n\tif t.Kind() != reflect.Struct {\n\t\treturn errNotAnStruct\n\t}\n\n\ttagName := p.cfg.TagName\n\tif tagName == \"\" {\n\t\ttagName = FlagTagName\n\t}\n\n\tvar mp map[string]string\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tsf := t.Field(i)\n\t\tname := sf.Name\n\n\t\t// skip cannot export field\n\t\tif name[0] >= 'a' && name[0] <= 'z' {\n\t\t\tcontinue\n\t\t}\n\n\t\t// eg: \"name=int0;shorts=i;required=true;desc=int option message\"\n\t\tstr := sf.Tag.Get(tagName)\n\t\tif str == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tfv := v.Field(i)\n\t\tft := t.Field(i).Type\n\t\tif !fv.CanInterface() {\n\t\t\tcontinue\n\t\t}\n\n\t\t// is pointer\n\t\t// var isPtr bool\n\t\t// var isNilPtr bool\n\t\tif ft.Kind() == reflect.Ptr {\n\t\t\t// isPtr = true\n\t\t\tif fv.IsNil() {\n\t\t\t\treturn fmt.Errorf(\"field: %s - nil pointer dereference\", name)\n\t\t\t}\n\n\t\t\tft = ft.Elem()\n\t\t\tfv = fv.Elem()\n\t\t}\n\n\t\tif p.cfg.TagRuleType == TagRuleNamed {\n\t\t\tmp = parseNamedRule(name, str)\n\t\t} else if p.cfg.TagRuleType == TagRuleSimple {\n\t\t\tmp = ParseSimpleRule(name, str)\n\t\t} else {\n\t\t\treturn errTagRuleType\n\t\t}\n\n\t\t// for create flag opt\n\t\toptName, has := mp[\"name\"]\n\t\tif !has { // use field as option name.\n\t\t\toptName = strutil.SnakeCase(name, \"-\")\n\t\t}\n\n\t\topt := newCliOpt(optName, mp[\"desc\"], mp[\"default\"], mp[\"shorts\"])\n\t\tif must, has := mp[\"required\"]; has {\n\t\t\topt.Required = strutil.MustBool(must)\n\t\t}\n\n\t\t// field is implements flag.Value\n\t\tif ft.Implements(flagValueType) {\n\t\t\tp.Var(fv.Interface().(flag.Value), opt)\n\t\t\tcontinue\n\t\t}\n\n\t\t// get field ptr addr\n\t\tptr := unsafe.Pointer(fv.UnsafeAddr())\n\t\tswitch ft.Kind() {\n\t\tcase reflect.Bool:\n\t\t\tp.BoolVar((*bool)(ptr), opt)\n\t\tcase reflect.Int:\n\t\t\tp.IntVar((*int)(ptr), opt)\n\t\t\t// if isNilPtr {\n\t\t\t// \tfv.SetInt(0)\n\t\t\t// \tnewPtr := unsafe.Pointer(fv.UnsafeAddr())\n\t\t\t// \tp.IntVar((*int)(newPtr), opt)\n\t\t\t// } else {\n\t\t\t// \tp.IntVar((*int)(ptr), opt)\n\t\t\t// }\n\t\tcase reflect.Int64:\n\t\t\tp.Int64Var((*int64)(ptr), opt)\n\t\tcase reflect.Uint:\n\t\t\tp.UintVar((*uint)(ptr), opt)\n\t\tcase reflect.Uint64:\n\t\t\tp.Uint64Var((*uint64)(ptr), opt)\n\t\tcase reflect.Float64:\n\t\t\tp.Float64Var((*float64)(ptr), opt)\n\t\tcase reflect.String:\n\t\t\tp.StrVar((*string)(ptr), opt)\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"field: %s - invalid type for binding flag\", name)\n\t\t}\n\t}\n\treturn nil\n}", "func (cmd *CmdStruct) SetTag(tag interface{}) {\n\tcmd.InternalTag = tag\n}", "func parseTagAndLength(bytes []byte, initOffset int) (ret tagAndLength, offset int, err error) {\n\toffset = initOffset\n\t// parseTagAndLength should not be called without at least a single\n\t// byte to read. Thus this check is for robustness:\n\tif offset >= len(bytes) || offset < 0 {\n\t\terr = errors.New(fmt.Sprintf(\"asn1: internal error in parseTagAndLength %s\", hex.EncodeToString(bytes)))\n\t\treturn\n\t}\n\tb := bytes[offset]\n\toffset++\n\tret.class = int(b >> 6)\n\tret.isCompound = b&0x20 == 0x20\n\tret.tag = int(b & 0x1f)\n\n\t// If the bottom five bits are set, then the tag number is actually base 128\n\t// encoded afterwards\n\tif ret.tag == 0x1f {\n\t\tret.tag, offset, err = parseBase128Int(bytes, offset)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\t// Tags should be encoded in minimal form.\n\t\tif ret.tag < 0x1f {\n\t\t\terr = SyntaxError{\"non-minimal tag\"}\n\t\t\treturn\n\t\t}\n\t}\n\tif offset >= len(bytes) {\n\t\terr = SyntaxError{\"truncated tag or length\"}\n\t\treturn\n\t}\n\tb = bytes[offset]\n\toffset++\n\tif b&0x80 == 0 {\n\t\t// The length is encoded in the bottom 7 bits.\n\t\tret.length = int(b & 0x7f)\n\t} else {\n\t\t// Bottom 7 bits give the number of length bytes to follow.\n\t\tnumBytes := int(b & 0x7f)\n\t\tif numBytes == 0 {\n\t\t\terr = SyntaxError{\"indefinite length found (not DER)\"}\n\t\t\treturn\n\t\t}\n\t\tret.length = 0\n\t\tfor i := 0; i < numBytes; i++ {\n\t\t\tif offset >= len(bytes) {\n\t\t\t\terr = SyntaxError{\"truncated tag or length\"}\n\t\t\t\treturn\n\t\t\t}\n\t\t\tb = bytes[offset]\n\t\t\toffset++\n\t\t\tif ret.length >= 1<<23 {\n\t\t\t\t// We can't shift ret.length up without\n\t\t\t\t// overflowing.\n\t\t\t\terr = StructuralError{\"length too large\"}\n\t\t\t\treturn\n\t\t\t}\n\t\t\tret.length <<= 8\n\t\t\tret.length |= int(b)\n\t\t\tif ret.length == 0 {\n\t\t\t\t// DER requires that lengths be minimal.\n\t\t\t\terr = StructuralError{\"superfluous leading zeros in length\"}\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\t// Short lengths must be encoded in short form.\n\t\tif ret.length < 0x80 {\n\t\t\terr = StructuralError{\"non-minimal length\"}\n\t\t\treturn\n\t\t}\n\t}\n\n\treturn\n}", "func (cmd *CmdStruct) Tag() interface{} {\n\treturn cmd.InternalTag\n}", "func parseTagFields(file *os.File) ([]TagField, []error) {\n\tvar errors []error\n\tre, err := regexp.Compile(`^(\\S*\\:)?(\\s.*)?$`)\n\tif err != nil {\n\t\terrors = append(errors, err)\n\t\treturn nil, errors\n\t}\n\n\tscanner := bufio.NewScanner(file)\n\tvar fields []TagField\n\tvar field TagField\n\n\t// Parse the remaining lines.\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\t// See http://play.golang.org/p/zLqvg2qo1D for some testing on the field match.\n\t\tif re.MatchString(line) {\n\t\t\tdata := re.FindStringSubmatch(line)\n\t\t\tdata[1] = strings.Replace(data[1], \":\", \"\", 1)\n\t\t\tif data[1] != \"\" {\n\t\t\t\tif field.Label() != \"\" {\n\t\t\t\t\tfields = append(fields, field)\n\t\t\t\t}\n\t\t\t\tfield = *NewTagField(data[1], strings.Trim(data[2], \" \"))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tvalue := strings.Trim(data[2], \" \")\n\t\t\tfield.SetValue(strings.Join([]string{field.Value(), value}, \" \"))\n\n\t\t} else {\n\t\t\terr := fmt.Errorf(\"Unable to parse tag data from line: %s\", line)\n\t\t\terrors = append(errors, err)\n\t\t}\n\t}\n\tif field.Label() != \"\" {\n\t\tfields = append(fields, field)\n\t}\n\n\tif scanner.Err() != nil {\n\t\terrors = append(errors, scanner.Err())\n\t}\n\n\t// See http://play.golang.org/p/nsw9zsAEPF for some testing on the field match.\n\treturn fields, errors\n}", "func TestTagField(t *testing.T) {\n\tschema := `{\n\t\t\"schema\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"options\": {\n\t\t\t\"type\": \"tag\"\n\t\t}\n\t}`\n\tdata := `[\"great\", \"wonderful\", \"ice cream\"]`\n\n\talpaca, err := New(AlpacaOptions{Schema: schema, Data: data})\n\tif err != nil {\n\t\tt.Fatalf(\"error: %s\", err)\n\t}\n\n\tresult := alpaca.Parse()\n\tif result != `[\"great\",\"wonderful\",\"ice cream\"]` {\n\t\tt.Fatalf(`Should return [\"great\",\"wonderful\",\"ice cream\"], instead returned %s`, result)\n\t}\n}", "func DecodeTiffTag(tag *tiff.Tag) interface{} {\n\ts := tag.String()\n\n\tif t, err := time.Parse(dateFormat, s); err == nil {\n\t\treturn t\n\t}\n\n\tif strings.HasPrefix(s, \"\\\"\") && strings.HasSuffix(s, \"\\\"\") {\n\t\treturn strings.Trim(s, \"\\\"\\\"\")\n\t}\n\n\tif i, err := strconv.ParseInt(s, 10, 64); err == nil {\n\t\treturn i\n\t}\n\n\tif f, err := strconv.ParseFloat(s, 64); err == nil {\n\t\treturn f\n\t}\n\n\treturn nil\n}", "func parseTag(tag string) (key string, opts map[string]string) {\n\topts = map[string]string{}\n\tfor i, s := range strings.Split(tag, \",\") {\n\t\tif i == 0 {\n\t\t\tkey = s\n\t\t\tcontinue\n\t\t}\n\n\t\tpp := strings.SplitN(s, \"=\", 2)\n\t\tif len(pp) == 1 {\n\t\t\topts[pp[0]] = \"\"\n\t\t} else {\n\t\t\topts[pp[0]] = pp[1]\n\t\t}\n\t}\n\treturn key, opts\n}", "func (p *Parser) parse(config reflect.Value) (bool, error) {\n\tvar tagFound bool\n\n\t// Look at each field of the struct\n\tt := config.Type()\n\n\tfor i := 0; i < t.NumField(); i++ {\n\t\t// Get the struct field tag data\n\t\tfield := t.Field(i)\n\t\tvalue := config.Field(i)\n\t\ttag, err := parseTag(field, p.Tag)\n\t\tif err != nil {\n\t\t\treturn tagFound, err\n\t\t}\n\n\t\t// Parse tagged fields\n\t\tif tag.Tagged {\n\t\t\ttagFound = true\n\n\t\t\t// Get the value from the LookupFn\n\t\t\terr = p.retrieve(value, tag)\n\t\t\tif err != nil {\n\t\t\t\treturn tagFound, err\n\t\t\t}\n\t\t}\n\n\t\t// If the field is a struct or pointer-to-struct, parse it\n\t\tif field.Type.Kind() == reflect.Struct || field.Type.Kind() == reflect.Ptr && field.Type.Elem().Kind() == reflect.Struct {\n\t\t\t// If the field is a pointer-to-struct, get the struct, not the pointer\n\t\t\tif field.Type.Kind() == reflect.Ptr {\n\t\t\t\t// If the pointer is nil, allocate memory first\n\t\t\t\tif value.IsNil() {\n\t\t\t\t\tvalue.Set(reflect.New(field.Type.Elem()))\n\t\t\t\t}\n\t\t\t\tvalue = value.Elem()\n\t\t\t}\n\n\t\t\tfound, err := p.parse(value)\n\n\t\t\t// First ensure that a tagged struct contains no tagged members\n\t\t\tif tag.Tagged && found {\n\t\t\t\treturn tagFound, NewErrNestedTags(field.Name, tag.Name)\n\t\t\t}\n\n\t\t\t// Handle any errors second\n\t\t\tif err != nil {\n\t\t\t\treturn tagFound, err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn tagFound, nil\n}", "func FromString(tagStr string) (Tagging, error) {\n\ttags, err := url.ParseQuery(tagStr)\n\tif err != nil {\n\t\treturn Tagging{}, err\n\t}\n\tvar idx = 0\n\tparsedTags := make([]Tag, len(tags))\n\tfor k := range tags {\n\t\tparsedTags[idx].Key = k\n\t\tparsedTags[idx].Value = tags.Get(k)\n\t\tidx++\n\t}\n\treturn Tagging{\n\t\tTagSet: TagSet{\n\t\t\tTags: parsedTags,\n\t\t},\n\t}, nil\n}", "func (r *Record) Tag(tag []byte) (v Aux, ok bool) {\n\tif len(tag) < 2 {\n\t\tpanic(\"sam: tag too short\")\n\t}\n\tfor _, aux := range r.AuxFields {\n\t\tif aux.matches(tag) {\n\t\t\treturn aux, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func (s *StructReader) ReadTag(target interface{}, each scanFn, tags ...string) errors.Error {\n\tif len(tags) == 0 {\n\t\treturn nil\n\t}\n\n\treturn s.Read(target, func(sf reflect.StructField, v reflect.Value) errors.Error {\n\t\tfor _, tag := range tags {\n\t\t\tif t, ok := sf.Tag.Lookup(tag); ok && t != \"\" {\n\t\t\t\tif err := each(sf, v); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t})\n}", "func parseRepoTag(s string) (string, string, error) {\n\tres := strings.Split(s, \":\")\n\tif len(res) != 2 {\n\t\treturn \"\", \"\", fmt.Errorf(\"could not parse image name %s\", s)\n\t}\n\treturn res[0], res[1], nil\n}", "func parse(field *reflectr.StructMeta, fieldValue string) (error, error) {\n\tr, err := field.\n\t\tMethod(\"Parse\").\n\t\tReturns(reflectr.ErrorType).\n\t\tCall(fieldValue)\n\tif err != nil {\n\t\treturn nil, errParseFieldValue\n\t}\n\treturn interfaceToError(r[0]), nil\n}", "func ParseTagAndWiretype(length uint32, data []byte, tag_out *uint32,\n\twiretype_out *ProtobufWireType) uint32 {\n\tvar max_rv uint32\n\n\tif length > 5 {\n\t\tmax_rv = 5\n\t} else {\n\t\tmax_rv = length\n\t}\n\n\tvar tag uint32 = uint32((uint8(data[0]) & 0x7f) >> 3)\n\tvar shift uint = 4\n\tvar rv uint32\n\n\t*wiretype_out = ProtobufWireType(data[0] & 7)\n\tif (data[0] & 0x80) == 0 {\n\t\t*tag_out = tag\n\t\treturn 1\n\t}\n\n\tfor rv = 1; rv < max_rv; rv++ {\n\t\tif r := uint8(data[rv]) & 0x80; r != 0 {\n\t\t\ttag = tag | uint32((uint8(data[rv])&0x7f)<<shift)\n\t\t\tshift += 7\n\t\t} else {\n\t\t\ttag = tag | uint32(uint8(data[rv])<<shift)\n\t\t\t*tag_out = tag\n\t\t\treturn rv + 1\n\t\t}\n\t}\n\treturn 0 /* error: bad header */\n}", "func ParseTags(v interface{}) error {\n\trv := reflect.ValueOf(v)\n\treturn ParseReflectTags(rv)\n}", "func TagFromReader(data io.Reader) (readTotal int, tag Tag, err error) {\n\tfirstByteDst := make([]byte, 1)\n\treadTotal, err = data.Read(firstByteDst)\n\tif err != nil {\n\t\treturn\n\t}\n\tfirstByte := firstByteDst[0]\n\ttag.Class = (TagClass(firstByte) & (b8 | b7)) >> 6\n\ttag.ConstructedEncoding = (firstByte & b6) > 0\n\tnumber := firstByte & 31\n\tif number < 31 {\n\t\ttag.Number = uint64(number)\n\t\treturn\n\t}\n\tvar bitSets []byte\n\tdst := make([]byte, 1)\n\tfor {\n\t\tdst[0] = 0\n\t\tn, readErr := data.Read(dst)\n\t\treadTotal += n\n\t\tif readErr != nil {\n\t\t\terr = fmt.Errorf(\"ran out of bytes before reaching the end of the tag: %w\", readErr)\n\t\t\treturn\n\t\t}\n\t\tnewBits := dst[0] & 0x7F\n\t\tbitSets = append(bitSets, newBits)\n\t\tif (dst[0] & b8) == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\tif len(bitSets) <= 10 && (len(bitSets) < 10 || bitSets[0] < 2) {\n\t\t// We can fit this into a 64 int\n\t\tu64 := uint64(0)\n\t\tfor i := 0; i < len(bitSets); i++ {\n\t\t\tu64 = u64 | (uint64(bitSets[len(bitSets)-1-i]) << (i * 7))\n\t\t}\n\t\ttag.Number = u64\n\t} else {\n\t\t// We need a *big.Int to store a number this big\n\t\t// Hopefully this never happens in reality\n\t\terr = fmt.Errorf(\"not implemented\")\n\t}\n\treturn\n}", "func ParseOneTag(ifdMapping *IfdMapping, tagIndex *TagIndex, fqIfdPath, ifdPath string, byteOrder binary.ByteOrder, tagBlock []byte, resolveValue bool) (tag *IfdTagEntry, err error) {\n\tdefer func() {\n\t\tif state := recover(); state != nil {\n\t\t\terr = log.Wrap(state.(error))\n\t\t}\n\t}()\n\n\tie := NewIfdEnumerate(ifdMapping, tagIndex, make([]byte, 0), byteOrder)\n\tite := NewIfdTagEnumerator(tagBlock, byteOrder, 0)\n\n\ttag, err = ie.parseTag(fqIfdPath, 0, ite, resolveValue)\n\tlog.PanicIf(err)\n\n\treturn tag, nil\n}", "func NewTagField(label string, value string) *TagField {\n\treturn &TagField{label, value}\n}", "func (field Field) TagGet(key string) (string, bool) {\n\tif field.Tag == nil {\n\t\treturn \"\", false\n\t}\n\ttags, err := structtag.Parse(strings.Trim(field.Tag.Value, \"`\"))\n\tif err != nil {\n\t\treturn \"\", false\n\t}\n\ttag, err := tags.Get(key)\n\tif err != nil {\n\t\treturn \"\", false\n\t}\n\treturn tag.Value(), true\n}", "func (d *Decoder) SetCustomStructTag(tag string) {\n\td.structTag = tag\n}", "func lexTag(l *lexer) stateFn {\n\tfor {\n\t\tswitch r := l.next(); {\n\t\tcase isIdentifierPrefix(r):\n\t\t\tl.backup()\n\t\t\treturn lexIdentifier(l, itemTag)\n\t\tcase r == ':':\n\t\t\tif n := l.next(); n != '\"' {\n\t\t\t\treturn l.errorf(`expected \" following :, got %q`, n)\n\t\t\t}\n\t\t\tl.emit(itemColonQuote)\n\t\t\treturn lexTagValues\n\t\tcase isSpace(r) || r == eof:\n\t\t\tl.backup()\n\t\t\treturn lexComment\n\t\tdefault:\n\t\t\treturn l.errorf(\"illegal character '%s' in tag name\", string(r))\n\t\t}\n\t}\n}", "func ProcessStruct(s interface{}) error {\n\tparentStruct := reflect.ValueOf(s).Elem()\n\tt := parentStruct.Type()\n\n\t// Loop through the fields on the struct, looking for tags.\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tf := t.Field(i)\n\t\tval := parentStruct.Field(i)\n\t\tfield := parentStruct.Type().Field(i)\n\t\tif tags, ok := f.Tag.Lookup(\"yamltags\"); ok {\n\t\t\tif err := ProcessTags(tags, val, parentStruct, field); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\t// Recurse down the struct\n\t\tif val.Kind() == reflect.Struct {\n\t\t\tif err := ProcessStruct(val.Addr().Interface()); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func ValidateTag(attribute string, tag string) error {\n\n\tif !tagRegex.MatchString(tag) {\n\t\treturn makeValidationError(attribute, fmt.Sprintf(\"'%s' must contain at least one '=' symbol separating two valid words\", tag))\n\t}\n\n\tif len([]byte(tag)) >= 1024 {\n\t\treturn makeValidationError(attribute, fmt.Sprintf(\"'%s' must be less than 1024 bytes\", tag))\n\t}\n\n\treturn nil\n}", "func ReadTag(r io.Reader) (Tag, error) {\n\tif r == nil {\n\t\treturn nil, io.EOF\n\t}\n\n\ttag := &tag{}\n\tif _, err := tag.ReadFrom(r); err != nil {\n\t\treturn nil, err\n\t}\n\treturn tag, nil\n}", "func getNameFromTag(f reflect.StructField, tagName string) string {\n\ttag, _ := parseTag(f, tagName)\n\tif tag != \"\" {\n\t\treturn tag\n\t}\n\treturn f.Name\n}", "func (ite *ifdTagEnumerator) ReadTag(ifd ifds.IFD) (t tag.Tag, err error) {\n\t// Read 12 bytes of Tag\n\tbuf, err := ite.ReadBuffer(12)\n\tif err != nil {\n\t\treturn\n\t}\n\ttagID := tag.ID(ite.byteOrder.Uint16(buf[:2])) // TagID\n\n\ttagTypeRaw := ite.byteOrder.Uint16(buf[2:4]) // TagType\n\n\tunitCount := ite.byteOrder.Uint32(buf[4:8]) // UnitCount\n\n\tvalueOffset := ite.byteOrder.Uint32(buf[8:12]) // ValueOffset\n\n\ttagType, err := tag.NewTagType(tagTypeRaw)\n\tif err != nil {\n\t\treturn t, err\n\t}\n\t// Creates a newTag. If the TypeFromRaw is unsupported, it returns tag.ErrTagTypeNotValid.\n\treturn tag.NewTag(tagID, tagType, unitCount, valueOffset, uint8(ifd)), err\n}", "func ValidateTag(tag string) error {\n\tif len(tag) > 1024 {\n\t\treturn ErrTagInvalidLength\n\t}\n\tif !tagRegexp.MatchString(tag) {\n\t\treturn ErrTagHasInvalidChars\n\t}\n\treturn nil\n}", "func ValidateTag(tag string) error {\n\tif len(tag) > 1024 {\n\t\treturn ErrTagInvalidLength\n\t}\n\tif !tagRegexp.MatchString(tag) {\n\t\treturn ErrTagHasInvalidChars\n\t}\n\treturn nil\n}", "func parsePromTagFromField(rsf reflect.StructField) *PrometheusMetric {\n\n\ttag := rsf.Tag.Get(\"prom\")\n\tprometheusTag := &PrometheusMetric{\n\t\tCustomCollectorFunc: nil,\n\t}\n\n\tif tag != \"\" {\n\n\t\t//TODO: Handle case where struct would not contain properly formatted tags\n\t\t//\t\tSince this is v0 - we will fix in prod release :)\n\t\tpromTagValues := strings.SplitN(tag, \";\", 2)\n\t\tprometheusTag.CounterDesc = promTagValues[1]\n\n\t\t//TODO: We can move this later on to more dynamic value mapping\n\t\t//\t\tor just simplify\n\t\tswitch promTagValues[0] {\n\t\tcase \"Gauge\":\n\t\t\tprometheusTag.CounterType = prometheus.GaugeValue\n\t\tcase \"Counter\":\n\t\t\tprometheusTag.CounterType = prometheus.CounterValue\n\t\tcase \"Untyped\":\n\t\t\tprometheusTag.CounterType = prometheus.UntypedValue\n\t\t}\n\n\t\treturn prometheusTag\n\t}\n\n\treturn nil\n}", "func parseStructField(cache structCache, key, sk, keytail string, values []string, target reflect.Value) {\n\tl, ok := cache[sk]\n\tif !ok {\n\t\tpanic(KeyError{\n\t\t\tFullKey: key,\n\t\t\tKey: kpath(key, keytail),\n\t\t\tType: target.Type(),\n\t\t\tField: sk,\n\t\t})\n\t}\n\tf := target.Field(l.offset)\n\n\tl.parse(key, keytail, values, f)\n}", "func parseTags(tag string) (ret block.Dict) {\n\tif len(tag) > 0 {\n\t\ttags := make(block.Dict)\n\t\tvisitTags(tag, func(k, v string) {\n\t\t\ttags[k] = parseCommas(v)\n\t\t})\n\t\tret = tags\n\t}\n\treturn\n}", "func (o *IscsiInterfaceGetIterRequest) SetTag(newValue string) *IscsiInterfaceGetIterRequest {\n\to.TagPtr = &newValue\n\treturn o\n}", "func execmStructTag(_ int, p *gop.Context) {\n\targs := p.GetArgs(2)\n\tret := args[0].(*types.Struct).Tag(args[1].(int))\n\tp.Ret(2, ret)\n}", "func (p *Parser) retrieve(v reflect.Value, tag tagData) error {\n\tvar bytes []byte\n\tvar err error\n\n\tvalue, found := p.LookupFn(tag.Name)\n\tif !found {\n\t\tif !tag.Optional {\n\t\t\treturn NewErrVarNotFound(tag.Name)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\t// Base64-decode if specified\n\tif tag.Base64 {\n\t\tbytes, err = base64.StdEncoding.DecodeString(value)\n\t\tif err != nil {\n\t\t\treturn NewErrDecodeFailure(err, tag.Name, value, \"base64\")\n\t\t}\n\t} else {\n\t\tbytes = []byte(value)\n\t}\n\n\t// JSON-decode if specified\n\tif tag.JSON {\n\t\tif v.Kind() == reflect.Ptr {\n\t\t\t// If v is a nil pointer, we need to allocate memory\n\t\t\tif v.IsNil() {\n\t\t\t\tv.Set(reflect.New(v.Type().Elem()))\n\t\t\t}\n\t\t} else {\n\t\t\t// We need a pointer to the struct for unmarshalling\n\t\t\tv = v.Addr()\n\t\t}\n\n\t\terr = json.Unmarshal(bytes, v.Interface())\n\t\tif err != nil {\n\t\t\treturn NewErrDecodeFailure(err, tag.Name, value, \"json\")\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tif v.Kind() == reflect.Ptr {\n\t\t// v is a Pointer; we need to allocate memory\n\t\tv.Set(reflect.New(v.Type().Elem()))\n\t\tv = v.Elem()\n\t}\n\n\terr = setValue(v, tag.Name, bytes)\n\n\treturn err\n}", "func ParseImageTag(s string) (string, string, string) {\n\tc := strings.LastIndex(s, \"/\")\n\tt := strings.LastIndex(s, \":\")\n\tif c < t {\n\t\treturn s[:t], s[c+1 : t], s[t+1:]\n\t}\n\treturn s, s[c+1:], \"\"\n}", "func ReadTag(raw string) string {\n\treturn readTagSequence([]rune(raw))\n}", "func ParseStruct(v interface{}, additionalFlags ...*Flag) error {\n\tflags, err := StructToFlags(v)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tflags = append(flags, additionalFlags...)\n\n\tconfig := &Config{\n\t\tFlagSet: DefaultFlagSet(),\n\t\tFlags: flags,\n\t}\n\n\treturn config.Parse(os.Args[1:])\n}", "func (o *InlineObject86) SetTag(v EventtypesJsonEventtype) {\n\to.Tag = &v\n}", "func Parse(ref string) (string, string, error) {\n\tdistributionRef, err := distreference.ParseNamed(ref)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\ttag := GetTagFromNamedRef(distributionRef)\n\treturn distributionRef.Name(), tag, nil\n}", "func (o *IscsiInitiatorGetIterRequest) SetTag(newValue string) *IscsiInitiatorGetIterRequest {\n\to.TagPtr = &newValue\n\treturn o\n}", "func ParseGeneric(b []byte) (*Generic, error) {\n\tg := &Generic{}\n\tif err := g.UnmarshalBinary(b); err != nil {\n\t\treturn nil, err\n\t}\n\treturn g, nil\n}", "func formTag(u *bsonTag) *model.Tag {\n\treturn &model.Tag{\n\t\tID: u.ID.Hex(),\n\t\tTag: u.Tag,\n\t\tUserID: u.UserID,\n\t\tExpireAt: u.ExpireAt,\n\t\tCreatedAt: u.CreatedAt,\n\t\tUpdatedAt: u.UpdatedAt,\n\t}\n}", "func (o *SmppTlv) SetTag(v int) {\n\to.Tag = &v\n}", "func (self *Map) Tag(key string) *Map {\n\tself.structTagKey = key\n\treturn self\n}", "func jsonFieldFromTag(tag reflect.StructTag) string {\n\tfield := strings.Split(tag.Get(\"json\"), \",\")[0]\n\tfor _, f := range strings.Split(tag.Get(\"protobuf\"), \",\") {\n\t\tif !strings.HasPrefix(f, \"json=\") {\n\t\t\tcontinue\n\t\t}\n\t\tfield = strings.TrimPrefix(f, \"json=\")\n\t}\n\treturn field\n}", "func ParseTagging(reader io.Reader) (*Tagging, error) {\n\tvar t Tagging\n\tif err := xml.NewDecoder(reader).Decode(&t); err != nil {\n\t\treturn nil, err\n\t}\n\tif err := t.Validate(); err != nil {\n\t\treturn nil, err\n\t}\n\treturn &t, nil\n}", "func parseNhFormTag(fieldT reflect.StructField) (label, name, fType string, id string, class string, ignored bool, required bool) {\n\ttags := strings.Split(fieldT.Tag.Get(\"form\"), \",\")\n\tlabel = fieldT.Name + \": \"\n\tname = fieldT.Name\n\tfType = \"text\"\n\tignored = false\n\tid = fieldT.Tag.Get(\"id\")\n\tclass = fieldT.Tag.Get(\"class\")\n\n\trequired = false\n\trequired_field := fieldT.Tag.Get(\"required\")\n\tif required_field != \"-\" && required_field != \"\" {\n\t\trequired, _ = strconv.ParseBool(required_field)\n\t}\n\n\tswitch len(tags) {\n\tcase 1:\n\t\tif tags[0] == \"-\" {\n\t\t\tignored = true\n\t\t}\n\t\tif len(tags[0]) > 0 {\n\t\t\tname = tags[0]\n\t\t}\n\tcase 2:\n\t\tif len(tags[0]) > 0 {\n\t\t\tname = tags[0]\n\t\t}\n\t\tif len(tags[1]) > 0 {\n\t\t\tfType = tags[1]\n\t\t}\n\tcase 3:\n\t\tif len(tags[0]) > 0 {\n\t\t\tname = tags[0]\n\t\t}\n\t\tif len(tags[1]) > 0 {\n\t\t\tfType = tags[1]\n\t\t}\n\t\tif len(tags[2]) > 0 {\n\t\t\tlabel = tags[2]\n\t\t}\n\t}\n\n\treturn\n}", "func parseTagKey(tag string) (string, bool, string, error) {\n\tparts := strings.Split(tag, \",\")\n\tif len(parts) == 0 {\n\t\treturn \"\", false, \"\", fmt.Errorf(\"empty tag\")\n\t}\n\tname, options := parts[0], parts[1:]\n\n\tvar defaultVal string\n\n\t// XXX: deprecated, required + default are kept here for backwards compatibility\n\t// use of \"default\" and \"validate\" tags is preferred\n\t// Iterate through the tag options to\n\t// find the required key.\n\tvar required bool\n\tfor _, o := range options {\n\t\to = strings.TrimSpace(o)\n\t\tif o == RequiredTag {\n\t\t\trequired = true\n\t\t} else if strings.HasPrefix(o, fmt.Sprintf(\"%s=\", DefaultTag)) {\n\t\t\tdefaultVal = strings.TrimPrefix(o, fmt.Sprintf(\"%s=\", DefaultTag))\n\t\t} else {\n\t\t\treturn \"\", false, \"\", fmt.Errorf(\"malformed tag for param '%s': unknown option '%s'\", name, o)\n\t\t}\n\t}\n\treturn name, required, defaultVal, nil\n}", "func (u *UUID) ParseField(t *Table, off int) (int, error) {\n\tub, err := t.GetBytesAt(off, 16)\n\tif err != nil {\n\t\treturn off, err\n\t}\n\tcopy(u[:], ub)\n\treturn off + 16, nil\n}", "func (o *VolumeModifyIterAsyncRequest) SetTag(newValue string) *VolumeModifyIterAsyncRequest {\n\to.TagPtr = &newValue\n\treturn o\n}", "func (m *Tag) UnmarshalJSON(data []byte) (e error) {\n\tmodel := struct {\n\t\tDescription *string `json:\"description\"`\n\t\tIsCostTracking *bool `json:\"isCostTracking\"`\n\t\tValidator basetagdefinitionvalidator `json:\"validator\"`\n\t\tName *string `json:\"name\"`\n\t}{}\n\n\te = json.Unmarshal(data, &model)\n\tif e != nil {\n\t\treturn\n\t}\n\tvar nn interface{}\n\tm.Description = model.Description\n\n\tm.IsCostTracking = model.IsCostTracking\n\n\tnn, e = model.Validator.UnmarshalPolymorphicJSON(model.Validator.JsonData)\n\tif e != nil {\n\t\treturn\n\t}\n\tif nn != nil {\n\t\tm.Validator = nn.(BaseTagDefinitionValidator)\n\t} else {\n\t\tm.Validator = nil\n\t}\n\n\tm.Name = model.Name\n\n\treturn\n}", "func Tag2Semver(tag string) *Semver {\n\n\tsemver := &Semver{}\n\n\tre, _ := regexp.Compile(\"(\\\\d+).(\\\\d+).(\\\\d+)\")\n\tsubs := re.FindStringSubmatch(tag)\n\n\tsemver.Major, _ = strconv.Atoi(subs[1])\n\tsemver.Minor, _ = strconv.Atoi(subs[2])\n\tsemver.Patch, _ = strconv.Atoi(subs[3])\n\n\treturn semver\n}", "func (o NetworkEndpointGroupCloudRunResponsePtrOutput) Tag() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *NetworkEndpointGroupCloudRunResponse) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.Tag\n\t}).(pulumi.StringPtrOutput)\n}", "func (a *Parser) parse(s string) error {\n\treturn a.parseBytes([]byte(s))\n}", "func (o *TagModelStore) SetTag(v string) {\n\to.Tag = v\n}", "func CidStructParse(data []byte) (CidStruct, error) {\n\tif len(data) == 34 && data[0] == 18 && data[1] == 32 {\n\t\th, err := mh.Cast(data)\n\t\tif err != nil {\n\t\t\treturn EmptyCidStruct, err\n\t\t}\n\t\treturn CidStruct{\n\t\t\tcodec: DagProtobuf,\n\t\t\tversion: 0,\n\t\t\thash: h,\n\t\t}, nil\n\t}\n\n\tvers, n := binary.Uvarint(data)\n\tif err := uvError(n); err != nil {\n\t\treturn EmptyCidStruct, err\n\t}\n\n\tif vers != 0 && vers != 1 {\n\t\treturn EmptyCidStruct, fmt.Errorf(\"invalid cid version number: %d\", vers)\n\t}\n\n\tcodec, cn := binary.Uvarint(data[n:])\n\tif err := uvError(cn); err != nil {\n\t\treturn EmptyCidStruct, err\n\t}\n\n\trest := data[n+cn:]\n\th, err := mh.Cast(rest)\n\tif err != nil {\n\t\treturn EmptyCidStruct, err\n\t}\n\n\treturn CidStruct{\n\t\tversion: vers,\n\t\tcodec: codec,\n\t\thash: h,\n\t}, nil\n}", "func (f *Field) Tag(key string) string {\n\treturn f.field.Tag.Get(key)\n}" ]
[ "0.7665988", "0.7565627", "0.70666677", "0.7003763", "0.69253194", "0.6555504", "0.6494551", "0.63994414", "0.6377795", "0.62923414", "0.6257043", "0.6251674", "0.6225439", "0.6202211", "0.6199089", "0.6185696", "0.6182165", "0.61815387", "0.61746836", "0.6147337", "0.6138106", "0.60189545", "0.5944552", "0.5913767", "0.5913767", "0.5906971", "0.5810632", "0.57792574", "0.57583445", "0.57430786", "0.5725845", "0.5662467", "0.5654401", "0.56440437", "0.5584924", "0.5575239", "0.5543807", "0.5538087", "0.5530598", "0.5522834", "0.5502602", "0.5487218", "0.54435843", "0.5441348", "0.54377264", "0.54325193", "0.5424501", "0.54176295", "0.5414474", "0.53948104", "0.53933996", "0.53805876", "0.5345208", "0.53399366", "0.53389966", "0.5296047", "0.52715707", "0.5262545", "0.52404153", "0.52301484", "0.522272", "0.5220749", "0.521611", "0.5208882", "0.5193165", "0.5173526", "0.5163742", "0.5155304", "0.5152758", "0.5152336", "0.5152336", "0.51506495", "0.51470554", "0.511162", "0.5107278", "0.5073543", "0.50709635", "0.5068639", "0.506773", "0.5065902", "0.5061332", "0.50535697", "0.5050461", "0.50494987", "0.5036474", "0.5024603", "0.5022365", "0.5021331", "0.501761", "0.5008631", "0.50022006", "0.4992904", "0.49928463", "0.49822527", "0.4974526", "0.49738574", "0.49676466", "0.49541333", "0.49523163", "0.4949732" ]
0.7106158
2
getIP returns the original IP address from the request, checking special headers before falling back to RemoteAddr.
func getIP(r *http.Request) string { if ip := r.Header.Get("CF-Connecting-IP"); ip != "" { return ip } if ip := r.Header.Get("X-Forwarded-For"); ip != "" { // Trim off any others: A.B.C.D[,X.X.X.X,Y.Y.Y.Y,] return strings.SplitN(ip, ",", 1)[0] } if ip, _, err := net.SplitHostPort(r.RemoteAddr); err == nil { return ip } return r.RemoteAddr }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func GetIP(r *http.Request) string {\n\tforwarded := r.Header.Get(\"X-FORWARDED-FOR\")\n\tif forwarded != \"\" {\n\t\treturn forwarded\n\t}\n\n\treturn r.RemoteAddr\n}", "func GetIP(r *http.Request) string {\n\tforwarded := r.Header.Get(\"X-FORWARDED-FOR\")\n\tif forwarded != \"\" {\n\t\treturn forwarded\n\t}\n\treturn r.RemoteAddr\n}", "func getIP(r *http.Request, trustForwardHeader bool) net.IP {\n\tif trustForwardHeader {\n\t\tip := r.Header.Get(\"X-Forwarded-For\")\n\t\tif ip != \"\" {\n\t\t\tparts := strings.SplitN(ip, \",\", 2)\n\t\t\tpart := strings.TrimSpace(parts[0])\n\t\t\treturn net.ParseIP(part)\n\t\t}\n\t\tip = strings.TrimSpace(r.Header.Get(\"X-Real-IP\"))\n\t\tif ip != \"\" {\n\t\t\treturn net.ParseIP(ip)\n\t\t}\n\t}\n\n\tremoteAddr := strings.TrimSpace(r.RemoteAddr)\n\thost, _, err := net.SplitHostPort(remoteAddr)\n\tif err != nil {\n\t\treturn net.ParseIP(remoteAddr)\n\t}\n\n\treturn net.ParseIP(host)\n}", "func GetIP(r *http.Request) string {\n\tfwd := r.Header.Get(\"X-FORWARDED-FOR\")\n\tif fwd != \"\" {\n\t\treturn fwd\n\t}\n\treturn r.RemoteAddr\n}", "func GetIP(r *http.Request) string {\n\taddr := r.Header.Get(\"X-Forwarded-For\")\n\tif addr != \"\" {\n\t\treturn addr\n\t}\n\treturn r.RemoteAddr\n}", "func GetIP(r *http.Request) (string, string) {\n\tfwd := r.Header.Get(\"X-Forwarded-For\")\n\taddrStr := \"\"\n\n\tif fwd != \"\" {\n\t\taddrStr = fwd\n\t} else {\n\t\taddrStr = r.RemoteAddr\n\t}\n\taddr := strings.Split(addrStr, \":\")\n\n\treturn addr[0], addr[1]\n}", "func GetIP(r *http.Request, options ...*KeyOptions) net.IP {\n\tif len(options) >= 1 && options[0].TrustForwardHeader {\n\t\tip := r.Header.Get(\"X-Forwarded-For\")\n\t\tif ip != \"\" {\n\t\t\tparts := strings.SplitN(ip, \",\", 2)\n\t\t\tpart := strings.TrimSpace(parts[0])\n\t\t\treturn net.ParseIP(part)\n\t\t}\n\n\t\tip = strings.TrimSpace(r.Header.Get(\"X-Real-IP\"))\n\t\tif ip != \"\" {\n\t\t\treturn net.ParseIP(ip)\n\t\t}\n\t}\n\n\tremoteAddr := strings.TrimSpace(r.RemoteAddr)\n\thost, _, err := net.SplitHostPort(remoteAddr)\n\tif err != nil {\n\t\treturn net.ParseIP(remoteAddr)\n\t}\n\n\treturn net.ParseIP(host)\n}", "func getIP(r *http.Request) string {\n\tvar addr string\n\n\tif fwd := r.Header.Get(xForwardedFor); fwd != \"\" {\n\t\t// Only grab the first (client) address. Note that '192.168.0.1,\n\t\t// 10.1.1.1' is a valid key for X-Forwarded-For where addresses after\n\t\t// the first may represent forwarding proxies earlier in the chain.\n\t\ts := strings.Index(fwd, \", \")\n\t\tif s == -1 {\n\t\t\ts = len(fwd)\n\t\t}\n\t\taddr = fwd[:s]\n\t} else if fwd := r.Header.Get(xRealIP); fwd != \"\" {\n\t\t// X-Real-IP should only contain one IP address (the client making the\n\t\t// request).\n\t\taddr = fwd\n\t} else if fwd := r.Header.Get(forwarded); fwd != \"\" {\n\t\t// match should contain at least two elements if the protocol was\n\t\t// specified in the Forwarded header. The first element will always be\n\t\t// the 'for=' capture, which we ignore. In the case of multiple IP\n\t\t// addresses (for=8.8.8.8, 8.8.4.4,172.16.1.20 is valid) we only\n\t\t// extract the first, which should be the client IP.\n\t\tif match := forRegex.FindStringSubmatch(fwd); len(match) > 1 {\n\t\t\t// IPv6 addresses in Forwarded headers are quoted-strings. We strip\n\t\t\t// these quotes.\n\t\t\taddr = strings.Trim(match[1], `\"`)\n\t\t}\n\t}\n\n\tif addr == \"\" {\n\t\treturn r.RemoteAddr\n\t}\n\treturn addr\n}", "func getIP(w http.ResponseWriter, req *http.Request) string {\n\n\tip, _, err := net.SplitHostPort(req.RemoteAddr)\n\tif err != nil {\n\t\tlog.Debugf(\"userip: %q is not IP:port\", req.RemoteAddr)\n\t}\n\n\tuserIP := net.ParseIP(ip)\n\tif userIP == nil {\n\t\treturn req.RemoteAddr\n\t}\n\n\t// This will only be defined when site is accessed via non-anonymous proxy\n\t// and takes precedence over RemoteAddr Header.Get is case-insensitive\n\tforward := req.Header.Get(\"X-Forwarded-For\")\n\treturn forward\n}", "func GetIPAddress(r *http.Request) string {\n\tip := \"\"\n\tfor _, h := range []string{\"X-Forwarded-For\", \"X-Real-Ip\"} {\n\t\taddresses := strings.Split(r.Header.Get(h), \",\")\n\t\t// march from right to left until we get a public address\n\t\t// that will be the address right before our proxy.\n\t\tfor i := len(addresses) - 1; i >= 0; i-- {\n\t\t\tip = strings.TrimSpace(addresses[i])\n\t\t\t// header can contain spaces too, strip those out.\n\t\t\trealIP := net.ParseIP(ip)\n\t\t\tif !realIP.IsGlobalUnicast() || IsPrivateSubnet(realIP) {\n\t\t\t\t// bad address, go to next\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn ip\n\t\t}\n\t}\n\n\tip, _, _ = net.SplitHostPort(r.RemoteAddr)\n\treturn ip\n}", "func GetClientIP(r *http.Request) string {\n remoteIP := \"\"\n if parts := strings.Split(r.RemoteAddr, \":\"); len(parts) == 2 {\n remoteIP = parts[0]\n }\n if xff := strings.Trim(r.Header.Get(\"X-Forwarded-For\"), \",\"); len(xff) > 0 {\n addrs := strings.Split(xff, \",\")\n lastFwd := addrs[len(addrs)-1]\n if ip := net.ParseIP(lastFwd); ip != nil {\n remoteIP = ip.String()\n }\n } else if xri := r.Header.Get(\"X-Real-Ip\"); len(xri) > 0 {\n if ip := net.ParseIP(xri); ip != nil {\n remoteIP = ip.String()\n }\n }\n return remoteIP\n}", "func GetRemoteIP(r *http.Request) string {\n\tremoteIP := \"\"\n\tif parts := strings.Split(r.RemoteAddr, \":\"); len(parts) == 2 {\n\t\tremoteIP = parts[0]\n\t}\n\n\tif xff := strings.Trim(r.Header.Get(\"X-Forwarded-For\"), \",\"); len(xff) > 0 {\n\t\taddrs := strings.Split(xff, \",\")\n\t\tlastFwd := addrs[len(addrs)-1]\n\t\tif ip := net.ParseIP(lastFwd); ip != nil {\n\t\t\tremoteIP = ip.String()\n\t\t}\n\t} else if xri := r.Header.Get(\"X-Real-Ip\"); len(xri) > 0 {\n\t\tif ip := net.ParseIP(xri); ip != nil {\n\t\t\tremoteIP = ip.String()\n\t\t}\n\t}\n\n\treturn remoteIP\n}", "func GetRemoteIP(r *http.Request) string {\n\tips := r.Header.Get(\"X-Forwarded-For\")\n\n\tsplitIps := strings.Split(ips, \",\")\n\n\tif ips != \"\" {\n\t\t// trim IP list\n\t\tfor i := range splitIps {\n\t\t\tsplitIps[i] = strings.TrimSpace(splitIps[i])\n\t\t}\n\n\t\t// get last IP in list since ELB prepends other user defined IPs, meaning the last one is the actual client IP.\n\t\tnetIP := net.ParseIP(splitIps[0])\n\t\tif netIP != nil {\n\t\t\treturn netIP.String()\n\t\t}\n\t}\n\n\tip, _, err := net.SplitHostPort(r.RemoteAddr)\n\tif err != nil {\n\t\treturn r.RemoteAddr\n\t}\n\n\tnetIP := net.ParseIP(ip)\n\tif netIP != nil {\n\t\tip := netIP.String()\n\t\tif ip == \"::1\" {\n\t\t\treturn \"127.0.0.1\"\n\t\t}\n\t\treturn ip\n\t}\n\n\treturn r.RemoteAddr\n}", "func GetIP(site, UserAgent string) string {\n\treturn getAPIResponse(site, UserAgent).ResponseIP\n}", "func findIP(req *http.Request) (string, error) {\n\tif xri := req.Header.Get(\"x-real-ip\"); xri != \"\" {\n\t\treturn xri, nil\n\t}\n\tif xff := req.Header.Get(\"x-forwarded-for\"); xff != \"\" {\n\t\tips := strings.Split(xff, \",\")\n\t\treturn ips[0], nil\n\t}\n\tip, _, err := net.SplitHostPort(req.RemoteAddr)\n\treturn ip, err\n\n}", "func getIP() (net.IP, error) {\n\tres, err := http.Get(\"http://checkip.amazonaws.com/\")\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer res.Body.Close()\n\tresData, err := ioutil.ReadAll(res.Body)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trawIP := strings.Trim(string(resData), \"\\n\")\n\n\treturn net.ParseIP(rawIP), nil\n}", "func extractIP(r *http.Request) (string, error) {\n\t// if not a proper remote addr, return empty\n\tif !strings.ContainsRune(r.RemoteAddr, ':') {\n\t\treturn \"\", errors.New(\"lol\")\n\t}\n\tipAddr, _, err := net.SplitHostPort(r.RemoteAddr)\n\tif err != nil || ipAddr == \"\" {\n\t\treturn \"\", errors.New(\"Request has failed origin validation. Please retry.\")\n\t}\n\treturn ipAddr, nil\n}", "func GetClientIp(r *http.Request) string {\n\tclientIp := r.Header.Get(XRealIp)\n\tif clientIp == \"\" {\n\t\tclientIp = \"UNKNOWN_IP\"\n\t}\n\treturn clientIp\n}", "func remoteIP(req *http.Request) (remote string) {\n\tif remote = req.Header.Get(_httpHeaderRemoteIP); remote != \"\" && remote != \"null\" {\n\t\treturn\n\t}\n\tvar xff = req.Header.Get(\"X-Forwarded-For\")\n\tif idx := strings.IndexByte(xff, ','); idx > -1 {\n\t\tif remote = strings.TrimSpace(xff[:idx]); remote != \"\" {\n\t\t\treturn\n\t\t}\n\t}\n\tif remote = req.Header.Get(\"X-Real-IP\"); remote != \"\" {\n\t\treturn\n\t}\n\tremote = req.RemoteAddr[:strings.Index(req.RemoteAddr, \":\")]\n\treturn\n}", "func GetClientIPHelper(req *http.Request) (ipResult string, errResult error) {\n\n\t// Try lots of ways :) Order is important.\n\t// Try Request Headers (X-Forwarder). Client could be behind a Proxy\n\tip, err := getClientIPByHeaders(req)\n\tif err == nil {\n\t\t// log.Printf(\"debug: Found IP using Request Headers sniffing. ip: %v\", ip)\n\t\treturn ip, nil\n\t}\n\n\t// Try by Request\n\tip, err = getClientIPByRequestRemoteAddr(req)\n\tif err == nil {\n\t\t// log.Printf(\"debug: Found IP using Request sniffing. ip: %v\", ip)\n\t\treturn ip, nil\n\t}\n\n\t// Try Request Header (\"Origin\")\n\turl, err := url.Parse(req.Header.Get(\"Origin\"))\n\tif err == nil {\n\t\thost := url.Host\n\t\tip, _, err := net.SplitHostPort(host)\n\t\tif err == nil {\n\t\t\t// log.Printf(\"debug: Found IP using Header (Origin) sniffing. ip: %v\", ip)\n\t\t\treturn ip, nil\n\t\t}\n\t}\n\n\terr = errors.New(\"error: Could not find clients IP address\")\n\treturn \"\", err\n}", "func GetRemoteAddr(r *http.Request) string {\n\tip := r.Header.Get(\"CF-Connecting-IP\")\n\tif ip == \"\" {\n\t\treturn r.RemoteAddr\n\t}\n\treturn ip\n}", "func GetClientIP(r *http.Request) string {\n\t// Header X-Forwarded-For\n\thdrForwardedFor := http.CanonicalHeaderKey(\"X-Forwarded-For\")\n\tif fwdFor := strings.TrimSpace(r.Header.Get(hdrForwardedFor)); fwdFor != \"\" {\n\t\tindex := strings.Index(fwdFor, \",\")\n\t\tif index == -1 {\n\t\t\treturn fwdFor\n\t\t}\n\t\treturn fwdFor[:index]\n\t}\n\n\t// Header X-Real-Ip\n\thdrRealIP := http.CanonicalHeaderKey(\"X-Real-Ip\")\n\tif realIP := strings.TrimSpace(r.Header.Get(hdrRealIP)); realIP != \"\" {\n\t\treturn realIP\n\t}\n\n\treturn \"10.82.33.161\"\n}", "func getClientIPByRequestRemoteAddr(req *http.Request) (ip string, err error) {\n\n\t// Try via request\n\tip, _, err = net.SplitHostPort(req.RemoteAddr)\n\tif err != nil {\n\t\t// log.Printf(\"debug: Getting req.RemoteAddr %v\", err)\n\t\treturn \"\", err\n\t} else {\n\t\t// log.Printf(\"debug: With req.RemoteAddr found IP:%v; Port: %v\", ip, port)\n\t}\n\n\tuserIP := net.ParseIP(ip)\n\tif userIP == nil {\n\t\tmessage := fmt.Sprintf(\"debug: Parsing IP from Request.RemoteAddr got nothing.\")\n\t\t// log.Printf(message)\n\t\treturn \"\", fmt.Errorf(message)\n\n\t}\n\t// log.Printf(\"debug: Found IP: %v\", userIP)\n\treturn userIP.String(), nil\n\n}", "func remoteIP(r *http.Request) (remote string) {\n\tremote = r.Header.Get(\"X-BACKEND-BILI-REAL-IP\")\n\tif remote != \"\" && remote != \"null\" {\n\t\treturn\n\t}\n\tremote = r.Header.Get(\"X-Real-IP\")\n\tif remote != \"\" {\n\t\treturn\n\t}\n\tremote = r.Header.Get(\"X-Forwarded-For\")\n\tif idx := strings.LastIndex(remote, \",\"); idx > -1 {\n\t\tif remote = strings.TrimSpace(remote[idx+1:]); remote != \"\" {\n\t\t\treturn\n\t\t}\n\t}\n\tremote = r.RemoteAddr[0:strings.Index(r.RemoteAddr, \":\")]\n\treturn\n}", "func GetIP() (ip string, err error) {\n\tvar res *http.Response\n\tif res, err = http.Get(API); err != nil {\n\t\treturn\n\t}\n\n\t// We could just get the string but for the sake of\n\t// consistency we go json.\n\tresIP := new(IPResponse)\n\tif err = json.NewDecoder(res.Body).Decode(resIP); err != nil {\n\t\treturn\n\t}\n\n\tip = resIP.IP\n\treturn\n}", "func getRemoteIP() (ip string, err error) {\n\tclient := &http.Client{\n\t\tTimeout: time.Second * 10,\n\t}\n\n\treq, err := http.NewRequest(\"GET\", \"http://ip.cn\", nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tres, err := client.Do(req)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tdefer res.Body.Close()\n\n\tdata, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tip = string(ipPattern.Find(data))\n\n\treturn\n}", "func GetClientIP(r *http.Request, headers ...string) string {\n\tfor _, header := range headers {\n\t\tip := r.Header.Get(header)\n\t\tif ip != \"\" {\n\t\t\treturn strings.Split(ip, \",\")[0]\n\t\t}\n\t}\n\treturn strings.Split(r.RemoteAddr, \":\")[0]\n}", "func (v *Client) IP() string {\n\tif v.ip == \"\" {\n\t\tip := strings.TrimSpace(v.req.Header.Get(\"X-Real-Ip\"))\n\t\tif len(ip) > 0 {\n\t\t\tv.ip = ip\n\t\t\treturn ip\n\t\t}\n\t\tip = v.req.Header.Get(\"X-Forwarded-For\")\n\t\tif index := strings.IndexByte(ip, ','); index >= 0 {\n\t\t\tip = ip[0:index]\n\t\t}\n\t\tip = strings.TrimSpace(ip)\n\t\tif len(ip) > 0 {\n\t\t\tv.ip = ip\n\t\t\treturn ip\n\t\t}\n\t\tif ip, _, err := net.SplitHostPort(strings.TrimSpace(v.req.RemoteAddr)); err == nil {\n\t\t\tv.ip = ip\n\t\t\treturn ip\n\t\t}\n\t}\n\treturn v.ip\n}", "func HandleGetIP(ctx *gin.Context) {\n\tip, port, err := net.SplitHostPort(ctx.Request.RemoteAddr)\n\tif err != nil {\n\t\tglog.Error(err.Error())\n\t\tctx.JSON(500, gin.H{\"result\": \"internal server error\"})\n\t\treturn\n\t}\n\n\tglog.Info(\"Incoming request /getip:\" + ip + \":\" + port)\n\t// Only return the IP, even though we have their source ephemeral port.\n\tctx.JSON(200, gin.H{\"ip\": ip})\n}", "func evaluateIPAddress(req *http.Request) (*ipAddress, error) {\n\tresult := ipAddress{}\n\tip, _, err := net.SplitHostPort(req.RemoteAddr)\n\tif err != nil {\n\t\treturn &result, fmt.Errorf(\"The user IP: %q is not IP:port\", req.RemoteAddr)\n\t}\n\n\t// If the client is behind a non-anonymous proxy, the IP address is in the X-Forwarded-For header.\n\t// req.Header.Get is case-insensitive.\n\tresult.IPAddressV4 = req.Header.Get(\"X-Forwarded-For\")\n\tif result.IPAddressV4 == \"\" {\n\t\t// If no header can be read, directly extract the address for the request.\n\t\tuserIP := net.ParseIP(ip)\n\t\tif userIP == nil {\n\t\t\treturn &result, fmt.Errorf(\"The user IP: %q is not IP:port\", req.RemoteAddr)\n\t\t}\n\t\tresult.IPAddressV4 = userIP.String()\n\t\tresult.Source = \"Remote address\"\n\t} else {\n\t\tresult.Source = \"X-Forwarded-For\"\n\t}\n\treturn &result, nil\n}", "func (i *Client) GetIP() (string, error) {\n\thttpClient := i.HTTPClient\n\tif httpClient == nil {\n\t\thttpClient = http.DefaultClient\n\t}\n\n\tres, err := httpClient.Get(baseURL)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer res.Body.Close()\n\n\tip, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn string(ip), nil\n}", "func IP(c *fiber.Ctx) string {\n\tvar headerValue []byte\n\tif c.App().Config().ProxyHeader == \"*\" {\n\t\tfor _, headerName := range possibleHeaderes {\n\t\t\theaderValue = c.Request().Header.Peek(headerName)\n\t\t\tif len(headerValue) > 3 {\n\t\t\t\treturn string(fetchIpFromString.Find(headerValue))\n\t\t\t}\n\t\t}\n\t}\n\theaderValue = []byte(c.IP())\n\tif len(headerValue) <= 3 {\n\t\theaderValue = []byte(\"0.0.0.0\")\n\t}\n\n\t// find ip address in string\n\treturn string(fetchIpFromString.Find(headerValue))\n}", "func ipAddr(r *http.Request) string {\n\tip := r.Header.Get(\"X-Real-Ip\")\n\tif ip == \"\" {\n\t\tip = strings.Split(r.Header.Get(\"X-Forwarded-For\"), \", \")[0]\n\t}\n\tif ip == \"\" {\n\t\tip = strings.Split(r.RemoteAddr, \":\")[0]\n\t}\n\treturn ip\n}", "func (registry *Registry) GetIP(_, reply *string) error {\n\t*reply = registryService.GetIP()\n\treturn nil\n}", "func getIP(url string) string {\n\tres, err := http.Get(url)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\n\tdefer res.Body.Close()\n\tb, _ := io.ReadAll(res.Body)\n\treturn string(b)\n}", "func realIP(r *http.Request) string {\n\txRealIP := r.Header.Get(\"X-Real-Ip\")\n\tif xRealIP != \"\" {\n\t\treturn xRealIP\n\t}\n\txForwardedFor := r.Header.Get(\"X-Forwarded-For\")\n\tfor _, address := range strings.Split(xForwardedFor, \",\") {\n\t\taddress = strings.TrimSpace(address)\n\t\tif address != \"\" {\n\t\t\treturn address\n\t\t}\n\t}\n\n\tip, _, err := net.SplitHostPort(r.RemoteAddr)\n\tif err != nil {\n\t\treturn r.RemoteAddr\n\t}\n\treturn ip\n}", "func realIP(r *http.Request) string {\n\txRealIP := r.Header.Get(\"X-Real-Ip\")\n\tif xRealIP != \"\" {\n\t\treturn xRealIP\n\t}\n\txForwardedFor := r.Header.Get(\"X-Forwarded-For\")\n\tfor _, address := range strings.Split(xForwardedFor, \",\") {\n\t\taddress = strings.TrimSpace(address)\n\t\tif address != \"\" {\n\t\t\treturn address\n\t\t}\n\t}\n\n\tip, _, err := net.SplitHostPort(r.RemoteAddr)\n\tif err != nil {\n\t\treturn r.RemoteAddr\n\t}\n\treturn ip\n}", "func RequestClientIP(req *http.Request) (net.IP, error) {\n\trealIp := req.Header.Get(\"X-Real-IP\")\n\t// ip, _, err := net.SplitHostPort(req.RemoteAddr)\n\t// if err != nil {\n\t// \treturn nil, fmt.Errorf(\"userip: %q is not IP:port\", req.RemoteAddr)\n\t// }\n\t//\n\t// userIP := net.ParseIP(ip)\n\t// if userIP == nil {\n\t// \treturn nil, fmt.Errorf(\"userip: %q is not IP:port\", req.RemoteAddr)\n\t// }\n\t// return userIP, nil\n\treturn net.ParseIP(realIp), nil\n}", "func getRemoteIP() (ip string, err error) {\n\tclient := &http.Client{\n\t\tTimeout: time.Second * 30,\n\t}\n\n\treq, err := http.NewRequest(\"GET\", \"http://ifconfig.me\", nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treq.Header.Set(\"User-Agent\", \"curl\")\n\tres, err := client.Do(req)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tdefer res.Body.Close()\n\n\tdata, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn\n\t}\n\tip = string(data)\n\n\treturn\n}", "func GetIPAddress(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tplainAddress := vars[\"domainName\"]\n\tif reply, ok := servers[plainAddress]; ok {\n\t\tw.WriteHeader(http.StatusOK)\n\t\tif enc, err := json.Marshal(reply); err == nil {\n\t\t\tw.Write([]byte(enc))\n\t\t} else {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t}\n\t} else {\n\t\treply := r.RemoteAddr\n\t\tif enc, err := json.Marshal(reply); err == nil {\n\t\t\tw.Write([]byte(enc))\n\t\t} else {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t}\n\t}\n}", "func GetClientIPAddress(r *http.Request) string {\n\tip := r.Header.Get(\"X-Forwarded-For\")\n\tif ip != \"\" {\n\t\titems := strings.Split(ip, \",\")\n\t\tfor i := len(items) - 1; i >= 0; i-- {\n\t\t\titem := strings.Trim(items[i], \" \")\n\t\t\tif item != \"127.0.0.1\" && !strings.HasPrefix(item, \"10.\") {\n\t\t\t\treturn item\n\t\t\t}\n\t\t}\n\t}\n\t// Try parsing remote address.\n\thost, _, err := net.SplitHostPort(r.RemoteAddr)\n\tif err == nil {\n\t\treturn host\n\t}\n\t// Fallback method.\n\tif strings.HasPrefix(r.RemoteAddr, \"[\") {\n\t\tparts := strings.Split(r.RemoteAddr, \"]\")\n\t\treturn parts[0][1:]\n\t}\n\tparts := strings.Split(r.RemoteAddr, \":\")\n\treturn parts[0]\n}", "func IP(w http.ResponseWriter, r *http.Request) {\n\tremoteAddr := r.Header.Get(\"X-Forwarded-For\")\n\n\tif remoteAddr == \"\" {\n\t\thost, _, err := net.SplitHostPort(r.RemoteAddr)\n\t\tif err != nil {\n\t\t\tlog.Fatalln(err)\n\t\t}\n\t\tremoteAddr = host\n\t}\n\n\tfmt.Fprintln(w, remoteAddr)\n}", "func ClientIP(r *http.Request) string {\n\tIPAddress := r.Header.Get(\"X-Real-Ip\")\n\tif IPAddress == \"\" {\n\t\tIPAddress = r.Header.Get(\"X-Forwarded-For\")\n\t}\n\n\tif IPAddress == \"\" {\n\t\tIPAddress = r.RemoteAddr\n\t}\n\n\treturn IPAddress\n}", "func (c *Context) GetClientIP() (ip string) {\n\tvar pIPs string\n\tvar pIPList []string\n\n\tif pIPs = c.Request.Header.Get(\"X-Real-Ip\"); pIPs != \"\" {\n\t\tpIPList = strings.Split(pIPs, \",\")\n\t\tip = strings.TrimSpace(pIPList[0])\n\n\t} else if pIPs = c.Request.Header.Get(\"Real-Ip\"); pIPs != \"\" {\n\t\tpIPList = strings.Split(pIPs, \",\")\n\t\tip = strings.TrimSpace(pIPList[0])\n\n\t} else if pIPs = c.Request.Header.Get(\"X-Forwarded-For\"); pIPs != \"\" {\n\t\tpIPList = strings.Split(pIPs, \",\")\n\t\tip = strings.TrimSpace(pIPList[0])\n\n\t} else if pIPs = c.Request.Header.Get(\"X-Forwarded\"); pIPs != \"\" {\n\t\tpIPList = strings.Split(pIPs, \",\")\n\t\tip = strings.TrimSpace(pIPList[0])\n\n\t} else if pIPs = c.Request.Header.Get(\"Forwarded-For\"); pIPs != \"\" {\n\t\tpIPList = strings.Split(pIPs, \",\")\n\t\tip = strings.TrimSpace(pIPList[0])\n\n\t} else if pIPs = c.Request.Header.Get(\"Forwarded\"); pIPs != \"\" {\n\t\tpIPList = strings.Split(pIPs, \",\")\n\t\tip = strings.TrimSpace(pIPList[0])\n\n\t} else {\n\t\tip = c.Request.RemoteAddr\n\t}\n\n\treturn strings.Split(ip, \":\")[0]\n}", "func GetClientIPFromRequest(request *http.Request) string {\n\tforwaredeFor := request.Header.Get(\"X-FORWARDED-FOR\")\n\tif forwaredeFor != \"\" {\n\t\treturn forwaredeFor\n\t}\n\t// RemoteAddr allows HTTP servers and other software to\n\t// record the network address that sent the request,\n\t// usually for logging. This field is not filled in by\n\t// ReadRequest and has no defined format.\n\t// The HTTP server in this package sets RemoteAddr to an\n\t// \"IP:port\" address before invoking a handler.\n\t// This field is ignored by the HTTP client.\n\treturn request.RemoteAddr\n}", "func GetClientIP(c *gin.Context) string {\n\t// first check the X-Forwarded-For header\n\trequester := c.Request.Header.Get(\"X-Forwarded-For\")\n\t// if empty, check the Real-IP header\n\tif len(requester) == 0 {\n\t\trequester = c.Request.Header.Get(\"X-Real-IP\")\n\t}\n\t// if the requester is still empty, use the hard-coded address from the socket\n\tif len(requester) == 0 {\n\t\trequester = c.Request.RemoteAddr\n\t}\n\n\t// if requester is a comma delimited list, take the first one\n\t// (this happens when proxied via elastic load balancer then again through nginx)\n\tif strings.Contains(requester, \",\") {\n\t\trequester = strings.Split(requester, \",\")[0]\n\t}\n\n\treturn requester\n}", "func GetClientIP(c *gin.Context) string {\n\t// first check the X-Forwarded-For header\n\trequester := c.Request.Header.Get(\"X-Forwarded-For\")\n\t// if empty, check the Real-IP header\n\tif len(requester) == 0 {\n\t\trequester = c.Request.Header.Get(\"X-Real-IP\")\n\t}\n\t// if the requester is still empty, use the hard-coded address from the socket\n\tif len(requester) == 0 {\n\t\trequester = c.Request.RemoteAddr\n\t}\n\n\t// if requester is a comma delimited list, take the first one\n\t// (this happens when proxied via elastic load balancer then again through nginx)\n\tif strings.Contains(requester, \",\") {\n\t\trequester = strings.Split(requester, \",\")[0]\n\t}\n\n\treturn requester\n}", "func extractIP(c *gin.Context) string {\n\tip := c.Request.Header.Get(\"X-Real-IP\")\n\tif ip == \"\" {\n\t\tip = c.Request.Header.Get(\"X-Forwarded-For\")\n\t}\n\tif ip == \"\" {\n\t\tremoteAddr := c.Request.RemoteAddr\n\t\tif remoteAddr != \"\" {\n\t\t\taddrPort := strings.Split(remoteAddr, \":\")\n\t\t\tip = addrPort[0]\n\t\t}\n\t}\n\n\t//Case when Nginx concatenate remote_addr to client addr\n\tif strings.Contains(ip, \",\") {\n\t\taddresses := strings.Split(ip, \",\")\n\t\treturn strings.TrimSpace(addresses[0])\n\t}\n\n\treturn ip\n}", "func (r *Request) RealIP() string {\n\tif len(r.realIP) > 0 {\n\t\treturn r.realIP\n\t}\n\tr.realIP = r.RemoteAddress()\n\tif ip := r.header.Get(echo.HeaderXForwardedFor); len(ip) > 0 {\n\t\tr.realIP = ip\n\t} else if ip := r.header.Get(echo.HeaderXRealIP); len(ip) > 0 {\n\t\tr.realIP = ip\n\t} else {\n\t\tr.realIP, _, _ = net.SplitHostPort(r.realIP)\n\t}\n\treturn r.realIP\n}", "func requestGetRemoteAddress(r *http.Request) string {\n\thdr := r.Header\n\thdrRealIP := hdr.Get(\"X-Real-Ip\")\n\thdrForwardedFor := hdr.Get(\"X-Forwarded-For\")\n\tif hdrRealIP == \"\" && hdrForwardedFor == \"\" {\n\t\treturn ipAddrFromRemoteAddr(r.RemoteAddr)\n\t}\n\tif hdrForwardedFor != \"\" {\n\t\t// X-Forwarded-For is potentially a list of addresses separated with \",\"\n\t\tparts := strings.Split(hdrForwardedFor, \",\")\n\t\tfor i, p := range parts {\n\t\t\tparts[i] = strings.TrimSpace(p)\n\t\t}\n\t\t// TODO: should return first non-local address\n\t\treturn parts[0]\n\t}\n\treturn hdrRealIP\n}", "func (c *Ctx) IP() string {\n\tif len(c.Core.ProxyHeader) > 0 {\n\t\treturn c.Get(c.Core.ProxyHeader)\n\t}\n\treturn c.RemoteIP().String()\n}", "func (test *Test) GetIP(projectName string, ip string) (models.IP, error) {\n\treturn tests.NormalIPs[0], nil\n}", "func getRemoteAddress(r *http.Request) string {\n\thdr := r.Header\n\thdrRealIP := hdr.Get(\"X-Real-Ip\")\n\thdrForwardedFor := hdr.Get(\"X-Forwarded-For\")\n\tif hdrRealIP == \"\" && hdrForwardedFor == \"\" {\n\t\treturn ipAddrFromRemoteAddr(r.RemoteAddr)\n\t}\n\tif hdrForwardedFor != \"\" {\n\t\t// X-Forwarded-For is potentially a list of addresses separated with \",\"\n\t\tparts := strings.Split(hdrForwardedFor, \",\")\n\t\tfor i, p := range parts {\n\t\t\tparts[i] = strings.TrimSpace(p)\n\t\t}\n\t\t// TODO: should return first non-local address\n\t\treturn parts[0]\n\t}\n\treturn hdrRealIP\n}", "func (c *Client) GetIP(id string, privateIPOnly bool) (string, error) {\n\tvar (\n\t\tmethod = \"GET\"\n\t\turi = fmt.Sprintf(\"%s/%s\", \"server\", id)\n\t)\n\n\tdata, err := c.newRequest(method, uri, nil)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tvar s sakura.Response\n\tif err := json.Unmarshal(data, &s); err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif privateIPOnly && len(s.Server.Interfaces) > 1 {\n\t\treturn s.Server.Interfaces[1].UserIPAddress, nil\n\t}\n\n\treturn s.Server.Interfaces[0].IPAddress, nil\n}", "func ReadUserIP(r *http.Request) string {\n\tIPAddress := r.Header.Get(\"X-Real-Ip\")\n\tif IPAddress == \"\" {\n\t\tIPAddress = r.Header.Get(\"X-Forwarded-For\")\n\t}\n\tif IPAddress == \"\" {\n\t\tIPAddress = r.RemoteAddr\n\t}\n\treturn IPAddress\n}", "func IPFromRequest(r *http.Request) string {\n\theaderIP := r.Header.Get(CsioClientIPHeader)\n\tif headerIP != \"\" {\n\t\treturn IPFromAddr(headerIP)\n\t}\n\treturn IPFromAddr(r.RemoteAddr)\n}", "func remoteAddr( r *http.Request ) net.IP {\n forwardedFor := r.Header.Get( \"X-Forwarded-For\" )\n if forwardedFor != \"\" {\n // Syntax on MDN: X-Forwarded-For: <client>, <proxy1>, <proxy2>\n ip := strings.Split( forwardedFor, \", \" )[0]\n if !(strings.HasPrefix( ip, \"10.\" ) ||\n strings.HasPrefix( ip, \"192.168.\" ) ||\n strings.HasPrefix( ip, \"172.16.\" ) ||\n strings.HasPrefix( ip, \"172.17.\" ) ||\n strings.HasPrefix( ip, \"172.18.\" ) ||\n strings.HasPrefix( ip, \"172.19.\" ) ||\n strings.HasPrefix( ip, \"172.20.\" ) ||\n strings.HasPrefix( ip, \"172.21.\" ) ||\n strings.HasPrefix( ip, \"172.22.\" ) ||\n strings.HasPrefix( ip, \"172.23.\" ) ||\n strings.HasPrefix( ip, \"172.24.\" ) ||\n strings.HasPrefix( ip, \"172.25.\" ) ||\n strings.HasPrefix( ip, \"172.26.\" ) ||\n strings.HasPrefix( ip, \"172.27.\" ) ||\n strings.HasPrefix( ip, \"172.28.\" ) ||\n strings.HasPrefix( ip, \"172.29.\" ) ||\n strings.HasPrefix( ip, \"172.30.\" ) ||\n strings.HasPrefix( ip, \"172.31.\" ) ) {\n return net.ParseIP( ip )\n }\n }\n\n ip, _, _ := net.SplitHostPort( r.RemoteAddr )\n return net.ParseIP( ip )\n}", "func getClientIPByHeaders(req *http.Request) (ip string, err error) {\n\n\t// Client could be behid a Proxy, so Try Request Headers (X-Forwarder)\n\tipSlice := []string{}\n\n\tipSlice = append(ipSlice, req.Header.Get(\"X-Forwarded-For\"))\n\tipSlice = append(ipSlice, req.Header.Get(\"x-forwarded-for\"))\n\tipSlice = append(ipSlice, req.Header.Get(\"X-FORWARDED-FOR\"))\n\n\tfor _, v := range ipSlice {\n\t\t// log.Printf(\"debug: client request header check gives ip: %v\", v)\n\t\tif v != \"\" {\n\t\t\treturn v, nil\n\t\t}\n\t}\n\terr = errors.New(\"error: Could not find clients IP address from the Request Headers\")\n\treturn \"\", err\n\n}", "func ClientIP(r *http.Request) (clientIP string) {\n\tvar values []string\n\n\tif values, _ = r.Header[XRealIP]; len(values) > 0 {\n\n\t\tclientIP = strings.TrimSpace(values[0])\n\t\tif clientIP != blank {\n\t\t\treturn\n\t\t}\n\t}\n\n\tif values, _ = r.Header[XForwardedFor]; len(values) > 0 {\n\t\tclientIP = values[0]\n\n\t\tif index := strings.IndexByte(clientIP, ','); index >= 0 {\n\t\t\tclientIP = clientIP[0:index]\n\t\t}\n\n\t\tclientIP = strings.TrimSpace(clientIP)\n\t\tif clientIP != blank {\n\t\t\treturn\n\t\t}\n\t}\n\n\tclientIP, _, _ = net.SplitHostPort(strings.TrimSpace(r.RemoteAddr))\n\n\treturn\n}", "func GetClientIP(rc *revel.Controller) (ip string) {\n\tclientIP := rc.Request.Header.Get(\"X-Forwarded-For\")\n\n\t// X-Forwarded-For can actually be an array of addresses separated with \",\"\n\t// client IP should be first address\n\tip = strings.Split(clientIP, \",\")[0]\n\tif ip != \"\" && ip != REVEL_ADDED_XIP {\n\t\treturn ip\n\t}\n\n\treturn RemovePortFromIP(rc.Request.RemoteAddr)\n}", "func (_class PIFClass) GetIP(sessionID SessionRef, self PIFRef) (_retval string, _err error) {\n\t_method := \"PIF.get_IP\"\n\t_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf(\"%s(%s)\", _method, \"session_id\"), sessionID)\n\tif _err != nil {\n\t\treturn\n\t}\n\t_selfArg, _err := convertPIFRefToXen(fmt.Sprintf(\"%s(%s)\", _method, \"self\"), self)\n\tif _err != nil {\n\t\treturn\n\t}\n\t_result, _err := _class.client.APICall(_method, _sessionIDArg, _selfArg)\n\tif _err != nil {\n\t\treturn\n\t}\n\t_retval, _err = convertStringToGo(_method + \" -> \", _result.Value)\n\treturn\n}", "func (server Server) GetIP() string {\n\treturn server.IP\n}", "func (s *serverCGI) remoteIP(host string) string {\n\tif host != \"\" {\n\t\treturn host\n\t}\n\tremoteAddr, _, err := net.SplitHostPort(s.req.RemoteAddr)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn \"\"\n\t}\n\tif !isGlobal(remoteAddr) {\n\t\tlog.Println(remoteAddr, \"is local IP\")\n\t\treturn \"\"\n\t}\n\treturn remoteAddr\n}", "func GetIp() string {\n\n\tout, err := exc.ExecuteWithBash(\"ip route get 1.1.1.1 | grep -oP 'src \\\\K\\\\S+'\")\n\n\tip := strings.TrimSpace(out)\n\tif log.Check(log.WarnLevel, \"Getting RH IP \"+ip, err) {\n\t\treturn \"\"\n\t}\n\n\treturn ip\n}", "func (d *Driver) GetIP() (string, error) {\n\td.connectAPI()\n\treturn d.driver.GetEth0IPv4(d.Node, d.VMID)\n}", "func RequestGetRemoteAddress(r *http.Request) string {\n\thdr := r.Header\n\thdrRealIP := hdr.Get(\"X-Real-Ip\")\n\thdrForwardedFor := hdr.Get(\"X-Forwarded-For\")\n\tif hdrRealIP == \"\" && hdrForwardedFor == \"\" {\n\t\treturn ipAddrFromRemoteAddr(r.RemoteAddr)\n\t}\n\tif hdrForwardedFor != \"\" {\n\t\t// X-Forwarded-For is potentially a list of addresses separated with \",\"\n\t\tparts := strings.Split(hdrForwardedFor, \",\")\n\t\tfor i, p := range parts {\n\t\t\tparts[i] = strings.TrimSpace(p)\n\t\t}\n\t\treturn parts[0]\n\t}\n\treturn hdrRealIP\n}", "func (l Lease) GetIP() (ip net.IP) {\n\treturn net.ParseIP(l.IP)\n}", "func GetIP() string {\n\tIP := os.Getenv(\"MYPRVIP\")\n\tif IP != \"\" {\n\t\treturn IP\n\t}\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\tlog.Printf(\"error in GetIP - %v\\n\", err)\n\t\treturn \"\"\n\t}\n\tfor _, address := range addrs {\n\t\t// return the first address that is not a loopback\n\t\tif ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tif ipnet.IP.To4() != nil {\n\t\t\t\treturn ipnet.IP.String()\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\"\n}", "func (ia IfAddr) GetIP() string { return ia.IfaIP }", "func (docker *Docker) GetIP() string {\n\treturn docker.ip\n}", "func (input *BeegoInput) IP() string {\n\tips := input.Proxy()\n\tif len(ips) > 0 && ips[0] != \"\" {\n\t\trip, _, err := net.SplitHostPort(ips[0])\n\t\tif err != nil {\n\t\t\trip = ips[0]\n\t\t}\n\t\treturn rip\n\t}\n\tif ip, _, err := net.SplitHostPort(input.Context.Request.RemoteAddr); err == nil {\n\t\treturn ip\n\t}\n\treturn input.Context.Request.RemoteAddr\n}", "func (cce *CCEClient) GetIP(cluster *clusterv1.Cluster, machine *clusterv1.Machine) (string, error) {\n\t// TODO\n\treturn \"\", nil\n}", "func (input *Input) IP() string {\n\tips := input.Proxy()\n\tif len(ips) > 0 && ips[0] != \"\" {\n\t\trip := strings.Split(ips[0], \":\")\n\t\treturn rip[0]\n\t}\n\tip := strings.Split(input.Context.Request.RemoteAddr, \":\")\n\tif len(ip) > 0 {\n\t\tif ip[0] != \"[\" {\n\t\t\treturn ip[0]\n\t\t}\n\t}\n\treturn \"127.0.0.1\"\n}", "func (ctx *Context) IP() string {\r\n\tvar ip = strings.Split(ctx.R.RemoteAddr, \":\")\r\n\tif len(ip) > 0 {\r\n\t\tif ip[0] != \"[\" {\r\n\t\t\treturn ip[0]\r\n\t\t}\r\n\t}\r\n\treturn \"127.0.0.1\"\r\n}", "func getIP(ip_str string) (net.IP, error) {\n\tip := net.ParseIP(ip_str)\n\tif ip != nil {\n\t\treturn ip.To4(), nil\n\t}\n\treturn nil, errors.New(\"Failed to parse ip\")\n}", "func (m MetaData) GetRemoteIP() string {\n\tif len(m) == 0 {\n\t\treturn \"\"\n\t}\n\tif ip := m[\"x-forwarded-for\"]; ip != \"\" {\n\t\tparts := strings.Split(ip, \",\")\n\t\tif len(parts) > 0 {\n\t\t\treturn parts[0]\n\t\t}\n\t}\n\treturn m[remoteIPFromPeer]\n}", "func getHost(r *http.Request) string {\n\tvar remoteHost string\n\n\tif header := r.Header.Get(\"X-Forwarded-For\"); header != \"\" {\n\t\tremoteHost = header\n\t} else {\n\t\tremoteHost = r.RemoteAddr\n\t}\n\n\treturn remoteHost\n}", "func getMyIP() string {\n\tresp, err := http.Get(\"http://api.ipify.org\")\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\tip, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\treturn string(ip)\n}", "func (s *SCIONBoxController) getSourceIP(r *http.Request) (string, error) {\n\tip, _, err := net.SplitHostPort(r.RemoteAddr)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn ip, nil\n}", "func GetIP(vrf uint64, ip *bnet.IP) *IPAddress {\n\treturn pkgIPCache.get(vrf, ip)\n}", "func (th *TailHandler) getIp(info []string) (string, string) {\n\tif info[8] == \"-\" || info[8] == \"\" {\n\t\treturn th.Ip(info[0])\n\t}\n\treturn th.Ip(info[8])\n}", "func (ins *EC2RemoteClient) getIPAddress() error {\n\tresult, err := ins.ec2Client.DescribeInstances(&ec2.DescribeInstancesInput{InstanceIds: aws.StringSlice([]string{ins.InstanceID})})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error getting instance details : %s\", err)\n\t}\n\tins.instanceIP = net.ParseIP(*result.Reservations[0].Instances[0].PublicIpAddress)\n\tif ins.instanceIP == nil {\n\t\treturn fmt.Errorf(\"Error parsing IP address\")\n\t}\n\treturn err\n}", "func (c *icecontext) RealIP() string {\n\tif c.clientip == \"\" {\n\t\tra := c.Request().GetRemoteAddr()\n\t\tif ip := c.Header().Get(protocol.HeaderXForwardedFor); ip != \"\" {\n\t\t\tra = strings.Split(ip, \", \")[0]\n\t\t} else if ip := c.Header().Get(protocol.HeaderXRealIP); ip != \"\" {\n\t\t\tra = ip\n\t\t} else {\n\t\t\tra, _, _ = net.SplitHostPort(ra)\n\t\t}\n\t\tc.clientip = ra\n\t\treturn ra\n\t}\n\treturn c.clientip\n}", "func (d *Driver) GetIP() (string, error) {\n\tvm, err := d.getVirtualMachine(true)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn vm.PrimaryIP().String(), nil\n}", "func GetIP() (ip string) {\n\n\thost, _ := os.Hostname()\n\taddrs, _ := net.LookupIP(host)\n\tfor _, addr := range addrs {\n\t\tif ipv4 := addr.To4(); ipv4 != nil && !ipv4.IsLoopback() {\n\t\t\t//fmt.Println(\"IPv4: \", ipv4.String())\n\t\t\tip = ipv4.String()\n\t\t}\n\t}\n\treturn ip\n}", "func (c *Context) RemoteIP() (remoteIP string) {\n\tremoteIP = metadata.String(c, metadata.RemoteIP)\n\tif remoteIP != \"\" {\n\t\treturn\n\t}\n\n\tremoteIP = c.Request.Header.Get(\"X-Forwarded-For\")\n\tremoteIP = strings.TrimSpace(strings.Split(remoteIP, \",\")[0])\n\tif remoteIP == \"\" {\n\t\tremoteIP = strings.TrimSpace(c.Request.Header.Get(\"X-Real-Ip\"))\n\t}\n\n\treturn\n}", "func (irkit *Irkit) GetIPAddress() string {\n\treturn irkit.Address\n}", "func getExternalIP() string {\n\tresp, err := http.Get(\"https://api.ipify.org?format=json\")\n\tif (err != nil) {\n\t\tlog.Fatal(\"Do: \", err)\n\t\treturn \"\"\n\t}\n\tdefer resp.Body.Close()\n\n\tvar record IPFy\n\n\tif err := json.NewDecoder(resp.Body).Decode(&record); err != nil {\n\t\tlog.Fatal(\"Decode \", err)\n\t\treturn \"\"\n\t}\n\treturn record.IP\n\n}", "func getIP(ec2inst ec2Instance,c *ecs.Container) string{\n\tif len(c.NetworkInterfaces) > 0 {\n\t\treturn ptr.StringValue(c.NetworkInterfaces[0].PrivateIpv4Address)\n\t}\n\treturn ptr.StringValue(ec2inst.PrivateIpAddress)\n}", "func (j * JoinHelper) GetIP () error{\n\t// get IP\n\tcmds := []string{\"echo \\\"net.ipv4.ip_forward=1\\\" >> /etc/sysctl.conf\",\n\t\t\"sysctl -p\"}//,\n\t\t//fmt.Sprintf(\"dhclient vpn_%s\", nicName)}\n\tfor _, command := range cmds {\n\t\tcmd := exec.Command(\"/bin/sh\", \"-c\", command)\n\t\terr := cmd.Run()\n\t\tif err != nil {\n\t\t\tlog.Warn().Str(\"command\", command).Str(\"error\", err.Error()).Msg(\"error executing\")\n\t\t\treturn err\n\t\t}\n\t}\n\treturn j.ExecuteDhClient()\n}", "func (i *IPGetter) Get(ctx context.Context) (string, error) {\n\tr, err := http.Get(canihaz)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Couldn't retrieve external IP address: %w\", err)\n\t}\n\n\tip, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Could not read IP address from response: %w\", err)\n\t}\n\n\treturn strings.TrimSpace(fmt.Sprintf(\"%s\", ip)), nil\n}", "func GetIP() string {\n\tifaces, err := net.Interfaces()\n\tterr.PrintError(\"problem collecting local ip address\", err)\n\t// handle err\n\tfor _, i := range ifaces {\n\t\taddrs, err := i.Addrs()\n\t\tterr.PrintError(\"problem collecting local ip address\", err)\n\t\t// handle err\n\t\tfor _, addr := range addrs {\n\t\t\tvar ip net.IP\n\t\t\tswitch v := addr.(type) {\n\t\t\tcase *net.IPNet:\n\t\t\t\tip = v.IP\n\t\t\tcase *net.IPAddr:\n\t\t\t\tip = v.IP\n\t\t\t}\n\t\t\t//if the address is not loopback return it\n\t\t\tif ip.String() != \"127.0.0.1\" && ip.String() != \"::1\" {\n\t\t\t\treturn ip.String()\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\"\n}", "func GetClientIP() string {\n\t//hmac.New(hash.)\n\treturn \"hope\"\n}", "func (c *APIClient) GetIP(strID string) (string, error) {\n\tid := types.StringID(strID)\n\tif id.IsEmpty() {\n\t\treturn \"\", fmt.Errorf(\"ServerID is invalid: %s\", strID)\n\t}\n\tserver, err := sacloud.NewServerOp(c.caller).Read(context.Background(), c.Zone, id)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn server.Interfaces[0].IPAddress, nil\n}", "func (d *driverMock) GetInstanceIP(ctx context.Context, id string) (string, error) {\n\tif d.GetInstanceIPErr != nil {\n\t\treturn \"\", d.GetInstanceIPErr\n\t}\n\tif d.cfg.UsePrivateIP {\n\t\treturn \"private_ip\", nil\n\t}\n\treturn \"ip\", nil\n}", "func (ia *IPApi) MyIP() (ip string, err error) {\n\tresp, err := ia.Client.Get(MyIPUrl)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer resp.Body.Close()\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif resp.StatusCode != 200 {\n\t\treturn \"\", fmt.Errorf(\"status code: %d\", resp.StatusCode)\n\t}\n\n\tinfos := make(map[string]string)\n\terr = json.Unmarshal(body, &infos)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tip, ok := infos[\"ip\"]\n\tif !ok {\n\t\treturn \"\", ErrInvalidRespResult\n\t}\n\treturn ip, nil\n}", "func (c *Context) ClientIP() string {\n\tclientIP := c.GetHeader(\"X-Forwarded-For\")\n\tclientIP = strings.TrimSpace(strings.Split(clientIP, \",\")[0])\n\tif clientIP == emptyString {\n\t\tclientIP = strings.TrimSpace(c.GetHeader(\"X-Real-Ip\"))\n\t}\n\tif clientIP != emptyString {\n\t\treturn clientIP\n\t}\n\tif ip, _, err := net.SplitHostPort(strings.TrimSpace(c.Req.RemoteAddr)); err == nil {\n\t\treturn ip\n\t}\n\treturn emptyString\n}", "func (c *C) ClientIP() string {\n\treturn c.Request.RemoteAddr\n}", "func (o *WafEventNetwork) GetIp() string {\n\tif o == nil || o.Ip == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Ip\n}" ]
[ "0.8188254", "0.8172519", "0.8153036", "0.8137045", "0.8078763", "0.8049451", "0.8041197", "0.8029479", "0.7872405", "0.75614214", "0.7544722", "0.75206316", "0.7445191", "0.7402611", "0.73768044", "0.72981644", "0.72841084", "0.72343224", "0.723342", "0.7230571", "0.71902466", "0.7153004", "0.71462554", "0.7135956", "0.7124085", "0.71140397", "0.711227", "0.7092719", "0.7062549", "0.705406", "0.7050865", "0.7049538", "0.70273143", "0.6989681", "0.6976015", "0.6961809", "0.6961809", "0.69286513", "0.68734574", "0.6843774", "0.68377954", "0.68248296", "0.68222624", "0.6818533", "0.6792699", "0.6791197", "0.6791197", "0.67839944", "0.6776444", "0.6741326", "0.6695642", "0.6687897", "0.66646296", "0.6661908", "0.6642517", "0.6637372", "0.6629904", "0.6621126", "0.6592966", "0.65874803", "0.65873927", "0.65731907", "0.6557977", "0.65466404", "0.65457296", "0.65426373", "0.65422523", "0.6537341", "0.6533133", "0.65268964", "0.65256923", "0.65114015", "0.6511349", "0.6509564", "0.6506434", "0.64946413", "0.6455563", "0.64501494", "0.64425176", "0.642709", "0.6426563", "0.6426402", "0.64228934", "0.6417261", "0.6381506", "0.6375902", "0.6367362", "0.6353496", "0.63148713", "0.63132554", "0.6280725", "0.6273475", "0.62477833", "0.62434924", "0.6243072", "0.6241006", "0.6237372", "0.62359536", "0.6226716" ]
0.802386
9
jsonRPCResponse returns a JSON response containing v, or a plaintext generic response for this httpCode and an error when JSON marshalling fails.
func jsonRPCResponse(httpCode int, v interface{}) (*http.Response, error) { body, err := json.Marshal(v) if err != nil { return &http.Response{ Body: ioutil.NopCloser(strings.NewReader(http.StatusText(httpCode))), StatusCode: httpCode, }, fmt.Errorf("failed to serialize JSON: %v", err) } return &http.Response{ Body: ioutil.NopCloser(bytes.NewReader(body)), StatusCode: httpCode, }, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func JSONRPCResponse(httpCode int, v interface{}) (*http.Response, error) {\n\tbody, err := json.Marshal(v)\n\tif err != nil {\n\t\treturn &http.Response{\n\t\t\tBody: ioutil.NopCloser(strings.NewReader(http.StatusText(httpCode))),\n\t\t\tStatusCode: httpCode,\n\t\t}, fmt.Errorf(\"failed to serialize JSON: %v\", err)\n\t}\n\treturn &http.Response{\n\t\tBody: ioutil.NopCloser(bytes.NewReader(body)),\n\t\tStatusCode: httpCode,\n\t\tHeader: map[string][]string{\"Content-Type\": {\"application/json\"}},\n\t}, nil\n}", "func JsonResponse(v interface{}, err *irma.RemoteError) (int, []byte) {\n\treturn encodeValOrError(v, err, json.Marshal)\n}", "func JsonResponse(status int, v interface{}) IResponse {\n\tb, err := json.Marshal(v)\n\tif err != nil {\n\t\treturn &Response{\n\t\t\tBytes: []byte(err.Error()),\n\t\t\tStatus: 500,\n\t\t\tHeaders: map[string]string{ContentTypeHeaderKey: \"plain/text; charset=utf-8\"},\n\t\t}\n\t}\n\treturn &Response{\n\t\tBytes: b,\n\t\tStatus: status,\n\t\tHeaders: map[string]string{ContentTypeHeaderKey: \"application/json; charset=utf-8\"},\n\t}\n}", "func responseJson(w http.ResponseWriter, code int, v interface{}) {\n\tbytes, err := json.Marshal(v)\n\tif err != nil {\n\t\tlog.Printf(\"marshal response %v: %v\", v, err)\n\t\treturn\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Header().Set(\"Content-Length\", strconv.Itoa(len(bytes)))\n\tw.WriteHeader(code)\n\tif v != nil {\n\t\tif _, err := w.Write(bytes); err != nil {\n\t\t\tlog.Printf(\"write response %v: %v\", bytes, err)\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}", "func RespondJSON(w http.ResponseWriter, code int, v interface{}) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tif code == 0 { // set default code\n\t\tcode = http.StatusOK\n\t}\n\tw.WriteHeader(code)\n\t_ = json.NewEncoder(w).Encode(Response{\n\t\tCode: code,\n\t\tStatus: http.StatusText(code),\n\t\tData: v,\n\t\tMetadata: nil,\n\t})\n}", "func JSONResponse(w http.ResponseWriter, v interface{}, statusCode int) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(statusCode)\n\n\tenc := json.NewEncoder(w)\n\tif err := enc.Encode(v); err != nil {\n\t\tlog.WithField(\"err\", err).Error(\"Failed to serialize JSON payload\")\n\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tfmt.Fprint(w, \"Failed to serialize JSON payload\")\n\t}\n}", "func JSONResponse(c echo.Context, statusCode int, result interface{}) error {\n\treturn c.JSON(statusCode, &HTTPOkResponseEnvelope{Data: result})\n}", "func JSONResponse(w http.ResponseWriter, status int, message, errCode string) error {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(status)\n\tres := NewResponse(status, message, errCode)\n\terr := json.NewEncoder(w).Encode(res)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *Context) Response(code int, body interface{}, message string, v ...interface{}) {\n\tc.JSON(200, ResponseWriter(code, fmt.Sprintf(message, v...), body))\n}", "func Response(w http.ResponseWriter, httpStatus int, data interface{}) {\n\tif httpStatus == 0 {\n\t\thttpStatus = http.StatusOK\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(httpStatus)\n\tjson.NewEncoder(w).Encode(data)\n}", "func (v1 *V1) responseJSON(w http.ResponseWriter, data interface{}, code int) {\n\tjs, err := json.Marshal(data)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(js)\n}", "func JSONResponse(w http.ResponseWriter, data interface{}, httpCode int) {\n\twriteJSONResponse(w, data, httpCode, \"data\")\n}", "func JSONResponse(w http.ResponseWriter, d interface{}, statusCode int) {\n\tjson, err := json.Marshal(d)\n\tif err != nil {\n\t\tlog.Printf(\"WebAuthNController: Error serializing response to JSON: %s\", err.Error())\n\t\thttp.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(statusCode)\n\tfmt.Fprintf(w, \"%s\", json)\n}", "func jsonResponse(rw http.ResponseWriter, code int, msg string) {\n\trw.Header().Set(\"Content-Type\", \"application/json\")\n\trw.WriteHeader(code)\n\trw.Write([]byte(fmt.Sprintf(`{\"message\":\"%s\"}`, msg)))\n}", "func WriteResponse(w http.ResponseWriter, data interface{}) error {\n\tenv := map[string]interface{}{\n\t\t\"meta\": map[string]interface{}{\n\t\t\t\"code\": http.StatusOK,\n\t\t},\n\t\t\"data\": data,\n\t}\n\treturn jsonResponse(w, env)\n}", "func JSONResponse(w http.ResponseWriter, r *http.Request, response []byte, code int) {\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\tw.WriteHeader(code)\n\tif string(response) != \"\" {\n\t\tw.Write(response)\n\t}\n}", "func responseJSON(message string, w http.ResponseWriter, statusCode int) {\n\tresponse := Response{message}\n\n\tjsonResponse, err := json.Marshal(response)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(statusCode)\n\tw.Write(jsonResponse)\n}", "func (ctx *RequestContext) JSONResponse(v interface{}) Response {\n\tresponse, _ := ctx.MakeJSONResponse(v)\n\treturn response\n}", "func (c *WSCodec) CreateResponse(id interface{}, reply interface{}) interface{} {\n\treturn &jsonSuccessResponse{Version: jsonrpcVersion, Id: id, Result: reply}\n}", "func jsonResponse(response interface{}, w http.ResponseWriter) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\tjson, err := json.Marshal(response)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.WriteHeader(response.(model.StandardResponse).Status)\n\tw.Write(json)\n}", "func JSON(resp http.ResponseWriter, result interface{}, code int) error {\n\tresp.Header().Add(\"Content-Type\", \"application/json\")\n\tresp.WriteHeader(code)\n\tif result != nil {\n\t\treturn maskAny(json.NewEncoder(resp).Encode(result))\n\t}\n\treturn nil\n}", "func WriteResponse(w http.ResponseWriter, v interface{}, statusCode int) {\n\tresBody, err := json.Marshal(v)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(statusCode)\n\t_, _ = w.Write(resBody)\n}", "func JSON(w http.ResponseWriter, d interface{}) {\n\tJSONWithHTTPCode(w, d, http.StatusOK)\n}", "func JSON(w http.ResponseWriter, d interface{}) {\n\tJSONWithHTTPCode(w, d, http.StatusOK)\n}", "func JSONResponse(w http.ResponseWriter, content interface{}, statusCode int) {\n\tresp, err := json.Marshal(content)\n\n\tif err != nil {\n\t\thttp.Error(w, \"Failed to encode content to JSON\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tw.Header().Set(\"Access-Control-Allow-Methods\", \"GET, POST\")\n\tw.WriteHeader(statusCode)\n\tw.Write(resp)\n}", "func ResponseOutput(v interface{}) ([]byte, error) {\n\tj, err := json.MarshalIndent(v, \"\", \"\\t\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn j, nil\n}", "func (r *Router) JSONResponse(w http.ResponseWriter, d interface{}, statusCode int) {\n\tjs, err := json.Marshal(d)\n\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.WriteHeader(statusCode)\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Write(js)\n}", "func respond(w http.ResponseWriter, val interface{}, statusCode int) {\n\tw.Header().Add(headerContentType, contentTypeJSONUTF8)\n\tif statusCode > 0 {\n\t\tw.WriteHeader(statusCode)\n\t}\n\n\tencoder := json.NewEncoder(w)\n\tif err := encoder.Encode(val); err != nil {\n\t\tlog.Printf(\"error encoding response value to JSON: %v\", err)\n\t}\n}", "func WriteMessageResponse(w http.ResponseWriter, message string, data interface{}) error {\n\tenv := map[string]interface{}{\n\t\t\"meta\": map[string]interface{}{\n\t\t\t\"code\": http.StatusOK,\n\t\t\t\"message\": message,\n\t\t},\n\t\t\"data\": data,\n\t}\n\n\treturn jsonResponse(w, env)\n}", "func (c *Context) WriteResponse(obj interface{}, statusCode int) os.Error {\n\n\tvar error os.Error\n\n\t// get the formatter\n\tformatter, error := GetFormatter(c.Format)\n\n\tif error != nil {\n\t\tc.writeInternalServerError(error, http.StatusNotFound)\n\t\treturn error\n\t} else {\n\n\t\t// set the content type\n\t\tc.ResponseWriter.Header()[\"Content-Type\"] = []string{formatter.ContentType()}\n\n\t\t// format the output\n\t\toutput, error := formatter.Format(obj)\n\n\t\tif error != nil {\n\t\t\tc.writeInternalServerError(error, http.StatusInternalServerError)\n\t\t\treturn error\n\t\t} else {\n\n\t\t\toutputString := string(output)\n\n\t\t\t/*\n\t\t\t\tJSONP\n\t\t\t*/\n\t\t\tcallback := c.GetCallback()\n\t\t\tif callback != \"\" {\n\n\t\t\t\t// wrap with function call\n\n\t\t\t\trequestContext := c.GetRequestContext()\n\n\t\t\t\toutputString = callback + \"(\" + outputString\n\n\t\t\t\tif requestContext != \"\" {\n\t\t\t\t\toutputString = outputString + \", \\\"\" + requestContext + \"\\\")\"\n\t\t\t\t} else {\n\t\t\t\t\toutputString = outputString + \")\"\n\t\t\t\t}\n\n\t\t\t\t// set the new content type\n\t\t\t\tc.ResponseWriter.Header()[\"Content-Type\"] = []string{JSONP_CONTENT_TYPE}\n\n\t\t\t}\n\n\t\t\t// write the status code\n\t\t\tif strings.Index(c.Request.URL.Raw, REQUEST_ALWAYS200_PARAMETER) > -1 {\n\n\t\t\t\t// \"always200\"\n\t\t\t\t// write a fake 200 status code (regardless of what the actual code was)\n\t\t\t\tc.ResponseWriter.WriteHeader(http.StatusOK)\n\n\t\t\t} else {\n\n\t\t\t\t// write the actual status code\n\t\t\t\tc.ResponseWriter.WriteHeader(statusCode)\n\n\t\t\t}\n\n\t\t\t// write the output\n\t\t\tc.ResponseWriter.Write([]uint8(outputString))\n\n\t\t}\n\n\t}\n\n\t// success - no errors\n\treturn nil\n\n}", "func ResponseJSON(w http.ResponseWriter, code int, data interface{}) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tif data != nil {\n\t\tjson, _ := json.Marshal(data)\n\t\t_, _ = w.Write(json)\n\t}\n}", "func Response(ctx *gin.Context, httpStatus int, code int, msg string, data interface{}) {\n\tctx.JSON(httpStatus, &Body{Code: code, Msg: msg, Data: data})\n}", "func responseMessage (w http.ResponseWriter, response *model.Response) {\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tif response.Code < 0{\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t}else{\n\t\tw.WriteHeader(http.StatusOK)\n\t}\n\terr := json.NewEncoder(w).Encode(&response)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}", "func JSONResponse(w http.ResponseWriter, status int, data interface{}, err error) {\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\n\t// Error Response - Return early\n\tif err != nil {\n\t\tjErr, _ := json.Marshal(map[string]interface{}{\n\t\t\t\"Error\": err.Error(),\n\t\t})\n\t\tw.WriteHeader(500)\n\t\tw.Write(jErr)\n\t}\n\n\t// Try to handle data\n\tjRes, mErr := json.Marshal(data)\n\tif mErr != nil {\n\t\tjErr, _ := json.Marshal(map[string]interface{}{\n\t\t\t\"Data Error\": err.Error(),\n\t\t})\n\t\tw.WriteHeader(500)\n\t\tw.Write(jErr)\n\t}\n\tw.WriteHeader(status)\n\tw.Write(jRes)\n}", "func respond(w http.ResponseWriter, code int, v interface{}) {\n\tswitch val := v.(type) {\n\tcase error:\n\t\tif val != nil {\n\t\t\tlog15.Error(val.Error())\n\t\t\tw.Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\t\t\tw.WriteHeader(code)\n\t\t\tfmt.Fprintf(w, \"%v\", val)\n\t\t}\n\tdefault:\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tbs, err := json.Marshal(v)\n\t\tif err != nil {\n\t\t\trespond(w, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\n\t\tw.WriteHeader(code)\n\t\tif _, err = w.Write(bs); err != nil {\n\t\t\tlog15.Error(\"failed to write response\", \"error\", err)\n\t\t}\n\t}\n}", "func (a *API) JSONResponse(ctx *fasthttp.RequestCtx, response model.ResponseInterface, status int) {\n\tctx.Response.Header.Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\tif response != nil {\n\t\tctx.SetBody([]byte(response.ToJSON()))\n\t}\n\tctx.SetStatusCode(status)\n}", "func jsonResponse(w http.ResponseWriter, d interface{}, c int) {\n\tdj, err := json.Marshal(d)\n\tif err != nil {\n\t\thttp.Error(w, \"Error creating JSON response\", http.StatusInternalServerError)\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(c)\n\tfmt.Fprintf(w, \"%s\", dj)\n}", "func response(ctx *fiber.Ctx, status int, msg fiber.Map) error {\n\treturn ctx.Status(status).JSON(msg)\n}", "func (response *HTTPResponseVM) JSON(w http.ResponseWriter) {\n\tif response.Data == nil {\n\t\tresponse.Data = map[string]interface{}{}\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(response.Status)\n\t_ = json.NewEncoder(w).Encode(response)\n}", "func JSONResp(w http.ResponseWriter, code int, payload interface{}) {\n\tresponse, _ := json.Marshal(payload)\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(response)\n}", "func Response(w http.ResponseWriter, status int, responseData interface{}) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(status)\n\tjson.NewEncoder(w).Encode(responseData)\n}", "func (s *Server) respond(w http.ResponseWriter, code int, v any) {\n\tswitch val := v.(type) {\n\tcase error:\n\t\tif val != nil {\n\t\t\ts.Logger.Error(\"response value error\", log.String(\"err\", val.Error()))\n\t\t\tw.Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\t\t\tw.WriteHeader(code)\n\t\t\tfmt.Fprintf(w, \"%v\", val)\n\t\t}\n\tdefault:\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tbs, err := json.Marshal(v)\n\t\tif err != nil {\n\t\t\ts.respond(w, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\n\t\tw.WriteHeader(code)\n\t\tif _, err = w.Write(bs); err != nil {\n\t\t\ts.Logger.Error(\"failed to write response\", log.Error(err))\n\t\t}\n\t}\n}", "func (l *HTTPLib) JSON(w http.ResponseWriter, code int, data interface{}) {\n\tresp := newResponse(code, data)\n\tw.WriteHeader(code)\n\tif err := json.NewEncoder(w).Encode(resp); err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tw.Write([]byte(`{\"data\":\"internal server error\"}`))\n\t\t// http.Error(w, `{\"data\":\"internal server error\"}`, http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "func createJsonResponse(w http.ResponseWriter, req *http.Request, statusCode int, data *om.OrderedMap, error string) {\n\tif statusCode == 0 {\n\t\tstatusCode = 200\n\t}\n\n\tsuccess := true\n\tif statusCode < 200 || statusCode > 299 {\n\t\tsuccess = false\n\t}\n\n\tw.Header().Set(\"Content-authType\", \"application/json\")\n\tw.WriteHeader(statusCode)\n\n\tstatus := om.NewOrderedMap(\n\t\t&om.KV{Key: \"http\", Value: om.NewOrderedMap(\n\t\t\t&om.KV{Key: \"code\", Value: statusCode},\n\t\t\t&om.KV{Key: \"message\", Value: http.StatusText(statusCode)},\n\t\t)})\n\n\tif error != \"\" {\n\t\tstatus.Set(\"error\", error)\n\t}\n\n\tresponse := om.NewOrderedMap().\n\t\tSet(\"success\", success).\n\t\tSet(\"status\", status)\n\n\tif data != nil {\n\t\tresponse.Append(data, false)\n\t}\n\n\tjsonData, _ := json.Marshal(response)\n\tw.Write(jsonData)\n}", "func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {\n\tif e, ok := response.(errorer); ok && e.error() != nil {\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\t\tw.WriteHeader(codeFrom(e.error()))\n\t\treturn marshalStructWithError(response, w)\n\t}\n\n\t// Used for pagination\n\tif e, ok := response.(counter); ok {\n\t\tw.Header().Set(\"X-Total-Count\", strconv.Itoa(e.count()))\n\t}\n\n\t// Don't overwrite a header (i.e. called from encodeTextResponse)\n\tif v := w.Header().Get(\"Content-Type\"); v == \"\" {\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\t\t// Only write json body if we're setting response as json\n\t\treturn json.NewEncoder(w).Encode(response)\n\t}\n\treturn nil\n}", "func ResponseJSON(w http.ResponseWriter, ResponseData interface{}) {\n\tw.WriteHeader(http.StatusOK)\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(ResponseData)\n}", "func encodeGetByCreteriaResponse(ctx context.Context, w http1.ResponseWriter, response interface{}) (err error) {\n\tif f, ok := response.(endpoint.Failure); ok && f.Failed() != nil {\n\t\tErrorEncoder(ctx, f.Failed(), w)\n\t\treturn nil\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\terr = json.NewEncoder(w).Encode(response)\n\treturn\n}", "func encodeUpdateTagResponse(ctx context.Context, w http.ResponseWriter, response interface{}) (err error) {\n\tif f, ok := response.(endpoint.Failure); ok && f.Failed() != nil {\n\t\tErrorEncoder(ctx, f.Failed(), w)\n\t\treturn nil\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\terr = json.NewEncoder(w).Encode(response)\n\tif err != nil {\n\t\t\tlogrus.Warn(err.Error())\n\t\t}\n\treturn\n}", "func encodeGetResponse(ctx context.Context, w http1.ResponseWriter, response interface{}) (err error) {\n\tif f, ok := response.(endpoint.Failure); ok && f.Failed() != nil {\n\t\tErrorEncoder(ctx, f.Failed(), w)\n\t\treturn nil\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\terr = json.NewEncoder(w).Encode(response)\n\treturn\n}", "func encodeGetResponse(ctx context.Context, w http1.ResponseWriter, response interface{}) (err error) {\n\tif f, ok := response.(endpoint.Failure); ok && f.Failed() != nil {\n\t\tErrorEncoder(ctx, f.Failed(), w)\n\t\treturn nil\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\terr = json.NewEncoder(w).Encode(response)\n\treturn\n}", "func errorResponse(w http.ResponseWriter, reason string, statusCode int) error {\n\tw.WriteHeader(statusCode)\n\terrResponse := ErrorResponse{Err: reason}\n\terr := json.NewEncoder(w).Encode(errResponse)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func encodeGetTagResponse(ctx context.Context, w http.ResponseWriter, response interface{}) (err error) {\n\tif f, ok := response.(endpoint.Failure); ok && f.Failed() != nil {\n\t\tErrorEncoder(ctx, f.Failed(), w)\n\t\treturn nil\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\terr = json.NewEncoder(w).Encode(response)\n\tif err != nil {\n\t\t\tlogrus.Warn(err.Error())\n\t\t}\n\treturn\n}", "func (fn reponseHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\tre := fn(req)\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\tw.WriteHeader(re.status)\n\tif err := json.NewEncoder(w).Encode(re.value); err != nil {\n\t\tlog.Printf(\"Error occured while marshalling response entity: %v\", err)\n\t}\n}", "func Respond(w http.ResponseWriter, r *Response) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(r.Code)\n\tif json.NewEncoder(w).Encode(r) != nil {\n\t\thttp.Error(w, \"Error occured while encoding JSON\", http.StatusInternalServerError)\n\t}\n}", "func ResponseJSON(w http.ResponseWriter, r *http.Request, v interface{}) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(v)\n}", "func writeResponse(w http.ResponseWriter, h int, p interface{}) {\n\t// I set the content type...\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t// ... I write the specified status code...\n\tw.WriteHeader(h)\n\t// ... and I write the response\n\tb, _ := json.Marshal(p)\n\tw.Write(b)\n}", "func RespondWithStatus(status string, data interface{}) string {\n response := make(map[string]interface{})\n response[\"status\"] = status\n response[\"data\"] = data\n edata, _ := json.Marshal(response)\n return string(edata)\n}", "func ResponseWrite(w http.ResponseWriter, responseCode int, responseData interface{}) {\n\t// Write Response\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(responseCode)\n\n\t// Write JSON to Response\n\tjson.NewEncoder(w).Encode(responseData)\n}", "func encodeCalculatorResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {\n\tif e, ok := response.(errorer); ok && e.error() != nil {\n\t\t// Not a Go kit transport error, but a business-logic error.\n\t\t// Provide those as HTTP errors.\n\t\tencodeError(ctx, e.error(), w)\n\t\treturn nil\n\t}\n\n\t// fmt.Println(ctx)\n\tfmt.Println(response)\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\treturn json.NewEncoder(w).Encode(response)\n}", "func returnResponse(success bool, message string) string {\n\tresp, err := json.Marshal(Response{Success: success, Message: message})\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\treturn string(resp)\n}", "func WriteResponse(w http.ResponseWriter, response datatypes.PerformanceSignatureReturn, ps datatypes.PerformanceSignature) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tif response.Error {\n\t\tw.WriteHeader(503)\n\t} else if !response.Pass {\n\t\tw.WriteHeader(406)\n\t}\n\n\tresponseJson, err := json.Marshal(response)\n\tif err != nil {\n\t\tlogging.LogError(datatypes.Logging{\n\t\t\tMessage: fmt.Sprintf(\"Couldn't marshal json for response. Error: %v.\", err),\n\t\t\tPerfSig: ps,\n\t\t})\n\n\t\tw.WriteHeader(513)\n\t\tmarshalErrorJson := datatypes.PerformanceSignatureReturn{\n\t\t\tError: true,\n\t\t\tResponse: []string{fmt.Sprintf(\"goDynaPerfSignature internal problem sending the response. The message was supposed to be: %v\", response.Response)},\n\t\t}\n\n\t\terrorJson, err2 := json.Marshal(marshalErrorJson)\n\t\tif err2 != nil {\n\t\t\tlogging.LogError(datatypes.Logging{\n\t\t\t\tMessage: fmt.Sprintf(\"Couldn't marshal failure json for response. Error: %v.\", err2),\n\t\t\t\tPerfSig: ps,\n\t\t\t})\n\t\t}\n\t\tw.Write(errorJson)\n\t\treturn\n\t}\n\n\tw.Write(responseJson)\n}", "func RespondJSON(w http.ResponseWriter, x interface{}) error {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tenc := json.NewEncoder(w)\n\tif err, ok := x.(error); ok {\n\t\tcode := http.StatusInternalServerError\n\t\tif coder, ok := err.(StatusCoder); ok {\n\t\t\tcode = coder.StatusCode()\n\t\t}\n\t\tw.WriteHeader(code)\n\t\tif u, ok := err.(json.Unmarshaler); ok {\n\t\t\treturn enc.Encode(u)\n\t\t}\n\t\treturn enc.Encode(New(code, err))\n\t}\n\tw.WriteHeader(http.StatusOK)\n\treturn enc.Encode(x)\n}", "func WriteResponse(w http.ResponseWriter, code int, err error, data interface{}, t0 time.Time) {\n\tw.WriteHeader(code)\n\tresp := &Response{Data: data, Dur: fmt.Sprint(time.Since(t0)), OK: false}\n\tif code < 300 {\n\t\tresp.OK = true\n\t}\n\tif err != nil {\n\t\tresp.Err = err.Error()\n\t}\n\terr = json.NewEncoder(w).Encode(resp)\n\tif err != nil {\n\t\tlog.Infof(\"failed to json encode response: %v\", err)\n\t\tif _, err = w.Write([]byte(spew.Sdump(resp))); err != nil {\n\t\t\tlog.Infof(\"failed to write dump of response: %v\", err)\n\t\t}\n\t}\n}", "func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {\n\tif e, ok := response.(errorer); ok && e.error() != nil {\n\t\tEncodeError(ctx, e.error(), w)\n\t\treturn nil\n\t}\n\n\tw.WriteHeader(http.StatusOK)\n\treturn nil\n}", "func (o *Operation) writeResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\tif err != nil {\n\t\tlog.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func writeResponse(r *http.Request, w http.ResponseWriter, code int, resp interface{}) {\n\n\t// Deal with CORS\n\tif origin := r.Header.Get(\"Origin\"); origin != \"\" {\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", origin)\n\t\tw.Header().Set(\"Access-Control-Allow-Methods\", \"DELETE, GET, HEAD, OPTIONS, POST, PUT\")\n\t\tw.Header().Set(\"Access-Control-Allow-Credentials\", \"true\")\n\t\t// Allow any headers\n\t\tif wantedHeaders := r.Header.Get(\"Access-Control-Request-Headers\"); wantedHeaders != \"\" {\n\t\t\tw.Header().Set(\"Access-Control-Allow-Headers\", wantedHeaders)\n\t\t}\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\n\tb, err := json.Marshal(resp)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tfmt.Fprintln(w, `{\"error\":\"failed to marshal json\"}`)\n\t\treturn\n\t}\n\n\tw.WriteHeader(code)\n\tfmt.Fprintln(w, string(b))\n}", "func Response(w http.ResponseWriter, resp interface{}, status int) {\n\t// set Header\n\theader(w)\n\tw.WriteHeader(status)\n\tb, err := marshaler(resp)\n\n\tif err == nil {\n\t\t// Responde\n\t\tw.Write(b)\n\t} else {\n\t\tutils.Error(\"Error on convert response to JSON\", err)\n\t\tResponseError(w, \"Error on convert response to JSON\")\n\t}\n}", "func JSON(w http.ResponseWriter, status int, data interface{}) {\n\t// Get rid of the invalid status codes\n\tif status < 100 || status > 599 {\n\t\tstatus = 200\n\t}\n\n\t// Try to marshal the input\n\tresult, err := json.Marshal(data)\n\tif err != nil {\n\t\t// Set the result to the default value to prevent empty responses\n\t\tresult = []byte(`{\"status\":500,\"message\":\"Error occurred while marshalling the response body\"}`)\n\t}\n\n\t// Set the response's content type to JSON\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\n\t// Write the result\n\tw.WriteHeader(status)\n\n\t// Write body\n\t_, err = w.Write(result)\n\tlog.CheckErr(\"Unable to write JSON data\", err)\n}", "func NewResponse(i int64, r string, e Error) Response {\n\treturn Response{\n\t\tID: i,\n\t\tJSONRpc: JSONRPCVersion,\n\t\tResult: r,\n\t\tError: e,\n\t}\n}", "func encodeGetUserResponse(ctx context.Context, w http1.ResponseWriter, response interface{}) (err error) {\n\tif f, ok := response.(endpoint.Failure); ok && f.Failed() != nil {\n\t\tErrorEncoder(ctx, f.Failed(), w)\n\t\treturn nil\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\terr = json.NewEncoder(w).Encode(response)\n\treturn\n}", "func WriteResponse(w http.ResponseWriter, code int, resp interface{}) error {\n\tj, err := json.Marshal(resp)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn err\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\n\t_, err = w.Write(j)\n\treturn err\n}", "func responseJson(err error, w http.ResponseWriter, payload interface{}) {\n\tif err == sql.ErrNoRows {\n\t\thttp.Error(w, err.Error(), 404)\n\t\treturn\n\t}\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), 400)\n\t\treturn\n\t}\n\tbyteArray, _ := json.Marshal(payload)\n\t//w.Header().Set(\"Access-Control-Allow-Origin\", \"*\") // uncomment to allow CORS\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(200)\n\tfmt.Fprintf(w, \"%s\", byteArray)\n}", "func jsonresponse(c *gin.Context) {\n\tc.JSON(200, gin.H{\n\t\t\"status\": \"success\",\n\t\t\"message\": \"process executed successfully\",\n\t})\n}", "func (h *BaseHTTPHandler) JSON(writer io.Writer, httpCode int, v interface{}) {\n\t_ = h.Render.JSON(writer, httpCode, v)\n}", "func getMessageResponse(w http.ResponseWriter, messages []Message, err error) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\tvar statusResponse StatusResponse\n\tvar messageResponse MessageResponse\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tstatusResponse.Error = true\n\t\tstatusResponse.Message = err.Error()\n\t\tstatusResponse.Code = 400\n\t} else {\n\t\tw.WriteHeader(http.StatusOK)\n\t\tstatusResponse.Error = false\n\t\tstatusResponse.Message = \"\"\n\t\tstatusResponse.Code = 200\n\t}\n\n\tmessageResponse.Status = statusResponse\n\tmessageResponse.Data = messages\n\n\tjson.NewEncoder(w).Encode(messageResponse)\n}", "func (b *BitcoinClient) createRPCBitcoinResponse(res string) *RPCBitcoinResponse {\n\tvar rpcBitcoinResponse RPCBitcoinResponse\n\tjson.Unmarshal([]byte(res), &rpcBitcoinResponse)\n\n\treturn &rpcBitcoinResponse\n}", "func ExtendedJSON(w http.ResponseWriter, code int, data interface{}, metadata map[string]interface{}) {\n\n\tvar status string\n\tswitch code {\n\tcase http.StatusOK:\n\t\tstatus = \"Success\"\n\tcase http.StatusCreated:\n\t\tstatus = \"Created\"\n\t}\n\n\ttype response struct {\n\t\tStatus string `json:\"status\"`\n\t\tCode int `json:\"code\"`\n\t\tData interface{} `json:\"data\"`\n\t\tMetadata map[string]interface{} `json:\"metadata,omitempty\"`\n\t}\n\n\tresp := response{\n\t\tStatus: status,\n\t\tCode: code,\n\t\tData: data,\n\t\tMetadata: metadata,\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tjson.NewEncoder(w).Encode(resp)\n}", "func writeJsonRespStructured(w http.ResponseWriter, err error, respBody interface{}, status int, apiErrors []*util.ApiError) {\n\tresponse := ResponseV2{}\n\tresponse.Code = status\n\tresponse.Status = http.StatusText(status)\n\tif err == nil {\n\t\tresponse.Result = respBody\n\t} else {\n\t\tresponse.Errors = apiErrors\n\t}\n\tb, err := json.Marshal(response)\n\tif err != nil {\n\t\tutil.GetLogger().Error(\"error in marshaling err object\", err)\n\t\tstatus = 500\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(status)\n\tw.Write(b)\n}", "func (resp *CommonRPCResponse) String() string {\n\treturn fmt.Sprintf(\"<Code: %d, Msg: %s>\", resp.Code, resp.Msg)\n}", "func messageResponse(w http.ResponseWriter, s int, m string) {\n\tw.WriteHeader(s)\n\tif m == \"\" {\n\t\treturn\n\t}\n\n\tb, err := json.Marshal(errorMessage{m})\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"Could not wrap message in JSON: %s\", m)\n\t\treturn\n\t}\n\tw.Write(b)\n}", "func (r *Response) JsonResponse(resp interface{}, statusCode int, header http.Header) error {\n\trsp, err := json.Marshal(resp)\n\tif err != nil {\n\t\tlog.Error(fmt.Sprintf(\"JSON err: %s\", err))\n\t\tr.StatusCode = HTTPStatusInternalServerError\n\t\trsp, _ = json.Marshal(map[string]string{\"error\": \"Error when parsing Json Response\"})\n\t\treturn err\n\t}\n\tr.Response = rsp\n\tr.StatusCode = statusCode\n\tvar respHeader http.Header\n\tif header != nil {\n\t\trespHeader = header\n\t\trespHeader.Add(\"Content-Type\", MIME_APP_JSON)\n\t} else {\n\t\trespHeader.Add(\"Content-Type\", MIME_APP_JSON)\n\t}\n\n\tr.Header = respHeader\n\treturn nil\n}", "func NewResponse(id string, result interface{}) *Response {\n\treturn &Response{JsonRPC: \"2.0\", Id: id, Result: result}\n}", "func WriteResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\tif err != nil {\n\t\tlogger.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func FormatResponse(o interface{}) string {\n\tout, err := json.MarshalIndent(o, \"\", \"\\t\")\n\tMust(err, `Command failed because an error occurred while prettifying output: %s`, err)\n\treturn string(out)\n}", "func JSONResponse(req *http.Request, status int, headers http.Header, body interface{}) (*http.Response, error) {\n\tbuf := new(bytes.Buffer)\n\tif err := json.NewEncoder(buf).Encode(body); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif headers == nil {\n\t\theaders = make(http.Header)\n\t}\n\tif headers.Get(\"Content-Type\") == \"\" {\n\t\theaders.Set(\"Content-Type\", \"application/json\")\n\t}\n\n\treturn SimpleResponse(req, status, headers, int64(buf.Len()), buf), nil\n}", "func jsonRes(data string, code int, txt string) string {\n\treturn fmt.Sprintf(`{\n\t\t\"data\": %s,\n\t\t\"status_code\": %d,\n\t\t\"status_txt\": \"%s\"\n\t}`, data, code, txt)\n}", "func WriteJSONResponse(w http.ResponseWriter, status int, value interface{}) {\n\tdata, _ := json.Marshal(value)\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Header().Set(\"Content-Length\", strconv.Itoa(len(data)))\n\tw.WriteHeader(status)\n\tw.Write(data)\n}", "func (o GoogleRpcStatusResponseOutput) Code() pulumi.IntOutput {\n\treturn o.ApplyT(func(v GoogleRpcStatusResponse) int { return v.Code }).(pulumi.IntOutput)\n}", "func Respond(w http.ResponseWriter, httpStatus int, response ResponseType) {\n\tw.WriteHeader(httpStatus)\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\n\tjson.NewEncoder(w).Encode(response)\n}", "func (app *application) errorResponse(w http.ResponseWriter, r *http.Request, status int, message interface{}) {\n\tresp := clientResponse{\"error\": message}\n\t// Write the response using the helper method.\n\terr := app.writeJSON(w, status, resp)\n\tif err != nil {\n\t\tapp.logError(r, err)\n\t\tw.WriteHeader(500)\n\t}\n}", "func ReturnGeneric(w http.ResponseWriter, message interface{}, status int) {\n\tresponse := GenericResponse{\n\t\tStatus: status,\n\t\tMessage: message,\n\t}\n\tw.WriteHeader(status)\n\tResponseWithJSON(w, response)\n}", "func ReturnResponseAsJSON(w http.ResponseWriter, resp interface{}, message string, statusCode int) (int, error) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tif resp == nil {\n\t\tresp = map[string]interface{}{}\n\t}\n\tresponse := &Response{\n\t\tResult: resp,\n\t\tMessage: message,\n\t}\n\n\tw.WriteHeader(statusCode)\n\treturn w.Write(MapToJSONByte(response))\n}", "func (response ListManagedInstanceUpdatablePackagesResponse) HTTPResponse() *http.Response {\n\treturn response.RawResponse\n}", "func RespondWithJSON(w http.ResponseWriter, code int, payload interface{}) {\n response, _ := json.Marshal(payload)\n w.Header().Set(\"Content-Type\", \"application/json\")\n w.WriteHeader(code)\n w.Write(response)\n}", "func SimpleResponse(code int, contentType string, val interface{}) Response {\n\treturn &simpleResp{\n\t\tct: contentType,\n\t\tv: val,\n\t\tcode: code,\n\t}\n}", "func ResponseWithJSON(w http.ResponseWriter, json []byte, code int) {\n\tw.Header().Set(\"Content-Type\", \"application/vnd.api+json; charset=utf-8\")\n\tw.WriteHeader(code)\n\tw.Write(json)\n}", "func WriteResponse(w http.ResponseWriter, object interface{}, rerr *irma.RemoteError) {\n\tstatus, bts := JsonResponse(object, rerr)\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(status)\n\t_, err := w.Write(bts)\n\tif err != nil {\n\t\tLogWarning(errors.WrapPrefix(err, \"failed to write response\", 0))\n\t}\n}", "func (o *ErrResponse) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\trw.WriteHeader(o.Code)\n\tjson.NewEncoder(rw).Encode(clientMessage{o.Err.Error()})\n}", "func (c *Response) ServeJSON(w http.ResponseWriter, r *http.Request) {\n\n\tdefer func() {\n\t\tb, err := json.Marshal(c.Body)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"helpers: could not json marshal: %s\", err.Error())\n\t\t}\n\t\t_, err = w.Write(b)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"helpers: could not write: %s\", err.Error())\n\t\t}\n\t}()\n\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tc.Body.Href = r.RequestURI\n\n\tif c.Err != nil {\n\t\tc.Body.StatusMessage = \"Error\"\n\t\tc.Body.Description = c.Err.Error()\n\t\tc.Body.StatusCode = 400\n\t\tw.WriteHeader(400)\n\t} else {\n\t\tc.Body.StatusMessage = \"Success\"\n\t\tc.Body.StatusCode = 200\n\t\tc.Body.Limit = 10\n\n\t\tif v := r.URL.Query().Get(\"offset\"); v != \"\" {\n\t\t\tvInt, err := strconv.Atoi(v)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t}\n\t\t\tc.Body.Offset = int64(vInt)\n\t\t}\n\t\tif v := r.URL.Query().Get(\"limit\"); v != \"\" {\n\t\t\tvInt, err := strconv.Atoi(v)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t}\n\t\t\tc.Body.Limit = int64(vInt)\n\t\t}\n\t}\n}", "func SendResponseErr(w http.ResponseWriter, httpStatus int, resp Response) {\n\tif resp.Code == \"0\" {\n\t\tresp.Code = \"-1\"\n\t}\n\n\tjson, _ := json.Marshal(resp)\n\n\tw.WriteHeader(httpStatus)\n\tw.Write(json)\n}" ]
[ "0.73640263", "0.7071985", "0.6591684", "0.62721163", "0.6254982", "0.6179157", "0.6164506", "0.6073439", "0.6067801", "0.60527635", "0.6048937", "0.60078514", "0.59905744", "0.5982659", "0.5979399", "0.5978767", "0.58956635", "0.58887005", "0.5792219", "0.57853013", "0.5774038", "0.5754084", "0.57447743", "0.57447743", "0.56988025", "0.5674067", "0.5671124", "0.56478524", "0.5639323", "0.5634975", "0.56329525", "0.56264246", "0.56178635", "0.56133795", "0.56089634", "0.5588032", "0.5578242", "0.5575994", "0.55753976", "0.5574302", "0.5572114", "0.5563503", "0.5561506", "0.5529433", "0.5513438", "0.5506764", "0.55007374", "0.5495482", "0.5494115", "0.5494115", "0.54865766", "0.548304", "0.5474901", "0.54653054", "0.5461056", "0.5453792", "0.54307485", "0.5429056", "0.5429009", "0.54247475", "0.5424738", "0.5406302", "0.5404313", "0.54011637", "0.5395082", "0.53934896", "0.5391905", "0.539023", "0.5387191", "0.5386913", "0.5384333", "0.53824234", "0.53810453", "0.5377464", "0.53764063", "0.53734714", "0.5364285", "0.5360154", "0.53533673", "0.5342044", "0.53399175", "0.5339723", "0.53359854", "0.5323979", "0.531596", "0.531298", "0.5310086", "0.5297604", "0.5296349", "0.5293805", "0.5292034", "0.52913845", "0.52875566", "0.5285019", "0.52790457", "0.5278523", "0.5277303", "0.5273767", "0.5269775", "0.52688634" ]
0.8310776
0
block returns a response only if the request should be blocked, otherwise it returns nil if allowed.
func (t *myTransport) block(ctx context.Context, parsedRequests []ModifiedRequest) (int, interface{}) { var union *blockRange for _, parsedRequest := range parsedRequests { ctx = gotils.With(ctx, "ip", parsedRequest.RemoteAddr) if allowed, _ := t.AllowVisitor(parsedRequest); !allowed { gotils.L(ctx).Info().Print("Request blocked: Rate limited") return http.StatusTooManyRequests, jsonRPCLimit(parsedRequest.ID) } //else if added { // gotils.L(ctx).Debug().Printf("Added new visitor, ip: %v", parsedRequest.RemoteAddr) // } if !t.MatchAnyRule(parsedRequest.Path) { // gotils.L(ctx).Debug().Print("Request blocked: Method not allowed") return http.StatusMethodNotAllowed, jsonRPCUnauthorized(parsedRequest.ID, parsedRequest.Path) } if t.blockRangeLimit > 0 && parsedRequest.Path == "eth_getLogs" { r, invalid, err := t.parseRange(ctx, parsedRequest) if err != nil { return http.StatusInternalServerError, jsonRPCError(parsedRequest.ID, jsonRPCInternal, err.Error()) } else if invalid != nil { gotils.L(ctx).Info().Printf("Request blocked: Invalid params: %v", invalid) return http.StatusBadRequest, jsonRPCError(parsedRequest.ID, jsonRPCInvalidParams, invalid.Error()) } if r != nil { if l := r.len(); l > t.blockRangeLimit { gotils.L(ctx).Info().Println("Request blocked: Exceeds block range limit, range:", l, "limit:", t.blockRangeLimit) return http.StatusBadRequest, jsonRPCBlockRangeLimit(parsedRequest.ID, l, t.blockRangeLimit) } if union == nil { union = r } else { union.extend(r) if l := union.len(); l > t.blockRangeLimit { gotils.L(ctx).Info().Println("Request blocked: Exceeds block range limit, range:", l, "limit:", t.blockRangeLimit) return http.StatusBadRequest, jsonRPCBlockRangeLimit(parsedRequest.ID, l, t.blockRangeLimit) } } } } } return 0, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Block(c *blocker.Client, h http.Handler) http.Handler {\n\treturn BlockWithCode(c, h, http.StatusForbidden)\n}", "func (r *BlockingResolver) handleBlocked(logger *logrus.Entry,\n\trequest *Request, question dns.Question, reason string) (*Response, error) {\n\tresponse := new(dns.Msg)\n\tresponse.SetReply(request.Req)\n\n\tswitch r.blockType {\n\tcase ZeroIP:\n\t\trr, err := util.CreateAnswerFromQuestion(question, typeToZeroIP[question.Qtype], BlockTTL)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tresponse.Answer = append(response.Answer, rr)\n\n\tcase NxDomain:\n\t\tresponse.Rcode = dns.RcodeNameError\n\t}\n\n\tlogger.Debugf(\"blocking request '%s'\", reason)\n\n\treturn &Response{Res: response, rType: BLOCKED, Reason: reason}, nil\n}", "func (c *Client) AllowBlocking(request *quotaservice.AllowRequest) error {\n\tresponse, err := c.qsClient.Allow(context.Background(), request)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif response.Status != quotaservice.AllowResponse_OK {\n\t\t// A REJECT response. Return an error.\n\t\treturn errors.New(quotaservice.AllowResponse_Status_name[int32(response.Status)])\n\t}\n\n\tif response.WaitMillis > 0 {\n\t\ttime.Sleep(time.Millisecond * time.Duration(response.WaitMillis))\n\t}\n\n\treturn nil\n}", "func (f *Firewall) BlockProxy(handler http.HandlerFunc) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\n\t\tp := r.URL.Path\n\t\thost := router.StripHostPort(r.RemoteAddr)\n\n\t\tfor pt := p; pt != \"/\"; pt = path.Dir(pt) {\n\t\t\tif val, ok := f.Rules[pt]; ok {\n\t\t\t\tfor _, v := range val {\n\t\t\t\t\tif v == host || v == \"*\" {\n\t\t\t\t\t\tif f.Blacklisting {\n\t\t\t\t\t\t\tf.ErrorHandler(w, r, 403)\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\thandler.ServeHTTP(w, r)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// The firewall subpath element allows blocking on specific subpaths of a website\n\t\t// This is only when you want to be extremely specific when configuring the firewall.\n\t\t// Subpath blocking is disabled by default and can be enabled in the configuration.\n\t\tif val, ok := f.Rules[\"/\"]; ok && p == \"/\" || ok && !f.Subpath {\n\t\t\tfor _, v := range val {\n\t\t\t\tif v == host || v == \"*\" {\n\t\t\t\t\tif f.Blacklisting {\n\t\t\t\t\t\tf.ErrorHandler(w, r, 403)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\thandler.ServeHTTP(w, r)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif f.Blacklisting {\n\t\t\thandler.ServeHTTP(w, r)\n\t\t\treturn\n\t\t}\n\n\t\tf.ErrorHandler(w, r, 403)\n\t\treturn\n\t}\n}", "func (f *Firewall) BlockHTTP(handler http.HandlerFunc) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\n\t\tp := r.URL.Path\n\t\thost := router.StripHostPort(r.RemoteAddr)\n\n\t\tfor pt := p; pt != \"/\"; pt = path.Dir(pt) {\n\t\t\tif val, ok := f.Rules[pt]; ok {\n\t\t\t\tfor _, v := range val {\n\t\t\t\t\tif v == host || v == \"*\" {\n\t\t\t\t\t\tif f.Blacklisting {\n\t\t\t\t\t\t\tf.ErrorHandler(w, r, 403)\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\thandler.ServeHTTP(w, r)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// The firewall subpath element allows blocking on specific subpaths of a website\n\t\t// This is only when you want to be extremely specific when configuring the firewall.\n\t\t// Subpath blocking is disabled by default and can be enabled in the configuration.\n\t\tif val, ok := f.Rules[\"/\"]; ok && p == \"/\" || ok && !f.Subpath {\n\t\t\tfor _, v := range val {\n\t\t\t\tif v == host || v == \"*\" {\n\t\t\t\t\tif f.Blacklisting {\n\t\t\t\t\t\tf.ErrorHandler(w, r, 403)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\thandler.ServeHTTP(w, r)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif f.Blacklisting {\n\t\t\tf.ErrorHandler(w, r, 403)\n\t\t\treturn\n\t\t}\n\t\thandler.ServeHTTP(w, r)\n\t\treturn\n\t}\n}", "func (brw *blockRetrievalWorker) HandleRequest() (err error) {\n\tretrievalCh := brw.queue.WorkOnRequest()\n\tvar retrieval *blockRetrieval\n\tselect {\n\tcase retrieval = <-retrievalCh:\n\t\tif retrieval == nil {\n\t\t\tpanic(\"Received a nil block retrieval. This should never happen.\")\n\t\t}\n\tcase <-brw.stopCh:\n\t\treturn io.EOF\n\t}\n\n\tvar block Block\n\tdefer func() {\n\t\tbrw.queue.FinalizeRequest(retrieval, block, err)\n\t}()\n\n\t// Handle canceled contexts.\n\tselect {\n\tcase <-retrieval.ctx.Done():\n\t\treturn retrieval.ctx.Err()\n\tdefault:\n\t}\n\n\twasBlockCached := func() bool {\n\t\tretrieval.reqMtx.RLock()\n\t\tdefer retrieval.reqMtx.RUnlock()\n\t\tif retrieval.requests[0].block == nil {\n\t\t\tpanic(\"Nil block passed in for first request. This should never happen.\")\n\t\t}\n\t\t// Attempt to retrieve the block from the cache. This might be a\n\t\t// specific type where the request blocks are CommonBlocks, but that\n\t\t// direction can Set correctly. The cache will never have CommonBlocks.\n\t\tblock, err = brw.queue.config.blockCache().Get(retrieval.blockPtr)\n\t\tif err == nil && block != nil {\n\t\t\treturn true\n\t\t}\n\t\t// Create a new block of the same type as the first request\n\t\tblock = retrieval.requests[0].block.NewEmpty()\n\t\treturn false\n\t}()\n\n\tif wasBlockCached {\n\t\treturn nil\n\t}\n\n\treturn brw.getBlock(retrieval.ctx, retrieval.kmd, retrieval.blockPtr, block)\n}", "func (a API) GetBlockChk() (isNew bool) {\n\tselect {\n\tcase o := <-a.Ch.(chan GetBlockRes):\n\t\tif o.Err != nil {\n\t\t\ta.Result = o.Err\n\t\t} else {\n\t\t\ta.Result = o.Res\n\t\t}\n\t\tisNew = true\n\tdefault:\n\t}\n\treturn\n}", "func BlockTorMiddleware(BanStatusCode int, BanPayload []byte) func(http.Handler) http.Handler {\r\n\treturn (func(next http.Handler) http.Handler {\r\n\t\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\r\n\t\t\t// parse IP:port\r\n\t\t\thost, _, _ := net.SplitHostPort(r.RemoteAddr)\r\n\t\t\thostIP := net.ParseIP(host)\r\n\r\n\t\t\t// Is Tor?\r\n\t\t\tif IsTor(hostIP) {\r\n\t\t\t\tw.WriteHeader(BanStatusCode)\r\n\t\t\t\tw.Write(BanPayload)\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\r\n\t\t\tnext.ServeHTTP(w, r)\r\n\t\t\treturn\r\n\t\t})\r\n\t})\r\n}", "func (env *Env) CheckBlock(pdu *libcoap.Pdu) (bool, *string, *libcoap.Block) {\n blockValue, err := pdu.GetOptionIntegerValue(libcoap.OptionBlock2)\n if err != nil {\n log.WithError(err).Warn(\"Get block2 option value failed.\")\n return false, nil, nil\n\t}\n block := libcoap.IntToBlock(int(blockValue))\n\n size2Value, err := pdu.GetOptionIntegerValue(libcoap.OptionSize2)\n\tif err != nil {\n\t\tlog.WithError(err).Warn(\"Get size 2 option value failed.\")\n return false, nil, nil\n }\n\n eTag := pdu.GetOptionOpaqueValue(libcoap.OptionEtag)\n\n if block != nil {\n isMoreBlock := true\n blockKey := eTag + string(pdu.Token)\n // If block.M = 1, block is more block. If block.M = 0, block is last block\n if block.M == libcoap.MORE_BLOCK {\n log.Debugf(\"Response block is comming (eTag=%+v, block=%+v, size2=%+v) for request (token=%+v), waiting for the next block.\", eTag, block.ToString(), size2Value, pdu.Token)\n if block.NUM == 0 {\n env.responseBlocks[blockKey] = pdu\n initialBlockSize := env.InitialRequestBlockSize()\n secondBlockSize := env.SecondRequestBlockSize()\n // Check what block_size is used for block2 option\n // If the initialBlockSize is set: client will always request with block2 option\n // If the initialBlockSize is not set and the secondBlockSize is set: if the secondBlockSize is greater than the\n // recommended block size -> use the recommended block size, reversely, use the configured block size\n // If both initialBlockSize and secondBlockSize are not set -> use the recommended block size\n if initialBlockSize == nil && secondBlockSize != nil {\n if *secondBlockSize > block.SZX {\n log.Warn(\"Second block size must not greater thans block size received from server\")\n block.NUM += 1\n } else {\n block.NUM = 1 << uint(block.SZX - *secondBlockSize)\n block.SZX = *secondBlockSize\n }\n } else {\n block.NUM += 1\n }\n } else {\n if data, ok := env.responseBlocks[blockKey]; ok {\n env.responseBlocks[blockKey].Data = append(data.Data, pdu.Data...)\n block.NUM += 1\n } else {\n log.Warnf(\"The block version is not unknown. Re-request from the first block\")\n delete(env.responseBlocks, blockKey)\n block.NUM = 0\n }\n }\n block.M = 0\n return isMoreBlock, &eTag, block\n } else if block.M == libcoap.LAST_BLOCK {\n log.Debugf(\"Response block is comming (eTag=%+v, block=%+v, size2=%+v), this is the last block.\", eTag, block.ToString(), size2Value)\n isMoreBlock = false\n if data, ok := env.responseBlocks[blockKey]; ok {\n env.responseBlocks[blockKey].Data = append(data.Data, pdu.Data...)\n } else if block.NUM > 0 {\n log.Warnf(\"The block version is not unknown. Re-request from the first block\")\n delete(env.responseBlocks, blockKey)\n block.NUM = 0\n isMoreBlock = true\n }\n return isMoreBlock, &eTag, block\n }\n }\n return false, nil, nil\n}", "func block(c echo.Context) error {\n\tpprof.Handler(\"block\").ServeHTTP(c.Response().Writer, c.Request())\n\treturn nil\n}", "func (dc *DeliverClient) RequestBlock(req *cb.Envelope) (*cb.Block, error) {\n\tde, conn, cancel, err := newAtomicBroadcastDeliverClient(dc.endpoint)\n\tif err != nil {\n\t\tlogger.Error(\"Error creating deliver client\", err)\n\t\treturn nil, err\n\t}\n\n\tdefer conn.Close()\n\tdefer de.CloseSend()\n\tdefer cancel()\n\n\terr = de.Send(req)\n\tif err != nil {\n\t\tlogger.Error(\"Error sending block request\", err)\n\t\treturn nil, err\n\t}\n\n\tmsg, err := de.Recv()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error receiving\")\n\t}\n\tswitch t := msg.Type.(type) {\n\tcase *ab.DeliverResponse_Status:\n\t\tlogger.Infof(\"Got status: %v\", t)\n\t\treturn nil, errors.Errorf(\"can't read the block: %v\", t)\n\tcase *ab.DeliverResponse_Block:\n\t\tlogger.Infof(\"Received block: %v\", t.Block.Header.Number)\n\t\tde.Recv() // Flush the success message\n\t\treturn t.Block, nil\n\tdefault:\n\t\treturn nil, errors.Errorf(\"response error: unknown type %T\", t)\n\t}\n}", "func GetBlockHandler(w http.ResponseWriter, r *http.Request) {\n\t// update in case last update is newer\n\tvars := mux.Vars(r)\n\t// convert block index string to uint64\n\tblockID, _ := strconv.ParseUint(vars[\"blockId\"], 10, 64)\n\n\ttmp := atomic.LoadUint64(&lastBlock)\n\tif blockID > tmp {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\terr := fmt.Errorf(\"requested id %d latest %d\", blockID, lastBlock)\n\t\tlog.Println(err.Error())\n\t\t_, _ = w.Write([]byte(err.Error()))\n\t\treturn\n\t}\n\t// retuning anything in the body regardless of any error code\n\t// it may contain\n\t_, _, body, _ := dataCollection.GetBlock(blockID, config.DefaultRequestsTimeout)\n\twriteResponse(body, &w)\n}", "func httpAvailHandler(c *web.C, h http.Handler) http.Handler {\n\tfn := func(w http.ResponseWriter, r *http.Request) {\n\t\tif httpUnavailable(w) || blockedRequest(w, r) {\n\t\t\treturn\n\t\t}\n\t\th.ServeHTTP(w, r)\n\t}\n\treturn http.HandlerFunc(fn)\n}", "func (a API) SubmitBlockChk() (isNew bool) {\n\tselect {\n\tcase o := <-a.Ch.(chan SubmitBlockRes):\n\t\tif o.Err != nil {\n\t\t\ta.Result = o.Err\n\t\t} else {\n\t\t\ta.Result = o.Res\n\t\t}\n\t\tisNew = true\n\tdefault:\n\t}\n\treturn\n}", "func BlockHandler() echo.HandlerFunc {\n\treturn func(ctx echo.Context) error {\n\t\tHandler(\"block\").ServeHTTP(ctx)\n\t\treturn nil\n\t}\n}", "func (app *App) blockHeaders(w http.ResponseWriter, r *http.Request, logger *zap.Logger) {\n\tt0 := time.Now()\n\n\ttoLog := carbonapipb.NewAccessLogDetails(r, \"blockHeaders\", &app.config)\n\tlogLevel := zap.InfoLevel\n\tdefer func() {\n\t\tapp.deferredAccessLogging(logger, r, &toLog, t0, logLevel)\n\t}()\n\n\tw.Header().Set(\"Content-Type\", contentTypeJSON)\n\n\tfailResponse := []byte(`{\"success\":\"false\"}`)\n\tif !app.requestBlocker.AddNewRules(r.URL.Query()) {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\ttoLog.HttpCode = http.StatusBadRequest\n\t\tif _, err := w.Write(failResponse); err != nil {\n\t\t\ttoLog.HttpCode = 499\n\t\t\tlogLevel = zapcore.WarnLevel\n\t\t}\n\t\treturn\n\t}\n\t_, err := w.Write([]byte(`{\"success\":\"true\"}`))\n\n\ttoLog.HttpCode = http.StatusOK\n\tif err != nil {\n\t\ttoLog.HttpCode = 499\n\t\tlogLevel = zapcore.WarnLevel\n\t}\n}", "func (app *App) blockHeaders(w http.ResponseWriter, r *http.Request, logger *zap.Logger) {\n\tt0 := time.Now()\n\n\tapiMetrics.Requests.Add(1)\n\n\ttoLog := carbonapipb.NewAccessLogDetails(r, \"blockHeaders\", &app.config)\n\tlogLevel := zap.InfoLevel\n\tdefer func() {\n\t\tapp.deferredAccessLogging(logger, r, &toLog, t0, logLevel)\n\t}()\n\n\tw.Header().Set(\"Content-Type\", contentTypeJSON)\n\n\tfailResponse := []byte(`{\"success\":\"false\"}`)\n\tif !app.requestBlocker.AddNewRules(r.URL.Query()) {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\ttoLog.HttpCode = http.StatusBadRequest\n\t\tif _, err := w.Write(failResponse); err != nil {\n\t\t\ttoLog.HttpCode = 499\n\t\t\tlogLevel = zapcore.WarnLevel\n\t\t}\n\t\treturn\n\t}\n\t_, err := w.Write([]byte(`{\"success\":\"true\"}`))\n\n\ttoLog.HttpCode = http.StatusOK\n\tif err != nil {\n\t\ttoLog.HttpCode = 499\n\t\tlogLevel = zapcore.WarnLevel\n\t}\n}", "func (o GetResolverFirewallRulesFirewallRuleOutput) BlockResponse() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetResolverFirewallRulesFirewallRule) string { return v.BlockResponse }).(pulumi.StringOutput)\n}", "func (resp *ActionVpsFeatureUpdateAllResponse) IsBlocking() bool {\n\treturn resp.Response.Meta != nil && resp.Response.Meta.ActionStateId > 0\n}", "func (app *application) Block(additional uint) error {\n\tendpoint := fmt.Sprintf(\"%s%d\", \"/blocks/\", additional)\n\turl := fmt.Sprintf(baseFormat, app.url, endpoint)\n\n\tresp, err := app.client.R().\n\t\tSetHeader(shared.TokenHeadKeyname, app.token).\n\t\tPost(url)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif resp.StatusCode() == http.StatusOK {\n\t\treturn nil\n\t}\n\n\treturn errors.New(string(resp.Body()))\n}", "func (l *Limiter) Wait() {\n\tisAllowed, sleep := l.Allow(time.Now())\n\tif !isAllowed {\n\t\ttime.Sleep(sleep)\n\t}\n}", "func (dc *PeerClient) RequestBlock(req *cb.Envelope) (*cb.Block, error) {\n\tde, conn, cancel, err := newPeerDeliverClient(dc.endpoint)\n\tif err != nil {\n\t\tlogger.Error(\"Error creating deliver client\", err)\n\t\treturn nil, err\n\t}\n\n\tdefer conn.Close()\n\tdefer de.CloseSend()\n\tdefer cancel()\n\n\terr = de.Send(req)\n\tif err != nil {\n\t\tlogger.Error(\"Error sending block request\", err)\n\t\treturn nil, err\n\t}\n\n\tmsg, err := de.Recv()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error receiving\")\n\t}\n\tswitch t := msg.Type.(type) {\n\tcase *pb.DeliverResponse_Status:\n\t\tlogger.Infof(\"Got status: %v\", t)\n\t\treturn nil, errors.Errorf(\"can't read the block: %v\", t)\n\tcase *pb.DeliverResponse_Block:\n\t\tlogger.Infof(\"Received block: %v\", t.Block.Header.Number)\n\t\tde.Recv() // Flush the success message\n\t\treturn t.Block, nil\n\tdefault:\n\t\treturn nil, errors.Errorf(\"response error: unknown type %T\", t)\n\t}\n}", "func denyHandler(w http.ResponseWriter, r *http.Request) {\n\t// XXX could log more fields e.g. specific headers,\n\tlog.Printf(\"received request: method=%q host=%q url=%q \", r.Method, r.Host, r.URL.String())\n\tw.WriteHeader(http.StatusForbidden)\n\tw.Write([]byte(\"Not allowed.\"))\n}", "func (r *reader) GetMaliciousBlocking() (blocking bool, err error) {\n\treturn r.envParams.GetOnOff(\"BLOCK_MALICIOUS\", libparams.Default(\"on\"))\n}", "func (bl BlockList) Response() *http.Response {\n\treturn bl.rawResponse\n}", "func (resp *ActionUserDeleteResponse) IsBlocking() bool {\n\treturn resp.Response.Meta != nil && resp.Response.Meta.ActionStateId > 0\n}", "func (r *RuntimeImpl) Block() {\n\t<-r.blocker\n}", "func (h *Hare) BlockingGetResult(id mesh.LayerID) ([]mesh.BlockID, error) {\n\tif h.isTooLate(id) {\n\t\treturn nil, ErrTooOld\n\t}\n\n\th.mu.RLock()\n\tblks, ok := h.outputs[id]\n\tif !ok {\n\t\th.mu.RUnlock()\n\t\treturn nil, ErrTooEarly\n\t}\n\th.mu.RUnlock()\n\treturn blks, nil\n}", "func (w *response) bodyAllowed() bool {\n\tif !w.wroteHeader {\n\t\tpanic(\"\")\n\t}\n\treturn bodyAllowedForStatus(w.status)\n}", "func (a API) GetBlockTemplateChk() (isNew bool) {\n\tselect {\n\tcase o := <-a.Ch.(chan GetBlockTemplateRes):\n\t\tif o.Err != nil {\n\t\t\ta.Result = o.Err\n\t\t} else {\n\t\t\ta.Result = o.Res\n\t\t}\n\t\tisNew = true\n\tdefault:\n\t}\n\treturn\n}", "func forbidden(rw http.ResponseWriter, r *http.Request) {\n\n}", "func (as *AddrServer) HandleGetBlocks(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tquery := r.URL.Query()\n\tlimit := \"10\"\n\tif len(query[\"limit\"]) > 0 {\n\t\tlimit = query[\"limit\"][0]\n\t}\n\tlim, err := strconv.ParseInt(limit, 10, 64)\n\tif err != nil {\n\t\tw.WriteHeader(400)\n\t\tw.Write(NewPostError(\"failed parsing ?limit={val}\", err))\n\t\treturn\n\t}\n\tw.Write(as.GetBlocksResponse(lim))\n}", "func (m Model) rejectRequest() (Model, tea.Cmd) {\n\tm.lh.response <- false\n\tm.status = linkRequestDenied\n\tif m.standalone {\n\t\treturn m, tea.Quit\n\t}\n\n\treturn m, nil\n}", "func (resp *ActionVpsConfigCreateResponse) IsBlocking() bool {\n\treturn resp.Response.Meta != nil && resp.Response.Meta.ActionStateId > 0\n}", "func (resp *ActionExportCreateResponse) IsBlocking() bool {\n\treturn resp.Response.Meta != nil && resp.Response.Meta.ActionStateId > 0\n}", "func (this pool) block(\n\thandle string, context ServerContext, access Access,\n) error {\n\t// Ignore self\n\tif handle == this.handle {\n\t\treturn fmt.Errorf(\n\t\t\t\"user \\\"%s\\\" attempted to delete self from pool\", this.handle,\n\t\t)\n\t}\n\n\t// Confirm that the given user exists\n\tif _, err := getRawUserInfo(handle, context, access); err != nil {\n\t\treturn err\n\t}\n\n\t// Remove handle from user pool\n\tthis.users.remove(handle)\n\n\t// Update data\n\terr := access.Save(&this, true, context)\n\n\tif err == nil {\n\t\tlog.Printf(\"Blocked \\\"%s\\\" from %s\", handle, this)\n\t}\n\n\treturn err\n}", "func (b *BlockChain) maybeAcceptBlock(workerNumber uint32, block *block.Block, flags BehaviorFlags) (bool, error) {\n\tT.Ln(\"maybeAcceptBlock starting\")\n\t// The height of this block is one more than the referenced previous block.\n\tprevHash := &block.WireBlock().Header.PrevBlock\n\tprevNode := b.Index.LookupNode(prevHash)\n\tif prevNode == nil {\n\t\tstr := fmt.Sprintf(\"previous block %s is unknown\", prevHash)\n\t\tE.Ln(str)\n\t\treturn false, ruleError(ErrPreviousBlockUnknown, str)\n\t} else if b.Index.NodeStatus(prevNode).KnownInvalid() {\n\t\tstr := fmt.Sprintf(\"previous block %s is known to be invalid\", prevHash)\n\t\tE.Ln(str)\n\t\treturn false, ruleError(ErrInvalidAncestorBlock, str)\n\t}\n\tblockHeight := prevNode.height + 1\n\tT.Ln(\"block not found, good, setting height\", blockHeight)\n\tblock.SetHeight(blockHeight)\n\t// // To deal with multiple mining algorithms, we must check first the block header version. Rather than pass the\n\t// // direct previous by height, we look for the previous of the same algorithm and pass that.\n\t// if blockHeight < b.params.BIP0034Height {\n\t//\n\t// }\n\tT.Ln(\"sanitizing header versions for legacy\")\n\tvar DoNotCheckPow bool\n\tvar pn *BlockNode\n\tvar a int32 = 2\n\tif block.WireBlock().Header.Version == 514 {\n\t\ta = 514\n\t}\n\tvar aa int32 = 2\n\tif prevNode.version == 514 {\n\t\taa = 514\n\t}\n\tif a != aa {\n\t\tvar i int64\n\t\tpn = prevNode\n\t\tfor ; i < b.params.AveragingInterval-1; i++ {\n\t\t\tpn = pn.GetLastWithAlgo(a)\n\t\t\tif pn == nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tT.Ln(\"check for blacklisted addresses\")\n\ttxs := block.Transactions()\n\tfor i := range txs {\n\t\tif ContainsBlacklisted(b, txs[i], hardfork.Blacklist) {\n\t\t\treturn false, ruleError(ErrBlacklisted, \"block contains a blacklisted address \")\n\t\t}\n\t}\n\tT.Ln(\"found no blacklisted addresses\")\n\tvar e error\n\tif pn != nil {\n\t\t// The block must pass all of the validation rules which depend on the position\n\t\t// of the block within the block chain.\n\t\tif e = b.checkBlockContext(block, prevNode, flags, DoNotCheckPow); E.Chk(e) {\n\t\t\treturn false, e\n\t\t}\n\t}\n\t// Insert the block into the database if it's not already there. Even though it\n\t// is possible the block will ultimately fail to connect, it has already passed\n\t// all proof-of-work and validity tests which means it would be prohibitively\n\t// expensive for an attacker to fill up the disk with a bunch of blocks that\n\t// fail to connect. This is necessary since it allows block download to be\n\t// decoupled from the much more expensive connection logic. It also has some\n\t// other nice properties such as making blocks that never become part of the\n\t// main chain or blocks that fail to connect available for further analysis.\n\tT.Ln(\"inserting block into database\")\n\tif e = b.db.Update(func(dbTx database.Tx) (e error) {\n\t\treturn dbStoreBlock(dbTx, block)\n\t}); E.Chk(e) {\n\t\treturn false, e\n\t}\n\t// Create a new block node for the block and add it to the node index. Even if the block ultimately gets connected\n\t// to the main chain, it starts out on a side chain.\n\tblockHeader := &block.WireBlock().Header\n\tnewNode := NewBlockNode(blockHeader, prevNode)\n\tnewNode.status = statusDataStored\n\tb.Index.AddNode(newNode)\n\tT.Ln(\"flushing db\")\n\tif e = b.Index.flushToDB(); E.Chk(e) {\n\t\treturn false, e\n\t}\n\n\t// Connect the passed block to the chain while respecting proper chain selection\n\t// according to the chain with the most proof of work. This also handles\n\t// validation of the transaction scripts.\n\tT.Ln(\"connecting to best chain\")\n\tvar isMainChain bool\n\tif isMainChain, e = b.connectBestChain(newNode, block, flags); E.Chk(e) {\n\t\treturn false, e\n\t}\n\t// Notify the caller that the new block was accepted into the block chain. The caller would typically want to react\n\t// by relaying the inventory to other peers.\n\tT.Ln(\"sending out block notifications for block accepted\")\n\tb.ChainLock.Unlock()\n\tb.sendNotification(NTBlockAccepted, block)\n\tb.ChainLock.Lock()\n\treturn isMainChain, nil\n}", "func (rl *RateLimiter) Wait(ctx context.Context, resp *http.Response) interface{} {\n\trlRemaining := resp.Header.Get(\"x-ratelimit-remaining\")\n\trlReset := resp.Header.Get(\"x-ratelimit-reset\")\n\n\tvar remaining, resetTime int\n\tvar err error\n\n\tif rlRemaining != \"\" {\n\t\tremaining, err = strconv.Atoi(rlRemaining)\n\n\t\tif err != nil {\n\t\t\tlogErr(err)\n\t\t\treturn rl.Limiter.Wait(ctx)\n\t\t}\n\n\t\tif remaining > 0 {\n\t\t\treturn struct{}{}\n\t\t}\n\n\t\tif rlReset != \"\" {\n\t\t\tresetTime, err = strconv.Atoi(rlReset)\n\t\t\tif err != nil {\n\t\t\t\tlogErr(err)\n\t\t\t\treturn rl.Limiter.Wait(ctx)\n\t\t\t}\n\t\t\ttoWait := int64(resetTime) - time.Now().Unix()\n\n\t\t\tif toWait < 120 {\n\t\t\t\t<-time.After(time.Duration(toWait) * time.Second)\n\t\t\t\treturn struct{}{}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn rl.Limiter.Wait(ctx)\n}", "func (r *Requestor) RequestCandidate(ctx context.Context, hash []byte) (block.Block, error) {\n\tr.setRequesting(true)\n\tdefer r.setRequesting(false)\n\n\tif err := r.sendGetCandidate(hash); err != nil {\n\t\treturn block.Block{}, nil\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tlog.WithField(\"hash\", hex.EncodeToString(hash)).Debug(\"failed to receive candidate from the network\")\n\t\t\treturn block.Block{}, errors.New(\"failed to receive candidate from the network\")\n\t\tcase cm := <-r.candidateQueue:\n\t\t\tif bytes.Equal(cm.Header.Hash, hash) {\n\t\t\t\treturn cm, nil\n\t\t\t}\n\t\t}\n\t}\n}", "func (b *BlockProcessorQueue) CanPublish(block uint64) bool {\n\n\tresp := make(chan bool)\n\treq := Request{\n\t\tBlockNumber: block,\n\t\tResponseChan: resp,\n\t}\n\n\tb.CanPublishChan <- req\n\treturn <-resp\n\n}", "func (rl *RateLimiter) AllowRequest(id string) (bool, error) {\n\tnow := time.Now().UnixNano() / 1000 //microseconds\n\tclearBefore := now - (rl.intervalInMillis * 1000) //microseconds\n\tlog.Debug(\"clearBefore \", clearBefore)\n\n\telement, err := uuid()\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tlog.Debug(\"new element \", element)\n\n\tnewZSetExpireTime := rl.intervalInMillis/1000\n\n\tcmd := rl.client.Eval(concurrent_requests_limiter_lua, []string{id},rl.maxInInterval, now,element, clearBefore, newZSetExpireTime)\n\tif cmd.Err() != nil {\n\t\tlog.Warn(\"script execution error\", cmd.Err().Error())\n\t\treturn false, cmd.Err()\n\t}\n\n\tcmdOutput := cmd.Val()\n\tlog.Debug(\"script output \", cmdOutput)\n\toutputSlice, ok := cmdOutput.([]interface{})\n\tif !ok {\n\t\treturn false, errors.New(\"Unexcepted result type from Redis script execution\")\n\t}\n\n\treturn outputSlice[0] != nil, nil\n}", "func (f *IpFiltering) Blocked(ip string) bool {\n\treturn !f.Allowed(ip)\n}", "func (l *RateLimiter) Allow() bool {\n\treturn l.AllowN(1)\n}", "func (l *RateLimiter) Allow() bool {\n\treturn l.AllowN(1)\n}", "func Block(f *Feed) error {\n\tf.Channel.Block = ValueYes\n\treturn nil\n}", "func (c *Sender) Do(r *http.Request) (*http.Response, error) {\n\tc.attempts++\n\n\tif !c.reuseResponse || c.resp == nil {\n\t\tresp := NewResponse()\n\t\tresp.Request = r\n\t\tresp.Body = NewBody(c.content)\n\t\tresp.Status = c.status\n\t\tresp.StatusCode = c.statusCode\n\t\tc.resp = resp\n\t} else {\n\t\tc.resp.Body.(*Body).reset()\n\t}\n\n\tif c.pollAttempts > 0 {\n\t\tc.pollAttempts--\n\t\tc.resp.Status = \"Accepted\"\n\t\tc.resp.StatusCode = http.StatusAccepted\n\t\tSetAcceptedHeaders(c.resp)\n\t}\n\n\tif c.emitErrors > 0 || c.emitErrors < 0 {\n\t\tc.emitErrors--\n\t\tif c.err == nil {\n\t\t\treturn c.resp, fmt.Errorf(\"Faux Error\")\n\t\t}\n\t\treturn c.resp, c.err\n\t}\n\treturn c.resp, nil\n}", "func (o *EventRuleAction) GetBlockedOk() (*bool, bool) {\n\tif o == nil || o.Blocked == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Blocked, true\n}", "func HandleRequest(process func(), u *User) bool {\n\n\tselect {\n\tcase <-time.Tick(10 * time.Second):\n\t\tif u.IsPremium {\n\t\t\treturn true\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\tdefault:\n\n\t}\n\tprocess()\n\treturn true\n}", "func (cb *CircuitBreaker) Block() {\n\tcb.Lock()\n\tcb.blocked = true\n\tcb.Unlock()\n}", "func (r *defaultRacer) loopUntilResponse(u *url.URL) (*http.Response, error) {\n\tvar resp *http.Response\n\tfor {\n\t\tvar err error\n\t\tresp, err = http.Get(u.String())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif resp.StatusCode == 429 {\n\t\t\ttime.Sleep(time.Millisecond * 100)\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn resp, nil\n}", "func (b *BruteBlocker) Delay(userID string, sourceAddr string, successful bool) time.Duration {\n\tvar response = make(chan time.Duration)\n\t// NOTE that delay call must happen as request, just as all accesses to\n\t// internal data structures\n\tb.requests <- func() {\n\t\tresponse <- b.delay(userID, sourceAddr, successful)\n\t}\n\treturn <-response\n}", "func (r *rateLimiter) Block(key string) {\n\tnow := time.Now()\n\n\tr.Lock()\n\n\t// if there's nothing in the map we can\n\t// return straight away\n\tif _, ok := r.ops[key]; !ok {\n\t\tr.ops[key] = now\n\t\tr.Unlock()\n\t\treturn\n\t}\n\n\t// if time is up we can return straight away\n\tt := r.ops[key]\n\tdeadline := t.Add(r.delay)\n\tif now.After(deadline) {\n\t\tr.ops[key] = now\n\t\tr.Unlock()\n\t\treturn\n\t}\n\n\tremaining := deadline.Sub(now)\n\n\t// Set the time of the operation\n\tr.ops[key] = now.Add(remaining)\n\tr.Unlock()\n\n\t// Block for the remaining time\n\t<-time.After(remaining)\n}", "func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}", "func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}", "func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}", "func (app AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}", "func (bo *localBlockOracle) BlockEligible(id mesh.LayerID, pubKey string) bool {\n\treturn bo.oc.Eligible(uint32(id), bo.committeeSize, pubKey, nil)\n}", "func (rl *ChannelBasedRateLimiter) Allow() bool {\n\t_, ok := <-rl.t.C\n\treturn ok\n}", "func (o *singleObserver) Block() (interface{}, error) {\n\to.disposedMutex.Lock()\n\tdisposed := o.disposed\n\to.disposedMutex.Unlock()\n\tif !disposed {\n\t\tfor v := range o.done {\n\t\t\tswitch v := v.(type) {\n\t\t\tcase error:\n\t\t\t\treturn nil, v\n\t\t\tdefault:\n\t\t\t\treturn v, nil\n\t\t\t}\n\t\t}\n\t}\n\treturn nil, nil\n}", "func (r *RemoteList) BlockRemote(bad *udp.Addr) {\n\tif bad == nil {\n\t\t// relays can have nil udp Addrs\n\t\treturn\n\t}\n\tr.Lock()\n\tdefer r.Unlock()\n\n\t// Check if we already blocked this addr\n\tif r.unlockedIsBad(bad) {\n\t\treturn\n\t}\n\n\t// We copy here because we are taking something else's memory and we can't trust everything\n\tr.badRemotes = append(r.badRemotes, bad.Copy())\n\n\t// Mark the next interaction must recollect/dedupe\n\tr.shouldRebuild = true\n}", "func (a API) GetBestBlockChk() (isNew bool) {\n\tselect {\n\tcase o := <-a.Ch.(chan GetBestBlockRes):\n\t\tif o.Err != nil {\n\t\t\ta.Result = o.Err\n\t\t} else {\n\t\t\ta.Result = o.Res\n\t\t}\n\t\tisNew = true\n\tdefault:\n\t}\n\treturn\n}", "func BlockHandler() gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\tpprof.Handler(\"block\").ServeHTTP(c.Writer, c.Request)\n\t}\n}", "func MineBlock(w http.ResponseWriter, r *http.Request) {\n\t// Checks for the block in data field\n\tvar data BlockData\n\terr := json.NewDecoder(r.Body).Decode(&data)\n\tif err != nil {\n\t\tlog.Println(\"MineBlock: Received block failed to prase(JSON)\")\n\t}\n\n\tsuccess := b.GenerateNextBlock(data.Data)\n\tif success {\n\t\thub.broadcastMsg(RespLatestMsg())\n\t}\n}", "func (r *Request) handleResponse(task *task.MessageTask, response *libcoap.Pdu, env *task.Env) {\n\tisMoreBlock, eTag, block := r.env.CheckBlock(response)\n\t// if block is more block, sent request to server with block option\n\t// else display data received from server\n\tif isMoreBlock {\n\t\tr.pdu.MessageID = r.env.CoapSession().NewMessageID()\n\t\tr.pdu.SetOption(libcoap.OptionBlock2, uint32(block.ToInt()))\n\t\tr.pdu.SetOption(libcoap.OptionEtag, uint32(*eTag))\n\n\t\t// Add block2 option for waiting for response\n\t\tr.options[messages.BLOCK2] = block.ToString()\n\t\ttask.SetMessage(r.pdu)\n\t\tr.env.Run(task)\n\t} else {\n\t\tif eTag != nil && block.NUM > 0 {\n\t\t\tblockKey := strconv.Itoa(*eTag) + string(response.Token)\n\t\t\tresponse = r.env.GetBlockData(blockKey)\n\t\t\tdelete(r.env.Blocks(), blockKey)\n\t\t}\n\t\tif response.Type == libcoap.TypeNon {\n\t\t\tlog.Debugf(\"Success incoming PDU(HandleResponse): %+v\", response)\n\t\t}\n\n\t\t// Skip set analyze response data if it is the ping response\n\t\tif response.Code != 0 {\n\t\t\ttask.AddResponse(response)\n\t\t}\n\t}\n\n\t// Handle Session config task and ping task after receive response message \n\t// If this is response of Get session config without abnormal, restart ping task with latest parameters\n\t// Check if the request does not contains sid option -> if not, does not restart ping task when receive response\n\t// Else if this is response of Put session config with code Created -> stop the current session config task\n\t// Else if this is response of Delete session config with code Deleted -> stop the current session config task\n\tlog.Debugf(\"r.queryParam=%v\", r.queryParams)\n\tif (r.requestName == \"session_configuration\") {\n\t\tif (r.method == \"GET\") && (response.Code == libcoap.ResponseContent) && len(r.queryParams) > 0 {\n\t\t\tlog.Debug(\"Get with sid - Client update new values to system session configuration and restart ping task.\")\n\t\t\tRestartHeartBeatTask(response, r.env)\n\t\t\tRefreshSessionConfig(response, r.env, r.pdu)\n\t\t} else if (r.method == \"PUT\") && (response.Code == libcoap.ResponseCreated) {\n\t\t\tlog.Debug(\"The new session configuration has been created. Stop the current session config task\")\n\t\t\tRefreshSessionConfig(response, r.env, r.pdu)\n\t\t} else if (r.method == \"DELETE\") && (response.Code == libcoap.ResponseDeleted) {\n\t\t\tlog.Debug(\"The current session configuration has been deleted. Stop the current session config task\")\n\t\t\tRefreshSessionConfig(response, r.env, r.pdu)\n\t\t}\n\t}\n}", "func (ws *Watchers) Block(args *Args, _ *bool) error {\n\tws.mu.Lock()\n\tdefer ws.mu.Unlock()\n\tw, ok := ws.lookup[args.WatcherID]\n\tif !ok {\n\t\treturn fmt.Errorf(\"no watcher with id %v\", args.WatcherID)\n\t}\n\tw.mu.Lock()\n\tw.sentinelCount++\n\tw.mu.Unlock()\n\treturn nil\n}", "func (ds *Dsync) ReceiveBlock(sid, hash string, data []byte) ReceiveResponse {\n\tsess, ok := ds.sessionPool[sid]\n\tif !ok {\n\t\treturn ReceiveResponse{\n\t\t\tHash: hash,\n\t\t\tStatus: StatusErrored,\n\t\t\tErr: fmt.Errorf(\"sid %q not found\", sid),\n\t\t}\n\t}\n\n\t// ReceiveBlock accepts a block from the sender, placing it in the local blockstore\n\tres := sess.ReceiveBlock(hash, bytes.NewReader(data))\n\n\t// check if transfer has completed, if so finalize it, but only once\n\tif res.Status == StatusOk && sess.IsFinalizedOnce() {\n\t\tif err := ds.finalizeReceive(sess); err != nil {\n\t\t\treturn ReceiveResponse{\n\t\t\t\tHash: sess.info.RootCID().String(),\n\t\t\t\tStatus: StatusErrored,\n\t\t\t\tErr: err,\n\t\t\t}\n\t\t}\n\t}\n\n\treturn res\n}", "func (o *OperationLimiter) Wait(r *request.Request) error {\n\treturn o.getLimiter().Wait(r.Context())\n}", "func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {}", "func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {}", "func (w *FilteredBlockWrapper) Block() *pb.FilteredBlock {\r\n\treturn w.block\r\n}", "func (r *Requester) Request(messageID hornet.MessageID, msIndex milestone.Index, preventDiscard ...bool) bool {\n\tif r.storage.SolidEntryPointsContain(messageID) {\n\t\treturn false\n\t}\n\n\tif r.storage.ContainsMessage(messageID) {\n\t\treturn false\n\t}\n\n\trequest := &Request{MessageID: messageID, MilestoneIndex: msIndex}\n\tif len(preventDiscard) > 0 {\n\t\trequest.PreventDiscard = preventDiscard[0]\n\t}\n\n\treturn r.enqueueAndSignal(request)\n}", "func (ch *clientSecureChannel) handleResponse(res ua.ServiceResponse) error {\n\tch.mapPendingResponses()\n\thnd := res.Header().RequestHandle\n\tif op, ok := ch.pendingResponses[hnd]; ok {\n\t\tdelete(ch.pendingResponses, hnd)\n\t\tselect {\n\t\tcase op.ResponseCh() <- res:\n\t\tdefault:\n\t\t\tfmt.Println(\"In handleResponse, responseCh was blocked.\")\n\t\t}\n\t\treturn nil\n\t}\n\treturn ua.BadUnknownResponse\n}", "func checkResponseRateLimit(resp *http.Response, logger log.Logger, defaultAbuseSleep time.Duration) whener {\n\tif err := asErrRateLimit(resp); err != nil {\n\t\treturn err\n\t}\n\n\tif err := asErrAbuseRateLimit(resp, logger, defaultAbuseSleep); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (s *Server) Block(ctx context.Context, req *rtypes.BlockRequest) (*rtypes.BlockResponse, *rtypes.Error) {\n\t_, _, b, err := s.getBlockByPartialId(ctx, req.BlockIdentifier)\n\tif err != nil {\n\t\treturn nil, types.DcrdError(err)\n\t}\n\tvar prev *wire.MsgBlock\n\n\t// Fetch the previous block when the current block disapproves of its\n\t// parent, since we'll need to reverse the transactions in the parent.\n\t// We include a special check for the genesis block because it has\n\t// VoteBits == 0.\n\tapprovesParent := b.Header.VoteBits&0x01 == 0x01\n\tif !approvesParent && b.Header.Height > 0 {\n\t\tprev, err = s.c.GetBlock(ctx, &b.Header.PrevBlock)\n\t\tif err != nil {\n\t\t\treturn nil, types.DcrdError(err, types.MapRpcErrCode(-5, types.ErrBlockNotFound))\n\t\t}\n\t}\n\n\tfetchInputs := s.makeInputsFetcher(ctx, nil)\n\trblock, err := types.WireBlockToRosetta(b, prev, fetchInputs, s.chainParams)\n\tif err != nil {\n\t\treturn nil, types.RError(err)\n\t}\n\treturn &rtypes.BlockResponse{\n\t\tBlock: rblock,\n\t}, nil\n}", "func (h HTTPHandler) HandleBlockInfo(w http.ResponseWriter, r *http.Request) {\n\terr := processJWT(r, false, h.secret)\n\tif err != nil {\n\t\thttp.Error(w, \"{\\\"message\\\": \\\"\"+err.Error()+\"\\\"}\", 401)\n\t\treturn\n\t}\n\n\tvars := mux.Vars(r)\n\tblockId, err := hex.DecodeString(vars[\"blockId\"])\n\n\tif err != nil {\n\t\thttp.Error(w, \"{\\\"message\\\": \\\"invalid block ID\\\"}\", 400)\n\t\treturn\n\t}\n\n\tblockchainPeer, err := getBlockchainById(h.bf, vars[\"blockchainId\"])\n\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), 400)\n\t\treturn\n\t}\n\n\tif blockchainPeer == nil {\n\t\thttp.Error(w, \"{\\\"message\\\": \\\"blockchain doesn't exist\\\"}\", 404)\n\t\treturn\n\t}\n\n\tvar block *blockchain.Block\n\n\terr = blockchainPeer.Db.View(func(dbtx *bolt.Tx) error {\n\t\tb := dbtx.Bucket([]byte(blockchain.BlocksBucket))\n\n\t\tif b == nil {\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"route\": \"HandleBlockInfo\",\n\t\t\t\t\"address\": r.Header.Get(\"address\"),\n\t\t\t}).Warn(\"bucket doesn't exist\")\n\t\t\treturn errors.New(\"block doesn't exist\")\n\t\t}\n\n\t\tencodedBlock := b.Get(blockId)\n\n\t\tif encodedBlock == nil {\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"route\": \"HandleBlockInfo\",\n\t\t\t\t\"address\": r.Header.Get(\"address\"),\n\t\t\t}).Error(\"block doesn't exist\")\n\t\t\treturn errors.New(\"block doesn't exist\")\n\t\t}\n\t\tblock = blockchain.DeserializeBlock(encodedBlock)\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\thttp.Error(w, \"{\\\"message\\\": \\\"block doesn't exist\\\"}\", 404)\n\t\treturn\n\t}\n\n\tblockInfoResponse := BlockInfo{BlockchainId: vars[\"blockchainId\"], BlockId: fmt.Sprintf(\"%x\", block.Hash), PrevBlockId: fmt.Sprintf(\"%x\", block.PrevBlockHash), BlockHeight: block.Height, TotalTransactions: block.TotalTransactions}\n\n\tmustEncode(w, blockInfoResponse)\n}", "func (c *Curator) blockIfNotLeader() {\n\tc.lock.Lock()\n\tfor !c.iAmLeader {\n\t\tc.iAmLeaderCond.Wait()\n\t}\n\tc.lock.Unlock()\n}", "func (u *Updater) HandleNoResponse(requestID []byte) {\n\tidStr := encodeToString(requestID)\n\tu.RLock()\n\ta, found := u.waiting[idStr]\n\tu.RUnlock()\n\tif !found {\n\t\treturn\n\t}\n\tu.Lock()\n\tdelete(u.waiting, idStr)\n\tu.Unlock()\n\tu.network.RemoveNodeID(a.NodeID, true)\n\tu.queueIdx(a.idx)\n}", "func (p *protocol) NonBlocking() bool {\n\treturn false\n}", "func HandleRequest(process func(), u *User) bool {\n\tctx := context.Background()\n\tif !u.IsPremium {\n\t\tvar cancel context.CancelFunc\n\t\tallowedSec := nonPremiumTimeSec - u.TimeUsed\n\t\tif allowedSec <= 0 {\n\t\t\tlog.Printf(\"User %v has no available time left\\n\", u.ID)\n\t\t\treturn false\n\t\t}\n\t\ttimeout := time.Duration(allowedSec) * time.Second\n\t\tctx, cancel = context.WithTimeout(ctx, timeout)\n\t\tdefer cancel()\n\t}\n\n\tready := make(chan struct{})\n\tdefer close(ready)\n\n\tgo runWithSignal(ctx, ready, process, u)\n\tselect {\n\tcase <-ready:\n\t\tlog.Printf(\"Process for user %v completed\\n\", u.ID)\n\t\treturn true\n\tcase <-ctx.Done():\n\t\tlog.Printf(\"Process for user %v timed out\\n\", u.ID)\n\t\treturn false\n\t}\n}", "func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBlock) {\n\tif app.deliverState.ms.TracingEnabled() {\n\t\tapp.deliverState.ms = app.deliverState.ms.SetTracingContext(nil).(store.CacheMultiStore)\n\t}\n\n\tif app.endBlocker != nil {\n\t\tres = app.endBlocker(app.deliverState.ctx, req)\n\t}\n\n\tvalMapper := validator.GetValidatorMapper(app.deliverState.ctx)\n\tif b := valMapper.IsEnableValidatorUpdated(); b {\n\t\tres.ValidatorUpdates = valMapper.GetValidatorUpdateSet()\n\t}\n\n\treturn\n}", "func (l *Limiter) Allow(now time.Time) (isAllowed bool, sleep time.Duration) {\n\telapsed := now.Sub(l.last)\n\n\t// \"rate * elapsed.Seconds()\" mean newly obtain tokens in the past elapsed time.\n\tl.tokens = l.tokens + l.rate*elapsed.Seconds()\n\tl.last = now\n\n\tif l.tokens > l.burst {\n\t\tl.tokens = l.burst\n\t}\n\n\t// Consume one token.\n\tl.tokens = l.tokens - 1\n\n\tif l.tokens < 0 {\n\t\t// \"-l.tokens / l.rate\" mean how many seconds can obtain these tokens.\n\t\treturn false, time.Duration(-l.tokens / l.rate * float64(time.Second))\n\t} else {\n\t\treturn true, 0\n\t}\n}", "func (bo *blockOracle) BlockEligible(id mesh.LayerID, pubKey string) bool {\n\treturn bo.oc.Eligible(uint32(id), bo.committeeSize, pubKey)\n}", "func (l *FixedLimiter) Allow() bool {\n\treturn l.AllowN(1)\n}", "func (r *reader) GetDNSMaliciousBlocking() (blocking bool, err error) {\n\treturn r.envParams.GetOnOff(\"BLOCK_MALICIOUS\", libparams.Default(\"on\"))\n}", "func BlockRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tvars := mux.Vars(r)\n\t\theight, err := strconv.ParseInt(vars[\"height\"], 10, 64)\n\t\tif err != nil {\n\t\t\trest.WriteErrorResponse(w, http.StatusBadRequest,\n\t\t\t\t\"ERROR: Couldn't parse block height. Assumed format is '/block/{height}'.\")\n\t\t\treturn\n\t\t}\n\t\tchainHeight, err := GetChainHeight(cliCtx)\n\t\tif height > chainHeight {\n\t\t\trest.WriteErrorResponse(w, http.StatusNotFound,\n\t\t\t\t\"ERROR: Requested block height is bigger then the chain length.\")\n\t\t\treturn\n\t\t}\n\t\toutput, err := getBlock(cliCtx, &height)\n\t\tif err != nil {\n\t\t\trest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())\n\t\t\treturn\n\t\t}\n\t\trest.PostProcessResponse(w, cdc, output, cliCtx.Indent)\n\t}\n}", "func (c Client) IsPollingAllowed(resp *http.Response, codes ...int) error {\n\tif c.DoNotPoll() && ResponseRequiresPolling(resp, codes...) {\n\t\treturn NewError(\"autorest.Client\", \"IsPollingAllowed\", \"Response to %s requires polling but polling is disabled\",\n\t\t\tresp.Request.URL)\n\t}\n\treturn nil\n}", "func (c *Client) Block() *Block {\n\treturn &Block{c}\n}", "func (api *Api) Block(number *int) (*models.Block, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), api.timeout)\n\tdefer cancel()\n\n\tblock, err := api.EthProxyServiceClient.Block(ctx, parseBlockGetter(number))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"fetch block grpc api request: %w\", err)\n\t}\n\n\treturn models.BlockFromProto(block), nil\n}", "func wouldBlock(fd int, timeout *syscall.Timeval) bool {\n\trd := syscall.FdSet{}\n\tfdset.Set(fd, &rd)\n\tn, err := syscall.Select(fd+1, &rd, nil, nil, timeout)\n\tif err != nil {\n\t\tlog.Printf(\"select error %s\\n\", err)\n\t\treturn false\n\t}\n\treturn n == 0\n}", "func Whitelist(c *blocker.Client, h http.Handler) http.Handler {\n\treturn WhitelistWithCode(c, h, http.StatusForbidden)\n}", "func (a API) GetBlockHeaderChk() (isNew bool) {\n\tselect {\n\tcase o := <-a.Ch.(chan GetBlockHeaderRes):\n\t\tif o.Err != nil {\n\t\t\ta.Result = o.Err\n\t\t} else {\n\t\t\ta.Result = o.Res\n\t\t}\n\t\tisNew = true\n\tdefault:\n\t}\n\treturn\n}", "func (c *Client) Allow(request *quotaservice.AllowRequest) (*quotaservice.AllowResponse, error) {\n\treturn c.qsClient.Allow(context.Background(), request)\n}", "func (r *Responder) Forbidden() { r.write(http.StatusForbidden) }", "func (s *TXPoolServer) verifyBlock(req *tc.VerifyBlockReq, sender *actor.PID) {\n\tif req == nil || len(req.Txs) == 0 {\n\t\treturn\n\t}\n\n\ts.setHeight(req.Height)\n\ts.pendingBlock.mu.Lock()\n\tdefer s.pendingBlock.mu.Unlock()\n\n\ts.pendingBlock.sender = sender\n\ts.pendingBlock.height = req.Height\n\ts.pendingBlock.processedTxs = make(map[common.Uint256]*tc.VerifyTxResult, len(req.Txs))\n\ts.pendingBlock.unProcessedTxs = make(map[common.Uint256]*tx.Transaction, 0)\n\n\ttxs := make(map[common.Uint256]bool, len(req.Txs))\n\n\t// Check whether a tx's gas price is lower than the required, if yes,\n\t// just return error\n\tfor _, t := range req.Txs {\n\t\tif t.GasPrice < s.gasPrice {\n\t\t\tentry := &tc.VerifyTxResult{\n\t\t\t\tHeight: s.pendingBlock.height,\n\t\t\t\tTx: t,\n\t\t\t\tErrCode: errors.ErrGasPrice,\n\t\t\t}\n\t\t\ts.pendingBlock.processedTxs[t.Hash()] = entry\n\t\t\ts.sendBlkResult2Consensus()\n\t\t\treturn\n\t\t}\n\t\t// Check whether double spent\n\t\tif _, ok := txs[t.Hash()]; ok {\n\t\t\tentry := &tc.VerifyTxResult{\n\t\t\t\tHeight: s.pendingBlock.height,\n\t\t\t\tTx: t,\n\t\t\t\tErrCode: errors.ErrDoubleSpend,\n\t\t\t}\n\t\t\ts.pendingBlock.processedTxs[t.Hash()] = entry\n\t\t\ts.sendBlkResult2Consensus()\n\t\t\treturn\n\t\t}\n\t\ttxs[t.Hash()] = true\n\t}\n\n\tcheckBlkResult := s.txPool.GetUnverifiedTxs(req.Txs, req.Height)\n\n\tfor _, t := range checkBlkResult.UnverifiedTxs {\n\t\ts.assignTxToWorker(t, tc.NilSender, nil)\n\t\ts.pendingBlock.unProcessedTxs[t.Hash()] = t\n\t}\n\n\tfor _, t := range checkBlkResult.OldTxs {\n\t\ts.reVerifyStateful(t, tc.NilSender)\n\t\ts.pendingBlock.unProcessedTxs[t.Hash()] = t\n\t}\n\n\tfor _, t := range checkBlkResult.VerifiedTxs {\n\t\ts.pendingBlock.processedTxs[t.Tx.Hash()] = t\n\t}\n\n\t/* If all the txs in the blocks are verified, send response\n\t * to the consensus directly\n\t */\n\tif len(s.pendingBlock.unProcessedTxs) == 0 {\n\t\ts.sendBlkResult2Consensus()\n\t}\n}", "func (client *Client) QueryBlock(request *QueryBlockRequest) (response *QueryBlockResponse, err error) {\n\tresponse = CreateQueryBlockResponse()\n\terr = client.DoAction(request, response)\n\treturn\n}", "func (r *reader) GetSurveillanceBlocking() (blocking bool, err error) {\n\t// Retro-compatibility\n\ts, err := r.envParams.GetEnv(\"BLOCK_NSA\")\n\tif err != nil {\n\t\treturn false, err\n\t} else if len(s) != 0 {\n\t\tr.logger.Warn(\"You are using the old environment variable BLOCK_NSA, please consider changing it to BLOCK_SURVEILLANCE\")\n\t\treturn r.envParams.GetOnOff(\"BLOCK_NSA\", libparams.Compulsory())\n\t}\n\treturn r.envParams.GetOnOff(\"BLOCK_SURVEILLANCE\", libparams.Default(\"off\"))\n}", "func (o *EventRuleAction) GetBlocked() bool {\n\tif o == nil || o.Blocked == nil {\n\t\tvar ret bool\n\t\treturn ret\n\t}\n\treturn *o.Blocked\n}", "func (m Model) acceptRequest() (Model, tea.Cmd) { // nolint: unparam\n\tm.lh.response <- true\n\treturn m, nil\n}", "func Ban(ip ban.IP, r *http.Request) ban.Ban {\n\tif IsMalicious(r) {\n\t\treturn ban.IPBan\n\t}\n\treturn ban.NoBan\n}", "func (cb *CircuitBreaker) Allow() bool {\n\t// force open the circuit, link is break so this is not allowed.\n\tif cb.forceOpen {\n\t\treturn false\n\t}\n\t// force close the circuit, link is not break so this is allowed.\n\tif cb.forceClose {\n\t\treturn true\n\t}\n\n\tvar now_ms int64\n\tnow_ms = NowInMs()\n\tcb.CalcStat(now_ms)\n\n\tif cb.circuitStatus == kCircuitClose {\n\t\treturn true\n\t} else {\n\t\tif cb.IsAfterSleepWindow(now_ms) {\n\t\t\tcb.lastCircuitOpenTime = now_ms\n\t\t\tcb.circuitStatus = kCircuitHalfOpen\n\t\t\t// sleep so long time, try ones, and set status to half-open\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}" ]
[ "0.6603521", "0.6544034", "0.62985706", "0.5726369", "0.5698893", "0.5625053", "0.5364136", "0.5360237", "0.531655", "0.5280611", "0.5275245", "0.52390784", "0.5230736", "0.5164695", "0.51578766", "0.5141324", "0.5141079", "0.51306504", "0.5129047", "0.51090413", "0.510555", "0.5102176", "0.5069094", "0.5066295", "0.5063157", "0.5046821", "0.50373685", "0.50182784", "0.5009538", "0.49775183", "0.4926558", "0.49265027", "0.49233007", "0.49072966", "0.4899888", "0.48803365", "0.48765174", "0.48745266", "0.48337406", "0.4825743", "0.4819031", "0.48078445", "0.48007023", "0.48007023", "0.47896996", "0.47809708", "0.47646475", "0.4763669", "0.476274", "0.47553754", "0.47525465", "0.4739682", "0.4736387", "0.4736387", "0.4736387", "0.47319648", "0.4731961", "0.4722052", "0.4720126", "0.47168592", "0.47155753", "0.4713382", "0.47116888", "0.47114345", "0.47112292", "0.4707037", "0.47052088", "0.46995476", "0.46995476", "0.46986875", "0.46979487", "0.46977836", "0.46894285", "0.46702716", "0.46538103", "0.46519846", "0.46514818", "0.46499828", "0.46460608", "0.4642767", "0.46356785", "0.4633924", "0.4632238", "0.46278095", "0.46277624", "0.46268004", "0.4623064", "0.46158227", "0.46089643", "0.46025363", "0.4596559", "0.45840633", "0.45825732", "0.45750645", "0.45695755", "0.4565317", "0.4564719", "0.45508286", "0.4547968", "0.4543003" ]
0.59495723
3
parseRange returns a block range if one exists, or an error if the request is invalid.
func (t *myTransport) parseRange(ctx context.Context, request ModifiedRequest) (r *blockRange, invalid, internal error) { if len(request.Params) == 0 { return nil, nil, nil } type filterQuery struct { BlockHash *string `json:"blockHash"` FromBlock *rpc.BlockNumber `json:"fromBlock"` ToBlock *rpc.BlockNumber `json:"toBlock"` } var fq filterQuery err := json.Unmarshal(request.Params[0], &fq) if err != nil { return nil, err, nil } if fq.BlockHash != nil { return nil, nil, nil } var start, end uint64 if fq.FromBlock != nil { switch *fq.FromBlock { case rpc.LatestBlockNumber, rpc.PendingBlockNumber: l, err := t.latestBlock.get(ctx) if err != nil { return nil, nil, err } start = l default: start = uint64(*fq.FromBlock) } } if fq.ToBlock == nil { l, err := t.latestBlock.get(ctx) if err != nil { return nil, nil, err } end = l } else { switch *fq.ToBlock { case rpc.LatestBlockNumber, rpc.PendingBlockNumber: l, err := t.latestBlock.get(ctx) if err != nil { return nil, nil, err } end = l default: end = uint64(*fq.ToBlock) } } return &blockRange{start: start, end: end}, nil, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func parseContentRange(r string) (parsed contentRange, err error) {\n\tinvalidErr := fmt.Errorf(\"invalid Content-Range: %v\", r)\n\n\t// Require that units == \"bytes\"\n\tconst bytesPrefix = \"bytes \"\n\tif !strings.HasPrefix(r, bytesPrefix) {\n\t\treturn parsed, invalidErr\n\t}\n\n\t// Split range from total length\n\tparts := strings.SplitN(r[len(bytesPrefix):], \"/\", 2)\n\tif len(parts) != 2 {\n\t\treturn parsed, invalidErr\n\t}\n\n\t// Process range\n\tif parts[0] == \"*\" {\n\t\tparsed.Start = -1\n\t\tparsed.End = -1\n\t} else {\n\t\trangeParts := strings.SplitN(parts[0], \"-\", 2)\n\t\tif len(rangeParts) != 2 {\n\t\t\treturn parsed, invalidErr\n\t\t}\n\t\tparsed.KnownRange = true\n\t\tparsed.Start, err = strconv.Atoi(rangeParts[0])\n\t\tif err != nil {\n\t\t\treturn parsed, invalidErr\n\t\t}\n\t\tparsed.End, err = strconv.Atoi(rangeParts[1])\n\t\tif err != nil {\n\t\t\treturn parsed, invalidErr\n\t\t}\n\t}\n\n\t// Process total length\n\tif parts[1] == \"*\" {\n\t\tparsed.Total = -1\n\t\tif !parsed.KnownRange {\n\t\t\t// Must know either range or total\n\t\t\treturn parsed, invalidErr\n\t\t}\n\t} else {\n\t\tparsed.KnownTotal = true\n\t\tparsed.Total, err = strconv.Atoi(parts[1])\n\t\tif err != nil {\n\t\t\treturn parsed, invalidErr\n\t\t}\n\t}\n\n\treturn parsed, nil\n}", "func parseRange(s string, size int64) ([]httpRange, error) {\n if s == \"\" {\n return nil, nil // header not present\n }\n const b = \"bytes=\"\n if !strings.HasPrefix(s, b) {\n return nil, errors.New(\"invalid range\")\n }\n var ranges []httpRange\n for _, ra := range strings.Split(s[len(b):], \",\") {\n ra = strings.TrimSpace(ra)\n if ra == \"\" {\n continue\n }\n i := strings.Index(ra, \"-\")\n if i < 0 {\n return nil, errors.New(\"invalid range\")\n }\n start, end := strings.TrimSpace(ra[:i]), strings.TrimSpace(ra[i+1:])\n var r httpRange\n if start == \"\" {\n // If no start is specified, end specifies the\n // range start relative to the end of the file.\n i, err := strconv.ParseInt(end, 10, 64)\n if err != nil {\n return nil, errors.New(\"invalid range\")\n }\n if i > size {\n i = size\n }\n r.start = size - i\n r.length = size - r.start\n } else {\n i, err := strconv.ParseInt(start, 10, 64)\n if err != nil || i > size || i < 0 {\n return nil, errors.New(\"invalid range\")\n }\n r.start = i\n if end == \"\" {\n // If no end is specified, range extends to end of the file.\n r.length = size - r.start\n } else {\n i, err := strconv.ParseInt(end, 10, 64)\n if err != nil || r.start > i {\n return nil, errors.New(\"invalid range\")\n }\n if i >= size {\n i = size - 1\n }\n r.length = i - r.start + 1\n }\n }\n ranges = append(ranges, r)\n }\n return ranges, nil\n}", "func parseRange(s string, size int64) ([]httpRange, error) {\n\tif s == \"\" {\n\t\treturn nil, nil // header not present\n\t}\n\tconst b = \"bytes=\"\n\tif !strings.HasPrefix(s, b) {\n\t\treturn nil, errors.New(\"invalid range\")\n\t}\n\tvar ranges []httpRange\n\tfor _, ra := range strings.Split(s[len(b):], \",\") {\n\t\tra = strings.TrimSpace(ra)\n\t\tif ra == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\ti := strings.Index(ra, \"-\")\n\t\tif i < 0 {\n\t\t\treturn nil, errors.New(\"invalid range\")\n\t\t}\n\t\tstart, end := strings.TrimSpace(ra[:i]), strings.TrimSpace(ra[i+1:])\n\t\tvar r httpRange\n\t\tif start == \"\" {\n\t\t\t// If no start is specified, end specifies the\n\t\t\t// range start relative to the end of the file.\n\t\t\ti, err := strconv.ParseInt(end, 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.New(\"invalid range\")\n\t\t\t}\n\t\t\tif i > size {\n\t\t\t\ti = size\n\t\t\t}\n\t\t\tr.start = size - i\n\t\t\tr.length = size - r.start\n\t\t} else {\n\t\t\ti, err := strconv.ParseInt(start, 10, 64)\n\t\t\tif err != nil || i > size || i < 0 {\n\t\t\t\treturn nil, errors.New(\"invalid range\")\n\t\t\t}\n\t\t\tr.start = i\n\t\t\tif end == \"\" {\n\t\t\t\t// If no end is specified, range extends to end of the file.\n\t\t\t\tr.length = size - r.start\n\t\t\t} else {\n\t\t\t\ti, err := strconv.ParseInt(end, 10, 64)\n\t\t\t\tif err != nil || r.start > i {\n\t\t\t\t\treturn nil, errors.New(\"invalid range\")\n\t\t\t\t}\n\t\t\t\tif i >= size {\n\t\t\t\t\ti = size - 1\n\t\t\t\t}\n\t\t\t\tr.length = i - r.start + 1\n\t\t\t}\n\t\t}\n\t\tranges = append(ranges, r)\n\t}\n\treturn ranges, nil\n}", "func parseRangeString(r string) (start, end, total int64) {\n\tfmt.Sscanf(r, \"bytes %d-%d/%d\", &start, &end, &total)\n\n\tif total != 0 && end > total {\n\t\tend = total\n\t}\n\tif start >= end {\n\t\tstart = 0\n\t\tend = 0\n\t}\n\n\treturn\n}", "func parse(text string) (IRange, error) {\n\tif index := strings.IndexByte(text, '/'); index != -1 {\n\t\tif _, network, err := net.ParseCIDR(text); err == nil {\n\t\t\treturn IpNetWrapper{network}, nil\n\t\t} else {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tif ip := parseIp(text); ip != nil {\n\t\treturn IpWrapper{ip}, nil\n\t}\n\tif index := strings.IndexByte(text, '-'); index != -1 {\n\t\tif start, end := parseIp(text[:index]), parseIp(text[index+1:]); start != nil && end != nil {\n\t\t\tif len(start) == len(end) && !lessThan(end, start) {\n\t\t\t\treturn &Range{start: start, end: end}, nil\n\t\t\t}\n\t\t}\n\t\treturn nil, &net.ParseError{Type: \"range\", Text: text}\n\t}\n\treturn nil, &net.ParseError{Type: \"ip/CIDR address/range\", Text: text}\n}", "func parse(s string, parseFn parseFunc, iplen int) Range {\n\tip, c := parseFn(s)\n\n\tif ip == nil {\n\t\treturn nil\n\t}\n\n\ts = s[c:]\n\n\tif len(s) > 0 && s[0] == '_' {\n\t\t// begin_end range.\n\n\t\tif ip.hasRanges() {\n\t\t\t// Already have octet ranges.\n\t\t\treturn nil\n\t\t}\n\n\t\ts = s[1:]\n\n\t\tmax, c := parseFn(s)\n\n\t\tif max == nil || max.hasRanges() || len(ip) != len(max) {\n\t\t\t// Invalid ip or have octet ranges.\n\t\t\treturn nil\n\t\t}\n\n\t\ts = s[c:]\n\n\t\t// Must have used entire string.\n\t\tif len(s) != 0 {\n\t\t\treturn nil\n\t\t}\n\n\t\treturn &minMaxRange{octets2ip(ip.min()), octets2ip(max.min())}\n\t}\n\n\tif len(s) > 0 && s[0] == '/' {\n\t\t// CIDR range.\n\n\t\tif ip.hasRanges() {\n\t\t\t// Already have octet ranges.\n\t\t\treturn nil\n\t\t}\n\n\t\ts = s[1:]\n\n\t\t// Decimal mask.\n\t\tn, c, ok := dtoi(s)\n\t\tif !ok || n < 0 || n > 8*iplen {\n\t\t\treturn nil\n\t\t}\n\n\t\ts = s[c:]\n\n\t\t// Must have used entire string.\n\t\tif len(s) != 0 {\n\t\t\treturn nil\n\t\t}\n\n\t\tmask := net.CIDRMask(n, iplen*8)\n\t\tmin := octets2ip(ip.min()).Mask(mask)\n\t\tmax := make(net.IP, len(min))\n\n\t\tfor i, m := range mask {\n\t\t\tif m == 0xff {\n\t\t\t\tmax[i] = min[i]\n\t\t\t} else {\n\t\t\t\tmax[i] = min[i] | (m ^ 0xff)\n\t\t\t}\n\t\t}\n\n\t\treturn &minMaxRange{min, max}\n\t}\n\n\t// Must have used entire string.\n\tif len(s) != 0 {\n\t\treturn nil\n\t}\n\n\tif !ip.hasRanges() {\n\t\t// singleRange ip.\n\t\treturn &singleRange{octets2ip(ip.min())}\n\t}\n\n\t// Sort ip2octets.\n\tip.sort()\n\n\treturn &octetsRange{ip}\n}", "func ParseContentRange(s string) (*HTTPRange, error) {\n\tif s == \"\" {\n\t\treturn nil, ErrInvalidFormat // header not present\n\t}\n\n\t// Only bytes are supported (for now)\n\tconst b = \"bytes \"\n\tif !strings.HasPrefix(s, b) {\n\t\treturn nil, ErrInvalidFormat\n\t}\n\n\tr := strings.Split(s[len(b):], \"/\")\n\tif len(r) != 2 {\n\t\treturn nil, ErrInvalidFormat\n\t}\n\tran := r[0]\n\tsize := strings.TrimSpace(r[1])\n\n\t// Parse size\n\ti, err := strconv.ParseInt(size, 10, 64)\n\tif err != nil {\n\t\treturn nil, ErrInvalidFormat\n\t}\n\thttpRange := &HTTPRange{\n\t\tSize: i,\n\t}\n\n\t// Parse ranges\n\tr = strings.Split(ran, \"-\")\n\tif len(r) != 2 {\n\t\treturn nil, ErrInvalidFormat\n\t}\n\tstart := strings.TrimSpace(r[0])\n\tend := strings.TrimSpace(r[1])\n\n\ti, err = strconv.ParseInt(start, 10, 64)\n\tif err != nil {\n\t\treturn nil, ErrInvalidFormat\n\t}\n\thttpRange.Start = i\n\ti, err = strconv.ParseInt(end, 10, 64)\n\tif err != nil {\n\t\treturn nil, ErrInvalidFormat\n\t}\n\thttpRange.End = i\n\n\t// Ensure range validity\n\tif httpRange.Start > httpRange.End {\n\t\treturn nil, ErrInvalidRange\n\t}\n\tif httpRange.End > httpRange.Size {\n\t\treturn nil, ErrInvalidRange\n\t}\n\n\treturn httpRange, nil\n}", "func parseRange(input string) (int, int, error) {\n\n\t// check for possible range\n\trangeSpec := strings.Split(input, \"-\")\n\n\tvar begin, end int\n\tvar err error\n\tswitch len(rangeSpec) {\n\tcase 1: // no range, simple columns\n\t\tbegin, err = strconv.Atoi(input)\n\t\tif err != nil {\n\t\t\treturn begin, end, fmt.Errorf(\"could not convert %s into integer representation\",\n\t\t\t\tinput)\n\t\t}\n\t\tend = begin\n\tcase 2: // range specified via begin and end\n\t\tbegin, err = strconv.Atoi(rangeSpec[0])\n\t\tif err != nil {\n\t\t\treturn begin, end, fmt.Errorf(\"could not convert %s into integer representation\",\n\t\t\t\trangeSpec[0])\n\t\t}\n\n\t\tend, err = strconv.Atoi(rangeSpec[1])\n\t\tif err != nil {\n\t\t\treturn begin, end, fmt.Errorf(\"could not convert %s into integer representation\",\n\t\t\t\trangeSpec[1])\n\t\t}\n\tdefault:\n\t\treturn begin, end, fmt.Errorf(\"incorrect column range specification %s\", input)\n\t}\n\treturn begin, end, nil\n}", "func ParseHeaderRange(h string) (int64, int64, error) {\n\tif !strings.HasPrefix(h, \"bytes=\") {\n\t\treturn 0, 0, errMissingBytesPrefix\n\t}\n\n\th = strings.TrimPrefix(h, \"bytes=\")\n\n\tpieces := strings.Split(h, \"-\")\n\tif len(pieces) != 2 {\n\t\treturn 0, 0, errInvalidNumPieces\n\t}\n\n\tstart, err := strconv.ParseInt(pieces[0], 10, 64)\n\tif err != nil {\n\t\treturn 0, 0, errors.Wrap(err, \"parsing start value\")\n\t}\n\n\tend, err := strconv.ParseInt(pieces[1], 10, 64)\n\tif err != nil {\n\t\treturn 0, 0, errors.Wrap(err, \"parsing end value\")\n\t}\n\n\treturn start, end, nil\n}", "func (r *Range) Parse() (min int, max int, err error) {\n\tif r.Value != nil {\n\t\treturn r.Value.Parse()\n\t}\n\treturn aws.IntValue(r.RangeConfig.Min), aws.IntValue(r.RangeConfig.Max), nil\n}", "func parseRangeLine(line string) *note {\n\tparts := strings.Split(line, \": \")\n\n\tbes := strings.Split(parts[1], \" or \")\n\n\tbeginEnds := make([]*beginEnd, 0)\n\tfor _, secondPart := range bes {\n\t\tvals := strings.Split(secondPart, \"-\")\n\t\tstart, err := strconv.Atoi(vals[0])\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tend, err := strconv.Atoi(vals[1])\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tbe := &beginEnd{\n\t\t\tstart: start,\n\t\t\tend: end,\n\t\t}\n\t\tbeginEnds = append(beginEnds, be)\n\t}\n\n\treturn &note{\n\t\tname: parts[0],\n\t\tbe: beginEnds,\n\t}\n}", "func parseRangeLine(line string) *note {\n\tparts := strings.Split(line, \": \")\n\n\tbes := strings.Split(parts[1], \" or \")\n\n\tbeginEnds := make([]*beginEnd, 0)\n\tfor _, secondPart := range bes {\n\t\tvals := strings.Split(secondPart, \"-\")\n\t\tstart, err := strconv.Atoi(vals[0])\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tend, err := strconv.Atoi(vals[1])\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tbe := &beginEnd{\n\t\t\tstart: start,\n\t\t\tend: end,\n\t\t}\n\t\tbeginEnds = append(beginEnds, be)\n\t}\n\n\treturn &note{\n\t\tname: parts[0],\n\t\tbe: beginEnds,\n\t}\n}", "func expectRange(r *style.Range) parser {\n\treturn func(in parserInput) parserOutput {\n\t\t// check for start symbol\n\t\tout := expectString(r.StartSymbol)(in)\n\t\tif out.result == nil {\n\t\t\treturn fail()\n\t\t}\n\t\tin = out.remaining\n\t\tvar b strings.Builder\n\t\t_, err := b.WriteString(r.StartSymbol)\n\t\tcheck(err)\n\n\t\t// search until end symbol or end\n\t\tout = searchUntil(expectString(r.EndSymbol))(in)\n\t\ts := out.result.(search)\n\t\t_, err = b.WriteString(s.consumed)\n\t\tcheck(err)\n\n\t\t// if end symbol found, add to builder\n\t\tif s.result != nil {\n\t\t\t_, err = b.WriteString(r.EndSymbol)\n\t\t\tcheck(err)\n\t\t}\n\t\tin = out.remaining\n\t\treturn success(rangeOutput{b.String(), r}, in)\n\t}\n}", "func newRange(file *token.File, start, end token.Pos) Range {\n\tfileBase := file.Base()\n\tfileEnd := fileBase + file.Size()\n\tif !start.IsValid() {\n\t\tpanic(\"invalid start token.Pos\")\n\t}\n\tif !end.IsValid() {\n\t\tpanic(\"invalid end token.Pos\")\n\t}\n\tif int(start) < fileBase || int(start) > fileEnd {\n\t\tpanic(fmt.Sprintf(\"invalid start: %d not in [%d, %d]\", start, fileBase, fileEnd))\n\t}\n\tif int(end) < fileBase || int(end) > fileEnd {\n\t\tpanic(fmt.Sprintf(\"invalid end: %d not in [%d, %d]\", end, fileBase, fileEnd))\n\t}\n\tif start > end {\n\t\tpanic(\"invalid start: greater than end\")\n\t}\n\treturn Range{\n\t\tTokFile: file,\n\t\tStart: start,\n\t\tEnd: end,\n\t}\n}", "func parseRange(input string, tr translations) intRange {\n\t// Parses s as a base 10 int, after applying translations.\n\t// Panics if the parse fails or if result is under minval.\n\tparseInt := func(s string, minval int) int {\n\t\tvar n int64\n\t\tif t, ok := tr.lookup(s); ok {\n\t\t\ts = t\n\t\t}\n\t\tn, err := strconv.ParseInt(s, 10, 64)\n\t\tif err != nil || int(n) < minval {\n\t\t\tpanic(fmt.Errorf(\"invalid range %q: expected integer >= %d, got %q\",\n\t\t\t\tinput, minval, s))\n\t\t}\n\t\treturn int(n)\n\t}\n\t// After splitting on a slash, there must be 1 or 2 fields.\n\tparts := strings.Split(input, \"/\")\n\tif len(parts) > 2 {\n\t\tpanic(fmt.Errorf(\"invalid range: %q\", input))\n\t}\n\t// Parse the 'step' non-terminal, if present.\n\tr := intRange{}\n\tif len(parts) == 2 {\n\t\tr.step = parseInt(parts[1], 1)\n\t}\n\t// Parse the 'values' non-terminal.\n\tvalues := parts[0]\n\tif values == \"*\" {\n\t\t// An asterisk: include all values.\n\t\tr.low, r.high = 0, 9999\n\t} else if dash := strings.Index(values, \"-\"); dash >= 1 {\n\t\t// A dash: parse as \"low-high\".\n\t\tr.low = parseInt(values[:dash], 0)\n\t\tr.high = parseInt(values[dash+1:], 0)\n\t} else {\n\t\t// There are two possibilities: \"X\" or \"X/Y\".\n\t\t// In the first case, low = high = X.\n\t\t// In the second case, a range is implied: \"X-maxval/Y\".\n\t\tr.low = parseInt(values, 0)\n\t\tr.high = r.low\n\t\tif r.step != 0 {\n\t\t\tr.high = 9999\n\t\t}\n\t}\n\treturn r\n}", "func ParseRangeBoundaries(s string) (int, int, error) {\n\tms := RangeMatchPattern.FindStringSubmatch(s)\n\tif len(ms) != 3 {\n\t\treturn 0, 0,\n\t\t\tfmt.Errorf(\n\t\t\t\t`Invalid range pattern: %q. Must be of the form \"[<start>,<end>)\"`,\n\t\t\t\ts,\n\t\t\t)\n\t}\n\n\tstart, err := strconv.Atoi(ms[1])\n\tif err != nil {\n\t\treturn 0, 0, err\n\t}\n\n\tend, err := strconv.Atoi(ms[2])\n\tif err != nil {\n\t\treturn 0, 0, err\n\t}\n\n\tif end <= start {\n\t\treturn 0, 0, errors.New(\"End of range must be greater than start\")\n\t}\n\n\treturn start, end, nil\n}", "func getRange(expr string, r bounds) (uint64, error) {\n\tvar (\n\t\tstart, end, step uint\n\t\trangeAndStep = strings.Split(expr, \"/\")\n\t\tlowAndHigh = strings.Split(rangeAndStep[0], \"-\")\n\t\tsingleDigit = len(lowAndHigh) == 1\n\t\terr error\n\t)\n\n\tvar extra uint64\n\tif lowAndHigh[0] == \"*\" || lowAndHigh[0] == \"?\" {\n\t\tstart = r.min\n\t\tend = r.max\n\t\textra = starBit\n\t} else {\n\t\tstart, err = ParseInt(lowAndHigh[0])\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\tswitch len(lowAndHigh) {\n\t\tcase 1:\n\t\t\tend = start\n\t\tcase 2:\n\t\t\tend, err = ParseInt(lowAndHigh[1])\n\t\t\tif err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\tdefault:\n\t\t\treturn 0, fmt.Errorf(\"Too many hyphens: %s\", expr)\n\t\t}\n\t}\n\n\tswitch len(rangeAndStep) {\n\tcase 1:\n\t\tstep = 1\n\tcase 2:\n\t\tstep, err = ParseInt(rangeAndStep[1])\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\tif singleDigit {\n\t\t\tend = r.max\n\t\t}\n\tdefault:\n\t\treturn 0, fmt.Errorf(\"Too many slashes: %s\", expr)\n\t}\n\n\tif start < r.min {\n\t\treturn 0, fmt.Errorf(\"Beginning of range (%d) below minimum (%d): %s\", start, r.min, expr)\n\t}\n\tif end > r.max {\n\t\treturn 0, fmt.Errorf(\"End of range (%d) above maximum (%d): %s\", end, r.max, expr)\n\t}\n\tif start > end {\n\t\treturn 0, fmt.Errorf(\"Beginning of range (%d) beyond end of range (%d): %s\", start, end, expr)\n\t}\n\tif step == 0 {\n\t\treturn 0, fmt.Errorf(\"Step of range should be a positive number: %s\", expr)\n\t}\n\n\treturn getBits(start, end, step) | extra, nil\n}", "func (r Range) Parse() (min int, max int, err error) {\n\tif r.Value != nil && !r.RangeConfig.IsEmpty() {\n\t\treturn 0, 0, errInvalidRangeOpts\n\t}\n\n\tif r.Value != nil {\n\t\treturn r.Value.Parse()\n\t}\n\n\treturn *r.RangeConfig.Min, *r.RangeConfig.Max, nil\n}", "func TestParsing05(t *testing.T) {\n\tvar q = \"%a-b-c%d\"\n\tvar r = &RangeExpr{Buffer: q}\n\tr.Init()\n\tr.Expression.Init(q)\n\terr := r.Parse()\n\tif err == nil {\n\t\tt.Errorf(\"Expected Error, (Query: %s) should NOT BE parsed [contains %%, where not expected]\", q)\n\t}\n}", "func parseRangeQuery(p *parser) parserStateFn {\n\topTok := p.next() // Already checked to be the range operator token.\n\tvalTok := p.next()\n\tswitch valTok.typ {\n\tcase tokTypeError:\n\t\tp.backup(valTok)\n\t\treturn parseErrorTok\n\tcase tokTypeUnquotedLiteral, tokTypeQuotedLiteral:\n\t\tvar trm term\n\t\tif valTok.typ == tokTypeUnquotedLiteral {\n\t\t\ttrm = newTerm(valTok.val)\n\t\t} else {\n\t\t\ttrm = newQuotedTerm(valTok.val)\n\t\t}\n\t\tif trm.Wildcard {\n\t\t\treturn p.errorfAt(valTok.pos, \"cannot have a wildcard in range query token\")\n\t\t}\n\t\tvar q rpnStep\n\t\tswitch opTok.typ {\n\t\tcase tokTypeGt:\n\t\t\tq = &rpnGtRangeQuery{\n\t\t\t\tfield: p.field.val,\n\t\t\t\tterm: trm,\n\t\t\t\tlogLevelLess: p.logLevelLess,\n\t\t\t}\n\t\tcase tokTypeGte:\n\t\t\tq = &rpnGteRangeQuery{\n\t\t\t\tfield: p.field.val,\n\t\t\t\tterm: trm,\n\t\t\t\tlogLevelLess: p.logLevelLess,\n\t\t\t}\n\t\tcase tokTypeLt:\n\t\t\tq = &rpnLtRangeQuery{\n\t\t\t\tfield: p.field.val,\n\t\t\t\tterm: trm,\n\t\t\t\tlogLevelLess: p.logLevelLess,\n\t\t\t}\n\t\tcase tokTypeLte:\n\t\t\tq = &rpnLteRangeQuery{\n\t\t\t\tfield: p.field.val,\n\t\t\t\tterm: trm,\n\t\t\t\tlogLevelLess: p.logLevelLess,\n\t\t\t}\n\t\tdefault:\n\t\t\tlg.Fatalf(\"invalid opTok.typ=%v while parsing range query\", opTok.typ)\n\t\t}\n\t\tp.filter.addStep(q)\n\t\tp.field = nil\n\t\treturn parseAfterQuery\n\tdefault:\n\t\treturn p.errorfAt(valTok.pos, \"expected a literal after '%s'; got %s\",\n\t\t\topTok.val, valTok.typ)\n\t}\n}", "func fromProtocolRange(f *token.File, r protocol.Range) source.Range {\n\tstart := fromProtocolPosition(f, r.Start)\n\tvar end token.Pos\n\tswitch {\n\tcase r.End == r.Start:\n\t\tend = start\n\tcase r.End.Line < 0:\n\t\tend = token.NoPos\n\tdefault:\n\t\tend = fromProtocolPosition(f, r.End)\n\t}\n\treturn source.Range{\n\t\tStart: start,\n\t\tEnd: end,\n\t}\n}", "func (b Body) Range(start, end int) Range {\n\treturn Range{b.Position(start), b.Position(end)}\n}", "func (s Span) Range(tf *token.File) (Range, error) {\n\ts, err := s.WithOffset(tf)\n\tif err != nil {\n\t\treturn Range{}, err\n\t}\n\t// go/token will panic if the offset is larger than the file's size,\n\t// so check here to avoid panicking.\n\tif s.Start().Offset() > tf.Size() {\n\t\treturn Range{}, bug.Errorf(\"start offset %v is past the end of the file %v\", s.Start(), tf.Size())\n\t}\n\tif s.End().Offset() > tf.Size() {\n\t\treturn Range{}, bug.Errorf(\"end offset %v is past the end of the file %v\", s.End(), tf.Size())\n\t}\n\treturn Range{\n\t\tStart: tf.Pos(s.Start().Offset()),\n\t\tEnd: tf.Pos(s.End().Offset()),\n\t\tTokFile: tf,\n\t}, nil\n}", "func parseRangeConsent(dst *rangeConsent, data []byte, initialBit uint, maxVendorID uint16) (uint, error) {\n\t// Fixes #10\n\tif uint(len(data)) <= initialBit/8 {\n\t\treturn 0, fmt.Errorf(\"bit %d was supposed to start a new RangeEntry, but the consent string was only %d bytes long\", initialBit, len(data))\n\t}\n\t// If the first bit is set, it's a Range of IDs\n\tif isSet(data, initialBit) {\n\t\tstart, err := bitutils.ParseUInt16(data, initialBit+1)\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\tend, err := bitutils.ParseUInt16(data, initialBit+17)\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\tif start == 0 {\n\t\t\treturn 0, fmt.Errorf(\"bit %d range entry exclusion starts at 0, but the min vendor ID is 1\", initialBit)\n\t\t}\n\t\tif end > maxVendorID {\n\t\t\treturn 0, fmt.Errorf(\"bit %d range entry exclusion ends at %d, but the max vendor ID is %d\", initialBit, end, maxVendorID)\n\t\t}\n\t\tif end <= start {\n\t\t\treturn 0, fmt.Errorf(\"bit %d range entry excludes vendors [%d, %d]. The start should be less than the end\", initialBit, start, end)\n\t\t}\n\t\tdst.startID = start\n\t\tdst.endID = end\n\t\treturn 33, nil\n\t}\n\n\tvendorID, err := bitutils.ParseUInt16(data, initialBit+1)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tif vendorID == 0 || vendorID > maxVendorID {\n\t\treturn 0, fmt.Errorf(\"bit %d range entry excludes vendor %d, but only vendors [1, %d] are valid\", initialBit, vendorID, maxVendorID)\n\t}\n\n\tdst.startID = vendorID\n\tdst.endID = vendorID\n\treturn 17, nil\n}", "func ParseBlocklistP2PLine(l []byte) (r Range, ok bool, err error) {\n\tl = bytes.TrimSpace(l)\n\tif len(l) == 0 || bytes.HasPrefix(l, []byte(\"#\")) {\n\t\treturn\n\t}\n\t// TODO: Check this when IPv6 blocklists are available.\n\tcolon := bytes.LastIndexAny(l, \":\")\n\tif colon == -1 {\n\t\terr = errors.New(\"missing colon\")\n\t\treturn\n\t}\n\thyphen := bytes.IndexByte(l[colon+1:], '-')\n\tif hyphen == -1 {\n\t\terr = errors.New(\"missing hyphen\")\n\t\treturn\n\t}\n\thyphen += colon + 1\n\tr.Description = string(l[:colon])\n\tr.First = net.ParseIP(string(l[colon+1 : hyphen]))\n\tminifyIP(&r.First)\n\tr.Last = net.ParseIP(string(l[hyphen+1:]))\n\tminifyIP(&r.Last)\n\tif r.First == nil || r.Last == nil || len(r.First) != len(r.Last) {\n\t\terr = errors.New(\"bad IP range\")\n\t\treturn\n\t}\n\tok = true\n\treturn\n}", "func Range(value string) Option {\n\treturn setHeader(\"Range\", value)\n}", "func TestParsing01(t *testing.T) {\n\tvar q = \"-1\"\n\tvar r = &RangeExpr{Buffer: q}\n\tr.Init()\n\tr.Expression.Init(q)\n\terr := r.Parse()\n\tif err == nil {\n\t\tt.Errorf(\"Expected Error, (Query: %s) should NOT BE parsed [starts with -]\", q)\n\t}\n}", "func RangeFromString(s string) (Range, error) {\n\tp := strings.SplitN(s, \"!\", 2)\n\n\tsheet := Sheet(\"\")\n\n\tif len(p) > 1 {\n\t\tsheet = Sheet(p[0])\n\t}\n\n\tp = strings.SplitN(p[len(p)-1], \":\", 2)\n\n\tstart, err := CellFromString(p[0])\n\n\tif err != nil {\n\t\treturn Range{}, err\n\t}\n\n\tend := Cell{start.Column, start.Row}\n\n\tif len(p) > 1 {\n\t\tend, err = CellFromString(p[1])\n\n\t\tif err != nil {\n\t\t\treturn Range{}, err\n\t\t}\n\t}\n\n\treturn Range{sheet, start, end}, nil\n}", "func RangeFromString(ctx *context.T, min, max string) (Range, error) {\n\tvar vMin, vMax T\n\tif err := vMin.Set(min); err != nil {\n\t\treturn Range{}, verror.New(errInvalidVersion, ctx, min, err)\n\t}\n\tif err := vMax.Set(max); err != nil {\n\t\treturn Range{}, verror.New(errInvalidVersion, ctx, max, err)\n\t}\n\treturn Range{vMin, vMax}, nil\n}", "func parseRanged(ctx context.Context, rawStep []byte, stepVars H) (Range, error) {\n\n\t//Load \"range\" attribute and perform actions depending on its typing\n\tvar ranged Range\n\tif err := json.Unmarshal(rawStep, &ranged); err != nil {\n\t\treturn ranged, fmt.Errorf(\"unable to parse range expression: %v\", err)\n\t}\n\n\tswitch ranged.RawContent.(type) {\n\n\t//Nil means this is not a ranged data, append an empty item to force at least one iteration and exit\n\tcase nil:\n\t\tranged.Items = append(ranged.Items, RangeData{})\n\t\treturn ranged, nil\n\n\t//String needs to be parsed and possibly templated\n\tcase string:\n\t\tDebug(ctx, \"attempting to parse range expression\")\n\t\trawString := ranged.RawContent.(string)\n\t\tif len(rawString) == 0 {\n\t\t\treturn ranged, fmt.Errorf(\"range expression has been specified without any data\")\n\t\t}\n\n\t\t// Try parsing already templated data\n\t\terr := json.Unmarshal([]byte(\"{\\\"range\\\":\"+rawString+\"}\"), &ranged)\n\t\t// ... or fallback\n\t\tif err != nil {\n\t\t\t//Try templating and escaping data\n\t\t\tDebug(ctx, \"attempting to template range expression and parse it again\")\n\t\t\tvars, err := DumpStringPreserveCase(stepVars)\n\t\t\tif err != nil {\n\t\t\t\tWarn(ctx, \"failed to parse range expression when loading step variables: %v\", err)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tfor i := range vars {\n\t\t\t\tvars[i] = strings.ReplaceAll(vars[i], \"\\\"\", \"\\\\\\\"\")\n\t\t\t}\n\t\t\tcontent, err := interpolate.Do(string(rawStep), vars)\n\t\t\tif err != nil {\n\t\t\t\tWarn(ctx, \"failed to parse range expression when templating variables: %v\", err)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t//Try parsing data\n\t\t\terr = json.Unmarshal([]byte(content), &ranged)\n\t\t\tif err != nil {\n\t\t\t\tWarn(ctx, \"failed to parse range expression when parsing data into raw string: %v\", err)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tswitch ranged.RawContent.(type) {\n\t\t\tcase string:\n\t\t\t\trawString = ranged.RawContent.(string)\n\t\t\t\terr := json.Unmarshal([]byte(\"{\\\"range\\\":\"+rawString+\"}\"), &ranged)\n\t\t\t\tif err != nil {\n\t\t\t\t\tWarn(ctx, \"failed to parse range expression when parsing raw string into data: %v\", err)\n\t\t\t\t\treturn ranged, fmt.Errorf(\"unable to parse range expression: unable to transform string data into a supported range expression type\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t//Format data\n\tswitch t := ranged.RawContent.(type) {\n\n\t//Array-like data\n\tcase []interface{}:\n\t\tDebug(ctx, \"\\\"range\\\" data is array-like\")\n\t\tfor index, value := range ranged.RawContent.([]interface{}) {\n\t\t\tkey := strconv.Itoa(index)\n\t\t\tranged.Items = append(ranged.Items, RangeData{key, value})\n\t\t}\n\n\t//Number data\n\tcase float64:\n\t\tDebug(ctx, \"\\\"range\\\" data is number-like\")\n\t\tupperBound := int(ranged.RawContent.(float64))\n\t\tfor i := 0; i < upperBound; i++ {\n\t\t\tkey := strconv.Itoa(i)\n\t\t\tranged.Items = append(ranged.Items, RangeData{key, i})\n\t\t}\n\n\t//Map-like data\n\tcase map[string]interface{}:\n\t\tDebug(ctx, \"\\\"range\\\" data is map-like\")\n\t\tfor key, value := range ranged.RawContent.(map[string]interface{}) {\n\t\t\tranged.Items = append(ranged.Items, RangeData{key, value})\n\t\t}\n\n\t//Unsupported data format\n\tdefault:\n\t\treturn ranged, fmt.Errorf(\"\\\"range\\\" was provided an unsupported type %T\", t)\n\t}\n\n\tranged.Enabled = true\n\tranged.RawContent = nil\n\treturn ranged, nil\n}", "func (t *BPTree) Range(start, end []byte) (records Records, err error) {\n\tif compare(start, end) > 0 {\n\t\treturn nil, ErrStartKey\n\t}\n\n\treturn getRecordWrapper(t.findRange(start, end))\n}", "func (r *NSNormalizedRange) normalizedRange(ns *NormalizedString) (start, end int, ok bool) {\n\tif r.start > r.end || r.start < 0 || r.end > len(ns.alignments) {\n\t\treturn -1, -1, false\n\t}\n\treturn r.start, r.end, true\n}", "func TestParsing06(t *testing.T) {\n\tvar q = \"%a-b-c-1\"\n\tvar r = &RangeExpr{Buffer: q}\n\tr.Init()\n\tr.Expression.Init(q)\n\terr := r.Parse()\n\tif err != nil {\n\t\tt.Errorf(\"Expected NO Error, (Query: %s) should BE parsed [ends with -1]\", q)\n\t}\n}", "func newRanges(input string) (string, ranges) {\n\ttmp := strings.Split(input, \": \")\n\tout := ranges{}\n\tfieldName := tmp[0]\n\tfor _, ele := range strings.Split(tmp[1], \" or \") {\n\t\tr := validRange{}\n\t\tvar err error\n\t\tvalues := strings.Split(ele, \"-\")\n\t\tr.lower, err = strconv.ParseUint(values[0], 10, 64)\n\t\tfailOnError(err)\n\t\tr.upper, err = strconv.ParseUint(values[1], 10, 64)\n\t\tfailOnError(err)\n\t\tout = append(out, r)\n\t}\n\treturn fieldName, out\n}", "func parseIntegerParameterRange(input string) (*IntegerParameterRange, error) {\n\tvar start, end int\n\n\tvar err error\n\tif strings.Index(input, \"-\") >= 0 {\n\t\tarray := strings.Split(input, \"-\")\n\t\tif len(array) != 2 {\n\t\t\terr = errors.New(\"Failed to split the string type\")\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif start, err = strconv.Atoi(array[0]); err != nil {\n\t\t\t// negative values must be dropped here\n\t\t\treturn nil, err\n\t\t}\n\t\tif end, err = strconv.Atoi(array[1]); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\tif start, err = strconv.Atoi(input); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tend = start\n\t}\n\n\tif start > end {\n\t\terr = errors.New(\"The 'max-config-values' attributes MUST be greater or equal to their counterpart in 'min-config-values' attributes.\")\n\t\treturn nil, err\n\t}\n\n\treturn &IntegerParameterRange{\n\t\tstart: start,\n\t\tend: end,\n\t}, nil\n}", "func (q *Query) validate(timeFirstBlock, timeLastBlock int64, l int) []byte {\n\tif q.Range == nil {\n\t\treturn nil\n\t}\n\tif q.Range.Start < q.Range.End {\n\t\treturn q.ReturnMessageResponse(\"ERROR_fromTimestamp_LESS_THAN_tillTimestamp\")\n\t}\n\tif q.Range.Start < timeLastBlock || q.Range.End > timeFirstBlock {\n\t\treturn q.ReturnNILResponse()\n\t}\n\tif l == 0 {\n\t\treturn q.ReturnNILResponse()\n\t}\n\treturn nil\n}", "func (m *GetBufferResponse) GetRange() *Range {\n\tif m != nil {\n\t\treturn m.Range\n\t}\n\treturn nil\n}", "func NewRange(file *token.File, start, end token.Pos) Range {\n\tif file == nil {\n\t\tpanic(\"nil *token.File\")\n\t}\n\tif !start.IsValid() || !end.IsValid() {\n\t\tpanic(\"invalid start/end token.Pos\")\n\t}\n\n\t// TODO(adonovan): ideally we would make this stronger assertion:\n\t//\n\t// // Assert that file is non-nil and contains start and end.\n\t// _ = file.Offset(start)\n\t// _ = file.Offset(end)\n\t//\n\t// but some callers (e.g. packageCompletionSurrounding,\n\t// posToMappedRange) don't ensure this precondition.\n\n\treturn Range{\n\t\tTokFile: file,\n\t\tStart: start,\n\t\tEnd: end,\n\t}\n}", "func parseHTTPCodeRanges(r string) []int {\n\tre := regexp.MustCompile(\"\\\\d{3}(?:-\\\\d{3})*(?:,\\\\d{3}(?:-\\\\d{3})*)*\")\n\tcodes := []int{}\n\tfor _, code := range strings.Split(r, \",\") {\n\t\tcode = strings.TrimSpace(code)\n\t\tif code == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif !re.MatchString(code) {\n\t\t\tfmt.Println(\"Invalid range for: \", code)\n\t\t\tcontinue\n\t\t}\n\t\trg := strings.Split(code, \"-\")\n\t\tif len(rg) == 1 {\n\t\t\tval, _ := strconv.Atoi(rg[0])\n\t\t\tcodes = appendOrdered(codes, val)\n\t\t} else {\n\t\t\tif rg[0] > rg[1] {\n\t\t\t\trg[0], rg[1] = rg[1], rg[0]\n\t\t\t}\n\t\t\tmin, _ := strconv.Atoi(rg[0])\n\t\t\tmax, _ := strconv.Atoi(rg[1])\n\t\t\tfor i := min; i <= max; i++ {\n\t\t\t\tcodes = appendOrdered(codes, i)\n\t\t\t}\n\t\t}\n\t}\n\treturn codes\n}", "func TestParsing09(t *testing.T) {\n\tvar q = \"%%RANGE\"\n\tvar r = &RangeExpr{Buffer: q}\n\tr.Init()\n\tr.Expression.Init(q)\n\terr := r.Parse()\n\tif err != nil {\n\t\tt.Errorf(\"Expected NO Error, (Query: %s) should BE parsed [Top Level Lookup, %, %% etc]\", q)\n\t}\n\n\tr.Execute()\n\tresult, errs := r.Evaluate(store)\n\tvar expected = []string{\"ops-prod\", \"data-prod\", \"data-qa\"}\n\tif len(errs) != 0 || !compare(*result, expected) {\n\t\tt.Errorf(\"Expected NO Evaluate Error, (Query: %s) should BE %s [Got: %s]\", q, expected, *result)\n\t}\n}", "func (t *myTransport) block(ctx context.Context, parsedRequests []ModifiedRequest) (int, interface{}) {\n\tvar union *blockRange\n\tfor _, parsedRequest := range parsedRequests {\n\t\tctx = gotils.With(ctx, \"ip\", parsedRequest.RemoteAddr)\n\t\tif allowed, _ := t.AllowVisitor(parsedRequest); !allowed {\n\t\t\tgotils.L(ctx).Info().Print(\"Request blocked: Rate limited\")\n\t\t\treturn http.StatusTooManyRequests, jsonRPCLimit(parsedRequest.ID)\n\t\t} //else if added {\n\t\t// gotils.L(ctx).Debug().Printf(\"Added new visitor, ip: %v\", parsedRequest.RemoteAddr)\n\t\t// }\n\n\t\tif !t.MatchAnyRule(parsedRequest.Path) {\n\t\t\t// gotils.L(ctx).Debug().Print(\"Request blocked: Method not allowed\")\n\t\t\treturn http.StatusMethodNotAllowed, jsonRPCUnauthorized(parsedRequest.ID, parsedRequest.Path)\n\t\t}\n\t\tif t.blockRangeLimit > 0 && parsedRequest.Path == \"eth_getLogs\" {\n\t\t\tr, invalid, err := t.parseRange(ctx, parsedRequest)\n\t\t\tif err != nil {\n\t\t\t\treturn http.StatusInternalServerError, jsonRPCError(parsedRequest.ID, jsonRPCInternal, err.Error())\n\t\t\t} else if invalid != nil {\n\t\t\t\tgotils.L(ctx).Info().Printf(\"Request blocked: Invalid params: %v\", invalid)\n\t\t\t\treturn http.StatusBadRequest, jsonRPCError(parsedRequest.ID, jsonRPCInvalidParams, invalid.Error())\n\t\t\t}\n\t\t\tif r != nil {\n\t\t\t\tif l := r.len(); l > t.blockRangeLimit {\n\t\t\t\t\tgotils.L(ctx).Info().Println(\"Request blocked: Exceeds block range limit, range:\", l, \"limit:\", t.blockRangeLimit)\n\t\t\t\t\treturn http.StatusBadRequest, jsonRPCBlockRangeLimit(parsedRequest.ID, l, t.blockRangeLimit)\n\t\t\t\t}\n\t\t\t\tif union == nil {\n\t\t\t\t\tunion = r\n\t\t\t\t} else {\n\t\t\t\t\tunion.extend(r)\n\t\t\t\t\tif l := union.len(); l > t.blockRangeLimit {\n\t\t\t\t\t\tgotils.L(ctx).Info().Println(\"Request blocked: Exceeds block range limit, range:\", l, \"limit:\", t.blockRangeLimit)\n\t\t\t\t\t\treturn http.StatusBadRequest, jsonRPCBlockRangeLimit(parsedRequest.ID, l, t.blockRangeLimit)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 0, nil\n}", "func NewRange(meta RangeMetadata, engine Engine, allocator *allocator, gossip *gossip.Gossip) *Range {\n\tr := &Range{\n\t\tMeta: meta,\n\t\tengine: engine,\n\t\tallocator: allocator,\n\t\tgossip: gossip,\n\t\tpending: make(chan *LogEntry, 100 /* TODO(spencer): what's correct value? */),\n\t\tcloser: make(chan struct{}),\n\t}\n\treturn r\n}", "func (c *client) BlockHeadersByRange(startHeight, endHeight *big.Int) ([]types.Header, error) {\n\t// avoid the batch call if there's no range\n\tif startHeight.Cmp(endHeight) == 0 {\n\t\theader, err := c.BlockHeaderByNumber(startHeight)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn []types.Header{*header}, nil\n\t}\n\n\tcount := new(big.Int).Sub(endHeight, startHeight).Uint64() + 1\n\tbatchElems := make([]rpc.BatchElem, count)\n\tfor i := uint64(0); i < count; i++ {\n\t\theight := new(big.Int).Add(startHeight, new(big.Int).SetUint64(i))\n\t\tbatchElems[i] = rpc.BatchElem{\n\t\t\tMethod: \"eth_getBlockByNumber\",\n\t\t\tArgs: []interface{}{toBlockNumArg(height), false},\n\t\t\tResult: new(types.Header),\n\t\t\tError: nil,\n\t\t}\n\t}\n\n\tctxwt, cancel := context.WithTimeout(context.Background(), defaultRequestTimeout)\n\tdefer cancel()\n\terr := c.rpc.BatchCallContext(ctxwt, batchElems)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Parse the headers.\n\t// - Ensure integrity that they build on top of each other\n\t// - Truncate out headers that do not exist (endHeight > \"latest\")\n\tsize := 0\n\theaders := make([]types.Header, count)\n\tfor i, batchElem := range batchElems {\n\t\tif batchElem.Error != nil {\n\t\t\treturn nil, batchElem.Error\n\t\t} else if batchElem.Result == nil {\n\t\t\tbreak\n\t\t}\n\n\t\theader, ok := batchElem.Result.(*types.Header)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"unable to transform rpc response %v into types.Header\", batchElem.Result)\n\t\t}\n\t\tif i > 0 && header.ParentHash != headers[i-1].Hash() {\n\t\t\treturn nil, fmt.Errorf(\"queried header %s does not follow parent %s\", header.Hash(), headers[i-1].Hash())\n\t\t}\n\n\t\theaders[i] = *header\n\t\tsize = size + 1\n\t}\n\n\theaders = headers[:size]\n\treturn headers, nil\n}", "func (v *Provider) Range() (int64, error) {\n\tres, err := v.apiG()\n\n\tif res, ok := res.(Response); err == nil && ok {\n\t\treturn int64(res.Data.Attributes.RangeHvacOff), nil\n\t}\n\n\treturn 0, err\n}", "func parsePortRange(portRangeStr string) (start, end int, err error) {\n\tportsRange := strings.Split(portRangeStr, \"-\")\n\tif len(portsRange) != 2 {\n\t\treturn 0, 0, fmt.Errorf(\"wrong port range format: %s\", portRangeStr)\n\t}\n\n\tif start, err = strconv.Atoi(portsRange[0]); err != nil {\n\t\treturn 0, 0, err\n\t}\n\n\tif end, err = strconv.Atoi(portsRange[1]); err != nil {\n\t\treturn 0, 0, err\n\t}\n\n\tif end <= start {\n\t\treturn 0, 0, fmt.Errorf(\"start port must be smaller than end port: %s\", portRangeStr)\n\t}\n\n\treturn start, end, nil\n}", "func parseMediaRange(mediaRange string) (rangeParams, typeSubtype []string, err error) {\n\trangeParams = strings.Split(mediaRange, \";\")\n\ttypeSubtype = strings.Split(rangeParams[0], \"/\")\n\n\t// typeSubtype should have a length of exactly two.\n\tif len(typeSubtype) > 2 {\n\t\terr = fmt.Errorf(errInvalidTypeSubtype, rangeParams[0])\n\t\treturn\n\t} else {\n\t\ttypeSubtype = append(typeSubtype, \"*\")\n\t}\n\n\t// Sanitize typeSubtype.\n\ttypeSubtype[0] = strings.TrimSpace(typeSubtype[0])\n\ttypeSubtype[1] = strings.TrimSpace(typeSubtype[1])\n\tif typeSubtype[0] == \"\" {\n\t\ttypeSubtype[0] = \"*\"\n\t}\n\tif typeSubtype[1] == \"\" {\n\t\ttypeSubtype[1] = \"*\"\n\t}\n\n\treturn\n}", "func GetBlockNumberRange() uint64 {\n\n\tblockRange := Get(\"BlockRange\")\n\tif blockRange == \"\" {\n\t\treturn 100\n\t}\n\n\tparsedBlockRange, err := strconv.ParseUint(blockRange, 10, 64)\n\tif err != nil {\n\t\tlog.Printf(\"[!] Failed to parse block range : %s\\n\", err.Error())\n\t\treturn 100\n\t}\n\n\treturn parsedBlockRange\n\n}", "func TestParsing11(t *testing.T) {\n\tvar q = \"a-b-c-d\"\n\tvar r = &RangeExpr{Buffer: q}\n\tr.Init()\n\tr.Expression.Init(q)\n\terr := r.Parse()\n\tif err != nil {\n\t\tt.Errorf(\"Expected NO Error, (Query: %s) should BE parsed (a.b.c.d is valid ip)\", q)\n\t}\n\n\tr.Execute()\n\tresult, errs := r.Evaluate(store)\n\tvar expected = []string{\"a-b-c-d\"}\n\tif len(errs) != 0 || !compare(*result, expected) {\n\t\tt.Errorf(\"Expected NO Evaluate Error, (Query: %s) should BE %s [Got: %s]\", q, expected, *result)\n\t}\n}", "func checkHTTPContentRangeHeader(h string, pos int64) (int64, error) {\n\tif len(h) == 0 {\n\t\treturn 0, errors.New(\"http server does not honor download resume\")\n\t}\n\n\th = strings.TrimPrefix(h, \"bytes \")\n\tdash := strings.IndexByte(h, '-')\n\tif dash <= 0 {\n\t\treturn 0, errors.Errorf(\"malformed Content-Range header: %s\", h)\n\t}\n\n\tresume, err := strconv.ParseInt(h[:dash], 10, 64)\n\tif err != nil {\n\t\treturn 0, errors.Errorf(\"malformed start offset in Content-Range header: %s\", h)\n\t}\n\n\tif resume != pos {\n\t\treturn 0, errors.Errorf(\n\t\t\t\"expected resume position %d, found %d instead in Content-Range header: %s\",\n\t\t\tpos, resume, h)\n\t}\n\n\tslash := strings.IndexByte(h, '/')\n\tif slash <= 0 {\n\t\treturn 0, errors.Errorf(\"malformed Content-Range header: %s\", h)\n\t}\n\tsize, err := strconv.ParseInt(h[slash+1:], 10, 64)\n\tif err != nil {\n\t\treturn 0, errors.Errorf(\"malformed slash offset in Content-Range header: %s\", h)\n\t}\n\n\treturn size, nil\n}", "func GetRange(beginKey string, endKey string, callback KVDBGetRangeCallback) {\n\tkvdbOpQueue.Push(&getRangeReq{\n\t\tbeginKey, endKey, callback,\n\t})\n\tcheckOperationQueueLen()\n}", "func (r IntRangeBand) Parse() (min int, max int, err error) {\n\tminMax := strings.Split(string(r), \"-\")\n\tif len(minMax) != 2 {\n\t\treturn 0, 0, fmt.Errorf(\"invalid range value %s. Should be in format of ${min}-${max}\", string(r))\n\t}\n\tmin, err = strconv.Atoi(minMax[0])\n\tif err != nil {\n\t\treturn 0, 0, fmt.Errorf(\"cannot convert minimum value %s to integer\", minMax[0])\n\t}\n\tmax, err = strconv.Atoi(minMax[1])\n\tif err != nil {\n\t\treturn 0, 0, fmt.Errorf(\"cannot convert maximum value %s to integer\", minMax[1])\n\t}\n\treturn min, max, nil\n}", "func (r IntRangeBand) Parse() (min int, max int, err error) {\n\tminMax := strings.Split(string(r), \"-\")\n\tif len(minMax) != 2 {\n\t\treturn 0, 0, fmt.Errorf(\"invalid range value %s. Should be in format of ${min}-${max}\", string(r))\n\t}\n\tmin, err = strconv.Atoi(minMax[0])\n\tif err != nil {\n\t\treturn 0, 0, fmt.Errorf(\"cannot convert minimum value %s to integer\", minMax[0])\n\t}\n\tmax, err = strconv.Atoi(minMax[1])\n\tif err != nil {\n\t\treturn 0, 0, fmt.Errorf(\"cannot convert maximum value %s to integer\", minMax[1])\n\t}\n\treturn min, max, nil\n}", "func parseChunkTimeRangeValue(rangeValue []byte, value []byte) (\n\tchunkID string, labelValue model.LabelValue, err error,\n) {\n\tcomponentRef := componentsPool.Get().(*componentRef)\n\tdefer componentsPool.Put(componentRef)\n\tcomponents := decodeRangeKey(rangeValue, componentRef.components)\n\n\tswitch {\n\tcase len(components) < 3:\n\t\terr = errors.Errorf(\"invalid chunk time range value: %x\", rangeValue)\n\t\treturn\n\n\t// v1 & v2 schema had three components - label name, label value and chunk ID.\n\t// No version number.\n\tcase len(components) == 3:\n\t\tchunkID = string(components[2])\n\t\tlabelValue = model.LabelValue(components[1])\n\t\treturn\n\n\tcase len(components[3]) == 1:\n\t\tswitch components[3][0] {\n\t\t// v3 schema had four components - label name, label value, chunk ID and version.\n\t\t// \"version\" is 1 and label value is base64 encoded.\n\t\t// (older code wrote \"version\" as 1, not '1')\n\t\tcase chunkTimeRangeKeyV1a, chunkTimeRangeKeyV1:\n\t\t\tchunkID = string(components[2])\n\t\t\tlabelValue, err = decodeBase64Value(components[1])\n\t\t\treturn\n\n\t\t// v4 schema wrote v3 range keys and a new range key - version 2,\n\t\t// with four components - <empty>, <empty>, chunk ID and version.\n\t\tcase chunkTimeRangeKeyV2:\n\t\t\tchunkID = string(components[2])\n\t\t\treturn\n\n\t\t// v5 schema version 3 range key is chunk end time, <empty>, chunk ID, version\n\t\tcase chunkTimeRangeKeyV3:\n\t\t\tchunkID = string(components[2])\n\t\t\treturn\n\n\t\t// v5 schema version 4 range key is chunk end time, label value, chunk ID, version\n\t\tcase chunkTimeRangeKeyV4:\n\t\t\tchunkID = string(components[2])\n\t\t\tlabelValue, err = decodeBase64Value(components[1])\n\t\t\treturn\n\n\t\t// v6 schema added version 5 range keys, which have the label value written in\n\t\t// to the value, not the range key. So they are [chunk end time, <empty>, chunk ID, version].\n\t\tcase chunkTimeRangeKeyV5:\n\t\t\tchunkID = string(components[2])\n\t\t\tlabelValue = model.LabelValue(value)\n\t\t\treturn\n\n\t\t// v9 schema actually return series IDs\n\t\tcase seriesRangeKeyV1:\n\t\t\tchunkID = string(components[0])\n\t\t\treturn\n\n\t\tcase labelSeriesRangeKeyV1:\n\t\t\tchunkID = string(components[1])\n\t\t\tlabelValue = model.LabelValue(value)\n\t\t\treturn\n\t\t}\n\t}\n\terr = fmt.Errorf(\"unrecognised chunkTimeRangeKey version: %q\", string(components[3]))\n\treturn\n}", "func Parse(s string) Range {\n\tfor i := 0; i < len(s); i++ {\n\t\tswitch s[i] {\n\t\tcase '.':\n\t\t\treturn parse(s, parseIPv4, net.IPv4len)\n\t\tcase ':':\n\t\t\treturn parse(s, parseIPv6, net.IPv6len)\n\t\t}\n\t}\n\treturn nil\n}", "func (o RouterAdvertisedIpRangeResponseOutput) Range() pulumi.StringOutput {\n\treturn o.ApplyT(func(v RouterAdvertisedIpRangeResponse) string { return v.Range }).(pulumi.StringOutput)\n}", "func (t *ParseTransaction) Range() TextRange {\n\treturn TextRange{t.start, t.reader.CurrentPosition()}\n}", "func FuzzARange(input []byte) int {\n\treturn doFuzz(input, &snap.GetAccountRangePacket{}, snap.GetAccountRangeMsg)\n}", "func TestParsing13(t *testing.T) {\n\tvar q = \"1.2.3.4\"\n\tvar r = &RangeExpr{Buffer: q}\n\tr.Init()\n\tr.Expression.Init(q)\n\terr := r.Parse()\n\tif err != nil {\n\t\tt.Errorf(\"Expected NO Error, (Query: %s) should BE parsed (a.b.c.d is valid ip)\", q)\n\t}\n\n\tr.Execute()\n\tresult, errs := r.Evaluate(store)\n\tvar expected = []string{\"1.2.3.4\"}\n\tif len(errs) != 0 || !compare(*result, expected) {\n\t\tt.Errorf(\"Expected NO Evaluate Error, (Query: %s) should BE %s [Got: %s]\", q, expected, *result)\n\t}\n}", "func ParseTimeRange(duration, offset string) (*time.Time, *time.Time, error) {\n\t// endTime defaults to the current time, unless an offset is explicity declared,\n\t// in which case it shifts endTime back by given duration\n\tendTime := time.Now()\n\tif offset != \"\" {\n\t\to, err := ParseDuration(offset)\n\t\tif err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"error parsing offset (%s): %s\", offset, err)\n\t\t}\n\t\tendTime = endTime.Add(-1 * *o)\n\t}\n\n\t// if duration is defined in terms of days, convert to hours\n\t// e.g. convert \"2d\" to \"48h\"\n\tdurationNorm, err := normalizeTimeParam(duration)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"error parsing duration (%s): %s\", duration, err)\n\t}\n\n\t// convert time duration into start and end times, formatted\n\t// as ISO datetime strings\n\tdur, err := time.ParseDuration(durationNorm)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"errorf parsing duration (%s): %s\", durationNorm, err)\n\t}\n\tstartTime := endTime.Add(-1 * dur)\n\n\treturn &startTime, &endTime, nil\n}", "func ParseTimeRange(duration, offset string) (*time.Time, *time.Time, error) {\n\t// endTime defaults to the current time, unless an offset is explicity declared,\n\t// in which case it shifts endTime back by given duration\n\tendTime := time.Now()\n\tif offset != \"\" {\n\t\to, err := ParseDuration(offset)\n\t\tif err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"error parsing offset (%s): %s\", offset, err)\n\t\t}\n\t\tendTime = endTime.Add(-1 * *o)\n\t}\n\n\t// if duration is defined in terms of days, convert to hours\n\t// e.g. convert \"2d\" to \"48h\"\n\tdurationNorm, err := normalizeTimeParam(duration)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"error parsing duration (%s): %s\", duration, err)\n\t}\n\n\t// convert time duration into start and end times, formatted\n\t// as ISO datetime strings\n\tdur, err := time.ParseDuration(durationNorm)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"errorf parsing duration (%s): %s\", durationNorm, err)\n\t}\n\tstartTime := endTime.Add(-1 * dur)\n\n\treturn &startTime, &endTime, nil\n}", "func TestParsing04(t *testing.T) {\n\tvar q = \"%aa1-b-c-d1\"\n\tvar r = &RangeExpr{Buffer: q}\n\tr.Init()\n\tr.Expression.Init(q)\n\terr := r.Parse()\n\tif err != nil {\n\t\tt.Errorf(\"Expected NO Error, (Query: %s) should BE parsed [is of %%[a-z][a-z0-9-_]*\", q)\n\t}\n}", "func parseURL(url *url.URL) (BlockID, string, error) {\n\n\tpath := strings.Split(url.Path, \"/\")\n\tif len(path) != 5 || path[1] != \"block\" || path[2] == \"\" || path[3] != \"txs\" || path[4] == \"\" {\n\t\treturn \"\", \"\", errors.New(\"Invalid request path\")\n\t}\n\n\tblockPattern := path[2]\n\tif blockPattern != \"latest\" {\n\t\tblockNumber, err := strconv.Atoi(path[2])\n\t\tif err != nil || blockNumber < 0 {\n\t\t\treturn \"\", \"\", errors.New(\"Invalid block number: \" + path[2])\n\t\t}\n\t}\n\n\treturn BlockID(blockPattern), path[4], nil\n}", "func (lp *logPoller) GetBlocksRange(ctx context.Context, numbers []uint64, qopts ...pg.QOpt) ([]LogPollerBlock, error) {\n\tvar blocks []LogPollerBlock\n\n\t// Do nothing if no blocks are requested.\n\tif len(numbers) == 0 {\n\t\treturn blocks, nil\n\t}\n\n\t// Assign the requested blocks to a mapping.\n\tblocksRequested := make(map[uint64]struct{})\n\tfor _, b := range numbers {\n\t\tblocksRequested[b] = struct{}{}\n\t}\n\n\t// Retrieve all blocks within this range from the log poller.\n\tblocksFound := make(map[uint64]LogPollerBlock)\n\tqopts = append(qopts, pg.WithParentCtx(ctx))\n\tminRequestedBlock := mathutil.Min(numbers[0], numbers[1:]...)\n\tmaxRequestedBlock := mathutil.Max(numbers[0], numbers[1:]...)\n\tlpBlocks, err := lp.orm.GetBlocksRange(minRequestedBlock, maxRequestedBlock, qopts...)\n\tif err != nil {\n\t\tlp.lggr.Warnw(\"Error while retrieving blocks from log pollers blocks table. Falling back to RPC...\", \"requestedBlocks\", numbers, \"err\", err)\n\t} else {\n\t\tfor _, b := range lpBlocks {\n\t\t\tif _, ok := blocksRequested[uint64(b.BlockNumber)]; ok {\n\t\t\t\t// Only fill requested blocks.\n\t\t\t\tblocksFound[uint64(b.BlockNumber)] = b\n\t\t\t}\n\t\t}\n\t\tlp.lggr.Debugw(\"Got blocks from log poller\", \"blockNumbers\", maps.Keys(blocksFound))\n\t}\n\n\t// Fill any remaining blocks from the client.\n\tblocksFoundFromRPC, err := lp.fillRemainingBlocksFromRPC(ctx, numbers, blocksFound)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor num, b := range blocksFoundFromRPC {\n\t\tblocksFound[num] = b\n\t}\n\n\tvar blocksNotFound []uint64\n\tfor _, num := range numbers {\n\t\tb, ok := blocksFound[num]\n\t\tif !ok {\n\t\t\tblocksNotFound = append(blocksNotFound, num)\n\t\t}\n\t\tblocks = append(blocks, b)\n\t}\n\n\tif len(blocksNotFound) > 0 {\n\t\treturn nil, errors.Errorf(\"blocks were not found in db or RPC call: %v\", blocksNotFound)\n\t}\n\n\treturn blocks, nil\n}", "func (ipAllocator *IPAllocator) parseCIDR(cidr string) (net.IP, *net.IPNet, error) {\n\tip, ipnet, err := net.ParseCIDR(cidr)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\t// The reserved-ipv4-cidr network size must be at least /29\n\tcidrSize, _ := ipnet.Mask.Size()\n\tif cidrSize > ipRangeSize {\n\t\treturn nil, nil, fmt.Errorf(\"the reserved-ipv4-cidr network size must be at least /%d\", ipRangeSize)\n\t}\n\n\t// The IP specified in the reserved-ipv4-cidr must be aligned on the /29 network boundary\n\tif ip.String() != ip.Mask(ipRangeMask).String() {\n\t\treturn nil, nil, fmt.Errorf(\"the IP specified in the reserved-ipv4-cidr must be aligned on the /29 network boundary\")\n\t}\n\treturn ip, ipnet, nil\n}", "func (r FieldRule) ValidateRangeStmt(expr *ast.RangeStmt) error {\n\tbatchError := pepperlint.NewBatchError()\n\n\t// TODO Also check if key or value is being assigned to a deprecated field\n\tswitch t := expr.X.(type) {\n\tcase *ast.SelectorExpr:\n\t\tif err := r.isDeprecatedField(t); err != nil {\n\t\t\tbatchError.Add(err)\n\t\t}\n\t}\n\n\treturn batchError.Return()\n}", "func TestParsing12(t *testing.T) {\n\tvar q = \"1-2-3-4\"\n\tvar r = &RangeExpr{Buffer: q}\n\tr.Init()\n\tr.Expression.Init(q)\n\terr := r.Parse()\n\tif err != nil {\n\t\tt.Errorf(\"Expected NO Error, (Query: %s) should BE parsed (a.b.c.d is valid ip)\", q)\n\t}\n\n\tr.Execute()\n\tresult, errs := r.Evaluate(store)\n\tvar expected = []string{\"1-2-3-4\"}\n\tif len(errs) != 0 || !compare(*result, expected) {\n\t\tt.Errorf(\"Expected NO Evaluate Error, (Query: %s) should BE %s [Got: %s]\", q, expected, *result)\n\t}\n}", "func parseRangeSet(rs string) []Range {\n\tset := make([]Range, 0)\n\tfor _, s := range strings.Split(rs, \",\") {\n\t\tif len(s) == 0 {\n\t\t\treturn nil\n\t\t}\n\t\tp := strings.Split(s, \":\")\n\t\tif len(p) > 2 {\n\t\t\treturn nil\n\t\t}\n\t\tstart, err := strconv.ParseUint(p[0], 10, 32)\n\t\tif err != nil {\n\t\t\treturn nil\n\t\t}\n\t\tend := uint64(0)\n\t\tinfinite := false\n\t\tif len(p) > 1 {\n\t\t\tif p[1] == \"*\" {\n\t\t\t\tinfinite = true\n\t\t\t} else {\n\t\t\t\tend, err = strconv.ParseUint(p[1], 10, 32)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tset = append(set, Range{uint32(start), uint32(end), infinite})\n\t}\n\treturn set\n}", "func (b Body) GetRange(rng Range) string {\n\ts, e := b.Offset(rng.Start), b.Offset(rng.End)\n\treturn string(b.runes[s:e])\n}", "func (ipAllocator *IPAllocator) parseCIDR(cidr string, ipRangeSize int) (net.IP, *net.IPNet, error) {\n\tip, ipnet, err := net.ParseCIDR(cidr)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\t// The reserved-ipv4-cidr network size must be at least ipRangeSize\n\tcidrSize, _ := ipnet.Mask.Size()\n\tif cidrSize > ipRangeSize {\n\t\treturn nil, nil, fmt.Errorf(\"the reserved-ipv4-cidr network size must be at least /%d\", ipRangeSize)\n\t}\n\n\t// The IP specified in the reserved-ipv4-cidr must be aligned on the ipRangeSize network boundary\n\tif ip.String() != ip.Mask(net.CIDRMask(ipRangeSize, ipV4Bits)).String() {\n\t\treturn nil, nil, fmt.Errorf(\"the IP specified in the reserved-ipv4-cidr must be aligned on the /%d network boundary\", ipRangeSize)\n\t}\n\treturn ip, ipnet, nil\n}", "func parseAcceptedBlobSize(rangeHeader string) (int64, error) {\n\t// Range: Range indicating the current progress of the upload.\n\t// https://github.com/opencontainers/distribution-spec/blob/master/spec.md#get-blob-upload\n\tif rangeHeader == \"\" {\n\t\treturn 0, fmt.Errorf(\"range header required\")\n\t}\n\n\tparts := strings.SplitN(rangeHeader, \"-\", 2)\n\tif len(parts) != 2 {\n\t\treturn 0, fmt.Errorf(\"range header bad value: %s\", rangeHeader)\n\t}\n\n\tsize, err := strconv.ParseInt(parts[1], 10, 64)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\t// docker registry did '-1' in the response\n\tif size > 0 {\n\t\tsize = size + 1\n\t}\n\n\treturn size, nil\n}", "func (c *BcsMonitorClient) QueryRange(promql string, startTime, endTime time.Time,\n\tstep time.Duration) (*QueryRangeResponse, error) {\n\tvar queryString string\n\tvar err error\n\tqueryString = c.setQuery(queryString, \"query\", promql)\n\tqueryString = c.setQuery(queryString, \"start\", fmt.Sprintf(\"%d\", startTime.Unix()))\n\tqueryString = c.setQuery(queryString, \"end\", fmt.Sprintf(\"%d\", endTime.Unix()))\n\tqueryString = c.setQuery(queryString, \"step\", step.String())\n\turl := fmt.Sprintf(\"%s%s?%s\", c.completeEndpoint, QueryRangePath, queryString)\n\turl = c.addAppMessage(url)\n\tstart := time.Now()\n\tdefer func() {\n\t\tprom.ReportLibRequestMetric(prom.BkBcsMonitor, \"QueryRange\", \"GET\", err, start)\n\t}()\n\trsp, err := c.requestClient.DoRequest(url, \"GET\", c.defaultHeader, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresult := &QueryRangeResponse{}\n\terr = json.Unmarshal(rsp, result)\n\tif err != nil {\n\t\tblog.Errorf(\"json unmarshal error:%v\", err)\n\t\treturn nil, fmt.Errorf(\"do request error, url: %s, error:%v\", url, err)\n\t}\n\treturn result, nil\n}", "func ParsePortRange(portRange string) (PortRange, error) {\n\tbounds := strings.Split(portRange, \"-\")\n\tif len(bounds) > 2 {\n\t\treturn PortRange{}, fmt.Errorf(\"ranges expected as <lower>-<upper>\")\n\t}\n\tif len(bounds) == 1 {\n\t\t// If only provided a single value, treat as both lower- and upper-bounds\n\t\tbounds = append(bounds, bounds[0])\n\t}\n\tlower, err := strconv.Atoi(bounds[0])\n\tif err != nil || !isPort(lower) {\n\t\treturn PortRange{}, fmt.Errorf(\"\\\"%s\\\" is not a valid lower-bound\", bounds[0])\n\t}\n\tupper, err := strconv.Atoi(bounds[1])\n\tif err != nil || !isPort(upper) {\n\t\treturn PortRange{}, fmt.Errorf(\"\\\"%s\\\" is not a valid upper-bound\", bounds[1])\n\t}\n\tif upper < lower {\n\t\treturn PortRange{}, fmt.Errorf(\"\\\"%s\\\": upper-bound must be greater than or equal to lower-bound\", portRange)\n\t}\n\treturn PortRange{LowerBound: lower, UpperBound: upper}, nil\n}", "func RangeQuery(in Query, r types.Request) (out Query) {\n\tout = in.Skip(r.Start)\n\tout = out.Limit(r.Length)\n\treturn\n}", "func CidrRange(v string) (*corepb.CidrRange, error) {\n\tvar address string\n\tvar prefixLen int\n\n\tif strings.Contains(v, \"/\") {\n\t\tif ip, ipnet, err := net.ParseCIDR(v); err == nil {\n\t\t\taddress = ip.String()\n\t\t\tprefixLen, _ = ipnet.Mask.Size()\n\t\t} else {\n\t\t\treturn nil, fmt.Errorf(\"invalid cidr range: %v\", err)\n\t\t}\n\t} else {\n\t\tif ip := net.ParseIP(v); ip != nil {\n\t\t\taddress = ip.String()\n\t\t\tif strings.Contains(v, \".\") {\n\t\t\t\t// Set the prefixLen to 32 for ipv4 address.\n\t\t\t\tprefixLen = 32\n\t\t\t} else if strings.Contains(v, \":\") {\n\t\t\t\t// Set the prefixLen to 128 for ipv6 address.\n\t\t\t\tprefixLen = 128\n\t\t\t} else {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid ip address: %s\", v)\n\t\t\t}\n\t\t} else {\n\t\t\treturn nil, fmt.Errorf(\"invalid ip address: %s\", v)\n\t\t}\n\t}\n\n\treturn &corepb.CidrRange{\n\t\tAddressPrefix: address,\n\t\tPrefixLen: &wrappers.UInt32Value{Value: uint32(prefixLen)},\n\t}, nil\n}", "func (f *fragment) rangeBetween(bitDepth uint, predicateMin, predicateMax int64) (*Row, error) {\n\tb := f.row(bsiExistsBit)\n\n\t// Convert predicates to unsigned values.\n\tupredicateMin, upredicateMax := uint64(predicateMin), uint64(predicateMax)\n\tif predicateMin < 0 {\n\t\tupredicateMin = uint64(-predicateMin)\n\t}\n\tif predicateMax < 0 {\n\t\tupredicateMax = uint64(-predicateMax)\n\t}\n\n\t// Handle positive-only values.\n\tif predicateMin >= 0 {\n\t\treturn f.rangeBetweenUnsigned(b.Difference(f.row(bsiSignBit)), bitDepth, upredicateMin, upredicateMax)\n\t}\n\n\t// Handle negative-only values. Swap unsigned min/max predicates.\n\tif predicateMax < 0 {\n\t\treturn f.rangeBetweenUnsigned(b.Intersect(f.row(bsiSignBit)), bitDepth, upredicateMax, upredicateMin)\n\t}\n\n\t// If predicate crosses positive/negative boundary then handle separately and union.\n\tpos, err := f.rangeLTUnsigned(b.Difference(f.row(bsiSignBit)), bitDepth, upredicateMax, true)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tneg, err := f.rangeLTUnsigned(b.Intersect(f.row(bsiSignBit)), bitDepth, upredicateMin, true)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn pos.Union(neg), nil\n}", "func TestParsing07(t *testing.T) {\n\tvar q = \"%a-b-%d\"\n\tvar r = &RangeExpr{Buffer: q}\n\tr.Init()\n\tr.Expression.Init(q)\n\terr := r.Parse()\n\tif err == nil {\n\t\tt.Errorf(\"Expected Error, (Query: %s) should NOT BE parsed [Unexpected %% (before d)]\", q)\n\t}\n}", "func (f FileURL) UploadRange(ctx context.Context, offset int64, body io.ReadSeeker, transactionalMD5 []byte) (*FileUploadRangeResponse, error) {\n\tif body == nil {\n\t\treturn nil, errors.New(\"invalid argument, body must not be nil\")\n\t}\n\n\tcount := validateSeekableStreamAt0AndGetCount(body)\n\tif count == 0 {\n\t\treturn nil, errors.New(\"invalid argument, body must contain readable data whose size is > 0\")\n\t}\n\n\t// TransactionalContentMD5 isn't supported currently.\n\treturn f.fileClient.UploadRange(ctx, *toRange(offset, count), FileRangeWriteUpdate, count, body, nil, transactionalMD5)\n}", "func (p IPPrefix) Range() IPRange {\n\tp = p.Masked()\n\tif p.IsZero() {\n\t\treturn IPRange{}\n\t}\n\treturn IPRange{From: p.IP, To: p.lastIP()}\n}", "func TestParsing10(t *testing.T) {\n\tvar q = \"a.b.c.d\"\n\tvar r = &RangeExpr{Buffer: q}\n\tr.Init()\n\tr.Expression.Init(q)\n\terr := r.Parse()\n\tif err != nil {\n\t\tt.Errorf(\"Expected NO Error, (Query: %s) should BE parsed (a.b.c.d is valid ip)\", q)\n\t}\n\n\tr.Execute()\n\tresult, errs := r.Evaluate(store)\n\tvar expected = []string{\"a.b.c.d\"}\n\tif len(errs) != 0 || !compare(*result, expected) {\n\t\tt.Errorf(\"Expected NO Evaluate Error, (Query: %s) should BE %s [Got: %s]\", q, expected, *result)\n\t}\n}", "func determineRange(g *u.GithubClient, owner, repo, branch, branchRange string) (startTag, releaseTag string, err error) {\n\tb, _, err := g.GetBranch(context.Background(), owner, repo, branch)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\tbranchHead = *b.Commit.SHA\n\n\tlastRelease, err := g.LastReleases(owner, repo)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\t// If lastRelease[branch] is unset, attempt to get the last release from the parent branch\n\t// and then master\n\tif i := strings.LastIndex(branch, \".\"); lastRelease[branch] == \"\" && i != -1 {\n\t\tlastRelease[branch] = lastRelease[branch[:i]]\n\t}\n\tif lastRelease[branch] == \"\" {\n\t\tlastRelease[branch] = lastRelease[\"master\"]\n\t}\n\n\t// Regexp Example:\n\t// This regexp matches the Git branch range in the format of [[startTag..]endTag]. For example:\n\t//\n\t// \"\"\n\t// \"v1.1.4..\"\n\t// \"v1.1.4..v1.1.7\"\n\t// \"v1.1.7\"\n\tre, _ := regexp.Compile(\"([v0-9.]*-*(alpha|beta|rc)*\\\\.*[0-9]*)\\\\.\\\\.([v0-9.]*-*(alpha|beta|rc)*\\\\.*[0-9]*)$\")\n\ttags := re.FindStringSubmatch(branchRange)\n\tif tags != nil {\n\t\tstartTag = tags[1]\n\t\treleaseTag = tags[3]\n\t} else {\n\t\tstartTag = lastRelease[branch]\n\t\treleaseTag = branchHead\n\t}\n\n\tif startTag == \"\" {\n\t\treturn \"\", \"\", fmt.Errorf(\"unable to set beginning of range automatically\")\n\t}\n\tif releaseTag == \"\" {\n\t\treleaseTag = branchHead\n\t}\n\n\treturn startTag, releaseTag, nil\n}", "func (c *BcsMonitorClient) QueryRange(promql string, startTime, endTime time.Time,\n\tstep time.Duration) (*QueryRangeResponse, error) {\n\tvar queryString string\n\tvar err error\n\tqueryString = c.setQuery(queryString, \"query\", promql)\n\tqueryString = c.setQuery(queryString, \"start\", fmt.Sprintf(\"%d\", startTime.Unix()))\n\tqueryString = c.setQuery(queryString, \"end\", fmt.Sprintf(\"%d\", endTime.Unix()))\n\tqueryString = c.setQuery(queryString, \"step\", step.String())\n\turl := fmt.Sprintf(\"%s%s?%s\", c.opts.Endpoint, QueryRangePath, queryString)\n\turl = c.addAppMessage(url)\n\theader := c.defaultHeader.Clone()\n\tstart := time.Now()\n\tdefer func() {\n\t\tprom.ReportLibRequestMetric(prom.BkBcsMonitor, \"QueryRange\", \"GET\", err, start)\n\t}()\n\trsp, err := c.requestClient.DoRequest(url, \"GET\", header, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresult := &QueryRangeResponse{}\n\terr = json.Unmarshal(rsp, result)\n\tif err != nil {\n\t\tblog.Errorf(\"json unmarshal error:%v\", err)\n\t\treturn nil, fmt.Errorf(\"do request error, url: %s, error:%v\", url, err)\n\t}\n\treturn result, nil\n}", "func (s *Store) RangeFeed(\n\targs *roachpb.RangeFeedRequest, stream roachpb.Internal_RangeFeedServer,\n) *roachpb.Error {\n\n\tif filter := s.TestingKnobs().TestingRangefeedFilter; filter != nil {\n\t\tif pErr := filter(args, stream); pErr != nil {\n\t\t\treturn pErr\n\t\t}\n\t}\n\n\tif err := verifyKeys(args.Span.Key, args.Span.EndKey, true); err != nil {\n\t\treturn roachpb.NewError(err)\n\t}\n\n\t// Get range and add command to the range for execution.\n\trepl, err := s.GetReplica(args.RangeID)\n\tif err != nil {\n\t\treturn roachpb.NewError(err)\n\t}\n\tif !repl.IsInitialized() {\n\t\t// (*Store).Send has an optimization for uninitialized replicas to send back\n\t\t// a NotLeaseHolderError with a hint of where an initialized replica might\n\t\t// be found. RangeFeeds can always be served from followers and so don't\n\t\t// otherwise return NotLeaseHolderError. For simplicity we also don't return\n\t\t// one here.\n\t\treturn roachpb.NewError(roachpb.NewRangeNotFoundError(args.RangeID, s.StoreID()))\n\t}\n\treturn repl.RangeFeed(args, stream)\n}", "func (x *fastReflection_QueryAccountRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {\n\tif x.Address != \"\" {\n\t\tvalue := protoreflect.ValueOfString(x.Address)\n\t\tif !f(fd_QueryAccountRequest_address, value) {\n\t\t\treturn\n\t\t}\n\t}\n}", "func (x *fastReflection_QueryAccountInfoRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {\n\tif x.Address != \"\" {\n\t\tvalue := protoreflect.ValueOfString(x.Address)\n\t\tif !f(fd_QueryAccountInfoRequest_address, value) {\n\t\t\treturn\n\t\t}\n\t}\n}", "func parseMetricNameRangeValue(rangeValue []byte, value []byte) (model.LabelValue, error) {\n\tcomponentRef := componentsPool.Get().(*componentRef)\n\tdefer componentsPool.Put(componentRef)\n\tcomponents := decodeRangeKey(rangeValue, componentRef.components)\n\n\tswitch {\n\tcase len(components) < 4:\n\t\treturn \"\", fmt.Errorf(\"invalid metric name range value: %x\", rangeValue)\n\n\t// v1 has the metric name as the value (with the hash as the first component)\n\tcase len(components[3]) == 1 && components[3][0] == metricNameRangeKeyV1:\n\t\treturn model.LabelValue(value), nil\n\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unrecognised metricNameRangeKey version: %q\", string(components[3]))\n\t}\n}", "func (s *FrontendServer) RangeGet(req *pb.RangeRequest, stream pb.Frontend_RangeGetServer) error {\n\tvar err error\n\tvar returnErr error = nil\n\tvar res, res2, res3 *clientv3.GetResponse\n\tvar kvRes *pb.KV\n\tvar more bool\n\tstartKey := req.GetStart()\n\tendKey := req.GetEnd()\n\tctx, cancel := context.WithTimeout(context.Background(), time.Second)\n\tdefer cancel()\n\tswitch req.GetType() {\n\tcase utils.LocalData:\n\t\tif startKey > endKey {\n\t\t\treturn fmt.Errorf(\"Range Get over local data failed: start > end\")\n\t\t}\n\t\tres, err = s.localSt.Get(ctx, startKey, clientv3.WithRange(endKey)) // get the key itself, no hashes used\n\tcase utils.GlobalData:\n\t\t// keys are assumed to be already hashed\n\t\tif s.gateway == nil {\n\t\t\treturn fmt.Errorf(\"RangeGet request failed: gateway node not initialized at the edge\")\n\t\t}\n\t\tstate, err := s.gateway.GetStateRPC()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get state of gateway node\")\n\t\t}\n\t\tif state < dht.Ready { // could happen if gateway node was created but didnt join dht\n\t\t\treturn fmt.Errorf(\"edge node %s not connected to dht yet or gateway node not ready\", s.print())\n\t\t}\n\t\tif startKey > endKey {\n\t\t\t// get results as: [startKey, MaxID) + MaxID + [0, endKey)\n\t\t\t// because etcd does not have knowledge of the ring and start must be < end for each range request\n\t\t\tmore = true\n\t\t\tend1 := s.gateway.MaxID()\n\t\t\tstart2 := s.gateway.ZeroID()\n\t\t\tres, err = s.globalSt.Get(ctx, startKey, clientv3.WithRange(end1))\n\t\t\tif returnErr = checkError(err); returnErr != nil {\n\t\t\t\treturn status.Errorf(codes.Unknown, \"Range Get failed with error: %v\", returnErr)\n\t\t\t}\n\t\t\t// log.Printf(\"First res length %d\", res.Count)\n\t\t\tres2, err = s.globalSt.Get(ctx, end1)\n\t\t\tif returnErr = checkError(err); returnErr != nil {\n\t\t\t\treturn status.Errorf(codes.Unknown, \"Range Get failed with error: %v\", returnErr)\n\t\t\t}\n\t\t\t// log.Printf(\"Second res length %d\", res2.Count)\n\n\t\t\tres3, err = s.globalSt.Get(ctx, start2, clientv3.WithRange(endKey))\n\t\t\t// log.Printf(\"Third res length %d\", res3.Count)\n\t\t} else {\n\t\t\tres, err = s.globalSt.Get(ctx, startKey, clientv3.WithRange(endKey))\n\t\t}\n\t}\n\treturnErr = checkError(err)\n\tif returnErr != nil {\n\t\treturn status.Errorf(codes.Unknown, \"Range Get failed with error: %v\", returnErr)\n\t}\n\t// if (res == nil) || (res.Count == 0) { // should be same as if len(res.Kvs) == 0\n\t// \treturn nil\n\t// }\n\tfor _, kv := range res.Kvs {\n\t\tkvRes = &pb.KV{Key: string(kv.Key), Value: string(kv.Value)}\n\t\tstream.Send(kvRes)\n\t}\n\tif more {\n\t\tif res2 != nil {\n\t\t\tfor _, kv := range res2.Kvs {\n\t\t\t\tkvRes = &pb.KV{Key: string(kv.Key), Value: string(kv.Value)}\n\t\t\t\tstream.Send(kvRes)\n\t\t\t}\n\t\t}\n\t\tif res3 != nil {\n\t\t\tfor _, kv := range res3.Kvs {\n\t\t\t\tkvRes = &pb.KV{Key: string(kv.Key), Value: string(kv.Value)}\n\t\t\t\tstream.Send(kvRes)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (o *GetIPAMsubnetsParams) SetRangeBegin(rangeBegin *string) {\n\to.RangeBegin = rangeBegin\n}", "func NewRange(first net.IP, last net.IP) Range {\n\treturn Range{\n\t\tFirst: first,\n\t\tLast: last,\n\t}\n}", "func (blk IntegerBlock) Parse(bytes []byte, rd io.Reader) (BlockParseResult, error) {\n\tvar result = BlockParseResult{}\n\n\tif string(bytes[0]) != \":\" {\n\t\treturn result, errors.New(\"invalid format: \" + string(bytes[0]))\n\t}\n\n\tline, bytes, err := readLine(bytes, rd)\n\tif err != nil {\n\t\treturn result, err\n\t}\n\n\ti, err := strconv.Atoi(string(line[1:]))\n\tif err != nil {\n\t\treturn result, err\n\t}\n\n\tresult.Value = IntegerBlock{Content: i}\n\tresult.remainBytes = bytes\n\n\treturn result, nil\n}", "func Range(params ...cty.Value) (cty.Value, error) {\n\treturn RangeFunc.Call(params)\n}", "func Range(protocol string) *model.IP {\n\tip, err := store.Random(model.ProtocolFromString(protocol))\n\tif err != nil {\n\t\treturn nil\n\t}\n\treturn ip\n}", "func (b *logEventBuffer) normalRange(start, end int) (int, int) {\n\tif end < start || end == 0 {\n\t\t// invalid range\n\t\treturn -1, -1\n\t}\n\tsize := b.bufferSize()\n\tif start == 0 {\n\t\t// we reduce start by 1 to make it easier to calculate the index,\n\t\t// but we need to ensure we don't go below 0.\n\t\tstart++\n\t}\n\tif start == end {\n\t\t// ensure we have at least one block in range\n\t\tend++\n\t}\n\tif end-start > size {\n\t\t// ensure we don't have more than the buffer size\n\t\tstart = (end - size) + 1\n\t}\n\tstart = (start - 1) % size\n\tend = end % size\n\n\treturn start, end\n}", "func (x *fastReflection_AddressStringToBytesRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {\n\tif x.AddressString != \"\" {\n\t\tvalue := protoreflect.ValueOfString(x.AddressString)\n\t\tif !f(fd_AddressStringToBytesRequest_address_string, value) {\n\t\t\treturn\n\t\t}\n\t}\n}", "func (m *GetTransactionRangeOKBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (q *Query) Range(indexName string, start, end interface{}) *Query {\n\t// For an index range search,\n\t// it is non-sensical to pass two nils\n\t// Set the error and return the query unchanged\n\tif start == nil && end == nil {\n\t\tq.err = errors.New(ErrNilInputsRangeIndexQuery)\n\t\treturn q\n\t}\n\tq.start = start\n\tq.end = end\n\tq.isIndexQuery = true\n\tq.indexName = []byte(indexName)\n\treturn q\n}", "func (b *logEventBuffer) getBlocksInRange(start, end int) []fetchedBlock {\n\tvar blocksInRange []fetchedBlock\n\tstart, end = b.normalRange(start, end)\n\tif start == -1 || end == -1 {\n\t\t// invalid range\n\t\treturn blocksInRange\n\t}\n\tif start < end {\n\t\treturn b.blocks[start:end]\n\t}\n\t// in case we get circular range such as [0, 1, end, ... , start, ..., size-1]\n\t// we need to return the blocks in two ranges: [start, size-1] and [0, end]\n\tblocksInRange = append(blocksInRange, b.blocks[start:]...)\n\tblocksInRange = append(blocksInRange, b.blocks[:end]...)\n\n\treturn blocksInRange\n}", "func TestParsing02(t *testing.T) {\n\tvar q = \"a\"\n\tvar r = &RangeExpr{Buffer: q}\n\tr.Init()\n\tr.Expression.Init(q)\n\terr := r.Parse()\n\tif err != nil {\n\t\tt.Errorf(\"Expected NO Error, (Query: %s) should BE parsed [starts with a-z]\", q)\n\t}\n\tr.Execute()\n\tresult, errs := r.Evaluate(store)\n\tif len(errs) != 0 || !compare(*result, []string{\"a\"}) {\n\t\tt.Errorf(\"Expected NO Evaluate Error, (Query: %s) should BE %s [Got: %s]\", []string{\"ops\"}, *result)\n\t}\n}", "func (v *Validator) validateRangeQuery(ns string, rangeQueryInfo *kvrwset.RangeQueryInfo, updates *statedb.UpdateBatch) (bool, error) {\n\tlogger.Debugf(\"validateRangeQuery: ns=%s, rangeQueryInfo=%s\", ns, rangeQueryInfo)\n\n\t// If during simulation, the caller had not exhausted the iterator so\n\t// rangeQueryInfo.EndKey is not actual endKey given by the caller in the range query\n\t// but rather it is the last key seen by the caller and hence the combinedItr should include the endKey in the results.\n\tincludeEndKey := !rangeQueryInfo.ItrExhausted\n\n\tcombinedItr, err := newCombinedIterator(v.db, updates,\n\t\tns, rangeQueryInfo.StartKey, rangeQueryInfo.EndKey, includeEndKey)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tdefer combinedItr.Close()\n\tvar validator rangeQueryValidator\n\tif rangeQueryInfo.GetReadsMerkleHashes() != nil {\n\t\tlogger.Debug(`Hashing results are present in the range query info hence, initiating hashing based validation`)\n\t\tvalidator = &rangeQueryHashValidator{}\n\t} else {\n\t\tlogger.Debug(`Hashing results are not present in the range query info hence, initiating raw KVReads based validation`)\n\t\tvalidator = &rangeQueryResultsValidator{}\n\t}\n\tvalidator.init(rangeQueryInfo, combinedItr)\n\treturn validator.validate()\n}", "func (ipAllocator *IPAllocator) GetUnreservedIPRange(cidr string, cloudInstancesReservedIPRanges map[string]bool) (string, error) {\n\tip, ipnet, err := ipAllocator.parseCIDR(cidr)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tvar reservedIPRanges = make(map[string]bool)\n\n\t// The final reserved list is obtained by combining the cloudInstancesReservedIPRanges list and the pendingIPRanges list in the ipAllocator\n\tfor cloudInstancesReservedIPRange := range cloudInstancesReservedIPRanges {\n\t\treservedIPRanges[cloudInstancesReservedIPRange] = true\n\t}\n\n\t// Lock is placed here so that the pendingIPRanges list captures all the IPs pending reservation in the cloud instances\n\tipAllocator.pendingIPRangesMutex.Lock()\n\tdefer ipAllocator.pendingIPRangesMutex.Unlock()\n\tfor reservedIPRange := range ipAllocator.pendingIPRanges {\n\t\treservedIPRanges[reservedIPRange] = true\n\t}\n\n\tfor cidrIP := cloneIP(ip.Mask(ipnet.Mask)); ipnet.Contains(cidrIP) && err == nil; cidrIP, err = incrementIP(cidrIP, incrementStep29IPRange) {\n\t\toverLap := false\n\t\tfor reservedIPRange := range reservedIPRanges {\n\t\t\t_, reservedIPNet, err := net.ParseCIDR(reservedIPRange)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\t// Creating IPnet object using IP and mask\n\t\t\tcidrIPNet := &net.IPNet{\n\t\t\t\tIP: cidrIP,\n\t\t\t\tMask: ipRangeMask,\n\t\t\t}\n\n\t\t\t// Find if the current IP range in the CIDR overlaps with any of the reserved IP ranges. If not, this can be returned\n\t\t\toverLap, err = isOverlap(cidrIPNet, reservedIPNet)\n\n\t\t\t// Error while processing ipnet\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\tif overLap {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !overLap {\n\t\t\tipRange := fmt.Sprint(cidrIP.String(), \"/\", ipRangeSize)\n\t\t\tipAllocator.holdIPRange(ipRange)\n\t\t\treturn ipRange, nil\n\t\t}\n\t}\n\n\t// No unreserved IP range available in the entire CIDR range since we did not return\n\treturn \"\", fmt.Errorf(\"all of the /29 IP ranges in the cidr %s are reserved\", cidr)\n}", "func appendRange(fs *token.FileSet, f *ast.File, src []byte, ident string) (start, end int, eof, ok bool) {\n\tif obj := f.Scope.Lookup(ident); obj != nil {\n\t\tif n, ok := obj.Decl.(ast.Node); ok {\n\t\t\tsp, ep := n.End(), n.End()\n\t\t\t// Scan file to find where the whitespace ends.\n\t\t\ts := new(scanner.Scanner)\n\t\t\ttf := fs.File(sp)\n\t\t\ts.Init(tf, src, nil, scanner.ScanComments)\n\t\t\tfor {\n\t\t\t\ttp, tok, _ := s.Scan()\n\t\t\t\tif tp < ep {\n\t\t\t\t\tcontinue\n\t\t\t\t} else if tp > ep {\n\t\t\t\t\tif tok == token.EOF {\n\t\t\t\t\t\teof = true\n\t\t\t\t\t\tep = tp\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tif tok == token.COMMENT || tok.IsKeyword() {\n\t\t\t\t\t\tep = tp\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn fs.PositionFor(sp, true).Offset,\n\t\t\t\tfs.PositionFor(ep, true).Offset, eof, true\n\t\t}\n\t}\n\treturn 0, 0, false, false\n}" ]
[ "0.65760976", "0.6273825", "0.62658364", "0.6203469", "0.6190573", "0.6104221", "0.60757834", "0.603592", "0.6012127", "0.5833827", "0.5749373", "0.5749373", "0.573297", "0.5513817", "0.5503804", "0.5434472", "0.5408448", "0.54031825", "0.5378902", "0.5353554", "0.5262798", "0.5234541", "0.52239877", "0.5216543", "0.5215258", "0.52105635", "0.5208237", "0.52069956", "0.5200514", "0.5200283", "0.51919127", "0.5180176", "0.51800704", "0.5175964", "0.5175607", "0.5174183", "0.5167805", "0.5139398", "0.51370037", "0.5133881", "0.51219916", "0.5114686", "0.51028025", "0.5094459", "0.506899", "0.5059214", "0.5040373", "0.5031999", "0.50282836", "0.5023497", "0.4996231", "0.4996231", "0.49922025", "0.49901763", "0.49746218", "0.4971965", "0.4959781", "0.49452657", "0.49218965", "0.49218965", "0.4921418", "0.49185714", "0.4909375", "0.48928952", "0.48788854", "0.4865439", "0.48584414", "0.48532474", "0.48314992", "0.48250085", "0.48199746", "0.47873768", "0.47835726", "0.4782667", "0.47821546", "0.47782937", "0.4778082", "0.47758332", "0.4774164", "0.47691762", "0.47667134", "0.4752592", "0.474709", "0.4739833", "0.47316638", "0.4727404", "0.47259307", "0.4724028", "0.47202507", "0.4717468", "0.4712945", "0.4711697", "0.46990454", "0.46901152", "0.4690084", "0.46822277", "0.4679743", "0.4668815", "0.46639025", "0.46635664" ]
0.7895962
0
update updates (num, err, at). Only one instance may run at a time, and it spot is reserved by setting next, which is closed when the operation completes. Returns a chan to wait on if another instance is already running. Otherwise returns num and err if the operation is complete.
func (l *latestBlock) update() (chan struct{}, uint64, error) { l.mu.Lock() if next := l.next; next != nil { // Someone beat us to it, return their next chan. l.mu.Unlock() return next, 0, nil } next := make(chan struct{}) l.next = next l.mu.Unlock() var latest uint64 var err error if l.client == nil { l.client, err = goclient.Dial(l.url) } if err == nil { var lBig *big.Int lBig, err = l.client.LatestBlockNumber(context.Background()) if err == nil { latest = lBig.Uint64() } } now := time.Now() l.mu.Lock() l.num = latest l.err = err l.at = &now l.next = nil l.mu.Unlock() close(next) return nil, latest, err }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (p *progress) update(nodeIndex NodeIndex, index LogEntryIndex) {\n\tp.NextIndex[nodeIndex] = index + 1\n\tp.MatchIndex[nodeIndex] = index\n}", "func (s *Stream) Update(ctx context.Context, c Collector) (err error) {\n\tupdate := newTaskLogger(s.stdout).Task(fmt.Sprintf(\"DRIVE %s\", s.drive)).Task(\"UPDATE\")\n\n\tupdate.Log(\"Started %s\\n\", time.Now().Format(time.RFC3339))\n\tdefer func(e *error) {\n\t\tif *e != nil {\n\t\t\tupdate.Log(\"ERROR: %v\\n\", *e)\n\t\t\tupdate.Log(\"Aborted %s | %s\\n\", time.Now().Format(time.RFC3339), update.Duration())\n\t\t} else {\n\t\t\tupdate.Log(\"Finished %s | %s\\n\", time.Now().Format(time.RFC3339), update.Duration())\n\t\t}\n\t}(&err)\n\n\tif err = s.collect(ctx, c, update); err != nil {\n\t\treturn err\n\t}\n\n\treturn s.buildCommits(ctx, update)\n}", "func (c *ConsulWatcher) Next() ([]*naming.Update, error) {\n\tfor atomic.LoadUint32(&c.running) == 1 {\n\t\tse, err := c.query.Execute(c.service, nil)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tup, err := c.buildUpdate(se)\n\n\t\tif len(up) > 0 {\n\t\t\treturn up, nil\n\t\t}\n\n\t\ttime.Sleep(c.update)\n\t}\n\n\treturn nil, nil\n}", "func (sm *ShardMaster) update() {\n\tvar noop Op\n\tnoop.ProposedConfig.Num = 0\n\t// Concatenate first 16 digits of current time with\n\t// first 3 digits of sm.me\n\t// Using 3 digits of sm.me allows for a thousand peers\n\t// Using 16 digits of the time means it won't repeat for about 115 days\n\t// Using both time and \"me\" means it's probably unique\n\t// Using 19 digits means it will fit in a uint64\n\ttimeDigits := uint64(time.Now().UnixNano() % 10000000000000000)\n\tmeDigits := uint64(sm.me % 1000)\n\tnoop.ID = timeDigits*1000 + meDigits\n\n\tupdated := false\n\tfor !updated && !sm.dead {\n\t\tsm.px.Start(sm.maxSequenceCommitted+1, noop)\n\t\t// Wait until its Status is decided\n\t\tdecided := false\n\t\tvar decidedValue interface{}\n\t\ttoWait := 25 * time.Millisecond\n\t\tfor !decided && !sm.dead {\n\t\t\tdecided, decidedValue = sm.px.Status(sm.maxSequenceCommitted + 1)\n\t\t\tif !decided {\n\t\t\t\ttime.Sleep(toWait)\n\t\t\t\t//if toWait < 2*time.Second {\n\t\t\t\t//\ttoWait *= 2\n\t\t\t\t//}\n\t\t\t}\n\t\t}\n\n\t\tif sm.dead {\n\t\t\tbreak\n\t\t}\n\n\t\t// Get the decided configuration for this sequence\n\t\tdecidedConfig := decidedValue.(Op).ProposedConfig\n\t\t// If the decided value has the chosen unique ID, ours was accepted and we are updated\n\t\t// Otherwise, store decided configuration (if it's not another no-op)\n\t\tif decidedValue.(Op).ID == noop.ID {\n\t\t\tupdated = true\n\t\t} else {\n\t\t\tif decidedConfig.Num > 0 {\n\t\t\t\tsm.addConfig(decidedConfig)\n\t\t\t}\n\t\t}\n\t\tsm.maxSequenceCommitted++\n\t}\n\tsm.px.Done(sm.maxSequenceCommitted)\n}", "func (u *Updater) Next() (bool, dht.NodeID, SeekRequest) {\n\tvar ln int\n\tlinks := len(u.network.ID()) * 8\n\n\tln = u.queueLen()\n\n\t// By lazy populating the queue, as responses come back, that can be used in\n\t// later requests.\n\tfor ; ln == 0; ln = u.queueLen() {\n\t\tif u.idx >= links {\n\t\t\treturn false, nil, SeekRequest{}\n\t\t}\n\t\tif u.idx > u.depth {\n\t\t\tu.idx = links - 1\n\t\t}\n\t\tu.queueIdx(u.idx)\n\t\tu.idx++\n\t}\n\tid, sr := u.seekRequest(u.queue[ln-1])\n\tu.Lock()\n\tu.queue = u.queue[:ln-1]\n\tu.Unlock()\n\treturn true, id, sr\n}", "func (op *updateInstanceUpdateInstanceOperation) do(ctx context.Context, r *Instance, c *Client) error {\n\t_, err := c.GetInstance(ctx, r.urlNormalized())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tu, err := r.updateURL(c.Config.BasePath, \"UpdateInstance\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treq, err := newUpdateInstanceUpdateInstanceRequest(ctx, r, c)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tc.Config.Logger.Infof(\"Created update: %#v\", req)\n\tbody, err := marshalUpdateInstanceUpdateInstanceRequest(c, req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tresp, err := dcl.SendRequest(ctx, c.Config, \"PATCH\", u, bytes.NewBuffer(body), c.Config.RetryProvider)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar o operations.StandardGCPOperation\n\tif err := dcl.ParseResponse(resp.Response, &o); err != nil {\n\t\treturn err\n\t}\n\terr = o.Wait(ctx, c.Config, \"https://file.googleapis.com/v1/\", \"GET\")\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (n *notifier) updateFD(fd int32) error {\n\tn.mu.Lock()\n\tdefer n.mu.Unlock()\n\n\tif fi, ok := n.fdMap[fd]; ok {\n\t\treturn n.waitFD(fd, fi, fi.queue.Events())\n\t}\n\n\treturn nil\n}", "func (s *State) Update(next State, f func() error) error {\n\ttype checkFunc func() error\n\tm := map[State]checkFunc{\n\t\tStateOpened: s.toOpened,\n\t\tStateClosed: s.toClosed,\n\t\tStateRunning: s.toRunning,\n\t}\n\n\terr := m[next]()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = f()\n\tif err == nil {\n\t\t*s = next\n\t}\n\treturn err\n}", "func doUpdate(w http.ResponseWriter, r *http.Request) {\n\ts, err := newServerCGI(w, r)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tlog.Println(\"failed to create cgi struct\")\n\t\treturn\n\t}\n\treg := regexp.MustCompile(`^update/(\\w+)/(\\d+)/(\\w+)/([^\\+]*)(\\+.*)`)\n\tm := reg.FindStringSubmatch(s.path())\n\tif m == nil {\n\t\tlog.Println(\"illegal url\")\n\t\treturn\n\t}\n\tdatfile, stamp, id, hostport, path := m[1], m[2], m[3], m[4], m[5]\n\thost, portstr, err := net.SplitHostPort(hostport)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\tport, err := strconv.Atoi(portstr)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\thost = s.remoteIP(host)\n\tif host == \"\" {\n\t\tlog.Println(\"host is null\")\n\t\treturn\n\t}\n\n\tn, err := node.MakeNode(host, path, port)\n\tif err != nil || !n.IsAllowed() {\n\t\tlog.Println(\"detects spam\")\n\t\treturn\n\t}\n\ts.NodeManager.AppendToTable(datfile, n)\n\ts.NodeManager.Sync()\n\tnstamp, err := strconv.ParseInt(stamp, 10, 64)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\n\tif !thread.IsInUpdateRange(nstamp) {\n\t\treturn\n\t}\n\trec := thread.NewRecord(datfile, stamp+\"_\"+id)\n\tgo s.UpdateQue.UpdateNodes(rec, n)\n\tfmt.Fprintln(w, \"OK\")\n}", "func (s *SimpleTask) Updates() <-chan *Update {\n\treturn s.ch\n}", "func (c *Conn) epUpdate(ctx context.Context) {\n\tvar lastEndpoints []string\n\tvar lastCancel func()\n\tvar lastDone chan struct{}\n\n\tvar regularUpdate <-chan time.Time\n\tif !version.IsMobile() {\n\t\t// We assume that LinkChange notifications are plumbed through well\n\t\t// on our mobile clients, so don't do the timer thing to save radio/battery/CPU/etc.\n\t\tticker := time.NewTicker(28 * time.Second) // just under 30s, a likely UDP NAT timeout\n\t\tdefer ticker.Stop()\n\t\tregularUpdate = ticker.C\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tif lastCancel != nil {\n\t\t\t\tlastCancel()\n\t\t\t}\n\t\t\treturn\n\t\tcase <-c.startEpUpdate:\n\t\tcase <-regularUpdate:\n\t\t}\n\n\t\tif lastCancel != nil {\n\t\t\tlastCancel()\n\t\t\t<-lastDone\n\t\t}\n\t\tvar epCtx context.Context\n\t\tepCtx, lastCancel = context.WithCancel(ctx)\n\t\tlastDone = make(chan struct{})\n\n\t\tgo func() {\n\t\t\tdefer close(lastDone)\n\n\t\t\tc.updateNetInfo() // best effort\n\t\t\tc.cleanStaleDerp()\n\n\t\t\tendpoints, err := c.determineEndpoints(epCtx)\n\t\t\tif err != nil {\n\t\t\t\tc.logf(\"magicsock.Conn: endpoint update failed: %v\", err)\n\t\t\t\t// TODO(crawshaw): are there any conditions under which\n\t\t\t\t// we should trigger a retry based on the error here?\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif stringsEqual(endpoints, lastEndpoints) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tlastEndpoints = endpoints\n\t\t\t// TODO(bradfiz): get nearestDerp back to ipn for a HostInfo update\n\t\t\tc.epFunc(endpoints)\n\t\t}()\n\t}\n}", "func (x *x509Handler) update(u *workload.X509SVIDResponse) {\n\tx.mtx.Lock()\n\tdefer x.mtx.Unlock()\n\n\tif reflect.DeepEqual(u, x.latest) {\n\t\treturn\n\t}\n\n\tx.latest = u\n\n\t// Don't block if the channel is full\n\tselect {\n\tcase x.changes <- struct{}{}:\n\t\tbreak\n\tdefault:\n\t\tbreak\n\t}\n}", "func (w *watcher) Next() ([]*naming.Update, error) {\n\tif !w.isInitialized {\n\t\tupdates := make([]*naming.Update, 1, 1)\n\t\tfor i := 0; i < 1; i++ {\n\t\t\tupdates[i] = &naming.Update{Op: naming.Add, Addr: w.re.serviceName}\n\t\t}\n\t\treturn updates, nil\n\t}\n\tsig := make(chan os.Signal, 1)\n\tsignal.Notify(sig, syscall.SIGUSR2)\n\t<-sig\n\treturn nil, nil\n}", "func Update(s *discordgo.Session, m *discordgo.MessageCreate) {\n\tif *R == false {\n\t\ts.ChannelMessageSend(support.Config.FactorioChannelID, \"Server is not running!\")\n\t\treturn\n\t}\n\n\ts.ChannelMessageSend(support.Config.FactorioChannelID, \"Server received factorio client update command.\")\n\t*QuitFlag = 1\n\tio.WriteString(*P, \"/quit\\n\")\n\ttime.Sleep(600 * time.Millisecond)\n\tfor {\n\t\tif *QuitFlag == 2 {\n\t\t\ts.ChannelMessageSend(support.Config.FactorioChannelID, \"server is closed.\")\n\t\t\t*QuitFlag = 0\n\t\t\tbreak\n\t\t}\n\t}\n\n\t*R = false\n\tUpdateCmd = 1\n\n\treturn\n}", "func tryUpdate(f func() error) error {\n\tsleepTime := 100\n\ttries := 0\n\tvar err error\n\tfor tries <= 3 {\n\t\terr = f()\n\t\tif err != nil {\n\t\t\tif apierror.IsConflict(err) {\n\t\t\t\ttime.Sleep(time.Duration(sleepTime) * time.Millisecond)\n\t\t\t\tsleepTime *= 2\n\t\t\t\ttries++\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t\tbreak\n\t}\n\treturn err\n}", "func (f *BatchFuture) Set(index uint64, err error) {\n\tf.index = index\n\tf.err = err\n\tclose(f.waitCh)\n}", "func (s *Server) updater(ctx context.Context) {\n\tfor {\n\t\tselect {\n\t\t// Same as handleConnections\n\t\tcase <-ctx.Done():\n\t\t\tlog.Println(\"Exit call updater...\")\n\n\t\t\treturn\n\t\tcase <-s.ticker.C:\n\t\t\tif err := s.updateClients(s.getTimer()); err == nil {\n\t\t\t\ts.notifyClients()\n\t\t\t} else {\n\t\t\t\tlog.Println(err)\n\t\t\t}\n\t\t}\n\t}\n}", "func (pr *Progress) maybeUpdate(n uint64) bool {\n\tvar updated bool\n\tif pr.Match < n {\n\t\tpr.Match = n\n\t\tupdated = true\n\t\tpr.resume()\n\t}\n\tif pr.Next < n+1 {\n\t\tpr.Next = n + 1\n\t}\n\treturn updated\n}", "func (a *MobileNetState) NextUpdate(lastState *keybase1.MobileNetworkState) chan keybase1.MobileNetworkState {\n\ta.Lock()\n\tdefer a.Unlock()\n\tch := make(chan keybase1.MobileNetworkState, 1)\n\tif lastState != nil && *lastState != a.state {\n\t\tch <- a.state\n\t} else {\n\t\ta.updateChs = append(a.updateChs, ch)\n\t}\n\treturn ch\n}", "func (p *Pool) incRunning() {\n\tatomic.AddInt32(&p.running, 1)\n}", "func (f *bookFeed) Next() <-chan *BookUpdate {\n\treturn f.c\n}", "func inc(i int, c chan int) {\n\tcount := 0\n\tfor ; count < 10; count++ {\n\t\tfmt.Println(\"int is now \", i)\n\t\tc <- i + 1 // <- is the \"send\" operator when a channel appears on the left.\n\t}\n}", "func (e *UpdateExec) Next(ctx context.Context, req *chunk.Chunk) error {\n\treq.Reset()\n\tif !e.drained {\n\t\tif e.collectRuntimeStatsEnabled() {\n\t\t\tctx = context.WithValue(ctx, autoid.AllocatorRuntimeStatsCtxKey, e.stats.AllocatorRuntimeStats)\n\t\t}\n\t\tnumRows, err := e.updateRows(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\te.drained = true\n\t\te.Ctx().GetSessionVars().StmtCtx.AddRecordRows(uint64(numRows))\n\t}\n\treturn nil\n}", "func (p *RoundRobinPool) nextIndex() int {\n\treturn int(atomic.AddUint64(&p.current, uint64(1)) % uint64(len(p.servers)))\n}", "func (r *Resolver) worker(instances []string, lastIndex uint64) {\n\tvar err error\n\tvar newInstances []string\n\n\tfor {\n\t\ttime.Sleep(5 * time.Second)\n\t\tselect {\n\t\tcase <-r.done:\n\t\t\treturn\n\t\tdefault:\n\t\t\tnewInstances, lastIndex, err = r.getInstances(lastIndex, true)\n\t\t\tif err != nil {\n\t\t\t\t// log\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tupdatedInstances := r.updateInstances(instances, newInstances)\n\t\t\tif len(updatedInstances) > 0 {\n\t\t\t\tr.updateCh <- updatedInstances\n\t\t\t}\n\t\t\tinstances = newInstances\n\t\t}\n\t}\n}", "func (gw *gRPCWatcher) Next() ([]*naming.Update, error) {\n\tif gw.wch == nil {\n\t\t// first Next() returns all addresses\n\t\treturn gw.firstNext()\n\t}\n\tif gw.err != nil {\n\t\treturn nil, gw.err\n\t}\n\n\t// process new events on target/*\n\twr, ok := <-gw.wch\n\tif !ok {\n\t\tgw.err = status.Error(codes.Unavailable, ErrWatcherClosed.Error())\n\t\treturn nil, gw.err\n\t}\n\tif gw.err = wr.Err(); gw.err != nil {\n\t\treturn nil, gw.err\n\t}\n\n\tupdates := make([]*naming.Update, 0, len(wr.Events))\n\tfor _, e := range wr.Events {\n\t\tvar jupdate naming.Update\n\t\tvar err error\n\t\tswitch e.Type {\n\t\tcase etcd.EventTypePut:\n\t\t\terr = json.Unmarshal(e.Kv.Value, &jupdate)\n\t\t\tjupdate.Op = naming.Add\n\t\tcase etcd.EventTypeDelete:\n\t\t\terr = json.Unmarshal(e.PrevKv.Value, &jupdate)\n\t\t\tjupdate.Op = naming.Delete\n\t\t}\n\t\tif err == nil {\n\t\t\tupdates = append(updates, &jupdate)\n\t\t}\n\t}\n\treturn updates, nil\n}", "func (u *updater) Update(ctx context.Context, at int64, payload []byte) error {\n\terr := u.Put(ctx, &index{u.next}, at, payload)\n\tif err != nil {\n\t\treturn err\n\t}\n\tu.next++\n\treturn nil\n}", "func (u *updater) Update(ctx context.Context, at int64, payload []byte) error {\n\terr := u.Put(ctx, &index{u.next}, at, payload)\n\tif err != nil {\n\t\treturn err\n\t}\n\tu.next++\n\treturn nil\n}", "func updater(done <-chan struct{}, outcome <-chan job) {\n\n\tfor outcome := range outcome {\n\t\tselect {\n\t\tcase <-done:\n\t\t\treturn\n\t\tdefault:\n\t\t\tnode, decision := outcome.node, outcome.decision\n\t\t\tif node != nil {\n\t\t\t\t//log.Printf(\"updater: updating %v node %p\", node.Status(), node)\n\t\t\t\tnode.UpdateTree(decision)\n\t\t\t\tnode.SetStatus(idle)\n\t\t\t} else {\n\t\t\t\t//log.Printf(\"updater: discarding %v node %p\", node.Status(), node)\n\t\t\t}\n\t\t}\n\t}\n}", "func UpdateBatch(conf *Configuration, result interface{}) (chan interface{}, error) {\n\telemt := internal.VerifyStructPointer(result)\n\n\tsession, err := mgo.Dial(connectString(conf))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// query db\n\tc := session.DB(conf.Database).C(conf.Collection)\n\n\tch := make(chan interface{})\n\ts := reflect.MakeSlice(reflect.SliceOf(elemt), 0, 0)\n\n\tvar ticker *time.Ticker\n\tvar t <-chan time.Time\n\tif conf.UpdateStrategy.UseMinRecords && conf.UpdateStrategy.UseTimeInterval {\n\t\tticker, t = internal.NewTicker(conf.UpdateStrategy.MaxInterval)\n\t}\n\n\tgo func() {\n\t\tdefer session.Close()\n\t\tminr := int(conf.UpdateStrategy.MinRecords)\n\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase v := <-ch: // receiving stream\n\t\t\t\tif !conf.UpdateStrategy.UseMinRecords {\n\t\t\t\t\t//update as they arrive\n\t\t\t\t\tgo updateSingleRecord(conf, v, c)\n\t\t\t\t} else {\n\t\t\t\t\trv := reflect.ValueOf(v)\n\t\t\t\t\tif rv.Type() == elemt {\n\t\t\t\t\t\ts = reflect.Append(s, rv)\n\t\t\t\t\t}\n\n\t\t\t\t\tif s.Len() >= minr {\n\t\t\t\t\t\ts = updateAndClear(conf, s, c)\n\n\t\t\t\t\t\t// reset the timer\n\t\t\t\t\t\tif conf.UpdateStrategy.UseTimeInterval {\n\t\t\t\t\t\t\tif ticker != nil {\n\t\t\t\t\t\t\t\tticker.Stop()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tticker, t = internal.NewTicker(conf.UpdateStrategy.MaxInterval)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\tcase <-t: // the max interval to go without updating records. nil channel if disabled.\n\t\t\t\tif s.Len() > 0 {\n\t\t\t\t\ts = updateAndClear(conf, s, c)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn ch, nil\n}", "func (s *s6aProxy) updateSession(sid string, ch chan interface{}) chan interface{} {\n\ts.sessionsMu.Lock()\n\toldCh, ok := s.sessions[sid]\n\ts.sessions[sid] = ch\n\ts.sessionsMu.Unlock()\n\tif ok {\n\t\tif oldCh != nil {\n\t\t\tclose(oldCh)\n\t\t}\n\t\treturn oldCh\n\t}\n\treturn nil\n}", "func (m *monitor) update(update *evalState) {\n\tm.Lock()\n\tdefer m.Unlock()\n\n\texisting := m.state\n\n\t// Swap in the new state at the end\n\tdefer func() {\n\t\tm.state = update\n\t}()\n\n\t// Check if the evaluation was triggered by a node\n\tif existing.node == \"\" && update.node != \"\" {\n\t\tm.ui.Output(fmt.Sprintf(\"Evaluation triggered by node %q\",\n\t\t\tlimit(update.node, m.length)))\n\t}\n\n\t// Check if the evaluation was triggered by a job\n\tif existing.job == \"\" && update.job != \"\" {\n\t\tm.ui.Output(fmt.Sprintf(\"Evaluation triggered by job %q\", update.job))\n\t}\n\n\t// Check the allocations\n\tfor allocID, alloc := range update.allocs {\n\t\tif existing, ok := existing.allocs[allocID]; !ok {\n\t\t\tswitch {\n\t\t\tcase alloc.index < update.index:\n\t\t\t\t// New alloc with create index lower than the eval\n\t\t\t\t// create index indicates modification\n\t\t\t\tm.ui.Output(fmt.Sprintf(\n\t\t\t\t\t\"Allocation %q modified: node %q, group %q\",\n\t\t\t\t\tlimit(alloc.id, m.length), limit(alloc.node, m.length), alloc.group))\n\n\t\t\tcase alloc.desired == structs.AllocDesiredStatusRun:\n\t\t\t\t// New allocation with desired status running\n\t\t\t\tm.ui.Output(fmt.Sprintf(\n\t\t\t\t\t\"Allocation %q created: node %q, group %q\",\n\t\t\t\t\tlimit(alloc.id, m.length), limit(alloc.node, m.length), alloc.group))\n\t\t\t}\n\t\t} else {\n\t\t\tswitch {\n\t\t\tcase existing.client != alloc.client:\n\t\t\t\tdescription := \"\"\n\t\t\t\tif alloc.clientDesc != \"\" {\n\t\t\t\t\tdescription = fmt.Sprintf(\" (%s)\", alloc.clientDesc)\n\t\t\t\t}\n\t\t\t\t// Allocation status has changed\n\t\t\t\tm.ui.Output(fmt.Sprintf(\n\t\t\t\t\t\"Allocation %q status changed: %q -> %q%s\",\n\t\t\t\t\tlimit(alloc.id, m.length), existing.client, alloc.client, description))\n\t\t\t}\n\t\t}\n\t}\n\n\t// Check if the status changed. We skip any transitions to pending status.\n\tif existing.status != \"\" &&\n\t\tupdate.status != structs.AllocClientStatusPending &&\n\t\texisting.status != update.status {\n\t\tm.ui.Output(fmt.Sprintf(\"Evaluation status changed: %q -> %q\",\n\t\t\texisting.status, update.status))\n\t}\n}", "func (u SysDBUpdater) UpdateNum() (int64, error) {\n\tdb := u.db.Updates(u.fields)\n\treturn db.RowsAffected, db.Error\n}", "func (p *RoundRobinPool) updateStatus(serverUrl *url.URL, alive bool) {\n\tfor _, b := range p.servers {\n\t\tif b.URL.String() == serverUrl.String() {\n\t\t\tb.SetAlive(alive)\n\t\t\tbreak\n\t\t}\n\t}\n}", "func (d *Data) Run() {\n\tgo func() {\n\t\tfor channelData := range d.channels {\n\t\t\tif err := d.pools.Invoke(channelData); err != nil {\n\t\t\t\tlog.Error(fmt.Sprintf(\"update data error(%s)\", err.Error()))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tfor {\n\t\t\tlog.Error(fmt.Sprintf(\"update run count(%d)\", d.pools.Running()))\n\t\t\tif d.pools.Running() <= 0 {\n\t\t\t\td.pools.Release()\n\t\t\t\td.done <- true\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\ttime.Sleep(3 * time.Second)\n\t\t}\n\t}()\n}", "func updateChecker(ch, stop chan bool, timeInterval time.Duration) {\n\tvar oldHash plumbing.Hash\n\tvar isFirstRun = true\n\n\tremote := git.NewRemote(memory.NewStorage(), &config.RemoteConfig{\n\t\tURLs: []string{info.address},\n\t})\n\n\tfor {\n\t\tselect {\n\t\tcase s := <-stop:\n\t\t\tif s {\n\t\t\t\tlog.Println(\"stop\")\n\t\t\t\treturn\n\t\t\t}\n\t\tdefault:\n\t\t\trefs, err := remote.List(&git.ListOptions{InsecureSkipTLS: true})\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\tgoto sleep\n\t\t\t}\n\n\t\t\tfor _, v := range refs {\n\t\t\t\tif v.Name().Short() == info.branch {\n\t\t\t\t\tif isFirstRun {\n\t\t\t\t\t\toldHash = v.Hash()\n\t\t\t\t\t\tisFirstRun = false\n\t\t\t\t\t} else if v.Hash() != oldHash {\n\t\t\t\t\t\tch <- true\n\t\t\t\t\t\toldHash = v.Hash()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\tsleep:\n\t\t\ttime.Sleep(timeInterval)\n\t\t}\n\t}\n}", "func (c *Aggregator) Update(_ context.Context, num number.Number, desc *metric.Descriptor) error {\n\tc.value.AddNumberAtomic(desc.NumberKind(), num)\n\treturn nil\n}", "func (r *Reporter) Update(message string) error {\n\tselect {\n\tcase r.c <- message:\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"warning: Reporter buffer is full\")\n\t}\n}", "func (s *Stats) Update(code int) {\n\ts.Lock()\n\ts.StatusCodes[code]++\n\ts.Unlock()\n}", "func (c *endpointCache) Update(event Event) {\n\tc.mtx.Lock()\n\tdefer c.mtx.Unlock()\n\n\t// Happy path.\n\tif event.Err == nil {\n\t\tc.updateCache(event.Instances)\n\t\tc.err = nil\n\t\treturn\n\t}\n\n\t// Sad path. Something's gone wrong in sd.\n\tc.logger.Log(\"err\", event.Err)\n\tif !c.options.invalidateOnError {\n\t\treturn // keep returning the last known endpoints on error\n\t}\n\tif c.err != nil {\n\t\treturn // already in the error state, do nothing & keep original error\n\t}\n\tc.err = event.Err\n\t// set new deadline to invalidate Endpoints unless non-error Event is received\n\tc.invalidateDeadline = c.timeNow().Add(c.options.invalidateTimeout)\n\treturn\n}", "func (u GroupUpdater) UpdateNum() (int64, error) {\n\tdb := u.db.Updates(u.fields)\n\treturn db.RowsAffected, db.Error\n}", "func (a *MobileAppState) NextUpdate(lastState *keybase1.MobileAppState) chan keybase1.MobileAppState {\n\ta.Lock()\n\tdefer a.Unlock()\n\tch := make(chan keybase1.MobileAppState, 1)\n\tif lastState != nil && *lastState != a.state {\n\t\tch <- a.state\n\t} else {\n\t\ta.updateChs = append(a.updateChs, ch)\n\t}\n\treturn ch\n}", "func (c *Consumer) UpdateOnChannel(ctx context.Context, fns ...OnChannel) error {\n\tfor _, fn := range fns {\n\t\terrCh := make(chan error)\n\t\tclosure := func(ch *amqp.Channel) error {\n\t\t\tvar err error\n\n\t\t\tdefer func() {\n\t\t\t\tc.onChan = fn\n\t\t\t\terrCh <- err\n\t\t\t}()\n\n\t\t\terr = fn(ch)\n\t\t\treturn err\n\t\t}\n\n\t\tselect {\n\t\tcase c.funcCh <- closure:\n\t\tcase <-ctx.Done():\n\t\t}\n\n\t\terr := <-errCh\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (pl *PolledList) UpdateCh() <-chan struct{} { return pl.updateCh }", "func (pl *PolledList) UpdateCh() <-chan struct{} { return pl.updateCh }", "func (f *asyncFinder) at(ctx context.Context, at int64, min int, i *interval, c chan<- *result, quit <-chan struct{}) {\n\tvar wg sync.WaitGroup\n\n\tfor l := i.level; l > min; l-- {\n\t\tselect {\n\t\tcase <-quit: // if the parent process quit\n\t\t\treturn\n\t\tdefault:\n\t\t}\n\n\t\twg.Add(1)\n\t\tgo func(l int) {\n\t\t\t// TODO: remove hardcoded timeout and define it as constant or inject in the getter.\n\t\t\treqCtx, cancel := context.WithTimeout(ctx, 1*time.Second)\n\t\t\tdefer func() {\n\t\t\t\tcancel()\n\t\t\t\twg.Done()\n\t\t\t}()\n\t\t\tindex := i.base + (1 << l) - 1\n\t\t\tchunk := f.asyncGet(reqCtx, at, index)\n\n\t\t\tselect {\n\t\t\tcase ch := <-chunk:\n\t\t\t\tselect {\n\t\t\t\tcase c <- &result{ch, i, l, index}:\n\t\t\t\tcase <-quit:\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\tcase <-reqCtx.Done():\n\t\t\t\tselect {\n\t\t\t\tcase c <- &result{nil, i, l, index}:\n\t\t\t\tcase <-quit:\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\tcase <-quit:\n\t\t\t}\n\t\t}(l)\n\t}\n\n\twg.Wait()\n}", "func (r *ReconcileRunner) tryUpdateInstance(ctx context.Context, count int) error {\n\t// refetch the instance and apply the updates to it\n\tbaseInstance := r.instance\n\tinstance := baseInstance.DeepCopyObject()\n\terr := r.KubeClient.Get(ctx, r.NamespacedName, baseInstance)\n\tif err != nil {\n\t\tif apierrors.IsNotFound(err) {\n\t\t\tr.log.Info(\"Unable to update deleted resource. it may have already been finalized. this error is ignorable. Resource: \" + r.Name)\n\t\t\treturn nil\n\t\t} else {\n\t\t\tr.log.Info(\"Unable to retrieve resource. falling back to prior instance: \" + r.Name + \": err \" + err.Error())\n\t\t}\n\t}\n\tstatus, _ := r.StatusAccessor(instance)\n\terr = r.instanceUpdater.applyUpdates(instance, status)\n\tif err != nil {\n\t\tr.log.Info(\"Unable to convert Object to resource\")\n\t\tr.instanceUpdater.clear()\n\t\treturn err\n\t}\n\terr = r.KubeClient.Update(ctx, instance)\n\tif err != nil {\n\t\tif count == 0 {\n\t\t\tr.Recorder.Event(instance, v1.EventTypeWarning, \"Update\", fmt.Sprintf(\"failed to update %s instance %s on K8s cluster.\", r.ResourceKind, r.Name))\n\t\t\tr.instanceUpdater.clear()\n\t\t\treturn err\n\t\t}\n\t\tr.log.Info(fmt.Sprintf(\"Failed to update CRD instance on K8s cluster. retries left=%d\", count))\n\t\ttime.Sleep(2 * time.Second)\n\t\treturn r.tryUpdateInstance(ctx, count-1)\n\t} else {\n\t\tr.instanceUpdater.clear()\n\t\treturn nil\n\t}\n}", "func (x *x509Handler) updateChan() <-chan *workload.X509SVIDResponse {\n\treturn x.updChan\n}", "func (client *Client) UpdateEcsImageWithChan(request *UpdateEcsImageRequest) (<-chan *UpdateEcsImageResponse, <-chan error) {\n\tresponseChan := make(chan *UpdateEcsImageResponse, 1)\n\terrChan := make(chan error, 1)\n\terr := client.AddAsyncTask(func() {\n\t\tdefer close(responseChan)\n\t\tdefer close(errChan)\n\t\tresponse, err := client.UpdateEcsImage(request)\n\t\tif err != nil {\n\t\t\terrChan <- err\n\t\t} else {\n\t\t\tresponseChan <- response\n\t\t}\n\t})\n\tif err != nil {\n\t\terrChan <- err\n\t\tclose(responseChan)\n\t\tclose(errChan)\n\t}\n\treturn responseChan, errChan\n}", "func (s *Store) Update(w http.ResponseWriter, r *http.Request) {\n\t// We don't set up the: \"defer dphttp.DrainBody(r)\" here, as the body is fully read in function unmarshalInstance() below\n\t// and a call to DrainBody() puts this error: \"invalid Read on closed Body\" into the logs - to no good effect\n\t// because there is no more body to be read - so instead we just set up the usual Close() on the Body.\n\tdefer func() {\n\t\tif bodyCloseErr := r.Body.Close(); bodyCloseErr != nil {\n\t\t\tlog.Error(r.Context(), \"could not close response body\", bodyCloseErr)\n\t\t}\n\t}()\n\n\tctx := r.Context()\n\tvars := mux.Vars(r)\n\tinstanceID := vars[\"instance_id\"]\n\teTag := getIfMatch(r)\n\n\tlogData := log.Data{\"instance_id\": instanceID}\n\n\tinstance, err := unmarshalInstance(ctx, r.Body, false)\n\tif err != nil {\n\t\tlog.Error(ctx, \"update instance: failed unmarshalling json to model\", err, logData)\n\t\thandleInstanceErr(ctx, taskError{error: err, status: 400}, w, logData)\n\t\treturn\n\t}\n\n\tif err = validateInstanceUpdate(instance); err != nil {\n\t\thandleInstanceErr(ctx, taskError{error: err, status: 400}, w, logData)\n\t\treturn\n\t}\n\n\t// acquire instance lock so that the dp-graph call to AddVersionDetailsToInstance and the mongoDB update are atomic\n\tlockID, err := s.AcquireInstanceLock(ctx, instanceID)\n\tif err != nil {\n\t\tlog.Error(ctx, \"update instance: failed to lock the instance\", err, logData)\n\t\thandleInstanceErr(ctx, taskError{error: err, status: http.StatusInternalServerError}, w, logData)\n\t\treturn\n\t}\n\tdefer s.UnlockInstance(ctx, lockID)\n\n\t// Get the current document\n\tcurrentInstance, err := s.GetInstance(ctx, instanceID, eTag)\n\tif err != nil {\n\t\tlog.Error(ctx, \"update instance: store.GetInstance returned error\", err, logData)\n\t\thandleInstanceErr(ctx, err, w, logData)\n\t\treturn\n\t}\n\n\tlogData[\"current_state\"] = currentInstance.State\n\tlogData[\"requested_state\"] = instance.State\n\tif instance.State != \"\" && instance.State != currentInstance.State {\n\t\tif err = validateInstanceStateUpdate(instance, currentInstance); err != nil {\n\t\t\tlog.Error(ctx, \"update instance: instance state invalid\", err, logData)\n\t\t\thandleInstanceErr(ctx, err, w, logData)\n\t\t\treturn\n\t\t}\n\t}\n\n\tdatasetID := currentInstance.Links.Dataset.ID\n\n\t// edition confirmation is a one time process - cannot be edited for an instance once done\n\tif instance.State == models.EditionConfirmedState && instance.Version == 0 {\n\t\tif instance.Edition == \"\" {\n\t\t\tinstance.Edition = currentInstance.Edition\n\t\t}\n\n\t\tedition := instance.Edition\n\t\teditionLogData := log.Data{\"instance_id\": instanceID, \"dataset_id\": datasetID, \"edition\": edition}\n\n\t\teditionDoc, editionConfirmErr := s.confirmEdition(ctx, datasetID, edition, instanceID)\n\t\tif editionConfirmErr != nil {\n\t\t\tlog.Error(ctx, \"update instance: store.getEdition returned an error\", editionConfirmErr, editionLogData)\n\t\t\thandleInstanceErr(ctx, editionConfirmErr, w, logData)\n\t\t\treturn\n\t\t}\n\n\t\t// update instance with confirmed edition details\n\t\tinstance.Links = currentInstance.Links\n\t\tinstance.Links.Edition = &models.LinkObject{\n\t\t\tID: instance.Edition,\n\t\t\tHRef: editionDoc.Next.Links.Self.HRef,\n\t\t}\n\n\t\tinstance.Links.Version = editionDoc.Next.Links.LatestVersion\n\t\tinstance.Version, editionConfirmErr = strconv.Atoi(editionDoc.Next.Links.LatestVersion.ID)\n\t\tif editionConfirmErr != nil {\n\t\t\tlog.Error(ctx, \"update instance: failed to convert edition latestVersion id to instance.version int\", editionConfirmErr, editionLogData)\n\t\t\thandleInstanceErr(ctx, editionConfirmErr, w, logData)\n\t\t\treturn\n\t\t}\n\n\t\t// update dp-graph instance node (only for non-cantabular types)\n\t\tif currentInstance.Type == models.CantabularBlob.String() || currentInstance.Type == models.CantabularTable.String() || currentInstance.Type == models.CantabularFlexibleTable.String() || currentInstance.Type == models.CantabularMultivariateTable.String() {\n\t\t\teditionLogData[\"instance_type\"] = instance.Type\n\t\t\tlog.Info(ctx, \"skipping dp-graph instance update because it is not required by instance type\", editionLogData)\n\t\t} else {\n\t\t\tif versionErr := s.AddVersionDetailsToInstance(ctx, currentInstance.InstanceID, datasetID, edition, instance.Version); versionErr != nil {\n\t\t\t\tlog.Error(ctx, \"update instance: datastore.AddVersionDetailsToInstance returned an error\", versionErr, editionLogData)\n\t\t\t\thandleInstanceErr(ctx, versionErr, w, logData)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tlog.Info(ctx, \"update instance: added version details to instance\", editionLogData)\n\t}\n\n\t// Set the current mongo timestamp on instance document\n\tinstance.UniqueTimestamp = currentInstance.UniqueTimestamp\n\tnewETag, err := s.UpdateInstance(ctx, currentInstance, instance, eTag)\n\tif err != nil {\n\t\tlog.Error(ctx, \"update instance: store.UpdateInstance returned an error\", err, logData)\n\t\thandleInstanceErr(ctx, err, w, logData)\n\t\treturn\n\t}\n\n\tif instance, err = s.GetInstance(ctx, instanceID, newETag); err != nil {\n\t\tlog.Error(ctx, \"update instance: store.GetInstance for response returned an error\", err, logData)\n\t\thandleInstanceErr(ctx, err, w, logData)\n\t\treturn\n\t}\n\n\tb, err := json.Marshal(instance)\n\tif err != nil {\n\t\tlog.Error(ctx, \"add instance: failed to marshal instance to json\", err, logData)\n\t\thandleInstanceErr(ctx, err, w, logData)\n\t\treturn\n\t}\n\n\tsetJSONContentType(w)\n\tdpresponse.SetETag(w, newETag)\n\tw.WriteHeader(http.StatusOK)\n\twriteBody(ctx, w, b, logData)\n\n\tlog.Info(ctx, \"update instance: request successful\", logData)\n}", "func (is *InfluxStats) WriteErrUpdate(wt time.Duration) {\n\tis.mutex.Lock()\n\tdefer is.mutex.Unlock()\n\n\tif is.WriteTimeMax < wt {\n\t\tis.WriteTimeMax = wt\n\t}\n\tis.WriteErrors++\n\tis.WriteTime += wt\n}", "func (w *watcher) Next() ([]*naming.Update, error) {\n\t// dir is the etcd dir/value dir to watch\n\tdir := fmt.Sprintf(\"/%s/%s/\", Prefix, w.re.serviceName)\n\n\t// check if is initialized\n\tif !w.isInitialized {\n\t\t// query addresses from etcd\n\t\tresp, err := w.api.Get(context.Background(), dir, &etcd2.GetOptions{Recursive: true})\n\t\tw.isInitialized = true\n\t\tif err == nil {\n\t\t\taddrs := extractAddrs(resp)\n\t\t\t//if not empty, return the updates or watcher new dir\n\t\t\tif l := len(addrs); l != 0 {\n\t\t\t\tupdates := make([]*naming.Update, l)\n\t\t\t\tfor i := range addrs {\n\t\t\t\t\tupdates[i] = &naming.Update{Op: naming.Add, Addr: addrs[i]}\n\t\t\t\t}\n\t\t\t\treturn updates, nil\n\t\t\t}\n\t\t}\n\t}\n\n\t// generate etcd Watcher\n\tetcdWatcher := w.api.Watcher(dir, &etcd2.WatcherOptions{Recursive: true})\n\tfor {\n\t\tresp, err := etcdWatcher.Next(context.Background())\n\t\tif err == nil {\n\t\t\tswitch resp.Action {\n\t\t\tcase \"set\":\n\t\t\t\treturn []*naming.Update{{Op: naming.Add, Addr: resp.Node.Value}}, nil\n\t\t\tcase \"delete\", \"expire\":\n\t\t\t\treturn []*naming.Update{{Op: naming.Delete, Addr: strings.TrimPrefix(resp.Node.Key, dir)}}, nil // not using PrevNode because it may nil\n\t\t\t}\n\t\t}\n\t}\n}", "func newUpdateConsumer(t *testing.T) (*Consumer, chan Event) {\n\tc := make(chan Event, 2048)\n\tac := NewConsumer(t.Name(), c, ConsumerUpdate)\n\trequire.NoError(t, acctProbe.RegisterConsumer(ac))\n\n\treturn ac, c\n}", "func (handler *BotHandler) updateStatus() {\n\thandler.McRunner.WaitGroup.Add(1)\n\tdefer handler.McRunner.WaitGroup.Done()\n\tfor {\n\t\tselect {\n\t\tcase <-time.After(60 * time.Second):\n\t\t\thandler.McRunner.StatusRequestChannel <- true\n\n\t\t\tselect {\n\t\t\tcase status := <-handler.McRunner.StatusChannel:\n\t\t\t\tstatusJSON, _ := json.Marshal(status)\n\t\t\t\theader := header{Type: \"status\", Data: statusJSON}\n\t\t\t\thandler.sock.WriteJSON(header)\n\t\t\tcase <-time.After(10 * time.Second):\n\t\t\t\tfmt.Println(\"Failed to receive status update from runner, might be deadlocked.\")\n\t\t\t}\n\t\tcase <-handler.killChannel:\n\t\t\treturn\n\t\t}\n\n\t}\n}", "func (q *remoteUnordered) Next(ctx context.Context) amboy.Job {\n\tvar err error\n\n\tstart := time.Now()\n\tcount := 0\n\tlockingErrors := 0\n\tgetErrors := 0\n\tdispatchableErrors := 0\n\tfor {\n\t\tcount++\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn nil\n\t\tcase job := <-q.channel:\n\t\t\tif job == nil {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tjob, err = q.driver.Get(ctx, job.ID())\n\t\t\tif job == nil {\n\t\t\t\tgetErrors++\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif err != nil {\n\t\t\t\tgrip.Debug(message.WrapError(err, message.Fields{\n\t\t\t\t\t\"id\": job.ID(),\n\t\t\t\t\t\"operation\": \"problem refreshing job in dispatching from remote queue\",\n\t\t\t\t}))\n\t\t\t\tgrip.Debug(message.WrapError(q.driver.Unlock(ctx, job),\n\t\t\t\t\tmessage.Fields{\n\t\t\t\t\t\t\"id\": job.ID(),\n\t\t\t\t\t\t\"operation\": \"unlocking job, may leave a stale job\",\n\t\t\t\t\t}))\n\n\t\t\t\tgetErrors++\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tstatus := job.Status()\n\t\t\tif !isDispatchable(status) {\n\t\t\t\tdispatchableErrors++\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tti := amboy.JobTimeInfo{\n\t\t\t\tStart: time.Now(),\n\t\t\t}\n\t\t\tjob.UpdateTimeInfo(ti)\n\n\t\t\tif err := q.driver.Lock(ctx, job); err != nil {\n\t\t\t\tlockingErrors++\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tdispatchSecs := time.Since(start).Seconds()\n\t\t\tgrip.DebugWhen(dispatchSecs > dispatchWarningThreshold.Seconds() || count > 3,\n\t\t\t\tmessage.Fields{\n\t\t\t\t\t\"message\": \"returning job from remote source\",\n\t\t\t\t\t\"threshold_secs\": dispatchWarningThreshold.Seconds(),\n\t\t\t\t\t\"dispatch_secs\": dispatchSecs,\n\t\t\t\t\t\"attempts\": count,\n\t\t\t\t\t\"stat\": status,\n\t\t\t\t\t\"job\": job.ID(),\n\t\t\t\t\t\"get_errors\": getErrors,\n\t\t\t\t\t\"locking_errors\": lockingErrors,\n\t\t\t\t\t\"dispatchable_errors\": dispatchableErrors,\n\t\t\t\t})\n\n\t\t\treturn job\n\t\t}\n\t}\n}", "func (watcher *ConsulWatcher) Next() ([]*naming.Update, error) {\r\n\t// watcher.addrs is nil means it is initial called\r\n\tif watcher.addrs == nil {\r\n\t\t// return addrs to balancer, use ticker to query consul till data gotten\r\n\t\taddrs, lastIndex, _ := watcher.queryConsul(nil)\r\n\t\tif len(addrs) != 0 {\r\n\t\t\twatcher.addrs = addrs\r\n\t\t\twatcher.lastIndex = lastIndex\r\n\t\t\treturn lib.GenUpdates([]string{}, addrs), nil\r\n\t\t}\r\n\t}\r\n\r\n\tfor {\r\n\t\t// query the consul to get the addresses for service\r\n\t\taddrs, lastIndex, err := watcher.queryConsul(&consul.QueryOptions{WaitIndex: watcher.lastIndex})\r\n\t\tif err != nil {\r\n\t\t\tlog.Printf(\"naming: get addresses of '%s' from consul error: %s\\n\", watcher.resolver.ServiceName, err.Error())\r\n\t\t\ttime.Sleep(1 * time.Second)\r\n\t\t\tcontinue\r\n\t\t}\r\n\r\n\t\t// 1. delete the addresses in cache not in consul\r\n\t\t// 2. add the addresses in consul not in cache\r\n\t\tupdates := lib.GenUpdates(watcher.addrs, addrs)\r\n\r\n\t\t// update the addresses and last index in cache\r\n\t\twatcher.addrs = addrs\r\n\t\twatcher.lastIndex = lastIndex\r\n\t\tif len(updates) != 0 {\r\n\t\t\treturn updates, nil\r\n\t\t}\r\n\t}\r\n}", "func (client *Client) UpdateAppInstanceGroupImageWithChan(request *UpdateAppInstanceGroupImageRequest) (<-chan *UpdateAppInstanceGroupImageResponse, <-chan error) {\n\tresponseChan := make(chan *UpdateAppInstanceGroupImageResponse, 1)\n\terrChan := make(chan error, 1)\n\terr := client.AddAsyncTask(func() {\n\t\tdefer close(responseChan)\n\t\tdefer close(errChan)\n\t\tresponse, err := client.UpdateAppInstanceGroupImage(request)\n\t\tif err != nil {\n\t\t\terrChan <- err\n\t\t} else {\n\t\t\tresponseChan <- response\n\t\t}\n\t})\n\tif err != nil {\n\t\terrChan <- err\n\t\tclose(responseChan)\n\t\tclose(errChan)\n\t}\n\treturn responseChan, errChan\n}", "func (l *slowLocator) WaitForUpdate(ctx context.Context, oldVersion uint64) (Result, error) {\n\tl.reqs++\n\tres := Result{\n\t\tVersion: l.reqs,\n\t}\n\tif l.reqs >= 20 {\n\t\tres.Endpoints = []*Endpoint{{Host: \"example.com\", Port: \"80\"}}\n\t}\n\treturn res, nil\n}", "func (client *Client) UpdateEcsImageWithCallback(request *UpdateEcsImageRequest, callback func(response *UpdateEcsImageResponse, err error)) <-chan int {\n\tresult := make(chan int, 1)\n\terr := client.AddAsyncTask(func() {\n\t\tvar response *UpdateEcsImageResponse\n\t\tvar err error\n\t\tdefer close(result)\n\t\tresponse, err = client.UpdateEcsImage(request)\n\t\tcallback(response, err)\n\t\tresult <- 1\n\t})\n\tif err != nil {\n\t\tdefer close(result)\n\t\tcallback(nil, err)\n\t\tresult <- 0\n\t}\n\treturn result\n}", "func run(x int, c chan int) {\r\n\tx += 10\r\n\tc <- x\r\n}", "func (db *MongoDbBridge) indexUpdater(iq chan *IndexList, sig chan bool) {\n\tdefer func() {\n\t\tdb.wg.Done()\n\t\tdb.log.Noticef(\"db index updater closed\")\n\t}()\n\n\tfor {\n\t\tselect {\n\t\tcase <-sig:\n\t\t\treturn\n\t\tcase ix, more := <-iq:\n\t\t\t// is this the end?\n\t\t\tif !more {\n\t\t\t\tdb.log.Noticef(\"all indexes processed\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// do the update\n\t\t\terr := db.updateIndexes(ix.Collection, ix.Indexes, sig)\n\t\t\tif err != nil {\n\t\t\t\tdb.log.Errorf(\"%s index list sync failed; %s\", ix.Collection.Name(), err.Error())\n\t\t\t}\n\t\t}\n\t}\n}", "func (b *cloudBackend) tryNextUpdate(ctx context.Context, update client.UpdateIdentifier, continuationToken *string,\n\ttry int, nextRetryTime time.Duration,\n) (bool, interface{}, error) {\n\t// If there is no error, we're done.\n\tresults, err := b.client.GetUpdateEvents(ctx, update, continuationToken)\n\tif err == nil {\n\t\treturn true, results, nil\n\t}\n\n\t// There are three kinds of errors we might see:\n\t// 1) Expected HTTP errors (like timeouts); silently retry.\n\t// 2) Unexpected HTTP errors (like Unauthorized, etc); exit with an error.\n\t// 3) Anything else; this could be any number of things, including transient errors (flaky network).\n\t// In this case, we warn the user and keep retrying; they can ^C if it's not transient.\n\twarn := true\n\tif errResp, ok := err.(*apitype.ErrorResponse); ok {\n\t\tif errResp.Code == 504 {\n\t\t\t// If our request to the Pulumi Service returned a 504 (Gateway Timeout), ignore it and keep\n\t\t\t// continuing. The sole exception is if we've done this 10 times. At that point, we will have\n\t\t\t// been waiting for many seconds, and want to let the user know something might be wrong.\n\t\t\tif try < 10 {\n\t\t\t\twarn = false\n\t\t\t}\n\t\t\tlogging.V(3).Infof(\"Expected %s HTTP %d error after %d retries (retrying): %v\",\n\t\t\t\tb.CloudURL(), errResp.Code, try, err)\n\t\t} else {\n\t\t\t// Otherwise, we will issue an error.\n\t\t\tlogging.V(3).Infof(\"Unexpected %s HTTP %d error after %d retries (erroring): %v\",\n\t\t\t\tb.CloudURL(), errResp.Code, try, err)\n\t\t\treturn false, nil, err\n\t\t}\n\t} else {\n\t\tlogging.V(3).Infof(\"Unexpected %s error after %d retries (retrying): %v\", b.CloudURL(), try, err)\n\t}\n\n\t// Issue a warning if appropriate.\n\tif warn {\n\t\tb.d.Warningf(diag.Message(\"\" /*urn*/, \"error querying update status: %v\"), err)\n\t\tb.d.Warningf(diag.Message(\"\" /*urn*/, \"retrying in %vs... ^C to stop (this will not cancel the update)\"),\n\t\t\tnextRetryTime.Seconds())\n\t}\n\n\treturn false, nil, nil\n}", "func (w *Watcher) DoUpdate() {\n\tfor _, i := range w.Inputs {\n\t\tif w.closed {\n\t\t\treturn\n\t\t}\n\t\tnewStats, err := i.GetStats()\n\t\tif err == nil {\n\t\t\tif i.LastErr != nil || w.isSameAs(i.KnownStats, newStats) == false {\n\t\t\t\ti.Update(newStats)\n\t\t\t}\n\t\t} else {\n\t\t\tif i.OnErrored != nil {\n\t\t\t\ti.OnErrored(i, err)\n\t\t\t}\n\t\t\tw.LogFunc(\"Failed to resolve: %v\", err)\n\t\t}\n\t}\n}", "func Run(url, updateCmd string) {\n\tt := time.NewTicker(1 * time.Minute)\n\tfor {\n\t\t<-t.C\n\n\t\tr, err := http.Head(url)\n\t\tif err != nil {\n\t\t\tlogrus.Errorln(err)\n\t\t\tcontinue\n\t\t} else if r.StatusCode >= 300 {\n\t\t\tlogrus.Errorf(\"HEAD request returned status code %d\", r.StatusCode)\n\t\t\tcontinue\n\t\t}\n\n\t\tlm, err := time.Parse(time.RFC1123, r.Header.Get(\"Last-Modified\"))\n\t\tif err != nil {\n\t\t\tlogrus.Errorln(err)\n\t\t\tcontinue\n\t\t}\n\n\t\tif !lm.After(meta.BuildTime.Add(5 * time.Minute)) { // buffer for compile and upload time\n\t\t\tcontinue\n\t\t}\n\n\t\tlogrus.Println(\"updating binary...\")\n\n\t\terr = updateBin(url)\n\t\tif err != nil {\n\t\t\tlogrus.Errorln(err)\n\t\t\t// todo: may need to recover here, if stuck without binary\n\t\t\tcontinue\n\t\t}\n\n\t\tparts := strings.Fields(updateCmd)\n\t\terr = exec.Command(parts[0], parts[1:]...).Start()\n\t\tif err != nil {\n\t\t\tlogrus.Errorln(err)\n\t\t\tcontinue\n\t\t}\n\n\t\treturn // stop checking for updates in case restart takes a while\n\t}\n}", "func (s *State) Update(status mesos.TaskStatus) {\n\ts.updates <- status\n}", "func (u *addressUpdater) update() ([]string, error) {\n\tu.mu.Lock()\n\tdefer u.mu.Unlock()\n\n\tresult := u.addrs[0 : 1+u.n%len(u.addrs)]\n\tu.n++\n\treturn result, nil\n}", "func updateAsync(updateStruct *Update, callback chan *Callback) {\n\trecords, err := update(updateStruct)\n\tcb := new(Callback)\n\tcb.Data = records\n\tcb.Error = err\n\tcallback <- cb\n}", "func (c *ospfCollector) Update(ch chan<- prometheus.Metric) error {\n\tcmd := \"show ip ospf vrf all interface json\"\n\n\tif len(c.instanceIDs) > 0 {\n\t\tfor _, id := range c.instanceIDs {\n\t\t\tjsonOSPFInterface, err := executeOSPFMultiInstanceCommand(cmd, id)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif err = processOSPFInterface(ch, jsonOSPFInterface, c.descriptions, id); err != nil {\n\t\t\t\treturn cmdOutputProcessError(cmd, string(jsonOSPFInterface), err)\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\n\tjsonOSPFInterface, err := executeOSPFCommand(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err = processOSPFInterface(ch, jsonOSPFInterface, c.descriptions, 0); err != nil {\n\t\treturn cmdOutputProcessError(cmd, string(jsonOSPFInterface), err)\n\t}\n\treturn nil\n}", "func (m *FirestoreManager) Update(ctx context.Context,\n\tusr *User) (<-chan *User, <-chan error) {\n\tuserCh := make(chan *User)\n\terrCh := make(chan error)\n\n\tgo func() {\n\t\tdefer close(userCh)\n\t\tdefer close(errCh)\n\n\t\tif err := m.client.RunTransaction(ctx, func(ctx context.Context,\n\t\t\tt *firestore.Transaction) error {\n\t\t\tref := m.client.Collection(m.collectionName).Doc(usr.UID)\n\t\t\t_, err := t.Get(ref)\n\t\t\tif err != nil {\n\t\t\t\tif status.Code(err) == codes.NotFound {\n\t\t\t\t\treturn ErrUserNotFound\n\t\t\t\t}\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\treturn t.Set(ref, usr)\n\t\t}); err != nil {\n\t\t\terrCh <- err\n\t\t\treturn\n\t\t}\n\t\tuserCh <- usr\n\t}()\n\n\treturn userCh, errCh\n}", "func (c *Client) next(ctx context.Context) (Update, error) {\n\terr := make(chan error, 1)\n\tfor {\n\t\tvar u Update\n\t\tgo func() {\n\t\tagain:\n\t\t\te := jsonCodec.Receive(c.webSock, &u)\n\t\t\tif _, ok := e.(*json.UnmarshalTypeError); ok {\n\t\t\t\t// Not all RTM events can be unmarshaled into an Update.\n\t\t\t\t// However, all \"message\" type events can,\n\t\t\t\t// and that's all we care about.\n\t\t\t\t// Ignore any events that failed to unmarshal\n\t\t\t\t// due to UnmarshalTypeError.\n\t\t\t\tgoto again\n\t\t\t}\n\t\t\terr <- e\n\t\t}()\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn Update{}, ctx.Err()\n\t\tcase err := <-err:\n\t\t\tif err != nil {\n\t\t\t\treturn Update{}, err\n\t\t\t}\n\t\t\tif u.Type != \"pong\" {\n\t\t\t\treturn u, nil\n\t\t\t}\n\t\t}\n\t}\n}", "func logUpdate(ch <-chan int, total int, msg string) {\n\tstart := time.Now()\n\ttimer := time.NewTimer(time.Minute)\n\tdefer timer.Stop()\n\tvar current int\n\tvar ok bool\n\tfor {\n\t\tselect {\n\t\tcase current, ok = <-ch:\n\t\t\tif !ok { // channel is closed\n\t\t\t\treturn\n\t\t\t}\n\t\tcase now := <-timer.C:\n\t\t\telapsed := now.Sub(start)\n\t\t\trate := elapsed / time.Duration(current)\n\t\t\teta := time.Duration(total-current) * rate\n\n\t\t\tlogrus.WithFields(logrus.Fields{\n\t\t\t\t\"current\": current,\n\t\t\t\t\"total\": total,\n\t\t\t\t\"percent\": (100 * current) / total,\n\t\t\t\t\"remain\": eta.Round(time.Minute),\n\t\t\t\t\"eta\": now.Add(eta).Round(time.Minute),\n\t\t\t}).Info(msg)\n\t\t\ttimer.Reset(time.Minute)\n\t\t}\n\t}\n}", "func (w *Watcher) Next() ([]*registry.ServiceInstance, error) {\n\tif !w.first {\n\t\tw.first = true\n\t\tif len(w.ServiceInstances) > 0 {\n\t\t\treturn instancesToServiceInstances(w.ServiceInstances), nil\n\t\t}\n\t}\n\tselect {\n\tcase <-w.Ctx.Done():\n\t\treturn nil, w.Ctx.Err()\n\tcase event := <-w.Channel:\n\t\tif event.GetSubScribeEventType() == model.EventInstance {\n\t\t\t// this always true, but we need to check it to make sure EventType not change\n\t\t\tif instanceEvent, ok := event.(*model.InstanceEvent); ok {\n\t\t\t\t// handle DeleteEvent\n\t\t\t\tif instanceEvent.DeleteEvent != nil {\n\t\t\t\t\tfor _, instance := range instanceEvent.DeleteEvent.Instances {\n\t\t\t\t\t\tdelete(w.ServiceInstances, instance.GetMetadata()[\"merge\"])\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// handle UpdateEvent\n\t\t\t\tif instanceEvent.UpdateEvent != nil {\n\t\t\t\t\tfor _, update := range instanceEvent.UpdateEvent.UpdateList {\n\t\t\t\t\t\tif v, ok := w.ServiceInstances[update.After.GetMetadata()[\"merge\"]]; ok {\n\t\t\t\t\t\t\tvar nv []model.Instance\n\t\t\t\t\t\t\tm := map[string]model.Instance{}\n\t\t\t\t\t\t\tfor _, ins := range v {\n\t\t\t\t\t\t\t\tm[ins.GetId()] = ins\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tm[update.After.GetId()] = update.After\n\t\t\t\t\t\t\tfor _, ins := range m {\n\t\t\t\t\t\t\t\tif ins.IsHealthy() {\n\t\t\t\t\t\t\t\t\tnv = append(nv, ins)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tw.ServiceInstances[update.After.GetMetadata()[\"merge\"]] = nv\n\t\t\t\t\t\t\tif len(nv) == 0 {\n\t\t\t\t\t\t\t\tdelete(w.ServiceInstances, update.After.GetMetadata()[\"merge\"])\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif update.After.IsHealthy() {\n\t\t\t\t\t\t\t\tw.ServiceInstances[update.After.GetMetadata()[\"merge\"]] = []model.Instance{update.After}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// handle AddEvent\n\t\t\t\tif instanceEvent.AddEvent != nil {\n\t\t\t\t\tfor _, instance := range instanceEvent.AddEvent.Instances {\n\t\t\t\t\t\tif v, ok := w.ServiceInstances[instance.GetMetadata()[\"merge\"]]; ok {\n\t\t\t\t\t\t\tvar nv []model.Instance\n\t\t\t\t\t\t\tm := map[string]model.Instance{}\n\t\t\t\t\t\t\tfor _, ins := range v {\n\t\t\t\t\t\t\t\tm[ins.GetId()] = ins\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tm[instance.GetId()] = instance\n\t\t\t\t\t\t\tfor _, ins := range m {\n\t\t\t\t\t\t\t\tif ins.IsHealthy() {\n\t\t\t\t\t\t\t\t\tnv = append(nv, ins)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif len(nv) != 0 {\n\t\t\t\t\t\t\t\tw.ServiceInstances[instance.GetMetadata()[\"merge\"]] = nv\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif instance.IsHealthy() {\n\t\t\t\t\t\t\t\tw.ServiceInstances[instance.GetMetadata()[\"merge\"]] = []model.Instance{instance}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn instancesToServiceInstances(w.ServiceInstances), nil\n\t\t}\n\t}\n\treturn instancesToServiceInstances(w.ServiceInstances), nil\n}", "func updateTX() {\n\n\t// forever monitor and reading the txChannel\n\tnTx := 0\n\tfor {\n\t\t//\ttime.Sleep(time.Duration(2) * time.Second)\n\t\tfmt.Printf(\"\\nChannel size:%d\", len(txChannel))\n\t\ttxInfo, ok := <-txChannel\n\n\t\ttxGrp := []TxInfo{txInfo}\n\n\t\tif !ok {\n\t\t\tfmt.Println(\"Channel closed!\")\n\t\t\tbreak\n\t\t}\n\n\t\tb := 0 // break flag\n\t\tnTx = 1\n\t\t// perform batch update up to 200 records at a time, 199 because one is alread read\n\t\t// parameter to be configured.\n\t\tfor i := 0; i < 199; i++ {\n\n\t\t\tselect {\n\t\t\tcase txInfo, ok := <-txChannel:\n\t\t\t\tif ok {\n\t\t\t\t\t// fmt.Printf(\"\\nSubsequent gets from channel:\\n%+v\\n\", txInfo)\n\t\t\t\t\ttxGrp = append(txGrp, txInfo)\n\t\t\t\t\tnTx++\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Println(\"Channel closed!\")\n\t\t\t\t\tb = 1\n\t\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tb = 1\n\t\t\t}\n\n\t\t\tif b == 1 {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t}\n\n\t\t// fmt.Printf(\"\\nTotal record from channel:%d\", nTx)\n\t\tupdateTXGrp(txGrp)\n\t}\n\n}", "func (rbl *Rbl) Update(ip string, rbls []string) {\n\t// from: godnsbl\n\twg := &sync.WaitGroup{}\n\n\tfor _, source := range rbls {\n\t\twg.Add(1)\n\t\tgo func(source string, ip string) {\n\t\t\tdefer wg.Done()\n\n\t\t\trbl.logger.Debug(\"Next up\", slog.String(\"rbl\", source), slog.String(\"ip\", ip))\n\n\t\t\tresults := rbl.lookup(source, ip)\n\t\t\tif len(results) == 0 {\n\t\t\t\trbl.Results = []Rblresult{}\n\t\t\t} else {\n\t\t\t\trbl.Results = results\n\t\t\t}\n\t\t}(source, ip)\n\t}\n\n\twg.Wait()\n}", "func (self *IoStatsBuilder) Update(current map[int]*IoAmount, now time.Time) {\n\tseconds := now.Sub(self.lastMeasurement).Seconds()\n\tvar total IoAmount\n\tfor pid, amt := range current {\n\t\ttotal.Increment(amt)\n\t\tdelete(self.lastPids, pid)\n\t}\n\tfor _, amt := range self.lastPids {\n\t\tself.deadUsage.Increment(amt)\n\t}\n\ttotal.Increment(&self.deadUsage)\n\tself.lastPids = current\n\tself.lastMeasurement = now\n\tdiff := self.Total.update(&total)\n\tif seconds > 0 {\n\t\trate := diff.rate(seconds)\n\t\tself.RateMax.TakeMax(rate)\n\t\trate.weightSquared(seconds)\n\t\tself.weightedSumSquared.Increment(rate)\n\t\tif t := now.Sub(self.start).Seconds(); t > 0 {\n\t\t\tself.RateDev = self.weightedSumSquared.computeStdDev(\n\t\t\t\t&self.Total, t)\n\t\t}\n\t}\n}", "func (is *InfluxStats) WriteOkUpdate(ps int64, wt time.Duration) {\n\tis.mutex.Lock()\n\tdefer is.mutex.Unlock()\n\tif is.PSentMax < ps {\n\t\tis.PSentMax = ps\n\t}\n\tif is.WriteTimeMax < wt {\n\t\tis.WriteTimeMax = wt\n\t}\n\tis.WriteSent++\n\tis.PSent += ps\n\tis.WriteTime += wt\n}", "func (ctl *Controller) Update() error {\n\tn, err := ctl.spi.Write(ctl.buffer)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif n != len(ctl.buffer) {\n\t\treturn errors.New(\"Unable to send the full LED colour buffer to device\")\n\t}\n\treturn nil\n}", "func (cp *ConnPool) Update(conn *Conn) error {\n\tcp.log.Info(\"Update conn\", \"id\", conn.GetConnID())\n\tcp.lock.Lock()\n\tdefer cp.lock.Unlock()\n\tif cp.conns[conn.GetConnID()] == nil {\n\t\tcp.log.Error(\"Update conn error\", \"error\", ErrNotExist.Error())\n\t\treturn ErrNotExist\n\t}\n\tcp.conns[conn.GetConnID()].Close()\n\tdelete(cp.conns, conn.GetConnID())\n\tcp.conns[conn.GetConnID()] = conn\n\treturn nil\n}", "func (p *AutoCommitter) Update(pair []interface{}) (e error) {\n\tif p.started {\n\t\tp.docsUpdate <- pair\n\t} else {\n\t\te = errors.New(fmt.Sprintf(\"AutoCommitter-%s(%s)_is_closed\", p.name, p.coll))\n\t}\n\treturn\n}", "func (c *ConcurrencyLimiter) Increment() {\n\tr := make(chan struct{})\n\tc.inc <- r\n\t<-r\n}", "func (c *Client) Run(ctx context.Context, start int) (next int, err error) {\n\tterm := ctx.Done()\nevloop:\n\tfor {\n\t\tif start < next {\n\t\t\tstart = next\n\t\t}\n\t\tevs, err := c.events(ctx, start)\n\t\tif err != nil {\n\t\t\treturn next, err\n\t\t}\n\t\tlog.Printf(\"[INFO] Found %d new events\", len(evs))\n\t\tselect {\n\t\tcase <-term:\n\t\t\tbreak evloop\n\t\tdefault:\n\t\t}\n\t\tfor _, ev := range evs {\n\t\t\tif c.Handler != nil {\n\t\t\t\tc.Handler.HandleEvent(ctx, c, ev)\n\t\t\t}\n\t\t\tselect {\n\t\t\tcase <-term:\n\t\t\t\tbreak evloop\n\t\t\tdefault:\n\t\t\t}\n\t\t\tnext = int(ev.Index()) + 1\n\t\t}\n\t}\n\treturn next, nil\n}", "func (p *Provider) UpdatesChan() chan<- Update {\n\treturn p.updatesChan\n}", "func (r *Ranking) addWaitUpdateAddressUnsafe(addrstr string) {\n\tif len(addrstr) == 0 {\n\t\treturn\n\t}\n\tif _, have := r.wait_update_address_list[addrstr]; have {\n\t\treturn // Already exists\n\t}\n\tr.wait_update_address_num += 1\n\tr.wait_update_address_list[addrstr] = true\n\t// Notify update\n\tif r.wait_update_address_num == 50 {\n\t\tif len(r.flushStateToDiskNotifyCh) == 0 {\n\t\t\tgo func() {\n\t\t\t\tr.flushStateToDiskNotifyCh <- true // notice\n\t\t\t}()\n\t\t}\n\t}\n}", "func (t *Group) updateExceeded(exceeded bool) {\n\tt.Lock()\n\tdefer t.Unlock()\n\n\tif exceeded {\n\t\tt.exceeded++\n\t\tif t.exceeded == 1 {\n\t\t\tt.wait = make(chan struct{})\n\t\t}\n\t} else {\n\t\tt.exceeded--\n\t\tif t.exceeded == 0 {\n\t\t\tclose(t.wait)\n\t\t\tt.wait = nil\n\t\t}\n\t}\n\n\treturn\n}", "func UpdateFD(fd int32) error {\n\treturn shared.notifier.updateFD(fd)\n}", "func (eer *externalEventReceiver) StateUpdating(seqNo uint64, id []byte) {\n\teer.manager.Queue() <- stateUpdatingEvent{\n\t\tseqNo: seqNo,\n\t\tid: id,\n\t}\n}", "func (w *Watcher) Update() {\n\tw.Action = true\n\tfits := w.SessionKey[:2]\n\tfmt.Println(\"[!] Attempting to update watcher: %s\", fits)\n\twriten, err := w.Connection.Write([]byte(\"Y\"))\n\tif writen != len([]byte(\"Y\")) {\n\t\tfmt.Println(\"[!]Error writting: unable to write\")\n\t}\n\tif err != nil {\n\t\tfmt.Printf(\"%s\", err)\n\t}\n\n}", "func (ipm *IPManager) updateRunner() {\n\tgo func() {\n\t\tfor {\n\t\t\tipm.updateReceiver(<-ipm.ipQueue)\n\t\t}\n\t}()\n}", "func (p *DirectBuy) runUpdateStatus() {\n\tlog := p.log.WithField(\"goroutine\", \"runUpdateStatus\")\n\tfor {\n\t\tselect {\n\t\tcase <-p.quit:\n\t\t\tlog.Info(\"quit\")\n\t\t\treturn\n\t\tcase d := <-p.receiver.Deposits():\n\t\t\tupdatedDeposit, err := p.updateStatus(d)\n\t\t\tp.setStatus(err)\n\t\t\tif err != nil {\n\t\t\t\tmsg := \"updateStatus failed. This deposit will not be reprocessed until teller is restarted.\"\n\t\t\t\tlog.WithFields(logrus.Fields{\n\t\t\t\t\t\"depositInfo\": d,\n\t\t\t\t\t\"notice\": logger.WatchNotice,\n\t\t\t\t}).WithError(err).Error(msg)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tp.deposits <- updatedDeposit\n\t\t}\n\t}\n}", "func (pb *Pubsub) run() {\n\tfor {\n\t\tselect {\n\t\tcase t := <-pb.updateCh.Get():\n\t\t\tpb.updateCh.Load()\n\t\t\tif pb.done.HasFired() {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tpb.callCallback(t.(*watcherInfoWithUpdate))\n\t\tcase <-pb.done.Done():\n\t\t\treturn\n\t\t}\n\t}\n}", "func (_m *Repository) Update(p *entity.Person, commitChan <-chan bool, doneChan chan<- bool) {\n\t_m.Called(p, commitChan, doneChan)\n}", "func (h *consulGRPCSocketHook) Update(req *interfaces.RunnerUpdateRequest) error {\n\th.mu.Lock()\n\tdefer h.mu.Unlock()\n\n\th.alloc = req.Alloc\n\n\tif !h.shouldRun() {\n\t\treturn nil\n\t}\n\n\treturn h.proxy.run(h.alloc)\n}", "func (client *Client) UpdateTicketWithCallback(request *UpdateTicketRequest, callback func(response *UpdateTicketResponse, err error)) <-chan int {\n\tresult := make(chan int, 1)\n\terr := client.AddAsyncTask(func() {\n\t\tvar response *UpdateTicketResponse\n\t\tvar err error\n\t\tdefer close(result)\n\t\tresponse, err = client.UpdateTicket(request)\n\t\tcallback(response, err)\n\t\tresult <- 1\n\t})\n\tif err != nil {\n\t\tdefer close(result)\n\t\tcallback(nil, err)\n\t\tresult <- 0\n\t}\n\treturn result\n}", "func (client *Client) UpdateIntegrationWithCallback(request *UpdateIntegrationRequest, callback func(response *UpdateIntegrationResponse, err error)) <-chan int {\n\tresult := make(chan int, 1)\n\terr := client.AddAsyncTask(func() {\n\t\tvar response *UpdateIntegrationResponse\n\t\tvar err error\n\t\tdefer close(result)\n\t\tresponse, err = client.UpdateIntegration(request)\n\t\tcallback(response, err)\n\t\tresult <- 1\n\t})\n\tif err != nil {\n\t\tdefer close(result)\n\t\tcallback(nil, err)\n\t\tresult <- 0\n\t}\n\treturn result\n}", "func lockItUp() {\n\twait := make(chan struct{})\n\tvar n AtomicInt\n\tgo func() {\n\t\tn.Add(1) // one access.\n\t\tclose(wait)\n\t}()\n\tn.Add(1) // another concurrent access.\n\t<-wait\n\tfmt.Println(n.Value())\n}", "func UpdateMetrics() error {\n\t// err is aggregation of errors while running each of the MetricFetchers\n\tvar err error\n\n\t// wg is go's way of concurrency control essentially a way to say when the main thread can resume execution\n\tvar wg sync.WaitGroup\n\t// main thread after spawning go routines should resume only once all go routines are done executing\n\twg.Add(len(MetricFetchers))\n\n\t// Loop over all the metric fetchers and spawn execution of each MetricFetcher as a go-routine(concurrent execution)\n\tfor _, metricFetcher := range MetricFetchers {\n\t\tgo func() {\n\t\t\t// execute the metricfetcher to get its corresponding clouwatch form\n\t\t\tnamespace, name, value, metaInfo, e := metricFetcher()\n\t\t\t// if err is not nil, accummulate it and error and later instead of failing fast...\n\t\t\t// So, that other metrics can be collected instead of failing completely for failure in collecting one/some\n\t\t\t// of the metrics\n\t\t\tif e != nil {\n\t\t\t\tif err == nil {\n\t\t\t\t\terr = e\n\t\t\t\t\treturn\n\t\t\t\t} else {\n\t\t\t\t\terr = fmt.Errorf(\"%s.%s\", err, e.Error())\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfmt.Println(namespace, name, value, metaInfo, e)\n\n\t\t\t// Push the metric just collected\n\t\t\te = PushMetricToCloudWatch(namespace, name, value, metaInfo)\n\t\t\t// If error accummulate error\n\t\t\tif e != nil {\n\t\t\t\t// ToDo(@Anmol Babu) handle the error concatenation better\n\t\t\t\tif err == nil {\n\t\t\t\t\terr = e\n\t\t\t\t\treturn\n\t\t\t\t} else {\n\t\t\t\t\terr = fmt.Errorf(\"%s.%s\", err, e.Error())\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Signal completion of one routine to be waited on\n\t\t\twg.Done()\n\t\t}()\n\t}\n\t// Wait until all go-routines are done executing\n\twg.Wait()\n\treturn err\n}", "func (c *Controller) updateStatus(name types.NamespacedName, update func(status *CmdStatus), stillHasSameProcNum func() bool) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tif !stillHasSameProcNum() {\n\t\treturn\n\t}\n\n\tcmd, ok := c.updateCmds[name]\n\tif !ok {\n\t\treturn\n\t}\n\n\tupdate(&cmd.Status)\n\n\terr := c.client.Status().Update(c.globalCtx, cmd)\n\tif err != nil && !apierrors.IsNotFound(err) {\n\t\tc.st.Dispatch(store.NewErrorAction(fmt.Errorf(\"syncing to apiserver: %v\", err)))\n\t\treturn\n\t}\n\n\tc.st.Dispatch(local.NewCmdUpdateStatusAction(cmd))\n}", "func (op *updateHealthCheckUpdateOperation) do(ctx context.Context, r *HealthCheck, c *Client) error {\n\t_, err := c.GetHealthCheck(ctx, r.urlNormalized())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tu, err := r.updateURL(c.Config.BasePath, \"update\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treq, err := newUpdateHealthCheckUpdateRequest(ctx, r, c)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tc.Config.Logger.Infof(\"Created update: %#v\", req)\n\tbody, err := marshalUpdateHealthCheckUpdateRequest(c, req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tresp, err := dcl.SendRequest(ctx, c.Config, \"PATCH\", u, bytes.NewBuffer(body), c.Config.RetryProvider)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar o operations.ComputeOperation\n\tif err := dcl.ParseResponse(resp.Response, &o); err != nil {\n\t\treturn err\n\t}\n\terr = o.Wait(ctx, c.Config, \"https://www.googleapis.com/compute/v1/\", \"GET\")\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (a *apiEndpoint) Update() error {\n\ta.e.mutex.RLock()\n\ta.SetEntry(\"server\", api.String(a.e.poolEntry.Desc))\n\ta.SetEntry(\"status\", api.String(a.e.status.String()))\n\tif a.e.lastErr != nil {\n\t\ta.SetEntry(\"last_error\", api.String(a.e.lastErr.Error()))\n\t\ta.SetEntry(\"last_error_time\", api.String(a.e.lastErrTime.Format(time.RFC3339)))\n\t} else {\n\t\ta.SetEntry(\"last_error\", api.Null)\n\t\ta.SetEntry(\"last_error_time\", api.Null)\n\t}\n\ta.SetEntry(\"pendingPayloads\", api.Number(a.e.NumPending()))\n\ta.SetEntry(\"publishedLines\", api.Number(a.e.LineCount()))\n\ta.SetEntry(\"averageLatency\", api.Float(a.e.AverageLatency()/time.Millisecond))\n\ta.e.mutex.RUnlock()\n\n\treturn nil\n}", "func (c *Consumer) eat(idx int) {\n\tdefer c.Done() // HL\n\tresults := c.workers[idx].Run()\n\tfor result := range results {\n\t\tc.consume(result) // HL\n\t}\n}" ]
[ "0.5178523", "0.5173922", "0.5094512", "0.50584483", "0.4905737", "0.48709536", "0.48703036", "0.48117092", "0.48010278", "0.4788073", "0.47819346", "0.4738964", "0.47305784", "0.47250986", "0.47129682", "0.47085497", "0.46851322", "0.46636736", "0.46448827", "0.46305528", "0.46168047", "0.46134213", "0.45766118", "0.4563894", "0.4559649", "0.45559475", "0.45538226", "0.45538226", "0.4551232", "0.45433685", "0.454163", "0.45322487", "0.4532084", "0.45263502", "0.45246613", "0.45207667", "0.45088318", "0.44936937", "0.44849205", "0.44772622", "0.447684", "0.44753408", "0.44661626", "0.4461681", "0.4461681", "0.4444176", "0.4439549", "0.44360515", "0.44328547", "0.44322202", "0.44317406", "0.44296837", "0.44212148", "0.44208652", "0.44178864", "0.44089416", "0.44024184", "0.4399651", "0.43987367", "0.43980908", "0.43965235", "0.43956015", "0.43952632", "0.43936613", "0.43900466", "0.43817165", "0.4379841", "0.4375911", "0.43716976", "0.43685624", "0.43617618", "0.43604597", "0.43546495", "0.43521392", "0.43394944", "0.43286267", "0.4324338", "0.4321287", "0.43153077", "0.43105525", "0.42992058", "0.429765", "0.42966998", "0.42932096", "0.4291205", "0.4286246", "0.4285835", "0.42851746", "0.4279435", "0.42778093", "0.42731726", "0.42705595", "0.4266749", "0.426584", "0.4264728", "0.42565602", "0.4255051", "0.42546785", "0.42519426", "0.42513633" ]
0.586269
0
/ ============== === Public === ============= StartPing to coordinator every interval duration
func StartPing(interval time.Duration){ log.Println("Ping Time") pinging := true for pinging { pinging = false log.Print("Pinging set to " + strconv.FormatBool(pinging)) if shouldIPing() { pinging = true log.Print("Pinging set to " + strconv.FormatBool(pinging)) bullyImpl.SetIsCoordinatorAlive(false) log.Print(bullyImpl.IsCoordinatorAlive()) bullyImpl.GetMoi().Ping(bullyImpl.GetCoordinator()) timer := time.NewTimer(interval) select { case <- endTimer: log.Print("Pinging was ended") case <- timer.C: if shouldIPing() && !bullyImpl.IsCoordinatorAlive() { pinging = false log.Print("Pinging set to " + strconv.FormatBool(pinging)) log.Print("Coordinator is not alive, launching a new Election") go func(){ electionChannel <- struct{}{} }() } } } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func periodicPing() {\n\tfor {\n\t\t// Shuffle membership list and get a member\n\t\t// Only executed when the membership list is not empty\n\t\tif CurrentList.Size() > 0 {\n\t\t\tmember := CurrentList.Shuffle()\n\t\t\t// Do not pick itself as the ping target\n\t\t\tif (member.TimeStamp == CurrentMember.TimeStamp) && (member.IP == CurrentMember.IP) {\n\t\t\t\ttime.Sleep(PingSendingPeriod)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tLogger.Info(\"Member (%d, %d) is selected by shuffling\\n\", member.TimeStamp, member.IP)\n\t\t\t// Get update entry from TTL Cache\n\t\t\tupdate, flag, err := getUpdate()\n\t\t\t// if no update there, do pure ping\n\t\t\tif err != nil {\n\t\t\t\tping(member)\n\t\t\t} else {\n\t\t\t\t// Send update as payload of ping\n\t\t\t\tpingWithPayload(member, update, flag)\n\t\t\t}\n\t\t}\n\t\ttime.Sleep(PingSendingPeriod)\n\t}\n}", "func startPeriodicHealthCheck(m *MicroService, interval time.Duration, d *net.Dialer) {\r\n\tticker := time.NewTicker(interval)\r\n\tdefer ticker.Stop()\r\n\tfor t := range ticker.C {\r\n\t\tlogVerbose(\"Checking health of Service:\", m.Route, \" ---tick:\", t)\r\n\t\thandleHealthCheck(m, d)\r\n\t}\r\n}", "func (x *Ping) StartPinging() {\n\tif x.cfg.Send {\n\t\tx.pingOnce.Do(func() {\n\t\t\tx.pingTm = time.AfterFunc(time.Second*time.Duration(x.cfg.SendInterval), x.sendPing)\n\t\t})\n\t}\n}", "func (conn *Conn) ping() {\n\ttick := time.NewTicker(conn.PingFreq)\n\tfor {\n\t\tselect {\n\t\tcase <-tick.C:\n\t\t\tconn.Raw(fmt.Sprintf(\"PING :%d\", time.Now().UnixNano()))\n\t\tcase <-conn.cPing:\n\t\t\ttick.Stop()\n\t\t\treturn\n\t\t}\n\t}\n}", "func ping() error {\n\tfor i := 0; i < 10; i++ {\n\t\t// Ping the server by sending a GET request to `/health`.\n\t\tresp, err := http.Get(\"http://localhost\" + viper.GetString(\"addr\") + \"/\")\n\t\tif err == nil && resp.StatusCode == 200 {\n\t\t\treturn nil\n\t\t}\n\n\t\t// Sleep for a second to continue the next ping.\n\t\tlog.Infoln(\"Waiting for the router, retry in 1 second.\")\n\t\ttime.Sleep(time.Second)\n\t}\n\treturn errors.New(\"app is not working\")\n}", "func pingLoop(client *Client) {\n\t// Create ticker to send pings every two minutes.\n\tticker := time.NewTicker(time.Minute * 2)\n\tfor {\n\t\tselect {\n\t\t// If the client is done, stop the time and goroutine.\n\t\tcase <-client.Done:\n\t\t\tticker.Stop()\n\t\t\treturn\n\t\t// Loop pings to keep connection alive.\n\t\tcase <-ticker.C:\n\t\t\tSendPing(client, strconv.FormatInt(time.Now().UnixNano(), 10))\n\t\t}\n\t}\n}", "func pingNodesLoop() {\n\tstop := false\n\tfor !stop {\n\t\tpingNodes()\n\t\t// TODO longer ping interval\n\t\ttime.Sleep(300 * time.Second)\n\t}\n}", "func (m *manager) onPing(addr string, rtt time.Duration) error {\n\tv := int32(rtt.Nanoseconds() / 1000)\n\tif v == 0 { // Don't let it be zero, otherwise the update would fail\n\t\tv = 1\n\t}\n\n\tm.monitor.Measure(addr, v)\n\treturn nil\n}", "func (e *EndpointsManager) Run() {\n\tticker := time.NewTicker(time.Second * 10)\n\tdefer ticker.Stop()\n\tfor {\n\t\tselect {\n\t\tcase <-ticker.C:\n\t\t\te.watchAliveEndpoint()\n\t\tcase <-e.exit:\n\t\t\tclose(e.closed)\n\t\t\tcommon.Logger.Info(\"service done!!!\")\n\t\t\treturn\n\t\t}\n\t}\n}", "func (t *Tracker) Ping() {\n\t// acquire mutex\n\tt.mutex.Lock()\n\tdefer t.mutex.Unlock()\n\n\t// increment\n\tt.pings++\n}", "func (p *Pool) heartbeat() {\n\tgo func() {\n\t\tfor {\n\t\t\tp.Cmd(\"PING\")\n\t\t\ttime.Sleep(1 * time.Second)\n\t\t}\n\t}()\n}", "func (conn *Conn) ping(ctx context.Context) {\n\tdefer conn.wg.Done()\n\ttick := time.NewTicker(conn.cfg.PingFreq)\n\tfor {\n\t\tselect {\n\t\tcase <-tick.C:\n\t\t\tconn.Ping(fmt.Sprintf(\"%d\", time.Now().UnixNano()))\n\t\tcase <-ctx.Done():\n\t\t\t// control channel closed, bail out\n\t\t\ttick.Stop()\n\t\t\treturn\n\t\t}\n\t}\n}", "func pingLoop(results chan Host, hostRegistry *HostRegistry, interval time.Duration, timeout time.Duration) {\n\tfor {\n\t\thostAddresses := hostRegistry.GetHostAddresses()\n\n\t\tlog.Info(\"Pinging these addresses: %q\\n\", hostAddresses)\n\n\t\tfor _, address := range hostAddresses {\n\t\t\tlog.Debug(\"Pinging: %v\\n\", address)\n\n\t\t\thost, err := hostRegistry.GetHost(address)\n\t\t\tif err != nil {\n\t\t\t\tlog.Warning(\"GetHost() returned error=%v for address=%v\", err, address)\n\t\t\t}\n\n\t\t\tgo pingAddress(results, host, timeout)\n\t\t}\n\n\t\tlog.Debug(\"Started pings for all hosts. Sleeping for: %v\", interval)\n\t\ttime.Sleep(interval)\n\t}\n}", "func (d *Daemon) Start(interval int, data chan *structs.Data) {\n\t// immediately fetch the first set of data and send it over the data channel\n\td.fetchData()\n\td.buildData()\n\n\tselect {\n\tcase data <- d.Data:\n\t\tlogger.Trace(\"Sending initial results on the 'data' channel\")\n\tdefault:\n\t\tlogger.Trace(\"Could not send initial results on the 'data' channel\")\n\t}\n\n\t// fetch new data every interval\n\tduration := time.Duration(interval) * time.Second\n\tfor _ = range time.Tick(duration) {\n\t\td.resetData()\n\t\td.fetchData()\n\t\td.buildData()\n\n\t\t// send the result over the data channel\n\t\tselect {\n\t\tcase data <- d.Data:\n\t\t\tlogger.Trace(\"Sending results on the 'data' channel\")\n\t\tdefault:\n\t\t\tlogger.Trace(\"Could not send results on the 'data' channel\")\n\t\t}\n\t}\n}", "func (p *Pinger) Ping() error {\r\n\tconn, err := p.NewConn()\r\n\tif err != nil {\r\n\t\treturn err\r\n\t}\r\n\tp.conn = conn\r\n\tfor i := 0; i < p.amt; i++ {\r\n\t\terr = p.SendOnePing(i, conn)\r\n\t}\r\n\treturn err\r\n}", "func (me *Mgr) doPing() {\n\tfor !me.stopped {\n\t\tme.workers.Scan(func(id string, w interface{}) {\n\t\t\terr := w.(*Worker).Ping()\n\t\t\tif err != DEADERR {\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// dead\n\t\t\tme.deadChan <- id\n\t\t\tme.deadWorkers.Set(id, []byte(\"OK\"))\n\t\t\tme.workers.Delete(id)\n\t\t})\n\t\ttime.Sleep(15 * time.Second)\n\t}\n}", "func Heartbeat() {\n\tdone := make(chan struct{})\n\tlistener, err := net.Listen(\"tcp\", \"127.0.0.1:\")\n\tif err != nil {\n\t\tfmt.Printf(\"can not listen: %v\", err)\n\t}\n\n\tgo func(){\n\t\tdefer func() {\n\t\t\tclose(done)\n\t\t}()\n\n\t\tconn, err := listener.Accept()\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"can not accept connection: %v\", err)\n\t\t}\n\n\t\tctx, cancel := context.WithCancel(context.Background())\n\t\tdefer func() {\n\t\t\tcancel()\n\t\t\tif err := conn.Close(); err != nil {\n\t\t\t\tfmt.Printf(\"can not close connection: %v\", err)\n\t\t\t}\n\t\t}()\n\n\t\tresetInterval := make(chan time.Duration)\n\t\tresetInterval <- time.Second\n\n\t\tgo doPing(ctx, conn, resetInterval)\n\n\t\terr = conn.SetDeadline(time.Now().Add(5 * time.Second))\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"can not set deadline: %v\", err)\n\t\t\treturn\n\t\t}\n\n\t\tbuf := make([]byte, 1024)\n\t\tfor {\n\t\t\tn, err := conn.Read(buf)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"can not read buffer: %v\", err)\n\t\t\t}\n\n\t\t\tfmt.Printf(\"Recieved: %s\", buf[:n])\n\n\t\t\tresetInterval <- 0\n\t\t\terr = conn.SetDeadline(time.Now().Add(5 * time.Second))\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"can not set deadline: %v\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n\n\tconn, err := net.Dial(\"tcp\", listener.Addr().String())\n\tif err != nil {\n\t\tfmt.Printf(\"can not dial listener: %v\", err)\n\t}\n\n\tdefer conn.Close()\n\n\tbuf := make([]byte, 1024)\n\tfor i := 0; i < 4; i++ {\n\t\tn, err := conn.Read(buf)\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"can not read buffer: %v\", err)\n\t\t}\n\t\tfmt.Printf(\"Recieved is: %s \", buf[:n])\n\t}\n\n\t_, err = conn.Write([]byte(\"Pong\"))\n\tif err != nil {\n\t\tfmt.Printf(\"can not write to connection: %v\", err)\n\t}\n\n\tfor i := 0; i < 4; i++ {\n\t\tn, err := conn.Read(buf)\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"can not read buffer: %v\", err)\n\t\t}\n\t\tfmt.Printf(\"Recieved is: %s \", buf[:n])\n\t}\n\n\t<-done\n\n}", "func (dispatcher *Dispatcher) Start() {\n\tfor {\n\t\tselect {\n\t\tcase statusUpdate := <-dispatcher.statusChan:\n\t\t\tif !dispatcher.shouldPublish(statusUpdate) {\n\t\t\t\tlog.Debugf(\"suppressing: %+v\", statusUpdate)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tpingResult := statusUpdate.Status.LatestResult\n\t\t\tvar error string\n\t\t\tif pingResult.Error != nil {\n\t\t\t\terror = pingResult.Error.Error()\n\t\t\t}\n\t\t\tstatus := alerter.PingerStatus{\n\t\t\t\tOK: pingResult.Status == ping.StatusOK,\n\t\t\t\tError: error,\n\t\t\t\tOutputURL: outputURL(dispatcher.advertisedBaseURL, statusUpdate.Name),\n\t\t\t}\n\n\t\t\tupdate := alerter.PingerUpdate{\n\t\t\t\tName: statusUpdate.Name,\n\t\t\t\tStatus: status,\n\t\t\t\tConsecutive: statusUpdate.Status.Consecutive,\n\t\t\t\tLatestOK: statusUpdate.Status.LatestOK,\n\t\t\t\tLatestNOK: statusUpdate.Status.LatestNOK,\n\t\t\t}\n\n\t\t\tlog.Debugf(\"dispatching %+v\", statusUpdate)\n\t\t\tdispatcher.dispatch(update)\n\t\t}\n\t}\n\n}", "func ping(url string) {\n\tfor {\n\t\ttime.Sleep(10000 * time.Millisecond)\n\t\thttp.Get(url)\n\t}\n}", "func (p *APIPingProbe) Start() error {\n\tif p.Active {\n\t\treturn nil\n\t}\n\n\tt := time.Duration(p.Config.Frequency * float64(time.Second))\n\twriteTicker := time.NewTicker(t)\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-p.StopChannel:\n\t\t\t\treturn\n\t\t\tcase <-writeTicker.C:\n\t\t\t\tgo p.PingAPI()\n\t\t\t}\n\t\t}\n\t}()\n\n\tp.Active = true\n\treturn nil\n}", "func Ping(conn net.Conn) {\n\tfor {\n\t\tconn.Write([]byte(\"ping\"))\n\t\ttime.Sleep(20 * time.Second)\n\t}\n}", "func Ping(conn net.Conn) {\n\tfor {\n\t\tconn.Write([]byte(\"ping\"))\n\t\ttime.Sleep(20 * time.Second)\n\t}\n}", "func AddPingTimeout() {}", "func intervalUpdate() {\n\tfor {\n\t\tif imAlive == false || isPlaying == false {\n\t\t\treturn\n\t\t}\n\t\tvar message *Message\n\t\tif isLeader() {\n\t\t\tmutex.Lock()\n\t\t\tmessage = &Message{IsLeader: true, FailedNodes: failedNodes, Node: *myNode}\n\t\t\tmutex.Unlock()\n\t\t} else {\n\t\t\tmessage = &Message{Node: *myNode}\n\t\t}\n\t\tlogMsg := \"Interval update\"\n\t\tsendPacketsToPeers(logMsg, message)\n\t\ttime.Sleep(intervalUpdateRate)\n\t}\n}", "func (rcs *Service) pingLoop(done <-chan struct{}) {\n\tpingChan := make(chan *model.RemoteCluster, MaxConcurrentSends*2)\n\n\t// create a thread pool to send pings concurrently to remotes.\n\tfor i := 0; i < MaxConcurrentSends; i++ {\n\t\tgo rcs.pingEmitter(pingChan, done)\n\t}\n\n\tgo rcs.pingGenerator(pingChan, done)\n}", "func PingEveryone(self *State) {\n\tfor i := 0; i < len(self.AllPorts); i ++ {\n\t\tif self.AllPorts[i] != self.ListenPort {\n\t\t\tgo ping(self, self.AllPorts[i])\n\t\t}\n\t}\n}", "func (env *Env) ManageSessionTraffic() {\n config := dots_config.GetServerSystemConfig()\n\n for { \n // loop on sessions in map that connecting to server\n time.Sleep(time.Duration(config.SessionInterval) * time.Second)\n for _, session := range libcoap.ConnectingSessions() {\n if session.GetIsAlive() == false {\n if session.GetIsPingTask() == true {\n log.Debugf(\"[Session Mngt Thread]: Waiting for current ping task (id = %+v)\", env.pingMessageTask.message.MessageID)\n break\n }\n\n // Get dot peer common name from current session\n cn, err := session.DtlsGetPeerCommonName()\n if err != nil {\n log.WithError(err).Error(\"[Session Mngt Thread]: DtlsGetPeercCommonName() failed\")\n return\n }\n\n // Get customer from common name\n customer, err := models.GetCustomerByCommonName(cn)\n if err != nil || customer.Id == 0 {\n log.WithError(err).Error(\"[Session Mngt Thread]: Customer not found.\")\n return\n }\n\n // Get session configuration of this session by customer id\n sessionConfig, err := controllers.GetSessionConfig(customer)\n if err != nil {\n log.Errorf(\"[Session Mngt Thread]: Get session configuration failed.\")\n return\n }\n\n // Update session configuration and start to run ping task\n session.SetSessionConfig(sessionConfig.MissingHbAllowed, sessionConfig.MaxRetransmit, sessionConfig.AckTimeout, sessionConfig.AckRandomFactor)\n env.session = session\n\n // new message ping to sent to client\n pingMessage := newPingMessage(env)\n log.Debugf(\"[Session Mngt Thread]: Create new ping message (id = %+v) to check client connection\", pingMessage.MessageID)\n env.Run(NewPingMessageTask(pingMessage, session.GetCurrentMissingHb(), time.Duration(0), time.Duration(0),\n pingResponseHandler, pingTimeoutHandler ))\n } else {\n // Set false for checking session at next cycle \n // Skip ping task message. Dots client has just negotiated recently.\n session.SetIsAlive(false)\n }\n }\n\n }\n}", "func (s *Service) Ping(topicID string) error {\n\tt := time.Now()\n\tpf, err := s.client.Publish(topicID, []byte(fmt.Sprintf(\"pinged at %s\", t)), 2, false)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn pf.Wait(5 * time.Second)\n}", "func ping(times, size, timeout, sendPackageInterMin, sendPackageWait int, ips []string, sip string) (result map[string]*PingStat, send int, err error) {\n\tresult = make(map[string]*PingStat)\n\t//给每个ip生成随机id放入icmp报文,保证同一个ip的id相同\n\tip2id := make(map[string]int)\n\trand.Seed(time.Now().UnixNano())\n\tfor _, ip := range ips {\n\t\tip2id[ip] = rand.Intn(0xffff)\n\t}\n\t// 开始ping指定次数\n\t// startTime := time.Now()\n\tfor send = 0; send < times; send++ {\n\t\tlogs.Debug(\"ping round:%d start\", send)\n\t\tpinger := util.NewPinger(send+1, \"\")\n\t\tfor _, ip := range ips {\n\t\t\terr := pinger.AddIP(ip, ip2id[ip])\n\t\t\tif err != nil {\n\t\t\t\tlogs.Error(\"p.AddIP(ip) for ip %s fails with error %s\\n\", ip, err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tpinger.Size = size\n\t\tpinger.MaxRTT = time.Duration(timeout) * time.Millisecond\n\t\ttimer := time.NewTimer(time.Duration(sendPackageInterMin) * time.Millisecond)\n\t\tnow := time.Now()\n\t\t// 启动本次ping\n\t\tm, _, err := pinger.Run()\n\t\tif err != nil {\n\t\t\tlogs.Error(\"ping run fails:%s\", err)\n\t\t\tcontinue\n\t\t}\n\t\t// 本次ping,与之前ping所有结果打包\n\t\t// logs.Debug(\"ping result:\", m)\n\t\tfor ip, d := range m {\n\t\t\tr := result[ip]\n\t\t\t// 已经有结果,则更新\n\t\t\tif r != nil {\n\t\t\t\tr.Times++\n\t\t\t\tr.Duration += d\n\t\t\t\tif d >= r.MaxRtt {\n\t\t\t\t\tr.MaxRtt = d\n\t\t\t\t}\n\t\t\t\tif d < r.MinRtt {\n\t\t\t\t\tr.MinRtt = d\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// 首次ping\n\t\t\t\tresult[ip] = &PingStat{\n\t\t\t\t\tTimes: 1,\n\t\t\t\t\tDuration: d,\n\t\t\t\t\tMaxRtt: d,\n\t\t\t\t\tMinRtt: d,\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdiff := time.Since(now)\n\t\tselect {\n\t\tcase <-timer.C:\n\t\t\tlogs.Debug(\"ping round:%d finished, %dip ping use time %s\", send, len(ips), diff.String())\n\t\tdefault:\n\t\t\tlogs.Debug(\"finish %d ip ping with %s,less than %d ms,so wait %d ms\",\n\t\t\t\tlen(ips), diff.String(), sendPackageInterMin, sendPackageWait)\n\t\t\ttime.Sleep(time.Duration(sendPackageWait) * time.Millisecond)\n\t\t}\n\t\ttimer.Stop()\n\t}\n\treturn\n}", "func (s *Refresh) StartBackgroundRefresh() {\n\tgo s.FindServerStateAdded()\n}", "func Ping(node *shared.Node) {\n\tfor {\n\t\tblockchain.SwimBatchPuzzleGenerator(node)\n\n\t\ttime.Sleep(pingInterval)\n\t\ttarget := node.MembersSet.GetRandom()\n\t\tif target == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\ttargetPeer := strings.Split(target, \" \")\n\t\tip := targetPeer[0]\n\t\tport := targetPeer[1]\n\t\tconn, err := net.Dial(\"tcp\", ip+\":\"+port)\n\t\tif err != nil {\n\t\t\t// failure detected!\n\t\t\tif strings.HasSuffix(err.Error(), \"connect: connection refused\") {\n\t\t\t\tnode.MembersSet.SetDelete(target)\n\t\t\t\tnode.FailMsgBuffer.Add(target)\n\t\t\t\tfmt.Println(\"FAILURE DETECTED \" + target)\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"Dial Error: \", err)\n\t\t\t}\n\t\t} else {\n\t\t\t// SWIM Implementation would send membership update message here\n\t\t\tswimMsg := \"DEAD \" + strings.Join(node.FailMsgBuffer.GetN(10), \",\") + \"\\n\"\n\t\t\tlogBandwithInfo(\"Send\", len(swimMsg))\n\t\t\tfmt.Fprintf(conn, swimMsg)\n\t\t\tfmt.Print(\"SWIM SENT \" + swimMsg)\n\t\t\ttransactionsMsg := strings.Join(node.TransactionBuffer.GetN(10000), \"\\n\") + \"\\n\"\n\t\t\tlogBandwithInfo(\"Send\", len(transactionsMsg))\n\t\t\tfmt.Fprintf(conn, transactionsMsg)\n\t\t\tfor _, block := range node.BlockBuffer.GetAll() {\n\t\t\t\tblockchain.SendBlock(node, conn, block)\n\t\t\t}\n\n\t\t\tconn.Close()\n\t\t}\n\t}\n}", "func (s *Server) loop() {\n\theartbeatTicker := s.clock.NewTicker(heartbeatInterval)\n\tdefer heartbeatTicker.Stop()\n\n\tresyncTicker := s.clock.NewTicker(resyncInterval)\n\tdefer resyncTicker.Stop()\n\n\tfor {\n\t\tselect {\n\t\t//\n\t\t// Re-sync cluster peers\n\t\t//\n\t\tcase <-resyncTicker.Chan():\n\t\t\terr := s.resyncPeerList()\n\t\t\tif err != nil {\n\t\t\t\ts.WithError(err).Error(\"Unexpected error re-syncing the list of peer nodes.\")\n\t\t\t}\n\n\t\t\terr = s.resyncNethealthPods()\n\t\t\tif err != nil {\n\t\t\t\ts.WithError(err).Error(\"Unexpected error re-syncing the list of peer pods.\")\n\t\t\t}\n\t\tcase <-s.triggerResync:\n\t\t\terr := s.resyncPeerList()\n\t\t\tif err != nil {\n\t\t\t\ts.WithError(err).Error(\"Unexpected error re-syncing the list of peer nodes.\")\n\t\t\t}\n\n\t\t\terr = s.resyncNethealthPods()\n\t\t\tif err != nil {\n\t\t\t\ts.WithError(err).Error(\"Unexpected error re-syncing the list of peer pods.\")\n\t\t\t}\n\n\t\t//\n\t\t// Send a heartbeat to each peer we know about\n\t\t// Check for peers that are timing out / down\n\t\t//\n\t\tcase <-heartbeatTicker.Chan():\n\t\t\ts.checkTimeouts()\n\t\t\tfor _, peer := range s.peers {\n\t\t\t\ts.sendHeartbeat(peer)\n\t\t\t}\n\n\t\t//\n\t\t// Rx heartbeats responses from peers\n\t\t//\n\t\tcase rx := <-s.rxMessage:\n\t\t\terr := s.processAck(rx)\n\t\t\tif err != nil {\n\t\t\t\ts.WithFields(logrus.Fields{\n\t\t\t\t\tlogrus.ErrorKey: err,\n\t\t\t\t\t\"peer_addr\": rx.peerAddr,\n\t\t\t\t\t\"rx_time\": rx.rxTime,\n\t\t\t\t\t\"message\": rx.message,\n\t\t\t\t}).Error(\"Error processing icmp message.\")\n\t\t\t}\n\t\t}\n\t}\n}", "func (n *Notifier) Start() error {\n\tnotificationForChannels := time.NewTicker(time.Second * 60).C\n\tnotificationForTimeTable := time.NewTicker(time.Second * 60).C\n\tfor {\n\t\tselect {\n\t\tcase <-notificationForChannels:\n\t\t\tn.NotifyChannels()\n\t\tcase <-notificationForTimeTable:\n\t\t\tn.NotifyIndividuals()\n\t\t}\n\t}\n}", "func (sc *sparkyClient) pingProcessor() {\n\tvar pingCount int\n\tvar ptMax, ptMin int\n\tvar latencyHist pingHistory\n\n\t// We never want to run the ping test beyond maxPingTestLength seconds\n\ttimeout := time.NewTimer(time.Duration(maxPingTestLength) * time.Second)\n\n\t// Signal pingTest() that we're ready\n\tclose(sc.pingProcessorReady)\n\n\tfor {\n\t\tselect {\n\t\tcase <-timeout.C:\n\t\t\t// If we've been pinging for maxPingTestLength, call it quits\n\t\t\treturn\n\t\tcase pt := <-sc.pingTime:\n\t\t\tpingCount++\n\n\t\t\t// Calculate our ping time in microseconds\n\t\t\tptMicro := pt.Nanoseconds() / 1000\n\n\t\t\t// Add this ping to our ping history\n\t\t\tlatencyHist = append(latencyHist, ptMicro)\n\n\t\t\tptMin, ptMax = latencyHist.minMax()\n\n\t\t\t// Advance the progress bar a bit\n\t\t\tsc.pingProgressTicker <- true\n\n\t\t\t// Update the ping stats widget\n\t\t\tsc.wr.jobs[\"latency\"].(*termui.Sparklines).Lines[0].Data = latencyHist.toMilli()\n\t\t\tsc.wr.jobs[\"latencystats\"].(*termui.Par).Text = fmt.Sprintf(\"Cur/Min/Max\\n%.2f/%.2f/%.2f ms\\nAvg/σ\\n%.2f/%.2f ms\",\n\t\t\t\tfloat64(ptMicro/1000), float64(ptMin/1000), float64(ptMax/1000), latencyHist.mean()/1000, latencyHist.stdDev()/1000)\n\t\t\tsc.wr.Render()\n\t\t}\n\t}\n}", "func (s *Slave) StartPinger() {\n\ts.pingerControl = heartbeat.Pinger(s.IPAddress, handleDisconnect)\n}", "func (p *peer) Ping() {\n\t// this task is recorded in the waitgroup, so clear waitgroup on return\n\tdefer p.ms.Done()\n\t// This must come after Done and before Reporter (executes in reverse order)\n\tdefer p.ms.Delete(p)\n\n\tif p.ms.Verbose() > 1 {\n\t\tlog.Println(\"ping\", p.Url)\n\t}\n\n\tmaxfail := p.Maxfail // default before thread quits trying\n\tmn := \"TCP RTT\" // CloudWatch metric name\n\tns := \"pingmesh\" // Cloudwatch namespace\n\n\tlimit := p.Limit // number of pings before we quit, \"forever\" if zero\n\tif limit == 0 {\n\t\tlimit = math.MaxInt32\n\t}\n\tif maxfail > limit {\n\t\tmaxfail = limit\n\t}\n\n\t////\n\t// Reporter summarizes ping statistics to stdout at the end of the run\n\tdefer func() { // Reporter\n\t\tif p.Pings == 0 {\n\t\t\tfmt.Printf(\"\\nRecorded 0 valid samples, %d of %d failures\\n\", p.Fails, maxfail)\n\t\t\treturn\n\t\t}\n\n\t\tfc := float64(p.Pings)\n\t\telapsed := Hhmmss_d(p.PingTotals.Start)\n\n\t\tfmt.Printf(\"\\nRecorded %d samples in %s, average values:\\n\"+\"%s\"+\n\t\t\t\"%d %-6s\\t%.03f\\t%.03f\\t%.03f\\t%.03f\\t%.03f\\t%.03f\\t\\t%d\\t%s\\t%s\\n\\n\",\n\t\t\tp.Pings, elapsed, pt.PingTimesHeader(),\n\t\t\tp.Pings, elapsed,\n\t\t\tpt.Msec(p.PingTotals.DnsLk)/fc,\n\t\t\tpt.Msec(p.PingTotals.TcpHs)/fc,\n\t\t\tpt.Msec(p.PingTotals.TlsHs)/fc,\n\t\t\tpt.Msec(p.PingTotals.Reply)/fc,\n\t\t\tpt.Msec(p.PingTotals.Close)/fc,\n\t\t\tpt.Msec(p.PingTotals.RespTime())/fc,\n\t\t\tp.PingTotals.Size/int64(p.Pings),\n\t\t\tpt.LocationOrIp(p.PingTotals.Location),\n\t\t\t*p.PingTotals.DestUrl)\n\t}()\n\n\tp.FirstPing = time.Now().UTC().Truncate(time.Second)\n\tfor {\n\t\tif p.ms.DoneChan() == nil {\n\t\t\t// channel is nil, reading from it will block, return\n\t\t\tif p.ms.Verbose() > 1 {\n\t\t\t\tlog.Println(\"peer.Ping: channel is nil, returning\")\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\t////\n\t\t// Sleep first, allows risk-free continue from error cases below\n\t\tvar sleepTime int\n\t\tif p.Pings == 0 {\n\t\t\tif sleepTime < p.Delay {\n\t\t\t\tsleepTime++\n\t\t\t}\n\t\t} else {\n\t\t\tsleepTime = p.Delay\n\t\t}\n\n\t\tselect {\n\t\tcase <-time.After(JitterPct(sleepTime, 1)):\n\t\t\t// we waited for the delay and got nothing ... loop around\n\n\t\tcase newdelay, more := <-p.ms.DoneChan():\n\t\t\tif !more {\n\t\t\t\t// channel is closed, we are done -- goodbye\n\t\t\t\tif p.ms.Verbose() > 1 {\n\t\t\t\t\tlog.Println(\"peer.Ping: channel is closed, returning\")\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// else we got a new delay on this channel (0 is signal to stop)\n\t\t\tp.Delay = newdelay\n\t\t\tif p.Delay <= 0 {\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// we did not (finish) our sleep in this case ...\n\t\t}\n\n\t\t////\n\t\t// Try to fetch the URL\n\t\tptResult := client.FetchURL(p.Url, p.PeerIP)\n\n\t\tswitch {\n\t\t// result nil, something totally failed\n\t\tcase nil == ptResult:\n\t\t\tfunc() {\n\t\t\t\tp.mu.Lock()\n\t\t\t\tdefer p.mu.Unlock()\n\t\t\t\tp.Fails++\n\t\t\t}()\n\t\t\tlog.Println(\"fetch failure\", p.Fails, \"of\", maxfail, \"on\", p.Url)\n\t\t\tif p.Fails >= maxfail {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcontinue\n\n\t\t// HTTP 200 OK and 300 series \"OK\" status codes\n\t\tcase ptResult.RespCode <= 304:\n\t\t\t// Take a write lock on this peer before updating values\n\t\t\t// (make each peer read/write reentrant, also []*peers)\n\t\t\tfunc() {\n\t\t\t\tp.mu.Lock()\n\t\t\t\tdefer p.mu.Unlock()\n\t\t\t\tp.Pings++\n\t\t\t\tnow := time.Now().UTC()\n\t\t\t\tp.LatestPing = now.UTC().Truncate(time.Second)\n\t\t\t\tif p.Pings == 1 {\n\t\t\t\t\t////\n\t\t\t\t\t// first ping -- initialize ptResult\n\t\t\t\t\tp.PingTotals = *ptResult\n\t\t\t\t} else {\n\t\t\t\t\tp.PingTotals.DnsLk += ptResult.DnsLk\n\t\t\t\t\tp.PingTotals.TcpHs += ptResult.TcpHs\n\t\t\t\t\tp.PingTotals.TlsHs += ptResult.TlsHs\n\t\t\t\t\tp.PingTotals.Reply += ptResult.Reply\n\t\t\t\t\tp.PingTotals.Close += ptResult.Close\n\t\t\t\t\tp.PingTotals.Total += ptResult.Total\n\t\t\t\t\tp.PingTotals.Size += ptResult.Size\n\t\t\t\t}\n\n\t\t\t\tif len(p.PeerIP) == 0 && len(ptResult.Remote) > 0 {\n\t\t\t\t\tp.PeerIP = ptResult.Remote\n\t\t\t\t}\n\n\t\t\t\tif p.Location == client.LocUnknown {\n\t\t\t\t\tif *ptResult.Location != client.LocUnknown && len(*ptResult.Location) > 0 {\n\t\t\t\t\t\tp.Location = *ptResult.Location\n\t\t\t\t\t\tp.PingTotals.Location = &p.Location\n\t\t\t\t\t\tif p.ms.Verbose() > 1 {\n\t\t\t\t\t\t\tlog.Println(\"Initialize remote location to\", *ptResult.Location)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// It's not returning a pingmesh Location response, use hostname\n\t\t\t\t\t\tp.Location = p.Url\n\t\t\t\t\t\tp.PingTotals.Location = &p.Location\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}()\n\n\t\t// HTTP 500 series error\n\t\tcase ptResult.RespCode > 304:\n\t\t\tfunc() {\n\t\t\t\tp.mu.Lock()\n\t\t\t\tdefer p.mu.Unlock()\n\t\t\t\tp.Fails++\n\t\t\t}()\n\t\t\tremote := p.Location\n\t\t\tif len(remote) == 0 || remote == client.LocUnknown {\n\t\t\t\tif len(p.PeerIP) > 0 {\n\t\t\t\t\tremote = p.PeerIP\n\t\t\t\t} else {\n\t\t\t\t\tremote = p.Host\n\t\t\t\t}\n\t\t\t}\n\t\t\tif p.ms.Verbose() > 0 {\n\t\t\t\tfmt.Println(p.Pings, ptResult.MsecTsv())\n\t\t\t}\n\t\t\tif p.Fails >= maxfail {\n\t\t\t\tclient.LogSentry(sentry.LevelWarning, \"%s to %s: HTTP error %d hit failure limit %d on %s, Ping quitting\", p.ms.SrvLocation(), remote, ptResult.RespCode, p.Fails, p.Url)\n\t\t\t\treturn\n\t\t\t} else {\n\t\t\t\tlog.Println(p.ms.SrvLocation(), \"to\", remote, \"HTTP\", ptResult.RespCode, \"failure\", p.Fails, \"of\", maxfail, \"on\", p.Url)\n\t\t\t}\n\t\t\tcontinue\n\n\t\t\t////\n\t\t\t// Other HTTP response codes can be coded here (error, redirect)\n\t\t\t////\n\t\t}\n\n\t\t////\n\t\t// Execution should continue here only in NON-ERROR cases; errors\n\t\t// continue the for{} above\n\t\t////\n\n\t\tif p.ms.Verbose() > 0 {\n\t\t\tif p.ms.Verbose() > 1 {\n\t\t\t\tfmt.Println(p.Pings, ptResult.MsecTsv())\n\t\t\t} else {\n\t\t\t\tfmt.Printf(\"%3d %8.03f msec %20s %s\\n\", p.Pings, pt.Msec(ptResult.TcpHs), pt.LocationOrIp(ptResult.Location), ptResult.Remote)\n\t\t\t}\n\t\t}\n\n\t\tif p.ms.CwFlag() {\n\t\t\tmetric := pt.Msec(ptResult.TcpHs)\n\t\t\tmyLocation := p.ms.SrvLocation()\n\t\t\tif p.ms.Verbose() > 2 {\n\t\t\t\tlog.Println(\"publishing TCP RTT\", metric, \"msec to CloudWatch\", ns, \"from\", myLocation)\n\t\t\t}\n\t\t\trespCode := \"0\"\n\t\t\tif ptResult.RespCode >= 0 {\n\t\t\t\t// 000 in cloudwatch indicates it was a zero return code from lower layer\n\t\t\t\t// while single digit 0 indicates an error making the request\n\t\t\t\trespCode = fmt.Sprintf(\"%03d\", ptResult.RespCode)\n\t\t\t}\n\n\t\t\t////\n\t\t\t// Publish my location (IP or REP_LOCATION) and their location\n\t\t\tcw.PublishRespTime(myLocation, p.Location, respCode, metric, mn, ns)\n\t\t\t// NOTE: using network RTT estimate (TcpHs) rather than full page response time\n\t\t\t// TODO: This makes the legends wrong in Cloudwatch. Fix that.\n\t\t}\n\n\t\tif p.Pings >= limit {\n\t\t\t// report stats (see deferred func() above) upon return\n\t\t\treturn\n\t\t}\n\n\t\tif p.Delay <= 0 {\n\t\t\t// we were signaled to stop\n\t\t\treturn\n\t\t}\n\t}\n}", "func (api *FooAPI) Ping(id enode.ID) error {\n\tif api.running {\n\t\tapi.pingC[id] <- struct{}{}\n\t}\n\treturn nil\n}", "func (s *ClientState) Ping(pingMsg MsgBody) error {\n\tlogInfo(\"Received ping message\")\n\trs := s.RegisterSystem(pingMsg.System)\n\tif rs.RedeemToken(pingMsg.Token) {\n\t\treturn s.SendPong(rs)\n\t}\n\treturn nil\n}", "func (s *Service) Start(ctx context.Context) <-chan error {\n\ttick := make(chan error, 1)\n\n\tif s.Interval <= 0 {\n\t\ttick <- errors.New(\"cannot run poll service for non-positive interval\")\n\t\tclose(tick)\n\t\treturn tick\n\t}\n\n\tgo func(c context.Context, t chan<- error, interval time.Duration) {\n\t\t// update once when the service starts.\n\t\tt <- nil\n\n\t\tticker := time.NewTicker(interval)\n\t\tdefer ticker.Stop()\n\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ticker.C:\n\t\t\t\tt <- nil\n\n\t\t\tcase <-ctx.Done():\n\t\t\t\tt <- ctx.Err()\n\t\t\t\tclose(t)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}(ctx, tick, time.Duration(s.Interval))\n\n\treturn tick\n}", "func ping(c chan string) {\n\n\t// on increment de 1 en 1 a chaque tour de boucle\n\tfor i := 1; ; i++ {\n\t\tc <- fmt.Sprintf(\"ping %v\", i)\n\t}\n}", "func StartHeartBeat() {\n\tduration := time.Duration(10) * time.Second // Pause for 10 seconds\n\n\tsendInitHeartBeat()\n\tfor true {\n\t\ttime.Sleep(duration)\n\t\tPeers.Rebalance()\n\t\tpeerMapJson, _ := Peers.PeerMapToJson()\n\t\tjsonStr := data.PrepareHeartBeatData(Peers.GetSelfId(), peerMapJson, SELF_ADDR)\n\t\tjsonString, _ := json.Marshal(jsonStr)\n\n\t\tfor key, _ := range Peers.Copy() {\n\t\t\turl := key + \"/heartbeat/receive\"\n\t\t\t_, err := http.Post(url, \"application/json\", bytes.NewBuffer(jsonString))\n\t\t\tif err != nil {\n\t\t\t\tfmt.Print(\"Error sending init message\")\n\t\t\t}\n\t\t}\n\t}\n}", "func (r *MyMonitor) StartMonitoring(urlinfo st.URLInfo) {\n\n\tgo func() {\n\t\tticker := time.NewTicker(time.Duration(urlinfo.Frequency) * time.Second) // trigers at rate of Frequency\n\t\trequestStatus := make(chan string) // result of http request will come on requestStatus channel\n\t\tdataBase := database.GetDatabase()\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase idStop := <-r.MonitorStp: // if deactivated Monitoring\n\t\t\t\tif idStop == urlinfo.ID { // check if this url need to be Deactivate\n\t\t\t\t\treturn // stop monitering\n\t\t\t\t}\n\t\t\tcase <-ticker.C: // at Frequency time\n\t\t\t\tfmt.Printf(\"Request to %s\\t\", urlinfo.URL)\n\t\t\t\tgo Request(urlinfo.URL, urlinfo.CrawlTimeout, requestStatus)\n\t\t\tcase st := <-requestStatus: // if status for request comes\n\t\t\t\tfmt.Println(\"Status: \", st)\n\t\t\t\t// if not 200 OK increase Failure count and update it to Database\n\t\t\t\t// if Failure count reaches to failure threshold then mark url inactive , stop crawling and update status into database\n\t\t\t\tif st != \"200 OK\" {\n\t\t\t\t\turlinfo.FailureCount++\n\t\t\t\t\tdataBase.UpdateColumnInDatabase(urlinfo.ID, \"failure_count\", urlinfo.FailureCount)\n\t\t\t\t\tif urlinfo.FailureCount == urlinfo.FailureThreshold {\n\t\t\t\t\t\tdataBase.UpdateColumnInDatabase(urlinfo.ID, \"status\", \"inactive\")\n\t\t\t\t\t\tdataBase.UpdateColumnInDatabase(urlinfo.ID, \"crawling\", false)\n\t\t\t\t\t\treturn //Stop Monitering\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n}", "func (im *IpManager) Start() error {\n\tim.mutex.Lock()\n\tdefer im.mutex.Unlock()\n\n\tlog.Debug(\"Starting IP Address Manager: \", im.name)\n\n\t// Make sure ticker is not already running\n\tif im.ticker != nil {\n\t\treturn errors.New(\"Ticker already running\")\n\t}\n\n\t// Start ticker to periodically retrieve platform information\n\tim.ticker = time.NewTicker(DEFAULT_TICKER_INTERVAL_MS * time.Millisecond)\n\tgo func() {\n\t\tfor range im.ticker.C {\n\t\t\t// Refresh IP addresses\n\t\t\tim.Refresh()\n\t\t}\n\t}()\n\n\treturn nil\n}", "func (g *Gossiper) Start(generation int) {\n\tlog.Printf(\"starting gossiper...\\n\")\n\tg.localEndPoint = network.NewEndPoint(config.ControlPort)\n\t// get the seeds from the config and initialize them.\n\tseedHosts := config.Seeds\n\tfor seedHost := range seedHosts {\n\t\tseed := network.NewEndPointH(seedHost, config.ControlPort)\n\t\tif *seed == *g.localEndPoint {\n\t\t\t// already this host\n\t\t\tcontinue\n\t\t}\n\t\tg.seeds[*seed] = true // add seed host\n\t}\n\n\t// initialize the heartbeat state for this localEndPoint\n\tlocalState, ok := g.endPointStateMap[*g.localEndPoint]\n\tif !ok {\n\t\t// localState doesn't exist\n\t\thbState := NewHeartBeatState(generation, 0)\n\t\tlocalState = NewEndPointState(hbState)\n\t\tlocalState.SetAlive(true)\n\t\tlocalState.SetGossiper(true)\n\t\tg.endPointStateMap[*g.localEndPoint] = localState\n\t}\n\tg.startControlServer()\n\tgo g.RunTimerTask()\n}", "func (p *pinger) Ping(addr net.Addr) {\n\tdefer close(p.reportChan)\n\tdefer close(p.errChan)\n\n\tconn, err := icmp.ListenPacket(\"ip4:icmp\", \"\")\n\tif err != nil {\n\t\tp.errChan <- fmt.Errorf(\"cannot connect to addr %s: %v\", addr, err)\n\t\treturn\n\t}\n\tdefer conn.Close()\n\n\tseq := 0\n\tfor {\n\t\tselect {\n\t\tcase <-p.stop:\n\t\t\treturn\n\t\tdefault:\n\t\t\tping, err := p.ping(conn, addr, seq)\n\t\t\tif err != nil {\n\t\t\t\tp.errChan <- err\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tp.reportChan <- ping\n\t\t\tseq++\n\n\t\t\tif p.opts.Count != 0 && int(p.opts.Count) == seq {\n\t\t\t\tp.Stop()\n\t\t\t} else {\n\t\t\t\ttime.Sleep(time.Second)\n\t\t\t}\n\t\t}\n\t}\n}", "func (c *Conn) pinger() {\n\tticker := time.NewTicker(PingInterval)\n\tdefer ticker.Stop()\n\tfor {\n\t\tselect {\n\t\tcase <-c.done:\n\t\t\treturn\n\t\tcase <-ticker.C:\n\t\t\tif _, err := c.write(websocket.PingMessage, []byte{}); err != nil {\n\t\t\t\t_ = c.Close()\n\t\t\t}\n\t\t}\n\t}\n}", "func (m *Mongo) Pinger() {\n\trand.Seed(time.Now().UTC().UnixNano())\n\t// Start pinger on a random schedule\n\ttime.Sleep(time.Duration(rand.Intn(5)) * time.Second)\n\n\tfor {\n\t\tlog.Infof(\"ping hosts:%s\", m.Hosts)\n\t\terr := m.Session.Ping()\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\tm.Connect(m.Hosts)\n\t\t\treturn\n\t\t}\n\t\ttime.Sleep(40 * time.Second)\n\t}\n}", "func (c *checkPointer) Run() {\n\tgo func() {\n\t\tc.logCheckPoint()\n\n\t\tfor range time.Tick(time.Minute * 60) {\n\t\t\tc.logCheckPoint()\n\t\t}\n\t}()\n}", "func (s *ControlPlaneServicer) startBackgroundPusher(duration time.Duration) {\n\tticker := time.NewTicker(duration)\n\tdefer ticker.Stop()\n\n\t// Reporting availability metric based on result of applying dp state (average of the\n\t// stat gives us availability percentage since zero is reported in failure and one\n\t// in success). Failure of applying state catches different set of issues including\n\t// network configuration/bgp session/ipvs and non-working data plane.\n\tfor {\n\t\tselect {\n\t\tcase <-s.ctx.Done():\n\t\t\tdlog.Info(\"closing control plane and event loop...\")\n\t\t\treturn\n\t\tcase config := <-s.modules.ConfigLoader.Updates():\n\t\t\t// config updates.\n\t\t\tif err := s.updateConfig(config.(*pb.ControlPlaneConfig)); err != nil {\n\t\t\t\texclog.Report(err, exclog.Critical, \"\")\n\t\t\t}\n\t\tcase <-ticker.C:\n\t\t\t// getting ref to the state since it might be updated.\n\t\t\ts.mu.Lock()\n\t\t\tstate := s.state\n\t\t\ts.mu.Unlock()\n\n\t\t\tif state != nil {\n\t\t\t\t// periodically re-applying state just in case data plane lost\n\t\t\t\t// it, for example after restarting.\n\t\t\t\tdlog.Info(\"sending state caused by ticker: \", state)\n\t\t\t\tif err := s.applyDataPlaneState(state); err != nil {\n\t\t\t\t\ts.updateAvailabilityGauge(0)\n\t\t\t\t\texclog.Report(err, exclog.Critical, \"\")\n\t\t\t\t} else {\n\t\t\t\t\ts.updateAvailabilityGauge(1)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ts.updateAvailabilityGauge(0)\n\t\t\t}\n\t\tcase <-s.balancersUpdatesChan:\n\t\t\tstate, err := s.GenerateDataPlaneState()\n\t\t\tif err != nil {\n\t\t\t\texclog.Report(err, exclog.Critical, \"\")\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\ts.mu.Lock()\n\t\t\ts.state = state\n\t\t\ts.mu.Unlock()\n\n\t\t\t// finally apply data plane state.\n\t\t\tdlog.Info(\"sending state because of balancers updates: \", state)\n\t\t\tif err := s.applyDataPlaneState(state); err != nil {\n\t\t\t\ts.updateAvailabilityGauge(0)\n\t\t\t\texclog.Report(err, exclog.Critical, \"\")\n\t\t\t} else {\n\t\t\t\ts.updateAvailabilityGauge(1)\n\t\t\t}\n\t\t}\n\t}\n}", "func (hc *HealthChecker) Start() {\n\tlog.Info(\"Starting the health checker...\")\n\tticker := time.NewTicker(time.Second * 10)\n\tdefer ticker.Stop()\n\tfor {\n\t\tselect {\n\t\tcase _ = <-ticker.C:\n\t\t\tfor _, server := range hc.servers {\n\t\t\t\tgo checkHealth(server)\n\t\t\t}\n\t\t}\n\t}\n}", "func pinger(cfg config.ConfYaml) error {\n\ttransport := &http.Transport{\n\t\tDial: (&net.Dialer{\n\t\t\tTimeout: 5 * time.Second,\n\t\t}).Dial,\n\t\tTLSHandshakeTimeout: 5 * time.Second,\n\t}\n\tclient := &http.Client{\n\t\tTimeout: time.Second * 10,\n\t\tTransport: transport,\n\t}\n\tresp, err := client.Get(\"http://localhost:\" + cfg.Core.Port + cfg.API.HealthURI)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"server returned non-200 status code\")\n\t}\n\treturn nil\n}", "func (b *Bootstrapper) Start() {\n\tb.ctx, b.cancel = context.WithCancel(b.ctx)\n\tb.ticker = time.NewTicker(b.config.Period)\n\n\tgo func() {\n\t\tdefer b.ticker.Stop()\n\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-b.ctx.Done():\n\t\t\t\treturn\n\t\t\tcase <-b.ticker.C:\n\t\t\t\tb.checkConnectivity()\n\t\t\t}\n\t\t}\n\t}()\n}", "func (connection *Connection) ping() {\n\tfor {\n\t\ttime.Sleep(1 * time.Second)\n\t\tif len(connection.consumers) > 0 {\n\t\t\t//do some ping, if no response then kill it\n\t\t\tfor _, consumer := range connection.consumers {\n\t\t\t\t_, pingError := consumer.connection.Write([]byte(\"hunga\"))\n\t\t\t\tif pingError != nil {\n\t\t\t\t\t// fmt.Print(\"PING ERROR\")\n\t\t\t\t\tconnection.killConsumer(consumer.id)\n\t\t\t\t} else {\n\t\t\t\t\tconnection.getConsumerMessage(consumer.id)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func ping(cfg configFlags) {\n\t// Dial a remote server and send a stream to that server.\n\tc, err := vsock.Dial(uint32(cfg.contextID), uint32(cfg.port))\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to dial: %v\", err)\n\t}\n\tdefer c.Close()\n\n\tvar p func(i uint) []byte\n\tp = func(i uint) []byte {\n\t\tc := make([]byte, 8)\n\t\tbinary.LittleEndian.PutUint64(c, uint64(i))\n\t\tb := md5.Sum(c)\n\t\treturn b[:]\n\t}\n\n\tif cfg.pattern != \"\" {\n\t\tb, err := hex.DecodeString(cfg.pattern)\n\t\tif err != nil {\n\t\t\tlog.Println(\"pattern must be specified as hex digits\")\n\t\t\tlog.Fatalf(\"failed to decode pattern: %v\", err)\n\t\t}\n\t\tp = func(i uint) []byte { return b }\n\t\tfmt.Printf(\"PATTERN: %s\", cfg.pattern)\n\t}\n\n\tlogf(\"PING %s FROM %s\", c.LocalAddr(), c.RemoteAddr())\n\n\tbuf := make([]byte, 64)\n\ttick := time.NewTicker(cfg.interval)\n\tfor i := uint(0); cfg.count == 0 || i < cfg.count; i++ {\n\t\tn, err := c.Write(p(i))\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"error writing to socket: %v\", err)\n\t\t}\n\t\tn, err = c.Read(buf)\n\t\tfmt.Printf(\"%d bytes from %s: ping_seq=%d\\n\", n, c.RemoteAddr(), i)\n\t\t<-tick.C\n\t}\n}", "func CheckPing(addr string) bool {\n\tgotit := false\n\tfor {\n\t\tconn, err := net.Dial(\"tcp\", addr+\":22\")\n\t\tif err == nil {\n\t\t\t// log.Fatal(err.Error())\n\t\t\tfmt.Print(\"got conncetion\")\n\t\t\tgotit = true\n\t\t\tconn.Close()\n\t\t\tbreak\n\t\t}\n\t\ttime.Sleep(10 * time.Second)\n\t}\n\treturn gotit\n}", "func (sb *StatusBeater) Start(stopChan chan struct{}, publish func(event beat.Event)) {\n\tgo func() {\n\t\tsb.Beat(ServiceStarted, \"Service started\", publish)\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-sb.IntervalFunc():\n\t\t\t\tsb.Beat(ServiceRunning, \"Service is Running\", publish)\n\t\t\tcase <-stopChan:\n\t\t\t\tsb.Beat(ServiceStopped, \"Service is Stopped\", publish)\n\t\t\t\tsb.doneChan <- struct{}{}\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n}", "func (m *MockUDPClient) Ping(num uint) {\n\tfor i := 0; i < int(num); i++ {\n\t\tm.ctrl <- true\n\t}\n}", "func (c *client) startEpochTask() {\n\ttick := time.Tick(time.Duration(c.EpochMillis) * time.Millisecond)\n\tfor {\n\t\tselect {\n\t\tcase <-c.endPointCloseChan:\n\t\t\treturn\n\t\tcase <-tick:\n\t\t\tc.logger.Println(\"Start epoch...\")\n\t\t\tif c.endPointClose {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif c.currentEpoch-c.lastRcvEpoch >= c.EpochLimit {\n\t\t\t\tc.closeNow()\n\t\t\t\tc.closeEndpoint()\n\t\t\t\treturn\n\t\t\t} else {\n\t\t\t\tc.epochHandler()\n\t\t\t}\n\t\t\tc.currentEpoch++\n\t\t}\n\t}\n}", "func (a *PeriodicalAnnouncer) Run() {\n\tdefer close(a.doneC)\n\ta.backoff.Reset()\n\n\ttimer := time.NewTimer(math.MaxInt64)\n\tdefer timer.Stop()\n\n\tresetTimer := func(interval time.Duration) {\n\t\ttimer.Reset(interval)\n\t\tif interval < 0 {\n\t\t\ta.nextAnnounce = time.Now()\n\t\t} else {\n\t\t\ta.nextAnnounce = time.Now().Add(interval)\n\t\t}\n\t}\n\n\tctx, cancel := context.WithCancel(context.Background())\n\n\t// BEP 0003: No completed is sent if the file was complete when started.\n\tselect {\n\tcase <-a.completedC:\n\t\ta.completedC = nil\n\tdefault:\n\t}\n\n\ta.doAnnounce(ctx, tracker.EventStarted, a.numWant)\n\tfor {\n\t\tselect {\n\t\tcase <-timer.C:\n\t\t\tif a.status == Contacting {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\ta.doAnnounce(ctx, tracker.EventNone, a.numWant)\n\t\tcase resp := <-a.responseC:\n\t\t\ta.status = Working\n\t\t\ta.seeders = int(resp.Seeders)\n\t\t\ta.leechers = int(resp.Leechers)\n\t\t\ta.warningMsg = resp.WarningMessage\n\t\t\tif a.warningMsg != \"\" {\n\t\t\t\ta.log.Debugln(\"announce warning:\", a.warningMsg)\n\t\t\t}\n\t\t\ta.interval = resp.Interval\n\t\t\tif resp.MinInterval > 0 {\n\t\t\t\ta.minInterval = resp.MinInterval\n\t\t\t}\n\t\t\ta.HasAnnounced = true\n\t\t\ta.lastError = nil\n\t\t\ta.backoff.Reset()\n\t\t\tinterval := a.getNextInterval()\n\t\t\tresetTimer(interval)\n\t\t\tgo func() {\n\t\t\t\tselect {\n\t\t\t\tcase a.newPeers <- resp.Peers:\n\t\t\t\tcase <-a.closeC:\n\t\t\t\t}\n\t\t\t}()\n\t\tcase err := <-a.errC:\n\t\t\ta.status = NotWorking\n\t\t\t// Give more friendly error to the user\n\t\t\ta.lastError = a.newAnnounceError(err)\n\t\t\tif a.lastError.Unknown {\n\t\t\t\ta.log.Errorln(\"announce error:\", a.lastError.ErrorWithType())\n\t\t\t} else {\n\t\t\t\ta.log.Debugln(\"announce error:\", a.lastError.Err.Error())\n\t\t\t}\n\t\t\tinterval := a.getNextIntervalFromError(a.lastError)\n\t\t\tresetTimer(interval)\n\t\tcase <-a.needMorePeersC:\n\t\t\tif a.status == Contacting || a.status == NotWorking {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tinterval := time.Until(a.lastAnnounce.Add(a.getNextInterval()))\n\t\t\tresetTimer(interval)\n\t\tcase <-a.completedC:\n\t\t\tif a.status == Contacting {\n\t\t\t\tcancel()\n\t\t\t\tctx, cancel = context.WithCancel(context.Background())\n\t\t\t}\n\t\t\ta.doAnnounce(ctx, tracker.EventCompleted, 0)\n\t\t\ta.completedC = nil // do not send more than one \"completed\" event\n\t\tcase req := <-a.statsCommandC:\n\t\t\treq.Response <- a.stats()\n\t\tcase <-a.closeC:\n\t\t\tcancel()\n\t\t\treturn\n\t\t}\n\t}\n}", "func (db *DB) Ping() <-chan SQLResult {\n\tresult := make(chan SQLResult, 10)\n\tgo func() {\n\t\tdefer close(result)\n\n\t\tticker := time.NewTicker(db.conf.GetFrequency())\n\t\tfor range ticker.C {\n\t\t\tgo func() {\n\t\t\t\tresult <- executeQuery(db.db, db.conf.GetQuery())\n\t\t\t}()\n\t\t}\n\t}()\n\treturn result\n}", "func (m *manager) StartNeighborRefresh(nh datapath.NodeNeighbors) {\n\tctx, cancel := context.WithCancel(context.Background())\n\tcontroller.NewManager().UpdateController(\n\t\t\"neighbor-table-refresh\",\n\t\tcontroller.ControllerParams{\n\t\t\tGroup: neighborTableRefreshControllerGroup,\n\t\t\tDoFunc: func(controllerCtx context.Context) error {\n\t\t\t\t// Cancel previous goroutines from previous controller run\n\t\t\t\tcancel()\n\t\t\t\tctx, cancel = context.WithCancel(controllerCtx)\n\t\t\t\tm.mutex.RLock()\n\t\t\t\tdefer m.mutex.RUnlock()\n\t\t\t\tfor _, entry := range m.nodes {\n\t\t\t\t\tentry.mutex.Lock()\n\t\t\t\t\tentryNode := entry.node\n\t\t\t\t\tentry.mutex.Unlock()\n\t\t\t\t\tif entryNode.IsLocal() {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tgo func(c context.Context, e nodeTypes.Node) {\n\t\t\t\t\t\t// To avoid flooding network with arping requests\n\t\t\t\t\t\t// at the same time, spread them over the\n\t\t\t\t\t\t// [0; ARPPingRefreshPeriod/2) period.\n\t\t\t\t\t\tn := randGen.Int63n(int64(option.Config.ARPPingRefreshPeriod / 2))\n\t\t\t\t\t\ttime.Sleep(time.Duration(n))\n\t\t\t\t\t\tnh.NodeNeighborRefresh(c, e)\n\t\t\t\t\t}(ctx, entryNode)\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t},\n\t\t\tRunInterval: option.Config.ARPPingRefreshPeriod,\n\t\t},\n\t)\n}", "func (iw *InstanceWorker) APILocalFeedMonitoring() {\n\tfmt.Printf(\"starting local feed API monitoring for %s\\n\", iw.Instance.Domain)\n\tvar timeFrame time.Duration\n\tu := url.URL{\n\t\tScheme: \"https\",\n\t\tHost: iw.Instance.Domain,\n\t\tPath: \"/api/v1/timelines/public\",\n\t\tRawQuery: \"local=true&limit=50\",\n\t}\n\tfor {\n\t\tresp, err := http.Get(u.String())\n\t\tif err == nil {\n\t\t\tbody, err := ioutil.ReadAll(resp.Body)\n\t\t\tresp.Body.Close()\n\t\t\tif err == nil {\n\t\t\t\tvar statuses []mastodon.Status\n\t\t\t\tif err = json.Unmarshal(body, &statuses); err == nil {\n\t\t\t\t\tif len(statuses) > 10 { // don't lose time with sleeping instances…\n\t\t\t\t\t\toldest := time.Now()\n\t\t\t\t\t\tmost_recent := time.Now()\n\t\t\t\t\t\tfor _, status := range statuses {\n\t\t\t\t\t\t\tiw.SaveIfUnknown(status.Account)\n\t\t\t\t\t\t\tif status.CreatedAt.After(most_recent) {\n\t\t\t\t\t\t\t\tmost_recent = status.CreatedAt\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif status.CreatedAt.Before(oldest) {\n\t\t\t\t\t\t\t\toldest = status.CreatedAt\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttimeFrame = most_recent.Sub(oldest)\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttimeFrame = 17 * time.Hour\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttimeFrame = time.Duration(float64(timeFrame) * 0.75)\n\t\tif timeFrame > (12 * time.Hour) {\n\t\t\ttimeFrame = 12 * time.Hour\n\t\t}\n\t\ttime.Sleep(timeFrame)\n\t}\n\t/*\n\t\t- fetch json from instance's URL\n\t\t- partially unmarshal json to retrieve toots' id and accounts\n\t\t- lookup worker's toots map\n\t\t- if toot not found, add it to worker's map and launch 'SaveIfUnknown' func\n\t\t- cleanup vars (json, etc.)\n\t*/\n}", "func (p *peerAddr) ping(curTime time.Time) {\n\n\t// Advance forward and record the current time.\n\tp.lastPing = p.lastPing.Next()\n\tp.lastPing.Value = curTime\n}", "func (e EgressV1) Start() {\n\tconn := NewConnectionManager(\n\t\te.tcAddrs,\n\t\te.authToken,\n\t\te.subscriptionID,\n\t\te.receiveDelay,\n\t\te.idStore,\n\t\te.batcher,\n\t)\n\tdefer conn.Close()\n\n\tgo e.syncRequest(e.firehoseCount, conn.Firehose)\n\tgo e.syncRequest(e.streamCount, conn.Stream)\n\tgo e.asyncRequest(e.asyncRequestDelay, e.recentLogCount, conn.RecentLogs)\n\tgo e.asyncRequest(e.asyncRequestDelay, e.containerMetricCount, conn.ContainerMetrics)\n}", "func (c *Coordinator) Run(stopCh <-chan struct{}) error {\n\t// Start HTTP server\n\tgo server.Serve(c.Config.Server.BindAddress, c.Config.Server.Port)\n\thandler.UpdateHealth(false)\n\tfor {\n\t\tc.Logger.Infof(\"In for loop\")\n\t\tselect {\n\t\tcase <-stopCh:\n\t\t\tc.Logger.Infof(\"Received stop signal.\\nTerminating...\\nGood bye!\")\n\t\t\treturn nil\n\t\tcase <-time.After(10 * time.Second):\n\t\t\tvalid, err := dns.ValidateDNSWithCname(c.Config.LookupEndpoint, c.Config.ExpectedCname)\n\t\t\tif err != nil {\n\t\t\t\tc.Logger.Errorf(\"failed to validate the DNS resolution: %v\", err)\n\t\t\t\tvalid = false\n\t\t\t}\n\n\t\t\tif valid {\n\t\t\t\tc.Logger.Infof(\"Lookup DNS %s resolved to expected value. Nothing to be done.\", c.Config.LookupEndpoint)\n\t\t\t\thandler.UpdateHealth(true)\n\t\t\t} else {\n\t\t\t\tc.Logger.Infof(\"Lookup DNS %s didn't resolved to expected value %s.\", c.Config.LookupEndpoint, c.Config.ExpectedCname)\n\t\t\t\thandler.UpdateHealth(false)\n\t\t\t}\n\t\t}\n\t}\n}", "func (h *Heartbeat) run(ctx context.Context) {\n\n\tupdateTicker := time.NewTicker(time.Second * time.Duration(h.cfg.updateInterval))\n\tdefer updateTicker.Stop()\n\n\treportTicker := time.NewTicker(time.Second * time.Duration(h.cfg.reportInterval))\n\tdefer reportTicker.Stop()\n\n\tfor {\n\t\tselect {\n\t\tcase <-updateTicker.C:\n\t\t\terr := h.updateTS()\n\t\t\tif err != nil {\n\t\t\t\th.logger.Error(\"update heartbeat ts\", zap.Error(err))\n\t\t\t}\n\n\t\tcase <-reportTicker.C:\n\t\t\terr := h.calculateLag(ctx)\n\t\t\tif err != nil {\n\t\t\t\th.logger.Error(\"calculate replication lag\", zap.Error(err))\n\t\t\t}\n\n\t\tcase <-ctx.Done():\n\t\t\treturn\n\t\t}\n\t}\n}", "func OpenHeartbeat(conn *net.UDPConn, NodePtr *nd.Node) {\n\tfor {\n\t\ttempList, portLog := listenHeartbeat(conn, NodePtr)\n\n\t\t// update InputList to be used for IncrementLocalTime()\n\t\t(*(*NodePtr).InputListPtr) = append((*(*NodePtr).InputListPtr), tempList)\n\t\tif len(portLog) > 0 {\n\t\t\t(*NodePtr).Logger.Println(portLog)\n\t\t}\n\t}\n}", "func (h *couchbaseHeartBeater) StartCheckingHeartbeats(staleThresholdMs int, handler HeartbeatsStoppedHandler) error {\n\n\tif err := h.addHeartbeatCheckView(); err != nil {\n\t\treturn err\n\t}\n\n\tticker := time.NewTicker(time.Duration(staleThresholdMs) * time.Millisecond)\n\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase _ = <-h.heartbeatCheckCloser:\n\t\t\t\tticker.Stop()\n\t\t\t\treturn\n\t\t\tcase <-ticker.C:\n\t\t\t\tif err := h.checkStaleHeartbeats(staleThresholdMs, handler); err != nil {\n\t\t\t\t\tlog.Printf(\"Error checking for stale heartbeats: %v\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\treturn nil\n\n}", "func (ch *PingCheck) Run() (*ResultSet, error) {\n\tlog.Debugf(\"Running PING Check: %v\", ch.GetID())\n\n\ttargetIP, err := ch.GetTargetIP()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar ipVersion string\n\tswitch ch.TargetResolver {\n\tcase protocol.ResolverIPV6:\n\t\tipVersion = \"v6\"\n\tcase protocol.ResolverIPV4:\n\t\tipVersion = \"v4\"\n\t}\n\n\tpinger, err := PingerFactory(ch.GetID(), targetIP, ipVersion)\n\tif err != nil {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"prefix\": ch.GetLogPrefix(),\n\t\t\t\"targetIP\": targetIP,\n\t\t}).Error(\"Failed to create pinger\")\n\t\treturn nil, err\n\t}\n\tdefer pinger.Close()\n\n\ttimeoutDuration := time.Duration(ch.Timeout) * time.Second\n\toverallTimeout := time.After(timeoutDuration)\n\n\tcount := int(ch.Details.Count)\n\tif count <= 0 {\n\t\tcount = defaultPingCount\n\t}\n\tinterPingDelay := utils.MinOfDurations(1*time.Second, timeoutDuration/time.Duration(count))\n\tperPingDuration := timeoutDuration / time.Duration(count)\n\n\tlog.WithFields(log.Fields{\n\t\t\"prefix\": ch.GetLogPrefix(),\n\t\t\"targetIP\": targetIP,\n\t\t\"ipVersion\": ipVersion,\n\t\t\"interPingDelay\": interPingDelay,\n\t\t\"perPingDuration\": perPingDuration,\n\t}).Info(\"Running check\")\n\n\tvar pingErr error\n\n\t// It's very unlikely, but ping responses could technically arrive out of order. This\n\t// slice will be a place to capture the responses in whatever order we get them.\n\tresponses := make([]*PingResponse, count)\n\npacketLoop:\n\tfor i := 0; i < count; i++ {\n\t\tseq := i + 1\n\n\t\tselect {\n\t\tcase <-overallTimeout:\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"prefix\": ch.GetLogPrefix(),\n\t\t\t\t\"targetIP\": targetIP,\n\t\t\t}).Debug(\"Reached overall timeout\")\n\n\t\t\tbreak packetLoop\n\n\t\tdefault:\n\t\t\tresp := pinger.Ping(seq, perPingDuration)\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"prefix\": ch.GetLogPrefix(),\n\t\t\t\t\"resp\": resp,\n\t\t\t\t\"checkId\": ch.Id,\n\t\t\t}).Debug(\"Got ping response\")\n\n\t\t\tif resp.Err != nil {\n\t\t\t\tif !resp.Timeout {\n\t\t\t\t\t// Latch non-timeout errors for consideration and inclusion in the final check result\n\t\t\t\t\tpingErr = resp.Err\n\t\t\t\t}\n\t\t\t\tcontinue packetLoop\n\t\t\t}\n\n\t\t\tif resp.Seq <= 0 || resp.Seq > len(responses) {\n\t\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\t\"prefix\": ch.GetLogPrefix(),\n\t\t\t\t\t\"seq\": resp.Seq,\n\t\t\t\t\t\"targetIP\": targetIP,\n\t\t\t\t}).Warn(\"Invalid response sequence\")\n\t\t\t\tcontinue packetLoop\n\t\t\t}\n\n\t\t\t// Check if the response slot already is occupied\n\n\t\t\tif responses[resp.Seq-1] != nil {\n\t\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\t\"prefix\": ch.GetLogPrefix(),\n\t\t\t\t\t\"seq\": resp.Seq,\n\t\t\t\t\t\"targetIP\": targetIP,\n\t\t\t\t}).Warn(\"Duplicate response sequence\")\n\t\t\t\tcontinue packetLoop\n\t\t\t}\n\n\t\t\t// ...but if not, save it for post-processing outside the loop\n\n\t\t\tresponses[resp.Seq-1] = &resp\n\n\t\t\ttime.Sleep(interPingDelay)\n\t\t}\n\n\t}\n\n\tsent := count\n\n\tinitialDuration := true\n\tvar minRTT time.Duration\n\tvar maxRTT time.Duration\n\tvar avgRTT time.Duration\n\tvar totalRTT time.Duration\n\n\tvar recv int\n\tfor i := 0; i < count; i++ {\n\t\tif responses[i] != nil {\n\t\t\trecv++\n\n\t\t\trtt := responses[i].Rtt\n\t\t\ttotalRTT += rtt\n\n\t\t\tif initialDuration {\n\t\t\t\tminRTT = rtt\n\t\t\t\tmaxRTT = rtt\n\t\t\t\tminRTT = rtt\n\t\t\t\tinitialDuration = false\n\t\t\t} else {\n\t\t\t\tif rtt > maxRTT {\n\t\t\t\t\tmaxRTT = rtt\n\t\t\t\t}\n\t\t\t\tif rtt < minRTT {\n\t\t\t\t\tminRTT = rtt\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif recv > 0 {\n\t\tavgRTT = totalRTT / time.Duration(recv)\n\t}\n\n\tlog.WithFields(log.Fields{\n\t\t\"prefix\": ch.GetLogPrefix(),\n\t\t\"checkId\": ch.Id,\n\t\t\"targetIP\": targetIP,\n\t\t\"sent\": sent,\n\t\t\"recv\": recv,\n\t\t\"minRTT\": minRTT,\n\t\t\"maxRTT\": maxRTT,\n\t\t\"avgRTT\": avgRTT,\n\t}).Debug(\"Computed overall ping results\")\n\n\tcr := NewResult(\n\t\tmetric.NewMetric(\"count\", \"\", metric.MetricNumber, sent, \"\"),\n\t\tmetric.NewPercentMetricFromInt(\"available\", \"\", recv, sent),\n\t\tmetric.NewMetric(\"average\", \"\", metric.MetricFloat, utils.ScaleFractionalDuration(avgRTT, time.Second), metric.UnitSeconds),\n\t\tmetric.NewMetric(\"maximum\", \"\", metric.MetricFloat, utils.ScaleFractionalDuration(maxRTT, time.Second), metric.UnitSeconds),\n\t\tmetric.NewMetric(\"minimum\", \"\", metric.MetricFloat, utils.ScaleFractionalDuration(minRTT, time.Second), metric.UnitSeconds),\n\t)\n\tcrs := NewResultSet(ch, cr)\n\n\tif pingErr == nil && recv > 0 {\n\t\tcrs.SetStatusSuccess()\n\t\tcrs.SetStateAvailable()\n\t} else if pingErr == nil && recv == 0 {\n\t\tcrs.SetStateUnavailable()\n\t\tcrs.SetStatus(\"No responses received\")\n\t} else {\n\t\tcrs.SetStateUnavailable()\n\t\tcrs.SetStatusFromError(pingErr)\n\t}\n\n\treturn crs, nil\n}", "func (rcs *Service) pingEmitter(pingChan <-chan *model.RemoteCluster, done <-chan struct{}) {\n\tfor {\n\t\tselect {\n\t\tcase rc := <-pingChan:\n\t\t\tif rc == nil {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tonline := rc.IsOnline()\n\n\t\t\tif err := rcs.pingRemote(rc); err != nil {\n\t\t\t\trcs.server.Log().Log(mlog.LvlRemoteClusterServiceWarn, \"Remote cluster ping failed\",\n\t\t\t\t\tmlog.String(\"remote\", rc.DisplayName),\n\t\t\t\t\tmlog.String(\"remoteId\", rc.RemoteId),\n\t\t\t\t\tmlog.Err(err),\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tif online != rc.IsOnline() {\n\t\t\t\tif metrics := rcs.server.GetMetrics(); metrics != nil {\n\t\t\t\t\tmetrics.IncrementRemoteClusterConnStateChangeCounter(rc.RemoteId, rc.IsOnline())\n\t\t\t\t}\n\t\t\t\trcs.fireConnectionStateChgEvent(rc)\n\t\t\t}\n\t\tcase <-done:\n\t\t\treturn\n\t\t}\n\t}\n}", "func Begin() {\n\t// Add this host.\n\tlogfInfo(\"Using listen IP: %s\", listenIP)\n\n\t// Use IPv6 address length if the listen IP is not an IPv4 address\n\tif GetListenIP().To4() == nil {\n\t\tipLen = net.IPv6len\n\t}\n\n\tme := Node{\n\t\tip: GetListenIP(),\n\t\tport: uint16(GetListenPort()),\n\t\ttimestamp: GetNowInMillis(),\n\t\tpingMillis: PingNoData,\n\t}\n\n\tthisHostAddress = me.Address()\n\tthisHost = &me\n\n\tlogInfo(\"My host address:\", thisHostAddress)\n\n\t// Add this node's status. Don't update any other node's statuses: they'll\n\t// report those back to us.\n\tupdateNodeStatus(thisHost, StatusAlive, 0, thisHost)\n\tAddNode(thisHost)\n\n\tgo listenUDP(GetListenPort())\n\n\t// Add initial hosts as specified by the SMUDGE_INITIAL_HOSTS property\n\tfor _, address := range GetInitialHosts() {\n\t\tn, err := CreateNodeByAddress(address)\n\t\tif err != nil {\n\t\t\tlogfError(\"Could not create node %s: %v\", address, err)\n\t\t} else {\n\t\t\tAddNode(n)\n\t\t}\n\t}\n\n\tif GetMulticastEnabled() {\n\t\tgo listenUDPMulticast(GetMulticastPort())\n\t\tgo multicastAnnounce(GetMulticastAddress())\n\t}\n\n\tgo startTimeoutCheckLoop()\n\n\t// Loop over a randomized list of all known nodes (except for this host\n\t// node), pinging one at a time. If the knownNodesModifiedFlag is set to\n\t// true by AddNode() or RemoveNode(), the we get a fresh list and start\n\t// again.\n\n\tfor {\n\t\tvar randomAllNodes = knownNodes.getRandomNodes(0, thisHost)\n\t\tvar pingCounter int\n\n\t\tfor _, node := range randomAllNodes {\n\t\t\t// Exponential backoff of dead nodes, until such time as they are removed.\n\t\t\tif node.status == StatusDead {\n\t\t\t\tvar dnc *deadNodeCounter\n\t\t\t\tvar ok bool\n\n\t\t\t\tdeadNodeRetries.Lock()\n\t\t\t\tif dnc, ok = deadNodeRetries.m[node.Address()]; !ok {\n\t\t\t\t\tdnc = &deadNodeCounter{retry: 1, retryCountdown: 2}\n\t\t\t\t\tdeadNodeRetries.m[node.Address()] = dnc\n\t\t\t\t}\n\t\t\t\tdeadNodeRetries.Unlock()\n\n\t\t\t\tdnc.retryCountdown--\n\n\t\t\t\tif dnc.retryCountdown <= 0 {\n\t\t\t\t\tdnc.retry++\n\t\t\t\t\tdnc.retryCountdown = int(math.Pow(2.0, float64(dnc.retry)))\n\n\t\t\t\t\tif dnc.retry > maxDeadNodeRetries {\n\t\t\t\t\t\tlogDebug(\"Forgetting dead node\", node.Address())\n\n\t\t\t\t\t\tdeadNodeRetries.Lock()\n\t\t\t\t\t\tdelete(deadNodeRetries.m, node.Address())\n\t\t\t\t\t\tdeadNodeRetries.Unlock()\n\n\t\t\t\t\t\tRemoveNode(node)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcurrentHeartbeat++\n\n\t\t\tlogfTrace(\"%d - hosts=%d (announce=%d forward=%d)\",\n\t\t\t\tcurrentHeartbeat,\n\t\t\t\tlen(randomAllNodes),\n\t\t\t\temitCount(),\n\t\t\t\tpingRequestCount())\n\n\t\t\tPingNode(node)\n\t\t\tpingCounter++\n\n\t\t\ttime.Sleep(time.Millisecond * time.Duration(GetHeartbeatMillis()))\n\n\t\t\tif knownNodesModifiedFlag {\n\t\t\t\tknownNodesModifiedFlag = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif pingCounter == 0 {\n\t\t\tlogDebug(\"No nodes to ping. So lonely. :(\")\n\t\t\ttime.Sleep(time.Millisecond * time.Duration(GetHeartbeatMillis()))\n\t\t}\n\t}\n}", "func hostCheckIn() {\n \n fmt.Println(\"Host Check in!\")\n currentTime := int32(time.Now().Unix())\n for index, _ := range hosts { \n go func(i int) {\n fmt.Println(\"Submitting Metrics for \"+hosts[i].name)\n metrics := hostMetrics(&hosts[i],currentTime)\n var jsonStr = []byte(metrics)\n req, err := http.NewRequest(\"POST\", metricApiUrl, bytes.NewBuffer(jsonStr))\n req.Header.Set(\"Content-Type\", \"application/json\")\n\n client := &http.Client{}\n resp, err := client.Do(req)\n if err != nil {\n return\n }\n defer resp.Body.Close()\n\n fmt.Println(\"response Status:\", resp.Status)\n fmt.Println(\"response Headers:\", resp.Header)\n body, _ := ioutil.ReadAll(resp.Body)\n fmt.Println(\"response Body:\", string(body))\n \n }(index)\n if(math.Mod(float64(index), 100) == 0) {\n time.Sleep(100*time.Millisecond)\n }\n }\n\n // Report in every 30 seconds\n time.Sleep(CheckInInterval * time.Second) \n hostCheckIn() \n}", "func (iw *InstanceWorker) WSLocalFeedMonitoring() {\n\tfmt.Printf(\"starting local feed WS monitoring for %s\\n\", iw.Instance.Domain)\n\tc := mastodon.NewClient(&mastodon.Config{\n\t\tServer: \"https://\" + iw.Instance.Domain,\n\t\tClientID: iw.Instance.APIid,\n\t\tClientSecret: iw.Instance.APIsecret,\n\t})\n\t// Loop to reconnect if connection closed\n\tfor {\n\t\tvar err error\n\tauthLoop:\n\t\tfor i := 0; i < 10; i++ {\n\t\t\terr = c.Authenticate(iw.Context, iw.Instance.Username, iw.Instance.Password)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"[MonitorInstanceFeed] : auth against instance %s failed with error : %s\\n\", iw.Instance.Domain, err)\n\t\t\t\ttime.Sleep(10 * time.Minute)\n\t\t\t} else {\n\t\t\t\tbreak authLoop\n\t\t\t}\n\t\t}\n\t\tif err != nil {\n\t\t\t//TODO: fallback to fetch timeline monitoring\n\t\t\tiw.Instance.IsAuthorized = false\n\t\t\tiw.Instance.APIid = \"\"\n\t\t\tiw.Instance.APIsecret = \"\"\n\t\t\tiw.Backend.SaveInstance(iw.Instance)\n\t\t\treturn\n\t\t}\n\t\twsClient := c.NewWSClient()\n\t\tpublicStream, _ := wsClient.StreamingWSPublic(iw.Context, true)\n\n\t\tfor evt := range publicStream {\n\t\t\tvar acc mastodon.Account\n\t\t\tswitch e := evt.(type) {\n\t\t\tcase *mastodon.NotificationEvent:\n\t\t\t\tacc = e.Notification.Account\n\t\t\tcase *mastodon.UpdateEvent:\n\t\t\t\tacc = e.Status.Account\n\t\t\tdefault:\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tiw.SaveIfUnknown(acc)\n\t\t\t// need to subhub to instance's local feed if it is a new one\n\t\t}\n\t}\n}", "func pingServer() error {\n\tfor i := 0; i < 2; i++ {\n\t\t// Ping the server by sending a GET request to `/health`.\n\t\tresp, err := http.Get(\"http://127.0.0.1:8080\" + \"/api/health\")\n\t\tif err == nil && resp.StatusCode == 200 {\n\t\t\treturn nil\n\t\t}\n\n\t\t// Sleep for a second to continue the next ping.\n\t\tlog.Print(\"Waiting for the router, retry in 1 second.\")\n\t\ttime.Sleep(time.Second)\n\t}\n\treturn errors.New(\"Cannot connect to the router.\")\n}", "func ConnPingInterval(interval time.Duration) ConnOption {\n\treturn func(c *Conn) error {\n\t\tc.pingInterval = interval\n\t\treturn nil\n\t}\n}", "func (finux *Finux) Ping() (err error) {\n\terr = finux.do(\"ping\", http.MethodGet, nil, nil)\n\treturn\n}", "func Heartbeat(config *config.Config, cache *cache.Cache) {\n\tticker := time.NewTicker(time.Second * time.Duration(config.HeartbeatInterval))\n\tfor range ticker.C {\n\t\tsendHeartbeat(cache)\n\t}\n}", "func ping(s *discordgo.Session, m *discordgo.MessageCreate, message []string) {\n\tarrivalTime, err := m.Timestamp.Parse()\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\treturn\n\t}\n\tif message[0] == \"ping\" {\n\t\ts.ChannelMessageSend(m.ChannelID, fmt.Sprintf(\"Pong! %dms\",\n\t\t\ttime.Since(arrivalTime).Nanoseconds()/1000000))\n\t} else {\n\t\ts.ChannelMessageSend(m.ChannelID, fmt.Sprintf(\"Ping! %dms\",\n\t\t\ttime.Since(arrivalTime).Nanoseconds()/1000000))\n\t}\n}", "func initStatsdTicker(ctx context.Context, config *types.Statsd) *time.Ticker {\n\taddress := config.Address\n\tif len(address) == 0 {\n\t\taddress = \"localhost:8125\"\n\t}\n\n\treport := time.NewTicker(time.Duration(config.PushInterval))\n\n\tsafe.Go(func() {\n\t\tstatsdClient.SendLoop(ctx, report.C, \"udp\", address)\n\t})\n\n\treturn report\n}", "func Start() {\n\tres, err := storage.P2PToConnect()\n\tif err == nil {\n\t\tfor _, p := range res {\n\t\t\tn := node{addr: p, lastSeen: time.Now().Unix()}\n\t\t\tpeerAll.Store(fmt.Sprintf(\"%s:%d\", n.addr.IP, n.addr.Port), n)\n\t\t}\n\t}\n\n\tfor {\n\t\tpeerAll.Range(func(key, value interface{}) bool {\n\t\t\ttime.Sleep(time.Second)\n\t\t\tn, ok := value.(node)\n\t\t\tif ok {\n\t\t\t\tif n.lastSeen < time.Now().Unix()-86400 {\n\t\t\t\t\tpeerAll.Delete(fmt.Sprintf(\"%s:%d\", n.addr.IP, n.addr.Port))\n\t\t\t\t} else {\n\t\t\t\t\tgo work(n.addr)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\t}\n}", "func (c *Client) Ping(ping string) {\n\tvar (\n\t\targ = ReqKeepAlive{}\n\t\treply = RespKeepAlive{}\n\t\terr error\n\t)\n\n\tfor {\n\t\tselect {\n\t\tcase <-c.quit:\n\t\t\tgoto closed\n\t\tdefault:\n\t\t}\n\n\t\tif c.Client != nil && c.err == nil {\n\t\t\tif err = c.Call(ping, &arg, &reply); err != nil {\n\t\t\t\tc.err = err\n\t\t\t\tif err != rpc.ErrShutdown {\n\t\t\t\t\tc.Client.Close()\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif err = c.dial(); err == nil {\n\t\t\t\tc.err = nil\n\t\t\t}\n\t\t}\n\t\ttime.Sleep(pingDuration)\n\t}\n\nclosed:\n\tif c.Client != nil {\n\t\tc.Client.Close()\n\t}\n}", "func (ls *LogShipper) Ping() {\n\t// set up new auth token\n\ttoken, _ := ls.knapsack.TokenStore().Get(storage.ObservabilityIngestAuthTokenKey)\n\tls.sender.authtoken = string(token)\n\n\tparsedUrl, err := url.Parse(ls.knapsack.LogIngestServerURL())\n\tif err != nil {\n\t\t// If we have a bad endpoint, just disable for now.\n\t\t// It will get renabled when control server sends a\n\t\t// valid endpoint.\n\t\tls.sender.endpoint = \"\"\n\t\tlevel.Debug(ls.baseLogger).Log(\n\t\t\t\"msg\", \"error parsing log ingest server url, shipping disabled\",\n\t\t\t\"err\", err,\n\t\t\t\"log_ingest_url\", ls.knapsack.LogIngestServerURL(),\n\t\t)\n\t} else if parsedUrl != nil {\n\t\tls.sender.endpoint = parsedUrl.String()\n\t}\n\n\tls.isShippingEnabled = ls.sender.endpoint != \"\"\n\tls.addDeviceIdentifyingAttributesToLogger()\n\n\tif !ls.isShippingEnabled {\n\t\tls.sendBuffer.DeleteAllData()\n\t}\n}", "func (c *MysqlClient) Ping() {\n\tselect {\n\tcase <-time.After(time.Millisecond * time.Duration(config.DELAY_MILLISECONDS)):\n\t\terr := c.DB.Ping()\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"MysqlClient Ping Error: err=%s\", err)\n\t\t\tc.Open()\n\t\t}\n\t}\n}", "func (h *ProxyHealth) run() {\n\tcheckHealth := func() {\n\t\th.mu.Lock()\n\t\tdefer h.mu.Unlock()\n\t\tisAvailable := h.check(h.origin)\n\t\th.isAvailable = isAvailable\n\t}\n\n\tgo func() {\n\t\tt := time.NewTicker(h.period)\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-t.C:\n\t\t\t\tcheckHealth()\n\t\t\tcase <-h.cancel:\n\t\t\t\tt.Stop()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n}", "func pingServer() error {\n\tfor i := 0; i < viper.GetInt(\"max_ping_count\"); i++ {\n\t\t// Ping the server by sending a GET request to `/health`.\n\t\tresp, err := http.Get(viper.GetString(\"url\") + \"/sd/health\")\n\t\tif err == nil && resp.StatusCode == 200 {\n\t\t\treturn nil\n\t\t}\n\n\t\t// Sleep for a second to continue the next ping.\n\t\tlog.Info(\"Waiting for the router, retry in 1 second.\")\n\t\ttime.Sleep(time.Second)\n\t}\n\treturn errors.New(\"Cannot connect to the router.\")\n}", "func pingServer() error {\n\tfor i := 0; i < viper.GetInt(\"max_ping_count\"); i++ {\n\t\t// Ping the server by sending a GET request to `/health`.\n\t\tresp, err := http.Get(viper.GetString(\"url\") + \"/sd/health\")\n\t\tif err == nil && resp.StatusCode == 200 {\n\t\t\treturn nil\n\t\t}\n\n\t\t// Sleep for a second to continue the next ping.\n\t\tlog.Info(\"Waiting for the router, retry in 1 second.\")\n\t\ttime.Sleep(time.Second)\n\t}\n\treturn errors.New(\"Cannot connect to the router.\")\n}", "func PingHosts(ipBase string, ipRange []int) {\n\n\tvar wg sync.WaitGroup\n\tcmd := LibConfig.SysCommands[\"PING\"] + \" -q -W 1 -c 1 \" + ipBase\n\n\tfor i := ipRange[0]; i < ipRange[1]; i++ {\n\t\twg.Add(1)\n\n\t\t// allow threaded system command calls to finish asynchronously\n\t\tgo func(i int, w *sync.WaitGroup) {\n\t\t\tdefer w.Done()\n\t\t\tRunCommand(cmd + strconv.Itoa(i))\n\t\t}(i, &wg)\n\t}\n\n\twg.Wait()\n\n}", "func (d *Discovery) Run(ctx context.Context) {\n\tticker := time.NewTicker(refreshInterval * time.Second)\n\tdefer ticker.Stop()\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn\n\t\tcase _ = <-ticker.C:\n\t\t\t_, err := d.RunDiscovery(ctx)\n\t\t\tif err != nil {\n\t\t\t\td.logger.Error(\"Regularly runDiscovery failed\", zap.Error(err))\n\t\t\t}\n\t\t}\n\t}\n}", "func (or OnionRouter) startSendingHeartbeatsToServer() {\n\tfor {\n\t\tor.sendHeartBeat()\n\t\ttime.Sleep(time.Duration(1000) / HeartbeatMultiplier * time.Millisecond)\n\t}\n}", "func Pinger(c chan connection, size int, PingInterval time.Duration, WriteWaitInterval time.Duration) {\n\tfor i := 0; i < size; i++ {\n\t\tgo func() {\n\t\t\tcSet := make(map[string]*websocket.Conn)\n\t\t\ttimer := time.NewTicker(PingInterval)\n\t\t\tfor {\n\t\t\t\tselect {\n\t\t\t\tcase conn := <-c:\n\t\t\t\t\tcSet[conn.uniqConnID] = conn.conn\n\t\t\t\tcase <-timer.C:\n\t\t\t\t\tfor uniqConnID, conn := range cSet {\n\t\t\t\t\t\tlogger.Debug(fmt.Sprintf(\"Pinging UniqConnID: %s \", uniqConnID))\n\t\t\t\t\t\tif err := conn.WriteControl(websocket.PingMessage, []byte(\"--ping--\"), time.Now().Add(WriteWaitInterval)); err != nil {\n\t\t\t\t\t\t\tlogger.Error(fmt.Sprintf(\"[websocket.pingPeer] - Failed to ping User: %s Error: %v\", uniqConnID, err))\n\t\t\t\t\t\t\tmetrics.Increment(\"server_ping_failure_total\", \"\")\n\t\t\t\t\t\t\tdelete(cSet, uniqConnID)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}()\n\t}\n}", "func (s *Service) Ping(c context.Context) (err error) {\n\t// TODO\n\treturn\n}", "func (s *Service) run() {\n\n\t// Create a communicator for sending and receiving packets.\n\tcommunicator := comm.NewCommunicator(s.config.PollInterval, s.config.Port)\n\tdefer communicator.Stop()\n\n\t// Create a ticker for sending pings.\n\tpingTicker := time.NewTicker(s.config.PingInterval)\n\tdefer pingTicker.Stop()\n\n\t// Create a ticker for timeout checks.\n\tpeerTicker := time.NewTicker(s.config.PeerTimeout)\n\tdefer peerTicker.Stop()\n\n\t// Create the packet that will be sent to all peers.\n\tpkt := &comm.Packet{\n\t\tID: s.config.ID,\n\t\tUserData: s.config.UserData,\n\t}\n\n\t// Continue processing events until explicitly stopped.\n\tfor {\n\t\tselect {\n\t\tcase p := <-communicator.PacketChan:\n\t\t\ts.processPacket(p)\n\t\tcase <-pingTicker.C:\n\t\t\tcommunicator.Send(pkt)\n\t\tcase <-peerTicker.C:\n\t\t\ts.processPeers()\n\t\tcase <-s.stopChan:\n\t\t\treturn\n\t\t}\n\t}\n}", "func (s *Service) Ping(c context.Context) (err error) {\n\treturn\n}", "func pingServer() error {\n\tfor i := 0; i < viper.GetInt(\"max_ping_count\"); i++ {\n\t\t// Ping the server by sending a GET request to `/health`.\n\t\tresp, err := http.Get(viper.GetString(\"url\") + viper.GetString(\"addr\") + \"/sd/health\")\n\t\tif err == nil && resp.StatusCode == 200 {\n\t\t\treturn nil\n\t\t}\n\n\t\t// Sleep for a second to continue the next ping.\n\t\tlog.Info(\"等待路由器,1秒后重试\")\n\t\ttime.Sleep(time.Second)\n\t}\n\treturn errors.New(\"不能连接路由器\")\n}", "func (c *connAttrs) SetPingInterval(d time.Duration) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\tc._pingInterval = d\n}", "func pinger(c chan<- string) {\n\tfor i := 0; ; i++ {\n\t\tc <- \"Ping\"\n\t}\n}", "func (c *Connection) startKeepAlive() {\n\tgo func() {\n\t\tdefer func() {\n\t\t\tc.WS.Close()\n\t\t\tc.OnClose(c)\n\t\t}()\n\n\t\tfor {\n\t\t\t// Enviar ping para verificar si esta activo el socket\n\t\t\tif err := websocket.JSON.Send(c.WS, common.SendMessage{Type: \"ping\"}); err != nil {\n\t\t\t\tc.logger.Debugf(\"\\n[Connection][keepAlive] Error al enviar ping , error: %s\", err)\n\t\t\t}\n\t\t\ttime.Sleep(timeoutKeepAlive / 3)\n\t\t\tc.logger.Debugf(\"\\n[Connection][keepAlive] Diferencia: %d\", time.Now().Sub(c.lastResponse))\n\t\t\tif time.Now().Sub(c.lastResponse) > timeoutKeepAlive {\n\t\t\t\tc.logger.Debugf(\"\\n[Connection][keepAlive] Cerrando conexion por KeepAlive\")\n\t\t\t\tc.WS.Close()\n\t\t\t\tc.OnClose(c)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n}", "func (p *Probe) Start(ctx context.Context, dataChan chan *metrics.EventMetrics) {\n\tif p.conn == nil {\n\t\tp.l.Critical(\"Probe has not been properly initialized yet.\")\n\t}\n\tdefer p.conn.close()\n\tfor ts := range time.Tick(p.opts.Interval) {\n\t\t// Don't run another probe if context is canceled already.\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn\n\t\tdefault:\n\t\t}\n\n\t\tp.runProbe()\n\t\tp.l.Debugf(\"%s: Probe finished.\", p.name)\n\t\tif (p.runCnt % uint64(p.c.GetStatsExportInterval())) != 0 {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, t := range p.targets {\n\t\t\tem := metrics.NewEventMetrics(ts).\n\t\t\t\tAddMetric(\"total\", metrics.NewInt(p.sent[t])).\n\t\t\t\tAddMetric(\"success\", metrics.NewInt(p.received[t])).\n\t\t\t\tAddMetric(\"latency\", metrics.NewFloat(p.latency[t].Seconds()/p.opts.LatencyUnit.Seconds())).\n\t\t\t\tAddLabel(\"ptype\", \"ping\").\n\t\t\t\tAddLabel(\"probe\", p.name).\n\t\t\t\tAddLabel(\"dst\", t)\n\n\t\t\tdataChan <- em.Clone()\n\t\t\tp.l.Info(em.String())\n\t\t}\n\t}\n}", "func pinger(wg *sync.WaitGroup, configuration *config) {\n\tfor {\n\t\tfor i := 0; i < len(configuration.Address); i++ {\n\n\t\t\t//Ping syscall, -c ping count, -i interval, -w timeout\n\t\t\tout, _ := exec.Command(\"ping\", configuration.Address[i], \"-c 5\", \"-i 3\", \"-w 10\").Output()\n\t\t\tif (strings.Contains(string(out), \"Destination Host Unreachable\")) || (strings.Contains(string(out), \"100% packet loss\")) {\n\t\t\t\tfmt.Println(\"Server down\")\n\t\t\t\tvar (\n\t\t\t\t\thost = \"xxx\"\n\t\t\t\t\tuser = \"xxx\"\n\t\t\t\t\tpass = \"xxx\"\n\t\t\t\t\trecipent = \"xxx\"\n\t\t\t\t)\n\t\t\t\t//recipent := configuration.Recipient[\"Recipinet\"+strconv.Itoa(i+1)]\n\n\t\t\t\tconfig := mailer.Config{\n\t\t\t\t\tHost: host,\n\t\t\t\t\tPort: 465,\n\t\t\t\t\tUser: user,\n\t\t\t\t\tPass: pass,\n\t\t\t\t}\n\n\t\t\t\tMailer := mailer.NewMailer(config, true)\n\n\t\t\t\tmail := mailer.NewMail()\n\t\t\t\tmail.FromName = \"Go Mailer\"\n\t\t\t\tmail.From = user\n\t\t\t\tmail.SetTo(recipent)\n\t\t\t\tmail.Subject = \"Server \"\n\t\t\t\tmail.Body = \"Your server is down\"\n\n\t\t\t\tif err := Mailer.Send(mail); err != nil {\n\t\t\t\t\tfmt.Println(err)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"Server is running\")\n\n\t\t\t}\n\t\t}\n\t\ttime.Sleep(2 * time.Second)\n\t}\n\twg.Done() // need to fix\n}", "func StartUpdateFollowersLoop(\n\tctx context.Context,\n\tfollowTarget string,\n\tredisCl *redis.Client,\n\thelixCl *helix.Client,\n) {\n\tgo func() {\n\t\tUpdateFollowers(ctx, followTarget, redisCl, helixCl)\n\t\tt := time.NewTicker(5 * time.Minute)\n\t\tfor range t.C {\n\t\t\tUpdateFollowers(ctx, followTarget, redisCl, helixCl)\n\t\t}\n\t}()\n}" ]
[ "0.6193315", "0.6179224", "0.6143193", "0.61351657", "0.6028782", "0.6014904", "0.5982548", "0.5971441", "0.59634084", "0.58982575", "0.5862859", "0.5855726", "0.58180887", "0.5785415", "0.5776094", "0.57536733", "0.57490754", "0.5747036", "0.57020706", "0.5685898", "0.5671513", "0.5671513", "0.5657552", "0.5645707", "0.5636351", "0.5613507", "0.55493826", "0.55486345", "0.5535501", "0.5530802", "0.5525936", "0.55256844", "0.5517841", "0.5498446", "0.5481142", "0.54808974", "0.54387915", "0.5434248", "0.54334146", "0.5429629", "0.54217815", "0.54084605", "0.53960717", "0.5378479", "0.5374572", "0.5358789", "0.5353625", "0.5352693", "0.5348487", "0.53329897", "0.53274345", "0.53269655", "0.5325476", "0.53109753", "0.5307576", "0.53033984", "0.53029823", "0.5301591", "0.53013563", "0.52989405", "0.52976114", "0.52970225", "0.5284299", "0.5273272", "0.52600604", "0.52568185", "0.52504766", "0.5243042", "0.523224", "0.52267367", "0.5224525", "0.5221669", "0.5220294", "0.5215585", "0.521485", "0.521369", "0.5203647", "0.51998734", "0.51938826", "0.51915294", "0.51896715", "0.51839584", "0.51744515", "0.5174333", "0.51657", "0.51657", "0.51631033", "0.5162339", "0.5157261", "0.5155016", "0.51511526", "0.51481843", "0.51459384", "0.51449466", "0.51404476", "0.5133945", "0.5128685", "0.51286304", "0.51276946", "0.5127493" ]
0.76078093
0
/ =============== === private === ============= shouldIPing
func shouldIPing() bool { return !initialElection && !bullyImpl.EnCours() && !bullyImpl.IsCoordinator() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CheckIp(ip string) int {\n return 0\n\n}", "func ( ipMeta * pState ) verifyScanningIP( pRecv *packet_metadata ) bool {\n\n\tpRecvKey := constructKey(pRecv)\n\t//first check that IP itself is being scanned\n\tps, ok := ipMeta.Get(pRecvKey)\n\tif !ok {\n\t\treturn false\n\t}\n\tpMap := ps.Packet\n\n\t//second check that 4-tuple matches with default packet\n\tif (( pMap.Saddr == pRecv.Saddr ) && (pMap.Dport == pRecv.Dport) &&\n\t\t(pMap.Sport == pRecv.Sport) ) {\n\n\t\tif verifySA( pMap, pRecv) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\t/*//lets re-query for the ACKtive packets\n\tpRecv.HyperACKtive = true\n\tpRecvKey = constructKey(pRecv)\n\tps, ok = ipMeta.Get( pRecvKey )\n\tif !ok {\n\t\tpRecv.HyperACKtive = false\n\t\treturn false\n\t}\n\tpMap = ps.Packet\n\n\tif verifySA( pMap, pRecv) {\n\t\treturn true\n\t}\n\tpRecv.HyperACKtive = false\n\t*/\n\tif DebugOn() {\n\t\tfmt.Println(pMap.Saddr, \"====\")\n\t\tfmt.Println(\"recv seq num:\", pRecv.Seqnum)\n\t\tfmt.Println(\"stored seqnum: \", pMap.Seqnum)\n\t\tfmt.Println(\"recv ack num:\", pRecv.Acknum)\n\t\tfmt.Println(\"stored acknum: \", pMap.Acknum)\n\t\tfmt.Println(\"received response length: \",len(pRecv.Data))\n\t\tfmt.Println(\"stored response length: \",pMap.LZRResponseL)\n\t\tfmt.Println(pMap.Saddr ,\"====\")\n\t}\n\treturn false\n\n}", "func ForwardPacket(packet *common.Pkt) bool {\n // Print packet contents (disable this before submitting your code)\n //printPkt(packet)\n\n as := \"\" ; ip := \"\"\n for k := 0; k < len(packet.SCION.SrcAS) ; k++ {\n as = as + strconv.Itoa(int(packet.SCION.SrcAS[k]))\n }\n for k := 0; k < len(packet.SCION.SrcHost); k++ {\n ip = ip + strconv.Itoa(int(packet.SCION.SrcHost[k]))\n }\n\n IA := SourceIA{ SrcISD: packet.SCION.SrcISD, SrcAS: as }\n Addr := SourceAddr{ Sip: ip, IA: IA }\n difference := time.Now().Sub(time_interval)\n\n //check if the time interval expired to limit rate\n if difference > TIME_INTERVAL {\n removePendingAddrs()\n removePendingIAs() \n time_interval = time.Now()\n }\n\n //check if Addr and IA is registered\n entryAddr , found := FilteredAddrs[Addr]\n entryIA , foundIA := FilteredIAs[IA]\n\n if found{\n //is the registered address a filtered one?\n if entryAddr.Done{\n if time.Since(entryAddr.TimeStamp) > ADDR_BAD_TIME {\n delete(FilteredAddrs, Addr) //remove the Addr from the ones we registered\n }\n //if its not done\n }else{\n //check if the threshold is reached\n if entryAddr.Amount >= ADDR_THRESHOLD{\n entryAddr.TimeStamp = time.Now()\n entryAddr.Done = true //label as filtered addr\n FilteredAddrs[Addr] = entryAddr\n }else{\n entryAddr.Amount = entryAddr.Amount + 1\n FilteredAddrs[Addr] = entryAddr\n } \n }\n }else{\n //add a big amount of time so that the 113 check doesnt pass\n timeAddr := time.Now().Add(time.Hour * 24 * 10)\n FilteredAddrs[Addr] = FilterSourceAddr{Amount: 1, TimeStamp: timeAddr, Done: false}\n }\n \n //is the IA part registered? \n if foundIA{\n if entryIA.Amount >= IA_THRESHOLD{\n entryIA.Done = true\n FilteredIAs[IA] = entryIA\n }else{\n //threshold not reached yet check if we can increase amount\n address := FilteredAddrs[Addr]\n if !address.Done{\n entryIA.Amount = entryIA.Amount + 1\n FilteredIAs[IA] = entryIA\n }\n }\n }else{\n FilteredIAs[IA] = FilterSourceIA{Amount: 1, Done: false}\n }\n \n dangerous_addr := FilteredAddrs[Addr]\n dangerous_IA := FilteredIAs[IA]\n\n if dangerous_addr.Done || dangerous_IA.Done{\n return false\n }else{\n return true\n\n }\n\n // Decision\n // | true -> forward packet\n // | false -> drop packet\n //return true\n}", "func (util copyHandlerUtil) isIPEndpointStyle(url url.URL) bool {\n\treturn net.ParseIP(url.Host) != nil\n}", "func selfintro() {\n\tmyip, _ := GetIp()\n\tif straddr[0] != myip {\n\t\tsrcAddr := &net.UDPAddr{IP: net.IPv4zero, Port: 1234}\n\t\tip := net.ParseIP(straddr[0])\n\t\tdstAddr := &net.UDPAddr{IP: ip, Port: 8888}\n\t\tconn, err := net.DialUDP(\"udp\", srcAddr, dstAddr)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t}\n\t\tdefer conn.Close()\n\t\tconn.Write(SyncMapToByte(table))\n\t}\n}", "func (m *Myself) setIP(ips string) {\n\tm.mutex.Lock()\n\tdefer m.mutex.Unlock()\n\tvar ip net.IP\n\tif ip = net.ParseIP(ips); ip == nil {\n\t\tlog.Println(\"ip\", ips, \"is illegal format\")\n\t\treturn\n\t}\n\tif nat.IsGlobalIP(ip) != \"\" {\n\t\tm.ip = ips\n\t}\n}", "func (ctx *Context) IP() string {\r\n\tvar ip = strings.Split(ctx.R.RemoteAddr, \":\")\r\n\tif len(ip) > 0 {\r\n\t\tif ip[0] != \"[\" {\r\n\t\t\treturn ip[0]\r\n\t\t}\r\n\t}\r\n\treturn \"127.0.0.1\"\r\n}", "func main() {\n\tvalidIPAddress(\"1.0.1.\")\n}", "func (s *Server) addrAvailable(target net.IP) bool {\n\n\tif s.ICMPTimeout == 0 {\n\t\treturn true\n\t}\n\n\tpinger, err := ping.NewPinger(target.String())\n\tif err != nil {\n\t\tlog.Error(\"ping.NewPinger(): %v\", err)\n\t\treturn true\n\t}\n\n\tpinger.SetPrivileged(true)\n\tpinger.Timeout = time.Duration(s.ICMPTimeout) * time.Millisecond\n\tpinger.Count = 1\n\treply := false\n\tpinger.OnRecv = func(pkt *ping.Packet) {\n\t\t// log.Tracef(\"Received ICMP Reply from %v\", target)\n\t\treply = true\n\t}\n\tlog.Tracef(\"Sending ICMP Echo to %v\", target)\n\tpinger.Run()\n\n\tif reply {\n\t\tlog.Info(\"DHCP: IP conflict: %v is already used by another device\", target)\n\t\treturn false\n\t}\n\n\tlog.Tracef(\"ICMP procedure is complete: %v\", target)\n\treturn true\n}", "func internalIP(node corev1.Node) string {\n\tfor _, address := range node.Status.Addresses {\n\t\tif address.Type == \"InternalIP\" {\n\t\t\treturn address.Address\n\t\t}\n\t}\n\treturn \"\"\n}", "func IP(c *fiber.Ctx) string {\n\tvar headerValue []byte\n\tif c.App().Config().ProxyHeader == \"*\" {\n\t\tfor _, headerName := range possibleHeaderes {\n\t\t\theaderValue = c.Request().Header.Peek(headerName)\n\t\t\tif len(headerValue) > 3 {\n\t\t\t\treturn string(fetchIpFromString.Find(headerValue))\n\t\t\t}\n\t\t}\n\t}\n\theaderValue = []byte(c.IP())\n\tif len(headerValue) <= 3 {\n\t\theaderValue = []byte(\"0.0.0.0\")\n\t}\n\n\t// find ip address in string\n\treturn string(fetchIpFromString.Find(headerValue))\n}", "func TestExternalIP(t *testing.T) {\n\t_, err := ExternalIP()\n\tif err != nil {\n\t\tt.Errorf(\"ExternalIP failed : %w\", err)\n\t}\n}", "func (c *Ctx) IP() string {\n\tif len(c.Core.ProxyHeader) > 0 {\n\t\treturn c.Get(c.Core.ProxyHeader)\n\t}\n\treturn c.RemoteIP().String()\n}", "func isIPAddrResolvable(fl FieldLevel) bool {\n\tif !isIP(fl) {\n\t\treturn false\n\t}\n\n\t_, err := net.ResolveIPAddr(\"ip\", fl.Field().String())\n\n\treturn err == nil\n}", "func (adminAPIOp) BypassInteractionIPRateLimit() bool { return true }", "func validateIP(ipn string) {\n\t// No validation required if no IP address is specified.\n\tif ipn == \"\" {\n\t\treturn\n\t}\n\n\tipAddr, _, err := cnet.ParseCIDROrIP(ipn)\n\tif err != nil {\n\t\tlog.WithError(err).Errorf(\"Failed to parse autodetected CIDR '%s'\", ipn)\n\t\tutils.Terminate()\n\t}\n\n\t// Get a complete list of interfaces with their addresses and check if\n\t// the IP address can be found.\n\tifaces, err := autodetection.GetInterfaces(net.Interfaces, nil, nil, ipAddr.Version())\n\tif err != nil {\n\t\tlog.WithError(err).Error(\"Unable to query host interfaces\")\n\t\tutils.Terminate()\n\t}\n\tif len(ifaces) == 0 {\n\t\tlog.Info(\"No interfaces found for validating IP configuration\")\n\t}\n\n\tfor _, i := range ifaces {\n\t\tfor _, c := range i.Cidrs {\n\t\t\tif ipAddr.Equal(c.IP) {\n\t\t\t\tlog.Debugf(\"IPv%d address %s discovered on interface %s\", ipAddr.Version(), ipAddr.String(), i.Name)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tlog.Warnf(\"Unable to confirm IPv%d address %s is assigned to this host\", ipAddr.Version(), ipAddr)\n}", "func getIPFrom(dbConn ucdb.Db, ipStr string) (net.IP, *net.IPNet, error) {\n\tlog.Debug(\"\")\n\tincIP := func(ip net.IP) {\n\t\tfor j := len(ip) - 1; j >= 0; j-- {\n\t\t\tip[j]++\n\t\t\tif ip[j] > 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tisNetworkAddr := func(ip net.IP, ipnet net.IPNet) bool {\n\t\treturn ip.Equal(ipnet.IP)\n\t}\n\tip, ipnet, err := net.ParseCIDR(ipStr)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tlog.Debug(\"Checking if IP %+v is a network address or an unique IP\", ip)\n\tif isNetworkAddr(ip, *ipnet) {\n\t\tlog.Debug(\"Is a network addr\")\n\t\tincIP(ip)\n\t\tlog.Debug(\"Incremented ip %+v\", ip)\n\t\tfor ipnet.Contains(ip) {\n\t\t\tif err = dbConn.PutIP(ip); err != nil {\n\t\t\t\tlog.Debug(\"Error %s\", err)\n\t\t\t\tincIP(ip)\n\t\t\t} else {\n\t\t\t\treturn ip, ipnet, nil\n\t\t\t}\n\t\t}\n\t\treturn nil, nil, fmt.Errorf(\"reached maximum IPs used\")\n\t} else {\n\t\tlog.Debug(\"Is an unique IP\")\n\t\tif err = dbConn.PutIP(ip); err == nil {\n\t\t\treturn ip, ipnet, nil\n\t\t} else {\n\t\t\treturn nil, nil, err\n\t\t}\n\t}\n}", "func (d *DB) checkip(ip string) (iptype uint32, ipnum uint128.Uint128, ipindex uint32) {\n\tiptype = 0\n\tipnum = uint128.From64(0)\n\tipnumtmp := uint128.From64(0)\n\tipindex = 0\n\tipaddress := net.ParseIP(ip)\n\n\tif ipaddress != nil {\n\t\tv4 := ipaddress.To4()\n\n\t\tif v4 != nil {\n\t\t\tiptype = 4\n\t\t\tipnum = uint128.From64(uint64(binary.BigEndian.Uint32(v4)))\n\t\t} else {\n\t\t\tv6 := ipaddress.To16()\n\n\t\t\tif v6 != nil {\n\t\t\t\tiptype = 6\n\t\t\t\treverseBytes(v6)\n\t\t\t\tipnum = uint128.FromBytes(v6)\n\n\t\t\t\tif ipnum.Cmp(from_v4mapped) >= 0 && ipnum.Cmp(to_v4mapped) <= 0 {\n\t\t\t\t\t// ipv4-mapped ipv6 should treat as ipv4 and read ipv4 data section\n\t\t\t\t\tiptype = 4\n\t\t\t\t\tipnum = ipnum.Sub(from_v4mapped)\n\t\t\t\t} else if ipnum.Cmp(from_6to4) >= 0 && ipnum.Cmp(to_6to4) <= 0 {\n\t\t\t\t\t// 6to4 so need to remap to ipv4\n\t\t\t\t\tiptype = 4\n\t\t\t\t\tipnum = ipnum.Rsh(80)\n\t\t\t\t\tipnum = ipnum.And(last_32bits)\n\t\t\t\t} else if ipnum.Cmp(from_teredo) >= 0 && ipnum.Cmp(to_teredo) <= 0 {\n\t\t\t\t\t// Teredo so need to remap to ipv4\n\t\t\t\t\tiptype = 4\n\t\t\t\t\tipnum = uint128.Uint128{^ipnum.Lo, ^ipnum.Hi}\n\t\t\t\t\tipnum = ipnum.And(last_32bits)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif iptype == 4 {\n\t\tif d.meta.ipv4indexed {\n\t\t\tipnumtmp = ipnum.Rsh(16)\n\t\t\tipnumtmp = ipnumtmp.Lsh(3)\n\t\t\tipindex = uint32(ipnumtmp.Add(uint128.From64(uint64(d.meta.ipv4indexbaseaddr))).Lo)\n\t\t}\n\t} else if iptype == 6 {\n\t\tif d.meta.ipv6indexed {\n\t\t\tipnumtmp = ipnum.Rsh(112)\n\t\t\tipnumtmp = ipnumtmp.Lsh(3)\n\t\t\tipindex = uint32(ipnumtmp.Add(uint128.From64(uint64(d.meta.ipv6indexbaseaddr))).Lo)\n\t\t}\n\t}\n\treturn\n}", "func provideIP(w http.ResponseWriter, req *http.Request) {\n\tresult, error := evaluateIPAddress(req)\n\tif error != nil {\n\t\tresult.Error = error.Error()\n\t}\n\tgo result.fetchGeoAndPersist()\n\n\twriteReponse(w, req, ipTemplate, result)\n}", "func (info *BaseEndpointInfo) IP() string {\n\treturn utilproxy.IPPart(info.Endpoint)\n}", "func ctrlIP(ipv4 string) (string, bool) {\n\tvar ipv4Addr net.IP\n\tipv4Addr = net.ParseIP(ipv4)\n\tif ipv4Addr.To4() == nil {\n\t\tfmt.Println(\"Invalid IP address.\\n\")\n\t\treturn \"\", true\n\t}\n\tipv4Str := ipv4Addr.String()\n\treturn ipv4Str, false\n}", "func (rhost *rhostData) getIPs() (ips []string, err error) {\n\tifaces, err := net.Interfaces()\n\tif err != nil {\n\t\treturn\n\t}\n\tfor _, i := range ifaces {\n\t\taddrs, err := i.Addrs()\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, addr := range addrs {\n\t\t\tvar ip net.IP\n\t\t\tswitch v := addr.(type) {\n\t\t\tcase *net.IPNet:\n\t\t\t\tip = v.IP\n\t\t\tcase *net.IPAddr:\n\t\t\t\tip = v.IP\n\t\t\t}\n\t\t\ta := ip.String()\n\t\t\t// Check ipv6 address add [] if ipv6 allowed and\n\t\t\t// skip this address if ipv6 not allowed\n\t\t\tif strings.IndexByte(a, ':') >= 0 {\n\t\t\t\tif !rhost.teo.param.IPv6Allow {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\ta = \"[\" + a + \"]\"\n\t\t\t}\n\t\t\tips = append(ips, a)\n\t\t}\n\t}\n\treturn\n}", "func checkIPConnection(host string, port string) bool {\n\tconn, err := net.Dial(\"tcp\", host+\":\"+port)\n\tif err != nil {\n\t\treturn false\n\t}\n\tdefer conn.Close()\n\n\treturn true\n}", "func InternalIpDiffSuppress(_, old, new string, _ *schema.ResourceData) bool {\n\treturn (net.ParseIP(old) != nil) && (net.ParseIP(new) == nil)\n}", "func toIPAddress(iip iPAddressv4) (ip hosting.IPAddress) {\n\tip.ID = strconv.Itoa(iip.ID)\n\tip.IP = iip.IP\n\tip.RegionID = strconv.Itoa(iip.RegionID)\n\tip.State = iip.State\n\tip.VM = strconv.Itoa(iip.VM)\n\n\tif iip.Version == 6 {\n\t\tip.Version = hosting.IPv6\n\t} else {\n\t\tip.Version = hosting.IPv4\n\t}\n\n\treturn\n}", "func (ia IfAddr) GetIP() string { return ia.IfaIP }", "func IpOk(ip string) bool {\n\tlock.RLock()\n\tdefer lock.RUnlock()\n\tif geoIPCheck == nil {\n\t\tlog.Printf(\"WARN geo ip check not activated\")\n\t\treturn true\n\t}\n\treturn geoIPCheck.Check(ip)\n}", "func main() {\n\turl := \"https://api.ipify.org?format=text\"\n\tfmt.Printf(\"Please wait while I fetch your IP address from ipify\\n\")\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\tip, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Printf(\"My IP is:%s\\n\", ip)\n}", "func SrcIpIs(ips ...string) ReqCondition {\n\treturn ReqConditionFunc(func(req *http.Request, ctx *ProxyCtx) bool {\n\t\tfor _, ip := range ips {\n\t\t\tif strings.HasPrefix(req.RemoteAddr, ip+\":\") {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\treturn false\n\t})\n}", "func ipString(na *wire.NetAddress) string {\n\tif Tor(na) {\n\t\t// We know now that na.IP is long enogh.\n\t\tbase32 := base32.StdEncoding.EncodeToString(na.IP[6:])\n\t\treturn strings.ToLower(base32) + \".onion\"\n\t} else {\n\t\treturn na.IP.String()\n\t}\n}", "func (s *BasejossListener) EnterFuncIp(ctx *FuncIpContext) {}", "func IP(w http.ResponseWriter, r *http.Request) {\n\tremoteAddr := r.Header.Get(\"X-Forwarded-For\")\n\n\tif remoteAddr == \"\" {\n\t\thost, _, err := net.SplitHostPort(r.RemoteAddr)\n\t\tif err != nil {\n\t\t\tlog.Fatalln(err)\n\t\t}\n\t\tremoteAddr = host\n\t}\n\n\tfmt.Fprintln(w, remoteAddr)\n}", "func isPrivateIP(ip net.IP) bool {\n\t//TODO: another great cidrtree option\n\t//TODO: Private for ipv6 or just let it ride?\n\treturn private24BitBlock.Contains(ip) || private20BitBlock.Contains(ip) || private16BitBlock.Contains(ip)\n}", "func (o TargetGkeOutput) InternalIp() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v TargetGke) *bool { return v.InternalIp }).(pulumi.BoolPtrOutput)\n}", "func (p IPPacket) IP(t IPType) (net.IP, error) {\n\tswitch p.Version() {\n\tcase 4:\n\t\t{\n\t\t\tif len(p) < IPv4PacketHeadLen {\n\t\t\t\treturn nil, ErrTooShort\n\t\t\t}\n\t\t\tip := make(net.IP, 4)\n\t\t\tif t == SourceIP {\n\t\t\t\tcopy(ip, p[12:16])\n\t\t\t} else {\n\t\t\t\tcopy(ip, p[16:20])\n\t\t\t}\n\t\t\treturn ip, nil\n\t\t}\n\tcase 6:\n\t\t{\n\t\t\tif len(p) < IPv6PacketHeadLen {\n\t\t\t\treturn nil, ErrTooShort\n\t\t\t}\n\t\t\tip := make(net.IP, 16)\n\t\t\tif t == SourceIP {\n\t\t\t\tcopy(ip, p[8:24])\n\t\t\t} else {\n\t\t\t\tcopy(ip, p[24:40])\n\t\t\t}\n\t\t\treturn ip, nil\n\t\t}\n\tdefault:\n\t\t{\n\t\t\treturn nil, ErrIPPacketBadVersion\n\t\t}\n\t}\n}", "func Extract(addr string) (string, error) {\n\t// if addr specified then its returned\n\tif len(addr) > 0 && (addr != \"0.0.0.0\" && addr != \"[::]\" && addr != \"::\") {\n\t\treturn addr, nil\n\t}\n\n\tifaces, err := net.Interfaces()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Failed to get interfaces! Err: %v\", err)\n\t}\n\n\t//nolint:prealloc\n\tvar addrs []net.Addr\n\tvar loAddrs []net.Addr\n\tfor _, iface := range ifaces {\n\t\tifaceAddrs, err := iface.Addrs()\n\t\tif err != nil {\n\t\t\t// ignore error, interface can dissapear from system\n\t\t\tcontinue\n\t\t}\n\t\tif iface.Flags&net.FlagLoopback != 0 {\n\t\t\tloAddrs = append(loAddrs, ifaceAddrs...)\n\t\t\tcontinue\n\t\t}\n\t\taddrs = append(addrs, ifaceAddrs...)\n\t}\n\taddrs = append(addrs, loAddrs...)\n\tfmt.Println(\"addrs\", addrs)\n\tvar ipAddr []byte\n\tvar publicIP []byte\n\n\tfor _, rawAddr := range addrs {\n\t\tvar ip net.IP\n\t\tswitch addr := rawAddr.(type) {\n\t\tcase *net.IPAddr:\n\t\t\tip = addr.IP\n\t\tcase *net.IPNet:\n\t\t\tip = addr.IP\n\t\tdefault:\n\t\t\tcontinue\n\t\t}\n\n\t\tif !isPrivateIP(ip.String()) {\n\t\t\tpublicIP = ip\n\t\t\tcontinue\n\t\t}\n\n\t\tipAddr = ip\n\t\tbreak\n\t}\n\n\t// return private ip\n\tif ipAddr != nil {\n\t\treturn net.IP(ipAddr).String(), nil\n\t}\n\n\t// return public or virtual ip\n\tif publicIP != nil {\n\t\treturn net.IP(publicIP).String(), nil\n\t}\n\n\treturn \"\", fmt.Errorf(\"No IP address found, and explicit IP not provided\")\n}", "func IpOk(ip string) bool {\n\tlock.RLock()\n\tdefer lock.RUnlock()\n\tif geoIPCheck == nil {\n\t\tlog.Info(\"WARN geo ip check not activated\")\n\t\treturn true\n\t}\n\treturn geoIPCheck.Check(ip)\n}", "func IsInternal(dots string) bool {\n\tip := net.ParseIP(dots)\n\tif ip == nil {\n\t\treturn true\n\t}\n\tif ip4 := ip.To4(); ip4 != nil {\n\t\tif ip4[0] == 127 {\n\t\t\treturn true\n\t\t}\n\t\tif ip4[0] == 10 {\n\t\t\treturn true\n\t\t}\n\t\tif ip4[0] == 192 && ip4[1] == 168 {\n\t\t\treturn true\n\t\t}\n\t\tif ip4[0] == 172 && ip4[1] >= 16 && ip4[1] < 32 {\n\t\t\treturn true\n\t\t}\n\t\tif ip4[0] == 0 && ip4[1] == 0 && ip4[2] == 0 && ip4[3] == 0 {\n\t\t\treturn true\n\t\t}\n\t}\n\n\t// IpV6\n\treturn false\n}", "func hasIPAns(m *dns.Msg) (ok bool) {\n\tfor _, rr := range m.Answer {\n\t\tif t := rr.Header().Rrtype; t == dns.TypeA || t == dns.TypeAAAA {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func ip(ipnet *net.IPNet, offset uint32) []expr.Any {\n\t// TODO: make it work with ipv6\n\t// TODO: remote the bitwise operation if there's not mask\n\tif ipnet == nil {\n\t\treturn nil\n\t}\n\n\tif ipnet.IP.To4() == nil {\n\t\treturn nil\n\t}\n\n\t// [ payload load 4b @ network header + 12 => reg 1 ]\n\t// [ bitwise reg 1 = (reg=1 & YYY ) ^ 0x00000000 ]\n\t// [ cmp eq reg 1 XXX ]\n\treturn []expr.Any{\n\t\t&expr.Payload{\n\t\t\tOperationType: expr.PayloadLoad,\n\t\t\tDestRegister: 1,\n\t\t\tBase: expr.PayloadBaseNetworkHeader,\n\t\t\tLen: 4,\n\t\t\tOffset: offset,\n\t\t},\n\t\t&expr.Bitwise{\n\t\t\tSourceRegister: 1,\n\t\t\tDestRegister: 1,\n\t\t\tLen: 4,\n\t\t\tMask: ipnet.Mask,\n\t\t\tXor: []byte{0x0, 0x0, 0x0, 0x0},\n\t\t},\n\t\t&expr.Cmp{\n\t\t\tOp: expr.CmpOpEq,\n\t\t\tRegister: 1,\n\t\t\tData: ipnet.IP.To4(),\n\t\t},\n\t}\n}", "func (i *IPIter) IP() net.IP {\n\treturn i.ip\n}", "func validateIpOverlap(d *db.DB, intf string, ipPref string, tblName string) (string, error) {\n log.Info(\"Checking for IP overlap ....\")\n\n ipA, ipNetA, err := net.ParseCIDR(ipPref)\n if err != nil {\n log.Info(\"Failed to parse IP address: \", ipPref)\n return \"\", err\n }\n\n var allIntfKeys []db.Key\n\n for key, _ := range IntfTypeTblMap {\n intTbl := IntfTypeTblMap[key]\n keys, err := d.GetKeys(&db.TableSpec{Name:intTbl.cfgDb.intfTN})\n if err != nil {\n log.Info(\"Failed to get keys; err=%v\", err)\n return \"\", err\n }\n allIntfKeys = append(allIntfKeys, keys...)\n }\n\n if len(allIntfKeys) > 0 {\n for _, key := range allIntfKeys {\n if len(key.Comp) < 2 {\n continue\n }\n ipB, ipNetB, perr := net.ParseCIDR(key.Get(1))\n //Check if key has IP, if not continue\n if ipB == nil || perr != nil {\n continue\n }\n if ipNetA.Contains(ipB) || ipNetB.Contains(ipA) {\n if log.V(3) {\n log.Info(\"IP: \", ipPref, \" overlaps with \", key.Get(1), \" of \", key.Get(0))\n }\n //Handle IP overlap across different interface, reject if in same VRF\n intfType, _, ierr := getIntfTypeByName(key.Get(0))\n if ierr != nil {\n log.Errorf(\"Extracting Interface type for Interface: %s failed!\", key.Get(0))\n return \"\", ierr\n }\n intTbl := IntfTypeTblMap[intfType]\n if intf != key.Get(0) {\n vrfNameA, _ := d.GetMap(&db.TableSpec{Name:tblName+\"|\"+intf}, \"vrf_name\")\n vrfNameB, _ := d.GetMap(&db.TableSpec{Name:intTbl.cfgDb.intfTN+\"|\"+key.Get(0)}, \"vrf_name\")\n if vrfNameA == vrfNameB {\n errStr := \"IP \" + ipPref + \" overlaps with IP \" + key.Get(1) + \" of Interface \" + key.Get(0)\n log.Error(errStr)\n return \"\", errors.New(errStr)\n }\n } else {\n //Handle IP overlap on same interface, replace\n log.Error(\"Entry \", key.Get(1), \" on \", intf, \" needs to be deleted\")\n errStr := \"IP overlap on same interface with IP \" + key.Get(1)\n return key.Get(1), errors.New(errStr)\n }\n }\n }\n }\n return \"\", nil\n}", "func (c NodeGroup) getPublicIP(i int) string {\n\tfor _, ni := range c.Nodes[i].instance.NetworkInterfaces {\n\t\tfor _, conn := range c.Connections {\n\t\t\tif conn.To == ni.Connection {\n\t\t\t\treturn toHCLStringFormat(fmt.Sprintf(\"aws_network_interface.%s.private_ip\", ni.Name))\n\t\t\t}\n\t\t}\n\t}\n\n\tpanic(errors.New(\"no possible connection possible\"))\n}", "func (info *endpointsInfo) IP() string {\n\treturn info.ip\n}", "func isIP(fl FieldLevel) bool {\n\tip := net.ParseIP(fl.Field().String())\n\n\treturn ip != nil\n}", "func revealIP() string {\n\t// consensus := externalip.\n\tconsensus := externalip.DefaultConsensus(nil, nil)\n\tip, err := consensus.ExternalIP()\n\thandle(\"Something went wrong getting the external IP: \", err)\n\tlogrus.Info(\"External IP: \", ip.String())\n\treturn ip.String()\n}", "func (e ErrParseIP) BadRequest() {}", "func checkRemoteAddress(r *http.Request, user_id int) bool {\n\tvar addresses string\n\tstmt, _ := db.Prepare(\"select remote_addr from users where id=?\")\n\tres := stmt.QueryRow(user_id)\n\terr := res.Scan(&addresses)\n\tcurrentAddr := strings.Split(r.RemoteAddr, \":\")[0]\n\tif currentAddr == \"[\" {\n\t\tcurrentAddr = \"localHost\"\n\t}\n\tif strings.Contains(addresses, currentAddr) && err == nil {\n\t\treturn true\n\t} else {\n\t\treturn false\n\t}\n}", "func getClientIP(ctx context.Context) string {\n\t/* method 1: using peer package get ip address */\n\t// get tcpAddrn w/o port\n\t// tcpAddr, ok := pr.Addr.(*net.TCPAddr)\n\t// addr = tcpAddr.IP.String()\n\tvar addr string\n\tif pr, ok := peer.FromContext(ctx); ok {\n\t\taddr = pr.Addr.String()\n\t}\n\treturn addr\n\n\t/* method 2: replace [::1] to 127.0.0.1 */\n\t// if client and server at the same machine, it will return [::1]:port\n\t// https://razil.cc/post/2018/09/go-grpc-get-requestaddr/\n\t// pr, ok := peer.FromContext(ctx)\n\t// if !ok {\n\t// \treturn \"\", fmt.Errorf(\"[getClinetIP] invoke FromContext() failed\")\n\t// }\n\t// if pr.Addr == net.Addr(nil) {\n\t// \treturn \"\", fmt.Errorf(\"[getClientIP] peer.Addr is nil\")\n\t// }\n\n\t// addSlice := strings.Split(pr.Addr.String(), \":\")\n\t// if addSlice[0] == \"[\" {\n\t// \treturn \"127.0.0.1\"\n\t// }\n\t// return addSlice[0]\n\n\t/* method 3: use metadata get IP address : localhost:50051 */\n\t// https://github.com/grpc/grpc-go/blob/master/Documentation/grpc-metadata.md\n\t// md, _ := metadata.FromIncomingContext(ctx)\n\t// fmt.Println(\"md[:authority]\", md[\":authority\"][0])\n\t// return md[\":authority\"][0]\n}", "func (input *Input) IP() string {\n\tips := input.Proxy()\n\tif len(ips) > 0 && ips[0] != \"\" {\n\t\trip := strings.Split(ips[0], \":\")\n\t\treturn rip[0]\n\t}\n\tip := strings.Split(input.Context.Request.RemoteAddr, \":\")\n\tif len(ip) > 0 {\n\t\tif ip[0] != \"[\" {\n\t\t\treturn ip[0]\n\t\t}\n\t}\n\treturn \"127.0.0.1\"\n}", "func checkip(meta *ip2locationmeta, ip string) (iptype uint32, ipnum *big.Int, ipindex uint32) {\n\tiptype = 0\n\tipnum = big.NewInt(0)\n\tipnumtmp := big.NewInt(0)\n\tipindex = 0\n\tipaddress := net.ParseIP(ip)\n\n\tif ipaddress != nil {\n\t\tv4 := ipaddress.To4()\n\n\t\tif v4 != nil {\n\t\t\tiptype = 4\n\t\t\tipnum.SetBytes(v4)\n\t\t} else {\n\t\t\tv6 := ipaddress.To16()\n\n\t\t\tif v6 != nil {\n\t\t\t\tiptype = 6\n\t\t\t\tipnum.SetBytes(v6)\n\t\t\t}\n\t\t}\n\t}\n\tif iptype == 4 {\n\t\tif meta.ipv4indexbaseaddr > 0 {\n\t\t\tipnumtmp.Rsh(ipnum, 16)\n\t\t\tipnumtmp.Lsh(ipnumtmp, 3)\n\t\t\tipindex = uint32(ipnumtmp.Add(ipnumtmp, big.NewInt(int64(meta.ipv4indexbaseaddr))).Uint64())\n\t\t}\n\t} else if iptype == 6 {\n\t\tif meta.ipv6indexbaseaddr > 0 {\n\t\t\tipnumtmp.Rsh(ipnum, 112)\n\t\t\tipnumtmp.Lsh(ipnumtmp, 3)\n\t\t\tipindex = uint32(ipnumtmp.Add(ipnumtmp, big.NewInt(int64(meta.ipv6indexbaseaddr))).Uint64())\n\t\t}\n\t}\n\treturn\n}", "func (o SelfIpOutput) Ip() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *SelfIp) pulumi.StringOutput { return v.Ip }).(pulumi.StringOutput)\n}", "func remoteAddr( r *http.Request ) net.IP {\n forwardedFor := r.Header.Get( \"X-Forwarded-For\" )\n if forwardedFor != \"\" {\n // Syntax on MDN: X-Forwarded-For: <client>, <proxy1>, <proxy2>\n ip := strings.Split( forwardedFor, \", \" )[0]\n if !(strings.HasPrefix( ip, \"10.\" ) ||\n strings.HasPrefix( ip, \"192.168.\" ) ||\n strings.HasPrefix( ip, \"172.16.\" ) ||\n strings.HasPrefix( ip, \"172.17.\" ) ||\n strings.HasPrefix( ip, \"172.18.\" ) ||\n strings.HasPrefix( ip, \"172.19.\" ) ||\n strings.HasPrefix( ip, \"172.20.\" ) ||\n strings.HasPrefix( ip, \"172.21.\" ) ||\n strings.HasPrefix( ip, \"172.22.\" ) ||\n strings.HasPrefix( ip, \"172.23.\" ) ||\n strings.HasPrefix( ip, \"172.24.\" ) ||\n strings.HasPrefix( ip, \"172.25.\" ) ||\n strings.HasPrefix( ip, \"172.26.\" ) ||\n strings.HasPrefix( ip, \"172.27.\" ) ||\n strings.HasPrefix( ip, \"172.28.\" ) ||\n strings.HasPrefix( ip, \"172.29.\" ) ||\n strings.HasPrefix( ip, \"172.30.\" ) ||\n strings.HasPrefix( ip, \"172.31.\" ) ) {\n return net.ParseIP( ip )\n }\n }\n\n ip, _, _ := net.SplitHostPort( r.RemoteAddr )\n return net.ParseIP( ip )\n}", "func (s *ProvisionedServer) Address() string { return s.Server.AdvertiseIP }", "func (this *IPAMNetworkPool) isAssigned(probe net.IP) bool {\n\t_, found := this.assignedIPs[probe.String()]\n\treturn found\n}", "func (ip IP) Less(ip2 IP) bool { return ip.Compare(ip2) == -1 }", "func isPrivateSubnet(ips string) bool {\n\tip := net.ParseIP(ips)\n\tfor _, r := range privateCIDRs {\n\t\tif r.Contains(ip) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func SrcIP(ipnet *net.IPNet) []expr.Any {\n\treturn ip(ipnet, 12)\n}", "func getIP(ec2inst ec2Instance,c *ecs.Container) string{\n\tif len(c.NetworkInterfaces) > 0 {\n\t\treturn ptr.StringValue(c.NetworkInterfaces[0].PrivateIpv4Address)\n\t}\n\treturn ptr.StringValue(ec2inst.PrivateIpAddress)\n}", "func (this *IPAMNetworkPool) isUsable(probe net.IP) bool {\n\tif _, found := this.unusableIPs[probe.String()]; found {\n\t\treturn false\n\t}\n\n\t// Regular IP usability checks should reject gateway IPs\n\tif probe.Equal(this.gateway) {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func anyIPContainedInNetwork(ips []string, network *net.IPNet) bool {\n\tfor _, ip := range ips {\n\t\tif network.Contains(net.ParseIP(ip)) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func IsPrivateIP(ips string) bool {\n\tip := net.ParseIP(ips)\n\tfor _, cidr := range privateCIDRs {\n\t\t_, nt, err := net.ParseCIDR(cidr)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tif nt.Contains(ip) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func makeIPRule(srcIp string) *RuleSet {\n var rule = Rule { Layer: \"network\", LType: \"ip\", Pattern: \"srcIp \" + srcIp }\n var ruleSet = RuleSet{ OOperator: NONE, RRule: &rule, LArg: nil, RArg: nil }\n return &ruleSet\n}", "func containsIP(podIPs []corev1.PodIP, targetIP string) bool {\n\tfor _, ip := range podIPs {\n\t\tif ip.IP == targetIP {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func getInternalIP(node *v1.Node) (string, error) {\n\tfor _, address := range node.Status.Addresses {\n\t\tif address.Type == v1.NodeInternalIP && address.Address != \"\" {\n\t\t\treturn address.Address, nil\n\t\t}\n\t}\n\treturn \"\", fmt.Errorf(\"couldn't get the internal IP of host %s with addresses %v\", node.Name, node.Status.Addresses)\n}", "func (f *FilterConfig) privateIP(ip net.IP) bool {\n\tfor _, cidr := range f.privateCIDRs {\n\t\tif cidr.Contains(ip) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (c *Info) IP() net.IP {\n\tself := c.Self()\n\n\ts, err := net.ResolveTCPAddr(\"tcp\", DefaultPort(self))\n\tif err != nil {\n\t\treturn nil\n\t}\n\n\treturn s.IP\n}", "func (o *WafEventNetwork) HasIp() bool {\n\tif o != nil && o.Ip != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func buscarIps(c *cli.Context) {\n\t//retorna o valor da flag Host\n\thost := c.String(\"host\")\n\n\t//net - busca os ips\n\tips, erro := net.LookupIP(host)\n\tif erro != nil {\n\t\tlog.Fatal(erro)\n\t}\n\n\tfor _, ip := range ips {\n\t\tfmt.Println(ip)\n\t}\n}", "func evaluateIPAddress(req *http.Request) (*ipAddress, error) {\n\tresult := ipAddress{}\n\tip, _, err := net.SplitHostPort(req.RemoteAddr)\n\tif err != nil {\n\t\treturn &result, fmt.Errorf(\"The user IP: %q is not IP:port\", req.RemoteAddr)\n\t}\n\n\t// If the client is behind a non-anonymous proxy, the IP address is in the X-Forwarded-For header.\n\t// req.Header.Get is case-insensitive.\n\tresult.IPAddressV4 = req.Header.Get(\"X-Forwarded-For\")\n\tif result.IPAddressV4 == \"\" {\n\t\t// If no header can be read, directly extract the address for the request.\n\t\tuserIP := net.ParseIP(ip)\n\t\tif userIP == nil {\n\t\t\treturn &result, fmt.Errorf(\"The user IP: %q is not IP:port\", req.RemoteAddr)\n\t\t}\n\t\tresult.IPAddressV4 = userIP.String()\n\t\tresult.Source = \"Remote address\"\n\t} else {\n\t\tresult.Source = \"X-Forwarded-For\"\n\t}\n\treturn &result, nil\n}", "func (peer *peerImp) IsIPVerified() bool {\n\treturn peer.ipVerified\n}", "func GetLocalIp() (net.IP, bool) {\n\tarr := getLocalIps()\n\n\tfmt.Println(arr)\n\n\tvar result net.IP\n\n\tfor _, el := range arr {\n\t\tif result != nil {\n\t\t\tbreak\n\t\t}\n\n\t\tips := strings.Split(el.String(), \".\")\n\t\tif ips[3] == \"1\" || ips[0] == \"10\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tip := ips[0] + \".\" + ips[1] + \".\" + ips[2] + \".\"\n\n\t\tfmt.Println(\"Starting: \" + ip)\n\n\t\twg := sync.WaitGroup{}\n\t\twg.Add(254)\n\n\t\tfor j := 1; j < 255; j++ {\n\n\t\t\tif result != nil {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t_ip := ip + strconv.Itoa(j)\n\n\t\t\tif _ip == el.String() {\n\t\t\t\twg.Done()\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tgo func() {\n\t\t\t\tif Ping(_ip) {\n\t\t\t\t\tresult = el\n\t\t\t\t}\n\n\t\t\t\twg.Done()\n\t\t\t}()\n\n\t\t}\n\n\t\twg.Wait()\n\n\t\t//for i := 1; i < 255; i++ {\n\t\t//\n\t\t//}\n\t\t//\n\t\t//wg.Wait()\n\t}\n\n\tif result != nil {\n\t\treturn result, true\n\t}\n\n\treturn GetOutboundIP(), true\n\t//for _, el := range arr {\n\t//\tif strings.HasPrefix(el.String(), \"192.168\") {\n\t//\t\treturn el, false\n\t//\t}\n\t//}\n\t//\n\t//for _, el := range arr {\n\t//\tif strings.HasPrefix(el.String(), \"172\") {\n\t//\t\treturn el, false\n\t//\t}\n\t//}\n\t//\n\t//for _, el := range arr {\n\t//\tif strings.HasPrefix(el.String(), \"10.\") {\n\t//\t\treturn el, false\n\t//\t}\n\t//}\n\t//\n\t//return nil, false\n}", "func IsIP(val interface{}) bool {\n\treturn isMatch(ip, val)\n}", "func IsIP(s string) bool { return s != \"\" && net.ParseIP(s) != nil }", "func (j *JoinHelper) getAllIPs () ([]string, error){\n\n\tvpnName := j.getVPNNicName()\n\tips := make ([]string, 0)\n\n\tinterfaces, err := net.Interfaces()\n\tif err != nil {\n\t\treturn ips, err\n\t}\n\tfor _, iface := range interfaces {\n\t\tif iface.Name != vpnName {\n\t\t\taddresses, err := iface.Addrs()\n\t\t\tif err != nil {\n\t\t\t\treturn ips, err\n\t\t\t}\n\t\t\tfor _, addr := range addresses {\n\t\t\t\tnetIP, ok := addr.(*net.IPNet)\n\t\t\t\tif ok && !netIP.IP.IsLoopback() && netIP.IP.To4() != nil {\n\t\t\t\t\tip := netIP.IP.String()\n\t\t\t\t\tips = append(ips, ip)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn ips, nil\n}", "func (i EC2Instance) IP() string {\n\treturn i.privateIP\n}", "func main() {\n\tif len(os.Args) != 2 {\n\t\tfmt.Fprintf(os.Stderr, \"Usage: %s host\", os.Args[0])\n\t\tos.Exit(1)\n\t}\n\n\taddr, err := net.ResolveIPAddr(\"ip\", os.Args[1])\n\tif err != nil {\n\t\tfmt.Println(\"Resolution error: \", err.Error())\n\t\tos.Exit(1)\n\t}\n\n\tconn, err := net.DialIP(\"ip4:icmp\", addr, addr)\n\tcheckError(err)\n\n\tvar msg [512]byte\n\tmsg[0] = 8 // echo\n\n\tmsg[1] = 0\n\n\tmsg[2] = 0\n\tmsg[3] = 0\n\n\tmsg[4] = 0\n\tmsg[5] = 13\n\n\tmsg[6] = 0\n\tmsg[7] = 37\n\n\tlen := 8\n\n\tcheck := checkSum(msg[0:len])\n\tmsg[2] = byte(check >> 8)\n\tmsg[3] = byte(check & 255)\n\t_, err = conn.Write(msg[0:len])\n\tcheckError(err)\n\t_, err = conn.Read(msg[0:])\n\tcheckError(err)\n\n\tfmt.Println(\"got response\")\n\n\tif msg[5] == 13 {\n\t\tfmt.Println(\"indentifier matches\")\n\t}\n\n\tif msg[7] == 37 {\n\t\tfmt.Println(\"sequence matches\")\n\t}\n\n\tos.Exit(0)\n}", "func InternalIP() string {\n\tinters, err := net.Interfaces()\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tfor _, inter := range inters {\n\t\tif !strings.HasPrefix(inter.Name, \"lo\") {\n\t\t\taddrs, err := inter.Addrs()\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor _, addr := range addrs {\n\t\t\t\tif ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\t\t\tif ipnet.IP.To4() != nil {\n\t\t\t\t\t\treturn ipnet.IP.String()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\"\n}", "func getOutboundIP() net.IP {\n\tconn, err := net.Dial(\"udp\", \"8.8.8.8:80\")\n\n\t//if there is no internet we get the localhost\n\tif err != nil {\n\t\t//log.Fatal(err)\n\t\tprintln(\"No network !\")\n\t\treturn net.IPv4(127, 0, 0, 1)\n\t}\n\tdefer conn.Close()\n\tlocalAddr := conn.LocalAddr().(*net.UDPAddr)\n\n\treturn localAddr.IP\n}", "func getIPAddress() string {\n\tvar validIP = false\n\tvar ip string\n\tfor validIP == false {\n\t\tfmt.Scanln(&ip)\n\t\tif len(ip) < 6 || !pattern.MatchString(ip) {\n\t\t\tfmt.Print(\"Enter a valid address: \")\n\t\t} else {\n\t\t\tvalidIP = true\n\t\t}\n\t}\n\treturn ip\n}", "func (h Hostingv4) CreatePrivateIP(vlan hosting.Vlan, ip string) (hosting.IPAddress, error) {\n\tvar fn = \"CreatePrivateIP\"\n\tif vlan.RegionID == \"\" || vlan.ID == \"\" {\n\t\treturn hosting.IPAddress{}, &HostingError{fn, \"Vlan\", \"ID/RegionID\", ErrNotProvided}\n\t}\n\tregionid, err := strconv.Atoi(vlan.RegionID)\n\tif err != nil {\n\t\treturn hosting.IPAddress{}, &HostingError{fn, \"Vlan\", \"RegionID\", ErrParse}\n\t}\n\tvlanid, err := strconv.Atoi(vlan.ID)\n\tif err != nil {\n\t\treturn hosting.IPAddress{}, &HostingError{fn, \"Vlan\", \"ID\", ErrParse}\n\t}\n\n\tvar ipv4 iPAddressv4\n\tvar response = Operation{}\n\terr = h.Send(\"hosting.iface.create\", []interface{}{\n\t\tmap[string]interface{}{\n\t\t\t\"datacenter_id\": regionid,\n\t\t\t\"bandwidth\": hosting.DefaultBandwidth,\n\t\t\t\"ip\": ip,\n\t\t\t\"vlan\": vlanid,\n\t\t}}, &response)\n\tif err != nil {\n\t\treturn hosting.IPAddress{}, err\n\t}\n\tif err = h.waitForOp(response); err != nil {\n\t\treturn hosting.IPAddress{}, err\n\t}\n\n\tif err = h.Send(\"hosting.ip.info\", []interface{}{response.IPID}, &ipv4); err != nil {\n\t\treturn hosting.IPAddress{}, err\n\t}\n\n\treturn toIPAddress(ipv4), nil\n}", "func boundIPs(c *caddy.Controller) (ips []net.IP) {\n\tconf := dnsserver.GetConfig(c)\n\thosts := conf.ListenHosts\n\tif hosts == nil || hosts[0] == \"\" {\n\t\thosts = nil\n\t\taddrs, err := net.InterfaceAddrs()\n\t\tif err != nil {\n\t\t\treturn nil\n\t\t}\n\t\tfor _, addr := range addrs {\n\t\t\thosts = append(hosts, addr.String())\n\t\t}\n\t}\n\tfor _, host := range hosts {\n\t\tip, _, _ := net.ParseCIDR(host)\n\t\tip4 := ip.To4()\n\t\tif ip4 != nil && !ip4.IsLoopback() {\n\t\t\tips = append(ips, ip4)\n\t\t\tcontinue\n\t\t}\n\t\tip6 := ip.To16()\n\t\tif ip6 != nil && !ip6.IsLoopback() {\n\t\t\tips = append(ips, ip6)\n\t\t}\n\t}\n\treturn ips\n}", "func (conn *PacketPipe) RemoteAddr() net.Addr { return fakeAddr{} }", "func GetOutboundIP() net.IP {\n conn, err := net.Dial(\"udp\", \"1.1.1.1:80\") // 8.8.8.8:80\")\n if err != nil {\n log.Fatal(err)\n }\n defer conn.Close()\n localAddr := conn.LocalAddr().(*net.UDPAddr)\n return localAddr.IP\n}", "func (o TargetGkePtrOutput) InternalIp() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v *TargetGke) *bool {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.InternalIp\n\t}).(pulumi.BoolPtrOutput)\n}", "func hasPrimaryIP(node *goeapi.Node, name, ip string) (bool, error) {\n\tiface := module.IPInterface(node)\n\tcfg, err := iface.Get(name)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn cfg.Address() == ip, nil\n}", "func CheckTrustedIP(c *router.Context, next router.Handler) {\n\t// TRUSTED_IP_REQUEST=1 means the request is coming from a corp machine.\n\tif c.Request.Header.Get(\"X-AppEngine-Trusted-IP-Request\") != \"1\" {\n\t\thttp.Error(c.Writer, \"Access Denied: You're not on corp.\", http.StatusForbidden)\n\t\treturn\n\t}\n\tnext(c)\n}", "func isIPValid(ip string) (bool, int) {\n\tpip := net.ParseIP(ip)\n\tif pip.To4() == nil {\n\t\treturn false, 0\n\t}\n\tfor _, reservedIP := range gaw.ReservedIPs {\n\t\t_, subnet, err := net.ParseCIDR(reservedIP)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tif subnet.Contains(pip) {\n\t\t\treturn false, -1\n\t\t}\n\t}\n\treturn true, 1\n}", "func isLocalIP(ip string) bool {\n\treturn ip == \"127.0.0.1\" ||\n\t\tip == \"::1\" ||\n\t\tisPrivateSubnet(ip)\n}", "func funcHasIP(ctx context.Context, out io.Writer, args []string) error {\n\tif len(args) != 1 {\n\t\treturn errors.New(\"usage: act has-ip [IP1] [IP2]... \")\n\t}\n\treturn executor.RunExecutorConfigReadOnly(ctx, func(executor executor.Executor) error {\n\t\tif err := executor.Runner.HasIP(out, args); err != nil {\n\t\t\tlogrus.Errorf(err.Error())\n\t\t}\n\t\treturn nil\n\t})\n}", "func (cc ClusterConfig) IP(name string) string {\n\tif name == cc.ID {\n\t\treturn cc.GatewayIP\n\t}\n\tfor _, peer := range cc.WatchedPeers {\n\t\tif name == peer.ID {\n\t\t\treturn peer.GatewayIP\n\t\t}\n\t}\n\treturn \"255.255.255.255\" // dummy value for unknown clusters\n}", "func (conn *PacketPipe) LocalAddr() net.Addr { return fakeAddr{} }", "func ipAddr(r *http.Request) string {\n\tip := r.Header.Get(\"X-Real-Ip\")\n\tif ip == \"\" {\n\t\tip = strings.Split(r.Header.Get(\"X-Forwarded-For\"), \", \")[0]\n\t}\n\tif ip == \"\" {\n\t\tip = strings.Split(r.RemoteAddr, \":\")[0]\n\t}\n\treturn ip\n}", "func (i *InternalData) GetInternalIP() {\n\n\tconn, err := net.Dial(\"udp\", \"8.8.8.8:80\")\n\tcheckErr(err)\n\tdefer conn.Close()\n\n\tlocalAddr := conn.LocalAddr().(*net.UDPAddr)\n\ti.IntIP = localAddr.IP.String()\n}", "func ipSpan(ipnet *net.IPNet) (minIP, maxIP uint32) {\n\tminIP = binary.BigEndian.Uint32(ipnet.IP.To4()) + 1\n\tmaxIP = minIP + (^binary.BigEndian.Uint32(ipnet.Mask)) - 2\n\treturn minIP, maxIP\n}", "func getOutboundIP() string {\n\tconn, _ := net.Dial(\"udp\", \"8.8.8.8:80\")\n\tdefer conn.Close()\n\tlocalAddr := conn.LocalAddr().String()\n\tidx := strings.LastIndex(localAddr, \":\")\n\treturn localAddr[0:idx]\n}", "func (assign AddressAssignment) EqualIP(b AddressAssignment) bool {\n\tif assign.PoolID != b.PoolID {\n\t\treturn false\n\t} else if assign.IPAddr == b.IPAddr {\n\t\treturn false\n\t} else if assign.Port != b.Port {\n\t\treturn false\n\t} else if assign.ServiceID != b.ServiceID {\n\t\treturn false\n\t} else if assign.EndpointName != b.EndpointName {\n\t\treturn false\n\t}\n\treturn true\n}", "func handlePacket(pkt *pcap.Packet) {\n\t// Ethernet frame has 14 bytes of stuff to ignore, so we start our root position here\n\tvar pos byte = 14\n\n\t// Grab the src IP address of this packet from the IP header.\n\tsrcIP := pkt.Data[pos+12 : pos+16]\n\tdstIP := pkt.Data[pos+16 : pos+20]\n\n\t// The IP frame has the header length in bits 4-7 of byte 0 (relative).\n\tpos += pkt.Data[pos] & 0x0F * 4\n\n\t// Grab the source port from the TCP header.\n\tsrcPort := uint16(pkt.Data[pos])<<8 + uint16(pkt.Data[pos+1])\n\tdstPort := uint16(pkt.Data[pos+2])<<8 + uint16(pkt.Data[pos+3])\n\n\t// The TCP frame has the data offset in bits 4-7 of byte 12 (relative).\n\tpos += byte(pkt.Data[pos+12]) >> 4 * 4\n\n\t// If this is a 0-length payload, do nothing. (Any way to change our filter\n\t// to only dump packets with data?)\n\tif len(pkt.Data[pos:]) <= 0 {\n\t\treturn\n\t}\n\n\t// This is either an inbound or outbound packet. Determine by seeing which\n\t// end contains our port. Either way, we want to put this on the channel of\n\t// the remote end.\n\tvar src string\n\tvar request bool = false\n\tif srcPort == port {\n\t\tsrc = fmt.Sprintf(\"%d.%d.%d.%d:%d\", dstIP[0], dstIP[1], dstIP[2],\n\t\t\tdstIP[3], dstPort)\n\t\t//\t\tlog.Printf(\"response to %s\", src)\n\t} else if dstPort == port {\n\t\tsrc = fmt.Sprintf(\"%d.%d.%d.%d:%d\", srcIP[0], srcIP[1], srcIP[2],\n\t\t\tsrcIP[3], srcPort)\n\t\trequest = true\n\t\t//\t\tlog.Printf(\"request from %s\", src)\n\t} else {\n\t\tlog.Fatalf(\"got packet src = %d, dst = %d\", srcPort, dstPort)\n\t}\n\n\t// Now we have the source and payload information, we can pass this off to\n\t// somebody who is better equipped to process it.\n\tgetChannel(src) <- &packet{request: request, data: pkt.Data[pos:]}\n}", "func hasStaticIP(ifaceName string) (bool, error) {\n\tif runtime.GOOS == \"windows\" {\n\t\treturn false, errors.New(\"Can't detect static IP: not supported on Windows\")\n\t}\n\n\tbody, err := ioutil.ReadFile(\"/etc/dhcpcd.conf\")\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tlines := strings.Split(string(body), \"\\n\")\n\tnameLine := fmt.Sprintf(\"interface %s\", ifaceName)\n\twithinInterfaceCtx := false\n\n\tfor _, line := range lines {\n\t\tline = strings.TrimSpace(line)\n\n\t\tif withinInterfaceCtx && len(line) == 0 {\n\t\t\t// an empty line resets our state\n\t\t\twithinInterfaceCtx = false\n\t\t}\n\n\t\tif len(line) == 0 || line[0] == '#' {\n\t\t\tcontinue\n\t\t}\n\t\tline = strings.TrimSpace(line)\n\n\t\tif !withinInterfaceCtx {\n\t\t\tif line == nameLine {\n\t\t\t\t// we found our interface\n\t\t\t\twithinInterfaceCtx = true\n\t\t\t}\n\n\t\t} else {\n\t\t\tif strings.HasPrefix(line, \"interface \") {\n\t\t\t\t// we found another interface - reset our state\n\t\t\t\twithinInterfaceCtx = false\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif strings.HasPrefix(line, \"static ip_address=\") {\n\t\t\t\treturn true, nil\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false, nil\n}", "func getIP(r *http.Request) string {\n\tvar addr string\n\n\tif fwd := r.Header.Get(xForwardedFor); fwd != \"\" {\n\t\t// Only grab the first (client) address. Note that '192.168.0.1,\n\t\t// 10.1.1.1' is a valid key for X-Forwarded-For where addresses after\n\t\t// the first may represent forwarding proxies earlier in the chain.\n\t\ts := strings.Index(fwd, \", \")\n\t\tif s == -1 {\n\t\t\ts = len(fwd)\n\t\t}\n\t\taddr = fwd[:s]\n\t} else if fwd := r.Header.Get(xRealIP); fwd != \"\" {\n\t\t// X-Real-IP should only contain one IP address (the client making the\n\t\t// request).\n\t\taddr = fwd\n\t} else if fwd := r.Header.Get(forwarded); fwd != \"\" {\n\t\t// match should contain at least two elements if the protocol was\n\t\t// specified in the Forwarded header. The first element will always be\n\t\t// the 'for=' capture, which we ignore. In the case of multiple IP\n\t\t// addresses (for=8.8.8.8, 8.8.4.4,172.16.1.20 is valid) we only\n\t\t// extract the first, which should be the client IP.\n\t\tif match := forRegex.FindStringSubmatch(fwd); len(match) > 1 {\n\t\t\t// IPv6 addresses in Forwarded headers are quoted-strings. We strip\n\t\t\t// these quotes.\n\t\t\taddr = strings.Trim(match[1], `\"`)\n\t\t}\n\t}\n\n\tif addr == \"\" {\n\t\treturn r.RemoteAddr\n\t}\n\treturn addr\n}" ]
[ "0.63308936", "0.63304776", "0.62865573", "0.6100806", "0.60891145", "0.60489625", "0.5988068", "0.5969013", "0.59549296", "0.5941177", "0.59268016", "0.59218574", "0.59127504", "0.5910385", "0.58939743", "0.5892218", "0.585198", "0.58493", "0.58442616", "0.58386356", "0.5836416", "0.58347845", "0.582397", "0.5799143", "0.5782274", "0.5780897", "0.5778225", "0.57629406", "0.57619447", "0.57595325", "0.57490975", "0.5739594", "0.572866", "0.5723335", "0.5709987", "0.5697399", "0.5693371", "0.56810457", "0.56805974", "0.567606", "0.5665388", "0.5661187", "0.56586385", "0.5649495", "0.564355", "0.5643118", "0.56385255", "0.5638148", "0.5622379", "0.56096137", "0.560062", "0.5595372", "0.5590709", "0.5580672", "0.5580171", "0.5578929", "0.5572979", "0.5572202", "0.55640256", "0.5541959", "0.5537191", "0.553285", "0.55316806", "0.5530837", "0.5529007", "0.55260676", "0.55245453", "0.55212826", "0.5517727", "0.55128664", "0.5511978", "0.55100656", "0.55035037", "0.54976857", "0.5492252", "0.5491767", "0.54910177", "0.5483991", "0.5481436", "0.54792655", "0.54761326", "0.54736656", "0.54729044", "0.5472163", "0.5471704", "0.54699886", "0.54617685", "0.5460089", "0.5459867", "0.5453779", "0.545037", "0.54467565", "0.54451567", "0.54433376", "0.5443134", "0.54413825", "0.5441313", "0.5440632", "0.54381806", "0.5433369" ]
0.7099065
0
Save it and make sure it shows up in new form
func saveConfigAndValidateNewFormat(t *testing.T, config *ConfigFile, homeFolder string) string { err := config.Save() if err != nil { t.Fatalf("Failed to save: %q", err) } buf, err := ioutil.ReadFile(filepath.Join(homeFolder, RootConfigFileName)) if !strings.Contains(string(buf), `"authConfig":`) { t.Fatalf("Should have save in new form: %s", string(buf)) } return string(buf) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *MakeRequestController) Save() {\n\tc.View.DisplaySaveView()\n}", "func saveHandler(w http.ResponseWriter, r *http.Request) {\r\n title := r.URL.Path[len(\"/save/\"):]\r\n body := r.FormValue(\"body\")\r\n p := &Page{Title: title, Body: []byte(body)}\r\n p.save()\r\n http.Redirect(w, r, \"/view/\"+title, http.StatusFound)\r\n}", "func Save() error {\n\treturn nil\n}", "func saveHandler(w http.ResponseWriter, r *http.Request, title string) {\n\tbody := r.FormValue(\"body\")\n\tp := &Page{Title: title, Body: []byte(body)}\n\terr := p.save()\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\thttp.Redirect(w, r, \"/view/\"+title, http.StatusFound)\n}", "func (p *Page) save(d *Dir) error {\n\tp.Sidebar = d.sidebar\n\tp.Items = d.pages\n\tfile, err := os.Create(p.Path)\n\n\tif (err != nil) {\n\t\treturn err\n\t}\n\n\tfmt.Printf(\"Create new page: %s\\n \\tby link:%s\\n\", p.Title, p.Path)\n\n\treturn p.render(file)\n}", "func handlerSave(w http.ResponseWriter, r *http.Request, title string) {\r\n\tbody := r.FormValue(\"body\")\r\n\tp := &Page{Title: title, Body: []byte(body)}\r\n\terr := p.save()\r\n\tif err != nil {\r\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\r\n\t\tos.Exit(1)\r\n\t}\r\n\thttp.Redirect(w, r, \"/view/\"+p.Title, http.StatusFound)\r\n}", "func handleSave(w http.ResponseWriter, r *http.Request, title string) {\n\tvar (\n\t\tbody = r.FormValue(\"body\")\n\t\tp = &page.Page{Title: title, Body: []byte(body)}\n\t)\n\tif err := p.Save(); err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\n\thttp.Redirect(w, r, pathView+title, http.StatusFound)\n\tlogInfo(p.Title, \"file saved succesfully\")\n}", "func Save() error {\n\treturn instance.Save()\n}", "func saveHandler(w http.ResponseWriter, r *http.Request, title string) {\n\tbody := r.FormValue(\"body\")\n\tp := &Page{Title: title, Body: []byte(body)}\n\terr := p.save()\n\tif err != nil {\n\t\tlog.Println(\"saveHandler() error: \", err)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\thttp.Redirect(w, r, \"/view/\"+title, http.StatusFound)\n}", "func saveHandler (w http.ResponseWriter, r *http.Request) {\n\n\t//on sauvegarde dans un fichier\n\tp := &PageTablature{Titre:r.FormValue(\"titre\"), Tab:[]byte(r.FormValue(\"sandbox\"))}\n\t\n\terr := p.save()\n\t\n\tif err != nil {\n\t\t//redirection vers page de création\n\t\tcreateHandler(w, r)\n\t}\n\n\ttabsHandler(w, r)\n}", "func (v *View) Save() {\n\t// If this is an empty buffer, ask for a filename\n\tif v.buf.path == \"\" {\n\t\tfilename, canceled := messenger.Prompt(\"Filename: \")\n\t\tif !canceled {\n\t\t\tv.buf.path = filename\n\t\t\tv.buf.name = filename\n\t\t} else {\n\t\t\treturn\n\t\t}\n\t}\n\terr := v.buf.Save()\n\tif err != nil {\n\t\tmessenger.Error(err.Error())\n\t} else {\n\t\tmessenger.Message(\"Saved \" + v.buf.path)\n\t}\n}", "func saveHandler(w http.ResponseWriter, r *http.Request) {\n\ttitle, err := getTitle(w, r)\n\tif err != nil {\n\t\treturn\n\t}\n\tbody := r.FormValue(\"body\")\t// Get the page content. It is of type string - we must convert it to []byte before it will fit into the Page struct.ß\n\tp := &Page{Title: title, Body: []byte(body)}\n\terr = p.save()\t// Write the data to a file\n\t// An error that occurs during p.save() will be reported to the user\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\thttp.Redirect(w, r, \"/view/\"+title, http.StatusFound)\n}", "func saveNote(w http.ResponseWriter, r *http.Request) {\n \n r.ParseForm()\n title := r.PostFormValue(\"title\")\n desc := r.PostFormValue(\"description\")\n created := time.Now()\n // create note instance based on form data\n note := Note{\n title,\n desc,\n created,\n }\n //increment id and add note to the data store map\n id++\n key := strconv.Itoa(id)\n noteStore[key] = note\n \n //redirect user\n http.Redirect(w, r, \"/\", 302)\n}", "func Store(w http.ResponseWriter, r *http.Request) {\n\tc := flight.Context(w, r)\n\n\t//submit_value := r.FormValue(\"sb\")\n\n\tif !c.FormValid(\"tittle\",\"issian\") {\n\t\tCreate(w, r)\n\t\treturn\n\t}\n\n\t// var publish string\n\t// if submit_value==\"save\"{\n\t// \tpublish = \"0\"\n\t// }else {\n\t// \tpublish = \"1\"\n\t// }\n\t// fmt.Println(publish)\n\n\t_, err := article.Create(c.DB, r.FormValue(\"tittle\"), r.FormValue(\"issian\"), r.FormValue(\"sb\"), c.UserID)\n\tif err != nil {\n\t\tc.FlashErrorGeneric(err)\n\t\tCreate(w, r)\n\t\treturn\n\t}\n\n\tc.FlashSuccess(\"Article added.\")\n\tc.Redirect(uri)\n}", "func (material *Material) Save() {\n\tDB.Set(\"Material\", material.ID, material)\n}", "func (s *saver) Save(survey models.Survey) {\n\ts.save <- survey\n}", "func (r *RadioStation) Save() error {\n\treturn nil\n}", "func (entry *EditLogEntry) Save() {\n\tDB.Set(\"EditLogEntry\", entry.ID, entry)\n}", "func saveHandler(w http.ResponseWriter, r *http.Request, title string) {\n\tingredients := r.FormValue(\"ingredients\")\n\tinstructions := r.FormValue(\"instructions\")\n\trecipeTitle := r.FormValue(\"recipeTitle\")\n\n\tfilename := convertTitleToFilename(recipeTitle)\n\n\tp := &Page{\n\t\tTitle: recipeTitle,\n\t\tFilename: filename,\n\t\tIngredients: template.HTML(ingredients),\n\t\tInstructions: template.HTML(instructions)}\n\n\terr := p.save()\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// If the filename is different than the title then we are renaming and\n\t// should remove the old file.\n\tif filename != title {\n\t\toldfile := filepath.Join(pagesDir, title+\".txt\")\n\n\t\t// Only proceed with the rename if the old file exists.\n\t\tif _, err := os.Stat(oldfile); err == nil {\n\t\t\tif err := os.Remove(oldfile); err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t}\n\t}\n\n\tupdateIndex()\n\thttp.Redirect(w, r, \"/view/\"+filename, http.StatusFound)\n}", "func saveEditedInfo(w http.ResponseWriter, r *http.Request, title string) {\n\tdescription := r.FormValue(\"description\")\n\ttoken := r.FormValue(\"CSRFToken\")\n\t// Get cookie from browser\n\tcookie, err := r.Cookie(\"V\")\n\tif err != nil {\n\t\tlog.Println(err)\n\t\thttp.Redirect(w, r, \"/loginError/\", http.StatusFound)\n\t\treturn\n\t}\n\tcookieValue := strings.TrimPrefix(cookie.Value, \"cookie=\")\n\toriginalPage, err := readProfile(cookieValue)\n\tif err != nil {\n\t\tlog.Println(\"cookie may expire and need to login again \", err)\n\t\thttp.Redirect(w, r, \"/loginError/\", http.StatusFound)\n\t\treturn\n\t}\n\t// Get the standard token to change the regular information\n\tclient := &http.Client{}\n\t// Change the information from preloaded information\n\tupdateInfo := PublicInfo{}\n\tupdateInfo.Username = originalPage.Username\n\tupdateInfo.Description = description\n\t// Json format transformation\n\tjsonData, err := json.Marshal(updateInfo)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\thttp.Redirect(w, r, \"/loginError/\", http.StatusFound)\n\t\treturn\n\t}\n\tData := string(jsonData)\n\tpayload := strings.NewReader(Data)\n\t// Send http request\n\tlink := \"http://localhost:8080/v1/accounts/@me?token=\" + token\n\trequest, err := http.NewRequest(\"PUT\", link, payload)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\thttp.Redirect(w, r, \"/loginError/\", http.StatusFound)\n\t\treturn\n\t}\n\trequest.Header.Add(\"Cookie\", cookieValue)\n\trequest.Header.Add(\"Content-Type\", \"application/json\")\n\t_, err = client.Do(request)\n\tclient.CloseIdleConnections()\n\tif err != nil {\n\t\thttp.Redirect(w, r, \"/loginError/\", http.StatusFound)\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\t// After edited it redirect to the private information page\n\thttp.Redirect(w, r, \"/privatePage/\", http.StatusFound)\n}", "func SaveFormData(form structs.Form) (structs.Form, error) {\n\tcollection := Client.Database(\"theveloper\").Collection(\"forms\")\n\tctx, _ := context.WithTimeout(context.Background(), 10*time.Second)\n\tform.ID = primitive.NewObjectID()\n\t//result, err := collection.InsertOne(ctx, form)\n\t_, err := collection.InsertOne(ctx, form)\n\tif err != nil {\n\t\treturn form, err\n\t}\n\n\treturn form, nil\n}", "func (p *Page) save() error {\n\tbody := fmt.Sprintf(\"<!-- Ingredients -->\\n%s\\n<!-- Instructions -->\\n%s\", p.Ingredients, p.Instructions)\n\treturn ioutil.WriteFile(filepath.Join(pagesDir, p.Filename+\".txt\"), []byte(body), 0600)\n}", "func (b *BlockCreator) save() error {\n\treturn persist.SaveJSON(settingsMetadata, b.persist, filepath.Join(b.persistDir, settingsFile))\n}", "func (env *Env) Save(res http.ResponseWriter, req *http.Request, title string) {\n\tenv.Log.V(1, \"beginning hanlding of Save.\")\n\ttitle = strings.Replace(strings.Title(title), \" \", \"_\", -1)\n\tbody := []byte(req.FormValue(\"body\"))\n\tpage := &webAppGo.Page{Title: title, Body: body}\n\terr := env.Cache.SaveToCache(page)\n\tif err != nil {\n\t\tenv.Log.V(1, \"notifying client that an internal error occured. Error is associated with Cache.SaveToCache.\")\n\t\thttp.Error(res, err.Error(), 500)\n\t}\n\terr = env.DB.SavePage(page)\n\tif err != nil {\n\t\tenv.Log.V(1, \"notifying client that an internal error occured. Error is associated with Cache.SavePage.\")\n\t\thttp.Error(res, err.Error(), 500)\n\t}\n\tenv.Log.V(1, \"The requested new page was successully saved, redirecting client to /view/PageTitle.\")\n\thttp.Redirect(res, req, \"/view/\"+title, http.StatusFound)\n}", "func (gl GroceryList) Save() error {\n\tgl.mu.Lock()\n\terr := ioutil.WriteFile(\"./resources/grocery-list.txt\", gl.Body, os.ModeDevice)\n\tgl.mu.Unlock()\n\treturn err\n}", "func (p *Page) save() error {\r\n\tfilename := p.Title\r\n\t//writes data to a file named by filename, the 0600 indicates that the file should be created with\r\n\t//read and write permissions for the user\r\n\treturn ioutil.WriteFile(filename, p.Body, 0600)\r\n}", "func (p *Page) save() error {\n\t// Save to database\n\treturn pages.Insert(p)\n}", "func (app * application) createSnippetForm(w http.ResponseWriter, r *http.Request){\n\tapp.render(w, r, \"create.page.tmpl\",nil)\n}", "func (v *Vessel) Save() error {\n\tdb := adaptors.DBConnector()\n\tdefer db.Close()\n\n\terr := db.Table(\"vessels\").Create(&Vessel{\n\t\tv.ID,\n\t\tv.Name,\n\t\tv.Beam,\n\t\tv.LOA,\n\t\tv.Draft,\n\t\tv.Status,\n\t}).Error\n\n\treturn err\n}", "func (flags *Vault) save(log *logging.Logger) (bool, error) {\n\tchanges := 0\n\treturn (changes > 0), nil\n}", "func (g *GamePlayerHand) Save() error {\n\tif g.ID == 0 {\n\t\treturn g.insert()\n\t}\n\n\treturn g.update()\n}", "func Save() {\n\tenforcer.SavePolicy()\n}", "func (company *Company) Save() {\n\tDB.Set(\"Company\", company.ID, company)\n}", "func (t *Title) Save() error {\n\tvar op = dbi.DB.Operation()\n\top.Dbg = dbi.Debug\n\treturn t.SaveOp(op)\n}", "func save(novel *Novel) {\n\t//if novel exist history\n\ttag := false\n\tfor index, historyNovel := range historyNovels {\n\t\tif historyNovel.Name == novel.Name {\n\t\t\thistoryNovels[index] = novel\n\t\t\ttag = true\n\t\t}\n\t}\n\tif !tag {\n\t\thistoryNovels = append(historyNovels, novel)\n\t}\n\tSaveHistory(historyNovels)\n\tfmt.Println(\"Save complete...\")\n}", "func (builder *Builder) Save() *Builder {\n\treturn builder.With(Save)\n}", "func (c *Container) save() error {\n\tif err := c.runtime.state.SaveContainer(c); err != nil {\n\t\treturn errors.Wrapf(err, \"error saving container %s state\", c.ID())\n\t}\n\treturn nil\n}", "func (p *Page) save() error {\n\tfilename := p.Title + \".txt\"\n\treturn ioutil.WriteFile(filename, p.Body, 0600)\t// 0600 = r-w permissions for current user only\n}", "func (p *Page) save() error {\r\n\tfilename := p.Title + \".txt\"\r\n\treturn ioutil.WriteFile(filename, p.Body, 0600)\r\n}", "func (page *Page) save() error {\n\tfilename := page.Title + \".txt\"\n\treturn ioutil.WriteFile(filename, page.Body, 0600)\n}", "func (p *Page) save() error {\n\tfilename := \"data/\" + p.Title + \".txt\"\n\treturn ioutil.WriteFile(filename, p.Body, 0600)\n}", "func (p *Page) save() error {\n\tfilename := p.Title + \".txt\"\n\treturn ioutil.WriteFile(filename, p.Body, 0600)\n}", "func (p *Page) save() error {\n filename := p.Title + \".txt\"\n return ioutil.WriteFile(filename, p.Body, 0600)\n}", "func (p *Page) save() error {\n\tfilename := \"./pages/\" + p.Title + \".txt\"\n\treturn ioutil.WriteFile(filename, p.Body, 0600)\n}", "func saveHandler(w http.ResponseWriter, r *http.Request, title string) {\n body := r.FormValue(\"body\")\n p := &Page{Title: title, Body: body}\n _, err := db.Exec(\"UPDATE pages SET body = $1 WHERE title = $2\", p.Body, p.Title)\n if err != nil {\n http.Error(w, err.Error(), http.StatusInternalServerError)\n }\n http.Redirect(w, r, \"/view/\"+title, http.StatusFound)\n}", "func (app *service) Save(genesis Genesis) error {\n\tjs, err := app.adapter.ToJSON(genesis)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn app.fileService.Save(app.fileNameWithExt, js)\n}", "func (app *service) Save(genesis Genesis) error {\n\t_, err := app.repository.Retrieve()\n\tif err == nil {\n\t\treturn errors.New(\"there is already a Genesis instance\")\n\t}\n\n\tbill := genesis.Bill()\n\terr = app.billService.Save(bill)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttrGenesis, err := app.adapter.ToTransfer(genesis)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn app.trService.Save(trGenesis)\n}", "func (a *App) save() {\n\ta.TodoStore.Save(a.TodoList.Data)\n\tif a.TodoList.IsSynced {\n\t\ta.EventLogger.ProcessEvents()\n\n\t\tsynchronizer := NewQuietSynchronizer()\n\t\tsynchronizer.ExecSyncInBackground()\n\t}\n}", "func ActivateSave(r *Root, e *Editor) {\n\tr.a = &SaveAndLoadEditor{\n\t\te: e,\n\t\tt: &Typer{\n\t\t\ttyp: true,\n\t\t\tPlaceholder: \"\",\n\t\t\tC: &e.c,\n\t\t},\n\t\tload: false,\n\t}\n}", "func (c *Contractor) save() error {\n\treturn c.persist.save(c.persistData())\n}", "func (oee *OtxEpubEpub) Save(db XODB) error {\n\tif oee.Exists() {\n\t\treturn oee.Update(db)\n\t}\n\n\treturn oee.Insert(db)\n}", "func (hr *HelpRequest) Save(db XODB) error {\n\tif hr.Exists() {\n\t\treturn hr.Update(db)\n\t}\n\n\treturn hr.Insert(db)\n}", "func (d *DXF) Save() error {\n\terr := d.drawing.SaveAs(d.name)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (hd *HelpDoc) Save(ctx context.Context) error {\n\tif hd.Exists() {\n\t\treturn hd.Update(ctx)\n\t}\n\n\treturn hd.Insert(ctx)\n}", "func (s *siteData) save() error {\n\tvar err error\n\tif err = db.open(); err != nil {\n\t\treturn err\n\t}\n\tdefer db.close()\n\n\tsiteConf := []string{\"site\"}\n\tif err = db.bolt.SetValue(siteConf, \"title\", s.Title); err != nil {\n\t\treturn err\n\t}\n\tif err = db.bolt.SetInt(siteConf, \"port\", s.Port); err != nil {\n\t\treturn err\n\t}\n\tif err = db.bolt.SetValue(siteConf, \"session-name\", s.SessionName); err != nil {\n\t\treturn err\n\t}\n\treturn db.bolt.SetValue(siteConf, \"server-dir\", s.ServerDir)\n}", "func (l *localLinker) Save(ctx context.Context, req *pbd.SaveRequest) (*pbd.Empty, error) {\n\tl.store[req.Key] = req.Value\n\treturn &pbd.Empty{}, nil\n}", "func SavePagenote(w http.ResponseWriter, req *http.Request) {\n\tdefer log.WithTrace().Info(\"SavePagenote...\")\n\tsecurity.EnableCORS(w)\n\tif (isHTTPOption(req)) {\n\t\treturn\n\t}\n\tif !requirePost(w, req) {\n\t\tlog.Warn(\"SavePagenote: invalid http method...\")\n\t\treturn\n\t}\n\tif !requireAuth(w, req) {\n\t\tlog.Warn(\"SavePagenote: not authorized...\")\n\t\treturn\n\t}\n\tpn, err := parseNewNotesRequest(req)\n\tif err != nil {\n\t\tlog.Warn(\"cannot parse request, error: \", err)\n\t\tvar errMsg string\n\t\tif conf.IsDebug() {\n\t\t\terrMsg = fmt.Sprintln(\"cannot parse request, error: \", err)\n\t\t} else {\n\t\t\terrMsg = \"cannot parse request\"\n\t\t}\n\t\thttp.Error(w, errMsg, http.StatusBadRequest)\n\t\treturn\n\t}\n\tidList, err := newNotes(pn)\n\tif err != nil {\n\t\tlog.Error(\"savePagenote: \", err)\n\t}\n\twriteRespMessage(w, nil, idList)\n}", "func (app *application) createSnippetForm(w http.ResponseWriter, r *http.Request) {\n\n\tapp.render(w, r, \"create.page.tmpl\", &templateData{\n\t\tForm: forms.New(nil),\n\t})\n\n}", "func (this *SettingsRouter) ProfileSave() {\n\tthis.TplNames = \"settings/profile.html\"\n\n\tif this.CheckLoginRedirect() {\n\t\treturn\n\t}\n\n\taction := this.GetString(\"action\")\n\n\tif this.IsAjax() {\n\t\tswitch action {\n\t\tcase \"send-verify-email\":\n\t\t\tif this.User.IsActive {\n\t\t\t\tthis.Data[\"json\"] = false\n\t\t\t} else {\n\t\t\t\tauth.SendActiveMail(this.Locale, &this.User)\n\t\t\t\tthis.Data[\"json\"] = true\n\t\t\t}\n\n\t\t\tthis.ServeJson()\n\t\t\treturn\n\t\t}\n\t\treturn\n\t}\n\n\tprofileForm := auth.ProfileForm{Locale: this.Locale}\n\tprofileForm.SetFromUser(&this.User)\n\n\tpwdForm := auth.PasswordForm{User: &this.User}\n\n\tthis.Data[\"Form\"] = profileForm\n\n\tswitch action {\n\tcase \"save-profile\":\n\t\tif this.ValidFormSets(&profileForm) {\n\t\t\tif err := profileForm.SaveUserProfile(&this.User); err != nil {\n\t\t\t\tbeego.Error(\"ProfileSave: save-profile\", err)\n\t\t\t}\n\t\t\tthis.FlashRedirect(\"/settings/profile\", 302, \"ProfileSave\")\n\t\t\treturn\n\t\t}\n\n\tcase \"change-password\":\n\t\tif this.ValidFormSets(&pwdForm) {\n\t\t\t// verify success and save new password\n\t\t\tif err := auth.SaveNewPassword(&this.User, pwdForm.Password); err == nil {\n\t\t\t\tthis.FlashRedirect(\"/settings/profile\", 302, \"PasswordSave\")\n\t\t\t\treturn\n\t\t\t} else {\n\t\t\t\tbeego.Error(\"ProfileSave: change-password\", err)\n\t\t\t}\n\t\t}\n\n\tdefault:\n\t\tthis.Redirect(\"/settings/profile\", 302)\n\t\treturn\n\t}\n\n\tif action != \"save-profile\" {\n\t\tthis.SetFormSets(&profileForm)\n\t}\n\tif action != \"change-password\" {\n\t\tthis.SetFormSets(&pwdForm)\n\t}\n}", "func (lm *LocalMeta) Save(pos mysql.Position, gs gtid.Set) error {\n\tlm.Lock()\n\tdefer lm.Unlock()\n\n\tlm.BinLogName = pos.Name\n\tlm.BinLogPos = pos.Pos\n\tif gs == nil {\n\t\tlm.BinlogGTID = \"\"\n\t} else {\n\t\tlm.BinlogGTID = gs.String()\n\t\tlm.gset = gs\n\t}\n\n\tlm.dirty = true\n\treturn nil\n}", "func (m *Account) SaveForm(form form.Account) error {\n\tdb := Db()\n\n\tif err := deepcopier.Copy(m).From(form); err != nil {\n\t\treturn err\n\t}\n\n\tif m.AccType != string(remote.ServiceWebDAV) {\n\t\t// TODO: Only WebDAV supported at the moment\n\t\tm.AccShare = false\n\t\tm.AccSync = false\n\t}\n\n\t// Set defaults\n\tif m.SharePath == \"\" {\n\t\tm.SharePath = \"/\"\n\t}\n\n\tif m.SyncPath == \"\" {\n\t\tm.SyncPath = \"/\"\n\t}\n\n\t// Refresh after performing changes\n\tif m.AccSync && m.SyncStatus == AccountSyncStatusSynced {\n\t\tm.SyncStatus = AccountSyncStatusRefresh\n\t}\n\n\treturn db.Save(m).Error\n}", "func (gist *Gist) Save() {\n\t_, err := Db.NamedExec(`\n\t\tUPDATE gists SET title = :title,\n\t\tcontent = :content, public = :public, updated_at = :updated_at WHERE id = :id`, gist,\n\t)\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func (s *Surface) Save() {\n\ts.Ctx.Call(\"save\")\n}", "func (c *Control) Save(db models.DBInterface) error {\n\tif c.existsInDB {\n\t\treturn c.update(db)\n\t}\n\n\treturn c.insert(db)\n}", "func (me TxsdShow) IsNew() bool { return me == \"new\" }", "func (s *Signup) Save(db XODB) error {\n\tif s.Exists() {\n\t\treturn s.Update(db)\n\t}\n\n\treturn s.Insert(db)\n}", "func (dcc *DoorCompiledContent) Save(db XODB) error {\n\tif dcc.Exists() {\n\t\treturn dcc.Update(db)\n\t}\n\n\treturn dcc.Insert(db)\n}", "func (payment *PayPalPayment) Save() {\n\tDB.Set(\"PayPalPayment\", payment.ID, payment)\n}", "func (f *Fermentor) Save(db *sqlx.DB) error {\n\tif f.Id != nil && *f.Id != 0 {\n\t\treturn UpdateFermentor(db, f)\n\t} else {\n\t\treturn InsertFermentor(db, f)\n\t}\n}", "func Save() {\n\tgo db.save()\n}", "func (app *service) Save(state State) error {\n\tjs, err := app.adapter.ToJSON(state)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tchainHash := state.Chain()\n\tindex := state.Height()\n\tpath := filePath(chainHash, index)\n\treturn app.fileService.Save(path, js)\n}", "func (p *PasswordStruct) Save() error {\n\terr := ioutil.WriteFile(path, p.hash, 0700)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (this *BaseController) FormOnceCreate(args ...bool) {\n var value string\n var creat bool\n creat = len(args) > 0 && args[0]\n if !creat {\n if v, ok := this.GetSession(\"form_once\").(string); ok && v != \"\" {\n value = v\n } else {\n creat = true\n }\n }\n if creat {\n value = utils.GetRandomString(10)\n this.SetSession(\"form_once\", value)\n }\n this.Data[\"once_token\"] = value\n this.Data[\"once_html\"] = template.HTML(`<input type=\"hidden\" name=\"_once\" value=\"` + value + `\">`)\n}", "func save() {\n\tnaksuIniPath := getIniFilePath()\n\n\terr := cfg.SaveTo(naksuIniPath)\n\tif err != nil {\n\t\tlog.Error(\"%s save failed: %v\", naksuIniPath, err)\n\t}\n}", "func (s store) Save() {\n\ts.writeToDisk()\n}", "func (form *Form) Show() {\n\tform.visible = true\n}", "func (file *File) Save() {\n\tif file.autoFmt {\n\t\terr := file.Fmt()\n\t\tif err != nil {\n\t\t\tfile.NotifyUser(err.Error())\n\t\t}\n\t}\n\tfile.SnapshotSaved()\n\tcontents := []byte(file.ToString())\n\terr := ioutil.WriteFile(file.Name, contents, file.fileMode)\n\tif err != nil {\n\t\tfile.NotifyUser(\"Save Failed: \" + err.Error())\n\t} else {\n\t\tfile.savedBuffer.ReplaceBuffer(file.buffer.DeepDup())\n\t\tfile.NotifyUser(\"Saved.\")\n\t\tfile.modTime = time.Now()\n\t\tfile.md5sum = md5.Sum(contents)\n\t}\n}", "func (p *Entry) Save() (err error) {\n\tfm, err := frontmatter.Marshal(&p)\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar perm os.FileMode = 0666\n\tif err = ioutil.WriteFile(p.Path, append(fm, p.Body...), perm); err != nil {\n\t\tfmt.Println(\"Dump:\")\n\t\tfmt.Println(string(fm))\n\t\tfmt.Println(string(p.Body))\n\t}\n\treturn err\n}", "func (ps *VacancySkill) Save() bool {\n\tvar err error\n\tvar action string\n\n\tif ps.ID == 0 {\n\t\t_, err = DB.Insert(ps)\n\t\taction = \"create\"\n\t} else {\n\t\t_, err = DB.Update(ps)\n\t\taction = \"update\"\n\t}\n\treturn utils.ProcessError(err, action+\" a vacancy`s skill\")\n}", "func Store(w http.ResponseWriter, r *http.Request) {\n\tc := flight.Context(w, r)\n\n\tif !c.FormValid(\"name\") {\n\t\tCreate(w, r)\n\t\treturn\n\t}\n\n\t_, err := summary.Create(c.DB, r.FormValue(\"name\"))\n\tif err != nil {\n\t\tc.FlashErrorGeneric(err)\n\t\tCreate(w, r)\n\t\treturn\n\t}\n\n\tc.FlashSuccess(\"Item added.\")\n\tc.Redirect(uri)\n}", "func (p *Command) Save() bool {\n\treturn p.saveInfo(p)\n}", "func (reajuste *Reajuste) SaveReajuste(db *gorm.DB) (*Reajuste, error) {\n\n\t//\tAdiciona um novo elemento ao banco de dados\n\terr := db.Debug().Create(&reajuste).Error\n\tif err != nil {\n\t\treturn &Reajuste{}, err\n\t}\n\n\treturn reajuste, err\n}", "func (bc *BengkelCreate) Save(ctx context.Context) (*Bengkel, error) {\n\tif bc.kode_bengkel == nil {\n\t\treturn nil, errors.New(\"ent: missing required field \\\"kode_bengkel\\\"\")\n\t}\n\tif bc.nama_bengkel == nil {\n\t\tv := bengkel.DefaultNamaBengkel\n\t\tbc.nama_bengkel = &v\n\t}\n\tif err := bengkel.NamaBengkelValidator(*bc.nama_bengkel); err != nil {\n\t\treturn nil, fmt.Errorf(\"ent: validator failed for field \\\"nama_bengkel\\\": %v\", err)\n\t}\n\tif bc.alamat_bengkel == nil {\n\t\treturn nil, errors.New(\"ent: missing required field \\\"alamat_bengkel\\\"\")\n\t}\n\tif err := bengkel.AlamatBengkelValidator(*bc.alamat_bengkel); err != nil {\n\t\treturn nil, fmt.Errorf(\"ent: validator failed for field \\\"alamat_bengkel\\\": %v\", err)\n\t}\n\tif bc.latitude == nil {\n\t\treturn nil, errors.New(\"ent: missing required field \\\"latitude\\\"\")\n\t}\n\tif bc.longitude == nil {\n\t\treturn nil, errors.New(\"ent: missing required field \\\"longitude\\\"\")\n\t}\n\tif bc.phonenumber == nil {\n\t\treturn nil, errors.New(\"ent: missing required field \\\"phonenumber\\\"\")\n\t}\n\treturn bc.sqlSave(ctx)\n}", "func (s *ServiceState) save() {\n\tlog.Lvl3(\"Saving service\")\n\tb, err := network.Marshal(s.Storage)\n\tif err != nil {\n\t\tlog.Error(\"Couldn't marshal service:\", err)\n\t} else {\n\t\terr = ioutil.WriteFile(s.path+\"/prifi.bin\", b, 0660)\n\t\tif err != nil {\n\t\t\tlog.Error(\"Couldn't save file:\", err)\n\t\t}\n\t}\n}", "func Save(r *http.Request, w http.ResponseWriter) error {\n\n}", "func (viperConfig *Configurator) Save(sbConfig *config.SBConfiguration) error {\n\tviperConfig.viper.Set(\"url\", sbConfig.URL)\n\tviperConfig.viper.Set(\"authorization\", sbConfig.Authorization)\n\tviperConfig.viper.Set(\"room\", sbConfig.Room)\n\n\tif err := viperConfig.viper.WriteConfig(); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (c *Cliente) Save() error {\n\tif c.IDDueno == 0 {\n\t\treturn c.create()\n\t}\n\treturn c.update()\n}", "func (v *Voto) Save() error {\n\tif v.ID == 0 {\n\t\treturn v.insert()\n\t}\n\treturn v.update()\n}", "func (n *mockAgent) save() (s persistapi.AgentState) {\n\treturn\n}", "func (o *VRS) Save() *bambou.Error {\n\n\treturn bambou.CurrentSession().SaveEntity(o)\n}", "func (ctl *taskController) Save() error {\n\treturn ctl.saveImpl(true)\n}", "func (p *BuildCommand) Save() bool {\n\treturn p.saveInfo(p)\n}", "func (me TxsdShow) IsNew() bool { return me.String() == \"new\" }", "func (us *UpdateService) save() error {\n\tus.Updated = time.Now()\n\tcontent, _ := json.Marshal(us)\n\tkey := fmt.Sprintf(\"%s/%s/%s/%s/%s\", us.Proto, us.Version, us.Namespace, us.Repository, defaultMetaFileName)\n\terr := us.store.Put(key, content)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif us.km != nil {\n\t\t// write sign file, don't popup error even fail to saveSign\n\t\tus.saveSign(content)\n\t}\n\n\treturn nil\n}", "func (modulo *Modulo) SaveModulo(db *gorm.DB) (*Modulo, error) {\n\n\t//\tAdiciona um novo elemento no banco de dados\n\terr := db.Debug().Create(&modulo).Error\n\tif err != nil {\n\t\treturn &Modulo{}, err\n\t}\n\n\treturn modulo, err\n}", "func (m *Mirror) save(link *url.URL, page *html.Node) {\n\tpath := m.buildLocalPath(link)\n\tdir := filepath.Dir(path)\n\tif err := os.MkdirAll(dir, 0777); err != nil {\n\t\tlog.Fatalf(\"creating dir %q: %v\", dir, err)\n\t}\n\n\tfile, err := os.Create(path)\n\tif err != nil {\n\t\tlog.Fatalf(\"creating file %q: %v\", path, err)\n\t}\n\tdefer file.Close()\n\n\terr = html.Render(file, page)\n\tif err != nil {\n\t\tlog.Fatalf(\"copying to %q: %v\", path, err)\n\t}\n}", "func SaveCurrentDesk(ctx context.Context, ac *uiauto.Context, savedDeskType SavedDeskType, savedDeskName string) error {\n\tvar saveDeskButton *nodewith.Finder\n\tvar savedDeskGridView *nodewith.Finder\n\tif savedDeskType == Template {\n\t\tsaveDeskButton = nodewith.ClassName(\"SavedDeskSaveDeskButton\").Nth(0)\n\t\tsavedDeskGridView = nodewith.ClassName(\"SavedDeskGridView\").Nth(0)\n\t} else if savedDeskType == SaveAndRecall {\n\t\tsaveDeskButton = nodewith.ClassName(\"SavedDeskSaveDeskButton\").Nth(1)\n\t\tsavedDeskGridView = nodewith.ClassName(\"SavedDeskGridView\").Nth(1)\n\t} else {\n\t\treturn errors.New(\"unknown savedDeskType, must be `kTemplate' or 'kSaveAndRecall'\")\n\t}\n\n\t// Save a desk.\n\tif err := uiauto.Combine(\n\t\t\"save a desk\",\n\t\tac.DoDefault(saveDeskButton),\n\t\t// Wait for the saved desk grid to show up.\n\t\tac.WaitUntilExists(savedDeskGridView),\n\t)(ctx); err != nil {\n\t\treturn errors.Wrap(err, \"failed to save a desk\")\n\t}\n\n\t// Type savedDeskName and press \"Enter\".\n\tkb, err := input.Keyboard(ctx)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"cannot create keyboard\")\n\t}\n\tdefer kb.Close()\n\tif err := kb.Type(ctx, savedDeskName); err != nil {\n\t\treturn errors.Wrapf(err, \"cannot type %q: \", savedDeskName)\n\t}\n\tif err := ac.WithInterval(2*time.Second).WaitUntilNoEvent(nodewith.Root(), event.LocationChanged)(ctx); err != nil {\n\t\treturn errors.Wrap(err, \"failed to wait for typing animation to be completed\")\n\t}\n\tif err := kb.Accel(ctx, \"Enter\"); err != nil {\n\t\treturn errors.Wrap(err, \"cannot press 'Enter'\")\n\t}\n\tif err := ac.WithInterval(2*time.Second).WaitUntilNoEvent(nodewith.Root(), event.LocationChanged)(ctx); err != nil {\n\t\treturn errors.Wrap(err, \"failed to wait for exit name nudge animation to be completed\")\n\t}\n\treturn nil\n}", "func (m *Message) Save() error {\n\treturn globalMessage.Set(m)\n}", "func (a *AppConf) Save(c LocalConf) (err error) {\n\terr = a.cc.Save(&c)\n\treturn\n}", "func (p *ProfileCommand) Save() bool {\n\treturn p.saveInfo(p)\n}", "func addSaveButton(isRegistered bool) *tgbotapi.InlineKeyboardMarkup {\n\n\t// Hide buttons if user is not registered\n\tif !isRegistered {\n\t\treturn nil\n\t}\n\treturn callback.AddActions([]int{callback.SaveAction})\n}" ]
[ "0.5938537", "0.57770675", "0.57358116", "0.56519854", "0.5645757", "0.56110734", "0.5565139", "0.556001", "0.55296665", "0.5515979", "0.5514796", "0.55080813", "0.5465128", "0.5440122", "0.5385621", "0.5378106", "0.5364931", "0.5349868", "0.5348707", "0.53369", "0.53316015", "0.52977157", "0.5291609", "0.5269667", "0.5235498", "0.5228672", "0.52268857", "0.52033424", "0.5195087", "0.5192441", "0.51815534", "0.51747286", "0.5171002", "0.5095721", "0.50817496", "0.507974", "0.5076843", "0.50711966", "0.5067111", "0.50630224", "0.5062795", "0.506227", "0.5058258", "0.5057546", "0.5052332", "0.5045463", "0.5041534", "0.50371087", "0.50284374", "0.5023837", "0.500823", "0.50022435", "0.49921194", "0.49774218", "0.4974253", "0.49739212", "0.49690962", "0.49672642", "0.4965809", "0.4962467", "0.49537256", "0.49465743", "0.4943874", "0.49430928", "0.4940912", "0.4940627", "0.49273312", "0.49222314", "0.49002412", "0.48986045", "0.4896303", "0.48952487", "0.48937067", "0.48919076", "0.48710978", "0.48640794", "0.4860179", "0.48566785", "0.48524415", "0.48517323", "0.48488444", "0.4844748", "0.4843652", "0.48382315", "0.4835305", "0.48322776", "0.48318875", "0.48224738", "0.4821973", "0.48183885", "0.4808595", "0.48005968", "0.47895744", "0.4786226", "0.47785142", "0.47779644", "0.47772393", "0.47745895", "0.4772064", "0.47686368", "0.47640726" ]
0.0
-1
Version returns package version
func Version() string { return "0.3.0" }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Version() string {\n\treturn version\n}", "func Version() string {\n\treturn version\n}", "func Version() string {\n\treturn version\n}", "func Version() string {\n\treturn version\n}", "func Version() string {\n\treturn version\n}", "func Version() string {\n\treturn version\n}", "func Version() string {\n\treturn version\n}", "func Version() string {\n\treturn version\n}", "func Version() (version string) {\n\treturn GetVersion()\n}", "func (p *Package) PkgVersion() string { return p.Version }", "func Version() string {\n\treturn versionNumber\n}", "func Version() string {\n\treturn getData().Version\n}", "func Version() string {\n\treturn libs.Version()\n}", "func Version() string {\n\treturn \"0.1.0\"\n}", "func Version() string {\r\n\tonce.Do(func() {\r\n\t\tsemver := fmt.Sprintf(\"%d.%d.%d\", major, minor, patch)\r\n\t\tverBuilder := bytes.NewBufferString(semver)\r\n\t\tif tag != \"\" && tag != \"-\" {\r\n\t\t\tupdated := strings.TrimPrefix(tag, \"-\")\r\n\t\t\t_, err := verBuilder.WriteString(\"-\" + updated)\r\n\t\t\tif err == nil {\r\n\t\t\t\tverBuilder = bytes.NewBufferString(semver)\r\n\t\t\t}\r\n\t\t}\r\n\t\tversion = verBuilder.String()\r\n\t})\r\n\treturn version\r\n}", "func Version() string {\n\treturn \"0.1.1\"\n}", "func Version() string {\n\treturn \"0.1.1\"\n}", "func Version() string {\n\t// TODO: Implement version tracking\n\treturn \"0.0.1\"\n}", "func Version() string {\n\tb, err := exec.Command(\"go\", \"version\").CombinedOutput()\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\ttoken := strings.Split(string(b), \" \")\n\tif strings.HasPrefix(token[2], \"go\") {\n\t\treturn token[2]\n\t}\n\tif !strings.HasPrefix(token[2], \"devel\") {\n\t\tpanic(\"Can not detect go version\")\n\t}\n\n\td := strings.Join(token[4:len(token)-1], \" \")\n\tt0, err := time.Parse(`Mon Jan _2 15:04:05 2006 -0700`, d)\n\tif err != nil {\n\t\tpanic(\"Can not detect go version\")\n\t}\n\tfor i, v := range vers {\n\t\tt1, err := time.Parse(`2006-01-2 15:04:05 -0700`, v[0])\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif t1.After(t0) {\n\t\t\treturn vers[i-1][1]\n\t\t}\n\t}\n\treturn vers[len(vers)-1][1]\n}", "func Version() string {\n\treturn buildVersion\n}", "func Version() string {\n\treturn runtime.Version()\n}", "func Version() string {\n\treturn \"1.0.6\"\n}", "func (pr LocalPackageReference) Version() string {\n\treturn pr.version\n}", "func GetVersion() string {\n\treturn version\n}", "func GetVersion() string {\n\treturn version\n}", "func Version() string {\n\treturn \"0.0.0\"\n}", "func Version() string {\n\treturn \"0.0.0\"\n}", "func Version() string {\n\tapi := C.Create()\n\tdefer C.Free(api)\n\tversion := C.Version(api)\n\treturn C.GoString(version)\n}", "func Version() string { return hs.Version() }", "func GetVersion() string {\n\treturn VersionString\n}", "func (c *CWebP) Version() (string, error) {\n\treturn version(c.BinWrapper)\n}", "func GetVersion() string {\n\treturn __VERSION__\n}", "func Version() (string, error) {\n\treturn makeRequest(\"version\")\n}", "func Version() string {\n\tif len(version) == 0 {\n\t\treturn \"UNKNOWN_VERSION\"\n\t}\n\treturn version\n}", "func (a *App) Version() string { return a.opts.version }", "func GetVersion() string {\n\treturn version.GetVersion()\n}", "func GetVersion() string {\n\treturn Version\n}", "func GetVersion() string {\n\treturn Version\n}", "func Version() string {\n\treturn \"0.2.0\"\n}", "func Version(ctx context.Context, args values.Object) (values.Value, error) {\n\tbi, ok := readBuildInfo()\n\tif !ok {\n\t\treturn nil, errBuildInfoNotPresent\n\t}\n\n\t// Find the module in the build info.\n\tvar m debug.Module\n\tif bi.Main.Path == modulePath {\n\t\tm = bi.Main\n\t} else {\n\t\tfor _, dep := range bi.Deps {\n\t\t\tif dep.Path == modulePath {\n\t\t\t\tm = *dep\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\t// Retrieve the version from the module.\n\tv := m.Version\n\tif m.Replace != nil {\n\t\t// If the module has been replaced, take the version from it.\n\t\tv = m.Replace.Version\n\t}\n\treturn values.NewString(v), nil\n}", "func pkgModVersion(dirname string) int64 {\n\tif match := vxMod.FindStringSubmatch(dirname); len(match) > 0 {\n\t\tif majorVer, err := strconv.ParseInt(match[1], 10, 32); err != nil {\n\t\t\tlog.Errorf(\"keh %v\", err)\n\t\t\tos.Exit(1)\n\t\t} else {\n\t\t\treturn majorVer\n\t\t}\n\t}\n\treturn 1\n}", "func GetVersion() string {\n\n\tcwd, _ := os.Getwd()\n\tcurrentFolderPathList := strings.Split(cwd, \"/\")\n\tlenFolder := len(currentFolderPathList)\n\tcurrFolder := currentFolderPathList[lenFolder-1]\n\n\tversionInformation := strings.Split(currFolder, \"-\")\n\n\t// In case we are not executing in the install directory, return\n\t// the version present in versionMetadata.json.\n\tif len(versionInformation) < 3 {\n\n\t\tviper.SetConfigName(\"version_metadata.json\")\n\t\tviper.SetConfigType(\"json\")\n\t\tviper.AddConfigPath(\".\")\n\t\terr := viper.ReadInConfig()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tversionNumber := fmt.Sprint(viper.Get(\"version_number\"))\n\t\tbuildNumber := fmt.Sprint(viper.Get(\"build_number\"))\n\n\t\tversion := versionNumber + \"-\" + buildNumber\n\n\t\treturn version\n\n\t}\n\n\tversionNumber := versionInformation[1]\n\tbuildNumber := versionInformation[2]\n\n\tversion := versionNumber + \"-\" + buildNumber\n\n\treturn version\n}", "func (k *Keybase) version() string {\n\tcmdOut, err := k.Exec(\"version\", \"-S\", \"-f\", \"s\")\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\n\treturn string(cmdOut)\n}", "func Version(frame wdte.Frame, args ...wdte.Func) wdte.Func {\n\tframe = frame.Sub(\"version\")\n\n\tinfo, ok := debug.ReadBuildInfo()\n\tif !ok {\n\t\treturn wdte.Error{\n\t\t\tErr: ErrNoBuildInfo,\n\t\t\tFrame: frame,\n\t\t}\n\t}\n\n\tfor _, dep := range info.Deps {\n\t\tif dep.Path != \"github.com/DeedleFake/wdte\" {\n\t\t\tcontinue\n\t\t}\n\n\t\treturn wdte.String(dep.Version)\n\t}\n\n\treturn wdte.Error{\n\t\tErr: ErrDepNotFound,\n\t\tFrame: frame,\n\t}\n}", "func (svc *Compiler) Version() string {\n\tval, err := svc.ctx.RunScript(\"svelte.VERSION\", \"version_call\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn val.String()\n}", "func Version() string {\n\treturn \"0.4.0\"\n}", "func (b *Binary) Version() string {\n\treturn b.version\n}", "func Version() string {\n\treturn \"0.7.0\"\n}", "func (_PlasmaFramework *PlasmaFrameworkCaller) Version(opts *bind.CallOpts) (string, error) {\n\tvar (\n\t\tret0 = new(string)\n\t)\n\tout := ret0\n\terr := _PlasmaFramework.contract.Call(opts, out, \"version\")\n\treturn *ret0, err\n}", "func (mgr *Manager) Version() string {\n\treturn mgr.version\n}", "func getVersion() string {\n\tif metadata == \"\" {\n\t\treturn version\n\t}\n\treturn version + \"-\" + metadata\n}", "func Version() string {\n\treturn \"0.12.0\"\n}", "func Version(am string) (string, error) {\n\ts, err := getStatus(am)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tinfo := s.VersionInfo\n\treturn fmt.Sprintf(\"%s (branch: %s, rev: %s)\", *info.Version, *info.Branch, *info.Revision), nil\n}", "func (c *Cron) GetVersion() string { return c.Version }", "func (r *Rkt) Version() (string, error) {\n\tver, err := r.Runner.CombinedOutput(\"rkt version\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// rkt Version: 1.24.0\n\t// appc Version: 0.8.10\n\tline := strings.Split(ver, \"\\n\")[0]\n\treturn strings.Replace(line, \"rkt Version: \", \"\", 1), nil\n}", "func GetVersion() string {\n\tif len(Version) == 0 {\n\t\treturn \"dev\"\n\t}\n\treturn Version\n}", "func GetVersion() string {\n\tif len(Version) == 0 {\n\t\treturn \"dev\"\n\t}\n\treturn Version\n}", "func (i DbInfo) Version() (string, error) {\n\tversion, _, _, err := i.Parse()\n\n\treturn version, err\n}", "func (a Asset) version() string {\n\tvar versionRegexp = regexp.MustCompile(`^v\\d+`)\n\tversion := a.Version\n\tif version == 0 &&\n\t\ta.Config.URL.ForceVersion &&\n\t\tfilepath.Dir(a.PublicID) != \".\" &&\n\t\t!isURL(a.PublicID) &&\n\t\t!versionRegexp.MatchString(a.PublicID) {\n\t\tversion = 1\n\t}\n\n\tif version != 0 {\n\t\treturn fmt.Sprintf(\"v%d\", version)\n\t}\n\n\treturn \"\"\n}", "func Version() string {\n\treturn gnmiVersion\n}", "func (u *Uname) Version() string {\n\treturn toString(u.Utsname.Version[:])\n}", "func (args) Version() string {\n\treturn config.App.Name\n}", "func Version() string {\n\treturn \"2.1.2\"\n}", "func GitVersion() string { return gitVersion }", "func Version() string {\n\treturn fmt.Sprint(\"C v1.2\", \"->\", d.Version())\n}", "func Version() string {\n\tif buildDate == \"{DATE}\" {\n\t\tnow := time.Now().Format(time.RFC3339)\n\t\tbuildDate = now\n\t}\n\treturn fmt.Sprintf(\"%s. Built at: %s\", BuildData(), buildDate)\n}", "func (cmd *CLI) Version() string {\n\treturn cmd.version\n}", "func PackageVersion() version.Version {\n\treturn version.New(4, 0, 1)\n}", "func LibVersion() string {\n\treturn version\n}", "func Version() string {\n\treturn fmt.Sprintf(\"%s %s %s\", AppVendor, AppName, AppVersion)\n}", "func Version() string {\n\treturn \"1.0.0-beta.8\"\n}", "func Version() (string, error) {\n\tvar version string\n\n\tcmd := exec.Command(\"git\", \"rev-parse\", \"HEAD\")\n\tcmdReader, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tscanner := bufio.NewScanner(cmdReader)\n\tgo func() {\n\t\tfor scanner.Scan() {\n\t\t\tversion = scanner.Text()\n\t\t}\n\t}()\n\n\terr = cmd.Start()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\terr = cmd.Wait()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn version, nil\n}", "func Version(buildpack buildpack.Buildpack) string {\n\tif version, ok := buildpack.Metadata[\"default_version\"].(string); ok {\n\t\treturn version\n\t}\n\n\treturn \"*\"\n}", "func (h Client) Version() (*semver.Version, error) {\n\tout, _, err := h.Exec(\"version\", \"--template={{.Version}}\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tversion, err := semver.NewVersion(out)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn version, nil\n}", "func String() string {\n\treturn Version\n}", "func (obj *script) Version() string {\n\treturn obj.version\n}", "func PackageVersion() version.Version {\n\treturn version.New(3, 0, 0)\n}", "func PackageVersion() version.Version {\n\treturn version.New(3, 0, 0)\n}", "func PackageVersion() version.Version {\n\treturn version.New(3, 0, 0)\n}", "func (net *NetAPI) Version() (string, error) {\n\treq := net.requestManager.newRequest(\"net_version\")\n\tresp, err := net.requestManager.send(req)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn resp.Get(\"result\").(string), nil\n}", "func version() string {\n\tif buildVersion != \"\" {\n\t\treturn buildVersion\n\t}\n\tlongTag, _ := sh.Output(\"git\", \"describe\", \"--tags\", \"--dirty\")\n\n\treturn longTag\n}", "func (d Dispatcher) Version() (string, error) {\n\theight, err := d.GetBC().GetLatestHeight()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\thashes, err := d.GetBC().GetBlockHashesHex()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tversionBytes, err := helpers.Serialize(NewVersion(GizoVersion, height, hashes))\n\treturn string(versionBytes), nil\n}", "func GetVersion() string {\n\tif metadata == \"\" {\n\t\treturn version\n\t}\n\treturn version + \"+\" + metadata\n}", "func (shl *SharedLibrary) Version() string {\n\treturn shl.version\n}", "func (client *Client) Version() string {\n\tversion := C.Version(client.api)\n\treturn C.GoString(version)\n}", "func getVersion() string {\n\tslurp, err := ioutil.ReadFile(filepath.Join(camRoot, \"VERSION\"))\n\tif err == nil {\n\t\treturn strings.TrimSpace(string(slurp))\n\t}\n\treturn gitVersion()\n}", "func Version() string {\n\tvar hashStr string\n\tif CommitHash != \"\" {\n\t\thashStr = \"+\" + CommitHash\n\t}\n\n\tif currentVersion.label == \"\" {\n\t\treturn fmt.Sprintf(\"%d.%d.%d%s\", currentVersion.major, currentVersion.minor, currentVersion.patch, hashStr)\n\t}\n\n\treturn fmt.Sprintf(\"%d.%d.%d-%s%s\", currentVersion.major, currentVersion.minor, currentVersion.patch, currentVersion.label, hashStr)\n}", "func (m *A2) Version() string {\n\t//In case semantic version field available return that or else the build number\n\tif m.SemVersion != \"\" {\n\t\treturn m.SemVersion\n\t}\n\treturn m.Build\n}", "func (hdr RPMHeader) Version() string {\n\treturn hdr.Tag(\"Version\")[0]\n}", "func (o *Basic) Version() string {\n\tif \"\" == o.Options.Version {\n\t\treturn defaultVersion\n\t}\n\treturn o.Options.Version\n}", "func (standardGo) Version() float64 {\n\treturn 0\n}", "func (_PlasmaFramework *PlasmaFrameworkSession) Version() (string, error) {\n\treturn _PlasmaFramework.Contract.Version(&_PlasmaFramework.CallOpts)\n}", "func (v *V0) Version() string {\n\tif v == nil {\n\t\treturn VersionUnknown.String()\n\t}\n\treturn v.version.String()\n}", "func (o OrderOutput) PackageVersion() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Order) pulumi.StringOutput { return v.PackageVersion }).(pulumi.StringOutput)\n}", "func (miner *CGMiner) Version() (*Version, error) {\n\tresponse, err := miner.runCommand(\"version\", \"\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresp := &VersionResponse{}\n\terr = json.Unmarshal(response, resp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = miner.checkStatus(resp.Status)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(resp.Version) < 1 {\n\t\treturn nil, errors.New(\"no version in JSON response\")\n\t}\n\tif len(resp.Version) > 1 {\n\t\treturn nil, errors.New(\"too many versions in JSON response\")\n\t}\n\n\treturn &resp.Version[0], nil\n}", "func (_PlasmaFramework *PlasmaFrameworkCallerSession) Version() (string, error) {\n\treturn _PlasmaFramework.Contract.Version(&_PlasmaFramework.CallOpts)\n}", "func (c *Connection) Version(ctx context.Context) (string, error) {\n\tresp, err := c.Request(ctx).\n\t\tSetResult(&api.VersionResponse{}).\n\t\tGet(\"/version\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn resp.Result().(*api.VersionResponse).Version, nil\n}", "func (api *API) Version(ctx context.Context) (string, error) {\n\taddr := api.host + \":\" + api.port\n\treturn version(addr)\n}", "func GetVersion() string {\n\tvar versionString bytes.Buffer\n\tfmt.Fprintf(&versionString, \"v%s\", versn)\n\tif env != \"\" {\n\t\tfmt.Fprintf(&versionString, \"-%s\", env)\n\t}\n\n\treturn versionString.String()\n}", "func GetVersion() string {\n\tv := Map[\"version\"]\n\treturn v\n}" ]
[ "0.77409333", "0.77409333", "0.77409333", "0.77409333", "0.77409333", "0.77409333", "0.77409333", "0.77409333", "0.7711625", "0.76718765", "0.76226705", "0.75100535", "0.75022686", "0.74754876", "0.7473825", "0.74727696", "0.74727696", "0.74476475", "0.7430816", "0.74275225", "0.73876315", "0.73823524", "0.73563987", "0.7353298", "0.7353298", "0.73497814", "0.73497814", "0.73276263", "0.7293393", "0.7228873", "0.7217595", "0.72072303", "0.7202637", "0.7193484", "0.71911114", "0.7187447", "0.7187151", "0.7187151", "0.71738136", "0.7150299", "0.7125105", "0.7123802", "0.7123501", "0.71049327", "0.708968", "0.70666325", "0.7065529", "0.70655257", "0.70596236", "0.7035075", "0.7030402", "0.7028156", "0.70089006", "0.6995495", "0.69944257", "0.6993036", "0.6993036", "0.6988725", "0.69862086", "0.6968325", "0.69456106", "0.69405687", "0.69382524", "0.6911695", "0.6905162", "0.6903466", "0.6899777", "0.6898555", "0.6889896", "0.6888189", "0.687351", "0.6871416", "0.68690073", "0.68689555", "0.6864909", "0.6863758", "0.6861716", "0.6861716", "0.6861716", "0.6861712", "0.6858705", "0.6853177", "0.6852548", "0.6849678", "0.6849471", "0.68450004", "0.6843261", "0.6839757", "0.6839114", "0.6827383", "0.68251103", "0.68066496", "0.679211", "0.6785269", "0.6784504", "0.67765045", "0.67719156", "0.67690665", "0.67556113", "0.6752835" ]
0.7183975
38
Author returns package author
func Author() string { return "[Li Kexian](https://www.likexian.com/)" }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func versionAuthor() string {\n\treturn fmt.Sprintf(\"By %s \", AUTHOR)\n}", "func (g *Generator) Author() string {\n\treturn g.image.Author\n}", "func (module *Crawler) Author() string {\n\treturn Author\n}", "func (r *Readme) Author() string {\n\treturn r.author\n}", "func (c Config) Author() string {\n\treturn c[\"author\"].(string)\n}", "func (m KafkaPlugin) Author() string {\n\treturn \"François SAMIN <[email protected]>\"\n}", "func (o Comment) Author() string {\n\treturn o.model.Author // string\n}", "func (r *Resolver) Author() generated.AuthorResolver { return &authorResolver{r} }", "func (r *Renderer) TitleAuthor(w io.Writer, a mast.Author, tag string) {\n\n\tattrs := Attributes(\n\t\t[]string{\"role\", \"initials\", \"surname\", \"fullname\"},\n\t\t[]string{a.Role, a.Initials, a.Surname, a.Fullname},\n\t)\n\n\tr.outTag(w, \"<\"+tag, attrs)\n\n\tr.outTag(w, \"<organization\", Attributes([]string{\"abbrev\"}, []string{a.OrganizationAbbrev}))\n\thtml.EscapeHTML(w, []byte(a.Organization))\n\tr.outs(w, \"</organization>\")\n\n\tr.outs(w, \"<address>\")\n\tr.outs(w, \"<postal>\")\n\n\tr.outTagContent(w, \"<street\", a.Address.Postal.Street)\n\tfor _, street := range a.Address.Postal.Streets {\n\t\tr.outTagContent(w, \"<street\", street)\n\t}\n\n\tr.outTagMaybe(w, \"<city\", a.Address.Postal.City)\n\tfor _, city := range a.Address.Postal.Cities {\n\t\tr.outTagContent(w, \"<city\", city)\n\t}\n\n\tr.outTagMaybe(w, \"<cityarea\", a.Address.Postal.CityArea)\n\tfor _, city := range a.Address.Postal.CityAreas {\n\t\tr.outTagContent(w, \"<cityarea\", city)\n\t}\n\n\tr.outTagMaybe(w, \"<code\", a.Address.Postal.Code)\n\tfor _, code := range a.Address.Postal.Codes {\n\t\tr.outTagContent(w, \"<code\", code)\n\t}\n\n\tr.outTagMaybe(w, \"<country\", a.Address.Postal.Country)\n\tfor _, country := range a.Address.Postal.Countries {\n\t\tr.outTagContent(w, \"<country\", country)\n\t}\n\n\tr.outTagMaybe(w, \"<extaddr\", a.Address.Postal.ExtAddr)\n\tfor _, extaddr := range a.Address.Postal.ExtAddrs {\n\t\tr.outTagContent(w, \"<extaddr\", extaddr)\n\t}\n\n\tr.outTagMaybe(w, \"<pobox\", a.Address.Postal.PoBox)\n\tfor _, pobox := range a.Address.Postal.PoBoxes {\n\t\tr.outTagContent(w, \"<pobox\", pobox)\n\t}\n\n\tr.outTagMaybe(w, \"<region\", a.Address.Postal.Region)\n\tfor _, region := range a.Address.Postal.Regions {\n\t\tr.outTagContent(w, \"<region\", region)\n\t}\n\n\tr.outs(w, \"</postal>\")\n\n\tr.outTagMaybe(w, \"<phone\", a.Address.Phone)\n\tr.outTagMaybe(w, \"<email\", a.Address.Email)\n\tfor _, email := range a.Address.Emails {\n\t\tr.outTagContent(w, \"<email\", email)\n\t}\n\tr.outTagMaybe(w, \"<uri\", a.Address.URI)\n\n\tr.outs(w, \"</address>\")\n\tr.outs(w, \"</\"+tag+\">\")\n}", "func (i *Invoice) Author() identity.DID {\n\treturn i.CoreDocument.Author()\n}", "func (r *Resolver) Author() AuthorResolver { return &authorResolver{r} }", "func findAuthorDetails(options *templates.Options) {\n\tif git.IsInstalled() {\n\t\tname, err := git.Name()\n\t\tif err == nil {\n\t\t\toptions.AuthorName = strings.TrimSpace(name)\n\t\t}\n\n\t\temail, err := git.Email()\n\t\tif err == nil {\n\t\t\toptions.AuthorEmail = strings.TrimSpace(email)\n\t\t}\n\t}\n}", "func (*SubstanceSourceMaterial_Organism_Author) Descriptor() ([]byte, []int) {\n\treturn file_proto_google_fhir_proto_r5_core_resources_substance_source_material_proto_rawDescGZIP(), []int{0, 1, 0}\n}", "func (hook *Hook) GetAuthor() (string, error) {\n\tcmd := exec.Command(\"svnlook\", \"author\", hook.repospath)\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif err = cmd.Start(); err != nil {\n\t\treturn \"\", err\n\t}\n\tauthor, err := ioutil.ReadAll(stdout)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\ttrimauthor := strings.TrimSuffix(string(author), \"\\n\")\n\treturn string(trimauthor), nil\n}", "func (o KafkaConnectorOutput) PluginAuthor() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *KafkaConnector) pulumi.StringOutput { return v.PluginAuthor }).(pulumi.StringOutput)\n}", "func (b *Book) Author(db XODB) (*Author, error) {\n\treturn AuthorByAuthorID(db, b.AuthorID)\n}", "func (e *engineImpl) Author(header *block.Header) (common.Address, error) {\n\t// TODO: implement this\n\treturn common.Address{}, nil\n}", "func Author(author string) func(f *Feed) error {\n\treturn func(f *Feed) error {\n\t\tf.Channel.Author = author\n\t\treturn nil\n\t}\n}", "func (consensus *Consensus) Author(header *types.Header) (common.Address, error) {\n\t// TODO: implement this\n\treturn common.Address{}, nil\n}", "func (r *CommitResolver) Author() *SignatureResolver {\n\treturn &SignatureResolver{r.commit.Author}\n}", "func RetrieveCMDAuthor(parent string) (string, error) {\n\tdata := cmdAuthorSelection.exp().FindStringSubmatch(parent)\n\tif len(data) > 1 && data[1] != \"\" {\n\t\treturn data[1], nil\n\t}\n\treturn \"\", fmt.Errorf(\"missing Author from the parsed string\")\n}", "func Author(v string) predicate.Book {\n\treturn predicate.Book(func(s *sql.Selector) {\n\t\ts.Where(sql.EQ(s.C(FieldAuthor), v))\n\t})\n}", "func (*Annotation_Author) Descriptor() ([]byte, []int) {\n\treturn file_proto_google_fhir_proto_stu3_datatypes_proto_rawDescGZIP(), []int{20, 0}\n}", "func (a *Author) String() string {\n\tif a.Others {\n\t\treturn \"others\"\n\t}\n\tlast := a.Last\n\tif a.Von != \"\" {\n\t\tlast = a.Von + \" \" + a.Last\n\t}\n\n\tlast = quoteName(last)\n\tfirst := quoteName(a.First)\n\tjr := quoteName(a.Jr)\n\n\tif last == \"\" {\n\t\treturn a.First\n\t} else if a.First == \"\" {\n\t\treturn last\n\t} else if a.Jr == \"\" {\n\t\treturn fmt.Sprintf(\"%s, %s\", last, first)\n\t} else {\n\t\treturn fmt.Sprintf(\"%s, %s, %s\", last, jr, first)\n\t}\n}", "func (r *PostReprGQL) AUTHOR(ctx context.Context) *AuthorReprGQL {\n\treturn &AuthorReprGQL{}\n}", "func (ec *executionContext) _Author(ctx context.Context, sel []query.Selection, obj *model.Author) graphql.Marshaler {\n\tfields := graphql.CollectFields(ec.Doc, sel, authorImplementors, ec.Variables)\n\n\tout := graphql.NewOrderedMap(len(fields))\n\tfor i, field := range fields {\n\t\tout.Keys[i] = field.Alias\n\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString(\"Author\")\n\t\tcase \"id\":\n\t\t\tout.Values[i] = ec._Author_id(ctx, field, obj)\n\t\tcase \"displayName\":\n\t\t\tout.Values[i] = ec._Author_displayName(ctx, field, obj)\n\t\tcase \"username\":\n\t\t\tout.Values[i] = ec._Author_username(ctx, field, obj)\n\t\tcase \"profileImagePath\":\n\t\t\tout.Values[i] = ec._Author_profileImagePath(ctx, field, obj)\n\t\tcase \"isAnonymous\":\n\t\t\tout.Values[i] = ec._Author_isAnonymous(ctx, field, obj)\n\t\tdefault:\n\t\t\tpanic(\"unknown field \" + strconv.Quote(field.Name))\n\t\t}\n\t}\n\n\treturn out\n}", "func (*Author) Descriptor() ([]byte, []int) {\n\treturn file_sandbox_proto_rawDescGZIP(), []int{3}\n}", "func (*Author) Descriptor() ([]byte, []int) {\n\treturn file_bookstore_proto_rawDescGZIP(), []int{0}\n}", "func NewAuthor() *Author {\n\tthis := Author{}\n\treturn &this\n}", "func (o *CommitOptions) GetAuthor() string {\n\tif o.Author == nil {\n\t\tvar z string\n\t\treturn z\n\t}\n\treturn *o.Author\n}", "func (publication *Publication) AddAuthor(name string, identifier string, sortAs string, href string, typeLink string) {\n\tvar c Contributor\n\tvar l Link\n\n\tc.Name.SingleString = name\n\tif identifier != \"\" {\n\t\tc.Identifier = identifier\n\t}\n\tif sortAs != \"\" {\n\t\tc.SortAs = sortAs\n\t}\n\tif href != \"\" {\n\t\tl.Href = href\n\t}\n\tif typeLink != \"\" {\n\t\tl.TypeLink = typeLink\n\t}\n\n\tif l.Href != \"\" {\n\t\tc.Links = append(c.Links, l)\n\t}\n\n\tpublication.Metadata.Author = append(publication.Metadata.Author, c)\n}", "func (c *Client) Author(id string) (Author, []Manga, error) {\n\tauthors, err := c.authorsByIDs([]string{id})\n\tif err != nil {\n\t\treturn Author{}, nil, errors.Wrap(err, \"could not get authors meta data\")\n\t}\n\tif len(authors) == 0 {\n\t\treturn Author{}, nil, errors.Errorf(\"author with id %s not found\", id)\n\t}\n\n\tres, err := c.get(c.base+\"/mrs_serie_related_author\", url.Values{\"oid\": []string{id}})\n\tif err != nil {\n\t\treturn Author{}, nil, errors.Wrap(err, \"could not get authors mangas\")\n\t}\n\tvar mangaIDStructs []struct {\n\t\tID string `json:\"oid\"`\n\t}\n\tif err := json.Unmarshal(res, &mangaIDStructs); err != nil {\n\t\treturn Author{}, nil, errors.Wrap(err, \"could not unmarshal authors meta data\")\n\t}\n\tvar mangaIDs []string\n\tfor _, manga := range mangaIDStructs {\n\t\tmangaIDs = append(mangaIDs, manga.ID)\n\t}\n\tmangas, err := c.mangasByIDs(mangaIDs)\n\tif err != nil {\n\t\treturn Author{}, nil, errors.Wrap(err, \"could not get authors mangas\")\n\t}\n\tfor i := range mangas {\n\t\tmangas[i].Author = authors[0]\n\t}\n\treturn authors[0], mangas, nil\n}", "func (r *RepositoryRelease) GetAuthor() *User {\n\tif r == nil {\n\t\treturn nil\n\t}\n\treturn r.Author\n}", "func (r *authorsResource) GetAuthor(request *restful.Request, response *restful.Response) {\n\tauthorID := request.PathParameter(\"author-id\")\n\tctx := context.Background()\n\n\tres, err := r.service.GetAuthor(ctx, authorID)\n\tif err != nil {\n\t\tencodeErrorWithStatus(response, err, http.StatusBadRequest)\n\t}\n\n\tresponse.WriteHeaderAndEntity(http.StatusOK, res)\n}", "func (c *common) PackageName() string { return uniquePackageOf(c.file) }", "func (c *AUTHOR) Parse() string {\n\tEmpty := AUTHOR{}\n\tvar auth string\n\tif *c != Empty {\n\t\tif c.Name != \"\" {\n\t\t\tauth += fmt.Sprintf(`\"name\": \"%v\" `, c.Name)\n\t\t}\n\t\tif auth != \"\" {\n\t\t\tif c.URL != \"\" {\n\t\t\t\tauth += fmt.Sprintf(`, \"url\": \"%v\" `, c.URL)\n\t\t\t}\n\t\t\tif c.IconURL != \"\" {\n\t\t\t\tauth += fmt.Sprintf(`, \"icon_url\": \"%v\" `, c.IconURL)\n\t\t\t}\n\t\t}\n\t\treturn fmt.Sprintf(`\"author\": { %v }`, auth)\n\t}\n\treturn \"\"\n}", "func (ec *executionContext) _Author_id(ctx context.Context, field graphql.CollectedField, obj *entc.Author) (ret graphql.Marshaler) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = graphql.Null\n\t\t}\n\t}()\n\tfc := &graphql.FieldContext{\n\t\tObject: \"Author\",\n\t\tField: field,\n\t\tArgs: nil,\n\t\tIsMethod: true,\n\t}\n\n\tctx = graphql.WithFieldContext(ctx, fc)\n\tresTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {\n\t\tctx = rctx // use context from middleware stack in children\n\t\treturn ec.resolvers.Author().ID(rctx, obj)\n\t})\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn graphql.Null\n\t}\n\tif resTmp == nil {\n\t\tif !graphql.HasFieldError(ctx, fc) {\n\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t}\n\t\treturn graphql.Null\n\t}\n\tres := resTmp.(string)\n\tfc.Result = res\n\treturn ec.marshalNID2string(ctx, field.Selections, res)\n}", "func (p *Parser) Package() string {\n\treturn p.asTree.Name.Name\n}", "func (r *RepositoryContentFileOptions) GetAuthor() *CommitAuthor {\n\tif r == nil {\n\t\treturn nil\n\t}\n\treturn r.Author\n}", "func (r *ThreadReprGQL) AUTHOR(ctx context.Context) *AuthorReprGQL {\n\treturn &AuthorReprGQL{}\n}", "func (p *Post) Author() *User {\n\tif !bson.IsObjectIdHex(p.CreatedBy) {\n\t\treturn ghostUser\n\t}\n\tuser := &User{Id: bson.ObjectIdHex(p.CreatedBy)}\n\terr := user.GetUserById()\n\tif err != nil {\n\t\treturn ghostUser\n\t}\n\treturn user\n}", "func (r *RPC) IsAuthor(c context.Context, arg *model.ArgMid, res *bool) (err error) {\n\t*res, _, err = r.s.IsAuthor(c, arg.Mid)\n\treturn\n}", "func ParseAuthor(authorStr string) (string, string, error) {\n\tif len(authorStr) == 0 {\n\t\treturn \"\", \"\", errors.New(\"Option 'author' requires a value\")\n\t}\n\n\treg := regexp.MustCompile(\"(?m)([^)]+) \\\\<([^)]+)\") // Regex matches Name <email\n\tmatches := reg.FindStringSubmatch(authorStr) // This function places the original string at the beginning of matches\n\n\t// If name and email are provided\n\tif len(matches) != 3 {\n\t\treturn \"\", \"\", errors.New(\"Author not formatted correctly. Use 'Name <[email protected]>' format\")\n\t}\n\n\tname := matches[1]\n\temail := strings.ReplaceAll(matches[2], \">\", \"\")\n\n\treturn name, email, nil\n}", "func (j *DSGit) RichAuthorField(*Ctx) string {\n\treturn DefaultAuthorField\n}", "func (c *CommitResult) GetAuthor() *User {\n\tif c == nil {\n\t\treturn nil\n\t}\n\treturn c.Author\n}", "func (j *DSGitHub) RichAuthorField(*Ctx) string {\n\treturn DefaultAuthorField\n}", "func (c *ContributorStats) GetAuthor() *Contributor {\n\tif c == nil {\n\t\treturn nil\n\t}\n\treturn c.Author\n}", "func (pr LocalPackageReference) PackageName() string {\n\treturn pr.Version()\n}", "func (bb *BooktestBook) BooktestAuthor(ctx context.Context, db DB) (*BooktestAuthor, error) {\n\treturn BooktestAuthorByAuthorID(ctx, db, bb.AuthorID)\n}", "func AddAuthorInfo(cmd *exec.Cmd, timestamp *time.Time) {\n\tcmd.Env = append(cmd.Env,\n\t\t\"GIT_AUTHOR_NAME=Arthur\",\n\t\t\"[email protected]\",\n\t\tfmt.Sprintf(\"GIT_AUTHOR_DATE=%d -0700\", timestamp.Unix()),\n\t\t\"GIT_COMMITTER_NAME=Constance\",\n\t\t\"[email protected]\",\n\t\tfmt.Sprintf(\"GIT_COMMITTER_DATE=%d -0700\", timestamp.Unix()),\n\t)\n\t*timestamp = timestamp.Add(60 * time.Second)\n}", "func (analyzer *Analyzer) Authors(flavor, payload string, options url.Values) (*AuthorsResponse, error) {\n\tif !entryPoints.hasFlavor(\"authors\", flavor) {\n\t\treturn nil, errors.New(fmt.Sprintf(\"authors info for %s not available\", flavor))\n\t}\n\n\toptions.Add(flavor, payload)\n\turl := entryPoints.urlFor(analyzer.baseUrl, \"authors\", flavor)\n\tdata, err := analyzer.analyze(url, options, nil)\n\n\tif err != nil {\n\t\treturn nil, err\n\t} else {\n\t\tresponse := new(AuthorsResponse)\n\t\terr := json.Unmarshal(data, &response)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tif response.Status != \"OK\" {\n\t\t\t\treturn nil, errors.New(response.StatusInfo)\n\t\t\t} else {\n\t\t\t\treturn response, nil\n\t\t\t}\n\t\t}\n\t}\n}", "func (r *bookResolver) Author(ctx context.Context, obj *model.Book) (*model.Author, error) {\n\tfor _, a := range r.AuthorsDB{\n\t\tif a.ID == obj.Author.ID{\n\t\t\treturn a, nil\n\t\t}\n\t}\n\treturn nil, errors.New(\"error finding author\")\n}", "func (kpc_obj *KPC) AddAuthor(aut Author) {\n\tkpc_obj.Authors = append(kpc_obj.Authors, aut)\n}", "func (c *common) GetPackage() string { return c.file.GetPackage() }", "func packageHTMLTitle(pkgPath, pkgName string) string {\n\tif pkgName != \"main\" {\n\t\treturn pkgName + \" package\"\n\t}\n\treturn effectiveName(pkgPath, pkgName) + \" command\"\n}", "func Synopsis(text string) string {\n\tvar p Package\n\treturn p.Synopsis(text)\n}", "func (g *Generator) SetAuthor(author string) {\n\tg.image.Author = author\n}", "func IsAuthor(issueUser, commentUser string) bool {\n\treturn NormLogin(issueUser) == NormLogin(commentUser)\n}", "func (t *Commit) GetAuthorUserID() string {\n\treturn t.AuthorUserID\n}", "func (s *SourceImportAuthor) GetName() string {\n\tif s == nil || s.Name == nil {\n\t\treturn \"\"\n\t}\n\treturn *s.Name\n}", "func (g *Generator) Package(pkg string) {\n\tif pkg == \"\" {\n\t\tpkg = \"main\"\n\t}\n\tg.Printf(\"package %s\\n\", pkg)\n}", "func (doc Document) Authors() []string {\n\tvar authors []string\n\tfor _, s := range doc.RawAuthors {\n\t\tfields := strings.FieldsFunc(s, func(r rune) bool {\n\t\t\treturn r == ';' || r == '/'\n\t\t})\n\t\tfor _, f := range fields {\n\t\t\tif !NomenNescio(f) {\n\t\t\t\tauthors = append(authors, strings.TrimSpace(f))\n\t\t\t}\n\t\t}\n\t}\n\treturn authors\n}", "func (o *InlineResponse200115) GetAuthorOk() (*InlineResponse200115Author, bool) {\n\tif o == nil || o.Author == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Author, true\n}", "func (w *WebHookCommit) GetAuthor() *WebHookAuthor {\n\tif w == nil {\n\t\treturn nil\n\t}\n\treturn w.Author\n}", "func (r *Readme) SetAuthor(a string) *Readme {\n\tr.author = a\n\treturn r\n}", "func (ec *executionContext) marshalNAuthor2githubᚗcomᚋCristhoperDevᚋgoᚑgraphqlᚑentcᚋinternalᚋproviderᚋentcᚐAuthor(ctx context.Context, sel ast.SelectionSet, v entc.Author) graphql.Marshaler {\n\treturn ec._Author(ctx, sel, &v)\n}", "func (author *Author) String() string {\n\tvar given, family = author.GivenCleaned(), author.FamilyCleaned()\n\tif given != \"\" {\n\t\tif family != \"\" {\n\t\t\treturn fmt.Sprintf(\"%s, %s\", family, given)\n\t\t}\n\t\treturn given\n\t}\n\treturn family\n}", "func (j *DSRocketchat) RichAuthorField(*Ctx) string {\n\treturn DefaultAuthorField\n}", "func RetrieveAuthorByUsername(dbProvider mmuoMongo.DbProviderFunc) RetrieveAuthorByUsernameFunc {\n\treturn func(username string) (internal.Author, error) {\n\t\tcol := mmuoMongo.NewCollection(dbProvider, authorsCollection)\n\t\tfilter := bson.D{{\"username\", username}}\n\t\tvar a internal.Author\n\n\t\tif err := col.FindOne(filter, &a); err != nil {\n\t\t\treturn internal.Author{}, errors.Wrapf(err, \"db - author not found\")\n\t\t}\n\t\treturn a, nil\n\t}\n}", "func GetAuthor(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"Endpoint Hit: return single author\")\n\tvars := mux.Vars(r)\n\tid, _ := strconv.Atoi(vars[\"id\"])\n\n\tvar author models.Author\n\tresult := DB.First(&author, id)\n\tif result.Error != nil {\n\t\tresponses.RespondWithError(w, http.StatusBadRequest, result.Error)\n\t\treturn\n\t}\n\n\tresponses.RespondWithJSON(w, http.StatusOK, author)\n}", "func (p *Package) Synopsis(text string) string {\n\ttext = firstSentence(text)\n\tlower := strings.ToLower(text)\n\tfor _, prefix := range IllegalPrefixes {\n\t\tif strings.HasPrefix(lower, prefix) {\n\t\t\treturn \"\"\n\t\t}\n\t}\n\tpr := p.Printer()\n\tpr.TextWidth = -1\n\td := p.Parser().Parse(text)\n\tif len(d.Content) == 0 {\n\t\treturn \"\"\n\t}\n\tif _, ok := d.Content[0].(*comment.Paragraph); !ok {\n\t\treturn \"\"\n\t}\n\td.Content = d.Content[:1] // might be blank lines, code blocks, etc in “first sentence”\n\treturn strings.TrimSpace(string(pr.Text(d)))\n}", "func PackageName(d *pdl.Domain) string {\n\treturn strings.ToLower(d.Domain.String())\n}", "func ExamplePdfMaroto_SetAuthor() {\n\tm := pdf.NewMaroto(consts.Portrait, consts.A4)\n\n\tm.SetAuthor(\"author\", true)\n\n\t// Do more things and save...\n}", "func getAuthorIdByName(name string) (id int64, err error) {\r\n\tvar acct Account\r\n\tdb := getAccountDB()\r\n\terr = db.Where(\"name=?\", name).First(&acct).Error\r\n\tid = acct.Id\r\n\treturn\r\n}", "func (p *PageRelatedArticle) GetAuthor() (value string, ok bool) {\n\tif !p.Flags.Has(3) {\n\t\treturn value, false\n\t}\n\treturn p.Author, true\n}", "func (p *PushEventCommit) GetAuthor() *CommitAuthor {\n\tif p == nil {\n\t\treturn nil\n\t}\n\treturn p.Author\n}", "func FindAuthorP(exec boil.Executor, id int64, selectCols ...string) *Author {\n\tretobj, err := FindAuthor(exec, id, selectCols...)\n\tif err != nil {\n\t\tpanic(boil.WrapErr(err))\n\t}\n\n\treturn retobj\n}", "func (c *Commit) GetAuthor() *CommitAuthor {\n\tif c == nil {\n\t\treturn nil\n\t}\n\treturn c.Author\n}", "func (me TAttlistAuthorListCompleteYN) String() string { return xsdt.Token(me).String() }", "func (*AuditAuthor) Descriptor() ([]byte, []int) {\n\treturn file_audit_proto_rawDescGZIP(), []int{5}\n}", "func Authors(exec boil.Executor, mods ...qm.QueryMod) authorQuery {\n\tmods = append(mods, qm.From(\"\\\"authors\\\"\"))\n\treturn authorQuery{NewQuery(exec, mods...)}\n}", "func FindAuthorGP(id int64, selectCols ...string) *Author {\n\tretobj, err := FindAuthor(boil.GetDB(), id, selectCols...)\n\tif err != nil {\n\t\tpanic(boil.WrapErr(err))\n\t}\n\n\treturn retobj\n}", "func (c *CommitAuthor) GetName() string {\n\tif c == nil || c.Name == nil {\n\t\treturn \"\"\n\t}\n\treturn *c.Name\n}", "func (m *AccessPackageCatalog) GetDisplayName()(*string) {\n return m.displayName\n}", "func GetFeedAuthor(db *sql.DB, feedID int64) (name, email string, err error) {\n\tstmt := \"SELECT authors.name, authors.email FROM feeds INNER JOIN authors ON authors.id = feeds.author_id WHERE feeds.id = $1\"\n\trow := db.QueryRow(stmt, feedID)\n\terr = row.Scan(&name, &email)\n\treturn\n}", "func (c *Contribution) Username() string {\n\treturn c.username\n}", "func (ac *Activity) PackageName() string {\n\treturn ac.pkgName\n}", "func GetAuthor(id string) (*models.Author, error) {\n\tfor _, author := range Authors {\n\t\tif author.ID == id {\n\t\t\treturn author, nil\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\"Author (id: %v) was not found\", id)\n}", "func (j *DSGit) GetAuthorsData(ctx *Ctx, doc interface{}, auth string) (authorsMap map[string]struct{}, firstAuthor string) {\n\tiauthors, ok := Dig(doc, []string{\"data\", auth}, false, true)\n\tif ok {\n\t\tauthors, _ := iauthors.(string)\n\t\tif j.PairProgramming {\n\t\t\tif ctx.Debug > 1 {\n\t\t\t\tPrintf(\"pp %s: %s\\n\", auth, authors)\n\t\t\t}\n\t\t\tm1 := MatchGroups(GitAuthorsPattern, authors)\n\t\t\tm2 := MatchGroupsArray(GitCoAuthorsPattern, authors)\n\t\t\tif len(m1) > 0 || len(m2) > 0 {\n\t\t\t\tauthorsMap, firstAuthor = j.GetAuthors(ctx, m1, m2)\n\t\t\t}\n\t\t}\n\t\tif len(authorsMap) == 0 {\n\t\t\tauthorsMap = map[string]struct{}{authors: {}}\n\t\t\tfirstAuthor = authors\n\t\t}\n\t}\n\treturn\n}", "func (project Project) Package() (string, error) {\n\n\tif project.packageName != \"\" {\n\t\treturn project.packageName, nil\n\t}\n\n\tgoModPath := project.RelPath(GoModFileName)\n\tif !project.FileExists(goModPath) {\n\t\treturn \"\", errors.New(\"Failed to determine the package name for this project\")\n\t}\n\n\tb, err := ioutil.ReadFile(goModPath)\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"Failed to read the go.mod file\")\n\t}\n\n\tmod, err := gomod.Parse(goModPath, b)\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"Failed to parse the go.mod file\")\n\t}\n\n\tproject.packageName = strings.TrimSuffix(mod.Name, \"/\")\n\n\treturn project.packageName, nil\n\n}", "func (p *Pkg) fullName() string {\n\treturn fmt.Sprintf(\"%v_%v\", p.name, p.version)\n}", "func (r *RepositoryCommit) GetAuthor() *User {\n\tif r == nil {\n\t\treturn nil\n\t}\n\treturn r.Author\n}", "func author(w http.ResponseWriter, r *http.Request) {\n\tnCalls += 1\n\tfmt.Fprintf(w, \"Author: Ewan Ewart\")\n\tfmt.Printf(\"Endpoint(%3v): REST website author\\n\", nCalls)\n}", "func (p *Package) Name() string {\n\treturn p.name\n}", "func (p *PublisherMunger) Name() string { return \"publisher\" }", "func (r PackageNameLowerCaseRule) Purpose() string {\n\treturn \"Verifies that the package name doesn't contain any uppercase letters.\"\n}" ]
[ "0.7753293", "0.74812424", "0.74752694", "0.7469505", "0.7041128", "0.70028955", "0.69293934", "0.6861273", "0.6804476", "0.6582052", "0.6518088", "0.64972675", "0.6433045", "0.641867", "0.6391086", "0.6371975", "0.63282406", "0.63003945", "0.61798203", "0.6172487", "0.6084106", "0.6032266", "0.601539", "0.5918941", "0.5913638", "0.5854962", "0.5852738", "0.58461225", "0.5841857", "0.5833839", "0.5820528", "0.5787219", "0.57575876", "0.56932384", "0.5656201", "0.5648794", "0.5614736", "0.56102914", "0.55638695", "0.55397093", "0.5537226", "0.55362046", "0.55053014", "0.55018824", "0.55006087", "0.54976094", "0.54888886", "0.5485179", "0.547044", "0.5444668", "0.5442474", "0.5439588", "0.542613", "0.54255235", "0.5399664", "0.53929436", "0.5388524", "0.5386339", "0.5384244", "0.53836334", "0.53330743", "0.5323505", "0.53211653", "0.5319748", "0.53120685", "0.53104883", "0.5305819", "0.529744", "0.5284481", "0.5245511", "0.524357", "0.52434933", "0.5238284", "0.5235005", "0.5230896", "0.5229154", "0.5223929", "0.522206", "0.5209112", "0.51947266", "0.5185665", "0.5183383", "0.5182351", "0.5165234", "0.516347", "0.5161974", "0.5159445", "0.5159054", "0.51572603", "0.51560855", "0.5144638", "0.5133755", "0.5130108", "0.51263076", "0.5115103", "0.5111639" ]
0.7652504
5
License returns package license
func License() string { return "Licensed under the Apache License 2.0" }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func License() string {\n\treturn C.GoString(C.avformat_license())\n}", "func (hdr RPMHeader) License() string {\n\treturn hdr.Tag(\"License\")[0]\n}", "func (o LicenseOutput) License() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *License) pulumi.StringOutput { return v.License }).(pulumi.StringOutput)\n}", "func License() string {\n\treturn C.GoString(C.avfilter_license())\n}", "func (o LicenseResourceCommitmentOutput) License() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v LicenseResourceCommitment) *string { return v.License }).(pulumi.StringPtrOutput)\n}", "func (s *Server) getLicense(w http.ResponseWriter, r *http.Request) {\n\twriteXML(w, func(c *container) {\n\t\t// A license that indicates valid \"true\" allows Subsonic\n\t\t// clients to connect to this server\n\t\tc.License = &license{Valid: true}\n\t})\n}", "func (o LicenseResourceCommitmentResponseOutput) License() pulumi.StringOutput {\n\treturn o.ApplyT(func(v LicenseResourceCommitmentResponse) string { return v.License }).(pulumi.StringOutput)\n}", "func (o KubernetesClusterWindowsProfileOutput) License() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v KubernetesClusterWindowsProfile) *string { return v.License }).(pulumi.StringPtrOutput)\n}", "func License() string {\n\treturn C.GoString(C.postproc_license())\n}", "func (o KubernetesClusterWindowsProfilePtrOutput) License() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *KubernetesClusterWindowsProfile) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.License\n\t}).(pulumi.StringPtrOutput)\n}", "func (s *SPDX) License(id string) (*License, error) {\n\tresp, err := s.hc.Get(fmt.Sprintf(s.detailsURL, id))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tvar result License\n\tif err := json.NewDecoder(resp.Body).Decode(&result); err != nil {\n\t\treturn nil, err\n\t}\n\n\trespDetails, err := s.hc.Get(result.DetailsURL)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer respDetails.Body.Close()\n\n\tvar details Details\n\tif err := json.NewDecoder(respDetails.Body).Decode(&details); err != nil {\n\t\treturn nil, err\n\t}\n\tresult.Details = details\n\n\treturn &result, nil\n}", "func AvformatLicense() string {\n\treturn C.GoString(C.avformat_license())\n}", "func getLicenceString() string {\n\tlicence :=\n\t\t\"\\nCopyright (c) 2015, Lindsay Bradford\\n\" +\n\t\t\t\"All rights reserved.\\n\\n\" +\n\t\t\t\"Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\\n\\n\" +\n\t\t\t\"1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\\n\\n\" +\n\t\t\t\"2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\\n\\n\" +\n\t\t\t\"3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\\n\\n\" +\n\t\t\t\"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \\\"AS IS\\\" AND ANY EXPRESS OR IMPLIED \" +\n\t\t\t\"WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A \" +\n\t\t\t\"PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY \" +\n\t\t\t\"DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, \" +\n\t\t\t\"PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \" +\n\t\t\t\"CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR \" +\n\t\t\t\"OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\\n\"\n\n\treturn licence\n}", "func (o LicenseResourceCommitmentPtrOutput) License() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *LicenseResourceCommitment) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.License\n\t}).(pulumi.StringPtrOutput)\n}", "func (p *Project) License() License {\n\tif p.license.Text == \"\" && p.license.Name != \"None\" {\n\t\tp.license = getLicense()\n\t}\n\n\treturn p.license\n}", "func (i Intangible) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func provideLicense(client *scm.Client, config config.Config) *core.License {\n\tl, err := license.Load(config.License)\n\tif config.License == \"\" {\n\t\tl = license.Trial(client.Driver.String())\n\t} else if err != nil {\n\t\tlogrus.WithError(err).\n\t\t\tFatalln(\"main: invalid or expired license\")\n\t}\n\tlogrus.WithFields(\n\t\tlogrus.Fields{\n\t\t\t\"kind\": l.Kind,\n\t\t\t\"expires\": l.Expires,\n\t\t\t\"repo.limit\": l.Repos,\n\t\t\t\"user.limit\": l.Users,\n\t\t\t\"build.limit\": l.Builds,\n\t\t},\n\t).Debugln(\"main: license loaded\")\n\treturn l\n}", "func (o LicenseResourceCommitmentResponsePtrOutput) License() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *LicenseResourceCommitmentResponse) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.License\n\t}).(pulumi.StringPtrOutput)\n}", "func (c *CommunityHealthFiles) GetLicense() *Metric {\n\tif c == nil {\n\t\treturn nil\n\t}\n\treturn c.License\n}", "func AVCodecLicense() string {\n\treturn C.GoString(C.avcodec_license())\n}", "func (cw CreativeWork) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (t Thing) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (p Place) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (h Hotel) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func printLicense() {\n\tfmt.Printf(color.GreenString(\"\\n\"+appName+\" v\"+semverInfo()) + color.WhiteString(\" by \"+appDev))\n\tcolor.Set(color.FgGreen)\n\tfmt.Println(\"\\n\" + appRepository + \"\\n\" + appURL + \"\\n\")\n\n\tcolor.Set(color.FgHiWhite)\n\tfmt.Println(\"\\nMIT License\\nCopyright (c) 2020-2021 RockSteady, TurtleCoin Developers\")\n\tcolor.Set(color.FgHiBlack)\n\tfmt.Println(\"\\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\\n\\nThe above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.\\n\\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\")\n\tfmt.Println()\n}", "func (l License) AsLicense() (*License, bool) {\n\treturn &l, true\n}", "func (mt MovieTheater) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (i Identifiable) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (a Answer) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (ioVar ImageObject) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (cs CivicStructure) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (lb LodgingBusiness) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (lb LocalBusiness) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (o Organization) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (a Airport) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (c Config) LicenseOrDefault() string {\n\tif c.License != \"\" {\n\t\treturn c.License\n\t}\n\treturn DefaultOpenSourceLicense\n}", "func NewLicense() *License {\n\treturn &License{\n\t\txml.Name{},\n\t\ttrue,\n\t}\n}", "func (c *TestClient) GetLicense(project, name string) (*compute.License, error) {\n\tif c.GetLicenseFn != nil {\n\t\treturn c.GetLicenseFn(project, name)\n\t}\n\treturn c.client.GetLicense(project, name)\n}", "func (r Restaurant) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (sv StructuredValue) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (r Response) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (fe FoodEstablishment) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (rb ResponseBase) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (e Entities) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (p Places) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func writeLicense (dir string) error {\n\tf := path.Join(dir, \"LICENSE\")\n\treturn ioutil.WriteFile(f, []byte(data.DefaultLicense), os.FileMode(0666))\n}", "func (eb EntertainmentBusiness) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (ta TouristAttraction) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (sr SearchResponse) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func (mo MediaObject) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func GetLicenseFromSecret(client *kubernetes.Clientset) (string, error) {\n\tsecret, err := client.CoreV1().Secrets(defaults.KubeSystemNamespace).\n\t\tGet(context.TODO(), constants.LicenseSecretName, metav1.GetOptions{})\n\tif err != nil {\n\t\treturn \"\", trace.Wrap(rigging.ConvertError(err))\n\t}\n\n\tlicenseData, ok := secret.Data[constants.LicenseSecretName]\n\tif !ok {\n\t\treturn \"\", trace.NotFound(\"no license data in Kubernetes secret\")\n\t}\n\n\treturn string(licenseData), nil\n}", "func (s *LicensesService) GetLicense(licenseID string) (*License, *resty.Response, error) {\n\n\tpath := \"/licenses/{licenseId}\"\n\tpath = strings.Replace(path, \"{\"+\"licenseId\"+\"}\", fmt.Sprintf(\"%v\", licenseID), -1)\n\n\tresponse, err := RestyClient.R().\n\t\tSetResult(&License{}).\n\t\tGet(path)\n\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tresult := response.Result().(*License)\n\treturn result, response, err\n\n}", "func (r *Repository) GetLicense() *License {\n\tif r == nil {\n\t\treturn nil\n\t}\n\treturn r.License\n}", "func (c Config) allowsLicense(name string) bool {\n\tfor _, l := range c.Licenses {\n\t\tif l == name {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (a *SyncApiService) GetSyncLicense(ctx context.Context) (LicenseLicense, *http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = strings.ToUpper(\"Get\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t \tsuccessPayload LicenseLicense\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/platform/5/sync/license\"\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{ \"application/json\", }\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\n\t\t\"application/json\",\n\t\t}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn successPayload, nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn successPayload, localVarHttpResponse, err\n\t}\n\tdefer localVarHttpResponse.Body.Close()\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tbodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)\n\t\treturn successPayload, localVarHttpResponse, reportError(\"Status: %v, Body: %s\", localVarHttpResponse.Status, bodyBytes)\n\t}\n\n\tif err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {\n\t\treturn successPayload, localVarHttpResponse, err\n\t}\n\n\n\treturn successPayload, localVarHttpResponse, err\n}", "func licFromName(commonLicenses []DOILicense, licenseName string) (DOILicense, bool) {\n\tlicname := cleancompstr(licenseName)\n\tfor _, lic := range commonLicenses {\n\t\tfor _, alias := range lic.Alias {\n\t\t\tif licname == strings.ToLower(alias) {\n\t\t\t\treturn lic, true\n\t\t\t}\n\t\t}\n\t}\n\n\tvar emptyLicense DOILicense\n\treturn emptyLicense, false\n}", "func NewLicense() *GetLicense {\n\trequest := gorequest.New()\n\tdownloader := GetLicense{\n\t\trequest: request,\n\t\tlicenseMap: make(map[string]string),\n\t}\n\treturn &downloader\n}", "func NewLicense(name string, expiry time.Time) *LicenseData {\n\treturn &LicenseData{Info: LicenseInfo{Name: name, Expiration: expiry}}\n}", "func New(licenseType, licenseText string) *License {\n\tl := &License{\n\t\tType: licenseType,\n\t\tText: licenseText,\n\t}\n\treturn l\n}", "func (r ProductLicenseInfo) Plan() string { return r.PlanValue }", "func (c *Client) GetLicense(ctx context.Context, p *LicenseObject) (res int, err error) {\n\tvar ires interface{}\n\tires, err = c.GetLicenseEndpoint(ctx, p)\n\tif err != nil {\n\t\treturn\n\t}\n\treturn ires.(int), nil\n}", "func (m *Mutator) styledLicense(path string) []byte {\n\tstyle := identifyLanguageStyle(path)\n\tif style == nil {\n\t\treturn nil\n\t}\n\tbuf := bytes.NewBuffer([]byte{})\n\n\t// TODO: implement block styling\n\tif style.isBlock {\n\n\t} else {\n\t\tscanner := bufio.NewScanner(m.license.Reader())\n\t\tfor scanner.Scan() {\n\t\t\t_, _ = buf.WriteString(style.comment)\n\t\t\tif len(scanner.Bytes()) != 0 {\n\t\t\t\t_, _ = buf.WriteString(\" \")\n\t\t\t}\n\t\t\t_, _ = buf.Write(scanner.Bytes())\n\t\t\t_, _ = buf.WriteString(\"\\n\")\n\t\t}\n\t}\n\treturn buf.Bytes()\n}", "func (o *V0037JobProperties) GetLicenses() string {\n\tif o == nil || o.Licenses == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Licenses\n}", "func (o *Operator) NewLicense(ctx context.Context, req ops.NewLicenseRequest) (string, error) {\n\tif !o.isOpsCenter() {\n\t\treturn \"\", trace.AccessDenied(\"cannot generate licenses\")\n\t}\n\n\terr := req.Validate()\n\tif err != nil {\n\t\treturn \"\", trace.Wrap(err)\n\t}\n\n\to.Infof(\"Generating new license: %v\", req)\n\n\tca, err := pack.ReadCertificateAuthority(o.packages())\n\tif err != nil {\n\t\treturn \"\", trace.Wrap(err)\n\t}\n\n\tlicense, err := licenseapi.NewLicense(licenseapi.NewLicenseInfo{\n\t\tMaxNodes: req.MaxNodes,\n\t\tValidFor: req.ValidFor,\n\t\tStopApp: req.StopApp,\n\t\tTLSKeyPair: *ca,\n\t})\n\tif err != nil {\n\t\treturn \"\", trace.Wrap(err)\n\t}\n\n\tparsed, err := licenseapi.ParseLicense(license)\n\tif err != nil {\n\t\treturn \"\", trace.Wrap(err)\n\t}\n\n\tlibevents.Emit(ctx, o, events.LicenseGenerated, libevents.Fields{\n\t\tevents.FieldExpires: parsed.GetPayload().Expiration,\n\t\tevents.FieldMaxNodes: parsed.GetPayload().MaxNodes,\n\t})\n\n\treturn license, nil\n}", "func (s *LicenseService) GetLicenseCommand() (result *LicenseView, resp *http.Response, err error) {\n\tpath := \"/license\"\n\trel := &url.URL{Path: fmt.Sprintf(\"%s%s\", s.client.Context, path)}\n\treq, err := s.client.newRequest(\"GET\", rel, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tresp, err = s.client.do(req, &result)\n\tif err != nil {\n\t\treturn result, resp, err\n\t}\n\treturn result, resp, nil\n\n}", "func TestLicense(t *testing.T) {\n\terr := filepath.Walk(\".\", func(path string, fi os.FileInfo, err error) error {\n\t\tif skip[path] {\n\t\t\treturn nil\n\t\t}\n\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif filepath.Ext(path) != \".go\" && filepath.Ext(path) != \".sh\" {\n\t\t\treturn nil\n\t\t}\n\n\t\tsrc, err := os.ReadFile(path)\n\t\tif err != nil {\n\t\t\treturn nil\n\t\t}\n\n\t\t// Verify that the license is matched.\n\t\tif !sentinel.Match(src) {\n\t\t\tt.Errorf(\"%v: license header not present\", path)\n\t\t\treturn nil\n\t\t}\n\n\t\t// Also check it is at the top of .go files (but not .sh files, because they must have a shebang first).\n\t\tif filepath.Ext(path) == \".go\" && !bytes.HasPrefix(src, []byte(prefix)) {\n\t\t\tt.Errorf(\"%v: license header not at the top\", path)\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n}", "func (d *portworx) GetLicenseSummary() (torpedovolume.LicenseSummary, error) {\n\tlicenseMgr := d.getLicenseManager()\n\tfeatureMgr := d.getLicenseFeatureManager()\n\tlicenseSummary := torpedovolume.LicenseSummary{}\n\n\tlic, err := licenseMgr.Status(d.getContext(), &pxapi.PxLicenseStatusRequest{})\n\tif err != nil {\n\t\treturn licenseSummary, err\n\t}\n\n\tlicenseSummary.SKU = lic.GetStatus().GetSku()\n\tif lic != nil && lic.Status != nil &&\n\t\tlic.Status.GetConditions() != nil &&\n\t\tlen(lic.Status.GetConditions()) > 0 {\n\t\tlicenseSummary.LicenesConditionMsg = lic.Status.GetConditions()[0].GetMessage()\n\t}\n\n\tfeatures, err := featureMgr.Enumerate(d.getContext(), &pxapi.PxLicensedFeatureEnumerateRequest{})\n\tif err != nil {\n\t\treturn licenseSummary, err\n\t}\n\tlicenseSummary.Features = features.GetFeatures()\n\treturn licenseSummary, nil\n}", "func (d *DBGenerator) readLicense(ctx context.Context) error {\n\t// If no license file given, then we omit the license from the manifests\n\tif d.Opts.LicenseFile == \"\" {\n\t\treturn nil\n\t}\n\n\tvar err error\n\td.LicenseData, err = ioutil.ReadFile(d.Opts.LicenseFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (pa PostalAddress) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func GetLicenseMetadata(key string, value *string) int {\n\tcKey := goToCString(key)\n\tvar cValue = getCArray()\n\tstatus := C.GetLicenseMetadata(cKey, &cValue[0], maxCArrayLength)\n\t*value = ctoGoString(&cValue[0])\n\tfreeCString(cKey)\n\treturn int(status)\n}", "func GetLicense(ctx *pulumi.Context,\n\tname string, id pulumi.IDInput, state *LicenseState, opts ...pulumi.ResourceOption) (*License, error) {\n\tvar resource License\n\terr := ctx.ReadResource(\"consul:index/license:License\", name, id, state, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (repo *GitHubProject) FetchLicense(context *Context) (*License, error) {\n\tif !context.Allow(NetworkAccessFlag) {\n\t\treturn nil, fmt.Errorf(\"network access denied\")\n\t}\n\tlicense, err := fetchLicensesByGitHubAPI(repo)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trepo.license = license\n\treturn license, nil\n}", "func (sra SearchResultsAnswer) AsLicense() (*License, bool) {\n\treturn nil, false\n}", "func writeLicense(manifest model.Manifest) error {\n\tif err := os.MkdirAll(filepath.Join(manifest.OutDir(), \"licenses\"), 0o750); err != nil {\n\t\treturn fmt.Errorf(\"failed to create license dir: %v\", err)\n\t}\n\tfor repo := range manifest.Dependencies.Get() {\n\t\tsrc := filepath.Join(manifest.RepoDir(repo), \"licenses\")\n\t\t// Just skip these, we can fail in the validation tests afterwards for repos we expect license for\n\t\tif _, err := os.Stat(src); os.IsNotExist(err) {\n\t\t\tlog.Warnf(\"skipping license for %v\", repo)\n\t\t\tcontinue\n\t\t}\n\t\t// Package as a tar.gz since there are hundreds of files\n\t\tcmd := util.VerboseCommand(\"tar\", \"-czf\", filepath.Join(manifest.OutDir(), \"licenses\", repo+\".tar.gz\"), \".\")\n\t\tcmd.Dir = src\n\t\tif err := cmd.Run(); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to compress license: %v\", err)\n\t\t}\n\t}\n\treturn nil\n}", "func (d *DefaultDriver) GetLicenseSummary() (LicenseSummary, error) {\n\treturn LicenseSummary{}, nil\n}", "func (o LicenseOutput) LicenseId() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *License) pulumi.StringOutput { return v.LicenseId }).(pulumi.StringOutput)\n}", "func GetLicence(userName, licenceName string) (txt, format string, err error) {\n\tdbQuery := `\n\t\tSELECT licence_text, file_format\n\t\tFROM database_licences\n\t\tWHERE friendly_name ILIKE $2\n\t\tAND (\n\t\t\t\tuser_id = (\n\t\t\t\t\tSELECT user_id\n\t\t\t\t\tFROM users\n\t\t\t\t\tWHERE lower(user_name) = lower($1)\n\t\t\t\t) OR\n\t\t\t\tuser_id = (\n\t\t\t\t\tSELECT user_id\n\t\t\t\t\tFROM users\n\t\t\t\t\tWHERE user_name = 'default'\n\t\t\t\t)\n\t\t\t)`\n\terr = pdb.QueryRow(dbQuery, userName, licenceName).Scan(&txt, &format)\n\tif err != nil {\n\t\tif err == pgx.ErrNoRows {\n\t\t\t// The requested licence text wasn't found\n\t\t\treturn \"\", \"\", errors.New(\"unknown licence\")\n\t\t}\n\t\tlog.Printf(\"Error when retrieving licence '%s', user '%s': %v\\n\", licenceName, userName, err)\n\t\treturn \"\", \"\", err\n\t}\n\treturn txt, format, nil\n}", "func (r *Repository) GetLicenseTemplate() string {\n\tif r == nil || r.LicenseTemplate == nil {\n\t\treturn \"\"\n\t}\n\treturn *r.LicenseTemplate\n}", "func (project *Project) Licenses() Licenses {\n\treturn project.LicenseList\n}", "func NewLicense(ctx *pulumi.Context,\n\tname string, args *LicenseArgs, opts ...pulumi.ResourceOption) (*License, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.License == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'License'\")\n\t}\n\tif args.License != nil {\n\t\targs.License = pulumi.ToSecret(args.License).(pulumi.StringInput)\n\t}\n\tsecrets := pulumi.AdditionalSecretOutputs([]string{\n\t\t\"license\",\n\t})\n\topts = append(opts, secrets)\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource License\n\terr := ctx.RegisterResource(\"consul:index/license:License\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func PrintLicenseBody(key string) error {\n\tl, err := GetLicenseInfo(strings.ToLower(key))\n\n\t// TODO:: err type\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tprintln(l.Body)\n\n\treturn nil\n}", "func (o LookupRegionCommitmentResultOutput) LicenseResource() LicenseResourceCommitmentResponseOutput {\n\treturn o.ApplyT(func(v LookupRegionCommitmentResult) LicenseResourceCommitmentResponse { return v.LicenseResource }).(LicenseResourceCommitmentResponseOutput)\n}", "func getLicenseFile(licenses []string, files []string) (string, error) {\n\tmatches := matchLicenseFile(licenses, files)\n\n\tswitch len(matches) {\n\tcase 0:\n\t\treturn \"\", ErrNoLicenseFile\n\tcase 1:\n\t\treturn matches[0], nil\n\tdefault:\n\t\treturn \"\", ErrMultipleLicenses\n\t}\n}", "func (r *Reader) LicenseFromFile(filePath string) (license *License, err error) {\n\tlicense, err = r.impl.LicenseFromFile(filePath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"classifying file to determine license: %w\", err)\n\t}\n\treturn license, err\n}", "func GetNSLicense(c *NitroClient, querystring string) (NSAPIResponse, error) {\n\tcfg, err := c.GetConfig(\"nslicense\", querystring)\n\tif err != nil {\n\t\treturn NSAPIResponse{}, err\n\t}\n\n\tvar response = new(NSAPIResponse)\n\n\terr = json.Unmarshal(cfg, &response)\n\tif err != nil {\n\t\treturn NSAPIResponse{}, errors.Wrap(err, \"error unmarshalling response body\")\n\t}\n\n\treturn *response, nil\n}", "func (r *RepositoryLicense) GetLicense() *License {\n\tif r == nil {\n\t\treturn nil\n\t}\n\treturn r.License\n}", "func (o IntegrationRuntimeManagedOutput) LicenseType() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *IntegrationRuntimeManaged) pulumi.StringPtrOutput { return v.LicenseType }).(pulumi.StringPtrOutput)\n}", "func ParseLicense(licenseJSON []byte) (license *License, err error) {\n\tlicense = &License{}\n\tif err := json.Unmarshal(licenseJSON, license); err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing SPDX licence: %w\", err)\n\t}\n\treturn license, nil\n}", "func (o LicenseOutput) Product() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *License) pulumi.StringOutput { return v.Product }).(pulumi.StringOutput)\n}", "func licenseWarnings(yada *libgin.RepositoryYAML, repoLicenseURL string, warnings []string) []string {\n\t// check datacite license URL, name and license file title to spot mismatches\n\tcommonLicenses := ReadCommonLicenses()\n\n\t// check if the datacite license can be matched to a common license via URL\n\tlicenseURL, ok := licFromURL(commonLicenses, yada.License.URL)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL (datacite) not found: '%s'\", yada.License.URL))\n\t}\n\n\t// check if the license can be matched to a common license via datacite license name\n\tlicenseName, ok := licFromName(commonLicenses, yada.License.Name)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name (datacite) not found: '%s'\", yada.License.Name))\n\t}\n\n\t// check if the license can be matched to a common license via the header line of the license file\n\tvar licenseHeader DOILicense\n\tcontent, err := readFileAtURL(repoLicenseURL)\n\tif err != nil {\n\t\twarnings = append(warnings, \"Could not access license file\")\n\t} else {\n\t\theadstr := string(content)\n\t\tfileHeader := strings.Split(strings.Replace(headstr, \"\\r\\n\", \"\\n\", -1), \"\\n\")\n\t\tvar ok bool // false if fileHeader 0 or licFromName returns !ok\n\t\tif len(fileHeader) > 0 {\n\t\t\tlicenseHeader, ok = licFromName(commonLicenses, fileHeader[0])\n\t\t}\n\t\tif !ok {\n\t\t\t// Limit license file content in warning message\n\t\t\tif len(headstr) > 20 {\n\t\t\t\theadstr = fmt.Sprintf(\"%s...\", headstr[0:20])\n\t\t\t}\n\t\t\twarnings = append(warnings, fmt.Sprintf(\"License file content header not found: '%s'\", headstr))\n\t\t}\n\t}\n\n\t// check license URL against license name\n\tif licenseURL.Name != licenseName.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL/Name mismatch: '%s'/'%s'\", licenseURL.Name, licenseName.Name))\n\t}\n\n\t// check license name against license file header\n\tif licenseName.Name != licenseHeader.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name/file header mismatch: '%s'/'%s'\", licenseName.Name, licenseHeader.Name))\n\t}\n\n\treturn warnings\n}", "func GetLicensesFiles() []string {\n\treturn []string{LicenseTxt, LicenseMd, License, Copying, Legal, COPYINGv3,\n\t\tReadme, Ftl, GPLv2, gpl20, Bsdl, Copyright, MITtxt, LisenseRst,\n\t\tLisenceHTML, Licenses2}\n}", "func (o *V0037JobProperties) GetLicensesOk() (*string, bool) {\n\tif o == nil || o.Licenses == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Licenses, true\n}", "func (r *Reader) LicenseFromLabel(label string) (license *License) {\n\treturn r.impl.LicenseFromLabel(label)\n}", "func (*LicenseResponse) Descriptor() ([]byte, []int) {\n\treturn file_interservice_license_control_license_control_proto_rawDescGZIP(), []int{1}\n}", "func (o *Operator) GetLicenseCA() ([]byte, error) {\n\tif !o.isOpsCenter() {\n\t\treturn nil, trace.BadParameter(\"not a Gravity Hub\")\n\t}\n\tca, err := pack.ReadCertificateAuthority(o.packages())\n\tif err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\treturn ca.CertPEM, nil\n}", "func (resolver *NpmResolver) ResolvePackageLicense(pkgName, pkgPath string) *Result {\n\tresult := &Result{\n\t\tDependency: pkgName,\n\t}\n\t// resolve from the package.json file\n\tif err := resolver.ResolvePkgFile(result, pkgPath); err != nil {\n\t\tresult.ResolveErrors = append(result.ResolveErrors, err)\n\t}\n\n\t// resolve from the LICENSE file\n\tif err := resolver.ResolveLcsFile(result, pkgPath); err != nil {\n\t\tresult.ResolveErrors = append(result.ResolveErrors, err)\n\t}\n\n\treturn result\n}" ]
[ "0.80683106", "0.7852772", "0.77681726", "0.73551273", "0.7304998", "0.7203316", "0.720249", "0.7114836", "0.711298", "0.7028955", "0.702722", "0.70210373", "0.7013474", "0.70109254", "0.69558066", "0.692713", "0.68597376", "0.6855891", "0.6848694", "0.6824606", "0.6714245", "0.66971505", "0.66578263", "0.6625068", "0.6604176", "0.66006154", "0.65611726", "0.6560872", "0.6552999", "0.6549236", "0.6544883", "0.65438396", "0.65220094", "0.6506668", "0.64603037", "0.6422343", "0.6418875", "0.6418316", "0.64040077", "0.6381505", "0.63459146", "0.6315453", "0.6311751", "0.6293469", "0.62846303", "0.6267545", "0.6266019", "0.6255147", "0.62510043", "0.6243024", "0.62329525", "0.6224682", "0.6188928", "0.6155449", "0.61512357", "0.60927606", "0.60627925", "0.6040298", "0.6039519", "0.60310733", "0.602801", "0.60216856", "0.6018476", "0.60118765", "0.60102284", "0.60040873", "0.6000178", "0.5985985", "0.5982705", "0.5970127", "0.59657466", "0.5964212", "0.5958958", "0.5944573", "0.5941525", "0.59320486", "0.5917077", "0.59155", "0.59075487", "0.59002554", "0.5892451", "0.58834994", "0.5851973", "0.58425677", "0.5815977", "0.58156407", "0.5810044", "0.5806609", "0.5803947", "0.5790142", "0.57875705", "0.5783241", "0.57730204", "0.57557184", "0.5755337", "0.57505286" ]
0.76687586
7
IsStruct returns if v is a struct
func IsStruct(v interface{}) bool { vv := reflect.ValueOf(v) if vv.Kind() == reflect.Ptr { vv = vv.Elem() } return vv.Kind() == reflect.Struct }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func IsStruct(v interface{}) bool {\n\tr := elconv.AsValueRef(reflect.ValueOf(v))\n\treturn r.Kind() == reflect.Struct\n}", "func IsStruct(v interface{}) bool {\n\tt := reflect.TypeOf(v)\n\tif t.Kind() == reflect.Ptr {\n\t\tt = t.Elem()\n\t}\n\treturn t.Kind() == reflect.Struct\n}", "func IsStruct(value interface{}) bool {\n\treturn kindOf(value) == reflect.Struct\n}", "func isStructType(v interface{}) bool {\n\treturn !isBasicType(v) && !isListType(v) && !isMapType(v) && !isEnumType(v)\n}", "func isStruct(aType *toolbox.TypeInfo) bool {\n\treturn len(aType.Fields()) > 0\n}", "func (f *Frugal) IsStruct(t *Type) bool {\n\tt = f.UnderlyingType(t)\n\tif _, ok := frugalBaseTypes[t.Name]; ok {\n\t\treturn false\n\t}\n\treturn t.KeyType == nil && t.ValueType == nil && !f.IsEnum(t)\n}", "func (L *State) IsGoStruct(index int) bool {\n\treturn C.clua_isgostruct(L.s, C.int(index)) != 0\n}", "func (ctx *ASTNodeTypeInfo) IsStruct() bool {\n\t_, ok := ctx.Type.Underlying().(*types.Struct)\n\treturn ok\n}", "func IsValueStruct(v reflect.Value) bool {\n\treturn v.Kind() == reflect.Struct\n}", "func (v *Validator) Struct(structure interface{}) (bool, error) {\n\tif err := v.Validate.Struct(structure); err != nil {\n\t\treturn false, fmt.Errorf(\"invalid structure: %w\", err)\n\t}\n\n\treturn true, nil\n}", "func IsStructObject(data interface{}) bool {\n\treturn typeIs(data, reflect.Struct)\n}", "func (s *Structx) IsStruct(name string) bool {\n\tf, ok := s.Field(name)\n\tif !ok {\n\t\treturn false\n\t}\n\n\treturn IsStruct(f.Value())\n}", "func (*Visibility_Visibility_Visibility) IsYANGGoStruct() {}", "func (*Component) IsYANGGoStruct() {}", "func (*Component_Subcomponent) IsYANGGoStruct() {}", "func (*Visibility_Visibility) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A_List4) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A_List5) IsYANGGoStruct() {}", "func (*Test1_Cont1A_Cont2D) IsYANGGoStruct() {}", "func isStructPtr(t reflect.Type) bool {\n\treturn t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Struct\n}", "func (*Device) IsYANGGoStruct() {}", "func (*Device) IsYANGGoStruct() {}", "func (*Device) IsYANGGoStruct() {}", "func (*Device) IsYANGGoStruct() {}", "func (*Device) IsYANGGoStruct() {}", "func (*Device) IsYANGGoStruct() {}", "func (*Device) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A) IsYANGGoStruct() {}", "func (*Test1_Cont1A) IsYANGGoStruct() {}", "func (*Test1_Cont1A_Cont2A) IsYANGGoStruct() {}", "func (*Test1_Cont1A_List2A) IsYANGGoStruct() {}", "func (c *Container) isStructPtrOrInterface(obj reflect.Value) bool {\n\tswitch obj.Type().Kind() {\n\tcase reflect.Interface:\n\t\treturn true\n\tcase reflect.Ptr:\n\t\tif reflect.Indirect(obj).Type().Kind() == reflect.Struct {\n\t\t\treturn true\n\t\t}\n\tdefault:\n\t}\n\treturn false\n}", "func (*Component_Property) IsYANGGoStruct() {}", "func (*Test1_Cont1BState) IsYANGGoStruct() {}", "func (*OnfTest1Choice_Vehicle) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A_Cont2D) IsYANGGoStruct() {}", "func (v Validator) Struct(i interface{}) error {\n\treturn v.validator.Struct(i)\n}", "func (*OnfTest1_Cont1BState) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1BState) IsYANGGoStruct() {}", "func (*Component_Port) IsYANGGoStruct() {}", "func (*Test1_Cont1BState_List2B) IsYANGGoStruct() {}", "func (src Source) IsStructMap() {}", "func (*Test1_Cont1BState_Cont2C) IsYANGGoStruct() {}", "func isRecursiveStruct(spec compile.TypeSpec, seenSoFar map[string]bool) bool {\n\tswitch t := spec.(type) {\n\tcase *compile.StructSpec:\n\t\t// detected cycle; second time seeing this type\n\t\tif _, found := seenSoFar[t.Name]; found {\n\t\t\treturn true\n\t\t}\n\n\t\t// mark this type as seen\n\t\tseenSoFar[t.Name] = true\n\n\t\t// search all fields of this struct\n\t\tfor _, field := range t.Fields {\n\t\t\tif isRecursiveStruct(field.Type, seenSoFar) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\n\t\t// unmark\n\t\tdelete(seenSoFar, t.Name)\n\n\t// for lists and maps, check element/key types the same way\n\tcase *compile.MapSpec:\n\t\tif isRecursiveStruct(t.KeySpec, seenSoFar) || isRecursiveStruct(t.ValueSpec, seenSoFar) {\n\t\t\treturn true\n\t\t}\n\tcase *compile.ListSpec:\n\t\tif isRecursiveStruct(t.ValueSpec, seenSoFar) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func (*OnfTest1_Cont1A_Cont2A) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A_Cont2A) IsYANGGoStruct() {}", "func (t *Type) IsFuncArgStruct() bool", "func (*OnfTest1_List1A) IsYANGGoStruct() {}", "func (*UseCase_UseCase) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A_List2A) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A_List2A) IsYANGGoStruct() {}", "func (*Component_Fan) IsYANGGoStruct() {}", "func (c *TypeConverter) isRecursiveStruct(fields []*compile.FieldSpec) bool {\n\tfor _, field := range fields {\n\t\tif isRecursiveStruct(field.Type, make(map[string]bool)) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (*Component_Memory) IsYANGGoStruct() {}", "func typeIsPointerToStruct(typ reflect.Type) bool {\n\treturn typ.Kind() == reflect.Ptr && typ.Elem().Kind() == reflect.Struct\n}", "func (*Component_Storage) IsYANGGoStruct() {}", "func (*UseCase_UseCase_UseCase_Visibility) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A_List4_List4A) IsYANGGoStruct() {}", "func validatorStruct(doc interface{}) bool {\n\tval := reflect.ValueOf(doc)\n\tif val.Kind() == reflect.Ptr && !val.IsNil() {\n\t\tval = val.Elem()\n\t}\n\tif val.Kind() != reflect.Struct || val.Type() == reflect.TypeOf(time.Time{}) {\n\t\treturn false\n\t}\n\treturn true\n}", "func isStructPtr(item interface{}) (reflect.Value, error) {\n\tvItemPtr := reflect.ValueOf(item)\n\tif vItemPtr.Kind() != reflect.Ptr {\n\t\treturn reflect.Value{}, fmt.Errorf(\"'item' must be a pointer to a struct\")\n\t}\n\tvItem := vItemPtr.Elem()\n\tif vItem.Kind() != reflect.Struct {\n\t\treturn reflect.Value{}, fmt.Errorf(\"'item' must be a pointer to a struct\")\n\t}\n\treturn vItem, nil\n}", "func (*Component_Backplane) IsYANGGoStruct() {}", "func Struct(s, t interface{}) error {\n\treturn defaultmasker.Struct(s, t)\n}", "func (*OnfTest1_Cont1BState_Cont2C) IsYANGGoStruct() {}", "func (*Enterprise_Enterprise_Enterprise) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1BState_List2B) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1BState_List2B) IsYANGGoStruct() {}", "func (*UseCase_UseCase_UseCase) IsYANGGoStruct() {}", "func (*OnfTest1Choice_Vehicle_ElectricMotor) IsYANGGoStruct() {}", "func (*OnfSwitchModel_SwitchModel_Port) IsYANGGoStruct() {}", "func (*OpenconfigLacp_Lacp_Interfaces_Interface_Members_Member) IsYANGGoStruct() {}", "func (*DeviceGroup_DeviceGroup_DeviceGroup) IsYANGGoStruct() {}", "func (*Enterprise_Enterprise) IsYANGGoStruct() {}", "func (*MapStructTestOne) IsYANGGoStruct() {}", "func (*OnfSwitchModel_SwitchModel) IsYANGGoStruct() {}", "func (v *defaultValidator) ValidateStruct(obj interface{}) error {\n\tvalue := reflect.ValueOf(obj)\n\tvalueType := value.Kind()\n\tif valueType == reflect.Ptr {\n\t\tvalueType = value.Elem().Kind()\n\t}\n\tif valueType == reflect.Struct {\n\t\tv.lazyinit()\n\t\tif err := v.validate.Struct(obj); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (*DeviceGroup_DeviceGroup) IsYANGGoStruct() {}", "func (v *Validator) ValidateStruct(obj interface{}) error {\n\tvalue := reflect.ValueOf(obj)\n\tvalueType := value.Kind()\n\tif valueType == reflect.Ptr {\n\t\tvalueType = value.Elem().Kind()\n\t}\n\tif valueType == reflect.Struct {\n\t\tv.lazyinit()\n\t\tif err := v.validate.Struct(obj); err != nil {\n\t\t\te, ok := err.(validator.ValidationErrors)\n\t\t\tif !ok {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\treturn errors.New(e[0].Translate(v.trans))\n\t\t}\n\t}\n\treturn nil\n}", "func (t *TypeRegistry) ValidateStruct(v interface{}, d func() string) error {\n\trt := reflect.TypeOf(v).Elem()\n\n\tinfo, ok := t.structInfo[rt]\n\tif !ok {\n\t\treturn fmt.Errorf(\"%v: %v is not a know struct type\", d(), rt)\n\t}\n\n\t// There may not be a validator (type is simple enough, etc...).\n\tif info.Validator != nil {\n\t\treturn info.Validator(v, d)\n\t}\n\n\treturn nil\n}", "func (*OnfSwitch_Switch_Port) IsYANGGoStruct() {}", "func (*OnfSwitch_Switch) IsYANGGoStruct() {}", "func (*MapStructTestOneChild) IsYANGGoStruct() {}", "func (*OnfTest1Choice_Vehicle_UnderCarriage) IsYANGGoStruct() {}", "func (*OnfTest1Choice_Vehicle_Battery) IsYANGGoStruct() {}", "func isSameStruct(firstVal, secondVal reflect.Value) (ret bool, err error) {\n\tfirstNum := firstVal.NumField()\n\tsecondNum := secondVal.NumField()\n\tif firstNum != secondNum {\n\t\tret = false\n\t\treturn\n\t}\n\n\tfor idx := 0; idx < firstNum; idx++ {\n\t\tfirstField := firstVal.Field(idx)\n\t\tsecondField := secondVal.Field(idx)\n\t\tret, err = IsSameVal(firstField, secondField)\n\t\tif !ret || err != nil {\n\t\t\tret = false\n\t\t\treturn\n\t\t}\n\t}\n\n\tret = true\n\treturn\n}", "func (v *StructValidator) ValidateStruct(obj interface{}) error {\n\tif kindOfData(obj) == reflect.Struct {\n\t\tv.lazyinit()\n\t\tif err := v.validate.Struct(obj); err != nil {\n\t\t\treturn error(err)\n\t\t}\n\t}\n\treturn nil\n}", "func (*OpenconfigLacp_Lacp_Interfaces_Interface_Members_Member_State) IsYANGGoStruct() {}", "func (*Component_Transceiver) IsYANGGoStruct() {}", "func (t *Type) StructType() *StructType", "func (*OpenconfigInterfaces_Interfaces_Interface_Aggregation) IsYANGGoStruct() {}", "func (*OpenconfigInterfaces_Interfaces_Interface_Aggregation) IsYANGGoStruct() {}", "func (*Component_Fabric) IsYANGGoStruct() {}", "func (*Component_Cpu) IsYANGGoStruct() {}", "func (*OpenconfigInterfaces_Interfaces_Interface_Aggregation_State) IsYANGGoStruct() {}", "func (*OpenconfigInterfaces_Interfaces_Interface_Aggregation_State) IsYANGGoStruct() {}", "func (*OpenconfigInterfaces_Interfaces_Interface_RoutedVlan_Ipv4) IsYANGGoStruct() {}", "func (*OpenconfigInterfaces_Interfaces_Interface_RoutedVlan_Ipv4) IsYANGGoStruct() {}", "func (*Component_OpticalPort) IsYANGGoStruct() {}", "func isNeCrossStructField(fl FieldLevel) bool {\n\tfield := fl.Field()\n\tkind := field.Kind()\n\n\ttopField, currentKind, ok := fl.GetStructFieldOK()\n\tif !ok || currentKind != kind {\n\t\treturn true\n\t}\n\n\tswitch kind {\n\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn topField.Int() != field.Int()\n\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn topField.Uint() != field.Uint()\n\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn topField.Float() != field.Float()\n\n\tcase reflect.Slice, reflect.Map, reflect.Array:\n\t\treturn int64(topField.Len()) != int64(field.Len())\n\n\tcase reflect.Bool:\n\t\treturn topField.Bool() != field.Bool()\n\n\tcase reflect.Struct:\n\n\t\tfieldType := field.Type()\n\n\t\tif fieldType.ConvertibleTo(timeType) && topField.Type().ConvertibleTo(timeType) {\n\n\t\t\tt := field.Convert(timeType).Interface().(time.Time)\n\t\t\tfieldTime := topField.Convert(timeType).Interface().(time.Time)\n\n\t\t\treturn !fieldTime.Equal(t)\n\t\t}\n\n\t\t// Not Same underlying type i.e. struct and time\n\t\tif fieldType != topField.Type() {\n\t\t\treturn true\n\t\t}\n\t}\n\n\t// default reflect.String:\n\treturn topField.String() != field.String()\n}", "func (*OnfSwitchModel_SwitchModel_Attribute) IsYANGGoStruct() {}" ]
[ "0.82171667", "0.7990323", "0.7817168", "0.77442557", "0.77005786", "0.7543898", "0.7345054", "0.7303476", "0.72643065", "0.72182626", "0.69576186", "0.69434875", "0.6671973", "0.65604955", "0.6540829", "0.6474984", "0.6456741", "0.6439632", "0.6424734", "0.6414836", "0.640928", "0.640928", "0.640928", "0.640928", "0.640928", "0.640928", "0.640928", "0.64045495", "0.64045495", "0.640051", "0.6364091", "0.6351348", "0.6332729", "0.632142", "0.6315249", "0.62962395", "0.6289413", "0.6288753", "0.62793344", "0.62793344", "0.62786597", "0.62694556", "0.6263223", "0.6244203", "0.6231801", "0.6229172", "0.6229172", "0.6219109", "0.621817", "0.6210682", "0.6196043", "0.6196043", "0.61942345", "0.6192323", "0.6178871", "0.6176551", "0.6144579", "0.6134908", "0.61347467", "0.6126844", "0.61030805", "0.60964346", "0.6083196", "0.6069724", "0.6066689", "0.60591686", "0.60591686", "0.605743", "0.6020682", "0.60132784", "0.6001633", "0.60002905", "0.6000019", "0.5988639", "0.5975553", "0.5954147", "0.5952846", "0.59525645", "0.59461975", "0.59433883", "0.5941746", "0.5939584", "0.59347755", "0.59346306", "0.5909646", "0.5907424", "0.59011054", "0.58676076", "0.5839434", "0.5838903", "0.5838903", "0.58351713", "0.5834103", "0.5832483", "0.5832483", "0.5829216", "0.5829216", "0.5828878", "0.58191425", "0.58182883" ]
0.79916877
1
Name returns name of struct
func Name(v interface{}) string { return New(v).Name() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (t *typeStruct) Name() string {\n\treturn t.name\n}", "func (t *Struct) String() string { return t.Name }", "func (s *Structx) Name() string {\n\treturn s.value.Type().Name()\n}", "func (s *Struct) Name() string {\n\tname := reflect.TypeOf(s.Ref).Elem().String()\n\n\t// strip the package prefix, as we don't want it explicitly in the name\n\tpkgStrip := strings.Split(name, \".\")\n\tif len(pkgStrip) > 1 {\n\t\treturn pkgStrip[1]\n\t}\n\n\treturn pkgStrip[0]\n}", "func (s *StructField) Name() string {\n\treturn s.name\n}", "func (cmd *CmdStruct) Name() string {\n\treturn MessageType(cmd.CmdID).String()\n}", "func (s *MyTestStruct) Name() string {\n\treturn s.field_Name\n}", "func (ds *DynamicStruct) Name() string {\n\treturn ds.name\n}", "func name(v reflect.StructField) string {\n\tif name, ok := v.Tag.Lookup(\"name\"); ok {\n\t\treturn name\n\t}\n\treturn v.Name\n}", "func structName(entry *yang.Entry, forList bool) (string, error) {\n\tname, ok := entry.Annotation[\"structname\"]\n\tif !ok {\n\t\treturn \"\", status.Errorf(codes.NotFound, \"structname not found in annotations\")\n\t}\n\tif entry.IsList() && forList {\n\t\tkeys, err := listKeys(entry)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\t// if the entry is a list and we are targeting the container\n\t\t// NOTE we still need to support composite keys\n\t\treturn fmt.Sprintf(\"map[%s]*%s\", keys[0].Gotype, name), nil\n\t}\n\treturn fmt.Sprintf(\"*%s\", name), nil\n}", "func (t Type) Name() string {\n\treturn schemas[t%EvCount].Name\n}", "func (t *SentryTaggedStruct) GetName() string {\n\treturn \"\"\n}", "func (p Packet) Name() (name string) {\n\t// todo: think of ways to make this not a compiled in hack\n\t// todo: collectd 4 uses different patterns for some plugins\n\t// https://collectd.org/wiki/index.php/V4_to_v5_migration_guide\n\tswitch p.Plugin {\n\tcase \"df\":\n\t\tname = fmt.Sprintf(\"df_%s_%s\", p.PluginInstance, p.TypeInstance)\n\tcase \"interface\":\n\t\tname = fmt.Sprintf(\"%s_%s\", p.Type, p.PluginInstance)\n\tcase \"load\":\n\t\tname = \"load\"\n\tcase \"memory\":\n\t\tname = fmt.Sprintf(\"memory_%s\", p.TypeInstance)\n\tdefault:\n\t\tname = fmt.Sprintf(\"%s_%s_%s_%s\", p.Plugin, p.PluginInstance, p.Type, p.TypeInstance)\n\t}\n\treturn name\n}", "func (f *Field) Name() string {\n\tjsonTag := reflect.StructTag(f.Tag.Value[1 : len(f.Tag.Value)-1]).Get(\"json\") // Delete first and last quotation\n\tjsonTag = strings.Split(jsonTag, \",\")[0] // This can return \"-\"\n\tif jsonTag != \"\" {\n\t\treturn jsonTag\n\t}\n\n\tif f.Names != nil {\n\t\treturn f.Names[0].Name\n\t}\n\n\treturn f.Type.(*ast.Ident).Name\n}", "func (p *GetField) Name() string { return p.name }", "func (p *PropertyGenerator) StructName() string {\n\tif p.asIterator {\n\t\treturn p.Name.CamelName\n\t}\n\treturn fmt.Sprintf(\"%sProperty\", p.Name.CamelName)\n}", "func (t Type) Name() string {\n\treturn t.impl.Name()\n}", "func (t Type) Name() string {\n\treturn t.name\n}", "func (_struct Struct) String() string {\n\treturn fmt.Sprintf(\"struct:%s\", _struct.Name())\n}", "func (t *Type) GetName() string { return t.Name }", "func (u *Union) Name() string { return u.TypeName }", "func (o FieldOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v Field) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func (t *DynamicMessageType) Name() string {\n\treturn t.spec.FullName\n}", "func (o *DatatypeObject) Name() string {\n\treturn o.name\n}", "func (o *Object) Name() string {\n\tif !o.Boundary {\n\t\tif o.ID < 0 || o.ID > 1188 {\n\t\t\treturn \"nil\"\n\t\t}\n\t\treturn ObjectDefs[o.ID].Name\n\t}\n\tif o.ID < 0 || o.ID >= len(BoundaryDefs) {\n\t\treturn \"nil\"\n\t}\n\treturn BoundaryDefs[o.ID].Name\n}", "func (defn *TypeDefinition) Name() *Name {\n\tswitch {\n\tcase defn == nil:\n\t\treturn nil\n\tcase defn.Scalar != nil:\n\t\treturn defn.Scalar.Name\n\tcase defn.Object != nil:\n\t\treturn defn.Object.Name\n\tcase defn.Union != nil:\n\t\treturn defn.Union.Name\n\tcase defn.Enum != nil:\n\t\treturn defn.Enum.Name\n\tcase defn.InputObject != nil:\n\t\treturn defn.InputObject.Name\n\tdefault:\n\t\treturn nil\n\t}\n}", "func (obj *label) Name() string {\n\treturn obj.name\n}", "func (t GoType) Name() string {\n\treturn \"go:\" + t.refType.Name()\n}", "func (nt *Ntuple) Name() string {\n\treturn nt.name\n}", "func (t Scalar) Name() string {\n\treturn strings.Title(t.Type)\n}", "func (p ByName) Name() string { return p.name }", "func (f *Fieldx) Name() string {\n\treturn f.data.Name\n}", "func (op *Options) StructName() string {\n\tname := op.structName\n\tif name == \"\" {\n\t\tname = \"AutoGenerated\"\n\t}\n\treturn name\n}", "func (i Uint8) Name() string {\n\treturn string(i)\n}", "func (t *Table) StructName() string {\n\tif t.structName == \"\" {\n\t\tt.structName = t.Name.ToCamel()\n\t}\n\treturn t.structName\n}", "func (o TypeOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v Type) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func (o TypeOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v Type) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func (obj *object) getStructName(line string) {\n\t/*nested := false\n\tif !strings.Contains(line, \"type \") {\n\t\tnested = true\n\t}*/\n\n\tline = strings.TrimSpace(line)\n\tline = strings.TrimPrefix(strings.TrimSuffix(line, \"{\"), \"type\")\n\tline = strings.TrimSpace(line)\n\tobj.Name = strings.TrimSpace(strings.TrimSuffix(line, \"struct\"))\n\tif strings.Contains(obj.Name, \"[]\") {\n\t\tobj.Name = strings.TrimSpace(strings.TrimSuffix(obj.Name, \"[]\"))\n\t}\n\tobj.Tp = obj.Name\n\tobj.JsonKey = obj.Name\n\t/*if nested {\n\t\tobj.CommonFileds = append(obj.CommonFileds, &field{JsonKey: obj.Name, Tp: obj.Name})\n\t}*/\n}", "func (v Value) Name() (string, error) {\n\tif v.typ != Name {\n\t\treturn \"\", v.newError(\"%s is not an object name\", v.Raw())\n\t}\n\treturn v.str, nil\n}", "func (f BinaryField) GetName() string {\n\treturn f.name\n}", "func GetNameFromStruct(u interface{}) string {\n\tvar result = ReturnValue{CustomStruct: u}\n\n\t//fmt.Println(result)\n\n\tmsg, ok := result.CustomStruct.(NameOnly)\n\tif ok {\n\t\t//fmt.Printf(\"Message1 is %s\\n\", msg.Name)\n\t\treturn msg.Name\n\t} else {\n\t\treturn \"\"\n\t}\n}", "func (ti *TypeInfo) Name() string {\n\tif ti == nil {\n\t\treturn \"\"\n\t}\n\tif ti.GenDecl == nil {\n\t\treturn \"\"\n\t}\n\tif len(ti.GenDecl.Specs) < 1 {\n\t\treturn \"\"\n\t}\n\tts, ok := ti.GenDecl.Specs[0].(*ast.TypeSpec)\n\tif !ok || ts == nil {\n\t\treturn \"\"\n\t}\n\tif ts.Name == nil {\n\t\treturn \"\"\n\t}\n\treturn ts.Name.Name\n}", "func (at AttributeType) Name() string {\n\tswitch at {\n\tcase AttributeTypeStandardInformation:\n\t\treturn \"$STANDARD_INFORMATION\"\n\tcase AttributeTypeAttributeList:\n\t\treturn \"$ATTRIBUTE_LIST\"\n\tcase AttributeTypeFileName:\n\t\treturn \"$FILE_NAME\"\n\tcase AttributeTypeObjectId:\n\t\treturn \"$OBJECT_ID\"\n\tcase AttributeTypeSecurityDescriptor:\n\t\treturn \"$SECURITY_DESCRIPTOR\"\n\tcase AttributeTypeVolumeName:\n\t\treturn \"$VOLUME_NAME\"\n\tcase AttributeTypeVolumeInformation:\n\t\treturn \"$VOLUME_INFORMATION\"\n\tcase AttributeTypeData:\n\t\treturn \"$DATA\"\n\tcase AttributeTypeIndexRoot:\n\t\treturn \"$INDEX_ROOT\"\n\tcase AttributeTypeIndexAllocation:\n\t\treturn \"$INDEX_ALLOCATION\"\n\tcase AttributeTypeBitmap:\n\t\treturn \"$BITMAP\"\n\tcase AttributeTypeReparsePoint:\n\t\treturn \"$REPARSE_POINT\"\n\tcase AttributeTypeEAInformation:\n\t\treturn \"$EA_INFORMATION\"\n\tcase AttributeTypeEA:\n\t\treturn \"$EA\"\n\tcase AttributeTypePropertySet:\n\t\treturn \"$PROPERTY_SET\"\n\tcase AttributeTypeLoggedUtilityStream:\n\t\treturn \"$LOGGED_UTILITY_STREAM\"\n\t}\n\treturn \"unknown\"\n}", "func (k *Kind) Name() string {\n\treturn \"team\"\n}", "func (*Object) Name() string { return \"object\" }", "func (i Uint64) Name() string {\n\treturn string(i)\n}", "func (e *EDNS) Name() string { return name }", "func (c *STableField) Name() string {\n\tif len(c.alias) > 0 {\n\t\treturn c.alias\n\t}\n\treturn c.spec.Name()\n}", "func (n NamedComponents) Name() string {\n\treturn n.uniqueComponent\n}", "func (sh SubdirectoryHeader) Name() string {\n\treturn string(sh.SubdirectoryName[0 : sh.TypeAndNameLength&0xf])\n}", "func (ifce *Interface) Name() string {\n\treturn ifce.name\n}", "func (ifce *Interface) Name() string {\n\treturn ifce.name\n}", "func (object *Object) Name() string {\n\treturn object.objectType\n}", "func (r *RepoStruct) Name() string {\n\tif r == nil {\n\t\treturn \"\"\n\t}\n\treturn r.name\n}", "func (r *PrivateVirtualInterface) Name() pulumi.StringOutput {\n\treturn (pulumi.StringOutput)(r.s.State[\"name\"])\n}", "func (e *errorT) Name() (string, bool) {\n\tif e.class == nil {\n\t\treturn \"\", false\n\t}\n\treturn string(*e.class), true\n}", "func (t *TypeSpecDef) Name() string {\n\tif t.TypeSpec != nil {\n\t\treturn t.TypeSpec.Name.Name\n\t}\n\n\treturn \"\"\n}", "func (field Field) Name() string {\n\tif len(field.Names) > 0 {\n\t\treturn field.Names[0].String()\n\t}\n\n\t// The field has no name, so we use Type name as the field name.\n\treturn itemTypeName(field.TypeValue.Type).Name\n}", "func (r *Root) Name() string { return \"\" }", "func (d *Driver) Name() string { return d.name }", "func (*BytesSchema) GetName() string {\n\treturn typeBytes\n}", "func (t *Type) Name() (string, error) {\n\tv := reflect.ValueOf(t.ctyType).MethodByName(\"GoString\")\n\tif !v.IsValid() {\n\t\treturn \"\", fmt.Errorf(\"Faild to find GoString(): %#v\", t)\n\t}\n\n\tnv := v.Call([]reflect.Value{})\n\tif len(nv) == 0 {\n\t\treturn \"\", fmt.Errorf(\"Faild to call GoString(): %#v\", v)\n\t}\n\n\tgoString := nv[0].String()\n\t// drop `cty.` prefix for simplicity. (e.g. cty.String => String)\n\tname := strings.Replace(goString, \"cty.\", \"\", -1)\n\n\treturn name, nil\n}", "func (def TypeDefinition) Name() InternalTypeName {\n\treturn def.name\n}", "func (d *Descriptor) Name() string {\n\treturn knownDescriptors[d.uuid.String()].Name\n}", "func (ts *STableSpec) Name() string {\n\treturn ts.name\n}", "func (obj *labelDeclaration) Name() string {\n\treturn obj.name\n}", "func (t *TypeMatcher) GetName() string { return t.Name }", "func (g *generator) Name() string {\n\treturn g.typeName\n}", "func (c *Config) Name(n int) string {\n\treturn fmt.Sprintf(\"%03d.%s\", n, c.Type)\n}", "func (p Primitive) Name() string {\n\tswitch p {\n\tcase Boolean:\n\t\treturn \"boolean\"\n\tcase Int:\n\t\treturn \"int\"\n\tcase Int32:\n\t\treturn \"int32\"\n\tcase Int64:\n\t\treturn \"int64\"\n\tcase UInt:\n\t\treturn \"uint\"\n\tcase UInt32:\n\t\treturn \"uint32\"\n\tcase UInt64:\n\t\treturn \"uint64\"\n\tcase Float32:\n\t\treturn \"float32\"\n\tcase Float64:\n\t\treturn \"float64\"\n\tcase String:\n\t\treturn \"string\"\n\tcase Bytes:\n\t\treturn \"bytes\"\n\tcase Any:\n\t\treturn \"any\"\n\tdefault:\n\t\tpanic(\"unknown primitive type\") // bug\n\t}\n}", "func (o ApiOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v Api) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func (b Binding) Name() string {\n\tbb := b.base()\n\treturn bb.interfaceName + \".\" + bb.elemName\n}", "func (i *Interface) Name() string {\n\treturn name\n}", "func (*UnionSchema) GetName() string {\n\treturn typeUnion\n}", "func (o Outside) Name() string {\n\treturn polName\n}", "func (d *Descriptor) Name() string {\n\treturn d.name\n}", "func (i *Index) Name() string { return i.name }", "func (o LogDescriptorOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v LogDescriptor) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func (v *VCard) Name() string {\n\treturn v.getFirstPropertySingleString(\"fn\")\n}", "func (n *Node) Name() string { return n.notNil().name }", "func (t *TypeStub) Name() string {\n\treturn t.typeName\n}", "func (obj *identity) Name() string {\n\treturn obj.name\n}", "func (f *Field) Name() string {\n\treturn f.field.Name\n}", "func (o ElastigroupSignalOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ElastigroupSignal) string { return v.Name }).(pulumi.StringOutput)\n}", "func (s *Structured) GetName() string {\n\treturn s.cloudEvent.Source\n}", "func (b *BaseType) Name() string {\n\treturn b.name\n}", "func (i *Interface) Name() string {\n\treturn i.name\n}", "func (s *StateTemplate)Name() string {\n\treturn s.op\n}", "func (f frame) name() string {\n\tfn := runtime.FuncForPC(f.pc())\n\tif fn == nil {\n\t\treturn \"unknown\"\n\t}\n\treturn fn.Name()\n}", "func (t *Type) GetName() string {\n\treturn formatGoName(t.Name)\n}", "func (f Frame) name() string {\n\tfn := runtime.FuncForPC(f.pc())\n\tif fn == nil {\n\t\treturn \"unknown\"\n\t}\n\treturn fn.Name()\n}", "func (header *GenericHeader) Name() string {\n\treturn header.HeaderName\n}", "func (ct ContentType) Name() string {\n\treturn string(ct)\n}", "func (ct ContentType) Name() string {\n\treturn string(ct)\n}", "func (o MethodOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v Method) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func (v *templateTableType) Name() string {\n\treturn v.s.SQLName\n}", "func (this *channelMeterStruct) name() string {\n\tname := this.channelName\n\treturn name\n}", "func (v *Vfs) Name() string {\n\tvfs := (*C.sqlite3_vfs)(unsafe.Pointer(v))\n\n\treturn C.GoString(vfs.zName)\n}", "func (o FleetMetricAggregationTypePtrOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *FleetMetricAggregationType) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.Name\n\t}).(pulumi.StringPtrOutput)\n}", "func (p Parameter) Name() string {\n\treturn string(p)\n}" ]
[ "0.78337574", "0.76747423", "0.7607495", "0.731499", "0.7308054", "0.7260499", "0.7234671", "0.72284794", "0.71106577", "0.70448375", "0.6989433", "0.6928384", "0.6928275", "0.6908289", "0.6873566", "0.6862104", "0.6840299", "0.6824419", "0.6818603", "0.6763319", "0.6750533", "0.6737451", "0.67150337", "0.670723", "0.6678336", "0.66729975", "0.6672897", "0.6650884", "0.66252357", "0.6588948", "0.65831774", "0.65749913", "0.6558103", "0.6536164", "0.65229315", "0.65209454", "0.65209454", "0.6513249", "0.65104645", "0.64976573", "0.6495438", "0.6494976", "0.649261", "0.6485848", "0.64763486", "0.64553314", "0.6428283", "0.64251184", "0.64235675", "0.6408917", "0.6405388", "0.6405388", "0.6402905", "0.63978153", "0.63773525", "0.63732433", "0.63706625", "0.63659996", "0.63600343", "0.6357312", "0.6356598", "0.63563013", "0.6351947", "0.63427216", "0.6333539", "0.63331354", "0.63311434", "0.63263845", "0.63117737", "0.6303615", "0.6299807", "0.6288663", "0.62863564", "0.62604403", "0.6245975", "0.6225102", "0.6222994", "0.62228847", "0.6220404", "0.62148607", "0.62028474", "0.62020373", "0.6201727", "0.61947405", "0.61853147", "0.6184643", "0.61823046", "0.6179448", "0.61686075", "0.61655664", "0.61552185", "0.61509323", "0.6149114", "0.6149114", "0.61460537", "0.61430407", "0.6141608", "0.6141594", "0.61365795", "0.613385" ]
0.66797554
24
Struct returns nested struct with name, it panic if not field
func Struct(v interface{}, name string) *Structx { return New(v).Struct(name) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (field Field) Struct() *Struct {\n\treturn field.Parent.Parent.Parent.StructByName(field.Field.ItemTypeName().Name)\n}", "func (s *Structx) Struct(name string) *Structx {\n\tf, ok := s.Field(name)\n\tif !ok {\n\t\tpanic(ErrNotField)\n\t}\n\n\treturn New(f.Value())\n}", "func (p Package) Struct(strct string) Struct {\n\treturn Struct{p, strct}\n}", "func (obj *object) getStructName(line string) {\n\t/*nested := false\n\tif !strings.Contains(line, \"type \") {\n\t\tnested = true\n\t}*/\n\n\tline = strings.TrimSpace(line)\n\tline = strings.TrimPrefix(strings.TrimSuffix(line, \"{\"), \"type\")\n\tline = strings.TrimSpace(line)\n\tobj.Name = strings.TrimSpace(strings.TrimSuffix(line, \"struct\"))\n\tif strings.Contains(obj.Name, \"[]\") {\n\t\tobj.Name = strings.TrimSpace(strings.TrimSuffix(obj.Name, \"[]\"))\n\t}\n\tobj.Tp = obj.Name\n\tobj.JsonKey = obj.Name\n\t/*if nested {\n\t\tobj.CommonFileds = append(obj.CommonFileds, &field{JsonKey: obj.Name, Tp: obj.Name})\n\t}*/\n}", "func (s *StructField) Field(name string) (*StructField, error) {\n\treturn Field(s.Value(), name)\n}", "func createStruct(r io.ReadSeeker) string {\n\ttagType := readByte(r)\n\tname := toPascalCase(getKey(r))\n\ttypeStr := getFieldType(r, tagType)\n\n\treturn fmt.Sprintf(\"type %s %s\", name, typeStr)\n}", "func structFieldByName(typ reflect.Type, name string) (*reflect.StructField, bool) {\n\tvar field *reflect.StructField\n\n\tfieldNames := chainedFieldNameToFieldNames(name)\n\tif len(fieldNames) == 0 {\n\t\treturn nil, false\n\t}\n\n\tfor i, fieldName := range fieldNames {\n\t\tf, ok := typ.FieldByName(fieldName)\n\t\tif !ok {\n\t\t\treturn nil, false\n\t\t}\n\t\tfield = &f\n\n\t\tif i == len(fieldNames)-1 {\n\t\t\tbreak\n\t\t}\n\n\t\ttyp = f.Type\n\t\tif typ.Kind() == reflect.Ptr {\n\t\t\ttyp = typ.Elem()\n\t\t}\n\t}\n\n\treturn field, true\n}", "func compileField(sf reflect.StructField, name string) interface{} {\n\tf := field{sField: sf.Index[0]}\n\n\tf.name = []byte(name)\n\n\tswitch sf.Type.Kind() {\n\tcase reflect.Struct:\n\t\treturn fieldStruct{f.sField, f.name, compileStruct(sf.Type)}\n\tcase reflect.Bool:\n\t\tf.write = encodeBool\n\t\tf.read = decodeBool\n\t\tf.requiredType = 1\n\tcase reflect.Int8:\n\t\tf.write = encodeInt8\n\t\tf.read = decodeInt8\n\t\tf.requiredType = 1\n\tcase reflect.Int16:\n\t\tf.write = encodeInt16\n\t\tf.read = decodeInt16\n\t\tf.requiredType = 2\n\tcase reflect.Int32:\n\t\tf.write = encodeInt32\n\t\tf.read = decodeInt32\n\t\tf.requiredType = 3\n\tcase reflect.Int64:\n\t\tf.write = encodeInt64\n\t\tf.read = decodeInt64\n\t\tf.requiredType = 4\n\tcase reflect.String:\n\t\tf.write = encodeString\n\t\tf.read = decodeString\n\t\tf.requiredType = 8\n\tcase reflect.Map:\n\t\tf.requiredType = 10\n\t\telem := sf.Type.Elem()\n\t\tvar elemField interface{}\n\t\tname := \"map:\" + sf.Name\n\t\tif elem.Kind() != reflect.Interface {\n\t\t\telemField = compileField(reflect.StructField{Type: elem, Index: []int{0}}, name)\n\t\t}\n\t\tf.write = func(w io.Writer, en *msgEncoder, fi reflect.Value) error {\n\t\t\tkeys := fi.MapKeys()\n\t\t\tfor _, key := range keys {\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tv := fi.MapIndex(key)\n\t\t\t\t\twritePrefix(en, w, []byte(key.String()), f.requiredType)\n\t\t\t\t\terr := f.write(w, en, v)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif elemField == nil {\n\t\t\t\t\t\tv := fi.MapIndex(key).Elem()\n\t\t\t\t\t\ttemp := compileField(reflect.StructField{Type: v.Type(), Index: []int{0}}, \"\")\n\t\t\t\t\t\tif f, ok := temp.(field); ok {\n\t\t\t\t\t\t\twritePrefix(en, w, []byte(key.String()), f.requiredType)\n\t\t\t\t\t\t\terr := f.write(w, en, v)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twritePrefix(en, w, []byte(key.String()), 10)\n\t\t\t\t\t\t\tfs := temp.(fieldStruct)\n\t\t\t\t\t\t\terr := write(w, en, fs.m, v)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\twritePrefix(en, w, []byte(key.String()), 10)\n\t\t\t\t\t\tfs := elemField.(fieldStruct)\n\t\t\t\t\t\tv := fi.MapIndex(key)\n\t\t\t\t\t\terr := write(w, en, fs.m, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t\tbs := en.b[:1]\n\t\t\tbs[0] = 0\n\t\t\t_, err := w.Write(bs)\n\t\t\treturn err\n\t\t}\n\t\tf.read = func(r io.Reader, de *msgDecoder, fi reflect.Value) error {\n\n\t\t\tma := reflect.MakeMap(sf.Type)\n\n\t\t\tname, t, err := readPrefix(r, de)\n\t\t\tfor ; t != 0; name, t, err = readPrefix(r, de) {\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tkeyVal := reflect.ValueOf(name)\n\n\t\t\t\tvar val reflect.Value\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tval = reflect.New(elem)\n\t\t\t\t\terr := f.read(r, de, val)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif elemField == nil {\n\t\t\t\t\t\tv, err := fallbackRead(r, de)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t\tval = reflect.ValueOf(v)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tval = reflect.New(elem)\n\t\t\t\t\t\tfs := elemField.(fieldStruct)\n\t\t\t\t\t\terr := read(r, de, fs.m, val)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tma.SetMapIndex(keyVal, val)\n\t\t\t}\n\t\t\tfi.Set(ma)\n\t\t\treturn nil\n\t\t}\n\tcase reflect.Slice:\n\t\tf.requiredType = 9\n\t\telem := sf.Type.Elem()\n\t\tswitch elem.Kind() {\n\t\tcase reflect.Uint8: //Short-cut for byte arrays\n\t\t\tf.requiredType = 7\n\t\t\tf.write = func(w io.Writer, en *msgEncoder, fi reflect.Value) error {\n\t\t\t\tl := fi.Len()\n\t\t\t\tbs := en.b[:4]\n\t\t\t\tbinary.BigEndian.PutUint32(bs, uint32(l))\n\t\t\t\t_, err := w.Write(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\t_, err = w.Write(fi.Bytes())\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tf.read = func(r io.Reader, de *msgDecoder, fi reflect.Value) error {\n\t\t\t\tbs := de.b[:4]\n\t\t\t\t_, err := r.Read(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tl := binary.BigEndian.Uint32(bs)\n\t\t\t\tout := make([]byte, l)\n\t\t\t\t_, err = r.Read(out)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tfi.SetBytes(out)\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase reflect.Int32: //Short-cut for int32 arrays\n\t\t\tf.requiredType = 11\n\t\t\tf.write = func(w io.Writer, en *msgEncoder, fi reflect.Value) error {\n\t\t\t\tl := fi.Len()\n\t\t\t\tbs := en.b[:4]\n\t\t\t\tbinary.BigEndian.PutUint32(bs, uint32(l))\n\t\t\t\t_, err := w.Write(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tdata := fi.Interface().([]int32)\n\t\t\t\tfor i := range data {\n\t\t\t\t\tbinary.BigEndian.PutUint32(bs, uint32(data[i]))\n\t\t\t\t\t_, err := w.Write(bs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tf.read = func(r io.Reader, de *msgDecoder, fi reflect.Value) error {\n\t\t\t\tbs := de.b[:4]\n\t\t\t\t_, err := r.Read(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tl := binary.BigEndian.Uint32(bs)\n\t\t\t\tout := make([]int32, l)\n\t\t\t\tfor i := range out {\n\t\t\t\t\t_, err := r.Read(bs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tout[i] = int32(binary.BigEndian.Uint32(bs))\n\t\t\t\t}\n\t\t\t\tfi.Set(reflect.ValueOf(out))\n\t\t\t\treturn nil\n\t\t\t}\n\t\tdefault:\n\t\t\tname := \"slice:\" + sf.Name\n\t\t\telemField := compileField(reflect.StructField{Type: elem, Index: []int{0}}, name)\n\t\t\tf.write = func(w io.Writer, en *msgEncoder, fi reflect.Value) error {\n\t\t\t\tl := fi.Len()\n\t\t\t\tbs := en.b[:5]\n\t\t\t\tbinary.BigEndian.PutUint32(bs[1:], uint32(l))\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tbs[0] = f.requiredType\n\t\t\t\t} else {\n\t\t\t\t\tbs[0] = 10\n\t\t\t\t}\n\t\t\t\t_, err := w.Write(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\t\t\tv := fi.Index(i)\n\t\t\t\t\t\terr := f.write(w, en, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tf := elemField.(fieldStruct)\n\t\t\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\t\t\tv := fi.Index(i)\n\t\t\t\t\t\terr := write(w, en, f.m, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tf.read = func(r io.Reader, de *msgDecoder, fi reflect.Value) error {\n\t\t\t\tbs := de.b[:5]\n\t\t\t\t_, err := r.Read(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tif bs[0] != f.requiredType {\n\t\t\t\t\t\treturn ErrorIncorrectType\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif bs[0] != 10 {\n\t\t\t\t\t\treturn ErrorIncorrectType\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tl := int(binary.BigEndian.Uint32(bs[1:]))\n\t\t\t\tval := reflect.MakeSlice(sf.Type, l, l)\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\t\t\tv := val.Index(i)\n\t\t\t\t\t\terr := f.read(r, de, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tf := elemField.(fieldStruct)\n\t\t\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\t\t\tv := val.Index(i)\n\t\t\t\t\t\terr := read(r, de, f.m, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfi.Set(val)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\tcase reflect.Float32:\n\t\tf.requiredType = 5\n\t\tf.write = encodeFloat32\n\t\tf.read = decodeFloat32\n\tcase reflect.Float64:\n\t\tf.requiredType = 6\n\t\tf.write = encodeFloat64\n\t\tf.read = decodeFloat64\n\tdefault:\n\t\tpanic(fmt.Errorf(\"Unhandled type %s for %s\", sf.Type.Kind().String(), sf.Name))\n\t}\n\treturn f\n}", "func (x *StructLevelTerseStruct) DefaultGetStructField() *MyStruct {\n if !x.IsSetStructField() {\n return NewMyStruct()\n }\n return x.StructField\n}", "func (x *FieldLevelTerseStruct) DefaultGetStructField() *MyStruct {\n if !x.IsSetStructField() {\n return NewMyStruct()\n }\n return x.StructField\n}", "func (p *Program) GetStruct(name string) *Struct {\n\tif name == \"\" {\n\t\treturn nil\n\t}\n\n\t// That allow to get struct from pointer type\n\tif last := len(name) - 1; name[last] == '*' {\n\t\tname = name[:last]\n\t}\n\n\tname = strings.TrimSpace(name)\n\n\tres, ok := p.Structs[name]\n\tif ok {\n\t\treturn res\n\t}\n\tres, ok = p.Unions[name]\n\tif ok {\n\t\treturn res\n\t}\n\n\treturn nil\n}", "func NestedField(obj *unstructured.Unstructured, name, path string) (interface{}, bool, error) {\n\tj := jsonpath.New(name).AllowMissingKeys(true)\n\ttemplate := fmt.Sprintf(\"{%s}\", path)\n\terr := j.Parse(template)\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\tresults, err := j.FindResults(obj.UnstructuredContent())\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\tif len(results) == 0 || len(results[0]) == 0 {\n\t\treturn nil, false, nil\n\t}\n\t// The input path refers to a unique field, we can assume to have only one result or none.\n\tvalue := results[0][0].Interface()\n\treturn value, true, nil\n}", "func (x *FieldLevelTerseStruct) DefaultGetTerseStructField() *MyStruct {\n if !x.IsSetTerseStructField() {\n return NewMyStruct()\n }\n return x.TerseStructField\n}", "func (pkg *Package) StructByName(structName string) *Struct {\n\tfor _, file := range pkg.Files {\n\t\tif _struct, ok := file.Structs[structName]; ok {\n\t\t\treturn _struct\n\t\t}\n\t}\n\n\treturn nil\n}", "func (sb *schemaBuilder) buildStruct(typ reflect.Type) error {\n\tif sb.types[typ] != nil {\n\t\treturn nil\n\t}\n\n\tif typ == unionType {\n\t\treturn fmt.Errorf(\"schemabuilder.Union can only be used as an embedded anonymous non-pointer struct\")\n\t}\n\n\tif hasUnionMarkerEmbedded(typ) {\n\t\treturn sb.buildUnionStruct(typ)\n\t} else if hasInterfaceMarkerEmbedded(typ) {\n\t\treturn sb.buildInterfaceStruct(typ)\n\t}\n\tvar name string\n\tvar description string\n\tvar methods Methods\n\tvar objectKey string\n\tif object, ok := sb.objects[typ]; ok {\n\t\tname = object.Name\n\t\tdescription = object.Description\n\t\tmethods = object.Methods\n\t\tobjectKey = object.key\n\t} else {\n\t\tif typ.Name() != \"query\" && typ.Name() != \"mutation\" && typ.Name() != \"Subscription\" {\n\t\t\treturn fmt.Errorf(\"%s not registered as object\", typ.Name())\n\t\t}\n\t}\n\n\tif name == \"\" {\n\t\tname = typ.Name()\n\t\tif name == \"\" {\n\t\t\treturn fmt.Errorf(\"bad type %s: should have a name\", typ)\n\t\t}\n\t}\n\n\tobject := &graphql.Object{\n\t\tName: name,\n\t\tDescription: description,\n\t\tFields: make(map[string]*graphql.Field),\n\t\tInterfaces: make(map[string]*graphql.Interface),\n\t}\n\tsb.types[typ] = object\n\n\t// for i := 0; i < typ.NumField(); i++ {\n\t// \tfield := typ.Field(i)\n\t// \tfieldInfo, err := parseGraphQLFieldInfo(field)\n\t// \tif err != nil {\n\t// \t\treturn fmt.Errorf(\"bad type %s: %s\", typ, fieldInfo.Name)\n\t// \t}\n\t// \tif fieldInfo.Skipped {\n\t// \t\tcontinue\n\t// \t}\n\n\t// \t//No need for this as struct are generated from proto\n\t// \tif _, ok := object.Fields[fieldInfo.Name]; ok {\n\t// \t\treturn fmt.Errorf(\"bad type %s: two fields named %s\", typ, fieldInfo.Name)\n\t// \t}\n\n\t// \tbuilt, err := sb.buildField(field)\n\t// \tif err != nil {\n\t// \t\treturn fmt.Errorf(\"bad field %s on type %s: %s\", fieldInfo.Name, typ, err)\n\t// \t}\n\t// \tobject.Fields[fieldInfo.Name] = built\n\t// \tif fieldInfo.KeyField {\n\t// \t\tif object.KeyField != nil {\n\t// \t\t\treturn fmt.Errorf(\"bad type %s: multiple key fields\", typ)\n\t// \t\t}\n\t// \t\tif !isScalarType(built.Type) {\n\t// \t\t\treturn fmt.Errorf(\"bad type %s: key type must be scalar, got %T\", typ, built.Type)\n\t// \t\t}\n\t// \t\tobject.KeyField = built\n\t// \t}\n\t// }\n\n\tvar names []string\n\tfor name := range methods {\n\t\tnames = append(names, name)\n\t}\n\tsort.Strings(names)\n\n\tfor _, name := range names {\n\t\tmethod := methods[name]\n\n\t\t// if method.Batch {\n\t\t// \tbatchField, err := sb.buildBatchFunctionWithFallback(typ, method)\n\t\t// \tif err != nil {\n\t\t// \t\treturn err\n\t\t// \t}\n\t\t// \tobject.Fields[name] = batchField\n\t\t// \tcontinue\n\t\t// }\n\n\t\tbuilt, err := sb.buildFunction(typ, method)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"bad method %s on type %s: %s\", name, typ, err)\n\t\t}\n\t\tobject.Fields[name] = built\n\t}\n\n\tif objectKey != \"\" {\n\t\tkeyPtr, ok := object.Fields[objectKey]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"key field doesn't exist on object\")\n\t\t}\n\n\t\tif !isTypeScalar(keyPtr.Type) {\n\t\t\treturn fmt.Errorf(\"bad type %s: key type must be scalar, got %s\", typ, keyPtr.Type.String())\n\t\t}\n\t\tobject.KeyField = keyPtr\n\t}\n\n\treturn nil\n}", "func Field(v reflect.StructField) (name string, mapped bool) {\n\tns := v.Tag.Get(\"ns\")\n\tif ns != \"\" {\n\t\tmapped = true\n\t\tname = ns\n\t\treturn\n\t}\n\tname = v.Name\n\treturn\n}", "func (k *key) Struct() *key {\n\treturn k\n}", "func (fields List) Get(name string) Field {\n\tvar isj bool\n\tvar jname string\n\tvar jpath string\n\tdot := strings.IndexByte(name, '.')\n\tif dot != -1 {\n\t\tisj = true\n\t\tjname = name[:dot]\n\t\tjpath = name[dot+1:]\n\t}\n\tb := ptob(fields.p)\n\tvar i int\n\tfor {\n\t\t// read the fname\n\t\tvar fname string\n\t\tx, n := uvarint(b[i:])\n\t\tif n == 0 {\n\t\t\tbreak\n\t\t}\n\t\tif useSharedNames {\n\t\t\tfname = sstring.Load(x)\n\t\t\ti += n\n\t\t} else {\n\t\t\tfname = btoa(b[i+n : i+n+x])\n\t\t\ti += n + x\n\t\t}\n\t\tkind := Kind(b[i])\n\t\ti++\n\t\tvar data string\n\t\tif datakind(kind) {\n\t\t\tx, n = uvarint(b[i:])\n\t\t\tdata = btoa(b[i+n : i+n+x])\n\t\t\ti += n + x\n\t\t}\n\t\tif kind == JSON && isj {\n\t\t\tif jname < fname {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif fname == jname {\n\t\t\t\tres := gjson.Get(data, jpath)\n\t\t\t\tif res.Exists() {\n\t\t\t\t\treturn bfield(name, Kind(res.Type), res.String())\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif name < fname {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif fname == name {\n\t\t\t\treturn bfield(name, kind, data)\n\t\t\t}\n\t\t}\n\t}\n\treturn ZeroField\n}", "func compileStruct(t reflect.Type) map[string]interface{} {\n\tfs := map[string]interface{}{}\n\tcount := t.NumField()\n\tfor i := 0; i < count; i++ {\n\t\tf := t.Field(i)\n\t\tvar name string\n\t\tif !f.Anonymous {\n\t\t\tname = f.Name\n\t\t\tif tName := f.Tag.Get(\"nbt\"); len(tName) > 0 {\n\t\t\t\tname = tName\n\t\t\t}\n\t\t\tif name == \"ignore\" || f.Tag.Get(\"ignore\") == \"true\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t} else {\n\t\t\tname = f.Type.Name()\n\t\t\tif tName := f.Tag.Get(\"nbt\"); len(tName) > 0 {\n\t\t\t\tname = tName\n\t\t\t}\n\t\t\tif name == \"ignore\" || f.Tag.Get(\"ignore\") == \"true\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tfs[name] = compileField(f, name)\n\t}\n\treturn fs\n}", "func fieldArgNamesStruct(obj any, path string, nest bool, allArgs map[string]reflect.Value) {\n\tif kit.IfaceIsNil(obj) {\n\t\treturn\n\t}\n\tov := reflect.ValueOf(obj)\n\tif ov.Kind() == reflect.Pointer && ov.IsNil() {\n\t\treturn\n\t}\n\tval := kit.NonPtrValue(ov)\n\ttyp := val.Type()\n\tfor i := 0; i < typ.NumField(); i++ {\n\t\tf := typ.Field(i)\n\t\tfv := val.Field(i)\n\t\tif kit.NonPtrType(f.Type).Kind() == reflect.Struct {\n\t\t\tnwPath := f.Name\n\t\t\tif path != \"\" {\n\t\t\t\tnwPath = path + \".\" + nwPath\n\t\t\t}\n\t\t\tnwNest := nest\n\t\t\tif !nwNest {\n\t\t\t\tneststr, ok := f.Tag.Lookup(\"nest\")\n\t\t\t\tif ok && (neststr == \"+\" || neststr == \"true\") {\n\t\t\t\t\tnwNest = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tfieldArgNamesStruct(kit.PtrValue(fv).Interface(), nwPath, nwNest, allArgs)\n\t\t\tcontinue\n\t\t}\n\t\tpval := kit.PtrValue(fv)\n\t\taddAllCases(f.Name, path, pval, allArgs)\n\t\tif f.Type.Kind() == reflect.Bool {\n\t\t\taddAllCases(\"No\"+f.Name, path, pval, allArgs)\n\t\t}\n\t\t// now process adding non-nested version of field\n\t\tif path == \"\" || nest {\n\t\t\tcontinue\n\t\t}\n\t\tneststr, ok := f.Tag.Lookup(\"nest\")\n\t\tif ok && (neststr == \"+\" || neststr == \"true\") {\n\t\t\tcontinue\n\t\t}\n\t\tif _, has := allArgs[f.Name]; has {\n\t\t\tmpi.Printf(\"econfig Field: %s.%s cannot be added as a non-nested %s arg because it has already been registered -- add 'nest:'+'' field tag to the one you want to keep only as a nested arg with path, to eliminate this message\\n\", path, f.Name, f.Name)\n\t\t\tcontinue\n\t\t}\n\t\taddAllCases(f.Name, \"\", pval, allArgs)\n\t\tif f.Type.Kind() == reflect.Bool {\n\t\t\taddAllCases(\"No\"+f.Name, \"\", pval, allArgs)\n\t\t}\n\t}\n}", "func (d *Data) Struct() *types.Struct {\n\tst := &types.Struct{\n\t\tFields: map[string]*types.Value{\n\t\t\tqueryField: d.Query.Value(),\n\t\t\ttokenField: toString(d.Token),\n\t\t},\n\t}\n\tif d.ServerURL != nil {\n\t\tst.Fields[serverURLField] = toString(d.ServerURL.String())\n\t}\n\tif d.MultiFrame {\n\t\tst.Fields[multiFrameField] = toBool(d.MultiFrame)\n\t}\n\tif d.MultiFrameWindowSize > 0 {\n\t\tst.Fields[multiFrameWindowSize] = toFloat64(float64(d.MultiFrameWindowSize))\n\t}\n\tif d.MultiFrameWindowAge > 0 {\n\t\tst.Fields[multiFrameWindowAge] = toFloat64(float64(d.MultiFrameWindowAge / time.Minute))\n\t}\n\treturn st\n}", "func GetStructFieldByName(st interface{}, fieldName string) interface{} {\n\tstv := reflect.ValueOf(st)\n\tif IsPtr(st) {\n\t\tstv = stv.Elem()\n\t}\n\n\tv := stv.FieldByName(fieldName)\n\tif !v.IsValid() {\n\t\treturn nil\n\t}\n\n\tswitch v.Kind() {\n\tcase reflect.Chan,\n\t\treflect.Func,\n\t\treflect.Slice,\n\t\treflect.Array,\n\t\treflect.Interface,\n\t\treflect.Ptr,\n\t\treflect.Map:\n\t\tif v.IsNil() {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\treturn v.Interface()\n}", "func getTag(t *reflect.Type, field string, tagName string) {\n var (\n tagVal string\n err error\n )\n fieldVal, ok := (*t).FieldByName(field)\n if ok {\n tagVal = fieldVal.Tag.Get(tagName)\n } else {\n err = errors.New(\"no field named:\" + field)\n }\n\n fmt.Printf(\"get struct[%s] tag[%s]: %s, error:%v\\n\", field, tagName, tagVal, err)\n fmt.Println(\"\")\n}", "func (w StructTemplater) Struct(reflect.Value) error {\n\treturn nil\n}", "func (s *Structx) Field(name string) (*Fieldx, bool) {\n\tf, ok := s.value.Type().FieldByName(name)\n\tif !ok {\n\t\treturn nil, false\n\t}\n\n\tff := &Fieldx{\n\t\tdata: f,\n\t\tvalue: s.value.FieldByName(name),\n\t}\n\n\treturn ff, true\n}", "func structsTest() {\n\ttype Data struct {\n\t\tname int\n\t\taddress int\n\t\tphone int\n\t}\n\n\tvar d1 Data\n\td1.name = 1\n\tfmt.Println(d1)\n\td2 := Data{1, 2, 3} //literal declaration, can also explicitly name with {field:value}\n\t_ = d2\n}", "func Structures() {\r\n\tdetails := myStruct{name: \"Chetan\", age: 31, frnd: friends{location: \"Bangalore\"}}\r\n\tfmt.Println(details) // {Chetan 31 {Bangalore}}\r\n\tfmt.Println(details.name) // Chetan\r\n\r\n\t// Overriding default value\r\n\tdetails.name = \"Chetan Patige\"\r\n\tfmt.Println(details.name) // Chetan Patige\r\n}", "func (node *selfNode) packToStructByFieldName(st reflect.Value) (err error) {\n\n\tnodeName := node.head.String()\n\tfor _, n := range node.values {\n\t\tif _, ok := n.(*selfNode); !ok {\n\t\t\treturn n.newPackError(\"field `\" + nodeName + \"` should be only made of lists\")\n\t\t}\n\t\tvalueNode := n.(*selfNode)\n\t\tfieldName := publicName(valueNode.head.String())\n\t\ttargetField := st.FieldByName(fieldName)\n\t\tif !targetField.IsValid() {\n\t\t\treturn valueNode.newPackError(\"undefined field `\" + fieldName + \"` for node `\" + nodeName + \"`\")\n\t\t}\n\n\t\tif err = valueNode.packIntoField(fieldName, targetField); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\treturn nil\n}", "func name(v reflect.StructField) string {\n\tif name, ok := v.Tag.Lookup(\"name\"); ok {\n\t\treturn name\n\t}\n\treturn v.Name\n}", "func Struct(s, t interface{}) error {\n\treturn defaultmasker.Struct(s, t)\n}", "func (ds *DynamicStruct) FieldByName(name string) (reflect.StructField, bool) {\n\treturn ds.rt.FieldByName(name)\n}", "func (t *Struct) String() string { return t.Name }", "func (db *DB) GetStruct(s interface{}, where string, params ...interface{}) error {\n\n structType := reflect.TypeOf(s)\n if structType.Kind() != reflect.Ptr {\n return errors.New(fmt.Sprintf(\"struct must be a pointer, but got %v\", structType))\n }\n structType = structType.Elem()\n\n v := reflect.ValueOf(s)\n if v.IsNil() {\n return errors.New(fmt.Sprintf(\"struct can not be nil, but got %v\", s))\n }\n\n qi := SqlQueryInfo{\n Limit: 1,\n Where: where,\n Params: params,\n }\n rows, fields, err := db.rawSelectByStruct(structType, qi)\n if err != nil {\n return err\n }\n defer rows.Close()\n\n if rows.Next() {\n err = rawScanStruct(v, fields, rows)\n if err != nil {\n return err\n }\n if moreThanOneRow := rows.Next(); moreThanOneRow {\n return errors.New(\"more than one row found\")\n }\n }\n return nil\n}", "func parseStructField(cache structCache, key, sk, keytail string, values []string, target reflect.Value) {\n\tl, ok := cache[sk]\n\tif !ok {\n\t\tpanic(KeyError{\n\t\t\tFullKey: key,\n\t\t\tKey: kpath(key, keytail),\n\t\t\tType: target.Type(),\n\t\t\tField: sk,\n\t\t})\n\t}\n\tf := target.Field(l.offset)\n\n\tl.parse(key, keytail, values, f)\n}", "func New(s interface{}) *Struct {\n\treturn &Struct{\n\t\traw: s,\n\t\tvalue: structVal(s),\n\t\tTagName: DefaultTagName,\n\t}\n}", "func lookup(s *types.Scope, name string) *types.Struct {\n\tif o := s.Lookup(name); o != nil {\n\t\tu := o.Type().Underlying()\n\t\tif s, ok := u.(*types.Struct); ok {\n\t\t\treturn s\n\t\t}\n\t}\n\tfor i := 0; i < s.NumChildren(); i++ {\n\t\ts := lookup(s.Child(i), name)\n\t\tif s != nil {\n\t\t\treturn s\n\t\t}\n\t}\n\treturn nil\n}", "func structName(entry *yang.Entry, forList bool) (string, error) {\n\tname, ok := entry.Annotation[\"structname\"]\n\tif !ok {\n\t\treturn \"\", status.Errorf(codes.NotFound, \"structname not found in annotations\")\n\t}\n\tif entry.IsList() && forList {\n\t\tkeys, err := listKeys(entry)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\t// if the entry is a list and we are targeting the container\n\t\t// NOTE we still need to support composite keys\n\t\treturn fmt.Sprintf(\"map[%s]*%s\", keys[0].Gotype, name), nil\n\t}\n\treturn fmt.Sprintf(\"*%s\", name), nil\n}", "func (f *Field) Field(name string) *Field {\n\tfield, ok := f.FieldOk(name)\n\tif !ok {\n\t\tpanic(\"field not found\")\n\t}\n\n\treturn field\n}", "func BuildStruct(s Servable, theType reflect.Type, theValue reflect.Value, req *http.Request) {\n\tif theValue.Kind() == reflect.Invalid {\n\t\tlog.Info(\"value is invalid, please check grpc-fieldmapping\")\n\t}\n\tconvertor := components(req).Convertor(theValue.Type().Name())\n\tif convertor != nil {\n\t\ttheValue.Set(convertor(req).Elem())\n\t\treturn\n\t}\n\n\tfieldNum := theType.NumField()\n\tfor i := 0; i < fieldNum; i++ {\n\t\tfieldName := theType.Field(i).Name\n\t\tif fieldName[0] < 'A' || fieldName[0] > 'Z' {\n\t\t\tcontinue\n\t\t}\n\t\tfieldValue := theValue.FieldByName(fieldName)\n\t\tif fieldValue.Kind() == reflect.Ptr && fieldValue.Type().Elem().Kind() == reflect.Struct {\n\t\t\tconvertor := components(req).Convertor(fieldValue.Type().Elem().Name())\n\t\t\tif convertor != nil {\n\t\t\t\tfieldValue.Set(convertor(req))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tBuildStruct(s, fieldValue.Type().Elem(), fieldValue.Elem(), req)\n\t\t\tcontinue\n\t\t}\n\t\tv, ok := findValue(fieldName, req)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\t\terr := setValue(theType.Field(i).Type, fieldValue, v)\n\t\tlogErrorIf(err)\n\t}\n}", "func toStructType(t *types.Struct, ctx GoTypeFinder) (typ reflect.Type, err error) {\n\tn := t.NumFields()\n\tflds := make([]reflect.StructField, n)\n\tfor i := 0; i < n; i++ {\n\t\tv := t.Field(i)\n\t\tif flds[i], err = toStructField(v, t.Tag(i), ctx); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\treturn reflect.StructOf(flds), nil\n}", "func Get(v reflect.Value, name string) reflect.Value {\n\tif v.Kind() == reflect.Interface {\n\t\tv = v.Elem()\n\t}\n\t// dereference pointers\n\tfor v.Kind() == reflect.Ptr {\n\t\tv = v.Elem()\n\t}\n\tswitch v.Kind() {\n\tcase reflect.Struct:\n\t\ttyp := v.Type()\n\t\tfor i := 0; i < typ.NumField(); i++ {\n\t\t\tf := typ.Field(i)\n\t\t\tif f.PkgPath != \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tns, mapped := Field(f)\n\t\t\tif (f.Anonymous && !mapped) || ns == \"-\" {\n\t\t\t\tnV := Get(v.Field(i), name)\n\t\t\t\tif nV.IsValid() {\n\t\t\t\t\treturn nV\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ns == name {\n\t\t\t\treturn v.Field(i)\n\t\t\t}\n\t\t}\n\tcase reflect.Map:\n\t\treturn v.MapIndex(reflect.ValueOf(name))\n\t}\n\treturn reflect.Value{}\n}", "func (s *Struct) nested(val reflect.Value) interface{} {\n\tvar finalVal interface{}\n\n\tv := reflect.ValueOf(val.Interface())\n\tif v.Kind() == reflect.Ptr {\n\t\tv = v.Elem()\n\t}\n\n\tswitch v.Kind() {\n\tcase reflect.Struct:\n\t\tn := New(val.Interface())\n\t\tn.TagName = s.TagName\n\t\tm := n.Map()\n\n\t\t// do not add the converted value if there are no exported fields, ie:\n\t\t// time.Time\n\t\tif len(m) == 0 {\n\t\t\tfinalVal = val.Interface()\n\t\t} else {\n\t\t\tfinalVal = m\n\t\t}\n\tcase reflect.Map:\n\t\t// get the element type of the map\n\t\tmapElem := val.Type()\n\t\tswitch val.Type().Kind() {\n\t\tcase reflect.Ptr, reflect.Array, reflect.Map,\n\t\t\treflect.Slice, reflect.Chan:\n\t\t\tmapElem = val.Type().Elem()\n\t\t\tif mapElem.Kind() == reflect.Ptr {\n\t\t\t\tmapElem = mapElem.Elem()\n\t\t\t}\n\t\t}\n\n\t\t// only iterate over struct types, ie: map[string]StructType,\n\t\t// map[string][]StructType,\n\t\tif mapElem.Kind() == reflect.Struct ||\n\t\t\t(mapElem.Kind() == reflect.Slice &&\n\t\t\t\tmapElem.Elem().Kind() == reflect.Struct) {\n\t\t\tm := make(map[string]interface{}, val.Len())\n\t\t\tfor _, k := range val.MapKeys() {\n\t\t\t\tm[k.String()] = s.nested(val.MapIndex(k))\n\t\t\t}\n\t\t\tfinalVal = m\n\t\t\tbreak\n\t\t}\n\n\t\t// TODO(arslan): should this be optional?\n\t\tfinalVal = val.Interface()\n\tcase reflect.Slice, reflect.Array:\n\t\tif val.Type().Kind() == reflect.Interface {\n\t\t\tfinalVal = val.Interface()\n\t\t\tbreak\n\t\t}\n\n\t\t// TODO(arslan): should this be optional?\n\t\t// do not iterate of non struct types, just pass the value. Ie: []int,\n\t\t// []string, co... We only iterate further if it's a struct.\n\t\t// i.e []foo or []*foo\n\t\tif val.Type().Elem().Kind() != reflect.Struct &&\n\t\t\t!(val.Type().Elem().Kind() == reflect.Ptr &&\n\t\t\t\tval.Type().Elem().Elem().Kind() == reflect.Struct) {\n\t\t\tfinalVal = val.Interface()\n\t\t\tbreak\n\t\t}\n\n\t\tslices := make([]interface{}, val.Len())\n\t\tfor x := 0; x < val.Len(); x++ {\n\t\t\tslices[x] = s.nested(val.Index(x))\n\t\t}\n\t\tfinalVal = slices\n\tdefault:\n\t\tfinalVal = val.Interface()\n\t}\n\n\treturn finalVal\n}", "func structFromProg(prog *loader.Program, packageName, objectName string) (*types.Struct, error) {\n\t// Lookup package.\n\tpkg := prog.Package(packageName)\n\tif pkg == nil {\n\t\treturn nil, errors.Errorf(\"Package %s not found\", packageName)\n\t}\n\n\t// Lookup struct object.\n\tobj := pkg.Pkg.Scope().Lookup(objectName)\n\tif obj == nil {\n\t\treturn nil, errors.Errorf(\"Definition %s.%s not found\", packageName, objectName)\n\t}\n\tobjType := obj.Type().Underlying()\n\tstructType, ok := objType.(*types.Struct)\n\tif !ok {\n\t\treturn nil, errors.Errorf(\"%s type is %T, want *types.Struct\", obj.Id(), objType)\n\t}\n\treturn structType, nil\n}", "func (t *Type) StructType() *StructType", "func StructFor(tableOrQueue string) (proto.Message, error) {\n\ttableOrQueue = strcase.ToKebab(tableOrQueue)\n\n\tif tableOrQueue == \"pkg\" || tableOrQueue == \"pkgs\" {\n\t\ttableOrQueue = TablePackages\n\t}\n\n\tswitch tableOrQueue {\n\t// N.B.: Metadata type is arbitrary on a per-key basis, so unsupported here.\n\t// case TableMetadata:\n\n\tcase inflection.Plural(TablePackages), inflection.Singular(TablePackages):\n\t\treturn &domain.Package{}, nil\n\n\tcase inflection.Plural(TablePendingReferences), inflection.Singular(TablePendingReferences):\n\t\treturn &domain.PendingReferences{}, nil\n\n\tcase inflection.Plural(TableCrawlResults), inflection.Singular(TableCrawlResults):\n\t\treturn &domain.CrawlResult{}, nil\n\n\tcase inflection.Plural(TableToCrawl), inflection.Singular(TableToCrawl):\n\t\treturn &domain.ToCrawlEntry{}, nil\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unrecognized or unsupported table or queue %q\", tableOrQueue)\n\t}\n}", "func execmStructField(_ int, p *gop.Context) {\n\targs := p.GetArgs(2)\n\tret := args[0].(*types.Struct).Field(args[1].(int))\n\tp.Ret(2, ret)\n}", "func (t *Thrift) GetStruct(name string) (*StructLike, bool) {\n\tfor _, st := range t.Structs {\n\t\tif st.Name == name {\n\t\t\treturn st, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func execNewStruct(_ int, p *gop.Context) {\n\targs := p.GetArgs(2)\n\tret := types.NewStruct(args[0].([]*types.Var), args[1].([]string))\n\tp.Ret(2, ret)\n}", "func getSymbolStructField(symbol string, symbolRate *exchangeRateTable) *ohlcData {\n\tswitch symbol {\n\tcase \"EURUSD\":\n\t\treturn &symbolRate.EURUSD\n\tcase \"GBPUSD\":\n\t\treturn &symbolRate.GBPUSD\n\tcase \"USDJPY\":\n\t\treturn &symbolRate.USDJPY\n\tcase \"AUDCAD\":\n\t\treturn &symbolRate.AUDCAD\n\tdefault:\n\t\treturn nil\n\t}\n}", "func (dec *Decoder) ReadStruct(t reflect.Type) {\n\tname := dec.ReadSafeString()\n\tcount := dec.ReadInt()\n\tnames := make([]string, count)\n\tfor i := 0; i < count; i++ {\n\t\tdec.decodeString(stringType, dec.NextByte(), &names[i])\n\t}\n\tdec.Skip()\n\tdec.ref = append(dec.ref, makeStructInfo(name, names, t))\n}", "func structToSchema(prog *Program, name, tagName string, ref Reference) (*Schema, error) {\n\tschema := &Schema{\n\t\tTitle: name,\n\t\tDescription: ref.Info,\n\t\tType: \"object\",\n\t\tProperties: map[string]*Schema{},\n\t}\n\n\tfor _, p := range ref.Fields {\n\t\tif p.KindField == nil {\n\t\t\treturn nil, fmt.Errorf(\"p.KindField is nil for %v\", name)\n\t\t}\n\n\t\tname = goutil.TagName(p.KindField, tagName)\n\n\t\tif name == \"-\" {\n\t\t\tcontinue\n\t\t}\n\t\tif name == \"\" {\n\t\t\tname = p.Name\n\t\t}\n\n\t\tprop, err := fieldToSchema(prog, name, tagName, ref, p.KindField)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot parse %v: %v\", ref.Lookup, err)\n\t\t}\n\n\t\tif !sliceutil.Contains([]string{\"path\", \"query\", \"form\"}, ref.Context) {\n\t\t\tfixRequired(schema, prop)\n\t\t}\n\n\t\tif prop == nil {\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"structToSchema: prop is nil for field %#v in %#v\",\n\t\t\t\tname, ref.Lookup)\n\t\t}\n\n\t\tschema.Properties[name] = prop\n\t}\n\n\treturn schema, nil\n}", "func (s *StructField) Name() string {\n\treturn s.name\n}", "func lookupFieldInStruct(reflectValue reflect.Value, name string) (interface{}, bool) {\n\tfield := reflectValue.FieldByName(name)\n\tif field.IsValid() {\n\t\treturn field.Interface(), truth(field)\n\t}\n\tmethod := reflectValue.MethodByName(name)\n\tif method.IsValid() && method.Type().NumIn() == 1 {\n\t\tout := method.Call(nil)[0]\n\t\treturn out.Interface(), truth(out)\n\t}\n\treturn nil, false\n}", "func newStructFLS(p interface{}) (FieldLoadSaver, error) {\n\tv := reflect.ValueOf(p)\n\tif v.Kind() != reflect.Ptr || v.IsNil() || v.Elem().Kind() != reflect.Struct {\n\t\treturn nil, ErrInvalidDocumentType\n\t}\n\treturn structFLS{v.Elem()}, nil\n}", "func (c *Context) Struct() *starlarkstruct.Struct {\n\tdict := starlark.StringDict{\n\t\t\"set\": starlark.NewBuiltin(\"set\", c.setValue),\n\t\t\"get\": starlark.NewBuiltin(\"get\", c.getValue),\n\t\t\"get_config\": starlark.NewBuiltin(\"get_config\", c.GetConfig),\n\t\t\"get_secret\": starlark.NewBuiltin(\"get_secret\", c.GetSecret),\n\t}\n\n\tfor k, v := range c.results {\n\t\tdict[k] = v\n\t}\n\n\treturn starlarkstruct.FromStringDict(starlark.String(\"context\"), dict)\n}", "func (sb *schemaBuilder) buildField(field reflect.StructField) (*graphql.Field, error) {\n\tretType, err := sb.getType(field.Type)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &graphql.Field{\n\t\tResolve: func(ctx context.Context, source, args interface{}, selectionSet *graphql.SelectionSet) (interface{}, error) {\n\t\t\tvalue := reflect.ValueOf(source)\n\t\t\tif value.Kind() == reflect.Ptr {\n\t\t\t\tvalue = value.Elem()\n\t\t\t}\n\t\t\treturn value.FieldByIndex(field.Index).Interface(), nil\n\t\t},\n\t\tType: retType,\n\t\tParseArguments: nilParseArguments,\n\t}, nil\n}", "func (*Component_Subcomponent) IsYANGGoStruct() {}", "func ReflectStruct(s interface{}) *Struct {\n\treturn &Struct{\n\t\tRef: s,\n\t\tOriginalPackage: \"\",\n\t}\n}", "func (c *Cache) create(rt reflect.Type, kind core.Kind) *StructInfo {\n\tt, _ := utils.RemovePointer(rt, false) // already removed, no need to remove again?\n\tsi := &StructInfo{\n\t\tt: t,\n\t\tFields: make(map[string]*FieldInfo),\n\t\tKind: kind,\n\t}\n\tcreateFieldInfo(si, t)\n\tif false {\n\t\tfmt.Println(\"******* print struct info *******************************************************\")\n\t\tfor k, v := range si.Fields {\n\t\t\tfmt.Println(k, \" -> \", v)\n\t\t}\n\t}\n\treturn si\n}", "func NewStructField(name string, value Value) StructField {\n\treturn StructField{Name: name, Value: value}\n}", "func Field(v interface{}, name string) (*Fieldx, bool) {\n\treturn New(v).Field(name)\n}", "func (node *selfNode) packToStruct(st reflect.Value) error {\n\n\tfor _, n := range node.values {\n\t\tswitch n.(type) {\n\t\tcase selfString:\n\t\t\treturn node.packToStructByFieldOrder(st)\n\n\t\tcase *selfNode:\n\t\t\tif !st.FieldByName(n.(*selfNode).head.String()).IsValid() {\n\t\t\t\treturn node.packToStructByFieldOrder(st)\n\t\t\t}\n\t\t}\n\t}\n\treturn node.packToStructByFieldName(st)\n}", "func (x *MyUnion) DefaultGetStructField() *MyStruct {\n if !x.IsSetStructField() {\n return NewMyStruct()\n }\n return x.StructField\n}", "func GetNameFromStruct(u interface{}) string {\n\tvar result = ReturnValue{CustomStruct: u}\n\n\t//fmt.Println(result)\n\n\tmsg, ok := result.CustomStruct.(NameOnly)\n\tif ok {\n\t\t//fmt.Printf(\"Message1 is %s\\n\", msg.Name)\n\t\treturn msg.Name\n\t} else {\n\t\treturn \"\"\n\t}\n}", "func (p TreeWriter) getFields(leaf *yaml.RNode) (treeFields, error) {\n\tfieldsByName := map[string]*treeField{}\n\n\t// index nested and non-nested fields\n\tfor i := range p.Fields {\n\t\tf := p.Fields[i]\n\t\tseq, err := leaf.Pipe(&f)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif seq == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tif fieldsByName[f.Name] == nil {\n\t\t\tfieldsByName[f.Name] = &treeField{name: f.Name}\n\t\t}\n\n\t\t// non-nested field -- add directly to the treeFields list\n\t\tif f.SubName == \"\" {\n\t\t\t// non-nested field -- only 1 element\n\t\t\tval, err := yaml.String(seq.Content()[0], yaml.Trim, yaml.Flow)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tfieldsByName[f.Name].value = val\n\t\t\tcontinue\n\t\t}\n\n\t\t// nested-field -- create a parent elem, and index by the 'match' value\n\t\tif fieldsByName[f.Name].subFieldByMatch == nil {\n\t\t\tfieldsByName[f.Name].subFieldByMatch = map[string]treeFields{}\n\t\t}\n\t\tindex := fieldsByName[f.Name].subFieldByMatch\n\t\tfor j := range seq.Content() {\n\t\t\telem := seq.Content()[j]\n\t\t\tmatches := f.Matches[elem]\n\t\t\tstr, err := yaml.String(elem, yaml.Trim, yaml.Flow)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\t// map the field by the name of the element\n\t\t\t// index the subfields by the matching element so we can put all the fields for the\n\t\t\t// same element under the same branch\n\t\t\tmatchKey := strings.Join(matches, \"/\")\n\t\t\tindex[matchKey] = append(index[matchKey], &treeField{name: f.SubName, value: str})\n\t\t}\n\t}\n\n\t// iterate over collection of all queried fields in the Resource\n\tfor _, field := range fieldsByName {\n\t\t// iterate over collection of elements under the field -- indexed by element name\n\t\tfor match, subFields := range field.subFieldByMatch {\n\t\t\t// create a new element for this collection of fields\n\t\t\t// note: we will convert name to an index later, but keep the match for sorting\n\t\t\telem := &treeField{name: match}\n\t\t\tfield.matchingElementsAndFields = append(field.matchingElementsAndFields, elem)\n\n\t\t\t// iterate over collection of queried fields for the element\n\t\t\tfor i := range subFields {\n\t\t\t\t// add to the list of fields for this element\n\t\t\t\telem.matchingElementsAndFields = append(elem.matchingElementsAndFields, subFields[i])\n\t\t\t}\n\t\t}\n\t\t// clear this cached data\n\t\tfield.subFieldByMatch = nil\n\t}\n\n\t// put the fields in a list so they are ordered\n\tfieldList := treeFields{}\n\tfor _, v := range fieldsByName {\n\t\tfieldList = append(fieldList, v)\n\t}\n\n\t// sort the fields\n\tsort.Sort(fieldList)\n\tfor i := range fieldList {\n\t\tfield := fieldList[i]\n\t\t// sort the elements under this field\n\t\tsort.Sort(field.matchingElementsAndFields)\n\n\t\tfor i := range field.matchingElementsAndFields {\n\t\t\telement := field.matchingElementsAndFields[i]\n\t\t\t// sort the elements under a list field by their name\n\t\t\tsort.Sort(element.matchingElementsAndFields)\n\t\t\t// set the name of the element to its index\n\t\t\telement.name = fmt.Sprintf(\"%d\", i)\n\t\t}\n\t}\n\n\treturn fieldList, nil\n}", "func structToMap(structPtr interface{}, depth int, prefix ...string) FieldMap {\n\tval := reflect.ValueOf(structPtr)\n\tind := reflect.Indirect(val)\n\tif val.Kind() != reflect.Ptr || ind.Kind() != reflect.Struct {\n\t\ttools.LogAndPanic(log, \"structPtr must be a pointer to a struct\", \"structPtr\", structPtr)\n\t}\n\tres := make(FieldMap)\n\tfor i := 0; i < ind.NumField(); i++ {\n\t\tvar fieldName string\n\t\tif len(prefix) > 0 {\n\t\t\tfieldName = fmt.Sprintf(\"%s.%s\", prefix[0], ind.Type().Field(i).Name)\n\t\t} else {\n\t\t\tfieldName = ind.Type().Field(i).Name\n\t\t}\n\t\tfieldValue := ind.Field(i)\n\t\tvar resVal interface{}\n\t\tif fieldValue.Kind() == reflect.Ptr {\n\t\t\t// Get the related struct if not nil\n\t\t\trelInd := reflect.Indirect(fieldValue)\n\t\t\trelTyp := fieldValue.Type().Elem()\n\t\t\tswitch relTyp.Kind() {\n\t\t\tcase reflect.Struct:\n\t\t\t\tif depth > 0 {\n\t\t\t\t\tif !relInd.IsValid() {\n\t\t\t\t\t\t// create the struct if the pointer is nil\n\t\t\t\t\t\tfieldValue = reflect.New(relTyp)\n\t\t\t\t\t}\n\t\t\t\t\t// get the related struct fields\n\t\t\t\t\trelMap := structToMap(fieldValue.Interface(), depth-1, fieldName)\n\t\t\t\t\tfor k, v := range relMap {\n\t\t\t\t\t\tres[k] = v\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif !relInd.IsValid() {\n\t\t\t\t\t\t// Skip if pointer is nil\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\t// get the ID of the related struct\n\t\t\t\t\tresVal = relInd.FieldByName(\"ID\").Interface()\n\t\t\t\t}\n\t\t\t}\n\t\t\tif relInd.Kind() != reflect.Struct {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t} else {\n\t\t\tresVal = ind.Field(i).Interface()\n\t\t}\n\t\tres[fieldName] = resVal\n\t}\n\treturn res\n}", "func AnonymousStruct() {\n\t//Biasanya dideklarasikan diluar ataupun didalam func\n\ttype orang struct {\n\t\tnama string\n\t}\n\n\t// struct ini nyaris sama seperti variabel dan tidak mempunya nama struct\n\t// hanya digunakan didalam func saja\n\tvar As1 = struct {\n\t\torang\n\t\tnegara string\n\t}{}\n\n\tAs1.nama = \"olgi\"\n\tAs1.negara = \"indonesia\"\n\n\tfmt.Println(\"Nama\\t = \", As1.nama)\n\tfmt.Println(\"Nama\\t = \", As1.negara)\n}", "func Struct(rt reflect.Type, gens map[string]gopter.Gen) gopter.Gen {\n\tif rt.Kind() == reflect.Ptr {\n\t\trt = rt.Elem()\n\t}\n\tif rt.Kind() != reflect.Struct {\n\t\treturn Fail(rt)\n\t}\n\tfieldGens := []gopter.Gen{}\n\tfieldTypes := []reflect.Type{}\n\tassignable := reflect.New(rt).Elem()\n\tfor i := 0; i < rt.NumField(); i++ {\n\t\tfieldName := rt.Field(i).Name\n\t\tif !assignable.Field(i).CanSet() {\n\t\t\tcontinue\n\t\t}\n\n\t\tgen := gens[fieldName]\n\t\tif gen != nil {\n\t\t\tfieldGens = append(fieldGens, gen)\n\t\t\tfieldTypes = append(fieldTypes, rt.Field(i).Type)\n\t\t}\n\t}\n\n\tbuildStructType := reflect.FuncOf(fieldTypes, []reflect.Type{rt}, false)\n\tunbuildStructType := reflect.FuncOf([]reflect.Type{rt}, fieldTypes, false)\n\n\tbuildStructFunc := reflect.MakeFunc(buildStructType, func(args []reflect.Value) []reflect.Value {\n\t\tresult := reflect.New(rt)\n\t\tfor i := 0; i < rt.NumField(); i++ {\n\t\t\tif _, ok := gens[rt.Field(i).Name]; !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif !assignable.Field(i).CanSet() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tresult.Elem().Field(i).Set(args[0])\n\t\t\targs = args[1:]\n\t\t}\n\t\treturn []reflect.Value{result.Elem()}\n\t})\n\tunbuildStructFunc := reflect.MakeFunc(unbuildStructType, func(args []reflect.Value) []reflect.Value {\n\t\ts := args[0]\n\t\tresults := []reflect.Value{}\n\t\tfor i := 0; i < s.NumField(); i++ {\n\t\t\tif _, ok := gens[rt.Field(i).Name]; !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif !assignable.Field(i).CanSet() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tresults = append(results, s.Field(i))\n\t\t}\n\t\treturn results\n\t})\n\n\treturn gopter.DeriveGen(\n\t\tbuildStructFunc.Interface(),\n\t\tunbuildStructFunc.Interface(),\n\t\tfieldGens...,\n\t)\n}", "func makeStruct(v interface{}, header, record []string) {\n\tval := reflect.ValueOf(v).Elem()\n\ttyp := reflect.TypeOf(v).Elem()\n\tfor i, heading := range header {\n\t\ttfield, found := typ.FieldByName(heading)\n\t\tif !found || tfield.Anonymous {\n\t\t\tcontinue\n\t\t}\n\n\t\tfieldval := val.FieldByName(heading)\n\t\tnewval := fromString(fieldval.Interface(), record[i])\n\n\t\tfieldval.Set(newval)\n\t}\n}", "func (s StructInfo) StructInfo() StructInfo {\n\treturn s\n}", "func godef(ds design.DataStructure, versioned bool, defPkg string, tabs int, jsonTags, inner, res bool) string {\n\tvar buffer bytes.Buffer\n\tdef := ds.Definition()\n\tt := def.Type\n\tswitch actual := t.(type) {\n\tcase design.Primitive:\n\t\treturn GoTypeName(t, tabs)\n\tcase *design.Array:\n\t\treturn \"[]\" + godef(actual.ElemType, versioned, defPkg, tabs, jsonTags, true, res)\n\tcase *design.Hash:\n\t\tkeyDef := godef(actual.KeyType, versioned, defPkg, tabs, jsonTags, true, res)\n\t\telemDef := godef(actual.ElemType, versioned, defPkg, tabs, jsonTags, true, res)\n\t\treturn fmt.Sprintf(\"map[%s]%s\", keyDef, elemDef)\n\tcase design.Object:\n\t\tif inner {\n\t\t\tbuffer.WriteByte('*')\n\t\t}\n\t\tbuffer.WriteString(\"struct {\\n\")\n\t\tkeys := make([]string, len(actual))\n\t\ti := 0\n\t\tfor n := range actual {\n\t\t\tkeys[i] = n\n\t\t\ti++\n\t\t}\n\t\tsort.Strings(keys)\n\t\tfor _, name := range keys {\n\t\t\tWriteTabs(&buffer, tabs+1)\n\t\t\ttypedef := godef(actual[name], versioned, defPkg, tabs+1, jsonTags, true, res)\n\t\t\tfname := Goify(name, true)\n\t\t\tvar tags string\n\t\t\tif jsonTags {\n\t\t\t\tvar omit string\n\t\t\t\tif !def.IsRequired(name) {\n\t\t\t\t\tomit = \",omitempty\"\n\t\t\t\t}\n\t\t\t\ttags = fmt.Sprintf(\" `json:\\\"%s%s\\\"`\", name, omit)\n\t\t\t}\n\t\t\tdesc := actual[name].Description\n\t\t\tif desc != \"\" {\n\t\t\t\tdesc = fmt.Sprintf(\"// %s\\n\", desc)\n\t\t\t}\n\t\t\tbuffer.WriteString(fmt.Sprintf(\"%s%s %s%s\\n\", desc, fname, typedef, tags))\n\t\t}\n\t\tWriteTabs(&buffer, tabs)\n\t\tbuffer.WriteString(\"}\")\n\t\treturn buffer.String()\n\tcase *design.UserTypeDefinition:\n\t\tname := GoPackageTypeName(actual, versioned, defPkg, tabs)\n\t\tif actual.Type.IsObject() {\n\t\t\treturn \"*\" + name\n\t\t}\n\t\treturn name\n\tcase *design.MediaTypeDefinition:\n\t\tif res && actual.Resource != nil {\n\t\t\treturn \"*\" + Goify(actual.Resource.Name, true)\n\t\t}\n\t\tname := GoPackageTypeName(actual, versioned, defPkg, tabs)\n\t\tif actual.Type.IsObject() {\n\t\t\treturn \"*\" + name\n\t\t}\n\t\treturn name\n\tdefault:\n\t\tpanic(\"goa bug: unknown data structure type\")\n\t}\n}", "func NewStruct(vs ...interface{}) Struct {\n\tstructFields := make([]StructField, len(vs)/2)\n\tfor i := range structFields {\n\t\tstructFields[i] = NewStructField(\n\t\t\tvs[2*i+0].(string),\n\t\t\tvs[2*i+1].(Value),\n\t\t)\n\t}\n\treturn Struct(structFields)\n}", "func Example_nestedStruct() {\n\tverbose := flag.Bool(\"verbose\", false, \"Verbose\")\n\tnode := flag.String(\"node\", \"\", \"Etcd node\")\n\tport := flag.String(\"port\", \"\", \"Etcd port\")\n\tflag.Parse()\n\n\t// Define nested structure.\n\tg := Group{\n\t\tName: \"staff\",\n\t\tUsers: []User{\n\t\t\tUser{\n\t\t\t\tName: \"jdoe\",\n\t\t\t\tAge: 25,\n\t\t\t\tMale: true,\n\t\t\t\tFirstName: \"John\",\n\t\t\t\tLastName: \"Doe\",\n\t\t\t},\n\t\t\tUser{\n\t\t\t\tName: \"lnemoy\",\n\t\t\t\tAge: 62,\n\t\t\t\tMale: true,\n\t\t\t\tFirstName: \"Leonard\",\n\t\t\t\tLastName: \"Nimoy\",\n\t\t\t},\n\t\t},\n\t}\n\n\t// Connect to Etcd.\n\tconn := getEnv()\n\tif node == nil && port == nil {\n\t\tconn = []string{fmt.Sprintf(\"http://%v:%v\", *node, *port)}\n\t}\n\n\tif *verbose {\n\t\tlog.Printf(\"Connecting to: %s\", conn)\n\t}\n\tclient := etcd.NewClient(conn)\n\n\t// Create directory structure based on struct.\n\terr := etcdmap.Create(client, \"/example\", reflect.ValueOf(g))\n\tif err != nil {\n\t\tlog.Fatal(err.Error())\n\t}\n\n\t// Get directory structure from Etcd.\n\tres, err := client.Get(\"/example\", true, true)\n\tif err != nil {\n\t\tlog.Fatal(err.Error())\n\t}\n\n\tj, err2 := etcdmap.JSON(res.Node)\n\tif err2 != nil {\n\t\tlog.Fatal(err2.Error())\n\t}\n\n\tfmt.Println(string(j))\n\n\t// Output:\n\t//{\"id\":\"staff\",\"users\":{\"0\":{\"age\":\"25\",\"first_name\":\"John\",\"id\":\"jdoe\",\"last_name\":\"Doe\",\"male\":\"true\"},\"1\":{\"age\":\"62\",\"first_name\":\"Leonard\",\"id\":\"lnemoy\",\"last_name\":\"Nimoy\",\"male\":\"true\"}}}\n}", "func jsonStruct(doc ElasticDocs) string {\n\n\t// Create struct instance of the Elasticsearch fields struct object\n\tdocStruct := &ElasticDocs{\n\t\tName: doc.Name,\n\t\tId: doc.Id,\n\t\tAvailable: doc.Available,\n\t\tNewField: doc.NewField,\n\t}\n\t// Marshal the struct to JSON and check for errors\n\tb, err := json.Marshal(docStruct)\n\tif err != nil {\n\t\tfmt.Println(\"json.Marshal ERROR:\", err)\n\t\treturn string(err.Error())\n\t}\n\treturn string(b)\n}", "func getElementStruct(stub shim.ChaincodeStubInterface, elementKey string, element interface{}) error {\n\telementBytes, err := getElementBytes(stub, elementKey)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn bytesToStruct(elementBytes, element)\n}", "func (e *exprHelper) NewStruct(typeName string, fieldInits ...ast.EntryExpr) ast.Expr {\n\treturn e.exprFactory.NewStruct(e.nextMacroID(), typeName, fieldInits)\n}", "func (t *Type) loadStruct(importPath string) error {\n\tstructName := t.Name\n\n\t// if import path is not define, try to import from local directory\n\tif importPath == \"\" {\n\t\timportPath = \"./\"\n\t}\n\tp, err := Program(importPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"load program: %s\", err)\n\t}\n\n\tfor _, pkg := range p.Imported {\n\t\tfor _, scope := range pkg.Scopes {\n\t\t\tst := lookup(scope.Parent(), structName)\n\t\t\tif st != nil {\n\t\t\t\tt.st = st\n\t\t\t\tt.pkg = pkg.Pkg\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}\n\treturn ErrTypeNotFound\n}", "func (_struct Struct) String() string {\n\treturn fmt.Sprintf(\"struct:%s\", _struct.Name())\n}", "func (p *Parser) parse(prefix string, s *ast.StructType) {\n\t// stop recursion for nested structs\n\tif s == nil {\n\t\treturn\n\t}\n\n\tfor _, f := range s.Fields.List {\n\t\terr := &ErrSyntax{line: p.file.Line(f.Pos())}\n\n\t\tvar (\n\t\t\ttag = err.append(p.parseTag(f)).(*types.Tag)\n\t\t\tname = prefix + err.append(p.parseName(f)).(string)\n\t\t\ttypeID = err.append(p.parseType(f)).(string)\n\t\t)\n\n\t\tswitch {\n\t\tcase err.errs != nil:\n\t\t\tp.errors = append(p.errors, err)\n\t\tcase tag == nil:\n\t\t\tp.parse(name+\".\", p.parseSubType(f))\n\t\tdefault:\n\t\t\tif tag.EnvVar == \"\" {\n\t\t\t\ttag.EnvVar = strings.ToUpper(strings.ReplaceAll(name, \".\", \"_\"))\n\t\t\t}\n\n\t\t\t// because names unique (because of prefix) we can omit checks like \"Did we find already?\"\n\t\t\tp.fields[name] = &types.Field{\n\t\t\t\tName: name,\n\t\t\t\tType: typeID,\n\t\t\t\tEnvVar: tag.EnvVar,\n\t\t\t\tAction: tag.Action,\n\t\t\t}\n\t\t}\n\t}\n}", "func (f *FieldHandler) StructField() reflect.StructField {\n\treturn f.field.structField\n}", "func (p *PropertyGenerator) StructName() string {\n\tif p.asIterator {\n\t\treturn p.Name.CamelName\n\t}\n\treturn fmt.Sprintf(\"%sProperty\", p.Name.CamelName)\n}", "func Struct(entries ...dgo.MapEntryType) dgo.StructType {\n\treturn internal.Struct(entries)\n}", "func getField(n string, i interface{}) (interface{}, bool) {\n\tre := reflect.ValueOf(i).Elem()\n\tif re.Kind() == reflect.Struct {\n\t\tf := re.FieldByName(n)\n\n\t\tif f.IsValid() {\n\t\t\treturn f.Interface(), true\n\t\t}\n\t}\n\n\treturn nil, false\n}", "func (c *Config) GetStruct(pattern string, pointer interface{}, mapping ...map[string]string) error {\n\tif j := c.getJson(); j != nil {\n\t\treturn j.GetStruct(pattern, pointer, mapping...)\n\t}\n\treturn errors.New(\"configuration not found\")\n}", "func (f Unstructured) Field(field string) Fragment {\n\tif f.fields != nil {\n\t\treturn f.fields[field]\n\t}\n\treturn nil\n}", "func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, __FieldImplementors)\n\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\n\tfor i, field := range fields {\n\t\tout.Keys[i] = field.Alias\n\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString(\"__Field\")\n\t\tcase \"name\":\n\t\t\tout.Values[i] = ec.___Field_name(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"description\":\n\t\t\tout.Values[i] = ec.___Field_description(ctx, field, obj)\n\t\tcase \"args\":\n\t\t\tout.Values[i] = ec.___Field_args(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"type\":\n\t\t\tout.Values[i] = ec.___Field_type(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"isDeprecated\":\n\t\t\tout.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"deprecationReason\":\n\t\t\tout.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)\n\t\tdefault:\n\t\t\tpanic(\"unknown field \" + strconv.Quote(field.Name))\n\t\t}\n\t}\n\n\tif invalid {\n\t\treturn graphql.Null\n\t}\n\treturn out\n}", "func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, __FieldImplementors)\n\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\n\tfor i, field := range fields {\n\t\tout.Keys[i] = field.Alias\n\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString(\"__Field\")\n\t\tcase \"name\":\n\t\t\tout.Values[i] = ec.___Field_name(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"description\":\n\t\t\tout.Values[i] = ec.___Field_description(ctx, field, obj)\n\t\tcase \"args\":\n\t\t\tout.Values[i] = ec.___Field_args(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"type\":\n\t\t\tout.Values[i] = ec.___Field_type(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"isDeprecated\":\n\t\t\tout.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"deprecationReason\":\n\t\t\tout.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)\n\t\tdefault:\n\t\t\tpanic(\"unknown field \" + strconv.Quote(field.Name))\n\t\t}\n\t}\n\n\tif invalid {\n\t\treturn graphql.Null\n\t}\n\treturn out\n}", "func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, __FieldImplementors)\n\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\n\tfor i, field := range fields {\n\t\tout.Keys[i] = field.Alias\n\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString(\"__Field\")\n\t\tcase \"name\":\n\t\t\tout.Values[i] = ec.___Field_name(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"description\":\n\t\t\tout.Values[i] = ec.___Field_description(ctx, field, obj)\n\t\tcase \"args\":\n\t\t\tout.Values[i] = ec.___Field_args(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"type\":\n\t\t\tout.Values[i] = ec.___Field_type(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"isDeprecated\":\n\t\t\tout.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"deprecationReason\":\n\t\t\tout.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)\n\t\tdefault:\n\t\t\tpanic(\"unknown field \" + strconv.Quote(field.Name))\n\t\t}\n\t}\n\n\tif invalid {\n\t\treturn graphql.Null\n\t}\n\treturn out\n}", "func getStructField(v reflect.Value, ii []int) reflect.Value {\n\tif len(ii) == 0 {\n\t\treturn v.Addr()\n\t}\n\ti, ii := ii[0], ii[1:]\n\n\tiv := v.Field(i)\n\tif iv.Kind() == reflect.Ptr && iv.IsNil() {\n\t\t// If the field is a pointer to an unexported type then it won't be\n\t\t// settable, though if the user pre-sets the value it will be (I think).\n\t\tif !iv.CanSet() {\n\t\t\treturn reflect.Value{}\n\t\t}\n\t\tiv.Set(reflect.New(iv.Type().Elem()))\n\t}\n\tiv = reflect.Indirect(iv)\n\n\treturn getStructField(iv, ii)\n}", "func generateStruct(a *AnnotationDoc, packageName string, imports []string, indent string) (string, []string) {\n\tvar allAnnotationsPackages []string\n\tpossiblePackagesForA := combinePackages(imports, []string{packageName})\n\tts, foundPackageOfA, foundImportsOfA := getAnnotationStruct(a.Name, possiblePackagesForA)\n\tallAnnotationsPackages = combinePackages(allAnnotationsPackages, []string{foundPackageOfA})\n\tstr, _ := ts.Type.(*ast.StructType)\n\tvar b bytes.Buffer\n\tb.WriteString(indent)\n\tb.WriteString(foundPackageOfA)\n\tb.WriteString(\".\")\n\tb.WriteString(a.Name)\n\tb.WriteString(\"{\\n\")\n\tchildIndent := indent + \" \"\n\tfor _, f := range str.Fields.List {\n\t\tfieldName := getFieldName(f)\n\t\tdefValue := getDefaultValue(f)\n\t\tfieldKey := fieldName\n\t\t// consider special case when only default parameter is specified\n\t\tif len(str.Fields.List) == 1 && len(a.Content) == 1 {\n\t\t\tfor key := range a.Content {\n\t\t\t\tif key == DEFAULT_PARAM {\n\t\t\t\t\tfieldKey = DEFAULT_PARAM\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvalue, found := a.Content[fieldKey]\n\t\tif found {\n\t\t\tswitch t := value.(type) {\n\t\t\tcase string:\n\t\t\t\tb.WriteString(childIndent)\n\t\t\t\tb.WriteString(getLiteral(f.Type, t, false))\n\t\t\t\tb.WriteString(\",\\n\")\n\t\t\tcase []string:\n\t\t\t\tb.WriteString(childIndent)\n\t\t\t\tb.WriteString(getFieldConstructor(f.Type))\n\t\t\t\tb.WriteString(\"\\n\")\n\t\t\t\tfor _, elem := range t {\n\t\t\t\t\tb.WriteString(childIndent + \" \")\n\t\t\t\t\tb.WriteString(elem)\n\t\t\t\t\tb.WriteString(\",\\n\")\n\t\t\t\t}\n\t\t\t\tb.WriteString(childIndent)\n\t\t\t\tb.WriteString(\"}\")\n\t\t\tcase []AnnotationDoc:\n\t\t\t\t// calculate array's elements\n\t\t\t\tvar bb bytes.Buffer\n\t\t\t\tfor _, sa := range t {\n\t\t\t\t\tchildCode, foundImportsOfChild := generateStruct(&sa, foundPackageOfA, foundImportsOfA, childIndent+\" \")\n\t\t\t\t\tallAnnotationsPackages = combinePackages(allAnnotationsPackages, foundImportsOfChild)\n\t\t\t\t\tbb.WriteString(childCode)\n\t\t\t\t\tbb.WriteString(\",\\n\")\n\t\t\t\t}\n\t\t\t\tb.WriteString(childIndent)\n\t\t\t\t// insert array initialzer of child annotation type\n\t\t\t\ts := writeArrayInitializer(&b, bb.String())\n\t\t\t\t// append array of child annotations\n\t\t\t\tb.WriteString(\"{\\n\")\n\t\t\t\tb.WriteString(childIndent + \" \")\n\t\t\t\tb.WriteString(s)\n\t\t\t\tb.WriteString(childIndent)\n\t\t\t\tb.WriteString(\"},\\n\")\n\t\t\tcase AnnotationDoc:\n\t\t\t\tchildCode, foundImportsOfChild := generateStruct(&t, foundPackageOfA, foundImportsOfA, childIndent)\n\t\t\t\tallAnnotationsPackages = combinePackages(allAnnotationsPackages, foundImportsOfChild)\n\t\t\t\tb.WriteString(childIndent)\n\t\t\t\tif isOptional(f.Type) {\n\t\t\t\t\tb.WriteString(\"&\")\n\t\t\t\t}\n\t\t\t\tb.WriteString(strings.TrimLeft(childCode, \" \"))\n\t\t\t\tb.WriteString(\",\\n\")\n\t\t\tdefault:\n\t\t\t\tpanic(\"Unexpected annotation value type\")\n\t\t\t}\n\t\t} else {\n\t\t\tb.WriteString(childIndent)\n\t\t\tb.WriteString(defValue)\n\t\t\tb.WriteString(\",\\n\")\n\t\t}\n\t}\n\tb.WriteString(indent)\n\tb.WriteString(\"}\")\n\treturn b.String(), allAnnotationsPackages\n}", "func (t *SimpleChaincode) readStruct(stub shim.ChaincodeStubInterface, structName string, arg string) ([]byte, error) {\n\tfmt.Println(\"Read called for \" + structName)\n\tvar jsonResp string\n\tvar err error\n\n\tkey := arg\n\tfmt.Println(\"Reading for key: \" + key)\n\tvalAsbytes, err := stub.GetState(key)\n\tif err != nil {\n\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get object for \" + key + \"\\\"}\"\n\t\treturn nil, errors.New(jsonResp)\n\t}\n\n\tif structName == \"readProvider\" {\n\t\tvar p Provider\n\t\terr = json.Unmarshal(valAsbytes, &p)\n\t\tif err != nil {\n\t\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get Provider for \" + key + \"\\\"}\"\n\t\t\treturn nil, errors.New(jsonResp)\n\t\t}\n\t\tfmt.Println(\"Provider fetched successfully with key: \" + key)\n\t} else if structName == \"readMember\" {\n\t\tvar m Member\n\t\terr = json.Unmarshal(valAsbytes, &m)\n\t\tif err != nil {\n\t\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get Member for \" + key + \"\\\"}\"\n\t\t\treturn nil, errors.New(jsonResp)\n\t\t}\n\t\tfmt.Println(\"Member fetched successfully with key: \")\n\t} else if structName == \"readService\" {\n\t\tvar s Service\n\t\terr = json.Unmarshal(valAsbytes, &s)\n\t\tif err != nil {\n\t\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get Service for \" + key + \"\\\"}\"\n\t\t\treturn nil, errors.New(jsonResp)\n\t\t}\n\t\tfmt.Println(\"Service fetched successfully with key: \" + key)\n\t} else if structName == \"readPayer\" {\n\t\tvar pyr Payer\n\t\terr = json.Unmarshal(valAsbytes, &pyr)\n\t\tif err != nil {\n\t\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get Payer for \" + key + \"\\\"}\"\n\t\t\treturn nil, errors.New(jsonResp)\n\t\t}\n\t\tfmt.Println(\"Payer fetched successfully with key: \" + key)\n\t} else {\n\t\treturn nil, errors.New(\"Received unknown structure or key in query: \" + structName + \":\" + key)\n\t}\n\n\treturn valAsbytes, nil\n}", "func (r *Reader) PropertyStruct(pkgPath, name string, defaults reflect.Value) (*PropertyStruct, error) {\n\tps := r.getPropertyStruct(pkgPath, name)\n\n\tif ps == nil {\n\t\tpkg, err := r.goPkg(pkgPath)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tfor _, t := range pkg.Types {\n\t\t\tif t.Name == name {\n\t\t\t\tps, err = newPropertyStruct(t)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tps = r.putPropertyStruct(pkgPath, name, ps)\n\t\t\t}\n\t\t}\n\t}\n\n\tif ps == nil {\n\t\treturn nil, fmt.Errorf(\"package %q type %q not found\", pkgPath, name)\n\t}\n\n\tps = ps.Clone()\n\tps.SetDefaults(defaults)\n\n\treturn ps, nil\n}", "func (x *TerseStructWithCustomDefault) DefaultGetStructField() *MyStructWithCustomDefault {\n if !x.IsSetStructField() {\n return NewMyStructWithCustomDefault()\n }\n return x.StructField\n}", "func dbNameToStruct(db string) (d utils.DBMS, err error) {\n\tswitch strings.ToLower(db) {\n\tcase \"mysql\":\n\t\td = &dbms.MySQL{}\n\tcase \"oracle\":\n\t\td = &dbms.Oracle{}\n\tcase \"postgres\":\n\t\td = &dbms.Postgres{}\n\tdefault:\n\t\terr = fmt.Errorf(\"Unknown DBMS: %s\", db)\n\t}\n\treturn\n}", "func (r *reflex) tagInfoFrom(field reflect.StructField, pkgPath string) (*tagInfo, error) {\n\tinfo := &tagInfo{\n\t\tmethods: make(utils.HttpMethodSet, 1),\n\t}\n\n\t// lookup mir tag info from struct field\n\ttag, exist := field.Tag.Lookup(r.tagName)\n\tif !exist {\n\t\treturn nil, errNotExist\n\t}\n\n\t// Skip leading space.\n\ti := 0\n\tfor i < len(tag) && tag[i] == ' ' {\n\t\ti++\n\t}\n\ttag = tag[i:]\n\n\t// group info or method info or chain info\n\tinfo.fieldName = field.Name\n\tswitch field.Type.Kind() {\n\tcase reflect.Interface:\n\t\tif field.Type.PkgPath() != mirPkgName {\n\t\t\treturn nil, errors.New(\"not supported filed type\")\n\t\t}\n\t\tswitch field.Type.Name() {\n\t\tcase \"Chain\":\n\t\t\tinfo.isChain = true\n\t\t\treturn info, nil\n\t\tcase \"Group\":\n\t\t\tinfo.isGroup = true\n\t\t\tinfo.group = tag\n\t\t\treturn info, nil\n\t\tdefault:\n\t\t\treturn nil, errors.New(\"not supported filed type\")\n\t\t}\n\tcase reflect.Func:\n\t\tft := field.Type\n\t\tnumIn := ft.NumIn()\n\t\tnumOut := ft.NumOut()\n\t\tif numOut > 1 {\n\t\t\treturn nil, errors.New(\"func field just need one most return value\")\n\t\t}\n\t\tif numIn > 0 {\n\t\t\t// request type in latest in argument if declared\n\t\t\tit := ft.In(numIn - 1)\n\t\t\tif it.Kind() == reflect.Struct {\n\t\t\t\tcts, err := CheckStruct(it, pkgPath)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tinfo.in = it\n\t\t\t\tif it.PkgPath() != pkgPath {\n\t\t\t\t\tinfo.isBindIn = assert.AssertBinding(reflect.New(it).Interface())\n\t\t\t\t}\n\t\t\t\tinfo.inOuts = append(info.inOuts, cts...)\n\n\t\t\t\t// minus numIn to ignore latest in argument that had processed\n\t\t\t\tnumIn--\n\t\t\t}\n\n\t\t\t// process other in argument\n\t\t\tfor i := numIn - 1; i >= 0; i-- {\n\t\t\t\tit = ft.In(i)\n\t\t\t\tif it.PkgPath() != mirPkgName {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tswitch it.Name() {\n\t\t\t\tcase \"Get\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodGet)\n\t\t\t\tcase \"Put\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodPut)\n\t\t\t\tcase \"Post\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodPost)\n\t\t\t\tcase \"Delete\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodDelete)\n\t\t\t\tcase \"Head\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodHead)\n\t\t\t\tcase \"Options\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodOptions)\n\t\t\t\tcase \"Patch\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodPatch)\n\t\t\t\tcase \"Trace\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodTrace)\n\t\t\t\tcase \"Connect\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodConnect)\n\t\t\t\tcase \"Any\":\n\t\t\t\t\tinfo.isAnyMethod = true\n\t\t\t\t\tinfo.methods.Add(mir.HttpMethods...)\n\t\t\t\tcase \"Chain\":\n\t\t\t\t\tinfo.isFieldChain = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// process special case for not set methods\n\t\tif len(info.methods) == 0 {\n\t\t\tinfo.isAnyMethod = true\n\t\t\tinfo.methods.Add(mir.HttpMethods...)\n\t\t}\n\t\tif numOut == 1 {\n\t\t\tot := ft.Out(i)\n\t\t\tif ot.Kind() != reflect.Struct {\n\t\t\t\treturn nil, errors.New(\"func field must return value is need struct type\")\n\t\t\t}\n\t\t\tcts, err := CheckStruct(ot, pkgPath)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tinfo.out = ot\n\t\t\tif ot.PkgPath() != pkgPath {\n\t\t\t\tinfo.isRenderOut = assert.AssertRender(reflect.New(ot).Interface())\n\t\t\t}\n\t\t\tinfo.inOuts = append(info.inOuts, cts...)\n\t\t}\n\tdefault:\n\t\treturn nil, errors.New(\"not supported filed type\")\n\t}\n\n\t// host info\n\tif len(tag) > 2 && tag[0] == '/' && tag[1] == '/' {\n\t\ti := 2\n\t\tfor i < len(tag) && tag[i] != '/' {\n\t\t\ti++\n\t\t}\n\t\tinfo.host = tag[2:i]\n\t\ttag = tag[i:]\n\t}\n\n\t// path info. must have path info if not a group field\n\tif len(tag) == 0 && !info.isGroup {\n\t\treturn nil, errNoPathInfo\n\t}\n\tfor i = 0; i < len(tag) && tag[i] != '#'; i++ {\n\t\tif !r.noneQuery && tag[i] == '?' {\n\t\t\tbreak\n\t\t}\n\t}\n\tinfo.path = tag[0:i]\n\ttag = tag[i:]\n\n\t// queries and handler info\n\tfor len(tag) != 0 {\n\t\tswitch tag[0] {\n\t\tcase '#':\n\t\t\ti := 1\n\t\t\tfor i < len(tag) && tag[i] != '?' {\n\t\t\t\ti++\n\t\t\t}\n\t\t\thandlerStr := tag[1:i]\n\t\t\ttag = tag[i:]\n\t\t\tif handlerStr != \"\" {\n\t\t\t\tif handlerStr[0] == '-' { // just contain chain func info\n\t\t\t\t\tinfo.chainFunc = handlerStr[1:]\n\t\t\t\t} else { // contain handler and inline chain info like #Handler&ChainFunc\n\t\t\t\t\thandlerChains := strings.Split(handlerStr, \"&\")\n\t\t\t\t\tinfo.handler = handlerChains[0]\n\t\t\t\t\tif len(handlerChains) > 1 { // extract chain func\n\t\t\t\t\t\tinfo.chainFunc = handlerChains[1]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tcase '?':\n\t\t\ti := 1\n\t\t\tfor i < len(tag) && tag[i] != '#' {\n\t\t\t\ti++\n\t\t\t}\n\t\t\tqueryStr := tag[1:i]\n\t\t\tif queryStr != \"\" {\n\t\t\t\tinfo.queries = r.inflateQuery(queryStr)\n\t\t\t}\n\t\t\ttag = tag[i:]\n\t\t}\n\t}\n\n\t// check handler if not group field\n\tif info.handler == \"\" {\n\t\t// assign handler name\n\t\tinfo.handler = utils.UpperFirst(field.Name)\n\t}\n\n\treturn info, nil\n}", "func (v Struct) Get(name string) Value {\n\tfor _, field := range v {\n\t\tif field.Name == name {\n\t\t\treturn field.Value\n\t\t}\n\t}\n\treturn nil\n}", "func (s *MyTestStruct) Name() string {\n\treturn s.field_Name\n}", "func (*buildingR) NewStruct() *buildingR {\n\treturn &buildingR{}\n}", "func (ds *DynamicStruct) Field(i int) reflect.StructField {\n\treturn ds.rt.Field(i)\n}", "func createFieldInfo(si *StructInfo, t reflect.Type) {\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfield := t.Field(i)\n\t\talias := fieldAlias(field)\n\t\tif alias == \"-\" { // Ignore this field.\n\t\t\tcontinue\n\t\t}\n\n\t\t//\n\t\tif field.Anonymous {\n\t\t\tanonymousType, _ := utils.RemovePointer(field.Type, false)\n\t\t\tcreateFieldInfo(si, anonymousType)\n\t\t}\n\n\t\tft, isSlice := utils.RemovePointer(field.Type, true)\n\t\tif isStruct := ft.Kind() == reflect.Struct; !isStruct {\n\t\t\t// GB: don't check if it's supported.\n\t\t\t/*\n\t\t\t\tif conv := c.conv[ft]; conv == nil {\n\t\t\t\t\t// Type is not supported.\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t*/\n\t\t}\n\t\tfi := &FieldInfo{\n\t\t\tName: field.Name,\n\t\t\tIndex: i,\n\t\t\tType: field.Type,\n\t\t\tIsSlice: isSlice,\n\t\t\tKind: core.UNKNOWN,\n\t\t}\n\t\t// TODO here judge if it's a page or component, store the type.\n\n\t\tsi.l.Lock()\n\t\tsi.Fields[strings.ToLower(alias)] = fi\n\t\tsi.l.Unlock()\n\t}\n}" ]
[ "0.7061889", "0.6602846", "0.6469764", "0.61510986", "0.6143574", "0.6041583", "0.5890761", "0.58896327", "0.58850324", "0.587014", "0.58472174", "0.5809523", "0.580942", "0.57638764", "0.5722698", "0.56878453", "0.5675025", "0.56681955", "0.56636596", "0.5662201", "0.5609322", "0.5607275", "0.5595225", "0.549378", "0.5486889", "0.54459417", "0.54374975", "0.54344517", "0.5414616", "0.54132426", "0.5409599", "0.5402012", "0.5392738", "0.5382655", "0.538209", "0.53647816", "0.53571665", "0.5351964", "0.5335954", "0.5311811", "0.5294095", "0.52830935", "0.5264315", "0.52588975", "0.5239523", "0.5234206", "0.52327806", "0.5228213", "0.5215345", "0.52144176", "0.52072734", "0.52057725", "0.5201764", "0.5193056", "0.517831", "0.516963", "0.5164607", "0.5159487", "0.51418304", "0.51341707", "0.51329434", "0.513291", "0.5120272", "0.51184905", "0.5116294", "0.5108897", "0.5104822", "0.50966626", "0.50933975", "0.50882363", "0.50880027", "0.50808156", "0.507697", "0.50749516", "0.507469", "0.5055799", "0.5054662", "0.5044169", "0.5043179", "0.5040028", "0.50378317", "0.5035981", "0.5026915", "0.501371", "0.5012485", "0.5009188", "0.5009188", "0.5009188", "0.5005291", "0.5003845", "0.4998415", "0.49850687", "0.49818617", "0.49769893", "0.4968341", "0.49670938", "0.49670735", "0.49670005", "0.49562144", "0.49502435" ]
0.5708856
15
Map returns struct name value as map
func Map(v interface{}) map[string]interface{} { return New(v).Map() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *Structx) Map() map[string]interface{} {\n\tresult := map[string]interface{}{}\n\n\tfs := s.Fields()\n\tfor _, v := range fs {\n\t\tif !v.IsExport() {\n\t\t\tcontinue\n\t\t}\n\t\tresult[v.Name()] = v.Value()\n\t}\n\n\treturn result\n}", "func (self *Map) Map(key string, tagName ...string) map[typeutil.Variant]typeutil.Variant {\n\tif len(tagName) == 0 {\n\t\ttagName = []string{self.structTagKey}\n\t}\n\n\treturn self.Get(key).Map(tagName...)\n}", "func (s *simpleFieldMapper) Map(value string) map[string]string {\n\n\t// Create a new map\n\tresult := make(map[string]string)\n\n\t// Iterate over the fieldMapper field defs\n\tfor _, v := range s.FieldDefs {\n\t\t// Get the state of the field def\n\t\tstate := v.GetState(value)\n\t\t// Add the key and value of the field def to the result\n\t\tresult[state.key] = state.value\n\t}\n\n\t// Return the result\n\treturn result\n\n}", "func Struct2Map(v interface{}) (map[string]interface{}, error) {\n bytes, err := json.Marshal(v)\n if err != nil {\n return nil, err\n }\n data := make(map[string]interface{})\n if err := json.Unmarshal(bytes, &data); err != nil {\n return nil, err\n }\n return data, nil\n}", "func (*Map) Name() string { return \"map\" }", "func Map(target interface{}, useTag string) (map[string]interface{}, error) {\n\tif nil == target {\n\t\treturn nil, nil\n\t}\n\tv := reflect.ValueOf(target)\n\tfor v.Kind() == reflect.Ptr {\n\t\tv = v.Elem()\n\t}\n\tif v.Kind() != reflect.Struct {\n\t\treturn nil, ErrNoneStructTarget\n\t}\n\tt := v.Type()\n\tresult := make(map[string]interface{})\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tkeyName := getKey(t.Field(i), useTag)\n\t\tif \"\" == keyName {\n\t\t\tcontinue\n\t\t}\n\t\tresult[keyName] = v.Field(i).Interface()\n\t}\n\treturn result, nil\n}", "func jsonNameMap(structType interface{}) map[string]string {\n\tsType := reflect.TypeOf(structType)\n\tnFields := sType.NumField()\n\tret := make(map[string]string, nFields)\n\tfor i := 0; i < nFields; i++ {\n\t\tf := sType.Field(i)\n\t\tjsonName := strings.SplitN(f.Tag.Get(\"json\"), \",\", 2)[0]\n\t\tif jsonName == \"\" || jsonName == \"-\" {\n\t\t\tcontinue\n\t\t}\n\t\tret[f.Name] = jsonName\n\t}\n\treturn ret\n}", "func StructToMap(i interface{}) (values map[string]interface{}) {\n\tvalues = map[string]interface{}{}\n\tiVal := reflect.Indirect(reflect.ValueOf(&i)).Elem()\n\ttyp := iVal.Type()\n\tfor i := 0; i < iVal.NumField(); i++ {\n\t\tf := iVal.Field(i)\n\t\t// You ca use tags here...\n\t\t// tag := typ.Field(i).Tag.Get(\"tagname\")\n\t\t// Convert each type into a string for the url.Values string map\n\t\tvar v string\n\t\tswitch f.Interface().(type) {\n\t\tcase int, int8, int16, int32, int64:\n\t\t\tv = strconv.FormatInt(f.Int(), 10)\n\t\tcase uint, uint8, uint16, uint32, uint64:\n\t\t\tv = strconv.FormatUint(f.Uint(), 10)\n\t\tcase float32:\n\t\t\tv = strconv.FormatFloat(f.Float(), 'f', 4, 32)\n\t\tcase float64:\n\t\t\tv = strconv.FormatFloat(f.Float(), 'f', 4, 64)\n\t\tcase []byte:\n\t\t\tv = string(f.Bytes())\n\t\tcase string:\n\t\t\tv = f.String()\n\t\t}\n\t\tvalues[typ.Field(i).Name] = v\n\t}\n\treturn\n}", "func Struct2Map(obj interface{}) map[string]interface{} {\n\tv := reflect.ValueOf(obj)\n\tt := v.Elem()\n\ttypeOfType := t.Type()\n\n\tvar data = make(map[string]interface{})\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tvar f string\n\t\tif typeOfType.Field(i).Tag.Get(\"json\") == \"\" {\n\t\t\tf = typeOfType.Field(i).Name\n\t\t} else {\n\t\t\tf = typeOfType.Field(i).Tag.Get(\"json\")\n\t\t}\n\t\tdata[f] = t.Field(i).Interface()\n\t}\n\treturn data\n}", "func Struct2Map(st interface{}) map[string]interface{} {\n\tvt := reflect.TypeOf(st)\n\tvv := reflect.ValueOf(st)\n\tvar data = make(map[string]interface{})\n\tfor i := 0; i < vt.NumField(); i++ {\n\t\tf := vt.Field(i)\n\t\tv := vv.Field(i)\n\t\tchKey := f.Tag.Get(\"json\")\n\t\tswitch v.Kind() {\n\t\tcase reflect.String:\n\t\t\tif s, ok := v.Interface().(string); ok && s != \"\" {\n\t\t\t\tdata[chKey] = s\n\t\t\t}\n\t\tcase reflect.Int:\n\t\t\tif i, ok := v.Interface().(int); ok && i != 0 {\n\t\t\t\tdata[chKey] = i\n\t\t\t}\n\t\tcase reflect.Struct:\n\t\t\tif t, ok := v.Interface().(time.Time); ok && t != (time.Time{}) {\n\t\t\t\tdata[chKey] = t\n\t\t\t}\n\t\tcase reflect.Uint64:\n\t\t\tif u64, ok := v.Interface().(uint64); ok && u64 != 0 {\n\t\t\t\tdata[chKey] = u64\n\t\t\t}\n\t\tcase reflect.Int64:\n\t\t\tif u64, ok := v.Interface().(int64); ok && u64 != 0 {\n\t\t\t\tdata[chKey] = u64\n\t\t\t}\n\t\tcase reflect.Uint:\n\t\t\tif u, ok := v.Interface().(uint); ok && u != 0 {\n\t\t\t\tdata[chKey] = u\n\t\t\t}\n\t\tcase reflect.Float32:\n\t\t\tif u, ok := v.Interface().(float32); ok && u != 0 {\n\t\t\t\tdata[chKey] = u\n\t\t\t}\n\t\tcase reflect.Float64:\n\t\t\tif u, ok := v.Interface().(float64); ok && u != 0 {\n\t\t\t\tdata[chKey] = u\n\t\t\t}\n\t\tcase reflect.Bool:\n\t\t\tif u, ok := v.Interface().(bool); ok {\n\t\t\t\tdata[chKey] = u\n\t\t\t}\n\n\t\tdefault:\n\t\t\tglog.Error(\"unsupport common query type: \" + string(chKey))\n\t\t}\n\t}\n\treturn data\n}", "func structToMap(t reflect.Type) (out map[string]interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tmlog.Error(fmt.Sprintf(\"Panicked in structToMap. This should never happen. %v\", r))\n\t\t}\n\t}()\n\n\tif t.Kind() != reflect.Struct {\n\t\t// Should never hit this, but this will prevent a panic if that does happen somehow\n\t\treturn nil\n\t}\n\n\tout = map[string]interface{}{}\n\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfield := t.Field(i)\n\n\t\tvar value interface{}\n\n\t\tswitch field.Type.Kind() {\n\t\tcase reflect.Struct:\n\t\t\tvalue = structToMap(field.Type)\n\t\tcase reflect.Ptr:\n\t\t\tindirectType := field.Type.Elem()\n\n\t\t\tif indirectType.Kind() == reflect.Struct {\n\t\t\t\t// Follow pointers to structs since we need to define defaults for their fields\n\t\t\t\tvalue = structToMap(indirectType)\n\t\t\t} else {\n\t\t\t\tvalue = nil\n\t\t\t}\n\t\tdefault:\n\t\t\tvalue = reflect.Zero(field.Type).Interface()\n\t\t}\n\n\t\tout[field.Name] = value\n\t}\n\n\treturn\n}", "func (qq Qualifiers) Map() map[string]string {\n\tm := make(map[string]string)\n\n\tfor i := 0; i < len(qq); i++ {\n\t\tk := qq[i].Key\n\t\tv := qq[i].Value\n\t\tm[k] = v\n\t}\n\n\treturn m\n}", "func makeMap(yamlStruct T) map[string]string {\n\turlMap := make(map[string]string)\n\tfor _, s := range yamlStruct {\n\t\turlMap[s.P] = s.U\n\t}\n\treturn urlMap\n}", "func (u *Util) StructToMap(data interface{}) (map[string]interface{}, error) {\n result := make(map[string]interface{})\n\n b, err := json.Marshal(data)\n if err != nil { return nil, err }\n\n err = json.Unmarshal(b, &result)\n return result, err\n}", "func (e *Extractor) FieldValueFromTagMap(tag string) (out map[string]interface{}, err error) {\n\n\tif err := e.isValidStruct(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tout = make(map[string]interface{})\n\ts := reflect.ValueOf(e.StructAddr).Elem()\n\tfields := e.fields(s)\n\n\tfor _, field := range fields {\n\t\tif val, ok := field.tags.Lookup(tag); ok {\n\t\t\tkey, omit := e.parseOmitempty(val, field.value)\n\t\t\tif omit {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tout[key] = field.value.Interface()\n\t\t}\n\n\t}\n\n\treturn\n}", "func (e *Extractor) TagMapping(from, to string) (out map[string]string, err error) {\n\tif err := e.isValidStruct(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tout = make(map[string]string)\n\ts := reflect.ValueOf(e.StructAddr).Elem()\n\tfields := e.fields(s)\n\n\tfor _, field := range fields {\n\t\tfromTag, fromOk := field.tags.Lookup(from)\n\t\ttoTag, toOk := field.tags.Lookup(to)\n\t\tif toOk && fromOk {\n\t\t\tout[fromTag] = toTag\n\t\t}\n\t}\n\n\treturn\n}", "func (r *ReflectMapper) FieldMap(v reflect.Value) map[string]reflect.Value {\n\tv = reflect.Indirect(v)\n\n\tret := map[string]reflect.Value{}\n\ttm := r.mapper.TypeMap(v.Type())\n\tfor tagName, fi := range tm.Names {\n\t\t//fmt.Println(tagName,fi.Parent.Zero.Kind(),fi.Parent.Field.Anonymous)\n\t\tif (fi.Parent.Zero.Kind() == reflect.Struct || (fi.Zero.Kind() == reflect.Ptr && fi.Zero.Type().Elem().Kind() == reflect.Struct)) && !fi.Parent.Field.Anonymous {\n\t\t\tcontinue\n\t\t}\n\t\tret[tagName] = reflectx.FieldByIndexes(v, fi.Index)\n\t}\n\n\treturn ret\n}", "func CreateMap(i interface{}, indent int) (map[string]interface{}, error) {\n\tm := make(map[string]interface{})\n\tv := reflect.ValueOf(i)\n\tif v.Kind() == reflect.Ptr {\n\t\tv = reflect.Indirect(v)\n\t}\n\tif v.Kind() != reflect.Struct {\n\t\treturn nil, ErrNotAStruct\n\t}\n\tif indent > 0 {\n\t\tfmt.Fprintln(writer,\"Struct: \", strings.Repeat(\" \", indent), v.Type().Name())\n\t} else {\n\t\tfmt.Fprintln(writer,\"Struct:\", v.Type().Name())\n\t}\n\tindent++\n\tscanner := bufio.NewScanner(reader)\n\tfor i := 0; i < v.NumField(); i++ {\n\t\tvar t string\n\t\tf := v.Field(i)\n\t\tn := v.Type().Field(i).Name\n\n\t\tswitch f.Kind() {\n\t\tcase reflect.Struct:\n\t\t\tfmt.Fprintf(writer, \"%sEmbedded struct: %s (name: %s)\\n\", strings.Repeat(\" \", indent+1), n, v.Type().Name())\n\t\tcase reflect.Ptr:\n\t\t\tfmt.Fprintf(writer, \"%sEmbedded pointer: %s (name: %s)\\n\", strings.Repeat(\" \", indent+1), n, v.Type().Name())\n\t\tcase reflect.Func, reflect.Uintptr, reflect.UnsafePointer, reflect.Chan:\n\t\t\tcontinue\n\t\tcase reflect.Interface:\n\t\t\t// if this isn't the empty interface we don't want to store data in it\n\t\t\tif f.NumMethod() != 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tif f.Kind() == reflect.Map || f.Kind() == reflect.Slice {\n\t\t\t// if we don't have a valid value type, skip it\n\t\t\tvtyp := reflect.New(f.Type().Elem())\n\t\t\t// TODO - fix - this shouldn't be here, too tired when working on this\n\t\t\tif !ValueTypeIsValid(vtyp, 0) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tif f.Kind() != reflect.Struct && f.Kind() != reflect.Ptr {\n\t\t\tfmt.Fprintf(writer, \"%sPlease enter a value for %s (type: %s)\", strings.Repeat(\" \", indent), n, f.Kind().String())\n\t\t\tif f.Kind() == reflect.Slice {\n\t\t\t\tfmt.Fprintf(writer, \"(%s) (enter your values as a comma separated list) ex: '1,2,3', 'I love configs!' - using double quotes will ignore commas inside them, like a csv. For slices of slices, use double quotes around each slice value: ex: \\\"1,2,3\\\",\\\"a,b,c\\\"\", f.Type().Elem())\n\t\t\t}\n\n\t\t\tif f.Kind() == reflect.Map {\n\t\t\t\tfmt.Fprintf(writer, \"KeyType: %s, ValueType:%s, (enter your values as a comma separated list of key value pairs separated by a colon) ex: 'first_key:first_value,second_key:secondvalue'\", f.Type().Key(), f.Type().Elem())\n\t\t\t}\n\n\t\t\tfmt.Fprintf(writer, \"\\n%s\", strings.Repeat(\" \", indent))\n\t\t\tscanner.Scan()\n\t\t\tt = scanner.Text()\n\t\t}\n\n\n\t\ti, err := ParseType(t, f.Type(), indent)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif i != nil {\n\t\t\tm[n] = i\n\t\t}\n\n\t}\n\treturn m, nil\n}", "func getMapping(t reflect.Type, mapFunc func(string) string) fieldMap {\n\ttype typeQueue struct {\n\t\tt reflect.Type\n\t\tp []int\n\t}\n\n\tqueue := []typeQueue{typeQueue{deref(t), []int{}}}\n\tm := fieldMap{}\n\tfor len(queue) != 0 {\n\t\t// Pop the first item off of the queue.\n\t\ttq := queue[0]\n\t\tqueue = queue[1:]\n\t\t// Iterate through all of its fields.\n\t\tfor fieldPos := 0; fieldPos < tq.t.NumField(); fieldPos++ {\n\t\t\tf := tq.t.Field(fieldPos)\n\n\t\t\tname, optlock := readTag(f.Tag.Get(tagName))\n\n\t\t\t// Breadth first search of untagged anonymous embedded structs.\n\t\t\tif f.Anonymous && f.Type.Kind() == reflect.Struct && name == \"\" {\n\t\t\t\tqueue = append(queue, typeQueue{deref(f.Type), appendIndex(tq.p, fieldPos)})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Skip unexported fields.\n\t\t\tif len(f.PkgPath) != 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// If the name is \"-\", disabled via a tag, skip it.\n\t\t\tif name == \"-\" {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif len(name) == 0 {\n\t\t\t\tif mapFunc != nil {\n\t\t\t\t\tname = mapFunc(f.Name)\n\t\t\t\t} else {\n\t\t\t\t\tname = f.Name\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If the name is shadowed by an earlier identical name in the\n\t\t\t// search, skip it.\n\t\t\tif _, ok := m[name]; ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Add it to the map at the current position.\n\t\t\tsf := f\n\t\t\tsf.Index = appendIndex(tq.p, fieldPos)\n\t\t\tm[name] = fieldDesc{sf, optlock}\n\t\t}\n\t}\n\treturn m\n}", "func MapToStruct(m map[string]interface{}, struc interface{}) error {\n\t//fmt.Printf(\"Input map: %+v\\n\", m)\n\t//fmt.Printf(\"Input struc: %+v\\n\", struc)\n\tval := r.Indirect(r.ValueOf(struc))\n\tsinfo := getStructInfo(val)\n\t//fmt.Printf(\"sinfo: %+v\\n\", sinfo)\n\tfor k, v := range m {\n\t\t//fmt.Printf(\"k: %+v v: %+v\\n\", k, v)\n\t\tif info, ok := sinfo.FieldsMap[k]; ok {\n\t\t\t//fmt.Printf(\"info: %+v\\n\", info)\n\t\t\tstructField := val.Field(info.Num)\n\t\t\t//fmt.Printf(\"type struct: %q, %q, %q\\n\", structField.Type(), structField.Type().Name(), structField.Kind())\n\t\t\t//fmt.Printf(\"type value: %q\\n\", r.TypeOf(v).Name())\n\t\t\t//fmt.Printf(\"value: %+v\\n\", r.ValueOf(v))\n\t\t\tif structField.Kind().String() == \"slice\" && r.TypeOf(v).Kind().String() == \"slice\" {\n\t\t\t\tif structField.Type().Elem() == r.TypeOf(v).Elem() {\n\t\t\t\t\t//fmt.Print(\"Slices of same type\\n\")\n\t\t\t\t\tstructField.Set(r.ValueOf(v))\n\t\t\t\t} else if structField.Type().Elem().Kind().String() == r.TypeOf(v).Elem().Kind().String() {\n\t\t\t\t\t//fmt.Print(\"Slices of same kind\\n\")\n\t\t\t\t\ts := r.ValueOf(v)\n\t\t\t\t\tresult := r.MakeSlice(structField.Type(), 0, s.Len())\n\t\t\t\t\tfor j := 0; j < s.Len(); j++ {\n\t\t\t\t\t\tresult = r.Append(result, r.ValueOf(s.Index(j).Interface()).Convert(structField.Type().Elem()))\n\t\t\t\t\t}\n\t\t\t\t\tstructField.Set(result)\n\t\t\t\t} else if r.TypeOf(v).Elem().String() == \"string\" {\n\t\t\t\t\t//fmt.Print(\"Slices of different kind\\n\")\n\t\t\t\t\tstringList := v.([]string)\n\t\t\t\t\tresult := r.MakeSlice(structField.Type(), 0, len(stringList))\n\t\t\t\t\tfor _, str := range stringList {\n\t\t\t\t\t\ttmp := r.New(structField.Type().Elem())\n\t\t\t\t\t\terr := json.Unmarshal([]byte(str), tmp.Interface())\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t//fmt.Printf(\"Unmarshal failed on: %q due to: %q!!!\\n\", str, err)\n\t\t\t\t\t\t\t//return err\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tresult = r.Append(result, r.Indirect(tmp))\n\t\t\t\t\t}\n\t\t\t\t\tstructField.Set(result)\n\t\t\t\t}\n\t\t\t} else if structField.Type().Name() == \"\" || r.TypeOf(v).Name() == \"\" {\n\t\t\t\treturn fmt.Errorf(\"WTF are these types???!!! %q %q\\n\", structField.Kind().String(), r.TypeOf(v).Kind().String())\n\t\t\t} else if structField.Type().Name() == r.TypeOf(v).Name() {\n\t\t\t\t//fmt.Print(\"Field set naturally!!!\\n\")\n\t\t\t\tstructField.Set(r.ValueOf(v))\n\t\t\t} else if structField.Kind().String() == r.TypeOf(v).Name() {\n\t\t\t\t//fmt.Print(\"Field set with convert !!!\\n\")\n\t\t\t\tstructField.Set(r.ValueOf(v).Convert(structField.Type()))\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"Please handle these types: %s with %s\\n\", structField.Kind().String(), r.TypeOf(v).Kind().String())\n\t\t\t}\n\t\t} else {\n\t\t\t//fmt.Printf(\"field %q not found\\n\", k) TODO: in which situation do we reach this point? oO\n\t\t}\n\t\t//fmt.Printf(\"Check fill struc: %+v\\n\", struc)\n\t}\n\treturn nil\n}", "func mapTags(tags []*elb.Tag) map[string]string {\n\ttagMap := make(map[string]string)\n\tfor _, t := range tags {\n\t\ttagMap[*t.Key] = *t.Value\n\t}\n\n\treturn tagMap\n}", "func (i GinJwtSignAlgorithm) NameMap() map[string]GinJwtSignAlgorithm {\n\treturn _GinJwtSignAlgorithmNameToValueMap\n}", "func (p Doc) Map() map[string]string {\n\tm := make(map[string]string)\n\n\tp.Foreach(func(v, k string) bool { m[k] = v; return true })\n\n\treturn m\n}", "func GetValueTagMap(src map[string]interface{}) map[string]interface{} {\n\tres := NewEmptyTagMap()\n\tres[\"inname\"] = \"value\"\n\tres[\"exname\"] = \"value\"\n\tres[\"type\"] = src[\"type\"]\n\tres[\"length\"] = src[\"length\"]\n\tres[\"scale\"] = src[\"scale\"]\n\tres[\"precision\"] = src[\"precision\"]\n\tres[\"fieldid\"] = src[\"fieldid\"]\n\treturn res\n}", "func (c *Config) MapStruct(key string, dst any) error {\n\treturn c.Structure(key, dst)\n}", "func (t *Type) MapType() *MapType", "func (self *Map) MapString(tagName ...string) map[string]string {\n\tvar rv = make(map[string]string)\n\n\tfor k, v := range self.MapNative(tagName...) {\n\t\trv[k] = typeutil.String(v)\n\t}\n\n\treturn rv\n}", "func Msg2Map(msg proto.Message) map[string]interface{} {\n\tt := reflect.TypeOf(msg)\n\tv := reflect.ValueOf(msg)\n\n\treturn buildStruct(t, v)\n}", "func parseMap(v interface{}) (map[string]interface{}, error) {\n\tstructRfl := reflect.ValueOf(v)\n\n\tresult := map[string]interface{}{}\n\n\t// Fail if the passed type is not a map\n\tif structRfl.Kind() != reflect.Map {\n\t\treturn result, fmt.Errorf(\"Expected map, got: %s\", structRfl.Kind().String())\n\t}\n\n\tmapRange := structRfl.MapRange()\n\tfor mapRange.Next() {\n\t\tresult[mapRange.Key().String()] = mapRange.Value().Interface()\n\t}\n\n\treturn result, nil\n}", "func getNameAndValue(m *dto.Metric) map[string]interface{} {\n\tfields := make(map[string]interface{})\n\tif m.Gauge != nil {\n\t\tif !math.IsNaN(m.GetGauge().GetValue()) {\n\t\t\t//nolint:unconvert // Conversion may be needed for float64 https://github.com/mdempsky/unconvert/issues/40\n\t\t\tfields[\"gauge\"] = float64(m.GetGauge().GetValue())\n\t\t}\n\t} else if m.Counter != nil {\n\t\tif !math.IsNaN(m.GetCounter().GetValue()) {\n\t\t\t//nolint:unconvert // Conversion may be needed for float64 https://github.com/mdempsky/unconvert/issues/40\n\t\t\tfields[\"counter\"] = float64(m.GetCounter().GetValue())\n\t\t}\n\t} else if m.Untyped != nil {\n\t\tif !math.IsNaN(m.GetUntyped().GetValue()) {\n\t\t\t//nolint:unconvert // Conversion may be needed for float64 https://github.com/mdempsky/unconvert/issues/40\n\t\t\tfields[\"value\"] = float64(m.GetUntyped().GetValue())\n\t\t}\n\t}\n\treturn fields\n}", "func ConfigToMap(in interface{}, tag string) (map[string]string, error) {\n\tout := make(map[string]string)\n\n\tv := reflect.ValueOf(in)\n\tif v.Kind() == reflect.Ptr {\n\t\tv = v.Elem()\n\t}\n\n\tif v.Kind() != reflect.Struct {\n\t\treturn nil, fmt.Errorf(\"ConfigToMap only accepts structs got %T\", v)\n\t}\n\n\ttyp := v.Type()\n\tfor i := 0; i < v.NumField(); i++ {\n\t\tfi := typ.Field(i)\n\t\tif mtag := fi.Tag.Get(tag); mtag != \"\" {\n\t\t\tout[mtag] = fmt.Sprint(v.Field(i).Interface())\n\t\t}\n\t}\n\treturn out, nil\n}", "func Map2Struct(in map[string]interface{}, out interface{}, configs ...*MapConfiguration) {\n\n\tconfig := combineConfiguration(configs...)\n\n\tfor key, value := range in {\n\t\tif config.ShouldIgnore(key) {\n\t\t\tcontinue\n\t\t}\n\t\tsetFieldValue(reflect.ValueOf(out).Elem(), config.Name(key), reflect.ValueOf(value), config)\n\t}\n}", "func (v *Value) Map() map[string]interface{} {\n\tval := make(map[string]interface{})\n\tkeys := &Value{value: C.value_array_keys(v.value)}\n\n\tfor _, k := range keys.Slice() {\n\t\tswitch key := k.(type) {\n\t\tcase int64:\n\t\t\tt := &Value{value: C.value_array_index_get(v.value, C.ulong(key))}\n\t\t\tsk := strconv.Itoa((int)(key))\n\n\t\t\tval[sk] = t.Interface()\n\t\t\tt.Destroy()\n\t\tcase string:\n\t\t\tstr := C.CString(key)\n\t\t\tt := &Value{value: C.value_array_key_get(v.value, str)}\n\t\t\tC.free(unsafe.Pointer(str))\n\n\t\t\tval[key] = t.Interface()\n\t\t\tt.Destroy()\n\t\t}\n\t}\n\n\tkeys.Destroy()\n\treturn val\n}", "func Map(vars ...Variable) map[string]interface{} {\n\tresult := map[string]interface{}{}\n\tfor _, v := range vars {\n\t\tresult[(string)(v)] = v.Value()\n\t}\n\treturn result\n}", "func compileStruct(t reflect.Type) map[string]interface{} {\n\tfs := map[string]interface{}{}\n\tcount := t.NumField()\n\tfor i := 0; i < count; i++ {\n\t\tf := t.Field(i)\n\t\tvar name string\n\t\tif !f.Anonymous {\n\t\t\tname = f.Name\n\t\t\tif tName := f.Tag.Get(\"nbt\"); len(tName) > 0 {\n\t\t\t\tname = tName\n\t\t\t}\n\t\t\tif name == \"ignore\" || f.Tag.Get(\"ignore\") == \"true\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t} else {\n\t\t\tname = f.Type.Name()\n\t\t\tif tName := f.Tag.Get(\"nbt\"); len(tName) > 0 {\n\t\t\t\tname = tName\n\t\t\t}\n\t\t\tif name == \"ignore\" || f.Tag.Get(\"ignore\") == \"true\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tfs[name] = compileField(f, name)\n\t}\n\treturn fs\n}", "func StructToMap(val interface{}) (map[string]interface{}, bool) {\n\t// indirect so function works with both structs and pointers to them\n\tstructVal := r.Indirect(r.ValueOf(val))\n\tkind := structVal.Kind()\n\tif kind != r.Struct {\n\t\treturn nil, false\n\t}\n\tsinfo := getStructInfo(structVal)\n\tmapVal := make(map[string]interface{}, len(sinfo.FieldsList))\n\tfor _, field := range sinfo.FieldsList {\n\t\tif structVal.Field(field.Num).CanInterface() {\n\t\t\tmapVal[field.Key] = structVal.Field(field.Num).Interface()\n\t\t}\n\t}\n\treturn mapVal, true\n}", "func ScanStructIntoMap(obj interface{}) (map[string]interface{}, error) {\n\tdataStruct := reflect.Indirect(reflect.ValueOf(obj))\n\tif dataStruct.Kind() != reflect.Struct {\n\t\treturn nil, errors.New(\"expected a pointer to a struct\")\n\t}\n\n\tdataStructType := dataStruct.Type()\n\n\tmapped := make(map[string]interface{})\n\n\tfor i := 0; i < dataStructType.NumField(); i++ {\n\t\tfield := dataStructType.Field(i)\n\t\tfieldName := field.Name\n\n\t\tmapKey := snakeCasedName(fieldName)\n\t\tvalue := dataStruct.FieldByName(fieldName).Interface()\n\n\t\tmapped[mapKey] = value\n\t}\n\n\treturn mapped, nil\n}", "func structToMap(structPtr interface{}, depth int, prefix ...string) FieldMap {\n\tval := reflect.ValueOf(structPtr)\n\tind := reflect.Indirect(val)\n\tif val.Kind() != reflect.Ptr || ind.Kind() != reflect.Struct {\n\t\ttools.LogAndPanic(log, \"structPtr must be a pointer to a struct\", \"structPtr\", structPtr)\n\t}\n\tres := make(FieldMap)\n\tfor i := 0; i < ind.NumField(); i++ {\n\t\tvar fieldName string\n\t\tif len(prefix) > 0 {\n\t\t\tfieldName = fmt.Sprintf(\"%s.%s\", prefix[0], ind.Type().Field(i).Name)\n\t\t} else {\n\t\t\tfieldName = ind.Type().Field(i).Name\n\t\t}\n\t\tfieldValue := ind.Field(i)\n\t\tvar resVal interface{}\n\t\tif fieldValue.Kind() == reflect.Ptr {\n\t\t\t// Get the related struct if not nil\n\t\t\trelInd := reflect.Indirect(fieldValue)\n\t\t\trelTyp := fieldValue.Type().Elem()\n\t\t\tswitch relTyp.Kind() {\n\t\t\tcase reflect.Struct:\n\t\t\t\tif depth > 0 {\n\t\t\t\t\tif !relInd.IsValid() {\n\t\t\t\t\t\t// create the struct if the pointer is nil\n\t\t\t\t\t\tfieldValue = reflect.New(relTyp)\n\t\t\t\t\t}\n\t\t\t\t\t// get the related struct fields\n\t\t\t\t\trelMap := structToMap(fieldValue.Interface(), depth-1, fieldName)\n\t\t\t\t\tfor k, v := range relMap {\n\t\t\t\t\t\tres[k] = v\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif !relInd.IsValid() {\n\t\t\t\t\t\t// Skip if pointer is nil\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\t// get the ID of the related struct\n\t\t\t\t\tresVal = relInd.FieldByName(\"ID\").Interface()\n\t\t\t\t}\n\t\t\t}\n\t\t\tif relInd.Kind() != reflect.Struct {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t} else {\n\t\t\tresVal = ind.Field(i).Interface()\n\t\t}\n\t\tres[fieldName] = resVal\n\t}\n\treturn res\n}", "func NamesMap() map[string]uint32 {\n\treturn map[string]uint32{\n\t\t\"dcOption\": DCOptionTypeID,\n\t\t\"config\": ConfigTypeID,\n\t}\n}", "func (node *selfNode) packToMap(m reflect.Value) (err error) {\n\n\tvar (\n\t\tkey interface{}\n\t\tvalue reflect.Value\n\t)\n\n\tnodeName := node.head.String()\n\tkeyType, elemType := m.Type().Key(), m.Type().Elem()\n\n\tfor _, n := range node.values {\n\t\tif _, ok := n.(*selfNode); !ok {\n\t\t\treturn n.newPackError(\"field `\" + nodeName + \"` should be only made of lists\")\n\t\t}\n\t\tvalueNode := n.(*selfNode)\n\t\tnodeHead := valueNode.head\n\t\tif key, err = nodeHead.encodeScalarField(keyType.Kind()); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tvalue = reflect.New(elemType).Elem()\n\t\tif err = valueNode.packIntoField(nodeHead.String(), value); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tm.SetMapIndex(reflect.ValueOf(key), value)\n\t}\n\treturn\n}", "func (i GinBindType) NameMap() map[string]GinBindType {\n\treturn _GinBindTypeNameToValueMap\n}", "func GetFieldMap(obj interface{}) (ret map[string]string) {\n\tval := reflect.ValueOf(obj).Elem()\n\tret = make(map[string]string)\n\tfor i := 0; i < val.NumField(); i++ {\n\t\ttypeField := val.Type().Field(i)\n\t\tkey := strings.ToLower(typeField.Name)\n\t\tif typeField.PkgPath != \"\" {\n\t\t\t// Private method\n\t\t\tcontinue\n\t\t} else {\n\t\t\tret[key] = typeField.Name\n\t\t}\n\t}\n\treturn\n}", "func (opts *ListOpts) GetMap() map[string]struct{} {\n ret := make(map[string]struct{})\n for _, k := range *opts.values {\n ret[k] = struct{}{}\n }\n return ret\n}", "func (i SNSProtocol) NameMap() map[string]SNSProtocol {\n\treturn _SNSProtocolNameToValueMap\n}", "func (kvs KeyValues) Map() map[string]string {\n\tvar m = make(map[string]string)\n\tfor idx := range kvs {\n\t\tm[kvs[idx].Key] = kvs[idx].Value\n\t}\n\treturn m\n}", "func StructToMap(in interface{}) (out map[string]interface{}) {\n\t// TODO use reflect to avoid encode-map-to-JSON then decode-JSON-to-struct\n\tout = nil\n\tif enc, err := json.Marshal(in); err == nil {\n\t\tout = make(map[string]interface{})\n\t\terr1 := json.Unmarshal(enc, &out)\n\t\tif err1 != nil {\n\t\t\tpanic(err1)\n\t\t}\n\t} else {\n\t\tpanic(err)\n\t}\n\treturn\n}", "func StructToMap(v interface{}) operator.M {\n\tdata := make(operator.M)\n\tbytes, _ := json.Marshal(v)\n\t_ = json.Unmarshal(bytes, &data)\n\treturn data\n}", "func (m *StructMapper) Map(src, dst interface{}) {\n\n\tif debug {\n\t\ttypeConversion := fmt.Sprintf(\"%s-%s\", reflect.ValueOf(src).Type(), reflect.ValueOf(dst).Type())\n\t\tfmt.Println(\"Enter Map() \", typeConversion)\n\t\tdefer fmt.Println(\"Leaving Map() \", typeConversion)\n\t}\n\n\tm.mapValue(reflect.ValueOf(src).Elem(), reflect.ValueOf(dst).Elem())\n}", "func (i SNSSubscribeAttribute) NameMap() map[string]SNSSubscribeAttribute {\n\treturn _SNSSubscribeAttributeNameToValueMap\n}", "func (node *Mapping) Map() (m map[interface{}]interface{}) {\n\tm = make(map[interface{}]interface{}, len(node.Pairs))\n\tfor _, pair := range node.Pairs {\n\t\tm[pair.Key.Data()] = pair.Value.Data()\n\t}\n\treturn\n}", "func processMap(name string, arr map[string]interface{}, value proto.Message) (reflect.Value, *adapter.ConfigErrors) {\n\tvar ce *adapter.ConfigErrors\n\tptrType := reflect.TypeOf(value)\n\tvalueType := reflect.Indirect(reflect.ValueOf(value)).Type()\n\toutmap := reflect.MakeMap(reflect.MapOf(reflect.ValueOf(\"\").Type(), ptrType))\n\tfor vname, val := range arr {\n\t\tdm := reflect.New(valueType).Interface().(proto.Message)\n\t\tif cerr := updateMsg(fmt.Sprintf(\"%s[%s]\", name, vname), val, dm, value, false); cerr != nil {\n\t\t\tce = ce.Extend(cerr)\n\t\t\tcontinue\n\t\t}\n\t\toutmap.SetMapIndex(reflect.ValueOf(vname), reflect.ValueOf(dm))\n\t}\n\treturn outmap, ce\n}", "func ConvertMapToStruct(v map[string]interface{}) (interface{}, error) {\n\tif v == nil {\n\t\treturn nil, nil\n\t}\n\n\trv := reflect.ValueOf(v)\n\tif !rv.IsValid() {\n\t\treturn nil, xerrors.Errorf(\"%#v is invalid\", v)\n\t}\n\n\tinstance := dynamicstruct.NewStruct()\n\n\ttype KeyValue struct {\n\t\tName string\n\t\tValue reflect.Value\n\t}\n\n\tkeys := rv.MapKeys()\n\tcollectedKeys := make([]KeyValue, len(keys))\n\tfor i, key := range keys {\n\t\tvalue := rv.MapIndex(key)\n\t\tif !value.CanInterface() {\n\t\t\treturn nil, xerrors.Errorf(\"cannot make interface for value of %s\", key.String())\n\t\t}\n\n\t\tif subMap, ok := value.Interface().(map[string]interface{}); ok {\n\t\t\tsubStruct, err := ConvertMapToStruct(subMap)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, xerrors.Errorf(\"cannot convert child map (key=%s) to struct: %w\", key.String(), err)\n\t\t\t}\n\t\t\tvalue = reflect.ValueOf(subStruct)\n\t\t\tif !value.CanInterface() {\n\t\t\t\treturn nil, xerrors.Errorf(\"cannot make interface for value of %s\", key.String())\n\t\t\t}\n\t\t}\n\n\t\tcollectedKeys[i] = KeyValue{\n\t\t\tName: strings.Title(key.String()),\n\t\t\tValue: value.Elem(),\n\t\t}\n\t}\n\n\t// sort keys\n\tsort.Slice(collectedKeys, func(i, j int) bool {\n\t\treturn strings.Compare(collectedKeys[i].Name, collectedKeys[j].Name) < 0\n\t})\n\n\tfor _, key := range collectedKeys {\n\t\tinstance = instance.AddField(key.Name, key.Value.Interface(), \"\")\n\t}\n\n\tst := instance.Build().New()\n\trst := reflect.ValueOf(st).Elem()\n\n\tfor _, key := range collectedKeys {\n\t\tf := rst.FieldByName(key.Name)\n\t\tif !f.IsValid() {\n\t\t\treturn nil, xerrors.Errorf(\"unable to find %s in new struct\", key.Name)\n\t\t}\n\t\tif !f.CanSet() {\n\t\t\treturn nil, xerrors.Errorf(\"unable to set value for %s in new struct\", key.Name)\n\t\t}\n\t\tf.Set(key.Value)\n\t}\n\n\treturn st, nil\n}", "func (s SliceOfBar) AsMap() map[string]*Bar {\n\tresult := make(map[string]*Bar)\n\tfor _, value := range s {\n\t\tresult[value.ID] = value\n\t}\n\treturn result\n}", "func (c *Config) Map() map[string]string {\n\treturn c.v\n}", "func ToStringStringMap(tagName string, input interface{}, properties ...string) (map[string]string, error) {\n\tvmap := make(map[string]string)\n\ts := structs.New(input)\n\ts.TagName = tagName\n\tif len(properties) == 0 {\n\t\tproperties = s.Names()\n\t}\n\n\tfor _, field := range s.Fields() {\n\t\tif !field.IsExported() {\n\t\t\tcontinue\n\t\t}\n\n\t\tif !stringInSlice(field.Name(), properties) {\n\t\t\tcontinue\n\t\t}\n\n\t\tfieldName, opts := parseTag(field.Tag(tagName))\n\t\tif fieldName == \"\" || fieldName == \"-\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tval := field.Value()\n\n\t\tif opts.Has(\"omitempty\") {\n\t\t\tif field.IsZero() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif z, ok := val.(isZeroer); ok && z.IsZero() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif z, ok := val.(isEmptier); ok && z.IsEmpty() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tkind := field.Kind()\n\t\tif kind == reflect.Ptr {\n\t\t\tv := reflect.ValueOf(val)\n\t\t\tif v.IsNil() {\n\t\t\t\tvmap[fieldName] = \"\"\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\telem := v.Elem()\n\t\t\tkind = elem.Kind()\n\t\t\tval = elem.Interface()\n\t\t}\n\n\t\tif opts.Has(\"include\") && kind == reflect.Struct {\n\t\t\tvar newProperties []string\n\t\t\tfor _, prop := range properties {\n\t\t\t\tif strings.HasPrefix(prop, fieldName+\".\") {\n\t\t\t\t\tnewProperties = append(newProperties, strings.TrimPrefix(prop, fieldName+\".\"))\n\t\t\t\t}\n\t\t\t}\n\t\t\tm, err := ToStringStringMap(tagName, val, newProperties...)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tfor k, v := range m {\n\t\t\t\tvmap[fieldName+\".\"+k] = v\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif v, ok := val.(string); ok {\n\t\t\tvmap[fieldName] = v\n\t\t\tcontinue\n\t\t} else if v, ok := val.(*string); ok {\n\t\t\tvmap[fieldName] = *v\n\t\t\tcontinue\n\t\t}\n\n\t\tif !field.IsZero() {\n\t\t\tif m, ok := val.(encoding.TextMarshaler); ok {\n\t\t\t\ttxt, err := m.MarshalText()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tvmap[fieldName] = string(txt)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif m, ok := val.(json.Marshaler); ok {\n\t\t\t\ttxt, err := m.MarshalJSON()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tvmap[fieldName] = string(txt)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tif kind == reflect.String {\n\t\t\tvmap[fieldName] = fmt.Sprint(val)\n\t\t\tcontinue\n\t\t}\n\n\t\tif txt, err := json.Marshal(val); err == nil {\n\t\t\tvmap[fieldName] = string(txt)\n\t\t\tif vmap[fieldName] == `\"\"` || vmap[fieldName] == \"null\" {\n\t\t\t\tvmap[fieldName] = \"\"\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tvmap[fieldName] = fmt.Sprintf(\"%v\", val)\n\t}\n\treturn vmap, nil\n}", "func (sl *Slice) NameToIndexMap() map[string]int {\n\tif len(*sl) == 0 {\n\t\treturn nil\n\t}\n\tnim := make(map[string]int, len(*sl))\n\tfor i, kid := range *sl {\n\t\tnim[kid.Name()] = i\n\t}\n\treturn nim\n}", "func bookInfoToMap(in BookInfo) map[string]string {\n\tret := make(map[string]string)\n\tv := reflect.ValueOf(in)\n\ttyp := v.Type()\n\tfor i := 0; i < v.NumField(); i++ {\n\t\tf := v.Field(i)\n\t\tvar v string\n\t\tswitch f.Type().Kind() {\n\t\tcase reflect.Slice, reflect.Array:\n\t\t\tv = fmt.Sprintf(\"%d\", f.Len())\n\t\tdefault:\n\t\t\tv = fmt.Sprintf(\"%s\", f.String())\n\t\t}\n\t\tret[typ.Field(i).Name] = v\n\t}\n\treturn ret\n}", "func (a *ByAttribute) newMap(data interface{}, reflectItems []*modelsNormalization.ReflectStructItem) (reflect.Value, error) {\n\tif len(reflectItems) == 0 {\n\t\treturn reflect.ValueOf(map[string]interface{}{}), nil\n\t}\n\n\tif mapElemType, equal := modelsNormalization.EqualStructItemType(reflectItems); equal {\n\t\tmapKeyType := reflect.TypeOf(string(\"\"))\n\t\tnewMap := reflect.MakeMap(reflect.MapOf(mapKeyType, mapElemType))\n\t\tfor _, item := range reflectItems {\n\t\t\tnewMap.SetMapIndex(reflect.ValueOf(item.MapKeyName), item.Value)\n\t\t}\n\t\treturn newMap, nil\n\t} else {\n\t\treturn a.newStruct(data, reflectItems)\n\t}\n}", "func mapKeysAndVals() {\r\n\tages := map[string]float64{}\r\n\r\n\tages[\"Alice\"] = 12\r\n\tages[\"Bob\"] = 9\r\n\tfmt.Println(ages[\"Alice\"], ages[\"Bob\"])\r\n}", "func Map(args ...interface{}) dgo.MapType {\n\treturn internal.MapType(args...)\n}", "func MarshallToStringMap(ni *NodeInfo) (data map[string]string) {\n\tm := make(map[string]string)\n\tm[\"ChassisSerial\"] = ni.ChassisSerial\n\tm[\"MachineID\"] = ni.MachineID\n\tm[\"CPUModelName\"] = ni.CPUModelName\n\tm[\"MemTotal\"] = fmt.Sprintf(\"%d\", ni.MemTotal)\n\tm[\"CPUMHz\"] = fmt.Sprintf(\"%f\", ni.CPUMHz)\n\tm[\"NumCPU\"] = fmt.Sprintf(\"%d\", ni.NumCPU)\n\tm[\"NumCore\"] = fmt.Sprintf(\"%d\", ni.NumCore)\n\tm[\"NumPhysicalCPU\"] = fmt.Sprintf(\"%d\", ni.NumPhysicalCPU)\n\tfor index, i := range ni.NetIntfs {\n\t\tvar buffer bytes.Buffer\n\t\tbody, _ := json.Marshal(i)\n\t\tbuffer.Write(body)\n\t\tm[\"NetIfs_\"+fmt.Sprintf(\"%d\", index)] = buffer.String()\n\t}\n\tfor index, d := range ni.Disks {\n\t\tvar buffer bytes.Buffer\n\t\tbody, _ := json.Marshal(d)\n\t\tbuffer.Write(body)\n\t\tm[\"Disks_\"+fmt.Sprintf(\"%d\", index)] = buffer.String()\n\t}\n\tlog.Printf(\"%+v\", m)\n\treturn m\n}", "func compileField(sf reflect.StructField, name string) interface{} {\n\tf := field{sField: sf.Index[0]}\n\n\tf.name = []byte(name)\n\n\tswitch sf.Type.Kind() {\n\tcase reflect.Struct:\n\t\treturn fieldStruct{f.sField, f.name, compileStruct(sf.Type)}\n\tcase reflect.Bool:\n\t\tf.write = encodeBool\n\t\tf.read = decodeBool\n\t\tf.requiredType = 1\n\tcase reflect.Int8:\n\t\tf.write = encodeInt8\n\t\tf.read = decodeInt8\n\t\tf.requiredType = 1\n\tcase reflect.Int16:\n\t\tf.write = encodeInt16\n\t\tf.read = decodeInt16\n\t\tf.requiredType = 2\n\tcase reflect.Int32:\n\t\tf.write = encodeInt32\n\t\tf.read = decodeInt32\n\t\tf.requiredType = 3\n\tcase reflect.Int64:\n\t\tf.write = encodeInt64\n\t\tf.read = decodeInt64\n\t\tf.requiredType = 4\n\tcase reflect.String:\n\t\tf.write = encodeString\n\t\tf.read = decodeString\n\t\tf.requiredType = 8\n\tcase reflect.Map:\n\t\tf.requiredType = 10\n\t\telem := sf.Type.Elem()\n\t\tvar elemField interface{}\n\t\tname := \"map:\" + sf.Name\n\t\tif elem.Kind() != reflect.Interface {\n\t\t\telemField = compileField(reflect.StructField{Type: elem, Index: []int{0}}, name)\n\t\t}\n\t\tf.write = func(w io.Writer, en *msgEncoder, fi reflect.Value) error {\n\t\t\tkeys := fi.MapKeys()\n\t\t\tfor _, key := range keys {\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tv := fi.MapIndex(key)\n\t\t\t\t\twritePrefix(en, w, []byte(key.String()), f.requiredType)\n\t\t\t\t\terr := f.write(w, en, v)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif elemField == nil {\n\t\t\t\t\t\tv := fi.MapIndex(key).Elem()\n\t\t\t\t\t\ttemp := compileField(reflect.StructField{Type: v.Type(), Index: []int{0}}, \"\")\n\t\t\t\t\t\tif f, ok := temp.(field); ok {\n\t\t\t\t\t\t\twritePrefix(en, w, []byte(key.String()), f.requiredType)\n\t\t\t\t\t\t\terr := f.write(w, en, v)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twritePrefix(en, w, []byte(key.String()), 10)\n\t\t\t\t\t\t\tfs := temp.(fieldStruct)\n\t\t\t\t\t\t\terr := write(w, en, fs.m, v)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\twritePrefix(en, w, []byte(key.String()), 10)\n\t\t\t\t\t\tfs := elemField.(fieldStruct)\n\t\t\t\t\t\tv := fi.MapIndex(key)\n\t\t\t\t\t\terr := write(w, en, fs.m, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t\tbs := en.b[:1]\n\t\t\tbs[0] = 0\n\t\t\t_, err := w.Write(bs)\n\t\t\treturn err\n\t\t}\n\t\tf.read = func(r io.Reader, de *msgDecoder, fi reflect.Value) error {\n\n\t\t\tma := reflect.MakeMap(sf.Type)\n\n\t\t\tname, t, err := readPrefix(r, de)\n\t\t\tfor ; t != 0; name, t, err = readPrefix(r, de) {\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tkeyVal := reflect.ValueOf(name)\n\n\t\t\t\tvar val reflect.Value\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tval = reflect.New(elem)\n\t\t\t\t\terr := f.read(r, de, val)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif elemField == nil {\n\t\t\t\t\t\tv, err := fallbackRead(r, de)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t\tval = reflect.ValueOf(v)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tval = reflect.New(elem)\n\t\t\t\t\t\tfs := elemField.(fieldStruct)\n\t\t\t\t\t\terr := read(r, de, fs.m, val)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tma.SetMapIndex(keyVal, val)\n\t\t\t}\n\t\t\tfi.Set(ma)\n\t\t\treturn nil\n\t\t}\n\tcase reflect.Slice:\n\t\tf.requiredType = 9\n\t\telem := sf.Type.Elem()\n\t\tswitch elem.Kind() {\n\t\tcase reflect.Uint8: //Short-cut for byte arrays\n\t\t\tf.requiredType = 7\n\t\t\tf.write = func(w io.Writer, en *msgEncoder, fi reflect.Value) error {\n\t\t\t\tl := fi.Len()\n\t\t\t\tbs := en.b[:4]\n\t\t\t\tbinary.BigEndian.PutUint32(bs, uint32(l))\n\t\t\t\t_, err := w.Write(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\t_, err = w.Write(fi.Bytes())\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tf.read = func(r io.Reader, de *msgDecoder, fi reflect.Value) error {\n\t\t\t\tbs := de.b[:4]\n\t\t\t\t_, err := r.Read(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tl := binary.BigEndian.Uint32(bs)\n\t\t\t\tout := make([]byte, l)\n\t\t\t\t_, err = r.Read(out)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tfi.SetBytes(out)\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase reflect.Int32: //Short-cut for int32 arrays\n\t\t\tf.requiredType = 11\n\t\t\tf.write = func(w io.Writer, en *msgEncoder, fi reflect.Value) error {\n\t\t\t\tl := fi.Len()\n\t\t\t\tbs := en.b[:4]\n\t\t\t\tbinary.BigEndian.PutUint32(bs, uint32(l))\n\t\t\t\t_, err := w.Write(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tdata := fi.Interface().([]int32)\n\t\t\t\tfor i := range data {\n\t\t\t\t\tbinary.BigEndian.PutUint32(bs, uint32(data[i]))\n\t\t\t\t\t_, err := w.Write(bs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tf.read = func(r io.Reader, de *msgDecoder, fi reflect.Value) error {\n\t\t\t\tbs := de.b[:4]\n\t\t\t\t_, err := r.Read(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tl := binary.BigEndian.Uint32(bs)\n\t\t\t\tout := make([]int32, l)\n\t\t\t\tfor i := range out {\n\t\t\t\t\t_, err := r.Read(bs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tout[i] = int32(binary.BigEndian.Uint32(bs))\n\t\t\t\t}\n\t\t\t\tfi.Set(reflect.ValueOf(out))\n\t\t\t\treturn nil\n\t\t\t}\n\t\tdefault:\n\t\t\tname := \"slice:\" + sf.Name\n\t\t\telemField := compileField(reflect.StructField{Type: elem, Index: []int{0}}, name)\n\t\t\tf.write = func(w io.Writer, en *msgEncoder, fi reflect.Value) error {\n\t\t\t\tl := fi.Len()\n\t\t\t\tbs := en.b[:5]\n\t\t\t\tbinary.BigEndian.PutUint32(bs[1:], uint32(l))\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tbs[0] = f.requiredType\n\t\t\t\t} else {\n\t\t\t\t\tbs[0] = 10\n\t\t\t\t}\n\t\t\t\t_, err := w.Write(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\t\t\tv := fi.Index(i)\n\t\t\t\t\t\terr := f.write(w, en, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tf := elemField.(fieldStruct)\n\t\t\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\t\t\tv := fi.Index(i)\n\t\t\t\t\t\terr := write(w, en, f.m, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tf.read = func(r io.Reader, de *msgDecoder, fi reflect.Value) error {\n\t\t\t\tbs := de.b[:5]\n\t\t\t\t_, err := r.Read(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tif bs[0] != f.requiredType {\n\t\t\t\t\t\treturn ErrorIncorrectType\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif bs[0] != 10 {\n\t\t\t\t\t\treturn ErrorIncorrectType\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tl := int(binary.BigEndian.Uint32(bs[1:]))\n\t\t\t\tval := reflect.MakeSlice(sf.Type, l, l)\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\t\t\tv := val.Index(i)\n\t\t\t\t\t\terr := f.read(r, de, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tf := elemField.(fieldStruct)\n\t\t\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\t\t\tv := val.Index(i)\n\t\t\t\t\t\terr := read(r, de, f.m, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfi.Set(val)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\tcase reflect.Float32:\n\t\tf.requiredType = 5\n\t\tf.write = encodeFloat32\n\t\tf.read = decodeFloat32\n\tcase reflect.Float64:\n\t\tf.requiredType = 6\n\t\tf.write = encodeFloat64\n\t\tf.read = decodeFloat64\n\tdefault:\n\t\tpanic(fmt.Errorf(\"Unhandled type %s for %s\", sf.Type.Kind().String(), sf.Name))\n\t}\n\treturn f\n}", "func (e *Extractor) FieldValueMap() (out map[string]interface{}, err error) {\n\n\tif err := e.isValidStruct(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tout = make(map[string]interface{})\n\ts := reflect.ValueOf(e.StructAddr).Elem()\n\tfields := e.fields(s)\n\n\tfor _, field := range fields {\n\t\tout[field.name] = field.value.Interface()\n\t}\n\n\treturn\n}", "func (i SNSPlatformApplicationAttribute) NameMap() map[string]SNSPlatformApplicationAttribute {\n\treturn _SNSPlatformApplicationAttributeNameToValueMap\n}", "func (p *packet) retrieveMap(value reflect.Value, tags []string) error {\n\tmatchedInstances := reflect.MakeMap(value.Type().Elem())\n\tfor tag, prv := range p.getProviders(tags) {\n\t\tinstance, err := prv.getInstance(p.ctn)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmatchedInstances.SetMapIndex(reflect.ValueOf(tag), instance)\n\t}\n\tvalue.Elem().Set(matchedInstances)\n\treturn nil\n}", "func (c combination) Map() map[string]interface{} {\n\tres := make(map[string]interface{}, len(c))\n\tfor _, p := range c {\n\t\tres[p.Dimension] = p.Value\n\t}\n\treturn res\n}", "func (p *Port) Map(name string) *Port {\n\tport, _ := p.subs[name]\n\treturn port\n}", "func NamesMap() map[string]uint32 {\n\treturn map[string]uint32{\n\t\t\"int\": 0xa8509bda,\n\t\t\"long\": 0x22076cba,\n\t\t\"double\": 0x2210c154,\n\t\t\"string\": 0xb5286e24,\n\t\t\"bytes\": 0xe937bb82,\n\t\t\"boolFalse\": 0xbc799737,\n\t\t\"boolTrue\": 0x997275b5,\n\t\t\"true\": 0x3fedd339,\n\t\t\"decryptedMessage8\": 0x1f814f1f,\n\t\t\"decryptedMessageService8\": 0xaa48327d,\n\t\t\"decryptedMessageMediaEmpty\": 0x89f5c4a,\n\t\t\"decryptedMessageMediaPhoto23\": 0x32798a8c,\n\t\t\"decryptedMessageMediaVideo8\": 0x4cee6ef3,\n\t\t\"decryptedMessageMediaGeoPoint\": 0x35480a59,\n\t\t\"decryptedMessageMediaContact\": 0x588a0a97,\n\t\t\"decryptedMessageActionSetMessageTTL\": 0xa1733aec,\n\t\t\"decryptedMessageMediaDocument23\": 0xb095434b,\n\t\t\"decryptedMessageMediaAudio8\": 0x6080758f,\n\t\t\"decryptedMessageActionReadMessages\": 0xc4f40be,\n\t\t\"decryptedMessageActionDeleteMessages\": 0x65614304,\n\t\t\"decryptedMessageActionScreenshotMessages\": 0x8ac1f475,\n\t\t\"decryptedMessageActionFlushHistory\": 0x6719e45c,\n\t\t\"decryptedMessage23\": 0x204d3878,\n\t\t\"decryptedMessageService\": 0x73164160,\n\t\t\"decryptedMessageMediaVideo23\": 0x524a415d,\n\t\t\"decryptedMessageMediaAudio\": 0x57e0a9cb,\n\t\t\"decryptedMessageLayer\": 0x1be31789,\n\t\t\"sendMessageTypingAction\": 0x16bf744e,\n\t\t\"sendMessageCancelAction\": 0xfd5ec8f5,\n\t\t\"sendMessageRecordVideoAction\": 0xa187d66f,\n\t\t\"sendMessageUploadVideoAction\": 0x92042ff7,\n\t\t\"sendMessageRecordAudioAction\": 0xd52f73f7,\n\t\t\"sendMessageUploadAudioAction\": 0xe6ac8a6f,\n\t\t\"sendMessageUploadPhotoAction\": 0x990a3c1a,\n\t\t\"sendMessageUploadDocumentAction\": 0x8faee98e,\n\t\t\"sendMessageGeoLocationAction\": 0x176f8ba1,\n\t\t\"sendMessageChooseContactAction\": 0x628cbc6f,\n\t\t\"decryptedMessageActionResend\": 0x511110b0,\n\t\t\"decryptedMessageActionNotifyLayer\": 0xf3048883,\n\t\t\"decryptedMessageActionTyping\": 0xccb27641,\n\t\t\"decryptedMessageActionRequestKey\": 0xf3c9611b,\n\t\t\"decryptedMessageActionAcceptKey\": 0x6fe1735b,\n\t\t\"decryptedMessageActionAbortKey\": 0xdd05ec6b,\n\t\t\"decryptedMessageActionCommitKey\": 0xec2e0b9b,\n\t\t\"decryptedMessageActionNoop\": 0xa82fdd63,\n\t\t\"documentAttributeImageSize\": 0x6c37c15c,\n\t\t\"documentAttributeAnimated\": 0x11b58939,\n\t\t\"documentAttributeSticker23\": 0xfb0a5727,\n\t\t\"documentAttributeVideo\": 0x5910cccb,\n\t\t\"documentAttributeAudio23\": 0x51448e5,\n\t\t\"documentAttributeFilename\": 0x15590068,\n\t\t\"photoSizeEmpty\": 0xe17e23c,\n\t\t\"photoSize\": 0x77bfb61b,\n\t\t\"photoCachedSize\": 0xe9a734fa,\n\t\t\"fileLocationUnavailable\": 0x7c596b46,\n\t\t\"fileLocation\": 0x53d69076,\n\t\t\"decryptedMessageMediaExternalDocument\": 0xfa95b0dd,\n\t\t\"documentAttributeAudio45\": 0xded218e0,\n\t\t\"decryptedMessage46\": 0x36b091de,\n\t\t\"decryptedMessageMediaPhoto\": 0xf1fa8d78,\n\t\t\"decryptedMessageMediaVideo\": 0x970c8c0e,\n\t\t\"decryptedMessageMediaDocument\": 0x7afe8ae2,\n\t\t\"documentAttributeSticker\": 0x3a556302,\n\t\t\"documentAttributeAudio\": 0x9852f9c6,\n\t\t\"messageEntityUnknown\": 0xbb92ba95,\n\t\t\"messageEntityMention\": 0xfa04579d,\n\t\t\"messageEntityHashtag\": 0x6f635b0d,\n\t\t\"messageEntityBotCommand\": 0x6cef8ac7,\n\t\t\"messageEntityUrl\": 0x6ed02538,\n\t\t\"messageEntityEmail\": 0x64e475c2,\n\t\t\"messageEntityBold\": 0xbd610bc9,\n\t\t\"messageEntityItalic\": 0x826f8b60,\n\t\t\"messageEntityCode\": 0x28a20571,\n\t\t\"messageEntityPre\": 0x73924be0,\n\t\t\"messageEntityTextUrl\": 0x76a6d327,\n\t\t\"messageEntityMentionName\": 0x352dca58,\n\t\t\"messageEntityPhone\": 0x9b69e34b,\n\t\t\"messageEntityCashtag\": 0x4c4e743f,\n\t\t\"messageEntityBankCard\": 0x761e6af4,\n\t\t\"inputStickerSetShortName\": 0x861cc8a0,\n\t\t\"inputStickerSetEmpty\": 0xffb62b95,\n\t\t\"decryptedMessageMediaVenue\": 0x8a0df56f,\n\t\t\"decryptedMessageMediaWebPage\": 0xe50511d8,\n\t\t\"sendMessageRecordRoundAction\": 0x88f27fbc,\n\t\t\"sendMessageUploadRoundAction\": 0xbb718624,\n\t\t\"documentAttributeVideo66\": 0xef02ce6,\n\t\t\"decryptedMessage\": 0x91cc4674,\n\t\t\"messageEntityUnderline\": 0x9c4e7e8b,\n\t\t\"messageEntityStrike\": 0xbf0693d4,\n\t\t\"messageEntityBlockquote\": 0x20df5d0,\n\t\t\"test.dummyFunction\": 0xc8357709,\n\t}\n}", "func StructToMap(a interface{}) (IObject, error) {\r\n\tb, err := json.Marshal(a)\r\n\tif err != nil {\r\n\t\treturn nil, TypeConvertError{}\r\n\t}\r\n\tvar f interface{}\r\n\terr = json.Unmarshal(b, &f)\r\n\tif res, ok := f.(map[string]interface{}); ok {\r\n\r\n\t\treturn NewObject(res)\r\n\t}\r\n\treturn nil, TypeConvertError{}\r\n}", "func mapfn(kvs ...interface{}) (map[string]interface{}, error) {\n\tif len(kvs)%2 != 0 {\n\t\treturn nil, errors.New(\"map requires even number of arguments.\")\n\t}\n\tm := make(map[string]interface{})\n\tfor i := 0; i < len(kvs); i += 2 {\n\t\ts, ok := kvs[i].(string)\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"even args to map must be strings.\")\n\t\t}\n\t\tm[s] = kvs[i+1]\n\t}\n\treturn m, nil\n}", "func mapCreate(name, rollNo, height, weight, averageMarks, extraCurricularGrade string) map[string]string {\n\tvar mapRet = map[string]string{\n\t\t\"name\": name,\n\t\t\"roll_no\": rollNo,\n\t\t\"weight\": weight,\n\t\t\"height\": height,\n\t\t\"avg_marks\": averageMarks,\n\t\t\"extra_curr_grades\": extraCurricularGrade,\n\t}\n\treturn mapRet\n}", "func Map2Struct(jmap interface{}, s interface{}) error {\n tmpDataJson, err := json.Marshal(jmap)\n if err != nil {\n return err\n }\n err = json.Unmarshal(tmpDataJson, &s)\n if err != nil {\n return err\n }\n return nil\n}", "func BuildTagMapping(structTemplatePointer interface{}, mappedKeyTag string, resultExclusionTag string, inheritKeyFromField bool, convertKeyToLowerCase bool, tags []string) map[string](map[string]string) {\n\treflectStructType := DiscoverTypeByKind(structTemplatePointer, reflect.Struct)\n\tvar result = make(map[string]map[string]string)\n\tvar anonymousMappings = make(map[string]map[string]string)\n\n\tfor i := 0; i < reflectStructType.NumField(); i++ {\n\t\tvar field reflect.StructField\n\t\tfield = reflectStructType.Field(i)\n\t\tkey := getTagValues(field, mappedKeyTag)\n\n\t\tif field.Anonymous && key == \"\" {\n\t\t\tvar anonymousType = DereferenceType(field.Type)\n\t\t\tif anonymousType.Kind() == reflect.Struct {\n\t\t\t\tanonymousMapping := BuildTagMapping(reflect.New(anonymousType).Interface(), mappedKeyTag, resultExclusionTag, inheritKeyFromField, convertKeyToLowerCase, tags)\n\t\t\t\tfor k, v := range anonymousMapping {\n\t\t\t\t\tanonymousMappings[k] = v\n\t\t\t\t\tanonymousMappings[k][anonymousKey] = \"true\"\n\t\t\t\t\tanonymousMappings[k][fieldIndexKey] = AsString(i)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcontinue\n\t\t}\n\n\t\tisTransient := strings.EqualFold(field.Tag.Get(resultExclusionTag), \"true\")\n\t\tif isTransient {\n\t\t\tcontinue\n\t\t}\n\n\t\tif key == \"\" {\n\t\t\tif !inheritKeyFromField {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tkey = field.Name\n\t\t}\n\n\t\tif convertKeyToLowerCase {\n\t\t\tkey = strings.ToLower(key)\n\t\t}\n\n\t\tresult[key] = make(map[string]string)\n\t\tfor _, tag := range tags {\n\t\t\ttagValue := field.Tag.Get(tag)\n\t\t\tif len(tagValue) > 0 {\n\t\t\t\tresult[key][tag] = tagValue\n\t\t\t}\n\t\t}\n\t\tresult[key][fieldNameKey] = field.Name\n\t}\n\n\tfor k, v := range anonymousMappings {\n\t\tif _, has := result[k]; !has {\n\t\t\tresult[k] = v\n\t\t}\n\t}\n\treturn result\n}", "func ToMap(componentName, src, root string) (map[string]interface{}, error) {\n\tobj, err := jsonnetParseFn(\"params.libsonnet\", src)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"parse jsonnet\")\n\t}\n\n\tcomponentObject, err := componentParams(obj, componentName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tm, err := convertObjectToMapFn(componentObject)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif componentName == \"\" {\n\t\treturn m[root].(map[string]interface{}), nil\n\t}\n\n\tparamsMap, ok := m[componentName].(map[string]interface{})\n\tif !ok {\n\t\treturn nil, errors.Errorf(\"component %q params is not an object\", componentName)\n\t}\n\n\treturn paramsMap, nil\n}", "func (c *Config) Map(w io.Writer, is ...interface{}) {\n\tvar iVals []reflect.Value\n\tfor _, i := range is {\n\t\tiVal := reflect.ValueOf(i)\n\t\tif !iVal.CanAddr() {\n\t\t\tif iVal.Kind() != reflect.Ptr && iVal.Kind() != reflect.Interface {\n\t\t\t\tfmt.Fprint(w, \"error: cannot map unaddressable value\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tiVal = iVal.Elem()\n\t\t}\n\t\tiVals = append(iVals, iVal)\n\t}\n\n\tm := &mapper{\n\t\tw,\n\t\tmap[nodeKey]nodeID{nilKey: 0},\n\t\tmap[nodeKey]string{nilKey: \"nil\"},\n\t\t5,\n\t}\n\n\tfmt.Fprintln(w, \"digraph structs {\")\n\tfmt.Fprintln(w, \" node [shape=Mrecord];\")\n\tfor _, iVal := range iVals {\n\t\tm.mapValue(iVal, 0, false)\n\t}\n\tfmt.Fprintln(w, \"}\")\n}", "func (deltaMergeImpl *DeltaMergeImpl) MapOfStringToGameObject(state *map[string]coreminer.GameObject, delta interface{}) map[string]coreminer.GameObject {\n\tdeltaMap := (*deltaMergeImpl).ToDeltaMap(delta)\n\tfor deltaKey, deltaValue := range deltaMap {\n\t\tif (*deltaMergeImpl).IsDeltaRemoved(deltaValue) {\n\t\t\tdelete(*state, deltaKey)\n\t\t} else {\n\t\t\t(*state)[deltaKey] = deltaMergeImpl.GameObject(deltaValue)\n\t\t}\n\t}\n\treturn *state\n}", "func (s StringSlice) Map() map[string]struct{} {\n\tm := map[string]struct{}{}\n\tfor _, w := range s {\n\t\tm[w] = struct{}{}\n\t}\n\treturn m\n}", "func Map(attrs []htmlgo.Attribute, children ...HTML) HTML {\n\treturn &htmlgo.Tree{Tag: \"map\", Attributes: attrs, Children: children}\n}", "func mapCreator2() {\n\n\tvar bootstrap2 = make(map[string]float64)\n\n\tbootstrap2[\"this is fun\"] = 123e9\n\n\tfmt.Println(bootstrap2)\n}", "func (flags VersionFlags) Map() map[string]int {\n\tflagMap := make(map[string]int, len(versionFlagIndices))\n\tflagValue := reflect.ValueOf(flags)\n\tfor flag, index := range versionFlagIndices {\n\t\tvalue := int(flagValue.Field(index).Int())\n\t\tflagMap[flag] = value\n\t}\n\treturn flagMap\n}", "func StructFromMapType() dgo.MapType {\n\tif sfmType == nil {\n\t\tsfmType = Parse(`map[string](dgo|type|{type:dgo|type,required?:bool,...})`).(dgo.MapType)\n\t}\n\treturn sfmType\n}", "func ParseMap(buf []byte) (map[string]interface{}, int, error) {\n\tif buf == nil {\n\t\tpanic(\"cannot parse nil byte array for structs\")\n\t}\n\n\tif len(buf) < 1 {\n\t\treturn nil, 0, errors.New(\"bytes empty, cannot parse struct\")\n\t}\n\n\tif buf[0]>>4 != 0xa && (buf[0] < 0xd8 || buf[0] > 0xda) {\n\t\treturn nil, 0, errors.New(\"expected a map\")\n\t}\n\n\tnumMembers := 0\n\tpos := 1\n\n\tif buf[0]>>4 == 0xa {\n\t\t// Tiny Map\n\t\tnumMembers = int(buf[0] & 0xf)\n\t} else {\n\t\tswitch buf[0] & 0x0f {\n\t\tcase 0x08:\n\t\t\tnumMembers = int(buf[pos])\n\t\t\tpos++\n\t\tcase 0x09:\n\t\t\tnumMembers = int(binary.BigEndian.Uint16(buf[pos : pos+2]))\n\t\t\tpos = pos + 2\n\t\tcase 0x0a:\n\t\t\tnumMembers = int(binary.BigEndian.Uint32(buf[pos : pos+4]))\n\t\t\tpos = pos + 4\n\t\tdefault:\n\t\t\treturn nil, 0, errors.New(\"invalid map prefix\")\n\t\t}\n\t}\n\n\tresult := make(map[string]interface{}, numMembers)\n\n\tfor i := 0; i < numMembers; i++ {\n\t\t// map keys are Strings\n\t\tname, n, err := ParseString(buf[pos:])\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tpos = pos + n\n\n\t\t// now for the value\n\t\tswitch buf[pos] >> 4 {\n\t\tcase 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7: // tiny-int\n\t\t\tval, err := ParseTinyInt(buf[pos])\n\t\t\tif err != nil {\n\t\t\t\treturn result, pos, err\n\t\t\t}\n\t\t\tresult[name] = val\n\t\t\tpos++\n\t\tcase 0x8: // tiny-string\n\t\t\tval, n, err := ParseTinyString(buf[pos:])\n\t\t\tif err != nil {\n\t\t\t\treturn result, pos, err\n\t\t\t}\n\t\t\tresult[name] = val\n\t\t\tpos = pos + n\n\t\tcase 0x9: // tiny-array\n\t\t\tval, n, err := ParseArray(buf[pos:])\n\t\t\tif err != nil {\n\t\t\t\treturn result, pos, err\n\t\t\t}\n\t\t\tresult[name] = val\n\t\t\tpos = pos + n\n\t\tcase 0xa: // tiny-map\n\t\t\tvalue, n, err := ParseMap(buf[pos:])\n\t\t\tif err != nil {\n\t\t\t\treturn result, pos, err\n\t\t\t}\n\t\t\tresult[name] = value\n\t\t\tpos = pos + n\n\t\tcase 0xc: // floats, nil, and bools\n\t\t\tnib := int(buf[pos] & 0xf)\n\t\t\tswitch nib {\n\t\t\tcase 0: // packed nil/null\n\t\t\t\tresult[name] = nil\n\t\t\t\tpos++\n\t\t\tcase 1: // packed float\n\t\t\t\tpanic(\"can't do floats yet\")\n\t\t\tcase 2:\n\t\t\t\tresult[name] = false\n\t\t\t\tpos++\n\t\t\tcase 3:\n\t\t\t\tresult[name] = true\n\t\t\t\tpos++\n\t\t\tcase 0x8, 0x9, 0xa, 0xb:\n\t\t\t\tval, n, err := ParseInt(buf[pos:])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn result, pos, err\n\t\t\t\t}\n\t\t\t\tresult[name] = val\n\t\t\t\tpos = pos + n\n\t\t\t}\n\t\tcase 0xd:\n\t\t\tnib := int(buf[pos] & 0xf)\n\t\t\tswitch nib {\n\t\t\tcase 0x0, 0x1, 0x2: // string\n\t\t\t\tval, n, err := ParseString(buf[pos:])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn result, pos, err\n\t\t\t\t}\n\t\t\t\tresult[name] = val\n\t\t\t\tpos = pos + n\n\t\t\tcase 0x4, 0x5, 0x6: // array\n\t\t\t\tval, n, err := ParseArray(buf[pos:])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn result, pos, err\n\t\t\t\t}\n\t\t\t\tresult[name] = val\n\t\t\t\tpos = pos + n\n\t\t\tcase 0x7:\n\t\t\t\tpanic(\"invalid prefix 0xd7\")\n\t\t\tcase 0x8, 0x9, 0xa:\n\t\t\t\t// err\n\t\t\t\tpanic(\"not ready\")\n\t\t\t}\n\n\t\tdefault:\n\t\t\terrMsg := fmt.Sprintf(\"found unsupported encoding type: %#v\\n\", buf[pos])\n\t\t\treturn result, pos, errors.New(errMsg)\n\t\t}\n\t}\n\treturn result, pos, nil\n}", "func (c Config) toMap() map[string]string {\n\tm := make(map[string]string)\n\tm[chefsolo.NAME] = meta.MC.Name\n\tm[chefsolo.CHEFREPO_GIT] = c.ChefRepoGit\n\tm[chefsolo.CHEFREPO_TARBALL] = c.ChefRepoTarball\n\tm[chefsolo.CHEFREPO_COOKBOOK] = c.Cookbook\n\treturn m\n}", "func LabelsToMap(kvs ...attribute.KeyValue) map[attribute.Key]attribute.Value {\n\tm := map[attribute.Key]attribute.Value{}\n\tfor _, label := range kvs {\n\t\tm[label.Key] = label.Value\n\t}\n\treturn m\n}", "func (h *virtualServiceHandler) Map(obj interface{}) (graph.Identifier, graph.Metadata) {\n\tvs := obj.(*kiali.VirtualService)\n\tm := k8s.NewMetadataFields(&vs.ObjectMeta)\n\treturn graph.Identifier(vs.GetUID()), k8s.NewMetadata(Manager, \"virtualservice\", m, vs, vs.Name)\n}", "func Test_interface001(t *testing.T) {\n\ts1 := make([]int, 10, 20)\n\ttest1(&s1)\n\tfmt.Println(s1)\n\n\tfmt.Println(len(s1))\n\n\ts2 := make(map[string]int)\n\ttest2(s2)\n\tfmt.Println(s2)\n\tfmt.Println(s2[\"aaaaa\"])\n\n\ts3 := make(map[string]sample1)\n\ttest2(s3)\n\tfmt.Println(s3)\n\n\ttype1 := reflect.MapOf(reflect.TypeOf(\"\"), reflect.TypeOf(1))\n\tfmt.Println(type1)\n\tfmt.Println(type1.Elem().Kind())\n\ts4 := reflect.MakeMap(type1)\n\tfmt.Println(s4.Kind())\n\tfmt.Println(s4.Type().Key().Kind())\n\tfmt.Println(s4.Type().Elem().Kind())\n\n\ts4.SetMapIndex(reflect.ValueOf(\"ccccc\"), reflect.ValueOf(3333))\n\n\tfmt.Println(s4)\n\n}", "func generateTomlKeysMap(structPtr reflect.Value, config map[string]interface{}) (map[string]interface{}, error) {\n\tstrct := structPtr.Elem()\n\ttomlMap := map[string]interface{}{}\n\tpType := strct.Type()\n\n\tfor configKey, configValue := range config {\n\t\tfield, found := pType.FieldByName(configKey)\n\n\t\tif !found {\n\t\t\treturn map[string]interface{}{}, fmt.Errorf(\"field %s did not exist on plugin\", configKey)\n\t\t}\n\n\t\ttomlTag := field.Tag.Get(\"toml\")\n\t\tif tomlTag == \"\" {\n\t\t\ttomlTag = configKey\n\t\t}\n\n\t\ttomlMap[tomlTag] = configValue\n\t}\n\n\treturn tomlMap, nil\n\n}", "func Map(m map[string]interface{}, k string, v interface{}) map[string]interface{} {\n\tm[k] = v\n\treturn m\n}", "func (p *Properties) Map() map[string]string {\n\treturn p.m\n}", "func Struct(v interface{}) (values CMap) {\n\tvalues = New()\n\tiVal := reflect.ValueOf(v)\n\tif iVal.Kind() == reflect.Ptr {\n\t\tiVal = iVal.Elem()\n\t}\n\ttyp := iVal.Type()\n\tfor i := 0; i < iVal.NumField(); i++ {\n\t\tfi := typ.Field(i)\n\t\tname := fi.Tag.Get(\"json\")\n\t\tif name == \"\" {\n\t\t\tname = fi.Name\n\t\t}\n\t\t// add support slice\n\t\tif iVal.Field(i).Kind() == reflect.Slice {\n\t\t\tvar buf bytes.Buffer\n\t\t\tbuf.WriteString(\"[\")\n\t\t\tiValArr := iVal.Field(i)\n\t\t\tfor j := 0; j < iValArr.Len(); j++ {\n\t\t\t\tbuf.WriteString(fmt.Sprint(`\"`, iValArr.Index(j), `\",`))\n\t\t\t}\n\t\t\tval := string(buf.Bytes()[:buf.Len()-1])\n\t\t\tval += \"]\"\n\t\t\tvalues.Set(name, val)\n\t\t\tcontinue\n\t\t}\n\t\tvalues.Set(name, fmt.Sprint(iVal.Field(i)))\n\t}\n\treturn\n}", "func (p Payload) Map() map[string]interface{} {\n\toutput := make(map[string]interface{})\n\terr := mapstructure.Decode(p, &output)\n\n\tif err != nil {\n\t\toutput = map[string]interface{}{\n\t\t\t\"error\": \"error in parsing response payload.\",\n\t\t}\n\t}\n\n\treturn output\n}", "func mapFilter(\n\tm map[string]*dynamodb.AttributeValue,\n\tnames ...string,\n) (n map[string]*dynamodb.AttributeValue) {\n\tn = make(map[string]*dynamodb.AttributeValue)\n\tfor _, name := range names {\n\t\tif name == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tif _, ok := m[name]; !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tn[name] = m[name]\n\t}\n\treturn\n}", "func (h *sizeHistogram) toMap() map[string]uint64 {\n\tres := make(map[string]uint64, dataUsageBucketLen)\n\tfor i, count := range h {\n\t\tres[ObjectsHistogramIntervals[i].name] = count\n\t}\n\treturn res\n}", "func (parser *Parser) parseMap(input string, targetType reflect.Type) (interface{}, error) {\n\tmatrix, err := parseHTMLTable(input)\n\tif err != nil {\n\t\treturn nil, toErrorf(\"'%v' is not a valid specification for '%v'\", input, targetType)\n\t}\n\tlength := len(matrix)\n\treturnValue := reflect.MakeMapWithSize(targetType, length)\n\tfor _, row := range matrix {\n\t\tif len(row) != 2 {\n\t\t\treturn nil, toErrorf(\"row '%v' in hash '%v' does not have two cells\", row, targetType)\n\t\t}\n\t\tvar key, value interface{}\n\t\tvar err error\n\t\tif key, err = parser.Parse(row[0], targetType.Key()); err != nil {\n\t\t\treturn nil, toErrorf(\"Could not parse key '%v' in hash '%v'\", row[0], targetType)\n\t\t}\n\t\tif value, err = parser.Parse(row[1], targetType.Elem()); err != nil {\n\t\t\treturn nil, toErrorf(\"Could not parse value '%v' in hash '%v'\", row[1], targetType)\n\t\t}\n\t\treturnValue.SetMapIndex(reflect.ValueOf(key), reflect.ValueOf(value))\n\t}\n\treturn returnValue.Interface(), nil\n}", "func StructToMap(s *structpb.Struct) map[string]interface{} {\n\tif s == nil {\n\t\treturn nil\n\t}\n\tm := map[string]interface{}{}\n\tfor k, v := range s.Fields {\n\t\tm[k] = decodeValue(v)\n\t}\n\treturn m\n}", "func mapFields(fields []string) map[string]uint16 {\n\trv := make(map[string]uint16, len(fields))\n\tfor i, fieldName := range fields {\n\t\trv[fieldName] = uint16(i) + 1\n\t}\n\treturn rv\n}", "func structName(entry *yang.Entry, forList bool) (string, error) {\n\tname, ok := entry.Annotation[\"structname\"]\n\tif !ok {\n\t\treturn \"\", status.Errorf(codes.NotFound, \"structname not found in annotations\")\n\t}\n\tif entry.IsList() && forList {\n\t\tkeys, err := listKeys(entry)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\t// if the entry is a list and we are targeting the container\n\t\t// NOTE we still need to support composite keys\n\t\treturn fmt.Sprintf(\"map[%s]*%s\", keys[0].Gotype, name), nil\n\t}\n\treturn fmt.Sprintf(\"*%s\", name), nil\n}", "func mapEncoder(e *encodeState, v reflect.Value) error {\n\ttype kvPair struct {\n\t\tk1 interface{}\n\t\tv1 interface{}\n\t\tk2 interface{}\n\t\tv2 interface{}\n\t}\n\n\tkeys := v.MapKeys()\n\tkvPairs := make([]kvPair, 0, (len(keys)+1)/2)\n\n\tif len(keys) == 0 {\n\t\treturn nil\n\t}\n\n\tvar (\n\t\tp kvPair\n\t\tisOdd bool\n\t)\n\n\tfor _, k := range keys {\n\t\tval := v.MapIndex(k)\n\t\tif !isOdd {\n\t\t\tp.k1, p.v1 = k.Interface(), val.Interface()\n\t\t} else {\n\t\t\tp.k2, p.v2 = k.Interface(), val.Interface()\n\t\t\tkvPairs = append(kvPairs, p)\n\t\t}\n\n\t\tisOdd = !isOdd\n\t}\n\n\tif !isOdd {\n\t\tkvPairs = append(kvPairs, p)\n\t}\n\n\treturn sliceEncoder(e, reflect.ValueOf(kvPairs))\n\n}", "func (this *DmnList) Map() (DmnMap, error) {\n\n\tdm := make(DmnMap)\n\n\tfor _, di := range *this {\n\n\t\tif dm[di.Key] == nil {\n\t\t\tdm[di.Key] = make(map[int]*DmnInfo)\n\t\t}\n\n\t\tdm[di.Key][di.Version] = di\n\t}\n\n\treturn dm, nil\n}", "func makeNodeMapperByLabel() (protocol.TreeFunc, func() map[int]*Node) {\n\tnodeMap := make(map[int]*Node)\n\n\tmapNode := func(t *protocol.Tree) { nodeMap[t.Node.(*Node).Label] = t.Node.(*Node) }\n\tgetNodeMap := func() map[int]*Node { return nodeMap }\n\n\treturn mapNode, getNodeMap\n}" ]
[ "0.6947698", "0.6550753", "0.6488883", "0.63773406", "0.63028806", "0.6241015", "0.6223389", "0.61835444", "0.6182754", "0.6062261", "0.60056233", "0.595988", "0.5907082", "0.5865792", "0.58084315", "0.5807308", "0.5769133", "0.573662", "0.57096326", "0.5690888", "0.5673567", "0.56454176", "0.5636232", "0.5604629", "0.5582723", "0.55700314", "0.556275", "0.55330545", "0.55089223", "0.5507531", "0.5501836", "0.54941887", "0.54886985", "0.54829454", "0.5480869", "0.5469815", "0.54688555", "0.5461785", "0.54411817", "0.5441106", "0.54364425", "0.5434295", "0.5433389", "0.5433006", "0.5432668", "0.5430304", "0.542877", "0.5405719", "0.5402013", "0.54019594", "0.53878784", "0.5381109", "0.53754807", "0.5375398", "0.5366907", "0.5346095", "0.5341997", "0.5338716", "0.53349465", "0.53329104", "0.53236425", "0.5321484", "0.53202206", "0.5309061", "0.52935547", "0.52919924", "0.5290974", "0.5288093", "0.5278047", "0.5276703", "0.5271783", "0.5259627", "0.5258068", "0.52580297", "0.5253407", "0.52502435", "0.5250119", "0.52460134", "0.5243124", "0.5218592", "0.5216123", "0.5214663", "0.52083784", "0.51805395", "0.5173114", "0.5170362", "0.5161843", "0.51575226", "0.5151872", "0.5144939", "0.51428145", "0.51357335", "0.51320624", "0.5131277", "0.5128481", "0.51134527", "0.5107609", "0.51072586", "0.51024055", "0.5101945" ]
0.5981603
11
Names returns names of struct
func Names(v interface{}) []string { return New(v).Names() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (e *Extractor) Names() (out []string, err error) {\n\n\tif err := e.isValidStruct(); err != nil {\n\t\treturn nil, err\n\t}\n\n\ts := reflect.ValueOf(e.StructAddr).Elem()\n\tfields := e.fields(s)\n\tfor _, field := range fields {\n\t\tout = append(out, field.name)\n\t}\n\n\treturn\n}", "func (s *Structx) Names() []string {\n\tvar result []string\n\n\tfs := s.Fields()\n\tfor _, v := range fs {\n\t\tresult = append(result, v.Name())\n\t}\n\n\treturn result\n}", "func (r *Recorder) names() []string {\n\tvar names []string\n\tfor _, h := range r.snapshot {\n\t\tnames = append(names, h.Name)\n\t}\n\treturn names\n}", "func Names(v interface{}, prev ...string) [][]string {\n\tval := reflect.ValueOf(v)\n\treturn names(val, prev)\n}", "func dataStructFieldNames(dataStruct reflect.Value) []string {\n\tfields := make([]string, dataStruct.NumField())\n\tstructType := dataStruct.Type()\n\tn := 0\n\tfor i := 0; i < len(fields); i++ {\n\t\tsf := structType.Field(i)\n\t\tname := sf.Name\n\t\tif r, _ := utf8.DecodeRuneInString(name); unicode.IsUpper(r) == false {\n\t\t\tcontinue\n\t\t}\n\t\tfields[n] = name\n\t\tn++\n\t}\n\treturn fields[:n]\n}", "func (a Fields) Names() []string {\n\tnames := make([]string, len(a))\n\tfor i, f := range a {\n\t\tnames[i] = f.Name\n\t}\n\treturn names\n}", "func getFieldsNames(v interface{}) []string {\n\tvalue := reflect.Indirect(reflect.ValueOf(v))\n\tvar result []string\n\tfor i := 0; i < value.NumField(); i++ {\n\t\tresult = append(result, value.Type().Field(i).Name)\n\t}\n\treturn result\n}", "func getFieldNames(v interface{}) (fieldNames []string) {\n\te := reflect.ValueOf(v).Elem()\n\teType := e.Type()\n\tfor i := 0; i < e.NumField(); i++ {\n\t\tvarName := eType.Field(i).Name\n\t\tfieldNames = append(fieldNames, varName)\n\t}\n\treturn\n}", "func objToNames(obj interface{}, names []string, tag string) []string {\n\tvar typ reflect.Type\n\n\tif sf, ok := obj.(reflect.StructField); ok {\n\t\ttyp = sf.Type\n\t} else {\n\t\ttyp = reflect.TypeOf(obj)\n\t\tif typ.Kind() == reflect.Ptr {\n\t\t\ttyp = typ.Elem()\n\t\t}\n\t}\n\n\tfor i := 0; i < typ.NumField(); i++ {\n\t\tfield := typ.Field(i)\n\n\t\tif field.Type.Kind() == reflect.Struct {\n\t\t\tnames = objToNames(field, names, tag)\n\t\t\tcontinue\n\t\t}\n\n\t\t// If tag is passed to the function, we only append if the field is tagged and that it matches tag.\n\t\tif tag == \"\" || field.Tag.Get(tag) != \"\" {\n\t\t\tnames = append(names, field.Name)\n\t\t}\n\t}\n\n\treturn names\n}", "func (mb *MutableBag) Names() []string {\n\ti := 0\n\tkeys := make([]string, len(mb.values))\n\tfor k := range mb.values {\n\t\tkeys[i] = k\n\t\ti++\n\t}\n\treturn append(keys, mb.parent.Names()...)\n}", "func (def *Definition) Fieldnames() []string {\n\ttypeList := make([]string, 0)\n\tt := TraverserMethods{EnterFunction: func(adaType IAdaType, parentType IAdaType, level int, x interface{}) error {\n\t\ttypeList = append(typeList, adaType.Name())\n\t\treturn nil\n\t}}\n\n\t_ = def.TraverseTypes(t, true, typeList)\n\treturn typeList\n}", "func (t *Struct) String() string { return t.Name }", "func GetNames(result []interface{})[]string{\n\tvar names []string\n\tfor _, poi := range result {\n\t\t//fmt.Println(poi.(map[string]interface{})[\"name\"])\n\t\tnames = append(names, poi.(map[string]interface{})[\"name\"].(string))\n\t}\n\treturn names\n}", "func (d data) GetNames(name string) []string {\n\tv := reflect.ValueOf(d.src).Elem().FieldByName(name)\n\tif v.Kind() != reflect.Slice {\n\t\treturn nil\n\t}\n\tnames := make([]string, v.Len())\n\tfor i := range names {\n\t\tsv := v.Index(i)\n\t\tvname := sv.FieldByName(\"Name\")\n\t\tif vname == (reflect.Value{}) {\n\t\t\tnames[i] = \"?\"\n\t\t} else {\n\t\t\tnames[i] = vname.String()\n\t\t}\n\t}\n\treturn names\n}", "func fields(spec *ast.TypeSpec) []*ast.Field {\n\ts := make([]*ast.Field, 0)\n\tif structType, ok := spec.Type.(*ast.StructType); ok {\n\t\tfor _, field := range structType.Fields.List {\n\t\t\tif keyname(field) != \"\" {\n\t\t\t\ts = append(s, field)\n\t\t\t}\n\t\t}\n\t}\n\treturn s\n}", "func StructFields(t reflect.Type) string {\n\tfields := make([]string, 0)\n\tif t.Kind() == reflect.Struct {\n\t\tfor i := 0; i < t.NumField(); i ++ {\n\t\t\tname := t.Field(i).Name\n\t\t\tif t.Field(i).Type.Kind() == reflect.Struct {\n\t\t\t\ts := StructFields(t.Field(i).Type)\n\t\t\t\tf := strings.Split(s, \", \")\n\t\t\t\tleft := FirstLower(name)\n\t\t\t\tfor _, v := range f {\n\t\t\t\t\tfields = append(fields, fmt.Sprintf(\"%s.%s\", left, FirstLower(v)))\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfields = append(fields, FirstLower(name))\n\t\t}\n\t}\n\n\treturn strings.Join(fields, \", \")\n}", "func (d *TagAny) NameS() []string {\n\treturn nvp.NameS(d)\n}", "func UConverterGetAvailableNames() (_swig_ret []string)", "func enumStructFields(t reflect.Type) []reflect.StructField {\n\t// We use this queue to visit every field in the struct (both immediate\n\t// ones and those in embedded structs), breadth-first.\n\tqueue := make([][]int, t.NumField())\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tqueue[i] = []int{i}\n\t}\n\n\tvar names = make(map[string]bool)\n\tvar fields []reflect.StructField\n\n\t// Work through the queue.\n\tfor ; len(queue) > 0; queue = queue[1:] {\n\t\tindex := queue[0]\n\t\tfield := t.FieldByIndex(index)\n\n\t\t// todo: Distinguish between empty struct tags and ones that are\n\t\t// simply missing.\n\t\tname := field.Tag.Get(\"binn\")\n\n\t\t// Visit the fields any embedded structs.\n\t\tif field.Anonymous && field.Type.Kind() == reflect.Struct && name == \"\" {\n\t\t\tindex = index[:len(index):len(index)]\n\t\t\tfor j := 0; j < field.Type.NumField(); j++ {\n\t\t\t\tqueue = append(queue, append(index, field.Type.Field(j).Index...))\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\t// Ignore unexported fields and fields without a \"binn\" tag.\n\t\tif field.PkgPath != \"\" && name == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tfield.Name = name\n\t\tfield.Index = index\n\t\tfields = append(fields, field)\n\n\t\tnames[name] = true\n\t}\n\n\t// Order the fields by their position in the root struct.\n\tsort.Sort(fieldsByIndex(fields))\n\n\treturn fields\n}", "func (o GetNodeTypesResultOutput) Names() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v GetNodeTypesResult) []string { return v.Names }).(pulumi.StringArrayOutput)\n}", "func getNames(elements []element) string {\n\tvar names string\n\tfor i, el := range elements {\n\t\tif i != 0 {\n\t\t\tnames += \" \"\n\t\t}\n\t\tnames += el.name\n\t}\n\treturn names\n}", "func (o GetFlowlogsResultOutput) Names() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v GetFlowlogsResult) []string { return v.Names }).(pulumi.StringArrayOutput)\n}", "func (n *dnode) Names() []string {\n\tn.mutex.RLock()\n\tdefer n.mutex.RUnlock()\n\n\ttmp := make([]string, 0, len(n.children))\n\tfor k := range n.children {\n\t\ttmp = append(tmp, k)\n\t}\n\tsort.Strings(tmp)\n\treturn tmp\n}", "func fieldNames(value interface{}) []ProcessClass {\n\tcountType := reflect.TypeOf(value)\n\tnames := make([]ProcessClass, 0, countType.NumField())\n\tfor index := 0; index < countType.NumField(); index++ {\n\t\ttag := strings.Split(countType.Field(index).Tag.Get(\"json\"), \",\")\n\t\tnames = append(names, ProcessClass(tag[0]))\n\t}\n\treturn names\n}", "func (m *ShowMeasurementsMapper) Fields() []string { return []string{\"name\"} }", "func (e *Extractor) NamesFromTag(tag string) (out []string, err error) {\n\n\tif err := e.isValidStruct(); err != nil {\n\t\treturn nil, err\n\t}\n\n\ts := reflect.ValueOf(e.StructAddr).Elem()\n\tfields := e.fields(s)\n\n\tfor _, field := range fields {\n\t\tif val, ok := field.tags.Lookup(tag); ok {\n\t\t\tkey, omit := e.parseOmitempty(val, field.value)\n\t\t\tif omit {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tout = append(out, key)\n\t\t}\n\t}\n\n\treturn\n}", "func (mb *MutableBag) Names() []string {\n\tif mb == nil {\n\t\treturn []string{}\n\t}\n\n\tif mb.parent == nil {\n\t\tpanic(fmt.Errorf(\"attempt to use a bag after its Done method has been called\"))\n\t}\n\n\tparentNames := mb.parent.Names()\n\n\tm := make(map[string]bool, len(parentNames)+len(mb.values))\n\tfor _, name := range parentNames {\n\t\tm[name] = true\n\t}\n\n\tfor name := range mb.values {\n\t\tm[name] = true\n\t}\n\n\ti := 0\n\tnames := make([]string, len(m))\n\tfor name := range m {\n\t\tnames[i] = name\n\t\ti++\n\t}\n\n\treturn names\n}", "func (g *Generator) fieldNames(n int) []string {\n\tif n > len(g.fieldStack) {\n\t\tn = len(g.fieldStack)\n\t}\n\tresult := make([]string, n)\n\tloopDepth := 0\n\tfor i := 0; i < n; i++ {\n\t\tf := g.fieldStack[i]\n\t\tif f.IsRepeated() {\n\t\t\tresult[i] = fmt.Sprintf(\"%s[%s]\", g.cName(f), loopVars[loopDepth])\n\t\t\tloopDepth++\n\t\t} else {\n\t\t\tresult[i] = g.cName(f)\n\t\t}\n\t}\n\treturn result\n}", "func GetNameFromStruct(u interface{}) string {\n\tvar result = ReturnValue{CustomStruct: u}\n\n\t//fmt.Println(result)\n\n\tmsg, ok := result.CustomStruct.(NameOnly)\n\tif ok {\n\t\t//fmt.Printf(\"Message1 is %s\\n\", msg.Name)\n\t\treturn msg.Name\n\t} else {\n\t\treturn \"\"\n\t}\n}", "func printNames(names []pkix.AttributeTypeAndValue, buf *bytes.Buffer) []string {\n values := []string{} \n for _, name := range names {\n oid := name.Type\n if len(oid) == 4 && oid[0] == 2 && oid[1] == 5 && oid[2] == 4 {\n switch oid[3] {\n case 3:\n values = append(values, fmt.Sprintf(\"CN=%s\", name.Value))\n case 6:\n values = append(values, fmt.Sprintf(\"C=%s\", name.Value))\n case 8:\n values = append(values, fmt.Sprintf(\"ST=%s\", name.Value))\n case 10:\n values = append(values, fmt.Sprintf(\"O=%s\", name.Value))\n case 11:\n values = append(values, fmt.Sprintf(\"OU=%s\", name.Value))\n default: \n values = append(values, fmt.Sprintf(\"UnknownOID=%s\", name.Type.String()))\n }\n } else if oid.Equal(oidEmailAddress) {\n values = append(values, fmt.Sprintf(\"emailAddress=%s\", name.Value))\n } else {\n values = append(values, fmt.Sprintf(\"UnknownOID=%s\", name.Type.String()))\n }\n }\n\nif len(values) > 0 {\n buf.WriteString(values[0])\n for i := 1; i < len(values); i++ {\n buf.WriteString(\",\" + values[i])\n }\n buf.WriteString(\"\\n\")\n }\n return values\n}", "func structName(entry *yang.Entry, forList bool) (string, error) {\n\tname, ok := entry.Annotation[\"structname\"]\n\tif !ok {\n\t\treturn \"\", status.Errorf(codes.NotFound, \"structname not found in annotations\")\n\t}\n\tif entry.IsList() && forList {\n\t\tkeys, err := listKeys(entry)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\t// if the entry is a list and we are targeting the container\n\t\t// NOTE we still need to support composite keys\n\t\treturn fmt.Sprintf(\"map[%s]*%s\", keys[0].Gotype, name), nil\n\t}\n\treturn fmt.Sprintf(\"*%s\", name), nil\n}", "func (pl List) names() []string {\n\tret := make([]string, len(pl))\n\tfor i, p := range pl {\n\t\tret[i] = p.String()\n\t}\n\treturn ret\n}", "func (o GetOpenApiPricingModulesResultOutput) Names() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v GetOpenApiPricingModulesResult) []string { return v.Names }).(pulumi.StringArrayOutput)\n}", "func (n Notes) Names() []string {\n\tnames := make([]string, 0)\n\tfor _, v := range n {\n\t\tnames = append(names, v.Name())\n\t}\n\treturn names\n}", "func (p *BaseProvider) Names() []string {\n\tnames := make([]string, 0, len(p.defs))\n\n\tfor name := range p.defs {\n\t\tnames = append(names, name)\n\t}\n\n\tsort.Strings(names)\n\n\treturn names\n}", "func (t *typeStruct) Name() string {\n\treturn t.name\n}", "func (t *SentryTaggedStruct) GetName() string {\n\treturn \"\"\n}", "func NameAnonStructs() {\n\tanonNamer := func(t reflect.StructField) string {\n\t\treturn fmt.Sprintf(\"WasAnon%s\", t.Name)\n\t}\n\tts, err := bel.Extract(NestedStuff{}, bel.NameAnonStructs(anonNamer))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\terr = bel.Render(ts)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}", "func (_DelegateProfile *DelegateProfileSession) FieldNames(arg0 *big.Int) (string, error) {\n\treturn _DelegateProfile.Contract.FieldNames(&_DelegateProfile.CallOpts, arg0)\n}", "func FieldArgNames(obj any, allArgs map[string]reflect.Value) {\n\tfieldArgNamesStruct(obj, \"\", false, allArgs)\n}", "func (rs Repos) Names() []string {\n\tnames := make([]string, len(rs))\n\tfor i := range rs {\n\t\tnames[i] = rs[i].Name\n\t}\n\treturn names\n}", "func (obj *ExitStatus) Names() []string {\n\treturn []string{\n\t\t\"OK\",\n\t\t\"ERROR\",\n\t}\n}", "func GetFields(m interface{}) (ns []string) {\n\ttyp := GetType(m)\n\t// Only structs are supported so return an empty result if the passed object\n\t// isn't a struct\n\tif typ.Kind() != reflect.Struct {\n\t\tfmt.Printf(\"%v type can't have attributes inspected\\n\", typ.Kind())\n\t\treturn\n\t}\n\t// loop through the struct's fields\n\tfor i := 0; i < typ.NumField(); i++ {\n\t\tf := typ.Field(i)\n\t\tif f.Anonymous {\n\t\t\tfkind := f.Type.Kind()\n\t\t\tif fkind == reflect.Struct || fkind == reflect.Ptr {\n\t\t\t\tfns := GetFields(reflect.New(f.Type).Interface())\n\t\t\t\tfor _, fn := range fns {\n\t\t\t\t\tif String(fn).IsInArray(ns) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tns = append(ns, fn)\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif String(f.Name).IsInArray(ns) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tns = append(ns, f.Name)\n\t\t}\n\t}\n\treturn ns\n}", "func (*unifinames) Name() string { return \"unifi-names\" }", "func (o GetSecretsResultOutput) Names() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v GetSecretsResult) []string { return v.Names }).(pulumi.StringArrayOutput)\n}", "func (_DelegateProfile *DelegateProfileCallerSession) FieldNames(arg0 *big.Int) (string, error) {\n\treturn _DelegateProfile.Contract.FieldNames(&_DelegateProfile.CallOpts, arg0)\n}", "func (s *Structx) Name() string {\n\treturn s.value.Type().Name()\n}", "func (e *Encoder) getColNames(v interface{}) []string {\n\ttyp := reflect.TypeOf(v)\n\tval := reflect.ValueOf(v)\n\tvar cols []string\n\tfor i := 0; i < typ.NumField(); i++ {\n\t\t// skip unexported\n\t\ttF := typ.Field(i)\n\t\tif len(tF.PkgPath) > 0 {\n\t\t\tcontinue\n\t\t}\n\t\tname := e.getFieldName(tF)\n\t\tif name == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tvF := val.Field(i)\n\t\tswitch vF.Kind() {\n\t\tcase reflect.Struct:\n\t\t\ttmp := e.getColNames(vF.Interface())\n\t\t\tcols = append(cols, tmp...)\n\t\t\tcontinue\n\t\tdefault:\n\t\t\tok := supportedBaseKind(vF)\n\t\t\tif !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tcols = append(cols, name)\n\t}\n\treturn cols\n}", "func (b bindingContainer) InterfaceNames() (keys []string) {\n\t//TODO: use Interfaces() here.\n\tkeys = make([]string, len(b))\n\ti := 0\n\tfor k, _ := range b {\n\t\tkeys[i] = k\n\t\ti++\n\t}\n\treturn\n}", "func (t Tags) Names() []string {\n\tset := map[string]string{}\n\tfor _, s := range t {\n\t\tset[s.Name] = \"\"\n\t}\n\n\tres := make([]string, 0, len(set))\n\n\tfor k := range set {\n\t\tres = append(res, k)\n\t}\n\n\tsort.Strings(res)\n\n\treturn res\n}", "func (p *Params) Names() []string {\n\treturn p.names\n}", "func (mfbp ProviderList) Names() []string {\n\tkeys := []string{}\n\tfor k := range mfbp {\n\t\tkeys = append(keys, k)\n\t}\n\n\tsort.Strings(keys)\n\n\treturn keys\n}", "func (g *generator) structFields(t reflect.Type) []field {\n\tvar fields []field\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tf := t.Field(i)\n\t\tif g.ignoreField(t, f) {\n\t\t\tcontinue\n\t\t}\n\t\tname, _ := parseTag(g.fieldTagKey, f.Tag)\n\t\tif name == \"\" {\n\t\t\tname = f.Name\n\t\t}\n\t\tfields = append(fields, field{\n\t\t\tName: name,\n\t\t\tType: f.Type,\n\t\t\tZero: zeroValue(f.Type),\n\t\t})\n\t}\n\treturn fields\n}", "func (m *Measurement) FieldNames() (a []string) {\n\tm.mu.RLock()\n\tdefer m.mu.RUnlock()\n\n\tfor n, _ := range m.fieldNames {\n\t\ta = append(a, n)\n\t}\n\treturn\n}", "func getNames(sub pkix.Name) []Name {\n\t// anonymous func for finding the max of a list of integer\n\tmax := func(v1 int, vn ...int) (max int) {\n\t\tmax = v1\n\t\tfor i := 0; i < len(vn); i++ {\n\t\t\tif vn[i] > max {\n\t\t\t\tmax = vn[i]\n\t\t\t}\n\t\t}\n\t\treturn max\n\t}\n\n\tnc := len(sub.Country)\n\tnorg := len(sub.Organization)\n\tnou := len(sub.OrganizationalUnit)\n\tnl := len(sub.Locality)\n\tnp := len(sub.Province)\n\n\tn := max(nc, norg, nou, nl, np)\n\n\tnames := make([]Name, n)\n\tfor i := range names {\n\t\tif i < nc {\n\t\t\tnames[i].C = sub.Country[i]\n\t\t}\n\t\tif i < norg {\n\t\t\tnames[i].O = sub.Organization[i]\n\t\t}\n\t\tif i < nou {\n\t\t\tnames[i].OU = sub.OrganizationalUnit[i]\n\t\t}\n\t\tif i < nl {\n\t\t\tnames[i].L = sub.Locality[i]\n\t\t}\n\t\tif i < np {\n\t\t\tnames[i].ST = sub.Province[i]\n\t\t}\n\t}\n\treturn names\n}", "func (s *FabricInterfaceSet) Names() []string {\n\tif s == nil {\n\t\treturn []string{}\n\t}\n\treturn s.byName.keys()\n}", "func (s *MyTestStruct) Name() string {\n\treturn s.field_Name\n}", "func (p Packet) ValueNames() []string {\n\tr := make([]string, len(p.DataTypes))\n\tfor i := range p.DataTypes {\n\t\tname := p.Name()\n\t\tvar valueName string\n\t\tswitch {\n\t\tcase p.Plugin == \"df\" && i == 0:\n\t\t\tvalueName = \"\"\n\t\tcase p.Plugin == \"memory\" && i == 0:\n\t\t\tvalueName = \"\"\n\t\tcase p.Plugin == \"interface\" && i == 0:\n\t\t\tvalueName = \"tx\"\n\t\tcase p.Plugin == \"interface\" && i == 1:\n\t\t\tvalueName = \"rx\"\n\t\tcase p.Plugin == \"load\" && i == 0:\n\t\t\tvalueName = \"1\"\n\t\tcase p.Plugin == \"load\" && i == 1:\n\t\t\tvalueName = \"5\"\n\t\tcase p.Plugin == \"load\" && i == 2:\n\t\t\tvalueName = \"15\"\n\t\tdefault:\n\t\t\tvalueName = strconv.FormatInt(int64(i), 10)\n\t\t}\n\t\tif valueName == \"\" {\n\t\t\tr[i] = name\n\t\t} else {\n\t\t\tr[i] = fmt.Sprintf(\"%s_%s\", name, valueName)\n\t\t}\n\t}\n\treturn r\n}", "func name(v reflect.StructField) string {\n\tif name, ok := v.Tag.Lookup(\"name\"); ok {\n\t\treturn name\n\t}\n\treturn v.Name\n}", "func (_DelegateProfile *DelegateProfileCaller) FieldNames(opts *bind.CallOpts, arg0 *big.Int) (string, error) {\n\tvar (\n\t\tret0 = new(string)\n\t)\n\tout := ret0\n\terr := _DelegateProfile.contract.Call(opts, out, \"fieldNames\", arg0)\n\treturn *ret0, err\n}", "func Names() []string {\n\t// TODO eliminate duplicates\n\tvar names []string\n\tfor _, f := range factories {\n\t\tnames = append(names, f.Names()...)\n\t}\n\treturn names\n}", "func (n *NameProvider) GetJSONNames(subject interface{}) []string {\n\tn.lock.Lock()\n\tdefer n.lock.Unlock()\n\ttpe := reflect.Indirect(reflect.ValueOf(subject)).Type()\n\tnames, ok := n.index[tpe]\n\tif !ok {\n\t\tnames = n.makeNameIndex(tpe)\n\t}\n\n\tres := make([]string, 0, len(names.jsonNames))\n\tfor k := range names.jsonNames {\n\t\tres = append(res, k)\n\t}\n\treturn res\n}", "func Names(tmpl Template) (names []string) {\n\ttS := tmpl.Templates()\n\tsort.Slice(tS, func(i, j int) bool { return (tS[i].Name() < tS[j].Name()) })\n\tfor i := range tS {\n\t\tnames = append(names, tS[i].Name())\n\t}\n\treturn\n}", "func (da *DataFrame) Names() []string {\n\treturn da.names\n}", "func (c Completer) Names() []string {\n\tnames := make([]string, 0, c.scope.Size())\n\tc.scope.Range(func(k string, v values.Value) {\n\t\tnames = append(names, k)\n\t})\n\tsort.Strings(names)\n\treturn names\n}", "func (n *Declarator) ParameterNames() []int { return n.DirectDeclarator.parameterNames() }", "func (s *Struct) structFields() []reflect.StructField {\n\tt := s.value.Type()\n\n\tvar f []reflect.StructField\n\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfield := t.Field(i)\n\t\t// we can't access the value of unexported fields\n\t\tif field.PkgPath != \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\t// don't check if it's omitted\n\t\tif tag := field.Tag.Get(s.TagName); tag == \"-\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tf = append(f, field)\n\t}\n\n\treturn f\n}", "func (d *DynamoDB) GetAllNames(table string) ([]string, error) {\n\titems, err := d.Scan(table)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar names []string\n\tfor _, item := range items {\n\t\tnames = append(names, *item[\"name\"].S)\n\t}\n\n\treturn names, nil\n}", "func mustGetNames(objects []runtime.Object) []string {\n\tvar names []string\n\tfor _, obj := range objects {\n\t\tmetaAccessor, err := meta.Accessor(obj)\n\t\tif err != nil {\n\t\t\tframework.Failf(\"error getting accessor for %T: %v\", obj, err)\n\t\t}\n\t\tname := metaAccessor.GetName()\n\t\tnames = append(names, name)\n\t}\n\tsort.Strings(names)\n\treturn names\n}", "func AllNames() []string {\n\tret := make([]string, 0, len(unitByName))\n\tfor n := range unitByName {\n\t\tif n == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tret = append(ret, n)\n\t}\n\tsort.Strings(ret)\n\treturn ret\n}", "func (t *Type) GetName() string { return t.Name }", "func (col Columns) Names() []string {\n\tnames := make([]string, col.Len())\n\tfor i, mn := range col.MultiNames() {\n\t\tname := strings.Join(mn, values.GetMultiColNameSeparator())\n\t\tnames[i] = name\n\t}\n\treturn names\n}", "func (sl *Slice) TypeAndNames() kit.TypeAndNameList {\n\tif len(*sl) == 0 {\n\t\treturn nil\n\t}\n\ttn := make(kit.TypeAndNameList, len(*sl))\n\tfor _, kid := range *sl {\n\t\ttn.Add(kid.Type(), kid.Name())\n\t}\n\treturn tn\n}", "func (c *Command) Names() []string {\n\tnames := strings.Split(c.Name, \",\")\n\tfor i, name := range names {\n\t\tnames[i] = strings.TrimSpace(name)\n\t}\n\treturn names\n}", "func (this *SIPMessage) GetHeaderNames() *list.List {\n\treturn this.headers\n\t// ListIterator li = this.headers.listIterator();\n\t// LinkedList retval = new LinkedList();\n\t// while (li.hasNext()) {\n\t// SIPHeader sipHeader = (SIPHeader) li.next();\n\t// String name = sipHeader.GetName();\n\t// retval.add(name);\n\t// }\n\t// return retval.listIterator();\n}", "func (e *Encoder) GetColNames(v interface{}) ([]string, error) {\n\tif reflect.TypeOf(v).Kind() != reflect.Struct {\n\t\treturn nil, StructRequiredError{reflect.TypeOf(v).Kind()}\n\t}\n\t// the returned bool is ignored because it's only used for recursive calls.\n\tnames := e.getColNames(v)\n\t// keep a copy\n\te.colNames = make([]string, len(names))\n\t_ = copy(e.colNames, names)\n\treturn names, nil\n}", "func (m *Workbook) GetNames()([]WorkbookNamedItemable) {\n return m.names\n}", "func typeNames(vars []*types.Var) string {\n\tif len(vars) == 0 {\n\t\treturn \"\"\n\t}\n\tvar buf strings.Builder\n\tfor i, v := range vars {\n\t\tif i != 0 {\n\t\t\tbuf.WriteString(\", \")\n\t\t}\n\t\tbuf.WriteString(nameOf(v.Type()))\n\t}\n\treturn buf.String()\n}", "func StructFields(t reflect.Type) interface{} {\n\treturn structInfoForType(t).fields\n}", "func (u *Union) Name() string { return u.TypeName }", "func (a *Aliens) Names() []string {\n\tnames := make([]string, len(*a))\n\tfor i, alien := range *a {\n\t\tnames[i] = alien.Name\n\t}\n\treturn names\n}", "func (c *ContainerContext) Names() string {\n\tnames := formatter.StripNamePrefix(c.c.Names)\n\tif c.trunc {\n\t\tfor _, name := range names {\n\t\t\tif len(strings.Split(name, \"/\")) == 1 {\n\t\t\t\tnames = []string{name}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\treturn strings.Join(names, \",\")\n}", "func (e *Enforcer) GetAllNamedObjects(ptype string) []string {\n\treturn e.model.GetValuesForFieldInPolicy(\"p\", ptype, 1)\n}", "func printStructField(t *reflect.Type) {\n fieldNum := (*t).NumField()\n for i := 0; i < fieldNum; i++ {\n fmt.Printf(\"conf's field: %s\\n\", (*t).Field(i).Name)\n }\n fmt.Println(\"\")\n}", "func Keys(i interface{}) (keys []string, ok bool) {\n\tkeys = make([]string, 0)\n\tv, k := preprocess(i)\n\tswitch k {\n\tcase reflect.Map:\n\t\tk := v.MapKeys()\n\t\tfor i := range k {\n\t\t\ts, ok := k[i].Interface().(string)\n\t\t\tif !ok {\n\t\t\t\treturn nil, false\n\t\t\t}\n\t\t\tkeys = append(keys, s)\n\t\t}\n\t\treturn keys, true\n\tcase reflect.Struct:\n\t\tt := v.Type()\n\t\tfor i := 0; i < v.NumField(); i++ {\n\t\t\tt2 := t.Field(i)\n\t\t\tfname := t2.Tag.Get(\"duck\")\n\t\t\tif fname != \"-\" {\n\t\t\t\tif fname == \"\" {\n\t\t\t\t\tfname = t2.Name\n\t\t\t\t}\n\t\t\t\tkeys = append(keys, fname)\n\t\t\t}\n\t\t}\n\t\treturn keys, true\n\t}\n\treturn nil, false\n}", "func (o GetInstanceAttachmentsResultOutput) Names() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v GetInstanceAttachmentsResult) []string { return v.Names }).(pulumi.StringArrayOutput)\n}", "func (p PropertyList) GetNames() []string {\n\tkeys := []string{}\n\tfor _, k := range p {\n\t\tkeys = append(keys, k.Name)\n\t}\n\n\t// Without this, the ordering is (intentionally) pseudorandom and inconsistent.\n\tsort.Strings(keys)\n\treturn keys\n}", "func (checker *CheckerType) VarNames() (obtained, expected string) {\n return \"obtained\", \"expected\"\n}", "func (flag *SliceFlag[T]) Names() []string {\n\treturn append([]string{flag.Name}, flag.Aliases...)\n}", "func (r *Registry) Names() []string {\n\tkeys := []string{}\n\tfor key := range r.registrants {\n\t\tkeys = append(keys, key)\n\t}\n\tsort.Strings(keys)\n\treturn keys\n}", "func (m *WorkbookWorksheet) GetNames()([]WorkbookNamedItemable) {\n return m.names\n}", "func (s *Struct) Fields() map[string]string {\n\tff := map[string]string{}\n\n\tfor _, f := range s.RawFields() {\n\t\tff[f.Field.Name] = f.Typ.String()\n\t}\n\n\treturn ff\n}", "func (obj *object) getStructName(line string) {\n\t/*nested := false\n\tif !strings.Contains(line, \"type \") {\n\t\tnested = true\n\t}*/\n\n\tline = strings.TrimSpace(line)\n\tline = strings.TrimPrefix(strings.TrimSuffix(line, \"{\"), \"type\")\n\tline = strings.TrimSpace(line)\n\tobj.Name = strings.TrimSpace(strings.TrimSuffix(line, \"struct\"))\n\tif strings.Contains(obj.Name, \"[]\") {\n\t\tobj.Name = strings.TrimSpace(strings.TrimSuffix(obj.Name, \"[]\"))\n\t}\n\tobj.Tp = obj.Name\n\tobj.JsonKey = obj.Name\n\t/*if nested {\n\t\tobj.CommonFileds = append(obj.CommonFileds, &field{JsonKey: obj.Name, Tp: obj.Name})\n\t}*/\n}", "func walkNames(exp Expr) []string {\n\tswitch expr := exp.(type) {\n\tcase *VarRef:\n\t\treturn []string{expr.Val}\n\tcase *Call:\n\t\tif len(expr.Args) == 0 {\n\t\t\treturn nil\n\t\t}\n\t\tlit, ok := expr.Args[0].(*VarRef)\n\t\tif !ok {\n\t\t\treturn nil\n\t\t}\n\n\t\treturn []string{lit.Val}\n\tcase *UnaryExpr:\n\t\treturn walkNames(expr.Expr)\n\tcase *BinaryExpr:\n\t\tvar ret []string\n\t\tret = append(ret, walkNames(expr.LHS)...)\n\t\tret = append(ret, walkNames(expr.RHS)...)\n\t\treturn ret\n\tcase *Case:\n\t\tvar ret []string\n\t\tfor _, cond := range expr.WhenThens {\n\t\t\tret = append(ret, walkNames(cond.When)...)\n\t\t\tret = append(ret, walkNames(cond.Then)...)\n\t\t}\n\t\tif expr.Else != nil {\n\t\t\tret = append(ret, walkNames(expr.Else)...)\n\t\t}\n\t\treturn ret\n\tcase *ParenExpr:\n\t\treturn walkNames(expr.Expr)\n\t}\n\n\treturn nil\n}", "func (cmd *CmdStruct) Name() string {\n\treturn MessageType(cmd.CmdID).String()\n}", "func (hdr RPMHeader) TagNames() []string {\n\ttags := []string{}\n\tfor _, tag := range hdr.Tags {\n\t\ttags = append(tags, tag.Name)\n\t}\n\treturn tags\n}", "func (e *EnumMatcher) GetName() string { return e.Name }", "func (o *Service) GetNamesOk() ([]string, bool) {\n\tif o == nil || o.Names == nil {\n\t\tvar ret []string\n\t\treturn ret, false\n\t}\n\treturn *o.Names, true\n}", "func ListNames(db *bolt.DB) ([]string, error) {\n\treturn dbutil.ListNames(db, dbutil.TOTPBucket)\n}", "func toStringFields(value reflect.Value, fieldNames []string) string {\n\tvar w bytes.Buffer\n\t// If value is a nil pointer, Indirect returns a zero Value!\n\t// Therefor we need to check for a zero value,\n\t// as CreateFieldByName could panic\n\tif indirectValue := reflect.Indirect(value); indirectValue.IsValid() {\n\t\tfor _, fieldName := range fieldNames {\n\t\t\tif fieldValue := indirectValue.FieldByName(fieldName); fieldValue.IsValid() {\n\t\t\t\ts := toString(fieldValue.Interface())\n\t\t\t\tif s == \"\" {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif w.Len() == 0 {\n\t\t\t\t\tw.WriteString(s)\n\t\t\t\t} else {\n\t\t\t\t\tw.WriteString(\"_\" + s)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn w.String()\n}" ]
[ "0.7588833", "0.7442672", "0.6471602", "0.64051765", "0.6401359", "0.63857347", "0.6371387", "0.6339941", "0.6253955", "0.62511194", "0.60572946", "0.60088223", "0.6007971", "0.5964404", "0.596039", "0.59451365", "0.5940028", "0.59323174", "0.5923466", "0.59138364", "0.5899827", "0.58126265", "0.57936966", "0.57861143", "0.57817996", "0.57734877", "0.5765923", "0.5733768", "0.57310116", "0.5723221", "0.5699389", "0.5696261", "0.56775266", "0.56728244", "0.5672804", "0.5670142", "0.56511873", "0.56360644", "0.5633906", "0.562456", "0.5620891", "0.5614059", "0.56088525", "0.56072295", "0.55495065", "0.5548502", "0.5534785", "0.5534192", "0.55287325", "0.55253834", "0.55167663", "0.55152005", "0.5510479", "0.55099386", "0.55031663", "0.54968727", "0.54864573", "0.54791284", "0.5477416", "0.5470214", "0.5468823", "0.5464027", "0.54586667", "0.54383737", "0.54363275", "0.5426113", "0.54248327", "0.542457", "0.5411303", "0.5405594", "0.5393388", "0.53792745", "0.5365517", "0.536432", "0.5343329", "0.5337602", "0.5337401", "0.5335077", "0.5330937", "0.5326291", "0.5317599", "0.5309694", "0.53064734", "0.5291121", "0.5287923", "0.527709", "0.52669597", "0.52605313", "0.525299", "0.5237339", "0.52311325", "0.522464", "0.52166086", "0.5215514", "0.520842", "0.5206319", "0.5206183", "0.52037126", "0.52025396", "0.519582" ]
0.6606947
2
Tags returns tags of struct
func Tags(v interface{}, key string) (map[string]string, error) { return New(v).Tags(key) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *Field) GetTags() string {\n\tif f == nil {\n\t\treturn \"\"\n\t}\n\n\tjsonTag := \"`json:\\\"\" + f.Name\n\n\tif f.Type.IsInputObject() || !f.Type.IsNonNull() {\n\t\tjsonTag += \",omitempty\"\n\t}\n\n\ttags := jsonTag + \"\\\"`\"\n\n\t// log.Print(\"\\n\\n **************************** \\n\")\n\t// log.Printf(\"\\n Struct Tags: %s \\n\", f)\n\t// log.Printf(\"\\n Struct Tags: %s \\n\", jsonTag)\n\t// log.Print(\"\\n **************************** \\n\\n\")\n\t// time.Sleep(5 * time.Second)\n\n\treturn tags\n}", "func tags(field *ast.Field) []string {\n\tvar tag string\n\tif field.Tag != nil {\n\t\ttag = field.Tag.Value[1 : len(field.Tag.Value)-1]\n\t\ttag = reflect.StructTag(tag).Get(\"json\")\n\t}\n\treturn strings.Split(tag, \",\")\n}", "func (r *RepositoryV2) Tags() (out []struct {\n\tName string\n\tImage string\n}, err error) {\n\turl := fmt.Sprintf(\"https://%s/v2/%s/tags/list\", r.Registry, r.Image)\n\treq, err := http.NewRequest(http.MethodGet, url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar apiResp struct {\n\t\tTags []string `json:\"tags\"`\n\t}\n\terr = json.NewDecoder(resp.Body).Decode(&apiResp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, tagName := range apiResp.Tags {\n\t\tout = append(out, struct {\n\t\t\tName string\n\t\t\tImage string\n\t\t}{\n\t\t\tName: tagName,\n\t\t\tImage: fmt.Sprintf(\"%s/%s:%s\", r.Registry, r.Image, tagName),\n\t\t})\n\t}\n\treturn out, nil\n}", "func (o InstanceOutput) Tags() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *Instance) pulumi.StringArrayOutput { return v.Tags }).(pulumi.StringArrayOutput)\n}", "func (o InstanceOutput) Tags() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *Instance) pulumi.StringArrayOutput { return v.Tags }).(pulumi.StringArrayOutput)\n}", "func (o InstanceFromTemplateOutput) Tags() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *InstanceFromTemplate) pulumi.StringArrayOutput { return v.Tags }).(pulumi.StringArrayOutput)\n}", "func (r *PrivateVirtualInterface) Tags() pulumi.MapOutput {\n\treturn (pulumi.MapOutput)(r.s.State[\"tags\"])\n}", "func (o BucketOutput) Tags() pulumi.MapOutput {\n\treturn o.ApplyT(func(v *Bucket) pulumi.MapOutput { return v.Tags }).(pulumi.MapOutput)\n}", "func (o BucketMetricFilterPtrOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *BucketMetricFilter) map[string]string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Tags\n\t}).(pulumi.StringMapOutput)\n}", "func (point *Point) GetTags(noarray bool, separator string) map[string]string {\n\ttags := map[string]string{}\n\ttags[\"vcenter\"] = point.VCenter\n\ttags[\"type\"] = point.ObjectType\n\ttags[\"name\"] = point.ObjectName\n\tif noarray {\n\t\tif len(point.Datastore) > 0 {\n\t\t\ttags[\"datastore\"] = point.Datastore[0]\n\t\t}\n\t} else {\n\t\tif len(point.Datastore) > 0 {\n\t\t\ttags[\"datastore\"] = strings.Join(point.Datastore, separator)\n\t\t}\n\t}\n\tif noarray {\n\t\tif len(point.Network) > 0 {\n\t\t\ttags[\"network\"] = point.Network[0]\n\t\t}\n\t} else {\n\t\tif len(point.Network) > 0 {\n\t\t\ttags[\"network\"] = strings.Join(point.Network, separator)\n\t\t}\n\t}\n\tif len(point.ESXi) > 0 {\n\t\ttags[\"host\"] = point.ESXi\n\t}\n\tif len(point.Cluster) > 0 {\n\t\ttags[\"cluster\"] = point.Cluster\n\t}\n\tif len(point.Instance) > 0 {\n\t\ttags[\"instance\"] = point.Instance\n\t}\n\tif len(point.ResourcePool) > 0 {\n\t\ttags[\"resourcepool\"] = point.ResourcePool\n\t}\n\tif len(point.Folder) > 0 {\n\t\ttags[\"folder\"] = point.Folder\n\t}\n\tif noarray {\n\t\tif len(point.ViTags) > 0 {\n\t\t\ttags[\"vitags\"] = point.ViTags[0]\n\t\t}\n\t} else {\n\t\tif len(point.ViTags) > 0 {\n\t\t\ttags[\"vitags\"] = strings.Join(point.ViTags, separator)\n\t\t}\n\t}\n\t/*\n\t\tif point.NumCPU != 0 {\n\t\t\ttags[\"numcpu\"] = strconv.FormatInt(int64(point.NumCPU), 10)\n\t\t}\n\t\tif point.MemorySizeMB != 0 {\n\t\t\ttags[\"memorysizemb\"] = strconv.FormatInt(int64(point.MemorySizeMB), 10)\n\t\t}\n\t*/\n\treturn tags\n}", "func (s *Structx) Tags(key string) (map[string]string, error) {\n\tresult := map[string]string{}\n\n\tfs := s.Fields()\n\tfor _, v := range fs {\n\t\tif !v.IsExport() {\n\t\t\tcontinue\n\t\t}\n\t\tresult[v.Name()] = v.Tag(key)\n\t}\n\n\treturn result, nil\n}", "func (hdr RPMHeader) Tag(tagname string) []string {\n\tfor _, tag := range hdr.Tags {\n\t\tif tag.Name == tagname {\n\t\t\treturn tag.Values\n\t\t}\n\t}\n\treturn []string{\"\"}\n}", "func (o TrackerOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Tracker) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o BucketOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Bucket) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func parseTags(st reflect.StructTag) tags {\n\ts := st.Get(ndrNameSpace)\n\tt := tags{\n\t\tValues: []string{},\n\t\tMap: make(map[string]string),\n\t}\n\tif s != \"\" {\n\t\tndrTags := strings.Trim(s, `\"`)\n\t\tfor _, tag := range strings.Split(ndrTags, \",\") {\n\t\t\tif strings.Contains(tag, \":\") {\n\t\t\t\tm := strings.SplitN(tag, \":\", 2)\n\t\t\t\tt.Map[m[0]] = m[1]\n\t\t\t} else {\n\t\t\t\tt.Values = append(t.Values, tag)\n\t\t\t}\n\t\t}\n\t}\n\treturn t\n}", "func (r *Repository) Tags() (out []struct {\n\tName string\n\tImage string\n}, err error) {\n\terr = r.Parse()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tswitch {\n\tcase r.V2 != nil:\n\t\treturn r.V2.Tags()\n\tcase r.DockerHub != nil:\n\t\treturn r.DockerHub.Tags()\n\tdefault:\n\t\treturn nil, errors.New(\"no docker Repository defined\")\n\t}\n}", "func (o BucketIntelligentTieringConfigurationFilterPtrOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *BucketIntelligentTieringConfigurationFilter) map[string]string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Tags\n\t}).(pulumi.StringMapOutput)\n}", "func ListTags() []string {\n\treturn _tags\n}", "func (self *Client) Tags(t MetricType, id string, o ...Modifier) (map[string]string, error) {\n\to = prepend(o, self.Url(\"GET\", TypeEndpoint(t), SingleMetricEndpoint(id), TagEndpoint()))\n\n\tr, err := self.Send(o...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer r.Body.Close()\n\n\tif r.StatusCode == http.StatusOK {\n\t\tb, err := ioutil.ReadAll(r.Body)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttags := make(map[string]string)\n\t\tif b != nil {\n\t\t\tif err = json.Unmarshal(b, &tags); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\treturn tags, nil\n\t} else if r.StatusCode > 399 {\n\t\treturn nil, self.parseErrorResponse(r)\n\t}\n\n\treturn nil, nil\n}", "func (o NetworkOutput) Tags() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *Network) pulumi.StringArrayOutput { return v.Tags }).(pulumi.StringArrayOutput)\n}", "func (c *Client) Tags(t MetricType, id string, o ...Modifier) (map[string]string, error) {\n\to = prepend(o, c.Url(\"GET\", TypeEndpoint(t), SingleMetricEndpoint(id), TagEndpoint()))\n\n\tr, err := c.Send(o...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer r.Body.Close()\n\n\tif r.StatusCode == http.StatusOK {\n\t\tb, err := ioutil.ReadAll(r.Body)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttags := make(map[string]string)\n\t\tif b != nil {\n\t\t\tif err = json.Unmarshal(b, &tags); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\treturn tags, nil\n\t} else if r.StatusCode > 399 {\n\t\treturn nil, c.parseErrorResponse(r)\n\t}\n\n\treturn nil, nil\n}", "func getTags(s interface{}, tag string) []string {\n\tvar columns []string\n\ttblStructType := reflect.TypeOf(s)\n\n\tfor fnum := 0; fnum < tblStructType.NumField(); fnum++ {\n\t\tfield := tblStructType.Field(fnum)\n\t\tif fieldName, ok := field.Tag.Lookup(tag); ok {\n\t\t\tif fieldName != \"\" {\n\t\t\t\tcolumns = append(columns, fieldName)\n\t\t\t}\n\t\t}\n\t}\n\treturn columns\n}", "func (aiService *AppinsightsMonitorService) getTags(tagType string, name string) map[string]*string {\n\n\ttags := make(map[string]*string)\n\n\tcomponentHiddenlink := fmt.Sprintf(\"hidden-link:/subscriptions/%s/resourceGroups/%s/providers/microsoft.insights/components/%s\", aiService.subscriptionID, aiService.resourceGroup, aiService.name)\n\twebtestHiddenlink := fmt.Sprintf(\"hidden-link:/subscriptions/%s/resourceGroups/%s/providers/microsoft.insights/webtests/%s\", aiService.subscriptionID, aiService.resourceGroup, name)\n\tvalue := \"Resource\"\n\n\tif tagType == \"webtest\" {\n\t\ttags[componentHiddenlink] = &value\n\t}\n\n\tif tagType == \"alert\" {\n\n\t\ttags[componentHiddenlink] = &value\n\t\ttags[webtestHiddenlink] = &value\n\t}\n\n\treturn tags\n}", "func (f Fess) GetTags() []string {\n\ttags := []string{\n\t\t\"full size\",\n\t\t\"ordinary\",\n\t}\n\treturn tags\n}", "func GetTags() [10]string {\n\treturn tags\n}", "func (o SubnetOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Subnet) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (r Roundel) GetTags() []string {\n\ttags := []string{\n\t\t\"ordinary\",\n\t}\n\treturn tags\n}", "func (r *Bucket) Tags() pulumi.MapOutput {\n\treturn (pulumi.MapOutput)(r.s.State[\"tags\"])\n}", "func (o OpenZfsVolumeOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *OpenZfsVolume) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func Tags(tags tftags.KeyValueTags) []*inspector.Tag {\n\tresult := make([]*inspector.Tag, 0, len(tags))\n\n\tfor k, v := range tags.Map() {\n\t\ttag := &inspector.Tag{\n\t\t\tKey: aws.String(k),\n\t\t\tValue: aws.String(v),\n\t\t}\n\n\t\tresult = append(result, tag)\n\t}\n\n\treturn result\n}", "func (o FleetOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Fleet) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (is *IfaceStat) GetTags() []string {\n\tvar tags []string\n\tvalueMap := structs.Map(is)\n\tfor k := range valueMap {\n\t\ttags = append(tags, k)\n\t}\n\n\treturn tags\n}", "func (o SnapshotOutput) Tags() pulumi.MapOutput {\n\treturn o.ApplyT(func(v *Snapshot) pulumi.MapOutput { return v.Tags }).(pulumi.MapOutput)\n}", "func (o EntityRecognizerOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *EntityRecognizer) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func GetStructTags(mode string, tagname string, input interface{}, options ...interface{}) []string {\n\n\tcolumns := make([]string, 0)\n\tvalue := reflect.ValueOf(input)\n\n\t// Originally used to rule out id field when insert\n\tvar skipFields []string\n\tif options != nil {\n\t\tskipFields = options[0].([]string)\n\t}\n\nFindTags:\n\tfor i := 0; i < value.NumField(); i++ {\n\n\t\tfield := value.Type().Field(i)\n\t\tfieldType := field.Type\n\t\tfieldValue := value.Field(i)\n\n\t\t// Use Type() to get struct tags\n\t\ttag := value.Type().Field(i).Tag.Get(tagname)\n\t\t// Skip fields if there are denoted\n\t\tif len(skipFields) > 0 {\n\n\t\t\tfor _, f := range skipFields {\n\t\t\t\tif tag == f {\n\t\t\t\t\tcontinue FindTags\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif mode == \"full\" {\n\t\t\tcolumns = append(columns, tag)\n\t\t} else if mode == \"non-null\" {\n\t\t\t// Append each tag for non-null field\n\t\t\tswitch fieldType.Name() {\n\t\t\tcase \"string\":\n\t\t\t\tif fieldValue.String() != \"\" {\n\t\t\t\t\tcolumns = append(columns, tag)\n\t\t\t\t}\n\t\t\tcase \"int64\", \"int\":\n\t\t\t\tif fieldValue.Int() != 0 {\n\t\t\t\t\tcolumns = append(columns, tag)\n\t\t\t\t}\n\t\t\tcase \"uint32\":\n\t\t\t\tif fieldValue.Uint() != 0 {\n\t\t\t\t\tcolumns = append(columns, tag)\n\t\t\t\t}\n\t\t\tcase \"NullString\", \"NullInt\", \"NullTime\", \"NullBool\":\n\t\t\t\tif fieldValue.FieldByName(\"Valid\").Bool() {\n\t\t\t\t\tcolumns = append(columns, tag)\n\t\t\t\t}\n\t\t\tcase \"bool\":\n\t\t\t\tcolumns = append(columns, tag)\n\t\t\tdefault:\n\t\t\t\tfmt.Println(\"unrecognised format: \", value.Field(i).Type())\n\t\t\t}\n\t\t}\n\t}\n\treturn columns\n}", "func (l *Log) Tags() (res []string) {\n\tres = l.tags\n\treturn\n}", "func getTagValues(f reflect.StructField, tag string) string {\n\treturn f.Tag.Get(tag)\n}", "func getTags(operation *openapi3.Operation) string {\n\treturn strings.Replace(operation.Tags[0], \" \", \"-\", -1)\n}", "func (g *GitLocal) Tags(dir string) ([]string, error) {\n\treturn g.GitCLI.Tags(dir)\n}", "func (s *Safe) Tags() ([]*safe.Tag, error) {\n\tres := make([]*safe.Tag, 0)\n\terr := s.db.View(func(tx *bolt.Tx) error {\n\t\treturn tx.Bucket([]byte(TagTable)).ForEach(func(k, v []byte) (err error) {\n\t\t\tvar d safe.Tag\n\t\t\tif err = json.Unmarshal(v, &d); err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tres = append(res, &d)\n\t\t\treturn\n\t\t})\n\t})\n\treturn res, err\n}", "func (m *MyMetric) TagList() []*protocol.Tag {\n\treturn m.Tags\n}", "func GetTags(registry string, github GitHub) ([]string, error) {\n\trepo := dockerRepo(github)\n\tvar tags []string\n\tfor _, t := range staticTags() {\n\t\ttags = append(tags, toFullTag(registry, repo, t))\n\t}\n\tif withRef, err := tagWithRef(); err != nil {\n\t\treturn nil, err\n\t} else if withRef {\n\t\tswitch github.Reference.Type {\n\t\tcase GitRefHead:\n\t\t\tif github.Reference.Name == \"master\" || github.Reference.Name == \"main\" {\n\t\t\t\ttags = append(tags, toFullTag(registry, repo, \"latest\"))\n\t\t\t} else {\n\t\t\t\ttags = appendGitRefTag(tags, registry, repo, github.Reference.Name)\n\t\t\t}\n\t\tcase GitRefPullRequest:\n\t\t\ttags = appendGitRefTag(tags, registry, repo, fmt.Sprintf(\"pr-%s\", github.Reference.Name))\n\n\t\tcase GitRefTag:\n\t\t\ttags = appendGitRefTag(tags, registry, repo, github.Reference.Name)\n\t\t}\n\t}\n\tif withSha, err := tagWithSha(); err != nil {\n\t\treturn nil, err\n\t} else if withSha {\n\t\ttags = appendShortGitShaTag(tags, github, registry, repo)\n\t}\n\treturn tags, nil\n}", "func (o LanguageModelOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *LanguageModel) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (t *SentryTaggedStruct) BuildTags(v interface{}) (tags map[string]string, err error) {\n\titems := make(map[string]string)\n\tfor prop, name := range t.Tags {\n\t\tif _, value, e := t.GetProperty(v, prop); e == nil {\n\t\t\titems[name] = value\n\t\t} else {\n\t\t\terr = e\n\t\t\treturn\n\t\t}\n\t}\n\n\ttags = items\n\treturn\n}", "func (o ReservedInstanceOutput) Tags() pulumi.MapOutput {\n\treturn o.ApplyT(func(v *ReservedInstance) pulumi.MapOutput { return v.Tags }).(pulumi.MapOutput)\n}", "func (f *flags) Tags() []string {\n\tif f.opt.Tags == modeFlagUnUsed {\n\t\treturn nil\n\t}\n\treturn f.exclude(f.getvalue(f.opt.Tags, \"tags\", \"t\"),\n\t\tf.getvalue(f.opt.ExcludeTags, \"nt\", \"\"))\n\n}", "func (o BucketMetricFilterOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v BucketMetricFilter) map[string]string { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (t *SentryTaggedStruct) GetTags() SentryTags {\n\treturn t.Tags\n}", "func (search *Search) Tags(tag string) (*SearchResult, error) {\n\tinsta := search.inst\n\tbody, err := insta.sendRequest(\n\t\t&reqOptions{\n\t\t\tEndpoint: urlSearchTag,\n\t\t\tQuery: map[string]string{\n\t\t\t\t\"is_typeahead\": \"true\",\n\t\t\t\t\"rank_token\": insta.rankToken,\n\t\t\t\t\"q\": tag,\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tres := &SearchResult{}\n\terr = json.Unmarshal(body, res)\n\treturn res, err\n}", "func (n *node) Tags() []string {\n\treturn n.tags\n}", "func (o RunBookOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *RunBook) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o BucketIntelligentTieringConfigurationFilterOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v BucketIntelligentTieringConfigurationFilter) map[string]string { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (d *DiskIOState) GetTags() []string {\n\tvar tags []string\n\tvalueMap := structs.Map(d)\n\tfor k := range valueMap {\n\t\ttags = append(tags, k)\n\t}\n\n\treturn tags\n}", "func (o BucketOutput) Tags() BucketTagArrayOutput {\n\treturn o.ApplyT(func(v *Bucket) BucketTagArrayOutput { return v.Tags }).(BucketTagArrayOutput)\n}", "func (o BucketOutput) Tags() BucketTagArrayOutput {\n\treturn o.ApplyT(func(v *Bucket) BucketTagArrayOutput { return v.Tags }).(BucketTagArrayOutput)\n}", "func Tag(name string, events ...imageapi.TagEvent) namedTagEventList {\n\treturn namedTagEventList{\n\t\tname: name,\n\t\tevents: imageapi.TagEventList{\n\t\t\tItems: events,\n\t\t},\n\t}\n}", "func getFieldTags(t reflect.StructField) (res []string) {\n\tif tags := t.Tag.Get(mapEnvTagName); len(tags) > 0 {\n\t\tfor _, s := range strings.Split(tags, \",\") {\n\t\t\tif len(s) > 0 {\n\t\t\t\tres = append(res, s)\n\t\t\t}\n\t\t}\n\t}\n\n\t// ignore json tags and field name if mpe tag is present\n\tif len(res) > 0 {\n\t\treturn\n\t}\n\n\tif tags := t.Tag.Get(\"json\"); len(tags) > 0 {\n\t\tjsonTags := strings.Split(tags, \",\")\n\t\tif len(jsonTags) > 0 && len(jsonTags[0]) > 0 {\n\t\t\tres = append(res, jsonTags[0])\n\t\t}\n\t}\n\n\t// ignore field name if json tag is present\n\tif len(res) > 0 {\n\t\treturn\n\t}\n\n\tres = append(res, t.Name)\n\n\treturn\n}", "func (o *ShortenBitlinkBodyAllOf) GetTags() []string {\n\tif o == nil || o.Tags == nil {\n\t\tvar ret []string\n\t\treturn ret\n\t}\n\treturn *o.Tags\n}", "func (p Pale) GetTags() []string {\n\ttags := []string{\n\t\t\"full size\",\n\t\t\"ordinary\",\n\t}\n\treturn tags\n}", "func (o ListenerOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v Listener) map[string]string { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o LinkOutput) Tags() LinkTagArrayOutput {\n\treturn o.ApplyT(func(v *Link) LinkTagArrayOutput { return v.Tags }).(LinkTagArrayOutput)\n}", "func (o LookupOpenZfsSnapshotResultOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v LookupOpenZfsSnapshotResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o VolumeGroupSapHanaVolumeOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v VolumeGroupSapHanaVolume) map[string]string { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (r *Registry) Tags(ctx context.Context, repository string) ([]Tag, error) {\n tagNames, err := r.TagNames(ctx, repository)\n if err != nil {\n\t\treturn nil, err\n\t}\n\n\ttags := make([]Tag, len(tagNames))\n\tfor i := range tags {\n\t\ttags[i] = Tag {\n\t\t\tName: tagNames[i],\n\t\t\tRepository: repository,\n\t\t\tRegistry: r,\n\t\t}\n\t}\n\treturn tags, nil\n}", "func (ce *CustomEvent) GetTags() []string {\n\treturn append(ce.tags, \"type:\"+ce.GetType())\n}", "func (o LookupTestCaseResultOutput) Tags() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v LookupTestCaseResult) []string { return v.Tags }).(pulumi.StringArrayOutput)\n}", "func (o ThingGroupOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *ThingGroup) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (db *BotDB) GetTags(guild uint64) []struct {\n\tName string\n\tCount int\n} {\n\tq, err := db.sqlGetTags.Query(guild)\n\terr = db.standardErr(err)\n\tif db.CheckError(\"GetTags\", err) != nil {\n\t\treturn []struct {\n\t\t\tName string\n\t\t\tCount int\n\t\t}{}\n\t}\n\tdefer q.Close()\n\tr := make([]struct {\n\t\tName string\n\t\tCount int\n\t}, 0, 10)\n\tfor q.Next() {\n\t\tp := struct {\n\t\t\tName string\n\t\t\tCount int\n\t\t}{}\n\t\tif err := q.Scan(&p.Name, &p.Count); err == nil {\n\t\t\tr = append(r, p)\n\t\t}\n\t}\n\treturn r\n}", "func GetTypeTags(typ reflect.Type, tagNames []string, fs ...func(reflect.StructTag) bool) map[string]GF[string] {\n\tvar (\n\t\ttags = make(map[string]GF[string])\n\t)\n\tfor _, tagName := range tagNames {\n\t\ttags[tagName] = GetTypeTag(typ, tagName, fs...)\n\t}\n\treturn tags\n}", "func (a *API) Tags(ctx context.Context, params TagsParams) (*TagsResult, error) {\n\tres := &TagsResult{}\n\t_, err := a.get(ctx, api.BuildPath(tags, params.AssetType), params, res)\n\n\treturn res, err\n}", "func GetTags() []string {\n\ttags := []string{\n\t\t\"script\",\n\t\t\"iframe\",\n\t\t\"svg\",\n\t\t\"img\",\n\t\t\"video\",\n\t\t\"audio\",\n\t\t\"meta\",\n\t\t\"object\",\n\t\t\"embed\",\n\t\t\"style\",\n\t\t\"frame\",\n\t\t\"frameset\",\n\t\t\"applet\",\n\t}\n\treturn tags\n}", "func (e *Extractor) NamesFromTag(tag string) (out []string, err error) {\n\n\tif err := e.isValidStruct(); err != nil {\n\t\treturn nil, err\n\t}\n\n\ts := reflect.ValueOf(e.StructAddr).Elem()\n\tfields := e.fields(s)\n\n\tfor _, field := range fields {\n\t\tif val, ok := field.tags.Lookup(tag); ok {\n\t\t\tkey, omit := e.parseOmitempty(val, field.value)\n\t\t\tif omit {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tout = append(out, key)\n\t\t}\n\t}\n\n\treturn\n}", "func (v *vcsCmd) tags(dir string) ([]string, error) {\n\tvar tags []string\n\tfor _, tc := range v.tagCmd {\n\t\tout, err := v.runOutput(dir, tc.cmd)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tre := regexp.MustCompile(`(?m-s)` + tc.pattern)\n\t\tfor _, m := range re.FindAllStringSubmatch(string(out), -1) {\n\t\t\ttags = append(tags, m[1])\n\t\t}\n\t}\n\treturn tags, nil\n}", "func (o VpcLinkOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *VpcLink) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o FaqOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Faq) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func typeTags(structType reflect.Type) (tags []byte) {\n\ttagStr := structType.Field(0).Tag.Get(\"sshtype\")\n\n\tfor _, tag := range strings.Split(tagStr, \"|\") {\n\t\ti, err := strconv.Atoi(tag)\n\t\tif err == nil {\n\t\t\ttags = append(tags, byte(i))\n\t\t}\n\t}\n\n\treturn tags\n}", "func (r *Document) Tags() pulumi.MapOutput {\n\treturn (pulumi.MapOutput)(r.s.State[\"tags\"])\n}", "func (o ListenerPtrOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Listener) map[string]string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Tags\n\t}).(pulumi.StringMapOutput)\n}", "func (t *Transaction) Tags() ([]Tag, error) {\n\ttags := []Tag{}\n\tfor _, tag := range t.tags {\n\t\t// access name\n\t\ttagName, err := utils.DecodeString(tag.Name)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttagValue, err := utils.DecodeString(tag.Value)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttags = append(tags, Tag{Name: string(tagName), Value: string(tagValue)})\n\t}\n\treturn tags, nil\n}", "func buildTags() string {\n\treturn *tags\n}", "func (o GetVolumeGroupSapHanaVolumeOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v GetVolumeGroupSapHanaVolume) map[string]string { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o LookupVirtualNetworkResultOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v LookupVirtualNetworkResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (r *Rule) Tags() pulumi.MapOutput {\n\treturn (pulumi.MapOutput)(r.s.State[\"tags\"])\n}", "func (lv *LogicalVolume) Tags() ([]string, error) {\n\tresult := new(lvsOutput)\n\tif err := run(\"lvs\", result, \"--options=lv_tags\", lv.vg.name+\"/\"+lv.name); err != nil {\n\t\tif IsLogicalVolumeNotFound(err) {\n\t\t\treturn nil, ErrLogicalVolumeNotFound\n\t\t}\n\t\treturn nil, err\n\t}\n\tfor _, report := range result.Report {\n\t\tfor _, lv := range report.Lv {\n\t\t\treturn lv.tagList(), nil\n\t\t}\n\t}\n\treturn nil, ErrLogicalVolumeNotFound\n}", "func (t ISILTagger) Tags(is finc.IntermediateSchema) []string {\n\tisils := container.NewStringSet()\n\tfor isil, filters := range t {\n\t\tfor _, f := range filters {\n\t\t\tif f.Apply(is) {\n\t\t\t\tisils.Add(isil)\n\t\t\t}\n\t\t}\n\t}\n\treturn isils.Values()\n}", "func (o ScheduledAuditOutput) Tags() ScheduledAuditTagArrayOutput {\n\treturn o.ApplyT(func(v *ScheduledAudit) ScheduledAuditTagArrayOutput { return v.Tags }).(ScheduledAuditTagArrayOutput)\n}", "func (o VirtualGatewayOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *VirtualGateway) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o AnalyzerOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Analyzer) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o AnalyzerOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Analyzer) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o DomainOutput) Tags() pulumi.MapOutput {\n\treturn o.ApplyT(func(v *Domain) pulumi.MapOutput { return v.Tags }).(pulumi.MapOutput)\n}", "func (o RepositoryOutput) Tags() RepositoryTagArrayOutput {\n\treturn o.ApplyT(func(v *Repository) RepositoryTagArrayOutput { return v.Tags }).(RepositoryTagArrayOutput)\n}", "func Tags(val []string) zap.Field {\n\treturn zap.Field{Key: FieldTags, Type: zapcore.SkipType, Interface: val}\n}", "func (sp *Space) GetTags() []string {\n\tif len(*sp) > 0 {\n\t\treturn (*sp)[0].GetTags()\n\t}\n\treturn []string{}\n}", "func (m *Application) GetTags()([]string) {\n return m.tags\n}", "func (o CachesIscsiVolumeOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *CachesIscsiVolume) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o StudioOutput) Tags() StudioTagArrayOutput {\n\treturn o.ApplyT(func(v *Studio) StudioTagArrayOutput { return v.Tags }).(StudioTagArrayOutput)\n}", "func (c Cross) GetTags() []string {\n\ttags := []string{\n\t\t\"full size\",\n\t\t\"ordinary\",\n\t}\n\treturn tags\n}", "func (o LookupDetectorModelResultOutput) Tags() DetectorModelTagArrayOutput {\n\treturn o.ApplyT(func(v LookupDetectorModelResult) []DetectorModelTag { return v.Tags }).(DetectorModelTagArrayOutput)\n}", "func (m FieldMap) Tags() []Tag {\n\ttags := make([]Tag, 0, len(m.tagLookup))\n\tfor t := range m.tagLookup {\n\t\ttags = append(tags, t)\n\t}\n\n\treturn tags\n}", "func (o OceanLaunchSpecOutput) Tags() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *OceanLaunchSpec) pulumi.StringArrayOutput { return v.Tags }).(pulumi.StringArrayOutput)\n}" ]
[ "0.6812187", "0.662246", "0.6557578", "0.64463", "0.64463", "0.6434869", "0.64187056", "0.64000773", "0.6397878", "0.63918966", "0.63906616", "0.63834083", "0.6358394", "0.6354617", "0.63435465", "0.63312256", "0.63297874", "0.6329586", "0.6325723", "0.6320472", "0.62952924", "0.6293875", "0.6293222", "0.6272951", "0.6271133", "0.6270027", "0.6269127", "0.6253629", "0.6244772", "0.62371594", "0.6236854", "0.62183976", "0.62020993", "0.61867434", "0.61806506", "0.6180196", "0.6169418", "0.61655384", "0.6152274", "0.6146125", "0.6131537", "0.6124739", "0.61236244", "0.6123234", "0.61150575", "0.6112322", "0.61103237", "0.6101857", "0.6093065", "0.6078722", "0.60779375", "0.6074663", "0.60710156", "0.60699964", "0.60699964", "0.6067895", "0.60611206", "0.6059571", "0.6058191", "0.605534", "0.6051761", "0.6038896", "0.6030711", "0.602959", "0.60249156", "0.6024602", "0.60242534", "0.6014877", "0.60137564", "0.60133964", "0.6009763", "0.60080194", "0.6004529", "0.5997459", "0.59934574", "0.5987844", "0.5981705", "0.5976986", "0.5975538", "0.5975033", "0.5962965", "0.59597707", "0.59523124", "0.59506935", "0.5946875", "0.59451735", "0.593869", "0.5933934", "0.5933934", "0.5933358", "0.59327567", "0.5931301", "0.5926761", "0.5923919", "0.5923057", "0.5922226", "0.5915596", "0.59138024", "0.59132314", "0.5907288" ]
0.63034225
20
Values returns values of struct
func Values(v interface{}) []interface{} { return New(v).Values() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (e *Extractor) Values() (out []interface{}, err error) {\n\n\tif err := e.isValidStruct(); err != nil {\n\t\treturn nil, err\n\t}\n\n\ts := reflect.ValueOf(e.StructAddr).Elem()\n\tfields := e.fields(s)\n\n\tfor _, field := range fields {\n\t\tout = append(out, field.value.Interface())\n\n\t}\n\n\treturn\n}", "func (s Struct) Value() []StructField {\n\treturn s.fields\n}", "func (m *Value) Values() []xmlrpc.Value { return m.ValuesMock() }", "func (s *Structx) Values() []interface{} {\n\tvar result []interface{}\n\n\tfs := s.Fields()\n\tfor _, v := range fs {\n\t\tif !v.IsExport() {\n\t\t\tcontinue\n\t\t}\n\t\tresult = append(result, v.Value())\n\t}\n\n\treturn result\n}", "func (c *Capture) Values() []interface{} {\n\tret := make([]interface{}, 8)\n\n\tret[0] = c.Timestamp\n\tret[1] = c.ColIP.String()\n\tret[2] = c.PeerIP.String()\n\tret[3] = pq.Array(c.ASPath)\n\tret[4] = c.NextHop.String()\n\tret[5] = c.Origin\n\n\tadvArr := util.PrefixesToPQArray(c.Advertised)\n\twdrArr := util.PrefixesToPQArray(c.Withdrawn)\n\tret[6] = advArr\n\tret[7] = wdrArr\n\n\treturn ret\n}", "func (pb *PageBuffer) Values() interface{} {\n offset := pb.pageOffset(pb.page_no)\n return pb.buffer.Slice(offset, offset + pb.idx).Interface()\n}", "func (c *AdapterMemory) Values(ctx context.Context) ([]interface{}, error) {\n\treturn c.data.Values()\n}", "func (s *Store) Values() []interface{} {\n\ts.access.RLock()\n\tdefer s.access.RUnlock()\n\n\tcpy := make([]interface{}, len(s.data))\n\ti := 0\n\tfor _, value := range s.data {\n\t\tcpy[i] = value\n\t\ti++\n\t}\n\treturn cpy\n}", "func (v *Version) Values(ctx context.Context) ([]byte, error) {\n\tlock := v.Chart.Space.SpaceManager.Lock.Get(v.Chart.Space.Name(), v.Chart.Name(), v.Number())\n\tif !lock.RLock(v.Chart.Space.SpaceManager.LockTimeout) {\n\t\treturn nil, ErrorLocking.Format(\"version\", v.Chart.Space.Name()+\"/\"+v.Chart.Name()+\"/\"+v.Number())\n\t}\n\tdefer lock.RUnlock()\n\tif err := v.Validate(ctx); err != nil {\n\t\treturn nil, err\n\t}\n\tpath := path.Join(v.Prefix, valuesName)\n\tdata, err := v.Backend.GetContent(ctx, path)\n\tif err != nil {\n\t\treturn nil, ErrorContentNotFound.Format(v.Prefix)\n\t}\n\treturn data, nil\n}", "func (e *Entity) Values() []interface{} {\n\tpqPrefs := util.PrefixesToPQArray(e.OwnedPrefixes)\n\tvals := make([]interface{}, 4)\n\tvals[0] = util.SanitizeDBString(e.Name)\n\tvals[1] = util.SanitizeDBString(e.Email)\n\tvals[2] = pq.Array(e.OwnedOrigins)\n\tvals[3] = pqPrefs\n\n\treturn vals\n}", "func (b *Buffer) Values() interface{} {\n return b.buffer.Slice(0, b.idx).Interface()\n}", "func (page MemberCollectionPage) Values() []Member {\n\tif page.mc.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.mc.Value\n}", "func (t Tuple) Values() []float64 {\n\treturn t\n}", "func (_TellorMesosphere *TellorMesosphereCaller) Values(opts *bind.CallOpts, arg0 *big.Int, arg1 *big.Int) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _TellorMesosphere.contract.Call(opts, &out, \"values\", arg0, arg1)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (lst List) Value() []Value {\n\treturn lst.values\n}", "func (nData *NaiveData) Value() []gotypes.Value {\n\treturn nData.Val\n}", "func (g *GrowingBuffer) Values() interface{} {\n return g.bufferPtr.Elem().Interface()\n}", "func (_SimpleStorage *SimpleStorageCallerSession) GetValues() (struct {\n\tIntValue *big.Int\n\tStringValue string\n}, error) {\n\treturn _SimpleStorage.Contract.GetValues(&_SimpleStorage.CallOpts)\n}", "func (page ListResultPage) Values() []Model {\n\tif page.lr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.lr.Value\n}", "func (f *observable) Value() map[string]interface{} {\n\ttoReturn := map[string]interface{}{}\n\tfor k, v := range f.ObsFields {\n\t\ttoReturn[k] = v\n\t}\n\treturn toReturn\n}", "func (t *Tags) Values() map[string]interface{} {\n\treturn t.values\n}", "func (o FleetMetricAggregationTypePtrOutput) Values() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *FleetMetricAggregationType) []string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Values\n\t}).(pulumi.StringArrayOutput)\n}", "func (InstanceGeneration) Values() []InstanceGeneration {\n\treturn []InstanceGeneration{\n\t\t\"current\",\n\t\t\"previous\",\n\t}\n}", "func (page ProviderOperationsMetadataListResultPage) Values() []ProviderOperationsMetadata {\n\tif page.pomlr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.pomlr.Value\n}", "func (it *Iter) Values() (uint32, float64) {\n\treturn it.T, it.Val\n}", "func (s SExp) Value() []Value {\n\treturn s.values\n}", "func (page VaultListResultPage) Values() []Vault {\n\tif page.vlr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.vlr.Value\n}", "func (rec Record) Values() []string {\n\trow := make([]string, numExported(rec.t))\n\tvar k int\n\tfor i := 0; i < rec.t.NumField(); i++ {\n\t\tif isExported(rec.t.Field(i)) {\n\t\t\trow[k] = fmt.Sprint(rec.v.Field(i))\n\t\t\tk++\n\t\t}\n\t}\n\treturn row\n}", "func (_SimpleStorage *SimpleStorageSession) GetValues() (struct {\n\tIntValue *big.Int\n\tStringValue string\n}, error) {\n\treturn _SimpleStorage.Contract.GetValues(&_SimpleStorage.CallOpts)\n}", "func (c *Cache) Values() ([]interface{}, error) {\n\treturn c.adapter.Values(c.getCtx())\n}", "func (page SasTokenInformationListResultPage) Values() []SasTokenInformation {\n\tif page.stilr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.stilr.Value\n}", "func (RecordWrapper) Values() []RecordWrapper {\n\treturn []RecordWrapper{\n\t\t\"None\",\n\t\t\"RecordIO\",\n\t}\n}", "func (v *Value) Data() interface{} {\n return v.data\n}", "func (m *Mutate) Values() map[string]map[string][]byte {\n\treturn m.values\n}", "func (_SimpleStorage *SimpleStorageCaller) GetValues(opts *bind.CallOpts) (struct {\n\tIntValue *big.Int\n\tStringValue string\n}, error) {\n\tret := new(struct {\n\t\tIntValue *big.Int\n\t\tStringValue string\n\t})\n\tout := ret\n\terr := _SimpleStorage.contract.Call(opts, out, \"getValues\")\n\treturn *ret, err\n}", "func (c *Scratch) Values() map[string]any {\n\tc.mu.RLock()\n\tdefer c.mu.RUnlock()\n\treturn c.values\n}", "func (f *FieldsWithValue) Values() []string {\n\tvalues := make([]string, len(f.fields))\n\tfor i := range f.fields {\n\t\tvalues[i] = f.fields[i].Value\n\t}\n\treturn values\n}", "func (page StorageAccountInformationListResultPage) Values() []StorageAccountInformation {\n\tif page.sailr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.sailr.Value\n}", "func (entry LogEntry) GetValues() []interface{} {\n\treturn entry.valueList\n}", "func Values(live bool) Model {\n\t// prepare model\n\tmodel := Auto(&glut.Model{}, \"value\", \"Value\", \"Values\", nil)\n\tmodel.Watchable = live\n\tmodel.Immediate = live\n\tmodel.Creatable = false\n\n\treturn model\n}", "func (tree *Tree) Values() []interface{} {\n\tvalues := make([]interface{}, tree.size)\n\tit := tree.Iterator()\n\tfor i := 0; it.Next(); i++ {\n\t\tvalues[i] = it.Value()\n\t}\n\treturn values\n}", "func (TrafficMirrorSessionField) Values() []TrafficMirrorSessionField {\n\treturn []TrafficMirrorSessionField{\n\t\t\"packet-length\",\n\t\t\"description\",\n\t\t\"virtual-network-id\",\n\t}\n}", "func (q *PriorityQueue) Values() []interface{} {\n\tsize := q.data.Size()\n\tvalues := q.data.Values()\n\tres := make([]interface{}, size)\n\tfor i := 0; i < size; i++ {\n\t\tres[i] = values[i].(*pqItem).value\n\t}\n\treturn res\n}", "func (p Packet) Values() ([]Value) {\n\tvalues := make([]Value, len(p.DataTypes))\n\tfor i := range values {\n\t\tvalues[i] = Value{p.DataTypes[i], p.Bytes[i*8 : 8+(i*8)] }\n\t}\n\treturn values\n}", "func (page ListPage) Values() []Response {\n\tif page.l.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.l.Value\n}", "func (t Tags) Values() []Tag {\n\treturn t.values\n}", "func (p Profile) Values() map[*structs.Field][]interface{} {\n\tvar v = make(map[*structs.Field][]interface{})\n\tfor i, f := range structs.Fields(p.First()) {\n\t\tfor _, a := range p.FieldPerms {\n\t\t\tv[f] = append(v[f], structs.Values(a)[i])\n\t\t}\n\t}\n\treturn v\n}", "func (page UsageAggregationListResultPage) Values() []UsageAggregation {\n\tif page.ualr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.ualr.Value\n}", "func Struct(v interface{}) (values CMap) {\n\tvalues = New()\n\tiVal := reflect.ValueOf(v)\n\tif iVal.Kind() == reflect.Ptr {\n\t\tiVal = iVal.Elem()\n\t}\n\ttyp := iVal.Type()\n\tfor i := 0; i < iVal.NumField(); i++ {\n\t\tfi := typ.Field(i)\n\t\tname := fi.Tag.Get(\"json\")\n\t\tif name == \"\" {\n\t\t\tname = fi.Name\n\t\t}\n\t\t// add support slice\n\t\tif iVal.Field(i).Kind() == reflect.Slice {\n\t\t\tvar buf bytes.Buffer\n\t\t\tbuf.WriteString(\"[\")\n\t\t\tiValArr := iVal.Field(i)\n\t\t\tfor j := 0; j < iValArr.Len(); j++ {\n\t\t\t\tbuf.WriteString(fmt.Sprint(`\"`, iValArr.Index(j), `\",`))\n\t\t\t}\n\t\t\tval := string(buf.Bytes()[:buf.Len()-1])\n\t\t\tval += \"]\"\n\t\t\tvalues.Set(name, val)\n\t\t\tcontinue\n\t\t}\n\t\tvalues.Set(name, fmt.Sprint(iVal.Field(i)))\n\t}\n\treturn\n}", "func (list *List) Values() []interface{} {\n\tvalues := make([]interface{}, list.size, list.size)\n\tfor e, element := 0, list.first; element != nil; e, element = e+1, element.next {\n\t\tvalues[e] = element.value\n\t}\n\treturn values\n}", "func (page AvailableSkusResultPage) Values() []SkuInformation {\n\tif page.asr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.asr.Value\n}", "func (o *Object) Value() interface{} { return o }", "func (it *Iterator) Value() interface{} { return it.n.v }", "func (it *Iterator) Value() interface{} { return it.n.v }", "func (page PrivateCloudListPage) Values() []PrivateCloud {\n\tif page.pcl.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.pcl.Value\n}", "func structVals(v reflect.Value, cols []string) []interface{} {\n\tvar vals []interface{}\n\tfor idx := range cols {\n\t\tif idx >= v.NumField() {\n\t\t\tbreak\n\t\t}\n\n\t\tval := v.Field(idx)\n\t\tif val.Kind() != reflect.Ptr {\n\t\t\tval = val.Addr()\n\t\t}\n\n\t\tvals = append(vals, val.Interface())\n\t}\n\treturn vals\n}", "func (i Information) Values() map[string]string {\n\treturn map[string]string{\n\t\t\"version\": i.Version,\n\t\t\"revision\": i.Revision,\n\t\t\"branch\": i.Branch,\n\t\t\"build_user\": i.BuildUser,\n\t\t\"build_date\": i.BuildDate,\n\t\t\"go_version\": i.GoVersion,\n\t}\n}", "func Values(mp any) (values []any) {\n\trv := reflect.Indirect(reflect.ValueOf(mp))\n\tif rv.Kind() != reflect.Map {\n\t\treturn\n\t}\n\n\tvalues = make([]any, 0, rv.Len())\n\tfor _, key := range rv.MapKeys() {\n\t\tvalues = append(values, rv.MapIndex(key).Interface())\n\t}\n\treturn\n}", "func (f *Filter) Values() Values {\n\treturn f.values\n}", "func (p Properties) Values() []interface{} {\n\tvalues := make([]interface{}, len(p))\n\tfor i, v := range p {\n\t\tvalues[i] = v.InterValue\n\t}\n\treturn values\n}", "func (page StorageInsightListResultPage) Values() []StorageInsight {\n\tif page.silr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.silr.Value\n}", "func (page StorageInsightListResultPage) Values() []StorageInsight {\n\tif page.silr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.silr.Value\n}", "func (l UpdateLabels) Values() []string {\n\treturn []string{l.Type, l.Result}\n}", "func (page DatabaseListResultPage) Values() []Database {\n if page.dlr.IsEmpty() {\n return nil\n }\n return *page.dlr.Value\n }", "func (s *GoObject) Value() interface{} {\n\treturn s.data\n}", "func getValues(l layer) []float64 {\n\tinputs := make([]float64, len(l))\n\tfor i := range l {\n\t\tinputs[i] = l[i].value\n\t}\n\treturn inputs\n}", "func (o RegistryTaskEncodedStepPtrOutput) Values() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *RegistryTaskEncodedStep) map[string]string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Values\n\t}).(pulumi.StringMapOutput)\n}", "func (page ProductResultValuePage) Values() []Product {\n\tif page.prv.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.prv.Value\n}", "func (b *Uniform) Values() []float64 {\n\treturn b.values\n}", "func (list *ArrayList) Values() []interface{} {\n\tnewE := make([]interface{}, list.size, list.size)\n\tcopy(newE, list.elements[:list.size])\n\treturn newE\n}", "func (e *Enum) Values() []interface{} {\n\treturn e.values\n}", "func (page DefinitionListResultPage) Values() []Definition {\n\tif page.dlr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.dlr.Value\n}", "func (this *record) Value() interface{} {\n\tswitch this._Type {\n\tcase sensors.OT_DATATYPE_UDEC_0:\n\t\tif value, err := this.UintValue(); err != nil {\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn value\n\t\t}\n\tcase sensors.OT_DATATYPE_UDEC_4, sensors.OT_DATATYPE_UDEC_8, sensors.OT_DATATYPE_UDEC_12, sensors.OT_DATATYPE_UDEC_16, sensors.OT_DATATYPE_UDEC_20, sensors.OT_DATATYPE_UDEC_24:\n\t\tif value, err := this.FloatValue(); err != nil {\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn value\n\t\t}\n\tcase sensors.OT_DATATYPE_STRING:\n\t\tif value, err := this.StringValue(); err != nil {\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn value\n\t\t}\n\tcase sensors.OT_DATATYPE_DEC_0:\n\t\tif value, err := this.IntValue(); err != nil {\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn value\n\t\t}\n\tcase sensors.OT_DATATYPE_DEC_8, sensors.OT_DATATYPE_DEC_16, sensors.OT_DATATYPE_DEC_24:\n\t\tif value, err := this.FloatValue(); err != nil {\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn value\n\t\t}\n\tdefault:\n\t\tif value, err := this.Data(); err != nil {\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn value\n\t\t}\n\t}\n}", "func (s *SequenceItemValue) GetValue() interface{} { return s.elements }", "func (a UserGroupAggregateRow) Values() m.UserData {\n\treturn a.values\n}", "func (rows *Rows) Values() ([]interface{}, error) {\n\tif rows.closed {\n\t\treturn nil, errors.New(\"rows is closed\")\n\t}\n\n\tvalues := make([]interface{}, 0, len(rows.fields))\n\n\tfor range rows.fields {\n\t\tvr, _ := rows.nextColumn()\n\n\t\tif vr.Len() == -1 {\n\t\t\tvalues = append(values, nil)\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch vr.Type().FormatCode {\n\t\t// All intrinsic types (except string) are encoded with binary\n\t\t// encoding so anything else should be treated as a string\n\t\tcase TextFormatCode:\n\t\t\tvalues = append(values, vr.ReadString(vr.Len()))\n\t\tcase BinaryFormatCode:\n\t\t\tswitch vr.Type().DataType {\n\t\t\tcase TextOid, VarcharOid:\n\t\t\t\tvalues = append(values, decodeText(vr))\n\t\t\tcase BoolOid:\n\t\t\t\tvalues = append(values, decodeBool(vr))\n\t\t\tcase ByteaOid:\n\t\t\t\tvalues = append(values, decodeBytea(vr))\n\t\t\tcase Int8Oid:\n\t\t\t\tvalues = append(values, decodeInt8(vr))\n\t\t\tcase Int2Oid:\n\t\t\t\tvalues = append(values, decodeInt2(vr))\n\t\t\tcase Int4Oid:\n\t\t\t\tvalues = append(values, decodeInt4(vr))\n\t\t\tcase OidOid:\n\t\t\t\tvalues = append(values, decodeOid(vr))\n\t\t\tcase Float4Oid:\n\t\t\t\tvalues = append(values, decodeFloat4(vr))\n\t\t\tcase Float8Oid:\n\t\t\t\tvalues = append(values, decodeFloat8(vr))\n\t\t\tcase BoolArrayOid:\n\t\t\t\tvalues = append(values, decodeBoolArray(vr))\n\t\t\tcase Int2ArrayOid:\n\t\t\t\tvalues = append(values, decodeInt2Array(vr))\n\t\t\tcase Int4ArrayOid:\n\t\t\t\tvalues = append(values, decodeInt4Array(vr))\n\t\t\tcase Int8ArrayOid:\n\t\t\t\tvalues = append(values, decodeInt8Array(vr))\n\t\t\tcase Float4ArrayOid:\n\t\t\t\tvalues = append(values, decodeFloat4Array(vr))\n\t\t\tcase Float8ArrayOid:\n\t\t\t\tvalues = append(values, decodeFloat8Array(vr))\n\t\t\tcase TextArrayOid, VarcharArrayOid:\n\t\t\t\tvalues = append(values, decodeTextArray(vr))\n\t\t\tcase TimestampArrayOid, TimestampTzArrayOid:\n\t\t\t\tvalues = append(values, decodeTimestampArray(vr))\n\t\t\tcase DateOid:\n\t\t\t\tvalues = append(values, decodeDate(vr))\n\t\t\tcase TimestampTzOid:\n\t\t\t\tvalues = append(values, decodeTimestampTz(vr))\n\t\t\tcase TimestampOid:\n\t\t\t\tvalues = append(values, decodeTimestamp(vr))\n\t\t\tcase InetOid, CidrOid:\n\t\t\t\tvalues = append(values, decodeInet(vr))\n\t\t\tcase JsonOid:\n\t\t\t\tvar d interface{}\n\t\t\t\tdecodeJSON(vr, &d)\n\t\t\t\tvalues = append(values, d)\n\t\t\tcase JsonbOid:\n\t\t\t\tvar d interface{}\n\t\t\t\tdecodeJSON(vr, &d)\n\t\t\t\tvalues = append(values, d)\n\t\t\tdefault:\n\t\t\t\trows.Fatal(errors.New(\"Values cannot handle binary format non-intrinsic types\"))\n\t\t\t}\n\t\tdefault:\n\t\t\trows.Fatal(errors.New(\"Unknown format code\"))\n\t\t}\n\n\t\tif vr.Err() != nil {\n\t\t\trows.Fatal(vr.Err())\n\t\t}\n\n\t\tif rows.Err() != nil {\n\t\t\treturn nil, rows.Err()\n\t\t}\n\t}\n\n\treturn values, rows.Err()\n}", "func (q *ColumnQueryAPI) Values(ctx context.Context, req *pb.ValuesRequest) (*pb.ValuesResponse, error) {\n\tvals, err := q.querier.Values(ctx, req.LabelName, req.Match, req.Start.AsTime(), req.End.AsTime())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &pb.ValuesResponse{\n\t\tLabelValues: vals,\n\t}, nil\n}", "func Values(i interface{}) ([]interface{}) {\n\tvar result []interface{}\n\tv := reflect.ValueOf(i)\n\n\tif v.Kind() != reflect.Map {\n\t\tfmt.Fprintf(os.Stderr, \"Input type is not a map type: %v\", v)\n\t\treturn nil\n\t}\n\n\tfor _,key := range (v.MapKeys()) {\n\t\tresult = append(result, v.MapIndex(key).Interface())\n\t}\n\n\treturn result\n}", "func FieldsAndValues(val interface{}) ([]string, []interface{}, bool) {\n\t// indirect so function works with both structs and pointers to them\n\tstructVal := r.Indirect(r.ValueOf(val))\n\tkind := structVal.Kind()\n\tif kind != r.Struct {\n\t\treturn nil, nil, false\n\t}\n\tsinfo := getStructInfo(structVal)\n\tfields := make([]string, len(sinfo.FieldsList))\n\tvalues := make([]interface{}, len(sinfo.FieldsList))\n\tfor i, info := range sinfo.FieldsList {\n\t\tfield := structVal.Field(info.Num)\n\t\tfields[i] = info.Key\n\t\tvalues[i] = field.Interface()\n\t}\n\treturn fields, values, true\n}", "func (page PeerAsnListResultPage) Values() []PeerAsn {\n\tif page.palr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.palr.Value\n}", "func (page ServiceProviderListResultPage) Values() []ServiceProvider {\n\tif page.splr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.splr.Value\n}", "func (page ConsortiumMemberCollectionPage) Values() []ConsortiumMember {\n\tif page.cmc.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.cmc.Value\n}", "func (value *Value) Value() interface{} {\n\treturn value.value\n}", "func (v Vector) Values() []float64 {\n\treturn v\n}", "func (d data) getPropertyValues(name string, index int, fieldname string) ([]string, error) {\n\tv := reflect.ValueOf(d.src).Elem().FieldByName(name)\n\tvar valueStruct reflect.Value\n\tswitch v.Kind() {\n\tcase reflect.Slice:\n\t\tif index < 0 || index >= v.Len() {\n\t\t\treturn nil, fmt.Errorf(\"%s[%d]: index out of range\", name, index)\n\t\t}\n\t\tvalueStruct = v.Index(index)\n\tcase reflect.Struct:\n\t\tvalueStruct = v\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown primary field type: %v\", v.Kind())\n\t}\n\n\ttoString := func(element reflect.Value) string {\n\t\tvar s string\n\t\tstringType := reflect.TypeOf(s)\n\t\t_, isStringer := element.Type().MethodByName(\"String\")\n\t\tif element.Kind() == reflect.Bool {\n\t\t\treturn strconv.FormatBool(element.Bool())\n\t\t} else if element.Kind() == reflect.Int {\n\t\t\treturn strconv.FormatInt(element.Int(), 10)\n\t\t} else if element.Kind() == reflect.Float64 {\n\t\t\treturn strconv.FormatFloat(element.Float(), 'g', -1, 64)\n\t\t} else if isStringer {\n\t\t\t// This panics, if the String method takes input arguments, or returns anything else than a single string.\n\t\t\tstringValues := element.MethodByName(\"String\").Call(nil)\n\t\t\treturn stringValues[0].String()\n\t\t}\n\t\tif element.Type().ConvertibleTo(stringType) {\n\t\t\ts = element.Convert(stringType).Interface().(string)\n\t\t\treturn s\n\t\t}\n\t\treturn \"<?>\"\n\t}\n\n\tvar values []string\n\tvar zero reflect.Value\n\tfield := valueStruct.FieldByName(fieldname)\n\tif field == zero {\n\t\treturn nil, fmt.Errorf(\"%s.%s: field does not exist\", name, fieldname)\n\t}\n\tif field.Kind() == reflect.Slice {\n\t\tvalues = make([]string, field.Len())\n\t\tfor i := range values {\n\t\t\tvalues[i] = toString(field.Index(i))\n\t\t}\n\t} else {\n\t\tvalues = []string{toString(field)}\n\t}\n\treturn values, nil\n}", "func (l RegistrationLabels) Values() []string {\n\treturn []string{l.Result, l.Type.String(), l.Src.String()}\n}", "func (page DataLakeAnalyticsAccountListResultPage) Values() []DataLakeAnalyticsAccountBasic {\n\tif page.dlaalr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.dlaalr.Value\n}", "func (page AccountsPage) Values() []Account {\n\tif page.a.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.a.Value\n}", "func (d *adapterMemoryData) Values() ([]interface{}, error) {\n\td.mu.RLock()\n\tvar (\n\t\tindex = 0\n\t\tvalues = make([]interface{}, len(d.data))\n\t)\n\tfor _, v := range d.data {\n\t\tif !v.IsExpired() {\n\t\t\tvalues[index] = v.v\n\t\t\tindex++\n\t\t}\n\t}\n\td.mu.RUnlock()\n\treturn values, nil\n}", "func (o RegistryTaskEncodedStepOutput) Values() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v RegistryTaskEncodedStep) map[string]string { return v.Values }).(pulumi.StringMapOutput)\n}", "func (p Point) Values() []float64 {\n\treturn p\n}", "func (p *VCardProperty) Values() []string {\n\tstrings := make([]string, 0, 1)\n\n\tp.appendValueStrings(p.Value, &strings, 0)\n\n\treturn strings\n}", "func (p *PKGBUILD) GetValues() map[string]string {\n\treturn p.info.GetValues()\n}", "func (m *MultiMap) Values() []interface{} {\n\tvalues := make([]interface{}, m.Size())\n\tcount := 0\n\tfor _, vs := range m.m {\n\t\tfor _, value := range vs {\n\t\t\tvalues[count] = value\n\t\t\tcount++\n\t\t}\n\t}\n\treturn values\n}", "func Valueize(values ...reflect.Value) []reflect.Value {\n\treturn values\n}", "func (o *InlineObject794) GetValues() AnyOfobject {\n\tif o == nil || o.Values == nil {\n\t\tvar ret AnyOfobject\n\t\treturn ret\n\t}\n\treturn *o.Values\n}", "func (ps *peerStore) Values(infoHash InfoHash) []net.UDPAddr {\n\tset := ps.Set(infoHash)\n\tif set == nil {\n\t\treturn nil\n\t}\n\n\treturn set.Next()\n}", "func (o ApiOperationRequestRepresentationFormParameterOutput) Values() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v ApiOperationRequestRepresentationFormParameter) []string { return v.Values }).(pulumi.StringArrayOutput)\n}", "func (_TellorMesosphere *TellorMesosphereSession) Values(arg0 *big.Int, arg1 *big.Int) (*big.Int, error) {\n\treturn _TellorMesosphere.Contract.Values(&_TellorMesosphere.CallOpts, arg0, arg1)\n}", "func (page RegisteredAsnListResultPage) Values() []RegisteredAsn {\n\tif page.ralr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.ralr.Value\n}" ]
[ "0.749085", "0.7193369", "0.70431256", "0.7038614", "0.6553561", "0.6546634", "0.6514496", "0.6409118", "0.6362563", "0.6319657", "0.6272307", "0.62592447", "0.6233262", "0.6200429", "0.61777216", "0.6162476", "0.615272", "0.61421496", "0.6131156", "0.61253464", "0.6119984", "0.60929567", "0.6087474", "0.60855603", "0.6081215", "0.6078335", "0.6071396", "0.60385567", "0.6032541", "0.60316736", "0.60242385", "0.60202354", "0.6011651", "0.60097116", "0.6007157", "0.59963894", "0.59935945", "0.5984117", "0.598346", "0.5967576", "0.59656066", "0.59630847", "0.5960114", "0.59585196", "0.595637", "0.59449166", "0.59427243", "0.59359753", "0.5927966", "0.5915933", "0.59159154", "0.5910997", "0.5910469", "0.5910469", "0.59076756", "0.5907574", "0.58990115", "0.5897618", "0.58943653", "0.5879604", "0.58795106", "0.58795106", "0.58743197", "0.5871471", "0.58650976", "0.5858465", "0.5858264", "0.58575326", "0.5855975", "0.5848261", "0.58441794", "0.5841845", "0.5840151", "0.58385885", "0.5832451", "0.5824317", "0.5819769", "0.58187777", "0.58140534", "0.5811576", "0.58099544", "0.58018196", "0.58018136", "0.5801699", "0.5799609", "0.57958513", "0.5794724", "0.5786098", "0.57857764", "0.57852906", "0.5785126", "0.5780899", "0.57790625", "0.5777796", "0.577477", "0.5770592", "0.57698137", "0.5769177", "0.57688797", "0.576725" ]
0.6132722
18
Fields return fields of struct
func Fields(v interface{}) []*Fieldx { return New(v).Fields() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (g *generator) structFields(t reflect.Type) []field {\n\tvar fields []field\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tf := t.Field(i)\n\t\tif g.ignoreField(t, f) {\n\t\t\tcontinue\n\t\t}\n\t\tname, _ := parseTag(g.fieldTagKey, f.Tag)\n\t\tif name == \"\" {\n\t\t\tname = f.Name\n\t\t}\n\t\tfields = append(fields, field{\n\t\t\tName: name,\n\t\t\tType: f.Type,\n\t\t\tZero: zeroValue(f.Type),\n\t\t})\n\t}\n\treturn fields\n}", "func (_struct *Struct) Fields() (Fields, error) {\n\tvar goFields Fields\n\tstructType := _struct.StructType()\n\tif structType == nil {\n\t\treturn nil, fmt.Errorf(\"no struct type in %#+v\", _struct)\n\t}\n\tfor idx, field := range structType.Fields.List {\n\t\ttyp, err := _struct.toType(field.Type)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to lookup type '%s': %w\", field.Type, err)\n\t\t}\n\t\tgoFields = append(goFields, &Field{\n\t\t\tField: *field,\n\t\t\tStruct: _struct,\n\t\t\tNames: field.Names,\n\t\t\tIndex: uint(idx),\n\t\t\tTypeValue: typ,\n\t\t})\n\t}\n\treturn goFields, nil\n}", "func StructFields(t reflect.Type) interface{} {\n\treturn structInfoForType(t).fields\n}", "func (s *Struct) Fields() map[string]string {\n\tff := map[string]string{}\n\n\tfor _, f := range s.RawFields() {\n\t\tff[f.Field.Name] = f.Typ.String()\n\t}\n\n\treturn ff\n}", "func StructFields(v interface{}) (vType reflect.Type, vFields []*TField) {\n\tvar (\n\t\tfield reflect.StructField\n\t)\n\tvType = reflect.Indirect(reflect.ValueOf(v)).Type()\n\tnumFields := vType.NumField()\n\tvFields = make([]*TField, 0, numFields)\n\tfor i := 0; i < numFields; i++ {\n\t\tfield = vType.Field(i)\n\t\tfieldInfo := &TField{\n\t\t\tFname: field.Name,\n\t\t\tFtype: field.Type.String(),\n\t\t\tFkind: field.Type.Kind(),\n\t\t\tFtags: field.Tag,\n\t\t}\n\t\tif field.PkgPath == \"\" {\n\t\t\tfieldInfo.Fexported = true\n\t\t}\n\t\tvFields = append(vFields, fieldInfo)\n\t}\n\treturn\n}", "func fields(spec *ast.TypeSpec) []*ast.Field {\n\ts := make([]*ast.Field, 0)\n\tif structType, ok := spec.Type.(*ast.StructType); ok {\n\t\tfor _, field := range structType.Fields.List {\n\t\t\tif keyname(field) != \"\" {\n\t\t\t\ts = append(s, field)\n\t\t\t}\n\t\t}\n\t}\n\treturn s\n}", "func (ds *DynamicStruct) Fields() []reflect.StructField {\n\treturn ds.fields\n}", "func StructFields() {\n\tv := vertex{1, 2}\n\tv.X = 11\n\n\tfmt.Println(v.X, v.Y)\n}", "func (s *Struct) structFields() []reflect.StructField {\n\tt := s.value.Type()\n\n\tvar f []reflect.StructField\n\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfield := t.Field(i)\n\t\t// we can't access the value of unexported fields\n\t\tif field.PkgPath != \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\t// don't check if it's omitted\n\t\tif tag := field.Tag.Get(s.TagName); tag == \"-\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tf = append(f, field)\n\t}\n\n\treturn f\n}", "func (e *Extractor) fields(s reflect.Value) []field {\n\tfields := make([]field, 0, s.NumField())\n\n\tfor i := 0; i < s.NumField(); i++ {\n\t\tif isIgnored(s.Type().Field(i).Name, e.ignoredFields) {\n\t\t\tcontinue\n\t\t}\n\n\t\tif s.Type().Field(i).Anonymous {\n\t\t\tif e.useEmbeddedStructs {\n\t\t\t\tfields = append(fields, e.fields(s.Field(i))...)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\ttag := s.Type().Field(i).Tag\n\t\tname := s.Type().Field(i).Name\n\t\tvalue := s.Field(i)\n\t\tfields = append(fields, field{value, name, tag})\n\t}\n\n\treturn fields\n}", "func (s *scanner) structFields(structType reflect.Type) ([]*r.Field, error) {\n\tfmPtr := reflect.New(structType).Interface()\n\tm, err := r.StructFieldMap(fmPtr, true)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not decode struct of type %T: %v\", fmPtr, err)\n\t}\n\n\tstructFields := make([]*r.Field, len(s.stmt.fieldNames))\n\tfor i, fieldName := range s.stmt.fieldNames {\n\t\tfield, ok := m[strings.ToLower(fieldName)]\n\t\tif !ok { // the field doesn't have a destination\n\t\t\tstructFields[i] = nil\n\t\t} else {\n\t\t\tstructFields[i] = &field\n\t\t}\n\t}\n\treturn structFields, nil\n}", "func (e TypeReflectCacheEntry) Fields() map[string]*FieldCacheEntry {\n\treturn e.structFields\n}", "func (f Fields) Fields() map[string]interface{} {\n\treturn f\n}", "func printStructField(t *reflect.Type) {\n fieldNum := (*t).NumField()\n for i := 0; i < fieldNum; i++ {\n fmt.Printf(\"conf's field: %s\\n\", (*t).Field(i).Name)\n }\n fmt.Println(\"\")\n}", "func (sh *Hook) Fields() map[string]interface{} {\n\treturn sh.fields\n}", "func StructFields(t reflect.Type) string {\n\tfields := make([]string, 0)\n\tif t.Kind() == reflect.Struct {\n\t\tfor i := 0; i < t.NumField(); i ++ {\n\t\t\tname := t.Field(i).Name\n\t\t\tif t.Field(i).Type.Kind() == reflect.Struct {\n\t\t\t\ts := StructFields(t.Field(i).Type)\n\t\t\t\tf := strings.Split(s, \", \")\n\t\t\t\tleft := FirstLower(name)\n\t\t\t\tfor _, v := range f {\n\t\t\t\t\tfields = append(fields, fmt.Sprintf(\"%s.%s\", left, FirstLower(v)))\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfields = append(fields, FirstLower(name))\n\t\t}\n\t}\n\n\treturn strings.Join(fields, \", \")\n}", "func (entry *Entry) Fields() Fields {\n\treturn entry.fields\n}", "func (self *mergeState) getFields() []string {\n\tfields := make([]string, len(self.fields))\n\tfor f, i := range self.fields {\n\t\tfields[i] = f\n\t}\n\treturn fields\n}", "func (s *Syncthing) Fields() log.Fields {\n\treturn debug.StructFields(s)\n}", "func GetFields(reader *os.File) []Field {\n\tvar curbuf []byte\n\tdbfhead := GetDbfHead(reader)\n\n\toff := dbfhead.Headerlen - 32 - 264\n\tif off < 1 {\n\t\tpanic(\"invalid header\")\n\t}\n\tfieldlist := make([]Field, off/32)\n\tbuf := make([]byte, off)\n\t_, err := reader.ReadAt(buf, 32)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfor i, val := range fieldlist {\n\t\ta := i * 32\n\t\tcurbuf = buf[a:]\n\t\tval.Name = copyUpToNull(curbuf[0:11])\n\t\tval.Fieldtype = fmt.Sprintf(\"%s\", curbuf[11:12])\n\t\tval.FieldDataaddress = curbuf[12:16]\n\t\tval.FieldLen = Changebytetoint(curbuf[16:17])\n\t\tval.DecimalCount = curbuf[17:18]\n\t\tval.Workareaid = curbuf[20:21]\n\t\tfieldlist[i] = val\n\t}\n\treturn fieldlist\n}", "func (s *Spec) Fields() log.Fields {\n\treturn s.Details.Fields()\n}", "func (game *Game) Fields() Fields {\n\treturn game.currentFields\n}", "func getFields(s interface{}) []interface{} {\n\tv := reflect.ValueOf(s)\n\tv = dereference(v)\n\tfields := []interface{}{}\n\tfor i := 0; i < v.NumField(); i++ {\n\t\tfield := v.Field(i)\n\t\tif field.CanInterface() {\n\t\t\tfields = append(fields, field.Interface())\n\t\t}\n\t}\n\treturn fields\n}", "func (u User) Fields() map[string]interface{} {\n\tfields := map[string]interface{}{\n\t\t\"hash\": u.Hash,\n\t\t\"email\": u.Email,\n\t\t\"private_id\": u.PrivateID,\n\t\t\"public_id\": u.PublicID,\n\t}\n\n\tif u.Profile != nil {\n\t\tfields[\"profile\"] = u.Profile.Fields()\n\t}\n\n\treturn fields\n}", "func (pce *ppdCacheEntry) getFields() (cdd.PrinterDescriptionSection, string, string, lib.DuplexVendorMap) {\n\tpce.mutex.Lock()\n\tdefer pce.mutex.Unlock()\n\treturn pce.description, pce.manufacturer, pce.model, pce.duplexMap\n}", "func (r *Route) Fields() RouteInfo {\n\tr.mu.RLock()\n\tdefer r.mu.RUnlock()\n\treturn r.fieldsLocked()\n}", "func (i PullAll) Fields() []interface{} {\n\treturn nil\n}", "func (d Document) Fields() []string {\n\treturn d.data.fields\n}", "func (Card) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.Int64(\"id\"),\n\t\tfield.String(\"name\"),\n\t\tfield.String(\"card_no\"),\n\t\tfield.String(\"ccv\"),\n\t\tfield.String(\"expires\"),\n\t\tfield.Time(\"created_at\").\n\t\t\tDefault(time.Now).SchemaType(map[string]string{\n\t\t\tdialect.MySQL: \"datetime\",\n\t\t}),\n\t\tfield.Time(\"updated_at\").\n\t\t\tDefault(time.Now).SchemaType(map[string]string{\n\t\t\tdialect.MySQL: \"datetime\",\n\t\t}),\n\t}\n}", "func (n *Node) Fields() []uintptr {\n\t// we store the offsets for the fields in type properties\n\ttprops := kit.Types.Properties(n.Type(), true) // true = makeNew\n\tpnm := \"__FieldOffs\"\n\tif foff, ok := tprops[pnm]; ok {\n\t\treturn foff.([]uintptr)\n\t}\n\tfoff := make([]uintptr, 0)\n\tkitype := KiType()\n\tFlatFieldsValueFunc(n.This, func(stru interface{}, typ reflect.Type, field reflect.StructField, fieldVal reflect.Value) bool {\n\t\tif fieldVal.Kind() == reflect.Struct && kit.EmbeddedTypeImplements(field.Type, kitype) {\n\t\t\tfoff = append(foff, field.Offset)\n\t\t}\n\t\treturn true\n\t})\n\ttprops[pnm] = foff\n\treturn foff\n}", "func (Recordfood) Fields() []ent.Field {\n\treturn nil\n}", "func (fm *FinalModelStructBytes) GetFields(fbeValue *StructBytes) (int, error) {\n var err error = nil\n fbeCurrentOffset := 0\n fbeCurrentSize := 0\n fbeFieldSize := 0\n\n fm.F1.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F1, fbeFieldSize, err = fm.F1.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F2.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F2, fbeFieldSize, err = fm.F2.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F3.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F3, fbeFieldSize, err = fm.F3.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n return fbeCurrentSize, err\n}", "func (o *NotificationAllOf) GetFields() map[string]interface{} {\n\tif o == nil || o.Fields == nil {\n\t\tvar ret map[string]interface{}\n\t\treturn ret\n\t}\n\treturn *o.Fields\n}", "func (sc *Scanner) Fields() []string {\n\treturn sc.fields\n}", "func GetFields(m interface{}) (ns []string) {\n\ttyp := GetType(m)\n\t// Only structs are supported so return an empty result if the passed object\n\t// isn't a struct\n\tif typ.Kind() != reflect.Struct {\n\t\tfmt.Printf(\"%v type can't have attributes inspected\\n\", typ.Kind())\n\t\treturn\n\t}\n\t// loop through the struct's fields\n\tfor i := 0; i < typ.NumField(); i++ {\n\t\tf := typ.Field(i)\n\t\tif f.Anonymous {\n\t\t\tfkind := f.Type.Kind()\n\t\t\tif fkind == reflect.Struct || fkind == reflect.Ptr {\n\t\t\t\tfns := GetFields(reflect.New(f.Type).Interface())\n\t\t\t\tfor _, fn := range fns {\n\t\t\t\t\tif String(fn).IsInArray(ns) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tns = append(ns, fn)\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif String(f.Name).IsInArray(ns) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tns = append(ns, f.Name)\n\t\t}\n\t}\n\treturn ns\n}", "func (s *Structx) Fields() []*Fieldx {\n\ttt := s.value.Type()\n\tfields := []*Fieldx{}\n\n\tfor i := 0; i < tt.NumField(); i++ {\n\t\tfield := tt.Field(i)\n\t\tf := &Fieldx{\n\t\t\tdata: field,\n\t\t\tvalue: s.value.FieldByName(field.Name),\n\t\t}\n\t\tfields = append(fields, f)\n\t}\n\n\treturn fields\n}", "func (m *ccMetric) Fields() map[string]interface{} {\n\treturn m.fields\n}", "func (svc record) readableFields(m *types.Module) []string {\n\tff := make([]string, 0)\n\n\t_ = m.Fields.Walk(func(f *types.ModuleField) error {\n\t\tif svc.ac.CanReadRecordValue(svc.ctx, f) {\n\t\t\tff = append(ff, f.Name)\n\t\t}\n\n\t\treturn nil\n\t})\n\n\treturn ff\n}", "func (fm *FinalModelStructOptional) GetFields(fbeValue *StructOptional) (int, error) {\n var err error = nil\n fbeCurrentOffset := 0\n fbeCurrentSize := 0\n fbeFieldSize := 0\n\n fm.FinalModelStructSimple.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.FinalModelStructSimple.GetFields(fbeValue.StructSimple); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F100.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F100, fbeFieldSize, err = fm.F100.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F101.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F101, fbeFieldSize, err = fm.F101.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F102.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F102, fbeFieldSize, err = fm.F102.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F103.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F103, fbeFieldSize, err = fm.F103.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F104.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F104, fbeFieldSize, err = fm.F104.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F105.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F105, fbeFieldSize, err = fm.F105.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F106.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F106, fbeFieldSize, err = fm.F106.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F107.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F107, fbeFieldSize, err = fm.F107.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F108.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F108, fbeFieldSize, err = fm.F108.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F109.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F109, fbeFieldSize, err = fm.F109.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F110.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F110, fbeFieldSize, err = fm.F110.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F111.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F111, fbeFieldSize, err = fm.F111.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F112.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F112, fbeFieldSize, err = fm.F112.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F113.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F113, fbeFieldSize, err = fm.F113.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F114.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F114, fbeFieldSize, err = fm.F114.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F115.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F115, fbeFieldSize, err = fm.F115.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F116.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F116, fbeFieldSize, err = fm.F116.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F117.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F117, fbeFieldSize, err = fm.F117.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F118.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F118, fbeFieldSize, err = fm.F118.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F119.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F119, fbeFieldSize, err = fm.F119.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F120.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F120, fbeFieldSize, err = fm.F120.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F121.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F121, fbeFieldSize, err = fm.F121.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F122.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F122, fbeFieldSize, err = fm.F122.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F123.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F123, fbeFieldSize, err = fm.F123.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F124.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F124, fbeFieldSize, err = fm.F124.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F125.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F125, fbeFieldSize, err = fm.F125.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F126.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F126, fbeFieldSize, err = fm.F126.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F127.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F127, fbeFieldSize, err = fm.F127.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F128.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F128, fbeFieldSize, err = fm.F128.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F129.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F129, fbeFieldSize, err = fm.F129.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F130.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F130, fbeFieldSize, err = fm.F130.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F131.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F131, fbeFieldSize, err = fm.F131.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F132.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F132, fbeFieldSize, err = fm.F132.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F133.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F133, fbeFieldSize, err = fm.F133.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F134.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F134, fbeFieldSize, err = fm.F134.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F135.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F135, fbeFieldSize, err = fm.F135.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F136.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F136, fbeFieldSize, err = fm.F136.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F137.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F137, fbeFieldSize, err = fm.F137.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F138.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F138, fbeFieldSize, err = fm.F138.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F139.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F139, fbeFieldSize, err = fm.F139.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F140.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F140, fbeFieldSize, err = fm.F140.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F141.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F141, fbeFieldSize, err = fm.F141.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F142.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F142, fbeFieldSize, err = fm.F142.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F143.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F143, fbeFieldSize, err = fm.F143.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F144.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F144, fbeFieldSize, err = fm.F144.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F145.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F145, fbeFieldSize, err = fm.F145.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F146.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F146, fbeFieldSize, err = fm.F146.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F147.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F147, fbeFieldSize, err = fm.F147.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F148.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F148, fbeFieldSize, err = fm.F148.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F149.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F149, fbeFieldSize, err = fm.F149.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F150.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F150, fbeFieldSize, err = fm.F150.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F151.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F151, fbeFieldSize, err = fm.F151.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F152.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F152, fbeFieldSize, err = fm.F152.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F153.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F153, fbeFieldSize, err = fm.F153.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F154.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F154, fbeFieldSize, err = fm.F154.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F155.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F155, fbeFieldSize, err = fm.F155.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F156.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F156, fbeFieldSize, err = fm.F156.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F157.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F157, fbeFieldSize, err = fm.F157.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F158.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F158, fbeFieldSize, err = fm.F158.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F159.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F159, fbeFieldSize, err = fm.F159.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F160.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F160, fbeFieldSize, err = fm.F160.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F161.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F161, fbeFieldSize, err = fm.F161.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F162.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F162, fbeFieldSize, err = fm.F162.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F163.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F163, fbeFieldSize, err = fm.F163.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F164.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F164, fbeFieldSize, err = fm.F164.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F165.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F165, fbeFieldSize, err = fm.F165.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n return fbeCurrentSize, err\n}", "func (m *ShowMeasurementsMapper) Fields() []string { return []string{\"name\"} }", "func (BaseMixin) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.UUID(\"id\", uuid.UUID{}).Default(uuid.New),\n\t\tfield.String(\"some_field\"),\n\t}\n}", "func (t *Type) FieldSlice() []*Field", "func (c Class) Fields() map[string]string {\n\tfields := make(map[string]string)\n\t//Interface\n\tfields[\"{{Interface.FileName}}\"] = c.InheritedInterface.FileName\n\tfields[\"{{Interface.Name}}\"] = c.InheritedInterface.Name\n\n\t//Class\n\tfields[\"{{Class.Name}}\"] = c.Name\n\n\t// Header\n\tfields[\"{{Class.Header.FileName}}\"] = c.HeaderFileName\n\tfields[\"{{Class.Header.DefineName}}\"] = c.DefineName\n\tfields[\"{{Class.Header.Includes}}\"] = c.HeaderIncludesString\n\tfields[\"{{Class.Header.ForwardDeclares}}\"] = c.ForwardDeclares\n\tfields[\"{{Class.Header.FunctionDeclarations}}\"] = c.FunctionDeclarations\n\tfields[\"{{Class.Header.QtSignalDeclarations}}\"] = c.QtSignalDeclarations\n\n\t//Implementation\n\tfields[\"{{Class.Implementation.FileName}}\"] = c.ImplementationFileName\n\tfields[\"{{Class.Implementation.Includes}}\"] = c.ImplementationIncludesString\n\tfields[\"{{Class.Implementation.FunctionDefinitions}}\"] = c.FunctionDefinitions\n\tfields[\"{{Class.Implementation.QtSignalDefinitions}}\"] = c.QtSignalDefinitions\n\treturn fields\n}", "func (Sample) Fields() []ent.Field {\n\treturn nil\n}", "func (PatientInfo) Fields() []ent.Field {\r\n\treturn []ent.Field{\r\n\t\tfield.String(\"cardNumber\").NotEmpty().Unique(),\r\n\t\tfield.String(\"name\").NotEmpty(),\r\n\t\tfield.String(\"gender\").NotEmpty(),\r\n\t\tfield.Int(\"age\").Positive(),\r\n\t}\r\n}", "func (tfs TwoFactorSession) Fields() (map[string]interface{}, error) {\n\treturn mapper.MapFrom(\"json\", &tfs)\n}", "func (e FailError) Fields() vals.StructMap { return failFields{e} }", "func (Borrow) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.Time(\"date\").Default(time.Now).Immutable(),\n\t}\n}", "func (Medicalfile) Fields() []ent.Field {\n return []ent.Field{\n\t\tfield.String(\"detail\").NotEmpty(),\n\t\tfield.Time(\"added_time\"),\n }\n}", "func (Patientrecord) Fields() []ent.Field {\n\treturn []ent.Field{\n\n field.String(\"Name\"),\n\n }\n}", "func (Car) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.String(\"model\"),\n\t\tfield.Time(\"registered_at\"),\n\t}\n}", "func GetStructFieldsData(i interface{}) ([]FieldData, error) {\n\tt := reflect.TypeOf(i)\n\tv := reflect.ValueOf(i)\n\tif t.Kind() == reflect.Ptr {\n\t\tt = t.Elem()\n\t\tv = v.Elem()\n\t}\n\n\tif t.Kind() != reflect.Struct {\n\t\treturn nil, errors.New(\"argument is not a struct\")\n\t}\n\n\tvar ret []FieldData\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfieldData := FieldData{}\n\t\tfieldData.Name = t.Field(i).Name\n\t\tfieldData.Type = t.Field(i).Type\n\t\tfieldData.Tags = t.Field(i).Tag\n\t\tfieldData.Exported = t.Field(i).PkgPath == \"\"\n\t\tfieldData.Anonymous = t.Field(i).Anonymous\n\n\t\tif fieldData.Exported {\n\t\t\tfieldData.Value = v.Field(i).Interface()\n\t\t} else {\n\t\t\tfieldData.Value = nil\n\t\t}\n\n\t\tret = append(ret, fieldData)\n\t}\n\n\treturn ret, nil\n}", "func (User) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.String(\"email\"),\n\t\tfield.String(\"password\"),\n\t\tfield.String(\"name\"),\n\t\tfield.String(\"age\"),\n\t\tfield.Time(\"birthday\"),\n\t\tfield.String(\"tel\"),\n\t}\n}", "func (o *PublicViewInfo) GetFields() []PublicField {\n\tif o == nil {\n\t\tvar ret []PublicField\n\t\treturn ret\n\t}\n\n\treturn o.Fields\n}", "func (e Account) EntFields() ent.Fields { return ent_Account_fields }", "func (e Account) EntFields() ent.Fields { return ent_Account_fields }", "func (fs *FollowService) Fields() ([]string, error) {\n\tf, err := fs.client.getFields(fs.end)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"cannot get Follow fields\")\n\t}\n\n\treturn f, nil\n}", "func (m *Message) Fields() map[string]interface{} {\n\treturn map[string]interface{}{\n\t\t\"groupId\": m.GroupID,\n\t\t\"memberId\": m.MemberID,\n\t\t\"trial\": m.Trial,\n\t}\n}", "func (Status) Fields() []ent.Field {\n\treturn nil\n}", "func (fm *FieldModelOrder) GetFields(fbeValue *Order, fbeStructSize int) {\n fbeCurrentSize := 4 + 4\n\n if (fbeCurrentSize + fm.Id.FBESize()) <= fbeStructSize {\n fbeValue.Id, _ = fm.Id.Get()\n } else {\n fbeValue.Id = 0\n }\n fbeCurrentSize += fm.Id.FBESize()\n\n if (fbeCurrentSize + fm.Symbol.FBESize()) <= fbeStructSize {\n fbeValue.Symbol, _ = fm.Symbol.Get()\n } else {\n fbeValue.Symbol = \"\"\n }\n fbeCurrentSize += fm.Symbol.FBESize()\n\n if (fbeCurrentSize + fm.Side.FBESize()) <= fbeStructSize {\n _ = fm.Side.GetValue(&fbeValue.Side)\n } else {\n fbeValue.Side = *NewOrderSide()\n }\n fbeCurrentSize += fm.Side.FBESize()\n\n if (fbeCurrentSize + fm.Type.FBESize()) <= fbeStructSize {\n _ = fm.Type.GetValue(&fbeValue.Type)\n } else {\n fbeValue.Type = *NewOrderType()\n }\n fbeCurrentSize += fm.Type.FBESize()\n\n if (fbeCurrentSize + fm.Price.FBESize()) <= fbeStructSize {\n fbeValue.Price, _ = fm.Price.GetDefault(float64(0.0))\n } else {\n fbeValue.Price = float64(0.0)\n }\n fbeCurrentSize += fm.Price.FBESize()\n\n if (fbeCurrentSize + fm.Volume.FBESize()) <= fbeStructSize {\n fbeValue.Volume, _ = fm.Volume.GetDefault(float64(0.0))\n } else {\n fbeValue.Volume = float64(0.0)\n }\n fbeCurrentSize += fm.Volume.FBESize()\n}", "func (msg *Message) Fields() []*Field {\n\treturn msg.fields\n}", "func (msg *Message) Fields() []*Field {\n\n\treturn msg.fields\n}", "func (n Node) AllFields() []interface{} {\n\tlabels := make([]interface{}, len(n.Labels))\n\tfor i, label := range n.Labels {\n\t\tlabels[i] = label\n\t}\n\treturn []interface{}{n.NodeIdentity, labels, n.Properties}\n}", "func (b Build) Fields() map[string]interface{} {\n\treturn map[string]interface{}{\n\t\t\"app\": b.App,\n\t\t\"build_date\": b.Date,\n\t\t\"commit\": b.Commit,\n\t}\n}", "func (Short) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.String(\"key\").NotEmpty().Unique().Immutable(),\n\t\tfield.UUID(\"value\", uuid.UUID{}).Immutable(),\n\t}\n}", "func (Token) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.UUID(\"id\", uuid.UUID{}).\n\t\t\tImmutable(),\n\t\tfield.String(\"name\").\n\t\t\tMinLen(1).\n\t\t\tMaxLen(64).\n\t\t\tNotEmpty(),\n\t\tfield.String(\"secret\").\n\t\t\tNotEmpty().\n\t\t\tMinLen(40).\n\t\t\tMaxLen(80).\n\t\t\tSensitive(),\n\t\tfield.Enum(\"permissions\").\n\t\t\tImmutable().\n\t\t\tValues(\"Read\", \"Write\", \"ReadWrite\").\n\t\t\tDefault(\"ReadWrite\"),\n\t\tfield.Time(\"created_at\").\n\t\t\tImmutable().\n\t\t\tDefault(time.Now),\n\t\tfield.Time(\"last_used\").\n\t\t\tOptional(),\n\t}\n}", "func (i Interface) Fields() map[string]string {\n\tfields := make(map[string]string)\n\tfields[\"{{Interface.Name}}\"] = i.Name\n\tfields[\"{{FileName}}\"] = i.FileName\n\tfields[\"{{Interface.DefineName}}\"] = i.DefineName\n\treturn fields\n}", "func (Complaint) Fields() []ent.Field {\n\treturn nil\n}", "func (Meta) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.Time(\"created_at\").\n\t\t\tDefault(time.Now),\n\t\tfield.Time(\"updated_at\").\n\t\t\tDefault(time.Now),\n\t\tfield.String(\"key\"),\n\t\tfield.String(\"value\").MaxLen(4095),\n\t}\n}", "func (cs *CoverService) Fields() ([]string, error) {\n\tf, err := cs.client.getFields(cs.end)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"cannot get Cover fields\")\n\t}\n\n\treturn f, nil\n}", "func (Player) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.String(\"name\").MinLen(1).MaxLen(16),\n\t\tfield.Enum(\"color\").Values(\"blue\", \"orange\", \"red\", \"white\"),\n\t}\n}", "func Fields() error {\n\treturn devtools.GenerateFieldsYAML()\n}", "func (Like) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.String(\"user_id\"),\n\t}\n}", "func (l *Logger) Fields() Fields {\n\treturn l.fields\n}", "func (Book) Fields() []ent.Field {\n\treturn []ent.Field{\t\t \n\t\tfield.Time(\"RESERVATIONS\"), \n\t}\n}", "func dumpfields(bv bitvector) {\n\tdumpbv(&bv, 0)\n\tdumpint(fieldKindEol)\n}", "func (Session) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.UUID(\"id\", uuid.UUID{}),\n\t\tfield.Bool(\"new_user\"),\n\t\tfield.Bool(\"is_unique\"),\n\t\tfield.Bool(\"is_bounce\"),\n\t\tfield.Bool(\"is_finished\"),\n\t\tfield.Int(\"duration\").Optional(),\n\t\tfield.Time(\"started_at\"),\n\t\tfield.Time(\"finished_at\").Nillable().Optional(),\n\t}\n}", "func (UnitOfMedicine) Fields() []ent.Field {\r\n\treturn []ent.Field{\r\n\t\tfield.String(\"name\"),\r\n\t}\r\n}", "func (cs *CharacterMugshotService) Fields() ([]string, error) {\n\tf, err := cs.client.getFields(cs.end)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"cannot get CharacterMugshot fields\")\n\t}\n\n\treturn f, nil\n}", "func (Group) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.UUID(\"id\", uuid.UUID{}).Default(uuid.New),\n\t\tfield.String(\"name\").NotEmpty(),\n\t\tfield.String(\"description\").NotEmpty().Optional(),\n\t\tfield.JSON(\"metadata\", map[string]interface{}{}).Optional(),\n\t\tfield.Time(\"created_at\").Immutable().Default(time.Now),\n\t\tfield.Time(\"updated_at\").Default(time.Now).UpdateDefault(time.Now),\n\t}\n}", "func (DrugAllergy) Fields() []ent.Field {\n return []ent.Field{\n \n }\n }", "func (Metric) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.Time(\"ts\"),\n\t\tfield.Float(\"value\"),\n\n\t\tfield.Uint(\"endpointId\"),\n\t\tfield.Uint(\"typeId\"),\n\t\tfield.Uint(\"nameId\"),\n\t\tfield.Uint(\"labelId\"),\n\n\t\tfield.Uint(\"clusterId\"),\n\t\tfield.Uint(\"nodeId\"),\n\t\tfield.Uint(\"procesId\"),\n\t\tfield.Uint(\"containerId\"),\n\t}\n}", "func (tc TraceContext) Fields() []string {\n\treturn []string{traceparentHeader, tracestateHeader}\n}", "func (Blob) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.Text(\"network_id\"),\n\t\tfield.Text(\"type\"),\n\t\tfield.Text(\"key\"),\n\t\tfield.Bytes(\"value\").\n\t\t\tOptional(),\n\t\tfield.Uint64(\"version\").\n\t\t\tDefault(0),\n\t}\n}", "func IterFields(t *Type) (*Field, Iter)", "func (s Struct) Value() []StructField {\n\treturn s.fields\n}", "func (Pet) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.UUID(\"id\", uuid.Nil).\n\t\t\tDefault(uuid.New),\n\t\tfield.UUID(\"best_friend_id\", uuid.Nil).\n\t\t\tAnnotations(\n\t\t\t\tentsql.Default(uuid.Nil.String()),\n\t\t\t),\n\t\tfield.Int(\"owner_id\").\n\t\t\tDefault(0),\n\t}\n}", "func (Builder) Fields() []ent.Field {\n\treturn nil\n}", "func (Bookreturn) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.Time(\"RETURN_TIME\"),\n\t\tfield.Int(\"DAMAGED_POINT\").Range(-1, 10),\n\t\t\n\t\tfield.String(\"DAMAGED_POINTNAME\").Validate(func(s string) error {\n\t\t\tmatch, _ := regexp.MatchString(\"^[a-zA-Z, ]+$\", s)\n\t\t\tif !match {\n\t\t\t\treturn errors.New(\"จุดที่เสียหายเป็นภาษาอังกฤษเท่านั้น เช่น TopFront,BottomBack\")\n\t\t\t}\n\t\t\treturn nil\n\t\t}),\n\t\tfield.String(\"LOST\").Validate(func(s string) error {\n\t\t\tmatch, _ := regexp.MatchString(\"^[a-zA-Z]+$\", s)\n\t\t\tif !match {\n\t\t\t\treturn errors.New(\"ถ้าหายให้พิมพ์ lost ถ้าไม่พิมพ์ no\")\n\t\t\t}\n\t\t\treturn nil\n\t\t}).MaxLen(5),\n\t}\n}", "func (m *RawMapper) Fields() []string { return append(m.selectFields, m.selectTags...) }", "func (f *Field) Fields() []*Field {\n\treturn getFields(f.value, f.defaultTag)\n}", "func (Dentist) Fields() []ent.Field {\n return []ent.Field{\n\tfield.String(\"name\").NotEmpty(),\n\tfield.Int(\"age\").Positive(),\n\tfield.String(\"cardid\").NotEmpty(),\n\tfield.Time(\"birthday\"),\n\tfield.String(\"experience\").NotEmpty(),\n\tfield.String(\"tel\").NotEmpty(),\n\tfield.String(\"email\").NotEmpty(),\n\tfield.String(\"password\").NotEmpty(),\n\n }\n}", "func (o *NotificationAllOf) GetFieldsOk() (*map[string]interface{}, bool) {\n\tif o == nil || o.Fields == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Fields, true\n}", "func (u ConfluenceServerUserV1) GetFields() logrus.Fields {\n\treturn logrus.Fields{\n\t\t\"Host\": u.Host,\n\t\t\"Port\": u.Port,\n\t\t\"Description\": u.Description,\n\t\t\"Auth\": u.Auth.GetFields(),\n\t}\n}", "func (m *message) Fields() (fs []*MessageField) {\n\tm.mu.RLock()\n\tfs = m.fields\n\tm.mu.RUnlock()\n\treturn\n}", "func (Checkout) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.Time(\"checkout_date\"),\n\t}\n}", "func (LevelOfDangerous) Fields() []ent.Field {\r\n\treturn []ent.Field{\r\n\t\tfield.String(\"name\"),\r\n\t}\r\n}", "func (OSContext) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.String(\"name\"),\n\t\tfield.String(\"family\"),\n\t\tfield.String(\"platform\").Optional(),\n\t\tfield.String(\"version\"),\n\t}\n}", "func (User) Fields() []ent.Field {\n\t// 添加实体字段\n\treturn []ent.Field{\n\t\tfield.Int(\"age\").Positive(),\n\t\tfield.String(\"name\").NotEmpty(),\n\t\tfield.Bool(\"sex\").Optional(),\n\t\tfield.String(\"address\"),\n\t}\n}", "func (Physician) Fields() []ent.Field {\n return []ent.Field{\n field.String(\"Physicianname\"),\n field.String(\"Physicianemail\"). \n Unique(), \n field.String(\"Password\"), \n } \n}", "func (u UpdateUser) Fields() map[string]interface{} {\n\treturn map[string]interface{}{\n\t\t\"email\": u.Email,\n\t\t\"public_id\": u.PublicID,\n\t}\n}" ]
[ "0.75068235", "0.7504617", "0.7480527", "0.7158599", "0.71165246", "0.70371705", "0.70371604", "0.70308304", "0.6974181", "0.6914422", "0.6902291", "0.6891259", "0.68756706", "0.68355393", "0.6823067", "0.6750258", "0.67315525", "0.67079526", "0.67078584", "0.66911334", "0.6661075", "0.6657865", "0.6647803", "0.66258925", "0.661139", "0.6594657", "0.6592684", "0.6521726", "0.6506695", "0.64922905", "0.6487828", "0.6478109", "0.6477042", "0.6470792", "0.6460926", "0.6436323", "0.64247286", "0.6413925", "0.64045167", "0.63989", "0.63944054", "0.6387932", "0.63753754", "0.63510066", "0.63500684", "0.63466716", "0.63461006", "0.6341394", "0.6333909", "0.63293386", "0.63140386", "0.63055897", "0.6305512", "0.63046455", "0.629242", "0.629242", "0.6285764", "0.62691915", "0.62661403", "0.62501496", "0.62370217", "0.62333685", "0.62271", "0.6226976", "0.62268865", "0.62204075", "0.62088686", "0.6206521", "0.61982185", "0.61833405", "0.61826855", "0.6178651", "0.6173471", "0.6169355", "0.61672485", "0.6166943", "0.61667055", "0.61636084", "0.61561084", "0.6154422", "0.6150378", "0.6144748", "0.6144114", "0.61426854", "0.61307037", "0.61270237", "0.6126125", "0.61255354", "0.61251694", "0.61225075", "0.6119657", "0.61170894", "0.61069816", "0.6103636", "0.60912794", "0.6079048", "0.6077752", "0.60762656", "0.607503", "0.6072843", "0.60702467" ]
0.0
-1
MustField returns a field with name, panic if error
func MustField(v interface{}, name string) *Fieldx { return New(v).MustField(name) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *Structx) MustField(name string) *Fieldx {\n\tf, ok := s.Field(name)\n\tif !ok {\n\t\tpanic(ErrNotField)\n\t}\n\n\treturn f\n}", "func (f *Field) Field(name string) *Field {\n\tfield, ok := f.FieldOk(name)\n\tif !ok {\n\t\tpanic(\"field not found\")\n\t}\n\n\treturn field\n}", "func (m *SnapshotPrepare) Field(fieldpath []string) (string, bool) {\n\tif len(fieldpath) == 0 {\n\t\treturn \"\", false\n\t}\n\tswitch fieldpath[0] {\n\tcase \"key\":\n\t\treturn string(m.Key), len(m.Key) > 0\n\tcase \"parent\":\n\t\treturn string(m.Parent), len(m.Parent) > 0\n\tcase \"snapshotter\":\n\t\treturn string(m.Snapshotter), len(m.Snapshotter) > 0\n\t}\n\treturn \"\", false\n}", "func (m *Command) MustCreateField(tb testing.TB, index, field string, opts ...pilosa.FieldOption) *pilosa.Field {\n\ttb.Helper()\n\tf, err := m.API.CreateField(context.Background(), index, field, opts...)\n\tif err != nil {\n\t\ttb.Fatalf(\"creating field: %s in index: %s err: %v\", field, index, err)\n\t}\n\treturn f\n}", "func (msg *Message) Field(fieldName string) *Field {\n\treturn msg.fieldByName[fieldName]\n}", "func (ds *DynamicStruct) FieldByName(name string) (reflect.StructField, bool) {\n\treturn ds.rt.FieldByName(name)\n}", "func (f *Field) FieldOk(name string) (*Field, bool) {\n\tvalue := &f.value\n\t// value must be settable so we need to make sure it holds the address of the\n\t// variable and not a copy, so we can pass the pointer to strctVal instead of a\n\t// copy (which is not assigned to any variable, hence not settable).\n\t// see \"https://blog.golang.org/laws-of-reflection#TOC_8.\"\n\tif f.value.Kind() != reflect.Ptr {\n\t\ta := f.value.Addr()\n\t\tvalue = &a\n\t}\n\tv := strctVal(value.Interface())\n\tt := v.Type()\n\n\tfield, ok := t.FieldByName(name)\n\tif !ok {\n\t\treturn nil, false\n\t}\n\n\treturn &Field{\n\t\tfield: field,\n\t\tvalue: v.FieldByName(name),\n\t}, true\n}", "func (s *Structx) Field(name string) (*Fieldx, bool) {\n\tf, ok := s.value.Type().FieldByName(name)\n\tif !ok {\n\t\treturn nil, false\n\t}\n\n\tff := &Fieldx{\n\t\tdata: f,\n\t\tvalue: s.value.FieldByName(name),\n\t}\n\n\treturn ff, true\n}", "func (v *Validator) Field(name string) (*app.Field, error) {\n\tfor _, field := range v.schema.Fields {\n\t\tif field.Name == name {\n\t\t\treturn field, nil\n\t\t}\n\t}\n\treturn nil, ErrNoField\n}", "func (s *StructLike) GetField(name string) (*Field, bool) {\n\tfor _, fi := range s.Fields {\n\t\tif fi.Name == name {\n\t\t\treturn fi, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func (s *StructField) Field(name string) (*StructField, error) {\n\treturn Field(s.Value(), name)\n}", "func (i Item) GetField(name string) interface{} {\n\treturn getField(name, i.Payload)\n}", "func (_DelegateProfile *DelegateProfileCaller) GetFieldByName(opts *bind.CallOpts, _name string) (struct {\n\tVerifier common.Address\n\tDeprecated bool\n}, error) {\n\tret := new(struct {\n\t\tVerifier common.Address\n\t\tDeprecated bool\n\t})\n\tout := ret\n\terr := _DelegateProfile.contract.Call(opts, out, \"getFieldByName\", _name)\n\treturn *ret, err\n}", "func (e CacheValidationError) Field() string { return e.field }", "func (m *ContainerCreate_Runtime) Field(fieldpath []string) (string, bool) {\n\tif len(fieldpath) == 0 {\n\t\treturn \"\", false\n\t}\n\n\tswitch fieldpath[0] {\n\tcase \"name\":\n\t\treturn string(m.Name), len(m.Name) > 0\n\tcase \"options\":\n\t\tdecoded, err := github_com_containerd_typeurl.UnmarshalAny(m.Options)\n\t\tif err != nil {\n\t\t\treturn \"\", false\n\t\t}\n\n\t\tadaptor, ok := decoded.(interface{ Field([]string) (string, bool) })\n\t\tif !ok {\n\t\t\treturn \"\", false\n\t\t}\n\t\treturn adaptor.Field(fieldpath[1:])\n\t}\n\treturn \"\", false\n}", "func getField(fieldName string, data interface{}) (string, error) {\n\tr := reflect.ValueOf(data)\n\tval := reflect.Indirect(r).FieldByName(fieldName).Interface()\n\n\tswitch v := val.(type) {\n\tcase string:\n\t\treturn v, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"only string type is supported\")\n\t}\n}", "func (v *ClassValue) field(s *scope, name string) Value {\n\tfield, ok := v.Fields[name]\n\tif !ok {\n\t\tpanic(fmt.Errorf(\"ClassValue %v did not contain field %v\", v.Type().Name(), name))\n\t}\n\treturn field\n}", "func getField(n string, i interface{}) (interface{}, bool) {\n\tre := reflect.ValueOf(i).Elem()\n\tif re.Kind() == reflect.Struct {\n\t\tf := re.FieldByName(n)\n\n\t\tif f.IsValid() {\n\t\t\treturn f.Interface(), true\n\t\t}\n\t}\n\n\treturn nil, false\n}", "func (entry *Entry) Field(name string) (value string, err error) {\n\tvalue, ok := entry.fields[name]\n\tif !ok {\n\t\terr = fmt.Errorf(\"field '%v' does not found in record %+v\", name, *entry)\n\t}\n\treturn\n}", "func (e ResponseMapperValidationError) Field() string { return e.field }", "func (e JwtRequirementValidationError) Field() string { return e.field }", "func (m *message) GetFieldByName(name string) (f *MessageField, ok bool) {\n\tm.mu.RLock()\n\tf, ok = m.fieldNameToField[name]\n\tm.mu.RUnlock()\n\treturn\n}", "func (e GetDisscusReqValidationError) Field() string { return e.field }", "func (res Result) GetField(fields ...string) interface{} {\n\tif len(fields) == 0 {\n\t\treturn res\n\t}\n\n\treturn res.get(fields)\n}", "func (e GetRequestValidationError) Field() string { return e.field }", "func (e GetRequestValidationError) Field() string { return e.field }", "func (e SimpleRequestValidationError) Field() string { return e.field }", "func (e JwtClaimToHeaderValidationError) Field() string { return e.field }", "func (e ChannelPayRequestValidationError) Field() string { return e.field }", "func (m *ContainerCreate) Field(fieldpath []string) (string, bool) {\n\tif len(fieldpath) == 0 {\n\t\treturn \"\", false\n\t}\n\n\tswitch fieldpath[0] {\n\tcase \"id\":\n\t\treturn string(m.ID), len(m.ID) > 0\n\tcase \"image\":\n\t\treturn string(m.Image), len(m.Image) > 0\n\tcase \"runtime\":\n\t\t// NOTE(stevvooe): This is probably not correct in many cases.\n\t\t// We assume that the target message also implements the Field\n\t\t// method, which isn't likely true in a lot of cases.\n\t\t//\n\t\t// If you have a broken build and have found this comment,\n\t\t// you may be closer to a solution.\n\t\tif m.Runtime == nil {\n\t\t\treturn \"\", false\n\t\t}\n\n\t\treturn m.Runtime.Field(fieldpath[1:])\n\t}\n\treturn \"\", false\n}", "func (e HTTPRequestValidationError) Field() string { return e.field }", "func (m FieldMap) GetField(tag Tag, parser FieldValueReader) MessageRejectError {\n\ttagValues, ok := m.tagLookup[tag]\n\tif !ok {\n\t\treturn ConditionallyRequiredFieldMissing(tag)\n\t}\n\n\tif err := parser.Read(tagValues[0].value); err != nil {\n\t\treturn IncorrectDataFormatForValue(tag)\n\t}\n\n\treturn nil\n}", "func (e GetMovableObjectRequestValidationError) Field() string { return e.field }", "func (_DelegateProfile *DelegateProfileCallerSession) GetFieldByName(_name string) (struct {\n\tVerifier common.Address\n\tDeprecated bool\n}, error) {\n\treturn _DelegateProfile.Contract.GetFieldByName(&_DelegateProfile.CallOpts, _name)\n}", "func (_DelegateProfile *DelegateProfileSession) GetFieldByName(_name string) (struct {\n\tVerifier common.Address\n\tDeprecated bool\n}, error) {\n\treturn _DelegateProfile.Contract.GetFieldByName(&_DelegateProfile.CallOpts, _name)\n}", "func (s UserSet) FieldGet(field models.FieldName) *models.FieldInfo {\n\tres := s.Collection().Call(\"FieldGet\", field)\n\tresTyped, _ := res.(*models.FieldInfo)\n\treturn resTyped\n}", "func (o *CreateRiskRulesData) GetFieldOk() (*string, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn &o.Field, true\n}", "func (e CreateTodoRequestValidationError) Field() string { return e.field }", "func (m *message) GetMapFieldByName(name string) (f *MapField, ok bool) {\n\tm.mu.RLock()\n\tf, ok = m.mapFieldNameToMapField[name]\n\tm.mu.RUnlock()\n\treturn\n}", "func (e JsonToMetadataValidationError) Field() string { return e.field }", "func (e HeaderMatchValidationError) Field() string { return e.field }", "func (e CreateDisscussReqValidationError) Field() string { return e.field }", "func (e HelloRequestValidationError) Field() string { return e.field }", "func (m *RoomInfoMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase roominfo.FieldInfo:\n\t\treturn m.Info()\n\t}\n\treturn nil, false\n}", "func (f *Flow) getFieldInterface(field string) (_ interface{}, err error) {\n\tswitch field {\n\tcase \"Metric\":\n\t\treturn f.Metric, nil\n\tcase \"LastUpdateMetric\":\n\t\treturn f.LastUpdateMetric, nil\n\tcase \"TCPMetric\":\n\t\treturn f.TCPMetric, nil\n\tcase \"Link\":\n\t\treturn f.Link, nil\n\tcase \"Network\":\n\t\treturn f.Network, nil\n\tcase \"ICMP\":\n\t\treturn f.ICMP, nil\n\tcase \"Transport\":\n\t\treturn f.Transport, nil\n\t}\n\n\t// check extra layers\n\tif _, ok := extraLayersMap[field]; ok {\n\t\tif value, ok := lookupPath(*f, field, reflect.Struct); ok && value.IsValid() {\n\t\t\treturn value.Interface(), nil\n\t\t}\n\t}\n\n\treturn 0, getter.ErrFieldNotFound\n}", "func (e MinioComponentValidationError) Field() string { return e.field }", "func (e GetApplicationPubSubRequestValidationError) Field() string { return e.field }", "func (e ResolveRequestValidationError) Field() string { return e.field }", "func (e JwtComponentValidationError) Field() string { return e.field }", "func (rec *Record) GetField(name string) (Field, error) {\n\tfor _, fld := range rec.Fields {\n\t\tif fld.Name == name {\n\t\t\treturn fld, nil\n\t\t}\n\t}\n\treturn Field{}, fmt.Errorf(\"No Field named \\\"%s\\\" in Record \\\"%s\\\"\", name, rec.Name)\n}", "func (m *ccMetric) GetField(key string) (interface{}, bool) {\n\tv, ok := m.fields[key]\n\treturn v, ok\n}", "func (e CreatePurchaseRequestValidationError) Field() string { return e.field }", "func (m *ResourceMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase resource.FieldName:\n\t\treturn m.Name()\n\tcase resource.FieldType:\n\t\treturn m.GetType()\n\t}\n\treturn nil, false\n}", "func (e Matcher_OnMatchValidationError) Field() string { return e.field }", "func (m *MapValue) GetField(name string) (*MapField, bool) {\n\tfield, found := m.fieldMap[name]\n\treturn field, found\n}", "func (e JwtCacheConfigValidationError) Field() string { return e.field }", "func (typ *Type) Field(n string) (*Field, bool) {\n\tidx, ok := typ.fieldIdx[n]\n\tif !ok {\n\t\treturn nil, false\n\t}\n\treturn typ.Fields[idx], true\n}", "func (m *ContainerUpdate) Field(fieldpath []string) (string, bool) {\n\tif len(fieldpath) == 0 {\n\t\treturn \"\", false\n\t}\n\n\tswitch fieldpath[0] {\n\tcase \"id\":\n\t\treturn string(m.ID), len(m.ID) > 0\n\tcase \"image\":\n\t\treturn string(m.Image), len(m.Image) > 0\n\tcase \"labels\":\n\t\t// Labels fields have been special-cased by name. If this breaks,\n\t\t// add better special casing to fieldpath plugin.\n\t\tif len(m.Labels) == 0 {\n\t\t\treturn \"\", false\n\t\t}\n\t\tvalue, ok := m.Labels[strings.Join(fieldpath[1:], \".\")]\n\t\treturn value, ok\n\tcase \"snapshot_key\":\n\t\treturn string(m.SnapshotKey), len(m.SnapshotKey) > 0\n\t}\n\treturn \"\", false\n}", "func (e Matcher_MatcherTree_MatchMapValidationError) Field() string { return e.field }", "func (o *FieldError) GetFieldOk() (*string, bool) {\n\tif o == nil || o.Field == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Field, true\n}", "func (e CreateTodoResponseValidationError) Field() string { return e.field }", "func (m *StreetMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase street.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e HealthCheck_GrpcHealthCheckValidationError) Field() string { return e.field }", "func (e CreateMovableObjectRequestValidationError) Field() string { return e.field }", "func (e GetResponseValidationError) Field() string { return e.field }", "func (m *PatientrecordMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase patientrecord.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (s *state) evalField(dot reflect.Value, fieldName string, node parse.Node, args []parse.Node, final, receiver reflect.Value) reflect.Value {\n\tif !receiver.IsValid() {\n\t\treturn zero\n\t}\n\ttyp := receiver.Type()\n\treceiver, _ = indirect(receiver)\n\t// Unless it's an interface, need to get to a value of type *T to guarantee\n\t// we see all methods of T and *T.\n\tptr := receiver\n\tif ptr.Kind() != reflect.Interface && ptr.CanAddr() {\n\t\tptr = ptr.Addr()\n\t}\n\tif method := ptr.MethodByName(fieldName); method.IsValid() {\n\t\treturn s.evalCall(dot, method, node, fieldName, args, final)\n\t}\n\thasArgs := len(args) > 1 || final.IsValid()\n\t// It's not a method; must be a field of a struct or an element of a map. The receiver must not be nil.\n\treceiver, isNil := indirect(receiver)\n\tif isNil {\n\t\ts.errorf(\"nil pointer evaluating %s.%s\", typ, fieldName)\n\t}\n\tswitch receiver.Kind() {\n\tcase reflect.Struct:\n\t\ttField, ok := receiver.Type().FieldByName(fieldName)\n\t\tif ok {\n\t\t\tfield := receiver.FieldByIndex(tField.Index)\n\t\t\tif tField.PkgPath != \"\" { // field is unexported\n\t\t\t\ts.errorf(\"%s is an unexported field of struct type %s\", fieldName, typ)\n\t\t\t}\n\t\t\t// If it's a function, we must call it.\n\t\t\tif hasArgs {\n\t\t\t\ts.errorf(\"%s has arguments but cannot be invoked as function\", fieldName)\n\t\t\t}\n\t\t\treturn field\n\t\t}\n\t\ts.errorf(\"%s is not a field of struct type %s\", fieldName, typ)\n\tcase reflect.Map:\n\t\t// If it's a map, attempt to use the field name as a key.\n\t\tnameVal := reflect.ValueOf(fieldName)\n\t\tif nameVal.Type().AssignableTo(receiver.Type().Key()) {\n\t\t\tif hasArgs {\n\t\t\t\ts.errorf(\"%s is not a method but has arguments\", fieldName)\n\t\t\t}\n\t\t\treturn receiver.MapIndex(nameVal)\n\t\t}\n\t}\n\ts.errorf(\"can't evaluate field %s in type %s\", fieldName, typ)\n\tpanic(\"not reached\")\n}", "func (e SimpleResponseValidationError) Field() string { return e.field }", "func (e MovableObjectValidationError) Field() string { return e.field }", "func (e GetUserRequestValidationError) Field() string { return e.field }", "func (e RequestValidationError) Field() string { return e.field }", "func (def *Definition) CheckField(name string) bool {\n\t_, ok := def.activeFields[name]\n\tif len(def.activeFields) == 0 && len(def.Values) > 0 {\n\t\treturn true\n\t}\n\tCentral.Log.Debugf(\"returning %v %d %d\", ok, len(def.activeFields), len(def.Values))\n\treturn ok\n}", "func (e MaintemplateComponentValidationError) Field() string { return e.field }", "func (o *RiskRulesListAllOfData) GetFieldOk() (*string, bool) {\n\tif o == nil || IsNil(o.Field) {\n\t\treturn nil, false\n\t}\n\treturn o.Field, true\n}", "func (e CreateRequestValidationError) Field() string { return e.field }", "func (e CreateRequestValidationError) Field() string { return e.field }", "func (e LoggingValidationError) Field() string { return e.field }", "func (e PassiveHealthCheckUnhealthyValidationError) Field() string { return e.field }", "func (e HelloResponseValidationError) Field() string { return e.field }", "func (e GetMessageRequestValidationError) Field() string { return e.field }", "func (e GetUserCommentReqValidationError) Field() string { return e.field }", "func (e CreateDisscusRespValidationError) Field() string { return e.field }", "func (e HealthCheck_RedisHealthCheckValidationError) Field() string { return e.field }", "func (e RanfunctionNameValidationError) Field() string { return e.field }", "func (e PassiveHealthCheckValidationError) Field() string { return e.field }", "func (e GcpComponentValidationError) Field() string { return e.field }", "func (e BodyResponseValidationError) Field() string { return e.field }", "func (e GetDisscusRespValidationError) Field() string { return e.field }", "func (e PurchaseValidationError) Field() string { return e.field }", "func (e ScopedRoutes_ScopeKeyBuilder_FragmentBuilder_HeaderValueExtractorValidationError) Field() string {\n\treturn e.field\n}", "func (e JsonToMetadata_RuleValidationError) Field() string { return e.field }", "func (m *GroupMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase group.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (d Document) GetField(field string) (interface{}, error) {\n\tif d.m != nil {\n\t\tx, ok := d.m[field]\n\t\tif !ok {\n\t\t\treturn nil, gcerr.Newf(gcerr.NotFound, nil, \"field %q not found in map\", field)\n\t\t}\n\t\treturn x, nil\n\t}\n\tpanic(\"unimplemented\")\n}", "func (m *LevelMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase level.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e JwtHeaderValidationError) Field() string { return e.field }", "func (e ActiveHealthCheckUnhealthyValidationError) Field() string { return e.field }", "func (r *ReflectMapper) FieldByName(v reflect.Value, name string) reflect.Value {\n\treturn r.mapper.FieldByName(v, name)\n}", "func (e CreateDocV1RequestValidationError) Field() string { return e.field }", "func (f Unstructured) Field(field string) Fragment {\n\tif f.fields != nil {\n\t\treturn f.fields[field]\n\t}\n\treturn nil\n}", "func (e JsonToMetadata_SelectorValidationError) Field() string { return e.field }" ]
[ "0.7423364", "0.69897777", "0.6543684", "0.646257", "0.64482886", "0.6440895", "0.6413086", "0.6412193", "0.62891877", "0.62620795", "0.6254666", "0.62189317", "0.62152255", "0.6193386", "0.6186558", "0.6180651", "0.6173179", "0.615851", "0.61473036", "0.6134028", "0.61222106", "0.6110208", "0.6098913", "0.6098791", "0.6092787", "0.6092787", "0.6060679", "0.6057631", "0.60574055", "0.60527253", "0.6049706", "0.60474145", "0.6038997", "0.6036933", "0.60353726", "0.6032634", "0.6032413", "0.60292995", "0.60289377", "0.60158944", "0.60089135", "0.599861", "0.5997543", "0.5996344", "0.59789336", "0.59737813", "0.59736747", "0.5971017", "0.59707636", "0.5968742", "0.5967652", "0.59662825", "0.5965052", "0.59613466", "0.5956423", "0.59486127", "0.59480107", "0.5946461", "0.5945364", "0.59379596", "0.5936633", "0.592914", "0.59263366", "0.5925779", "0.5925731", "0.5925697", "0.5924194", "0.59231186", "0.5921261", "0.5920909", "0.59192044", "0.591467", "0.5911885", "0.59114444", "0.59108675", "0.59108675", "0.59069663", "0.59030974", "0.59028774", "0.5901877", "0.5901123", "0.5899888", "0.5899119", "0.5898897", "0.5897561", "0.58919364", "0.5890659", "0.5890063", "0.58890986", "0.5885801", "0.5882242", "0.5877064", "0.5876639", "0.58764267", "0.58756393", "0.587457", "0.58680314", "0.58680165", "0.5867649", "0.5866143" ]
0.6793865
2
Field returns a field with name
func Field(v interface{}, name string) (*Fieldx, bool) { return New(v).Field(name) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (msg *Message) Field(fieldName string) *Field {\n\treturn msg.fieldByName[fieldName]\n}", "func (f *Field) Field(name string) *Field {\n\tfield, ok := f.FieldOk(name)\n\tif !ok {\n\t\tpanic(\"field not found\")\n\t}\n\n\treturn field\n}", "func (p *GetField) Name() string { return p.name }", "func (entry *Entry) Field(name string) (value string, err error) {\n\tvalue, ok := entry.fields[name]\n\tif !ok {\n\t\terr = fmt.Errorf(\"field '%v' does not found in record %+v\", name, *entry)\n\t}\n\treturn\n}", "func Field(name, from, reference string) (string, error) {\n\treturn makeRequest(\"field\", name, from, reference)\n}", "func (i Item) GetField(name string) interface{} {\n\treturn getField(name, i.Payload)\n}", "func (v *Validator) Field(name string) (*app.Field, error) {\n\tfor _, field := range v.schema.Fields {\n\t\tif field.Name == name {\n\t\t\treturn field, nil\n\t\t}\n\t}\n\treturn nil, ErrNoField\n}", "func (i *Index) Field(name string) *Field {\n\ti.mu.RLock()\n\tdefer i.mu.RUnlock()\n\treturn i.field(name)\n}", "func (typ *Type) Field(n string) (*Field, bool) {\n\tidx, ok := typ.fieldIdx[n]\n\tif !ok {\n\t\treturn nil, false\n\t}\n\treturn typ.Fields[idx], true\n}", "func (e RanfunctionNameValidationError) Field() string { return e.field }", "func getField(fieldName string, data interface{}) (string, error) {\n\tr := reflect.ValueOf(data)\n\tval := reflect.Indirect(r).FieldByName(fieldName).Interface()\n\n\tswitch v := val.(type) {\n\tcase string:\n\t\treturn v, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"only string type is supported\")\n\t}\n}", "func (e IdentifierValidationError) Field() string { return e.field }", "func (db *DB) Field(name, field string) (fieldID uint8, typ influxql.DataType) {\n\t// Find measurement.\n\tm := db.measurements[name]\n\tif m == nil {\n\t\treturn\n\t}\n\n\t// Find field.\n\tf := m.fields[field]\n\tif f == nil {\n\t\treturn\n\t}\n\n\treturn f.id, f.typ\n}", "func (tbl *STable) Field(name string, alias ...string) IQueryField {\n\t// name = reflectutils.StructFieldName(name)\n\tname = utils.CamelSplit(name, \"_\")\n\tspec := tbl.spec.ColumnSpec(name)\n\tif spec == nil {\n\t\tlog.Warningf(\"column %s not found in table %s\", name, tbl.spec.Name())\n\t\treturn nil\n\t}\n\tcol := STableField{table: tbl, spec: spec}\n\tif len(alias) > 0 {\n\t\tcol.Label(alias[0])\n\t}\n\treturn &col\n}", "func (s *StructField) Field(name string) (*StructField, error) {\n\treturn Field(s.Value(), name)\n}", "func Field(v reflect.StructField) (name string, mapped bool) {\n\tns := v.Tag.Get(\"ns\")\n\tif ns != \"\" {\n\t\tmapped = true\n\t\tname = ns\n\t\treturn\n\t}\n\tname = v.Name\n\treturn\n}", "func (q *Query) GetField(name string) *Field {\n\tfor _, f := range q.Fields {\n\t\tif f.Name == name {\n\t\t\treturn f\n\t\t}\n\t}\n\treturn nil\n}", "func (e SimpleRequestValidationError) Field() string { return e.field }", "func (e GetRequestValidationError) Field() string { return e.field }", "func (e GetRequestValidationError) Field() string { return e.field }", "func (e GetInstanceRequestValidationError) Field() string { return e.field }", "func (m *EventMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase event.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (f Unstructured) Field(field string) Fragment {\n\tif f.fields != nil {\n\t\treturn f.fields[field]\n\t}\n\treturn nil\n}", "func (rec *Record) GetField(name string) (Field, error) {\n\tfor _, fld := range rec.Fields {\n\t\tif fld.Name == name {\n\t\t\treturn fld, nil\n\t\t}\n\t}\n\treturn Field{}, fmt.Errorf(\"No Field named \\\"%s\\\" in Record \\\"%s\\\"\", name, rec.Name)\n}", "func (m *ContainerCreate_Runtime) Field(fieldpath []string) (string, bool) {\n\tif len(fieldpath) == 0 {\n\t\treturn \"\", false\n\t}\n\n\tswitch fieldpath[0] {\n\tcase \"name\":\n\t\treturn string(m.Name), len(m.Name) > 0\n\tcase \"options\":\n\t\tdecoded, err := github_com_containerd_typeurl.UnmarshalAny(m.Options)\n\t\tif err != nil {\n\t\t\treturn \"\", false\n\t\t}\n\n\t\tadaptor, ok := decoded.(interface{ Field([]string) (string, bool) })\n\t\tif !ok {\n\t\t\treturn \"\", false\n\t\t}\n\t\treturn adaptor.Field(fieldpath[1:])\n\t}\n\treturn \"\", false\n}", "func (e RanparameterNameValidationError) Field() string { return e.field }", "func (e GetEventByIDRequestValidationError) Field() string { return e.field }", "func (e GetMessageRequestValidationError) Field() string { return e.field }", "func (e ArfcnValidationError) Field() string { return e.field }", "func (s UserSet) FieldGet(field models.FieldName) *models.FieldInfo {\n\tres := s.Collection().Call(\"FieldGet\", field)\n\tresTyped, _ := res.(*models.FieldInfo)\n\treturn resTyped\n}", "func (m *PatientrecordMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase patientrecord.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (m *GroupMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase group.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (m *DiseaseMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase disease.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e GitopsCFValidationError) Field() string { return e.field }", "func (e HTTPRequestValidationError) Field() string { return e.field }", "func (e GetDisscusReqValidationError) Field() string { return e.field }", "func (s *Structx) Field(name string) (*Fieldx, bool) {\n\tf, ok := s.value.Type().FieldByName(name)\n\tif !ok {\n\t\treturn nil, false\n\t}\n\n\tff := &Fieldx{\n\t\tdata: f,\n\t\tvalue: s.value.FieldByName(name),\n\t}\n\n\treturn ff, true\n}", "func (m *LevelMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase level.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e LoggingValidationError) Field() string { return e.field }", "func (e EutracgiValidationError) Field() string { return e.field }", "func (e RanparameterDefItemValidationError) Field() string { return e.field }", "func (e DocValidationError) Field() string { return e.field }", "func (field Field) Name() string {\n\tif len(field.Names) > 0 {\n\t\treturn field.Names[0].String()\n\t}\n\n\t// The field has no name, so we use Type name as the field name.\n\treturn itemTypeName(field.TypeValue.Type).Name\n}", "func (e GetMovableObjectRequestValidationError) Field() string { return e.field }", "func (e PurchaseValidationError) Field() string { return e.field }", "func (m *StreetMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase street.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e RetrieveRequestValidationError) Field() string { return e.field }", "func (m *ResourceMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase resource.FieldName:\n\t\treturn m.Name()\n\tcase resource.FieldType:\n\t\treturn m.GetType()\n\t}\n\treturn nil, false\n}", "func FieldByName(name string) func(interface{}) interface{} {\n\treturn func(record interface{}) interface{} {\n\t\treturn reflect.ValueOf(record).FieldByName(name).Interface()\n\t}\n}", "func (e SkillValidationError) Field() string { return e.field }", "func (f *Flow) GetField(field string) (interface{}, error) {\n\tif i, err := f.getFieldInterface(field); err == nil {\n\t\treturn i, nil\n\t}\n\n\tif i, err := f.GetFieldInt64(field); err == nil {\n\t\treturn i, nil\n\t}\n\n\treturn f.GetFieldString(field)\n}", "func (e AdminValidationError) Field() string { return e.field }", "func (e TagSpecifierValidationError) Field() string { return e.field }", "func (v *ClassValue) field(s *scope, name string) Value {\n\tfield, ok := v.Fields[name]\n\tif !ok {\n\t\tpanic(fmt.Errorf(\"ClassValue %v did not contain field %v\", v.Type().Name(), name))\n\t}\n\treturn field\n}", "func (e PathCFValidationError) Field() string { return e.field }", "func fieldname(field *ast.Field) string {\n\treturn field.Names[0].Name\n}", "func (e CreateTodoRequestValidationError) Field() string { return e.field }", "func (e RanparameterItemValidationError) Field() string { return e.field }", "func (e RetrieveCurrentRequestValidationError) Field() string { return e.field }", "func (m *PermissionMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase permission.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e MovableObjectValidationError) Field() string { return e.field }", "func (e StatItem) GetField(key string) interface{} {\n\tswitch key {\n\tcase \"HeapAlloc\":\n\t\treturn e.HeapAlloc\n\tcase \"StackInuse\":\n\t\treturn e.StackInuse\n\tcase \"NumGC\":\n\t\treturn e.NumGC\n\tcase \"Goroutines\":\n\t\treturn e.Goroutines\n\tcase \"TotalAlloc\":\n\t\treturn e.TotalAlloc\n\tcase \"Mallocs\":\n\t\treturn e.Mallocs\n\tcase \"Frees\":\n\t\treturn e.Frees\n\tcase \"HeapObjects\":\n\t\treturn e.HeapObjects\n\tcase \"GCCPUFraction\":\n\t\treturn e.GCCPUFraction\n\tcase \"GCPauseUs\":\n\t\treturn e.GCPauseUs\n\t}\n\treturn nil\n}", "func (e ResolveRequestValidationError) Field() string { return e.field }", "func (e RdsValidationError) Field() string { return e.field }", "func (e RanparameterIdValidationError) Field() string { return e.field }", "func (e MaintemplateComponentValidationError) Field() string { return e.field }", "func (e MessageDValidationError) Field() string { return e.field }", "func (e ScopedRdsValidationError) Field() string { return e.field }", "func (e JwtComponentValidationError) Field() string { return e.field }", "func (c *Column) Field() string {\n\treturn c.field\n}", "func (e GetResponseValidationError) Field() string { return e.field }", "func (e RequestValidationError) Field() string { return e.field }", "func (e NrarfcnValidationError) Field() string { return e.field }", "func (e NoOneofsValidationError) Field() string { return e.field }", "func (e GetUserRequestValidationError) Field() string { return e.field }", "func (s *StructLike) GetField(name string) (*Field, bool) {\n\tfor _, fi := range s.Fields {\n\t\tif fi.Name == name {\n\t\t\treturn fi, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func (e CreatePaymentRequestValidationError) Field() string { return e.field }", "func (e GetDisscusRespValidationError) Field() string { return e.field }", "func (e PublishRequestValidationError) Field() string { return e.field }", "func (t *Type) Field(i int) *Field", "func (e GetApplicationPubSubRequestValidationError) Field() string { return e.field }", "func (e RetrievePaymentRequestValidationError) Field() string { return e.field }", "func (m *TenantMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase tenant.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e CacheValidationError) Field() string { return e.field }", "func (m *CleanernameMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase cleanername.FieldCleanername:\n\t\treturn m.Cleanername()\n\t}\n\treturn nil, false\n}", "func (c *Checker) getFieldName(field reflect.StructField) string {\n\tname := field.Name\n\tif c.JSONTag != nil {\n\t\tif val, ok := field.Tag.Lookup(\"json\"); ok {\n\t\t\tname = strings.Split(val, \",\")[0]\n\t\t}\n\t}\n\tif name == \"-\" {\n\t\tif !c.JSONTag.IgnoreDashFields {\n\t\t\tname = field.Name\n\t\t}\n\t}\n\treturn name\n}", "func (e BitStringValidationError) Field() string { return e.field }", "func (e ManifestProjectCFValidationError) Field() string { return e.field }", "func (m *ExchangeMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase exchange.FieldCode:\n\t\treturn m.Code()\n\tcase exchange.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e ApplicationPubSubValidationError) Field() string { return e.field }", "func (e CreatePurchaseRequestValidationError) Field() string { return e.field }", "func (e MatcherValidationError) Field() string { return e.field }", "func (e RetrieveMyCardsRequestValidationError) Field() string { return e.field }", "func (e GetInstanceResponseValidationError) Field() string { return e.field }", "func (e SXGValidationError) Field() string { return e.field }", "func (e SimpleResponseValidationError) Field() string { return e.field }", "func (e NrtValidationError) Field() string { return e.field }", "func (e GetEventByIDResponseValidationError) Field() string { return e.field }", "func (e NrcgiValidationError) Field() string { return e.field }", "func (e ChannelPayRequestValidationError) Field() string { return e.field }" ]
[ "0.7775857", "0.77345854", "0.74935126", "0.73585737", "0.7355919", "0.73011225", "0.7235797", "0.71676767", "0.70273715", "0.7023392", "0.7013657", "0.6991286", "0.69764125", "0.6976257", "0.69483006", "0.6941868", "0.6929807", "0.69133073", "0.69127744", "0.69127744", "0.68830323", "0.6865768", "0.68641937", "0.68576205", "0.6827762", "0.6822214", "0.6808312", "0.68078387", "0.6800825", "0.6797324", "0.6793458", "0.67859876", "0.67857474", "0.67818385", "0.67783284", "0.6771548", "0.67714995", "0.6764539", "0.67530245", "0.6751863", "0.67483616", "0.67482626", "0.6746906", "0.67464006", "0.67458874", "0.6742949", "0.6741088", "0.6740917", "0.6737908", "0.673625", "0.67333126", "0.6731638", "0.67276543", "0.6724225", "0.67225415", "0.67169154", "0.6712727", "0.6712214", "0.6707202", "0.67068595", "0.6704307", "0.66984195", "0.6695589", "0.66878045", "0.6687594", "0.6683799", "0.6682492", "0.668221", "0.66790557", "0.667469", "0.6674543", "0.66718996", "0.66714203", "0.66683507", "0.6667785", "0.6666932", "0.66648155", "0.66608775", "0.66599435", "0.6659827", "0.6658803", "0.6655476", "0.66506517", "0.66503465", "0.6648327", "0.6647826", "0.6646551", "0.664473", "0.66435385", "0.66428894", "0.6641389", "0.6640816", "0.66392326", "0.6639018", "0.6638517", "0.66381454", "0.66374624", "0.6637279", "0.66348237", "0.6630783" ]
0.6887245
20
Set set value to the field name, must be exported field
func Set(v interface{}, name string, value interface{}) error { return New(v).Set(name, value) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *Actionmap) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Wfmagent) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *SeriesMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase series.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Series field %s\", name)\n}", "func (o *Directrouting) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (r *Wrapper) Set(name string, val any) error {\n\tfv := r.rv.FieldByName(name)\n\tif !fv.IsValid() {\n\t\treturn errors.New(\"field not found\")\n\t}\n\n\tif !fv.CanSet() {\n\t\treturn errors.New(\"field can not set value\")\n\t}\n\n\tfv.Set(reflect.ValueOf(val))\n\treturn nil\n}", "func (o *Createshareresponse) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Workitemwrapup) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Integrationtype) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *ModelStructRecord) SetField(name string, value reflect.Value) {\n\tif name == \"\" {\n\t\treturn\n\t}\n\tfieldValue := m.FieldValues[name]\n\t//if value.Kind() == reflect.Ptr {\n\t//\tpanic(\"RecordFieldSetError: value cannot be a ptr\")\n\t//}\n\tif fieldValue.IsValid() == false {\n\t\tm.VirtualFieldValues[name] = reflect.New(m.model.GetFieldWithName(name).StructField().Type).Elem()\n\t\tfieldValue = m.VirtualFieldValues[name]\n\t}\n\t//fieldValue = LoopIndirectAndNew(fieldValue)\n\tsafeSet(fieldValue, value)\n}", "func (m *DiseaseMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase disease.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Disease field %s\", name)\n}", "func (o *Webchatmemberinfo) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *ExchangeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase exchange.FieldCode:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCode(v)\n\t\treturn nil\n\tcase exchange.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Exchange field %s\", name)\n}", "func (o *Wfmbushorttermforecastimportcompletetopicbuforecastmodification) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *ToolMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase tool.FieldToolName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetToolName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Tool field %s\", name)\n}", "func (df *DataFrame) SetField(name string, val starlark.Value) error {\n\tif df.frozen {\n\t\treturn fmt.Errorf(\"cannot set, DataFrame is frozen\")\n\t}\n\n\tif name == \"columns\" {\n\t\tidx, ok := val.(*Index)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"cannot assign to 'columns', wrong type\")\n\t\t}\n\t\tdf.columns = idx\n\t\treturn nil\n\t}\n\treturn starlark.NoSuchAttrError(name)\n}", "func setField(obj interface{}, name string, value interface{}) error {\n\tstructValue := reflect.ValueOf(obj).Elem()\n\tstructFieldValue := structValue.FieldByName(name)\n\n\tif !structFieldValue.IsValid() {\n\t\treturn fmt.Errorf(\"No such field: %s in obj\", name)\n\t}\n\n\tif !structFieldValue.CanSet() {\n\t\treturn fmt.Errorf(\"Cannot set %s field value\", name)\n\t}\n\n\tstructFieldType := structFieldValue.Type()\n\n\tvar val reflect.Value\n\tswitch structFieldType.String() {\n\tcase \"int\":\n\t\ti, _ := strconv.Atoi(value.(js.Value).String())\n\t\tval = reflect.ValueOf(i)\n\t\tbreak\n\tcase \"float64\":\n\t\ti, _ := strconv.ParseFloat(value.(js.Value).String(), 64)\n\t\tval = reflect.ValueOf(i)\n\t\tbreak\n\tcase \"bool\":\n\t\ti, _ := strconv.ParseBool(value.(js.Value).String())\n\t\tval = reflect.ValueOf(i)\n\t\tbreak\n\tcase \"string\":\n\t\tval = reflect.ValueOf(value.(js.Value).String())\n\t\tbreak\n\tdefault:\n\t\tval = reflect.ValueOf(value)\n\t\tbreak\n\t}\n\n\tstructFieldValue.Set(val)\n\treturn nil\n}", "func (o *Appevent) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *CompanyMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase company.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Company field %s\", name)\n}", "func (m *EventMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase event.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Event field %s\", name)\n}", "func (m *GroupMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase group.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Group field %s\", name)\n}", "func (m *StreetMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase street.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Street field %s\", name)\n}", "func setValueByName(target interface{}, fieldName string, fieldValue interface{}) (err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = exception.Newf(\"Error setting field: %v\", r)\n\t\t}\n\t}()\n\ttypeCheck := reflect.TypeOf(target)\n\tif typeCheck.Kind() != reflect.Ptr {\n\t\treturn exception.New(\"Cannot modify non-pointer target\")\n\t}\n\n\ttargetValue := reflectValue(target)\n\ttargetType := reflectType(target)\n\trelevantField, hasField := targetType.FieldByName(fieldName)\n\n\tif !hasField {\n\t\treturn exception.Newf(\"Field not found %s.%s\", targetType.Name(), fieldName)\n\t}\n\n\tfield := targetValue.FieldByName(relevantField.Name)\n\tfieldType := field.Type()\n\tif !field.CanSet() {\n\t\treturn exception.Newf(\"Cannot set field %s\", fieldName)\n\t}\n\n\tvalueReflected := reflectValue(fieldValue)\n\tif !valueReflected.IsValid() {\n\t\treturn exception.New(\"Reflected value is invalid, cannot continue.\")\n\t}\n\n\tif valueReflected.Type().AssignableTo(fieldType) {\n\t\tfield.Set(valueReflected)\n\t\treturn nil\n\t}\n\n\tif field.Kind() == reflect.Ptr {\n\t\tif valueReflected.CanAddr() {\n\t\t\tconvertedValue := valueReflected.Convert(fieldType.Elem())\n\t\t\tif convertedValue.CanAddr() {\n\t\t\t\tfield.Set(convertedValue.Addr())\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\treturn exception.New(\"Cannot take address of value for assignment to field pointer\")\n\t}\n\n\tif fieldAsString, isString := valueReflected.Interface().(string); isString {\n\t\tvar parsedValue reflect.Value\n\t\thandledType := true\n\t\tswitch fieldType.Kind() {\n\t\tcase reflect.Int:\n\t\t\tintValue, err := strconv.Atoi(fieldAsString)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(intValue)\n\t\tcase reflect.Int64:\n\t\t\tint64Value, err := strconv.ParseInt(fieldAsString, 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(int64Value)\n\t\tcase reflect.Uint16:\n\t\t\tintValue, err := strconv.Atoi(fieldAsString)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(uint16(intValue))\n\t\tcase reflect.Uint: //a.k.a. uint32\n\t\t\tintValue, err := strconv.Atoi(fieldAsString)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(uint(intValue))\n\t\tcase reflect.Uint32:\n\t\t\tintValue, err := strconv.Atoi(fieldAsString)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(uint32(intValue))\n\t\tcase reflect.Uint64:\n\t\t\tintValue, err := strconv.Atoi(fieldAsString)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(uint64(intValue))\n\t\tcase reflect.Float32:\n\t\t\tfloatValue, err := strconv.ParseFloat(fieldAsString, 32)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(floatValue)\n\t\tcase reflect.Float64:\n\t\t\tfloatValue, err := strconv.ParseFloat(fieldAsString, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(floatValue)\n\t\tdefault:\n\t\t\thandledType = false\n\t\t}\n\t\tif handledType {\n\t\t\tfield.Set(parsedValue)\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tconvertedValue := valueReflected.Convert(fieldType)\n\tif convertedValue.IsValid() && convertedValue.Type().AssignableTo(fieldType) {\n\t\tfield.Set(convertedValue)\n\t\treturn nil\n\t}\n\n\treturn exception.New(\"Couldnt set field %s.%s\", targetType.Name(), fieldName)\n}", "func (f *Field) Set(val interface{}) error {\n\t// we can't set unexported fields, so be sure this field is exported\n\tif !f.IsExported() {\n\t\treturn errNotExported\n\t}\n\n\t// do we get here? not sure...\n\tif !f.value.CanSet() {\n\t\treturn errNotSettable\n\t}\n\n\tgiven := reflect.ValueOf(val)\n\n\tif f.value.Kind() != given.Kind() {\n\t\treturn fmt.Errorf(\"wrong kind. got: %s want: %s\", given.Kind(), f.value.Kind())\n\t}\n\n\tf.value.Set(given)\n\treturn nil\n}", "func (m *BedtypeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase bedtype.FieldBedtypename:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetBedtypename(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Bedtype field %s\", name)\n}", "func (m *NametitleMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase nametitle.FieldTitle:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetTitle(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Nametitle field %s\", name)\n}", "func (o *Oauthclientrequest) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Wfmintradaydataupdatetopicintradayhistoricalqueuedata) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *DataSourceMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase datasource.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase datasource.FieldAddress:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddress(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown DataSource field %s\", name)\n}", "func (m *StatusdMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase statusd.FieldStatusdname:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetStatusdname(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Statusd field %s\", name)\n}", "func (s *Structx) Set(name string, value interface{}) error {\n\tf, ok := s.Field(name)\n\tif !ok {\n\t\treturn ErrNotField\n\t}\n\n\treturn f.Set(value)\n}", "func (o *Posttextresponse) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Contentmanagementworkspacedocumentstopicdocumentdatav2) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func Set(target, source interface{}) error {\n\tconverter := &Converter{\n\t\tTagName: \"field\",\n\t}\n\n\treturn converter.Convert(source, target)\n}", "func (f *Field) Set(l *Location, val string, seps *Delimeters) error {\n\tloc := l.Comp\n\tif loc < 0 {\n\t\tloc = 0\n\t}\n\tif x := loc - len(f.Components) + 1; x > 0 {\n\t\tf.Components = append(f.Components, make([]Component, x)...)\n\t}\n\terr := f.Components[loc].Set(l, val, seps)\n\tif err != nil {\n\t\treturn err\n\t}\n\tf.Value = f.encode(seps)\n\treturn nil\n}", "func (m *PlayerMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase player.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase player.FieldColor:\n\t\tv, ok := value.(player.Color)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetColor(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Player field %s\", name)\n}", "func (m *OperativeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase operative.FieldOperativeName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetOperativeName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Operative field %s\", name)\n}", "func (m *ClassifierMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase classifier.FieldEQUIPMENTCLASSIFIER:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEQUIPMENTCLASSIFIER(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Classifier field %s\", name)\n}", "func (m *PermissionMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase permission.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Permission field %s\", name)\n}", "func (m *SettlementMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase settlement.FieldX:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetX(v)\n\t\treturn nil\n\tcase settlement.FieldY:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetY(v)\n\t\treturn nil\n\tcase settlement.FieldIsCity:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetIsCity(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Settlement field %s\", name)\n}", "func setField(name string, field reflect.Value, usage string) {\n\tswitch field.Kind() {\n\tcase reflect.Bool:\n\t\tpflag.Bool(name, false, usage)\n\tcase reflect.Float64:\n\t\tpflag.Float64(name, 0, usage)\n\tcase reflect.Uint:\n\t\tpflag.Uint(name, 0, usage)\n\tcase reflect.String:\n\t\tpflag.String(name, \"\", usage)\n\tcase reflect.Slice:\n\t\tslice := field.Interface()\n\t\tif _, ok := slice.([]string); ok {\n\t\t\tpflag.StringSlice(name, []string{}, usage)\n\t\t} else if _, ok := slice.([]float64); ok {\n\t\t\tpflag.Float64Slice(name, []float64{}, usage)\n\t\t} else if _, ok := slice.([]uint); ok {\n\t\t\tpflag.UintSlice(name, []uint{}, usage)\n\t\t}\n\t\tpanic(\"unsupported slice type\")\n\tdefault:\n\t\tpanic(\"unsupported type\")\n\t}\n\tviper.BindPFlag(strings.ReplaceAll(name, \"-\", \".\"), pflag.Lookup(name))\n}", "func (m *PatientrecordMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase patientrecord.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Patientrecord field %s\", name)\n}", "func (m *CleanernameMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase cleanername.FieldCleanername:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCleanername(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Cleanername field %s\", name)\n}", "func (f *Fieldx) Set(v interface{}) error {\n\tif !f.IsExport() {\n\t\treturn ErrNotExported\n\t}\n\n\tif !f.value.CanSet() {\n\t\treturn errNotSettable\n\t}\n\n\tvv := reflect.ValueOf(v)\n\tif f.Kind() != vv.Kind() {\n\t\treturn fmt.Errorf(\"xstruct: value kind not match, want: %s but got %s\", f.Kind(), vv.Kind())\n\t}\n\n\tf.value.Set(vv)\n\n\treturn nil\n}", "func (cli *SetWrapper) SetName(name string) error {\n\treturn cli.set.SetValue(fieldSetName, name)\n}", "func (m *MenuMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase menu.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase menu.FieldDescription:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDescription(v)\n\t\treturn nil\n\tcase menu.FieldIsOption:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetIsOption(v)\n\t\treturn nil\n\tcase menu.FieldPrice:\n\t\tv, ok := value.(*money.Money)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPrice(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Menu field %s\", name)\n}", "func (m *RepairingMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase repairing.FieldRepairpart:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetRepairpart(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Repairing field %s\", name)\n}", "func (m *ManagerMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase manager.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase manager.FieldEmail:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEmail(v)\n\t\treturn nil\n\tcase manager.FieldPassword:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPassword(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Manager field %s\", name)\n}", "func (m *PaymentchannelMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase paymentchannel.FieldBank:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetBank(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Paymentchannel field %s\", name)\n}", "func (o *Edge) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *SystemMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase system.FieldCreateByUser:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCreateByUser(v)\n\t\treturn nil\n\tcase system.FieldUpdateByUser:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetUpdateByUser(v)\n\t\treturn nil\n\tcase system.FieldCreateTime:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCreateTime(v)\n\t\treturn nil\n\tcase system.FieldUpdateTime:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetUpdateTime(v)\n\t\treturn nil\n\tcase system.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown System field %s\", name)\n}", "func (m *ZoneproductMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase zoneproduct.FieldZone:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetZone(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Zoneproduct field %s\", name)\n}", "func (m *DayMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase day.FieldDay:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDay(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Day field %s\", name)\n}", "func SetField(obj interface{}, name string, value interface{}) error {\n\tstructValue := reflect.ValueOf(obj).Elem()\n\tstructFieldValue := structValue.FieldByName(name)\n\n\tif !structFieldValue.IsValid() {\n\t\treturn fmt.Errorf(\"No such field: %s in obj\", name)\n\t}\n\n\tif !structFieldValue.CanSet() {\n\t\treturn fmt.Errorf(\"Cannot set %s field value\", name)\n\t}\n\n\tstructFieldType := structFieldValue.Type()\n\tval := reflect.ValueOf(value)\n\tif structFieldType != val.Type() {\n\t\treturn errors.New(\"Provided value type didn't match obj field type\")\n\t}\n\n\tstructFieldValue.Set(val)\n\treturn nil\n}", "func (m *PaymentMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase payment.FieldPaymentname:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPaymentname(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Payment field %s\", name)\n}", "func (m *LevelMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase level.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Level field %s\", name)\n}", "func (s *Struct) SetField(key string, to Item) (err error) {\n\treqType, ok := s.ty.Fields[key]\n\tif !ok {\n\t\treturn newError(ErrIndex, \"cannot retrieve undefined field %s\")\n\t}\n\tif !to.Type().Equals(reqType) {\n\t\treturn newError(\n\t\t\tErrType,\n\t\t\t\"field %s of type %s cannot be assigned to a %s\",\n\t\t\tkey,\n\t\t\treqType,\n\t\t\tto.Type(),\n\t\t)\n\t}\n\n\ts.value[key] = to\n\n\treturn nil\n}", "func (m *InviteePartyMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase inviteeparty.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase inviteeparty.FieldCode:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCode(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown InviteeParty field %s\", name)\n}", "func setField(obj interface{}, name string, value interface{}) error {\n\tstructValue := reflect.ValueOf(obj).Elem()\n\tstructType := reflect.TypeOf(obj).Elem()\n\tstructFieldValue := structValue.FieldByName(name)\n\n\tfor i := 0; i < structType.NumField(); i++ {\n\t\tfield := structType.Field(i)\n\t\ttag := field.Tag.Get(\"query\")\n\n\t\tif tag == name {\n\t\t\tstructFieldValue = structValue.Field(i)\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !structFieldValue.IsValid() || !structFieldValue.CanSet() {\n\t\treturn errors.New(fmt.Sprintf(\"%s is not allowed\", name))\n\t}\n\n\tstructFieldType := structFieldValue.Type()\n\tval := reflect.ValueOf(value)\n\n\tif structFieldType.Kind() == reflect.Bool {\n\t\tswitch val.String() {\n\t\tcase \"false\":\n\t\t\tstructFieldValue.SetBool(false)\n\t\t\treturn nil\n\t\tcase \"true\":\n\t\t\tstructFieldValue.SetBool(true)\n\t\t\treturn nil\n\t\tdefault:\n\t\t\treturn errors.New(fmt.Sprintf(\"%s must be a boolean\", name))\n\t\t}\n\t} else {\n\t\tstructFieldValue.Set(val)\n\t\treturn nil\n\t}\n}", "func (m *PetruleMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase petrule.FieldPetrule:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPetrule(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Petrule field %s\", name)\n}", "func (m *CityMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase city.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown City field %s\", name)\n}", "func (m *StaytypeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase staytype.FieldStaytype:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetStaytype(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Staytype field %s\", name)\n}", "func (o *Voicemailmessagestopicvoicemailmessage) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (entry *Entry) SetField(name string, value string) {\n\tentry.fields[name] = value\n}", "func SetStrByName(o interface{}, name string, val string) {\n\tif fd := reflect.ValueOf(o).Elem().FieldByName(name); fd.IsValid() {\n\t\tfd.SetString(val)\n\t}\n}", "func (m *TypeproductMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase typeproduct.FieldTypeproduct:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetTypeproduct(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Typeproduct field %s\", name)\n}", "func (m *WifiMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase wifi.FieldWifiname:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetWifiname(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Wifi field %s\", name)\n}", "func (o *Outcomequantilecondition) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Digitalcondition) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *StatisticMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase statistic.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Statistic field %s\", name)\n}", "func (m *ZoneMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase zone.FieldEQUIPMENTZONE:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEQUIPMENTZONE(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Zone field %s\", name)\n}", "func (s *StructField) Set(v interface{}) error {\n\tif s.field.PkgPath != \"\" {\n\t\treturn errors.New(\"Field is not exported\")\n\t}\n\n\tif !s.CanSet() {\n\t\treturn errors.New(\"Field cannot be set\")\n\t}\n\n\tgiven := reflect.ValueOf(v)\n\n\tif s.value.Kind() != given.Kind() {\n\t\treturn errors.New(\"Field and value kind don't match\")\n\t}\n\n\ts.value.Set(given)\n\treturn nil\n}", "func (v *ClassValue) setField(s *scope, name string, val Value) Value {\n\tout := v.Clone().(*ClassValue)\n\tout.Fields[name] = val\n\treturn out\n}", "func (m *AuthorizeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase authorize.FieldProvider:\n\t\tv, ok := value.(authorize.Provider)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetProvider(v)\n\t\treturn nil\n\tcase authorize.FieldServiceID:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetServiceID(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Authorize field %s\", name)\n}", "func (f *FieldHeaderNames) SetValue(val interface{}) {\n\t*f = val.(FieldHeaderNames)\n}", "func (m *UserMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase user.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase user.FieldAddress:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddress(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown User field %s\", name)\n}", "func (m *RoomInfoMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase roominfo.FieldInfo:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetInfo(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown RoomInfo field %s\", name)\n}", "func (m *PurposeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase purpose.FieldObjective:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetObjective(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Purpose field %s\", name)\n}", "func (m *EntityMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase entity.FieldActive:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetActive(v)\n\t\treturn nil\n\tcase entity.FieldTicker:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetTicker(v)\n\t\treturn nil\n\tcase entity.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase entity.FieldDescription:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDescription(v)\n\t\treturn nil\n\tcase entity.FieldListDate:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetListDate(v)\n\t\treturn nil\n\tcase entity.FieldDelisted:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDelisted(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Entity field %s\", name)\n}", "func (m *HospitalMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase hospital.FieldHospital:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetHospital(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Hospital field %s\", name)\n}", "func (m *TenantMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase tenant.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Tenant field %s\", name)\n}", "func (m *DiseasetypeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase diseasetype.FieldDiseaseTypeName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDiseaseTypeName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Diseasetype field %s\", name)\n}", "func (m *RegistryKeyState) SetValueName(value *string)() {\n m.valueName = value\n}", "func (m *EmployeeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase employee.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase employee.FieldEmail:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEmail(v)\n\t\treturn nil\n\tcase employee.FieldPassword:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPassword(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Employee field %s\", name)\n}", "func (m *StockMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase stock.FieldIDstock:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetIDstock(v)\n\t\treturn nil\n\tcase stock.FieldPriceproduct:\n\t\tv, ok := value.(float64)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPriceproduct(v)\n\t\treturn nil\n\tcase stock.FieldAmount:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAmount(v)\n\t\treturn nil\n\tcase stock.FieldTime:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetTime(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Stock field %s\", name)\n}", "func (m *EquipmenttypeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase equipmenttype.FieldEQUIPMENTTYPE:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEQUIPMENTTYPE(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Equipmenttype field %s\", name)\n}", "func (o *Dialercampaignconfigchangecampaign) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *CustomerMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase customer.FieldCustomerName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCustomerName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Customer field %s\", name)\n}", "func (o *Initialconfiguration) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *PaymenttypeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase paymenttype.FieldTYPE:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetTYPE(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Paymenttype field %s\", name)\n}", "func (m *InsuranceMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase insurance.FieldCompany:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCompany(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Insurance field %s\", name)\n}", "func (m *RestaurantMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase restaurant.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase restaurant.FieldDescription:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDescription(v)\n\t\treturn nil\n\tcase restaurant.FieldURI:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetURI(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Restaurant field %s\", name)\n}", "func (m *CardMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase card.FieldNumber:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetNumber(v)\n\t\treturn nil\n\tcase card.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase card.FieldOwnerID:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetOwnerID(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Card field %s\", name)\n}", "func (o *Compliance) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *DevelopperMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase developper.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase developper.FieldAge:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAge(v)\n\t\treturn nil\n\tcase developper.FieldSchool:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetSchool(v)\n\t\treturn nil\n\tcase developper.FieldExperience:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetExperience(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Developper field %s\", name)\n}", "func (m *CategoryMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase category.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Category field %s\", name)\n}", "func (m *AssessmentMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase assessment.FieldAssessment:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAssessment(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Assessment field %s\", name)\n}", "func (m *ResourceMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase resource.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase resource.FieldType:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetType(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Resource field %s\", name)\n}", "func (m *RepairinvoiceMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase repairinvoice.FieldBequipment:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetBequipment(v)\n\t\treturn nil\n\tcase repairinvoice.FieldEmtell:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEmtell(v)\n\t\treturn nil\n\tcase repairinvoice.FieldNum:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetNum(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Repairinvoice field %s\", name)\n}", "func (m *InsuranceMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase insurance.FieldInsurancecompany:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetInsurancecompany(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Insurance field %s\", name)\n}", "func (m *NodeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase node.FieldValue:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetValue(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Node field %s\", name)\n}", "func (m *PromotiontypeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase promotiontype.FieldTYPE:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetTYPE(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Promotiontype field %s\", name)\n}" ]
[ "0.6949978", "0.69492817", "0.68532985", "0.68419826", "0.68381053", "0.6827162", "0.6813239", "0.6796274", "0.6747405", "0.6737535", "0.67272395", "0.66946477", "0.6677503", "0.6676532", "0.66673386", "0.66642684", "0.6662115", "0.665408", "0.66438115", "0.6634173", "0.6630461", "0.6623552", "0.66211385", "0.66136706", "0.66055983", "0.6605133", "0.6580262", "0.65801793", "0.65709674", "0.6568997", "0.65687394", "0.65646374", "0.6561406", "0.65609646", "0.65472865", "0.6546212", "0.65398854", "0.65295166", "0.6528232", "0.65260255", "0.6521727", "0.6520993", "0.6508541", "0.6502788", "0.6501986", "0.6500759", "0.650071", "0.64998966", "0.6499482", "0.6496486", "0.64960617", "0.64953583", "0.64935225", "0.648978", "0.6484278", "0.64777446", "0.64540124", "0.6432546", "0.64282244", "0.64278114", "0.64253867", "0.64215255", "0.6418659", "0.6412928", "0.64098316", "0.6407461", "0.64066225", "0.6402975", "0.6401816", "0.6400391", "0.63983727", "0.63957715", "0.6394517", "0.6391718", "0.6390963", "0.63873535", "0.6386666", "0.63860977", "0.63847834", "0.63824415", "0.637967", "0.6374795", "0.6372074", "0.63710856", "0.63641715", "0.63579637", "0.6353842", "0.63522416", "0.63491684", "0.6347119", "0.6343974", "0.63425136", "0.6331505", "0.6329049", "0.6327475", "0.6325632", "0.63187283", "0.6318501", "0.63170046", "0.63148487", "0.6313862" ]
0.0
-1
Zero set zero value to the field name, must be exported field
func Zero(v interface{}, name string) error { return New(v).Zero(name) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *Fieldx) Zero() error {\n\tzero := reflect.Zero(f.value.Type()).Interface()\n\treturn f.Set(zero)\n}", "func (f *Field) Zero() error {\n\tzero := reflect.Zero(f.value.Type()).Interface()\n\treturn f.Set(zero)\n}", "func (s *Structx) Zero(name string) error {\n\tf, ok := s.Field(name)\n\tif !ok {\n\t\treturn ErrNotField\n\t}\n\n\treturn f.Zero()\n}", "func (p *Pet) SetFieldZeroValue(field *mapping.StructField) error {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\tp.ID = 0\n\tcase 1: // Name\n\t\tp.Name = \"\"\n\tcase 3: // OwnerID\n\t\tp.OwnerID = 0\n\tdefault:\n\t\treturn errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n\t}\n\treturn nil\n}", "func (u *User) SetFieldZeroValue(field *mapping.StructField) error {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\tu.ID = 0\n\tcase 1: // Name\n\t\tu.Name = \"\"\n\tcase 2: // CreatedAt\n\t\tu.CreatedAt = time.Time{}\n\tcase 3: // CreatedAtIso\n\t\tu.CreatedAtIso = time.Time{}\n\tcase 5: // MotherID\n\t\tu.MotherID = 0\n\tcase 7: // FatherID\n\t\tu.FatherID = 0\n\tdefault:\n\t\treturn errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n\t}\n\treturn nil\n}", "func (dt *FieldTraits) AllowZeroValue(p Path) { dt.add(p, FieldTypeAllowZeroValue) }", "func (u *User) GetFieldZeroValue(field *mapping.StructField) (interface{}, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn 0, nil\n\tcase 1: // Name\n\t\treturn \"\", nil\n\tcase 2: // CreatedAt\n\t\treturn time.Time{}, nil\n\tcase 3: // CreatedAtIso\n\t\treturn time.Time{}, nil\n\tcase 5: // MotherID\n\t\treturn 0, nil\n\tcase 7: // FatherID\n\t\treturn 0, nil\n\tdefault:\n\t\treturn nil, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n\t}\n}", "func (p *Pet) GetFieldZeroValue(field *mapping.StructField) (interface{}, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn 0, nil\n\tcase 1: // Name\n\t\treturn \"\", nil\n\tcase 3: // OwnerID\n\t\treturn 0, nil\n\tdefault:\n\t\treturn nil, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n\t}\n}", "func (v *DataRateIndexValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *DataRateOffsetValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (t systemSetType) Zero() interface{} {\n\treturn \"\"\n}", "func (v *FCtrl) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"ack\":\n\t\treturn !v.Ack\n\tcase \"adr\":\n\t\treturn !v.ADR\n\tcase \"adr_ack_req\":\n\t\treturn !v.ADRAckReq\n\tcase \"class_b\":\n\t\treturn !v.ClassB\n\tcase \"f_pending\":\n\t\treturn !v.FPending\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *FHDR) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"dev_addr\":\n\t\treturn v.DevAddr == types.DevAddr{}\n\tcase \"f_cnt\":\n\t\treturn v.FCnt == 0\n\tcase \"f_ctrl\":\n\t\treturn v.FCtrl == FCtrl{}\n\tcase \"f_ctrl.ack\":\n\t\treturn v.FCtrl.FieldIsZero(\"ack\")\n\tcase \"f_ctrl.adr\":\n\t\treturn v.FCtrl.FieldIsZero(\"adr\")\n\tcase \"f_ctrl.adr_ack_req\":\n\t\treturn v.FCtrl.FieldIsZero(\"adr_ack_req\")\n\tcase \"f_ctrl.class_b\":\n\t\treturn v.FCtrl.FieldIsZero(\"class_b\")\n\tcase \"f_ctrl.f_pending\":\n\t\treturn v.FCtrl.FieldIsZero(\"f_pending\")\n\tcase \"f_opts\":\n\t\treturn v.FOpts == nil\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (u *User) IsFieldZero(field *mapping.StructField) (bool, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn u.ID == 0, nil\n\tcase 1: // Name\n\t\treturn u.Name == \"\", nil\n\tcase 2: // CreatedAt\n\t\treturn u.CreatedAt == time.Time{}, nil\n\tcase 3: // CreatedAtIso\n\t\treturn u.CreatedAtIso == time.Time{}, nil\n\tcase 5: // MotherID\n\t\treturn u.MotherID == 0, nil\n\tcase 7: // FatherID\n\t\treturn u.FatherID == 0, nil\n\t}\n\treturn false, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n}", "func (v *FrequencyValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (p *Pet) IsFieldZero(field *mapping.StructField) (bool, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn p.ID == 0, nil\n\tcase 1: // Name\n\t\treturn p.Name == \"\", nil\n\tcase 3: // OwnerID\n\t\treturn p.OwnerID == 0, nil\n\t}\n\treturn false, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n}", "func zeroValue(t reflect.Type) string {\n\tswitch t.Kind() {\n\tcase reflect.Bool:\n\t\treturn \"false\"\n\tcase reflect.String:\n\t\treturn `\"\"`\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn \"0\"\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn \"0\"\n\tcase reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128:\n\t\treturn \"0\"\n\tcase reflect.Ptr, reflect.Slice, reflect.Map, reflect.Interface:\n\t\treturn \"nil\"\n\tdefault:\n\t\treturn \"\"\n\t}\n}", "func (v *MHDR) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"m_type\":\n\t\treturn v.MType == 0\n\tcase \"major\":\n\t\treturn v.Major == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func noEmptyField(target FormatResult, args ...string) string {\n\tfor _, field := range args {\n\t\tif cur, ok := target[field]; ok && cur != \"\" {\n\t\t\treturn cur\n\t\t}\n\t}\n\treturn \"\"\n}", "func TestZeroWithMapField(t *testing.T) {\n\ttype MapFieldStruct struct {\n\t\tMapField map[string]int\n\t}\n\tsimpleMapStruct := new(MapFieldStruct)\n\tZero(simpleMapStruct)\n\t// This would panic if executed pre-Zero\n\tsimpleMapStruct.MapField[\"test\"] = 25\n}", "func (v *AggregatedDutyCycleValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func mungeSetZeroValue(i int, rec []interface{}, destMeta sqlz.RecordMeta) {\n\t// REVISIT: do we need to do special handling for kind.Datetime\n\t// and kind.Time (e.g. \"00:00\" for time)?\n\tz := reflect.Zero(destMeta[i].ScanType()).Interface()\n\trec[i] = z\n}", "func (p *property) zeroString() string {\n\tif p.Type == reflect.TypeOf(false) {\n\t\treturn \"false\"\n\t} else if p.Type == reflect.TypeOf(0) {\n\t\treturn \"0\"\n\t} else if p.Type == reflect.TypeOf(0.0) {\n\t\treturn \"0\"\n\t} else if p.Type == reflect.TypeOf(\"\") {\n\t\treturn \"\"\n\t} else {\n\t\tv := reflect.New(p.Type)\n\t\tif f := v.MethodByName(\"ZeroString\"); f == (reflect.Value{}) {\n\t\t\treturn \"\"\n\t\t} else {\n\t\t\tret := f.Call(nil)\n\t\t\tif len(ret) != 1 {\n\t\t\t\treturn \"\"\n\t\t\t} else {\n\t\t\t\treturn ret[0].String()\n\t\t\t}\n\t\t}\n\t}\n}", "func (v *DLSettings) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"opt_neg\":\n\t\treturn !v.OptNeg\n\tcase \"rx1_dr_offset\":\n\t\treturn v.Rx1DROffset == 0\n\tcase \"rx2_dr\":\n\t\treturn v.Rx2DR == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *RejoinRequestPayload) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"dev_eui\":\n\t\treturn v.DevEUI == types.EUI64{}\n\tcase \"join_eui\":\n\t\treturn v.JoinEUI == types.EUI64{}\n\tcase \"net_id\":\n\t\treturn v.NetID == types.NetID{}\n\tcase \"rejoin_cnt\":\n\t\treturn v.RejoinCnt == 0\n\tcase \"rejoin_type\":\n\t\treturn v.RejoinType == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *ADRAckDelayExponentValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *ADRAckLimitExponentValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func formatZeroValue(T types.Type, qf types.Qualifier) string {\n\tswitch u := T.Underlying().(type) {\n\tcase *types.Basic:\n\t\tswitch {\n\t\tcase u.Info()&types.IsNumeric > 0:\n\t\t\treturn \"0\"\n\t\tcase u.Info()&types.IsString > 0:\n\t\t\treturn `\"\"`\n\t\tcase u.Info()&types.IsBoolean > 0:\n\t\t\treturn \"false\"\n\t\tdefault:\n\t\t\treturn \"\"\n\t\t}\n\tcase *types.Pointer, *types.Interface, *types.Chan, *types.Map, *types.Slice, *types.Signature:\n\t\treturn \"nil\"\n\tdefault:\n\t\treturn types.TypeString(T, qf) + \"{}\"\n\t}\n}", "func TestZeroWithPrivateField(t *testing.T) {\n\ttype PrivateFieldStruct struct {\n\t\tprivField *int\n\t\tPublicField *int\n\t}\n\tpfstruct := new(PrivateFieldStruct)\n\n\terr := Zero(pfstruct)\n\n\tif err != nil {\n\t\tt.Errorf(\"Private field struct produced error: %v\", err)\n\t}\n\n\tif pfstruct.privField != nil {\n\t\tt.Errorf(\"Private field is not nil: %v\", pfstruct.privField)\n\t}\n\n\tif pfstruct.PublicField == nil || *pfstruct.PublicField != 0 {\n\t\tt.Errorf(\"Public field was not allocated correctly: %v\", pfstruct.PublicField)\n\t}\n}", "func (v *PingSlotPeriodValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *RxDelayValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *JoinRequestPayload) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"dev_eui\":\n\t\treturn v.DevEUI == types.EUI64{}\n\tcase \"dev_nonce\":\n\t\treturn v.DevNonce == types.DevNonce{}\n\tcase \"join_eui\":\n\t\treturn v.JoinEUI == types.EUI64{}\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *ApplicationIdentifiers) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"application_id\":\n\t\treturn v.ApplicationId == \"\"\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *CFList) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"ch_masks\":\n\t\treturn v.ChMasks == nil\n\tcase \"freq\":\n\t\treturn v.Freq == nil\n\tcase \"type\":\n\t\treturn v.Type == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func SetStructFieldIfZeroValue(strukt interface{}, fieldName string, value interface{}) (bool, error) {\n\tfieldType := reflect.TypeOf(value)\n\treturn setStructField(strukt, fieldName, value, fieldType, true)\n}", "func ZeroValue(t JType) interface{} {\n\tif t.IsPrimitive() {\n\t\treturn basicZeroValue(t.Orig.Underlying().(*types.Basic))\n\t} else {\n\t\tv := \"new \" + t.JName() + \"(\"\n\t\tif t.NeedsAddress() {\n\t\t\tv += fmt.Sprint(FakeAddressFor(t.Ident))\n\t\t}\n\t\tv += \")\"\n\t\treturn v\n\t}\n}", "func (v *MACPayload) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"decoded_payload\":\n\t\treturn v.DecodedPayload == nil\n\tcase \"f_hdr\":\n\t\treturn fieldsAreZero(&v.FHDR, FHDRFieldPathsTopLevel...)\n\tcase \"f_hdr.dev_addr\":\n\t\treturn v.FHDR.FieldIsZero(\"dev_addr\")\n\tcase \"f_hdr.f_cnt\":\n\t\treturn v.FHDR.FieldIsZero(\"f_cnt\")\n\tcase \"f_hdr.f_ctrl\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl\")\n\tcase \"f_hdr.f_ctrl.ack\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.ack\")\n\tcase \"f_hdr.f_ctrl.adr\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.adr\")\n\tcase \"f_hdr.f_ctrl.adr_ack_req\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.adr_ack_req\")\n\tcase \"f_hdr.f_ctrl.class_b\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.class_b\")\n\tcase \"f_hdr.f_ctrl.f_pending\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.f_pending\")\n\tcase \"f_hdr.f_opts\":\n\t\treturn v.FHDR.FieldIsZero(\"f_opts\")\n\tcase \"f_port\":\n\t\treturn v.FPort == 0\n\tcase \"frm_payload\":\n\t\treturn v.FRMPayload == nil\n\tcase \"full_f_cnt\":\n\t\treturn v.FullFCnt == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func CopyNoneZeroField(from, to interface{}) {\n\tfValue := reflect.ValueOf(from)\n\ttValue := reflect.ValueOf(to)\n\tif fValue.Type() != tValue.Type() {\n\t\tpanic(fmt.Sprintf(\"from/to must by same type:from=%v, to=%v\", fValue.Type(), tValue.Type()))\n\t}\n\tfValue = fValue.Elem()\n\ttValue = tValue.Elem()\n\tif !tValue.CanAddr() {\n\t\tpanic(\"copy destination must be CanAddr\")\n\t}\n\n\tfor i := 0; i < fValue.NumField(); i++ {\n\t\tfield := fValue.Field(i)\n\t\tif !field.IsZero() && field.CanSet() {\n\t\t\ttValue.Field(i).Set(field)\n\t\t}\n\t}\n}", "func ZeroString(v interface{}) string {\n\treturn String(v)\n}", "func (v *Message) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"Payload\":\n\t\treturn v.Payload == nil\n\tcase \"Payload.join_accept_payload\":\n\t\treturn v.GetJoinAcceptPayload() == nil\n\tcase \"Payload.join_accept_payload.cf_list\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"cf_list\")\n\tcase \"Payload.join_accept_payload.cf_list.ch_masks\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"cf_list.ch_masks\")\n\tcase \"Payload.join_accept_payload.cf_list.freq\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"cf_list.freq\")\n\tcase \"Payload.join_accept_payload.cf_list.type\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"cf_list.type\")\n\tcase \"Payload.join_accept_payload.dev_addr\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"dev_addr\")\n\tcase \"Payload.join_accept_payload.dl_settings\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"dl_settings\")\n\tcase \"Payload.join_accept_payload.dl_settings.opt_neg\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"dl_settings.opt_neg\")\n\tcase \"Payload.join_accept_payload.dl_settings.rx1_dr_offset\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"dl_settings.rx1_dr_offset\")\n\tcase \"Payload.join_accept_payload.dl_settings.rx2_dr\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"dl_settings.rx2_dr\")\n\tcase \"Payload.join_accept_payload.encrypted\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"encrypted\")\n\tcase \"Payload.join_accept_payload.join_nonce\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"join_nonce\")\n\tcase \"Payload.join_accept_payload.net_id\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"net_id\")\n\tcase \"Payload.join_accept_payload.rx_delay\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"rx_delay\")\n\tcase \"Payload.join_request_payload\":\n\t\treturn v.GetJoinRequestPayload() == nil\n\tcase \"Payload.join_request_payload.dev_eui\":\n\t\treturn v.GetJoinRequestPayload().FieldIsZero(\"dev_eui\")\n\tcase \"Payload.join_request_payload.dev_nonce\":\n\t\treturn v.GetJoinRequestPayload().FieldIsZero(\"dev_nonce\")\n\tcase \"Payload.join_request_payload.join_eui\":\n\t\treturn v.GetJoinRequestPayload().FieldIsZero(\"join_eui\")\n\tcase \"Payload.mac_payload\":\n\t\treturn v.GetMACPayload() == nil\n\tcase \"Payload.mac_payload.decoded_payload\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"decoded_payload\")\n\tcase \"Payload.mac_payload.f_hdr\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr\")\n\tcase \"Payload.mac_payload.f_hdr.dev_addr\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.dev_addr\")\n\tcase \"Payload.mac_payload.f_hdr.f_cnt\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_cnt\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl.ack\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl.ack\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl.adr\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl.adr\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl.adr_ack_req\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl.adr_ack_req\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl.class_b\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl.class_b\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl.f_pending\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl.f_pending\")\n\tcase \"Payload.mac_payload.f_hdr.f_opts\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_opts\")\n\tcase \"Payload.mac_payload.f_port\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_port\")\n\tcase \"Payload.mac_payload.frm_payload\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"frm_payload\")\n\tcase \"Payload.mac_payload.full_f_cnt\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"full_f_cnt\")\n\tcase \"Payload.rejoin_request_payload\":\n\t\treturn v.GetRejoinRequestPayload() == nil\n\tcase \"Payload.rejoin_request_payload.dev_eui\":\n\t\treturn v.GetRejoinRequestPayload().FieldIsZero(\"dev_eui\")\n\tcase \"Payload.rejoin_request_payload.join_eui\":\n\t\treturn v.GetRejoinRequestPayload().FieldIsZero(\"join_eui\")\n\tcase \"Payload.rejoin_request_payload.net_id\":\n\t\treturn v.GetRejoinRequestPayload().FieldIsZero(\"net_id\")\n\tcase \"Payload.rejoin_request_payload.rejoin_cnt\":\n\t\treturn v.GetRejoinRequestPayload().FieldIsZero(\"rejoin_cnt\")\n\tcase \"Payload.rejoin_request_payload.rejoin_type\":\n\t\treturn v.GetRejoinRequestPayload().FieldIsZero(\"rejoin_type\")\n\tcase \"m_hdr\":\n\t\treturn v.MHDR == MHDR{}\n\tcase \"m_hdr.m_type\":\n\t\treturn v.MHDR.FieldIsZero(\"m_type\")\n\tcase \"m_hdr.major\":\n\t\treturn v.MHDR.FieldIsZero(\"major\")\n\tcase \"mic\":\n\t\treturn v.MIC == nil\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (l *LangPackStringPluralized) SetZeroValue(value string) {\n\tl.Flags.Set(0)\n\tl.ZeroValue = value\n}", "func (wv *Spectrum) SetZero() {\n\tfor k := 0; k < 4; k++ {\n\t\twv.C[k] = 0\n\t}\n\n}", "func (n *Uint256) Zero() {\n\tn.n[0], n.n[1], n.n[2], n.n[3] = 0, 0, 0, 0\n}", "func (String) Zero(c *compiler.Compiler) (expression compiler.Expression) {\n\texpression = c.NewExpression()\n\texpression.Type = String{}\n\n\texpression.Go.WriteString(`\"\"`)\n\texpression.JS.WriteString(`\"\"`)\n\n\treturn\n}", "func (n Name) Zero() bool {\n\treturn len(n) == 0\n}", "func (this *Iter_UServ_UpdateNameToFoo) Zero() error {\n\trow, ok := this.Next()\n\tif row != nil && row.err != nil && row.err != io.EOF {\n\t\treturn row.err\n\t}\n\tif ok {\n\t\treturn fmt.Errorf(\"expected exactly 0 results from query 'UpdateNameToFoo'\")\n\t}\n\treturn nil\n}", "func (self *T) mZERO() {\r\n \r\n \r\n\t\t_type := T_ZERO\r\n\t\t_channel := antlr3rt.DEFAULT_TOKEN_CHANNEL\r\n\t\t// C:/dev/antlr.github/antlr/runtime/Go/antlr/test/T.g:8:5: ( '0' )\r\n\t\t// C:/dev/antlr.github/antlr/runtime/Go/antlr/test/T.g:8:7: '0'\r\n\t\t{\r\n\t\tself.MatchChar('0') \r\n\r\n\r\n\t\t}\r\n\r\n\t\tself.State().SetType( _type )\r\n\t\tself.State().SetChannel( _channel )\r\n}", "func (z *Element22) SetZero() *Element22 {\n\tz[0] = 0\n\tz[1] = 0\n\tz[2] = 0\n\tz[3] = 0\n\tz[4] = 0\n\tz[5] = 0\n\tz[6] = 0\n\tz[7] = 0\n\tz[8] = 0\n\tz[9] = 0\n\tz[10] = 0\n\tz[11] = 0\n\tz[12] = 0\n\tz[13] = 0\n\tz[14] = 0\n\tz[15] = 0\n\tz[16] = 0\n\tz[17] = 0\n\tz[18] = 0\n\tz[19] = 0\n\tz[20] = 0\n\tz[21] = 0\n\treturn z\n}", "func (v *JoinAcceptPayload) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"cf_list\":\n\t\treturn v.CFList == nil\n\tcase \"cf_list.ch_masks\":\n\t\treturn v.CFList.FieldIsZero(\"ch_masks\")\n\tcase \"cf_list.freq\":\n\t\treturn v.CFList.FieldIsZero(\"freq\")\n\tcase \"cf_list.type\":\n\t\treturn v.CFList.FieldIsZero(\"type\")\n\tcase \"dev_addr\":\n\t\treturn v.DevAddr == types.DevAddr{}\n\tcase \"dl_settings\":\n\t\treturn v.DLSettings == DLSettings{}\n\tcase \"dl_settings.opt_neg\":\n\t\treturn v.DLSettings.FieldIsZero(\"opt_neg\")\n\tcase \"dl_settings.rx1_dr_offset\":\n\t\treturn v.DLSettings.FieldIsZero(\"rx1_dr_offset\")\n\tcase \"dl_settings.rx2_dr\":\n\t\treturn v.DLSettings.FieldIsZero(\"rx2_dr\")\n\tcase \"encrypted\":\n\t\treturn v.Encrypted == nil\n\tcase \"join_nonce\":\n\t\treturn v.JoinNonce == types.JoinNonce{}\n\tcase \"net_id\":\n\t\treturn v.NetID == types.NetID{}\n\tcase \"rx_delay\":\n\t\treturn v.RxDelay == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func TestZeroWithPointerMapField(t *testing.T) {\n\ttype PtrMapFieldStruct struct {\n\t\tMapField *map[string]int\n\t}\n\tptrMapStruct := new(PtrMapFieldStruct)\n\tZero(ptrMapStruct)\n\t// This would panic if executed pre-Zero\n\t(*ptrMapStruct.MapField)[\"test\"] = 25\n}", "func (r1 *csvTable) Zero() interface{} {\n\treturn r1.zero\n}", "func (v *EndDeviceIdentifiers) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"application_ids\":\n\t\treturn v.ApplicationIds == nil\n\tcase \"application_ids.application_id\":\n\t\treturn v.ApplicationIds.FieldIsZero(\"application_id\")\n\tcase \"dev_addr\":\n\t\treturn v.DevAddr == nil\n\tcase \"dev_eui\":\n\t\treturn v.DevEui == nil\n\tcase \"device_id\":\n\t\treturn v.DeviceId == \"\"\n\tcase \"join_eui\":\n\t\treturn v.JoinEui == nil\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *Vector) SetZero() {\n\tv.X = 0\n\tv.Y = 0\n\tv.Z = 0\n}", "func (e *Zero) Reset() {}", "func (v *Vec3i) SetZero() {\n\tv.SetScalar(0)\n}", "func (e *GT) Zero() *GT {\n\tif e.p == nil {\n\t\te.p = &gfP12{}\n\t}\n\te.p.SetZero()\n\treturn e\n}", "func zeroFill(prefix string, width int, suffix string) string {\n\treturn prefix + strings.Repeat(\"0\", width-len(suffix)) + suffix\n}", "func zeroFill(prefix string, width int, suffix string) string {\n\treturn prefix + strings.Repeat(\"0\", width-len(suffix)) + suffix\n}", "func zeroFill(prefix string, width int, suffix string) string {\n\treturn prefix + strings.Repeat(\"0\", width-len(suffix)) + suffix\n}", "func (dc *ByteArrayDictConverter) FillZero(out interface{}) {\n\to := out.([]parquet.ByteArray)\n\to[0] = dc.zeroVal\n\tfor i := 1; i < len(o); i *= 2 {\n\t\tcopy(o[i:], o[:i])\n\t}\n}", "func (this *otherActivityStruct) Zero() bool {\n\tenergyKJ := this.energyKJ\n\tresult := energyKJ == 0\n\treturn result\n}", "func Zero() Vect { return Vect{} }", "func zeroNID(n nid) error {\n\tname := trimNIDs(n.name())\n\tid := strings.ToLower(trimNIDs(n.id()))\n\n\tif name == \"\" && id == \"\" {\n\t\treturn errors.New(\"id and name can not both be empty\")\n\t}\n\tif id == \"\" {\n\t\tid = idFromName(name)\n\t}\n\tif strings.ContainsAny(id, \" .\") {\n\t\treturn errors.New(\"a specified id can not contain spaces or full stops\")\n\t}\n\tif name == \"\" {\n\t\tname = nameFromID(id)\n\t}\n\n\tn.setID(id)\n\tn.setName(name)\n\treturn nil\n}", "func NullValue() Value { return Value{Typ: '$', Null: true} }", "func NonZeroFields(msg interface{ FieldIsZero(string) bool }, fields ...string) []string {\n\tnonZeroFields := make([]string, 0, len(fields))\n\tfor _, field := range fields {\n\t\tif !msg.FieldIsZero(field) {\n\t\t\tnonZeroFields = append(nonZeroFields, field)\n\t\t}\n\t}\n\treturn nonZeroFields\n}", "func getZeroLiteral(e ast.Expr) string {\n\tswitch t := e.(type) {\n\tcase *ast.StarExpr:\n\t\treturn \"nil\"\n\tcase *ast.Ident:\n\t\tswitch t.Name {\n\t\tcase \"string\":\n\t\t\treturn \"\\\"\\\"\"\n\t\tcase \"int\", \"int8\", \"int16\", \"int32\", \"int64\",\n\t\t\t\"uint\", \"uint8\", \"uint16\", \"uint32\", \"uint64\",\n\t\t\t\"float32\", \"float64\", \"byte\", \"rune\":\n\t\t\treturn \"0\"\n\t\tdefault:\n\t\t\tpanic(\"Type '\" + t.Name + \"' doesn't support default value for annotation field\")\n\t\t}\n\tcase *ast.ArrayType:\n\t\treturn \"nil\"\n\tdefault:\n\t\tpanic(\"Unsupported fied type in annotation definition\")\n\t}\n}", "func (s *Scalar) Zero() *Scalar {\n\ts.s = scalar.Scalar{}\n\treturn s\n}", "func (v *Vec4) Zero() {\n\tv.X = 0.0\n\tv.Y = 0.0\n\tv.Z = 0.0\n\tv.W = 0.0\n}", "func (d *Decoder) ZeroEmpty(z bool) {\n\td.zeroEmpty = z\n}", "func (e EmptyValidationError) Field() string { return e.field }", "func (util *stringUtil) FillZero(num string, digit int) string {\n\tfor fillNum := len(num) - digit; fillNum > 0; fillNum-- {\n\t\tnum = \"0\" + num\n\t}\n\treturn num\n}", "func (t systemIntType) Zero() interface{} {\n\treturn int64(0)\n}", "func (t systemIntType) Zero() interface{} {\n\treturn int64(0)\n}", "func ZeroHeader() Header {\n\treturn Header{}\n}", "func (f *Fieldx) IsZero() bool {\n\tzero := reflect.Zero(f.value.Type()).Interface()\n\treturn reflect.DeepEqual(f.Value(), zero)\n}", "func zeroval(ival int) {\n\tival = 0\n}", "func zeroval(ival int) {\n\tival = 0\n}", "func zeroval(ival int) {\n\tival = 0\n}", "func zeroval(ival int) {\n\tival = 0\n}", "func (f *Field) IsZero() bool {\n\tzero := reflect.Zero(f.value.Type()).Interface()\n\tcurrent := f.Value()\n\n\treturn reflect.DeepEqual(current, zero)\n}", "func (dc *FixedLenByteArrayDictConverter) FillZero(out interface{}) {\n\to := out.([]parquet.FixedLenByteArray)\n\to[0] = dc.zeroVal\n\tfor i := 1; i < len(o); i *= 2 {\n\t\tcopy(o[i:], o[:i])\n\t}\n}", "func (e StartElement) isZero() bool {\n\treturn len(e.Name.Local) == 0\n}", "func setTblIfNonZeroMs(event *beat.Event, tableName string, fieldName string, valueMS int64) {\n\tif valueMS > 0 {\n\t\tevent.Fields[fmt.Sprintf(\"p4.tbl.%s.%s\", strings.ToLower(tableName), fieldName)] = float64(valueMS) / 1000.0\n\t}\n}", "func (feature Feature) UnnsetField(index int) {\n\tC.OGR_F_UnsetField(feature.cval, C.int(index))\n}", "func Zero() ID {\n\treturn nilID\n}", "func (s *StructField) IsZero() bool {\n\treturn reflect2.IsZero(s.value)\n}", "func (dc *Float64DictConverter) FillZero(out interface{}) {\n\to := out.([]float64)\n\to[0] = dc.zeroVal\n\tfor i := 1; i < len(o); i *= 2 {\n\t\tcopy(o[i:], o[:i])\n\t}\n}", "func publicName(fieldName string) string {\n\tif len(fieldName) == 0 {\n\t\treturn fieldName\n\t} else {\n\t\treturn string(unicode.ToUpper(rune(fieldName[0]))) + fieldName[1:]\n\t}\n}", "func (feature Feature) SetFieldNull(index int) {\n\tC.OGR_F_SetFieldNull(feature.cval, C.int(index))\n}", "func (m *SystemMutation) ResetField(name string) error {\n\tswitch name {\n\tcase system.FieldCreateByUser:\n\t\tm.ResetCreateByUser()\n\t\treturn nil\n\tcase system.FieldUpdateByUser:\n\t\tm.ResetUpdateByUser()\n\t\treturn nil\n\tcase system.FieldCreateTime:\n\t\tm.ResetCreateTime()\n\t\treturn nil\n\tcase system.FieldUpdateTime:\n\t\tm.ResetUpdateTime()\n\t\treturn nil\n\tcase system.FieldName:\n\t\tm.ResetName()\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown System field %s\", name)\n}", "func (m *MarketHoursMutation) ResetField(name string) error {\n\tswitch name {\n\tcase markethours.FieldDate:\n\t\tm.ResetDate()\n\t\treturn nil\n\tcase markethours.FieldStartTime:\n\t\tm.ResetStartTime()\n\t\treturn nil\n\tcase markethours.FieldEndTime:\n\t\tm.ResetEndTime()\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown MarketHours field %s\", name)\n}", "func ZeroBytes() []byte {\n\treturn zeroLabelBytes\n}", "func (t JsonType) Zero() interface{} {\n\t// MySQL throws an error for INSERT IGNORE, UPDATE IGNORE, etc. when bad json is encountered:\n\t// ERROR 3140 (22032): Invalid JSON text: \"Invalid value.\" at position 0 in value for column 'table.column'.\n\treturn nil\n}", "func (a Attribute) IsZero() bool {\n\treturn a.Key == \"\"\n}", "func ZeroKey(k *ecdsa.PrivateKey) {\n\tb := k.D.Bits()\n\tfor i := range b {\n\t\tb[i] = 0\n\t}\n}", "func Zero[T Number](val T, a ...any) {\n\tif val != 0 {\n\t\tdefMsg := fmt.Sprintf(assertionMsg+\": got '%v', want (== '0')\", val)\n\t\tDefault().reportAssertionFault(defMsg, a...)\n\t}\n}", "func (zf *ZeroField) Literal(value interface{}) (string, error) {\n\tswitch v := value.(type) {\n\tcase bool, float32, float64, int32, uint32:\n\t\treturn fmt.Sprintf(\"%v\", v), nil\n\tcase int64, uint64:\n\t\treturn fmt.Sprintf(`%s(%d)`, zf.Int64Type(), v), nil\n\tcase string:\n\t\treturn dart.RawString(v), nil\n\tcase []byte:\n\t\treturn \"const <int>[\" + util.BytesLiteral(v) + \"]\", nil\n\tcase pgs.EnumValue:\n\t\ttargetFullEnumClass, err := zf.Zeros().FullPbEnum(v.Enum())\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn targetFullEnumClass.Dot(zf.File.Dart.NameOf(v)).String(), nil\n\tcase *any.Any:\n\t\treturn zf.AnyType().Init().\n\t\t\tDotString(\".typeUrl=\" + v.TypeUrl).\n\t\t\tDotString(\".value=const <int>[\" + util.BytesLiteral(v.Value) + \"]\").\n\t\t\tString(), nil\n\tcase *duration.Duration:\n\t\treturn zf.DurationType().Init().\n\t\t\tDotString(fmt.Sprintf(\".seconds=%d\", v.Seconds)).\n\t\t\tDotString(fmt.Sprintf(\".nanos=%d\", v.Nanos)).\n\t\t\tString(), nil\n\tcase *timestamp.Timestamp:\n\t\treturn zf.TimestampType().Init().\n\t\t\tDotString(fmt.Sprintf(\".seconds=%d\", v.Seconds)).\n\t\t\tDotString(fmt.Sprintf(\".nanos=%d\", v.Nanos)).\n\t\t\tString(), nil\n\tcase *ZeroEvalNow:\n\t\tt := v.Format.Dot(\"ofTime(DateTime.now())\").String()\n\t\tif v.Add != 0 {\n\t\t\tt += fmt.Sprintf(\"%+d\", v.Add)\n\t\t}\n\t\treturn t, nil\n\tcase *wrappers.DoubleValue:\n\t\treturn fmt.Sprintf(\"%s.DoubleValue()..value=%v\",\n\t\t\tzf.WrappersFile(), v.Value), nil\n\tcase *wrappers.FloatValue:\n\t\treturn fmt.Sprintf(\"%s.FloatValue()..value=%v\",\n\t\t\tzf.WrappersFile(), v.Value), nil\n\tcase *wrappers.Int64Value:\n\t\treturn fmt.Sprintf(\"%s.Int64Value()..value=%s(%d)\",\n\t\t\tzf.WrappersFile(), zf.Int64Type(), v.Value), nil\n\tcase *wrappers.UInt64Value:\n\t\treturn fmt.Sprintf(\"%s.UInt64Value()..value=%s(%d)\",\n\t\t\tzf.WrappersFile(), zf.Int64Type(), v.Value), nil\n\tcase *wrappers.Int32Value:\n\t\treturn fmt.Sprintf(\"%s.Int32Value()..value=%v\",\n\t\t\tzf.WrappersFile(), v.Value), nil\n\tcase *wrappers.UInt32Value:\n\t\treturn fmt.Sprintf(\"%s.UInt32Value()..value=%v\",\n\t\t\tzf.WrappersFile(), v.Value), nil\n\tcase *wrappers.BoolValue:\n\t\treturn fmt.Sprintf(\"%s.BoolValue()..value=%v\",\n\t\t\tzf.WrappersFile(), v.Value), nil\n\tcase *wrappers.StringValue:\n\t\treturn fmt.Sprintf(\"%s.StringValue()..value=%s\",\n\t\t\tzf.WrappersFile(), dart.RawString(v.Value)), nil\n\tcase *wrappers.BytesValue:\n\t\treturn fmt.Sprintf(\"%s.BytesValue()..value=const <int>[%s]\",\n\t\t\tzf.WrappersFile(), util.BytesLiteral(v.Value)), nil\n\tcase proto.Message:\n\t\tb, err := proto.Marshal(v)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tembed, err := zf.Zeros().FullPbClass(zf.ElementOrEmbed())\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn fmt.Sprintf(\"%s.fromBuffer(const <int>[%s])\",\n\t\t\tembed, util.BytesLiteral(b)), nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"bug: unsupported literal type: %#T\", value)\n\t}\n}", "func fieldIsEmpty(p unsafe.Pointer) bool {\n\treturn uintptr(p) == uintptr(0)\n}", "func zeroInt(s string) string {\n\tn, _ := strconv.Atoi(s)\n\treturn strconv.FormatInt(int64(n), 10)\n}", "func TestPetNameForZeroWords(t *testing.T) {\n\tname := Generate(0, 0, \"\")\n\tif name != \"\" {\n\t\tt.Fatalf(\"Generated a 0-word name, '%s'\", name)\n\t}\n}" ]
[ "0.707016", "0.69367206", "0.6867141", "0.6822513", "0.67891884", "0.6624016", "0.64442945", "0.6401223", "0.6326696", "0.6121608", "0.61069906", "0.61046386", "0.60874426", "0.60581774", "0.6054828", "0.60095847", "0.5999497", "0.59959507", "0.59943426", "0.599377", "0.5992363", "0.59793216", "0.59760165", "0.5969893", "0.5964902", "0.59423923", "0.59350795", "0.5928043", "0.5922606", "0.5916075", "0.5907382", "0.588452", "0.5870827", "0.5809496", "0.5767175", "0.5679964", "0.56779766", "0.5629985", "0.5624318", "0.5623131", "0.5577666", "0.55559456", "0.5549849", "0.5546004", "0.5545773", "0.55409414", "0.54987025", "0.54951674", "0.54927844", "0.5470779", "0.54688877", "0.54661906", "0.54655176", "0.5459046", "0.5444278", "0.5436946", "0.53928393", "0.53928393", "0.53928393", "0.53874695", "0.5373453", "0.53676784", "0.5352269", "0.53500634", "0.5344097", "0.5339571", "0.53320026", "0.53202635", "0.53104967", "0.5307835", "0.5302965", "0.52997595", "0.52997595", "0.5289112", "0.52870774", "0.5280638", "0.5280638", "0.5280638", "0.5280638", "0.52666944", "0.524423", "0.52349204", "0.52300143", "0.52247167", "0.5217514", "0.52088255", "0.5207626", "0.52023625", "0.5202187", "0.5192502", "0.5191778", "0.51870847", "0.518566", "0.5181692", "0.51596266", "0.51572967", "0.5152653", "0.5149759", "0.51492167", "0.5148209" ]
0.5743831
35
New return a new xstruct object, it panic if not struct
func New(v interface{}) *Structx { if !IsStruct(v) { panic(ErrNotStruct) } vv := reflect.ValueOf(v) if vv.Kind() == reflect.Ptr { vv = vv.Elem() } s := &Structx{ data: v, value: vv, } return s }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func New(s interface{}) *Struct {\n\treturn &Struct{\n\t\traw: s,\n\t\tvalue: structVal(s),\n\t\tTagName: DefaultTagName,\n\t}\n}", "func (*illnessR) NewStruct() *illnessR {\n\treturn &illnessR{}\n}", "func (*storeR) NewStruct() *storeR {\n\treturn &storeR{}\n}", "func (*utxoR) NewStruct() *utxoR {\n\treturn &utxoR{}\n}", "func execNewStruct(_ int, p *gop.Context) {\n\targs := p.GetArgs(2)\n\tret := types.NewStruct(args[0].([]*types.Var), args[1].([]string))\n\tp.Ret(2, ret)\n}", "func (*sourceR) NewStruct() *sourceR {\n\treturn &sourceR{}\n}", "func (*storestateR) NewStruct() *storestateR {\n\treturn &storestateR{}\n}", "func (*holdenAtR) NewStruct() *holdenAtR {\n\treturn &holdenAtR{}\n}", "func (*kvstoreR) NewStruct() *kvstoreR {\n\treturn &kvstoreR{}\n}", "func (*contentUnitDerivationR) NewStruct() *contentUnitDerivationR {\n\treturn &contentUnitDerivationR{}\n}", "func (*originR) NewStruct() *originR {\n\treturn &originR{}\n}", "func (*ticketR) NewStruct() *ticketR {\n\treturn &ticketR{}\n}", "func (*currentChartDataMinutelyR) NewStruct() *currentChartDataMinutelyR {\n\treturn &currentChartDataMinutelyR{}\n}", "func (s *Structx) Struct(name string) *Structx {\n\tf, ok := s.Field(name)\n\tif !ok {\n\t\tpanic(ErrNotField)\n\t}\n\n\treturn New(f.Value())\n}", "func (*vspR) NewStruct() *vspR {\n\treturn &vspR{}\n}", "func (*projectR) NewStruct() *projectR {\n\treturn &projectR{}\n}", "func (*projectR) NewStruct() *projectR {\n\treturn &projectR{}\n}", "func (*notificationR) NewStruct() *notificationR {\n\treturn &notificationR{}\n}", "func (*buildingR) NewStruct() *buildingR {\n\treturn &buildingR{}\n}", "func (e *exprHelper) NewStruct(typeName string, fieldInits ...ast.EntryExpr) ast.Expr {\n\treturn e.exprFactory.NewStruct(e.nextMacroID(), typeName, fieldInits)\n}", "func newDirectStruct(initial string) directStruct {\n\tr := directStruct{}\n\tr.v = append(r.v, initial)\n\treturn r\n}", "func (*treeR) NewStruct() *treeR {\n\treturn &treeR{}\n}", "func (*weatherR) NewStruct() *weatherR {\n\treturn &weatherR{}\n}", "func (*emailR) NewStruct() *emailR {\n\treturn &emailR{}\n}", "func (*nodeR) NewStruct() *nodeR {\n\treturn &nodeR{}\n}", "func (*stockKeepingUnitContentR) NewStruct() *stockKeepingUnitContentR {\n\treturn &stockKeepingUnitContentR{}\n}", "func Struct(v interface{}, name string) *Structx {\n\treturn New(v).Struct(name)\n}", "func NewStruct(ty *StructType) *Struct {\n\ts := &Struct{\n\t\tty: ty,\n\t\tvalue: make(map[string]Item),\n\t}\n\n\tfor k, t := range ty.Fields {\n\t\ts.value[k] = MakeZeroValue(t)\n\t}\n\n\treturn s\n}", "func (*paymentObjectR) NewStruct() *paymentObjectR {\n\treturn &paymentObjectR{}\n}", "func (*repositoryR) NewStruct() *repositoryR {\n\treturn &repositoryR{}\n}", "func (*exchangeCurrencyR) NewStruct() *exchangeCurrencyR {\n\treturn &exchangeCurrencyR{}\n}", "func (*rawVisitR) NewStruct() *rawVisitR {\n\treturn &rawVisitR{}\n}", "func (*descriptionR) NewStruct() *descriptionR {\n\treturn &descriptionR{}\n}", "func (*peerR) NewStruct() *peerR {\n\treturn &peerR{}\n}", "func (*chatR) NewStruct() *chatR {\n\treturn &chatR{}\n}", "func (*vendorR) NewStruct() *vendorR {\n\treturn &vendorR{}\n}", "func NewStruct(vs ...interface{}) Struct {\n\tstructFields := make([]StructField, len(vs)/2)\n\tfor i := range structFields {\n\t\tstructFields[i] = NewStructField(\n\t\t\tvs[2*i+0].(string),\n\t\t\tvs[2*i+1].(Value),\n\t\t)\n\t}\n\treturn Struct(structFields)\n}", "func (*blockR) NewStruct() *blockR {\n\treturn &blockR{}\n}", "func (*mempoolBinR) NewStruct() *mempoolBinR {\n\treturn &mempoolBinR{}\n}", "func (a *ByAttribute) newStruct(data interface{}, reflectItems []*modelsNormalization.ReflectStructItem) (reflect.Value, error) {\n\tif len(reflectItems) == 0 {\n\t\treturn reflect.ValueOf(struct{}{}), nil\n\t}\n\n\tfields := make([]reflect.StructField, len(reflectItems))\n\tfor i, item := range reflectItems {\n\t\tfields[i] = item.Field\n\t}\n\n\tnewStruct := reflect.New(reflect.StructOf(fields)).Elem()\n\tfor i, item := range reflectItems {\n\t\tnewStruct.Field(i).Set(item.Value)\n\t}\n\treturn newStruct, nil\n}", "func (*friendshipR) NewStruct() *friendshipR {\n\treturn &friendshipR{}\n}", "func (*docR) NewStruct() *docR {\n\treturn &docR{}\n}", "func (*itemR) NewStruct() *itemR {\n\treturn &itemR{}\n}", "func newStructFLS(p interface{}) (FieldLoadSaver, error) {\n\tv := reflect.ValueOf(p)\n\tif v.Kind() != reflect.Ptr || v.IsNil() || v.Elem().Kind() != reflect.Struct {\n\t\treturn nil, ErrInvalidDocumentType\n\t}\n\treturn structFLS{v.Elem()}, nil\n}", "func (*taskR) NewStruct() *taskR {\n\treturn &taskR{}\n}", "func newXPubWallet(meta Meta) (*XPubWallet, error) {\n\txpub, err := parseXPub(meta.XPub())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &XPubWallet{\n\t\tMeta: meta,\n\t\txpub: xpub,\n\t}, nil\n}", "func (*currencyR) NewStruct() *currencyR {\n\treturn &currencyR{}\n}", "func (*withdrawalCryptoR) NewStruct() *withdrawalCryptoR {\n\treturn &withdrawalCryptoR{}\n}", "func (*offerR) NewStruct() *offerR {\n\treturn &offerR{}\n}", "func (*rssAnnouncementR) NewStruct() *rssAnnouncementR {\n\treturn &rssAnnouncementR{}\n}", "func (*boardR) NewStruct() *boardR {\n\treturn &boardR{}\n}", "func (*jobR) NewStruct() *jobR {\n\treturn &jobR{}\n}", "func New() Object {\n\treturn Object{}\n}", "func (*postR) NewStruct() *postR {\n\treturn &postR{}\n}", "func (*employeeR) NewStruct() *employeeR {\n\treturn &employeeR{}\n}", "func newDynamicStruct(fields []reflect.StructField, isPtr bool, name string) (ds *DynamicStruct, err error) {\n\tdefer func() {\n\t\terr = util.RecoverToError(recover())\n\t}()\n\n\tds = &DynamicStruct{\n\t\tname: name,\n\t\tfields: fields,\n\t\trt: reflect.StructOf(fields),\n\t\tisPtr: isPtr,\n\t}\n\n\treturn\n}", "func New(namespace string, name string) (t TupleType) {\n\thash := syncHash.Hash([]byte(name))\n\tns_hash := syncHash.Hash([]byte(namespace))\n\tt = TupleType{namespace, name, ns_hash, hash, make([][]Field, 0), make(map[string]int)}\n\treturn\n}", "func (*segmentR) NewStruct() *segmentR {\n\treturn &segmentR{}\n}", "func (*customerR) NewStruct() *customerR {\n\treturn &customerR{}\n}", "func newStructReflector(v *Reflector) (*StructReflector, error) {\n\tif !v.IsValid() {\n\t\treturn nil, errors.New(ERR_INVALID_VALUE)\n\t}\n\n\t// Dereference interfaces.\n\tif v.IsInterface() {\n\t\tif v.IsNil() {\n\t\t\treturn nil, errors.New(ERR_INVALID_VALUE)\n\t\t}\n\t\tv = v.Elem()\n\t}\n\n\tif v.IsStruct() {\n\t\treturn &StructReflector{\n\t\t\titem: v,\n\t\t\tstructItem: v,\n\t\t}, nil\n\t} else if v.IsStructPtr() {\n\t\tif v.IsNil() {\n\t\t\tnewStruct := New(v.Type().Elem())\n\t\t\tif err := v.Set(newStruct); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\n\t\treturn &StructReflector{\n\t\t\titem: v,\n\t\t\tstructItem: v.Elem(),\n\t\t\tisPtr: true,\n\t\t}, nil\n\t}\n\treturn nil, errors.New(ERR_NOT_A_STRUCT)\n}", "func (*trainingCostR) NewStruct() *trainingCostR {\n\treturn &trainingCostR{}\n}", "func (*btcTXOutputR) NewStruct() *btcTXOutputR {\n\treturn &btcTXOutputR{}\n}", "func NewFromStruct(s interface{}) (types.Document, error) {\n\tref := reflect.Indirect(reflect.ValueOf(s))\n\n\tif !ref.IsValid() || ref.Kind() != reflect.Struct {\n\t\treturn nil, errors.New(\"expected struct or pointer to struct\")\n\t}\n\n\treturn newFromStruct(ref)\n}", "func (p Package) Struct(strct string) Struct {\n\treturn Struct{p, strct}\n}", "func (*smallblogR) NewStruct() *smallblogR {\n\treturn &smallblogR{}\n}", "func newInstance(x *runtime.Runtime, p *build.Instance, v *adt.Vertex) *Instance {\n\t// TODO: associate root source with structLit.\n\tinst := &Instance{\n\t\troot: v,\n\t\tinst: p,\n\t}\n\tif p != nil {\n\t\tinst.ImportPath = p.ImportPath\n\t\tinst.Dir = p.Dir\n\t\tinst.PkgName = p.PkgName\n\t\tinst.DisplayName = p.ImportPath\n\t\tif p.Err != nil {\n\t\t\tinst.setListOrError(p.Err)\n\t\t}\n\t}\n\n\tx.AddInst(p.ImportPath, v, p)\n\tx.SetBuildData(p, inst)\n\tinst.index = x\n\treturn inst\n}", "func New(msg string) error {\n\treturn &fundamental{\n\t\tmsg: msg,\n\t\tstack: callers(2),\n\t}\n}", "func (*cmfSlideItemR) NewStruct() *cmfSlideItemR {\n\treturn &cmfSlideItemR{}\n}", "func Newx(v ...interface{}) error {\n\treturn errors.New(stringJoin(v...))\n}", "func New() error {\n\treturn &errorMessage{\"Find the bug\"}\n}", "func (v *actorInfoViewType) NewStruct() reform.Struct {\n\treturn new(ActorInfo)\n}", "func newVar(v interface{}) (*interface{}, error) {\n\tx := interface{}(v)\n\treturn &x, nil\n}", "func New(title string, x, y, width, height int) Device { return newDevice(title, x, y, width, height) }", "func New() Go { return Go{} }", "func (*voteR) NewStruct() *voteR {\n\treturn &voteR{}\n}", "func (r *ResUnstructured) newUnstructured(object map[string]interface{}) *unstructured.Unstructured {\n\tu := &unstructured.Unstructured{}\n\tu.Object = object\n\n\tu.SetGroupVersionKind(schema.GroupVersionKind{\n\t\tGroup: r.group,\n\t\tKind: r.kind,\n\t\tVersion: r.version,\n\t})\n\n\tu.SetName(r.name)\n\tu.SetNamespace(r.namespace)\n\treturn u\n}", "func New() Type {\n\treturn Type(0)\n}", "func (*premiumSlotR) NewStruct() *premiumSlotR {\n\treturn &premiumSlotR{}\n}", "func (*filesStorageR) NewStruct() *filesStorageR {\n\treturn &filesStorageR{}\n}", "func (*activityLogR) NewStruct() *activityLogR {\n\treturn &activityLogR{}\n}", "func (*recipeLipidR) NewStruct() *recipeLipidR {\n\treturn &recipeLipidR{}\n}", "func (*channelR) NewStruct() *channelR {\n\treturn &channelR{}\n}", "func (*cmfUserSuperR) NewStruct() *cmfUserSuperR {\n\treturn &cmfUserSuperR{}\n}", "func New(msg string) error {\n\treturn &basic{msg}\n}", "func (v Value) New(args ...interface{}) Value {\n\tpanic(message)\n}", "func (s *internalPointPtrView) New() (PointPtr, error) {\n\tslice, allocErr := s.state.makeSlice(1)\n\tif allocErr != nil {\n\t\treturn PointPtr{}, allocErr\n\t}\n\tptr := PointPtr{ptr: slice.data}\n\treturn ptr, nil\n}", "func (*cmfMusicR) NewStruct() *cmfMusicR {\n\treturn &cmfMusicR{}\n}", "func hackedNew(t reflect.Type) reflect.Value {\n\treturn reflect.New(unhackType(t))\n}", "func New(v interface{}) Record {\n\tt := reflect.TypeOf(v)\n\treturn Record{\n\t\tv: reflect.ValueOf(v),\n\t\tt: t,\n\t\t//\tlen: numExported(t),\n\t}\n}", "func New(value interface{}) interface{} {\n\trv := reflect.ValueOf(value)\n\tif rv.Type().Kind() == reflect.Ptr {\n\t\treturn value\n\t}\n\trp := reflect.New(rv.Type())\n\trp.Elem().Set(rv)\n\treturn rp.Interface()\n}", "func (*tenantR) NewStruct() *tenantR {\n\treturn &tenantR{}\n}", "func (*premiumCodeR) NewStruct() *premiumCodeR {\n\treturn &premiumCodeR{}\n}", "func (*rentalRowerR) NewStruct() *rentalRowerR {\n\treturn &rentalRowerR{}\n}", "func (v *pgUserViewType) NewStruct() reform.Struct {\n\treturn new(pgUser)\n}", "func create() I {\n\treturn B{\n\t\tStruct: A{\n\t\t\tGreeting: \"Hello\",\n\t\t\tMessage: \"translate this\",\n\t\t\tPi: 3.14,\n\t\t},\n\t\tPtr: &A{\n\t\t\tGreeting: \"What's up?\",\n\t\t\tMessage: \"point here\",\n\t\t\tPi: 3.14,\n\t\t},\n\t\tMap: map[string]string{\n\t\t\t\"Test\": \"translate this\",\n\t\t},\n\t\tStructMap: map[string]C{\n\t\t\t\"C\": C{\n\t\t\t\tString: \"deep\",\n\t\t\t},\n\t\t},\n\t\tSlice: []string{\n\t\t\t\"and once more\",\n\t\t},\n\t\tAnswer: 42,\n\t}\n}", "func NewFoo() *Foo {\n return &Foo{}\n}", "func New(v interface{}) (provider.Provider, error) {\n\ts := Spec{}\n\treturn &s, ioutil.Intermarshal(v, &s)\n}", "func (*cmfUserExperienceLogR) NewStruct() *cmfUserExperienceLogR {\n\treturn &cmfUserExperienceLogR{}\n}", "func (*subscriberR) NewStruct() *subscriberR {\n\treturn &subscriberR{}\n}", "func (*peerPropertyR) NewStruct() *peerPropertyR {\n\treturn &peerPropertyR{}\n}" ]
[ "0.6531026", "0.6405301", "0.6293614", "0.6285489", "0.6268683", "0.6236182", "0.61969244", "0.61175734", "0.604844", "0.6025139", "0.60025066", "0.5989801", "0.5977882", "0.5950956", "0.59397024", "0.59170663", "0.59170663", "0.5900451", "0.5890951", "0.5887615", "0.58850825", "0.5875948", "0.58732307", "0.5869682", "0.585509", "0.58426243", "0.5813794", "0.5800923", "0.58003193", "0.5784912", "0.57820773", "0.57731766", "0.572889", "0.5728514", "0.572732", "0.5715505", "0.5690349", "0.5680939", "0.56803346", "0.56556696", "0.5626976", "0.560964", "0.55996585", "0.5591545", "0.55772865", "0.5572816", "0.55725306", "0.5565564", "0.55649465", "0.55600566", "0.5558271", "0.5550653", "0.55482477", "0.55384105", "0.5495883", "0.5494496", "0.54709697", "0.54629797", "0.5453501", "0.5447942", "0.54354024", "0.54347956", "0.543211", "0.54116166", "0.54008377", "0.53998566", "0.5398974", "0.53870916", "0.5386391", "0.5382345", "0.53553385", "0.53520644", "0.534474", "0.5344653", "0.5342268", "0.5339583", "0.53380525", "0.53326243", "0.53262675", "0.5320127", "0.53166544", "0.53096783", "0.5309504", "0.52788705", "0.5275233", "0.5254711", "0.5253998", "0.5253164", "0.52527153", "0.5244816", "0.5242365", "0.52236515", "0.52086604", "0.5206322", "0.51924735", "0.5190762", "0.51807255", "0.51700246", "0.5164814", "0.51618505" ]
0.7363922
0
Name returns name of struct
func (s *Structx) Name() string { return s.value.Type().Name() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (t *typeStruct) Name() string {\n\treturn t.name\n}", "func (t *Struct) String() string { return t.Name }", "func (s *Struct) Name() string {\n\tname := reflect.TypeOf(s.Ref).Elem().String()\n\n\t// strip the package prefix, as we don't want it explicitly in the name\n\tpkgStrip := strings.Split(name, \".\")\n\tif len(pkgStrip) > 1 {\n\t\treturn pkgStrip[1]\n\t}\n\n\treturn pkgStrip[0]\n}", "func (s *StructField) Name() string {\n\treturn s.name\n}", "func (cmd *CmdStruct) Name() string {\n\treturn MessageType(cmd.CmdID).String()\n}", "func (s *MyTestStruct) Name() string {\n\treturn s.field_Name\n}", "func (ds *DynamicStruct) Name() string {\n\treturn ds.name\n}", "func name(v reflect.StructField) string {\n\tif name, ok := v.Tag.Lookup(\"name\"); ok {\n\t\treturn name\n\t}\n\treturn v.Name\n}", "func structName(entry *yang.Entry, forList bool) (string, error) {\n\tname, ok := entry.Annotation[\"structname\"]\n\tif !ok {\n\t\treturn \"\", status.Errorf(codes.NotFound, \"structname not found in annotations\")\n\t}\n\tif entry.IsList() && forList {\n\t\tkeys, err := listKeys(entry)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\t// if the entry is a list and we are targeting the container\n\t\t// NOTE we still need to support composite keys\n\t\treturn fmt.Sprintf(\"map[%s]*%s\", keys[0].Gotype, name), nil\n\t}\n\treturn fmt.Sprintf(\"*%s\", name), nil\n}", "func (t Type) Name() string {\n\treturn schemas[t%EvCount].Name\n}", "func (t *SentryTaggedStruct) GetName() string {\n\treturn \"\"\n}", "func (p Packet) Name() (name string) {\n\t// todo: think of ways to make this not a compiled in hack\n\t// todo: collectd 4 uses different patterns for some plugins\n\t// https://collectd.org/wiki/index.php/V4_to_v5_migration_guide\n\tswitch p.Plugin {\n\tcase \"df\":\n\t\tname = fmt.Sprintf(\"df_%s_%s\", p.PluginInstance, p.TypeInstance)\n\tcase \"interface\":\n\t\tname = fmt.Sprintf(\"%s_%s\", p.Type, p.PluginInstance)\n\tcase \"load\":\n\t\tname = \"load\"\n\tcase \"memory\":\n\t\tname = fmt.Sprintf(\"memory_%s\", p.TypeInstance)\n\tdefault:\n\t\tname = fmt.Sprintf(\"%s_%s_%s_%s\", p.Plugin, p.PluginInstance, p.Type, p.TypeInstance)\n\t}\n\treturn name\n}", "func (f *Field) Name() string {\n\tjsonTag := reflect.StructTag(f.Tag.Value[1 : len(f.Tag.Value)-1]).Get(\"json\") // Delete first and last quotation\n\tjsonTag = strings.Split(jsonTag, \",\")[0] // This can return \"-\"\n\tif jsonTag != \"\" {\n\t\treturn jsonTag\n\t}\n\n\tif f.Names != nil {\n\t\treturn f.Names[0].Name\n\t}\n\n\treturn f.Type.(*ast.Ident).Name\n}", "func (p *GetField) Name() string { return p.name }", "func (p *PropertyGenerator) StructName() string {\n\tif p.asIterator {\n\t\treturn p.Name.CamelName\n\t}\n\treturn fmt.Sprintf(\"%sProperty\", p.Name.CamelName)\n}", "func (t Type) Name() string {\n\treturn t.impl.Name()\n}", "func (t Type) Name() string {\n\treturn t.name\n}", "func (_struct Struct) String() string {\n\treturn fmt.Sprintf(\"struct:%s\", _struct.Name())\n}", "func (t *Type) GetName() string { return t.Name }", "func (u *Union) Name() string { return u.TypeName }", "func (o FieldOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v Field) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func (t *DynamicMessageType) Name() string {\n\treturn t.spec.FullName\n}", "func (o *DatatypeObject) Name() string {\n\treturn o.name\n}", "func Name(v interface{}) string {\n\treturn New(v).Name()\n}", "func (o *Object) Name() string {\n\tif !o.Boundary {\n\t\tif o.ID < 0 || o.ID > 1188 {\n\t\t\treturn \"nil\"\n\t\t}\n\t\treturn ObjectDefs[o.ID].Name\n\t}\n\tif o.ID < 0 || o.ID >= len(BoundaryDefs) {\n\t\treturn \"nil\"\n\t}\n\treturn BoundaryDefs[o.ID].Name\n}", "func (defn *TypeDefinition) Name() *Name {\n\tswitch {\n\tcase defn == nil:\n\t\treturn nil\n\tcase defn.Scalar != nil:\n\t\treturn defn.Scalar.Name\n\tcase defn.Object != nil:\n\t\treturn defn.Object.Name\n\tcase defn.Union != nil:\n\t\treturn defn.Union.Name\n\tcase defn.Enum != nil:\n\t\treturn defn.Enum.Name\n\tcase defn.InputObject != nil:\n\t\treturn defn.InputObject.Name\n\tdefault:\n\t\treturn nil\n\t}\n}", "func (obj *label) Name() string {\n\treturn obj.name\n}", "func (t GoType) Name() string {\n\treturn \"go:\" + t.refType.Name()\n}", "func (nt *Ntuple) Name() string {\n\treturn nt.name\n}", "func (t Scalar) Name() string {\n\treturn strings.Title(t.Type)\n}", "func (p ByName) Name() string { return p.name }", "func (f *Fieldx) Name() string {\n\treturn f.data.Name\n}", "func (op *Options) StructName() string {\n\tname := op.structName\n\tif name == \"\" {\n\t\tname = \"AutoGenerated\"\n\t}\n\treturn name\n}", "func (i Uint8) Name() string {\n\treturn string(i)\n}", "func (t *Table) StructName() string {\n\tif t.structName == \"\" {\n\t\tt.structName = t.Name.ToCamel()\n\t}\n\treturn t.structName\n}", "func (o TypeOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v Type) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func (o TypeOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v Type) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func (obj *object) getStructName(line string) {\n\t/*nested := false\n\tif !strings.Contains(line, \"type \") {\n\t\tnested = true\n\t}*/\n\n\tline = strings.TrimSpace(line)\n\tline = strings.TrimPrefix(strings.TrimSuffix(line, \"{\"), \"type\")\n\tline = strings.TrimSpace(line)\n\tobj.Name = strings.TrimSpace(strings.TrimSuffix(line, \"struct\"))\n\tif strings.Contains(obj.Name, \"[]\") {\n\t\tobj.Name = strings.TrimSpace(strings.TrimSuffix(obj.Name, \"[]\"))\n\t}\n\tobj.Tp = obj.Name\n\tobj.JsonKey = obj.Name\n\t/*if nested {\n\t\tobj.CommonFileds = append(obj.CommonFileds, &field{JsonKey: obj.Name, Tp: obj.Name})\n\t}*/\n}", "func (v Value) Name() (string, error) {\n\tif v.typ != Name {\n\t\treturn \"\", v.newError(\"%s is not an object name\", v.Raw())\n\t}\n\treturn v.str, nil\n}", "func (f BinaryField) GetName() string {\n\treturn f.name\n}", "func GetNameFromStruct(u interface{}) string {\n\tvar result = ReturnValue{CustomStruct: u}\n\n\t//fmt.Println(result)\n\n\tmsg, ok := result.CustomStruct.(NameOnly)\n\tif ok {\n\t\t//fmt.Printf(\"Message1 is %s\\n\", msg.Name)\n\t\treturn msg.Name\n\t} else {\n\t\treturn \"\"\n\t}\n}", "func (ti *TypeInfo) Name() string {\n\tif ti == nil {\n\t\treturn \"\"\n\t}\n\tif ti.GenDecl == nil {\n\t\treturn \"\"\n\t}\n\tif len(ti.GenDecl.Specs) < 1 {\n\t\treturn \"\"\n\t}\n\tts, ok := ti.GenDecl.Specs[0].(*ast.TypeSpec)\n\tif !ok || ts == nil {\n\t\treturn \"\"\n\t}\n\tif ts.Name == nil {\n\t\treturn \"\"\n\t}\n\treturn ts.Name.Name\n}", "func (at AttributeType) Name() string {\n\tswitch at {\n\tcase AttributeTypeStandardInformation:\n\t\treturn \"$STANDARD_INFORMATION\"\n\tcase AttributeTypeAttributeList:\n\t\treturn \"$ATTRIBUTE_LIST\"\n\tcase AttributeTypeFileName:\n\t\treturn \"$FILE_NAME\"\n\tcase AttributeTypeObjectId:\n\t\treturn \"$OBJECT_ID\"\n\tcase AttributeTypeSecurityDescriptor:\n\t\treturn \"$SECURITY_DESCRIPTOR\"\n\tcase AttributeTypeVolumeName:\n\t\treturn \"$VOLUME_NAME\"\n\tcase AttributeTypeVolumeInformation:\n\t\treturn \"$VOLUME_INFORMATION\"\n\tcase AttributeTypeData:\n\t\treturn \"$DATA\"\n\tcase AttributeTypeIndexRoot:\n\t\treturn \"$INDEX_ROOT\"\n\tcase AttributeTypeIndexAllocation:\n\t\treturn \"$INDEX_ALLOCATION\"\n\tcase AttributeTypeBitmap:\n\t\treturn \"$BITMAP\"\n\tcase AttributeTypeReparsePoint:\n\t\treturn \"$REPARSE_POINT\"\n\tcase AttributeTypeEAInformation:\n\t\treturn \"$EA_INFORMATION\"\n\tcase AttributeTypeEA:\n\t\treturn \"$EA\"\n\tcase AttributeTypePropertySet:\n\t\treturn \"$PROPERTY_SET\"\n\tcase AttributeTypeLoggedUtilityStream:\n\t\treturn \"$LOGGED_UTILITY_STREAM\"\n\t}\n\treturn \"unknown\"\n}", "func (k *Kind) Name() string {\n\treturn \"team\"\n}", "func (*Object) Name() string { return \"object\" }", "func (i Uint64) Name() string {\n\treturn string(i)\n}", "func (e *EDNS) Name() string { return name }", "func (c *STableField) Name() string {\n\tif len(c.alias) > 0 {\n\t\treturn c.alias\n\t}\n\treturn c.spec.Name()\n}", "func (n NamedComponents) Name() string {\n\treturn n.uniqueComponent\n}", "func (sh SubdirectoryHeader) Name() string {\n\treturn string(sh.SubdirectoryName[0 : sh.TypeAndNameLength&0xf])\n}", "func (ifce *Interface) Name() string {\n\treturn ifce.name\n}", "func (ifce *Interface) Name() string {\n\treturn ifce.name\n}", "func (object *Object) Name() string {\n\treturn object.objectType\n}", "func (r *RepoStruct) Name() string {\n\tif r == nil {\n\t\treturn \"\"\n\t}\n\treturn r.name\n}", "func (r *PrivateVirtualInterface) Name() pulumi.StringOutput {\n\treturn (pulumi.StringOutput)(r.s.State[\"name\"])\n}", "func (e *errorT) Name() (string, bool) {\n\tif e.class == nil {\n\t\treturn \"\", false\n\t}\n\treturn string(*e.class), true\n}", "func (t *TypeSpecDef) Name() string {\n\tif t.TypeSpec != nil {\n\t\treturn t.TypeSpec.Name.Name\n\t}\n\n\treturn \"\"\n}", "func (field Field) Name() string {\n\tif len(field.Names) > 0 {\n\t\treturn field.Names[0].String()\n\t}\n\n\t// The field has no name, so we use Type name as the field name.\n\treturn itemTypeName(field.TypeValue.Type).Name\n}", "func (r *Root) Name() string { return \"\" }", "func (d *Driver) Name() string { return d.name }", "func (*BytesSchema) GetName() string {\n\treturn typeBytes\n}", "func (t *Type) Name() (string, error) {\n\tv := reflect.ValueOf(t.ctyType).MethodByName(\"GoString\")\n\tif !v.IsValid() {\n\t\treturn \"\", fmt.Errorf(\"Faild to find GoString(): %#v\", t)\n\t}\n\n\tnv := v.Call([]reflect.Value{})\n\tif len(nv) == 0 {\n\t\treturn \"\", fmt.Errorf(\"Faild to call GoString(): %#v\", v)\n\t}\n\n\tgoString := nv[0].String()\n\t// drop `cty.` prefix for simplicity. (e.g. cty.String => String)\n\tname := strings.Replace(goString, \"cty.\", \"\", -1)\n\n\treturn name, nil\n}", "func (def TypeDefinition) Name() InternalTypeName {\n\treturn def.name\n}", "func (d *Descriptor) Name() string {\n\treturn knownDescriptors[d.uuid.String()].Name\n}", "func (ts *STableSpec) Name() string {\n\treturn ts.name\n}", "func (obj *labelDeclaration) Name() string {\n\treturn obj.name\n}", "func (t *TypeMatcher) GetName() string { return t.Name }", "func (g *generator) Name() string {\n\treturn g.typeName\n}", "func (c *Config) Name(n int) string {\n\treturn fmt.Sprintf(\"%03d.%s\", n, c.Type)\n}", "func (p Primitive) Name() string {\n\tswitch p {\n\tcase Boolean:\n\t\treturn \"boolean\"\n\tcase Int:\n\t\treturn \"int\"\n\tcase Int32:\n\t\treturn \"int32\"\n\tcase Int64:\n\t\treturn \"int64\"\n\tcase UInt:\n\t\treturn \"uint\"\n\tcase UInt32:\n\t\treturn \"uint32\"\n\tcase UInt64:\n\t\treturn \"uint64\"\n\tcase Float32:\n\t\treturn \"float32\"\n\tcase Float64:\n\t\treturn \"float64\"\n\tcase String:\n\t\treturn \"string\"\n\tcase Bytes:\n\t\treturn \"bytes\"\n\tcase Any:\n\t\treturn \"any\"\n\tdefault:\n\t\tpanic(\"unknown primitive type\") // bug\n\t}\n}", "func (o ApiOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v Api) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func (b Binding) Name() string {\n\tbb := b.base()\n\treturn bb.interfaceName + \".\" + bb.elemName\n}", "func (i *Interface) Name() string {\n\treturn name\n}", "func (*UnionSchema) GetName() string {\n\treturn typeUnion\n}", "func (o Outside) Name() string {\n\treturn polName\n}", "func (d *Descriptor) Name() string {\n\treturn d.name\n}", "func (i *Index) Name() string { return i.name }", "func (o LogDescriptorOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v LogDescriptor) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func (v *VCard) Name() string {\n\treturn v.getFirstPropertySingleString(\"fn\")\n}", "func (n *Node) Name() string { return n.notNil().name }", "func (t *TypeStub) Name() string {\n\treturn t.typeName\n}", "func (obj *identity) Name() string {\n\treturn obj.name\n}", "func (f *Field) Name() string {\n\treturn f.field.Name\n}", "func (o ElastigroupSignalOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ElastigroupSignal) string { return v.Name }).(pulumi.StringOutput)\n}", "func (s *Structured) GetName() string {\n\treturn s.cloudEvent.Source\n}", "func (b *BaseType) Name() string {\n\treturn b.name\n}", "func (i *Interface) Name() string {\n\treturn i.name\n}", "func (s *StateTemplate)Name() string {\n\treturn s.op\n}", "func (f frame) name() string {\n\tfn := runtime.FuncForPC(f.pc())\n\tif fn == nil {\n\t\treturn \"unknown\"\n\t}\n\treturn fn.Name()\n}", "func (t *Type) GetName() string {\n\treturn formatGoName(t.Name)\n}", "func (f Frame) name() string {\n\tfn := runtime.FuncForPC(f.pc())\n\tif fn == nil {\n\t\treturn \"unknown\"\n\t}\n\treturn fn.Name()\n}", "func (header *GenericHeader) Name() string {\n\treturn header.HeaderName\n}", "func (ct ContentType) Name() string {\n\treturn string(ct)\n}", "func (ct ContentType) Name() string {\n\treturn string(ct)\n}", "func (o MethodOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v Method) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func (v *templateTableType) Name() string {\n\treturn v.s.SQLName\n}", "func (this *channelMeterStruct) name() string {\n\tname := this.channelName\n\treturn name\n}", "func (v *Vfs) Name() string {\n\tvfs := (*C.sqlite3_vfs)(unsafe.Pointer(v))\n\n\treturn C.GoString(vfs.zName)\n}", "func (o FleetMetricAggregationTypePtrOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *FleetMetricAggregationType) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.Name\n\t}).(pulumi.StringPtrOutput)\n}", "func (p Parameter) Name() string {\n\treturn string(p)\n}" ]
[ "0.78337574", "0.76747423", "0.731499", "0.7308054", "0.7260499", "0.7234671", "0.72284794", "0.71106577", "0.70448375", "0.6989433", "0.6928384", "0.6928275", "0.6908289", "0.6873566", "0.6862104", "0.6840299", "0.6824419", "0.6818603", "0.6763319", "0.6750533", "0.6737451", "0.67150337", "0.670723", "0.66797554", "0.6678336", "0.66729975", "0.6672897", "0.6650884", "0.66252357", "0.6588948", "0.65831774", "0.65749913", "0.6558103", "0.6536164", "0.65229315", "0.65209454", "0.65209454", "0.6513249", "0.65104645", "0.64976573", "0.6495438", "0.6494976", "0.649261", "0.6485848", "0.64763486", "0.64553314", "0.6428283", "0.64251184", "0.64235675", "0.6408917", "0.6405388", "0.6405388", "0.6402905", "0.63978153", "0.63773525", "0.63732433", "0.63706625", "0.63659996", "0.63600343", "0.6357312", "0.6356598", "0.63563013", "0.6351947", "0.63427216", "0.6333539", "0.63331354", "0.63311434", "0.63263845", "0.63117737", "0.6303615", "0.6299807", "0.6288663", "0.62863564", "0.62604403", "0.6245975", "0.6225102", "0.6222994", "0.62228847", "0.6220404", "0.62148607", "0.62028474", "0.62020373", "0.6201727", "0.61947405", "0.61853147", "0.6184643", "0.61823046", "0.6179448", "0.61686075", "0.61655664", "0.61552185", "0.61509323", "0.6149114", "0.6149114", "0.61460537", "0.61430407", "0.6141608", "0.6141594", "0.61365795", "0.613385" ]
0.7607495
2
Struct returns nested struct with name, it panic if not field
func (s *Structx) Struct(name string) *Structx { f, ok := s.Field(name) if !ok { panic(ErrNotField) } return New(f.Value()) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (field Field) Struct() *Struct {\n\treturn field.Parent.Parent.Parent.StructByName(field.Field.ItemTypeName().Name)\n}", "func (p Package) Struct(strct string) Struct {\n\treturn Struct{p, strct}\n}", "func (obj *object) getStructName(line string) {\n\t/*nested := false\n\tif !strings.Contains(line, \"type \") {\n\t\tnested = true\n\t}*/\n\n\tline = strings.TrimSpace(line)\n\tline = strings.TrimPrefix(strings.TrimSuffix(line, \"{\"), \"type\")\n\tline = strings.TrimSpace(line)\n\tobj.Name = strings.TrimSpace(strings.TrimSuffix(line, \"struct\"))\n\tif strings.Contains(obj.Name, \"[]\") {\n\t\tobj.Name = strings.TrimSpace(strings.TrimSuffix(obj.Name, \"[]\"))\n\t}\n\tobj.Tp = obj.Name\n\tobj.JsonKey = obj.Name\n\t/*if nested {\n\t\tobj.CommonFileds = append(obj.CommonFileds, &field{JsonKey: obj.Name, Tp: obj.Name})\n\t}*/\n}", "func (s *StructField) Field(name string) (*StructField, error) {\n\treturn Field(s.Value(), name)\n}", "func createStruct(r io.ReadSeeker) string {\n\ttagType := readByte(r)\n\tname := toPascalCase(getKey(r))\n\ttypeStr := getFieldType(r, tagType)\n\n\treturn fmt.Sprintf(\"type %s %s\", name, typeStr)\n}", "func structFieldByName(typ reflect.Type, name string) (*reflect.StructField, bool) {\n\tvar field *reflect.StructField\n\n\tfieldNames := chainedFieldNameToFieldNames(name)\n\tif len(fieldNames) == 0 {\n\t\treturn nil, false\n\t}\n\n\tfor i, fieldName := range fieldNames {\n\t\tf, ok := typ.FieldByName(fieldName)\n\t\tif !ok {\n\t\t\treturn nil, false\n\t\t}\n\t\tfield = &f\n\n\t\tif i == len(fieldNames)-1 {\n\t\t\tbreak\n\t\t}\n\n\t\ttyp = f.Type\n\t\tif typ.Kind() == reflect.Ptr {\n\t\t\ttyp = typ.Elem()\n\t\t}\n\t}\n\n\treturn field, true\n}", "func compileField(sf reflect.StructField, name string) interface{} {\n\tf := field{sField: sf.Index[0]}\n\n\tf.name = []byte(name)\n\n\tswitch sf.Type.Kind() {\n\tcase reflect.Struct:\n\t\treturn fieldStruct{f.sField, f.name, compileStruct(sf.Type)}\n\tcase reflect.Bool:\n\t\tf.write = encodeBool\n\t\tf.read = decodeBool\n\t\tf.requiredType = 1\n\tcase reflect.Int8:\n\t\tf.write = encodeInt8\n\t\tf.read = decodeInt8\n\t\tf.requiredType = 1\n\tcase reflect.Int16:\n\t\tf.write = encodeInt16\n\t\tf.read = decodeInt16\n\t\tf.requiredType = 2\n\tcase reflect.Int32:\n\t\tf.write = encodeInt32\n\t\tf.read = decodeInt32\n\t\tf.requiredType = 3\n\tcase reflect.Int64:\n\t\tf.write = encodeInt64\n\t\tf.read = decodeInt64\n\t\tf.requiredType = 4\n\tcase reflect.String:\n\t\tf.write = encodeString\n\t\tf.read = decodeString\n\t\tf.requiredType = 8\n\tcase reflect.Map:\n\t\tf.requiredType = 10\n\t\telem := sf.Type.Elem()\n\t\tvar elemField interface{}\n\t\tname := \"map:\" + sf.Name\n\t\tif elem.Kind() != reflect.Interface {\n\t\t\telemField = compileField(reflect.StructField{Type: elem, Index: []int{0}}, name)\n\t\t}\n\t\tf.write = func(w io.Writer, en *msgEncoder, fi reflect.Value) error {\n\t\t\tkeys := fi.MapKeys()\n\t\t\tfor _, key := range keys {\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tv := fi.MapIndex(key)\n\t\t\t\t\twritePrefix(en, w, []byte(key.String()), f.requiredType)\n\t\t\t\t\terr := f.write(w, en, v)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif elemField == nil {\n\t\t\t\t\t\tv := fi.MapIndex(key).Elem()\n\t\t\t\t\t\ttemp := compileField(reflect.StructField{Type: v.Type(), Index: []int{0}}, \"\")\n\t\t\t\t\t\tif f, ok := temp.(field); ok {\n\t\t\t\t\t\t\twritePrefix(en, w, []byte(key.String()), f.requiredType)\n\t\t\t\t\t\t\terr := f.write(w, en, v)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twritePrefix(en, w, []byte(key.String()), 10)\n\t\t\t\t\t\t\tfs := temp.(fieldStruct)\n\t\t\t\t\t\t\terr := write(w, en, fs.m, v)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\twritePrefix(en, w, []byte(key.String()), 10)\n\t\t\t\t\t\tfs := elemField.(fieldStruct)\n\t\t\t\t\t\tv := fi.MapIndex(key)\n\t\t\t\t\t\terr := write(w, en, fs.m, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t\tbs := en.b[:1]\n\t\t\tbs[0] = 0\n\t\t\t_, err := w.Write(bs)\n\t\t\treturn err\n\t\t}\n\t\tf.read = func(r io.Reader, de *msgDecoder, fi reflect.Value) error {\n\n\t\t\tma := reflect.MakeMap(sf.Type)\n\n\t\t\tname, t, err := readPrefix(r, de)\n\t\t\tfor ; t != 0; name, t, err = readPrefix(r, de) {\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tkeyVal := reflect.ValueOf(name)\n\n\t\t\t\tvar val reflect.Value\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tval = reflect.New(elem)\n\t\t\t\t\terr := f.read(r, de, val)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif elemField == nil {\n\t\t\t\t\t\tv, err := fallbackRead(r, de)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t\tval = reflect.ValueOf(v)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tval = reflect.New(elem)\n\t\t\t\t\t\tfs := elemField.(fieldStruct)\n\t\t\t\t\t\terr := read(r, de, fs.m, val)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tma.SetMapIndex(keyVal, val)\n\t\t\t}\n\t\t\tfi.Set(ma)\n\t\t\treturn nil\n\t\t}\n\tcase reflect.Slice:\n\t\tf.requiredType = 9\n\t\telem := sf.Type.Elem()\n\t\tswitch elem.Kind() {\n\t\tcase reflect.Uint8: //Short-cut for byte arrays\n\t\t\tf.requiredType = 7\n\t\t\tf.write = func(w io.Writer, en *msgEncoder, fi reflect.Value) error {\n\t\t\t\tl := fi.Len()\n\t\t\t\tbs := en.b[:4]\n\t\t\t\tbinary.BigEndian.PutUint32(bs, uint32(l))\n\t\t\t\t_, err := w.Write(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\t_, err = w.Write(fi.Bytes())\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tf.read = func(r io.Reader, de *msgDecoder, fi reflect.Value) error {\n\t\t\t\tbs := de.b[:4]\n\t\t\t\t_, err := r.Read(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tl := binary.BigEndian.Uint32(bs)\n\t\t\t\tout := make([]byte, l)\n\t\t\t\t_, err = r.Read(out)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tfi.SetBytes(out)\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase reflect.Int32: //Short-cut for int32 arrays\n\t\t\tf.requiredType = 11\n\t\t\tf.write = func(w io.Writer, en *msgEncoder, fi reflect.Value) error {\n\t\t\t\tl := fi.Len()\n\t\t\t\tbs := en.b[:4]\n\t\t\t\tbinary.BigEndian.PutUint32(bs, uint32(l))\n\t\t\t\t_, err := w.Write(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tdata := fi.Interface().([]int32)\n\t\t\t\tfor i := range data {\n\t\t\t\t\tbinary.BigEndian.PutUint32(bs, uint32(data[i]))\n\t\t\t\t\t_, err := w.Write(bs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tf.read = func(r io.Reader, de *msgDecoder, fi reflect.Value) error {\n\t\t\t\tbs := de.b[:4]\n\t\t\t\t_, err := r.Read(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tl := binary.BigEndian.Uint32(bs)\n\t\t\t\tout := make([]int32, l)\n\t\t\t\tfor i := range out {\n\t\t\t\t\t_, err := r.Read(bs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tout[i] = int32(binary.BigEndian.Uint32(bs))\n\t\t\t\t}\n\t\t\t\tfi.Set(reflect.ValueOf(out))\n\t\t\t\treturn nil\n\t\t\t}\n\t\tdefault:\n\t\t\tname := \"slice:\" + sf.Name\n\t\t\telemField := compileField(reflect.StructField{Type: elem, Index: []int{0}}, name)\n\t\t\tf.write = func(w io.Writer, en *msgEncoder, fi reflect.Value) error {\n\t\t\t\tl := fi.Len()\n\t\t\t\tbs := en.b[:5]\n\t\t\t\tbinary.BigEndian.PutUint32(bs[1:], uint32(l))\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tbs[0] = f.requiredType\n\t\t\t\t} else {\n\t\t\t\t\tbs[0] = 10\n\t\t\t\t}\n\t\t\t\t_, err := w.Write(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\t\t\tv := fi.Index(i)\n\t\t\t\t\t\terr := f.write(w, en, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tf := elemField.(fieldStruct)\n\t\t\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\t\t\tv := fi.Index(i)\n\t\t\t\t\t\terr := write(w, en, f.m, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tf.read = func(r io.Reader, de *msgDecoder, fi reflect.Value) error {\n\t\t\t\tbs := de.b[:5]\n\t\t\t\t_, err := r.Read(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tif bs[0] != f.requiredType {\n\t\t\t\t\t\treturn ErrorIncorrectType\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif bs[0] != 10 {\n\t\t\t\t\t\treturn ErrorIncorrectType\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tl := int(binary.BigEndian.Uint32(bs[1:]))\n\t\t\t\tval := reflect.MakeSlice(sf.Type, l, l)\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\t\t\tv := val.Index(i)\n\t\t\t\t\t\terr := f.read(r, de, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tf := elemField.(fieldStruct)\n\t\t\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\t\t\tv := val.Index(i)\n\t\t\t\t\t\terr := read(r, de, f.m, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfi.Set(val)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\tcase reflect.Float32:\n\t\tf.requiredType = 5\n\t\tf.write = encodeFloat32\n\t\tf.read = decodeFloat32\n\tcase reflect.Float64:\n\t\tf.requiredType = 6\n\t\tf.write = encodeFloat64\n\t\tf.read = decodeFloat64\n\tdefault:\n\t\tpanic(fmt.Errorf(\"Unhandled type %s for %s\", sf.Type.Kind().String(), sf.Name))\n\t}\n\treturn f\n}", "func (x *StructLevelTerseStruct) DefaultGetStructField() *MyStruct {\n if !x.IsSetStructField() {\n return NewMyStruct()\n }\n return x.StructField\n}", "func (x *FieldLevelTerseStruct) DefaultGetStructField() *MyStruct {\n if !x.IsSetStructField() {\n return NewMyStruct()\n }\n return x.StructField\n}", "func (p *Program) GetStruct(name string) *Struct {\n\tif name == \"\" {\n\t\treturn nil\n\t}\n\n\t// That allow to get struct from pointer type\n\tif last := len(name) - 1; name[last] == '*' {\n\t\tname = name[:last]\n\t}\n\n\tname = strings.TrimSpace(name)\n\n\tres, ok := p.Structs[name]\n\tif ok {\n\t\treturn res\n\t}\n\tres, ok = p.Unions[name]\n\tif ok {\n\t\treturn res\n\t}\n\n\treturn nil\n}", "func NestedField(obj *unstructured.Unstructured, name, path string) (interface{}, bool, error) {\n\tj := jsonpath.New(name).AllowMissingKeys(true)\n\ttemplate := fmt.Sprintf(\"{%s}\", path)\n\terr := j.Parse(template)\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\tresults, err := j.FindResults(obj.UnstructuredContent())\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\tif len(results) == 0 || len(results[0]) == 0 {\n\t\treturn nil, false, nil\n\t}\n\t// The input path refers to a unique field, we can assume to have only one result or none.\n\tvalue := results[0][0].Interface()\n\treturn value, true, nil\n}", "func (x *FieldLevelTerseStruct) DefaultGetTerseStructField() *MyStruct {\n if !x.IsSetTerseStructField() {\n return NewMyStruct()\n }\n return x.TerseStructField\n}", "func (pkg *Package) StructByName(structName string) *Struct {\n\tfor _, file := range pkg.Files {\n\t\tif _struct, ok := file.Structs[structName]; ok {\n\t\t\treturn _struct\n\t\t}\n\t}\n\n\treturn nil\n}", "func (sb *schemaBuilder) buildStruct(typ reflect.Type) error {\n\tif sb.types[typ] != nil {\n\t\treturn nil\n\t}\n\n\tif typ == unionType {\n\t\treturn fmt.Errorf(\"schemabuilder.Union can only be used as an embedded anonymous non-pointer struct\")\n\t}\n\n\tif hasUnionMarkerEmbedded(typ) {\n\t\treturn sb.buildUnionStruct(typ)\n\t} else if hasInterfaceMarkerEmbedded(typ) {\n\t\treturn sb.buildInterfaceStruct(typ)\n\t}\n\tvar name string\n\tvar description string\n\tvar methods Methods\n\tvar objectKey string\n\tif object, ok := sb.objects[typ]; ok {\n\t\tname = object.Name\n\t\tdescription = object.Description\n\t\tmethods = object.Methods\n\t\tobjectKey = object.key\n\t} else {\n\t\tif typ.Name() != \"query\" && typ.Name() != \"mutation\" && typ.Name() != \"Subscription\" {\n\t\t\treturn fmt.Errorf(\"%s not registered as object\", typ.Name())\n\t\t}\n\t}\n\n\tif name == \"\" {\n\t\tname = typ.Name()\n\t\tif name == \"\" {\n\t\t\treturn fmt.Errorf(\"bad type %s: should have a name\", typ)\n\t\t}\n\t}\n\n\tobject := &graphql.Object{\n\t\tName: name,\n\t\tDescription: description,\n\t\tFields: make(map[string]*graphql.Field),\n\t\tInterfaces: make(map[string]*graphql.Interface),\n\t}\n\tsb.types[typ] = object\n\n\t// for i := 0; i < typ.NumField(); i++ {\n\t// \tfield := typ.Field(i)\n\t// \tfieldInfo, err := parseGraphQLFieldInfo(field)\n\t// \tif err != nil {\n\t// \t\treturn fmt.Errorf(\"bad type %s: %s\", typ, fieldInfo.Name)\n\t// \t}\n\t// \tif fieldInfo.Skipped {\n\t// \t\tcontinue\n\t// \t}\n\n\t// \t//No need for this as struct are generated from proto\n\t// \tif _, ok := object.Fields[fieldInfo.Name]; ok {\n\t// \t\treturn fmt.Errorf(\"bad type %s: two fields named %s\", typ, fieldInfo.Name)\n\t// \t}\n\n\t// \tbuilt, err := sb.buildField(field)\n\t// \tif err != nil {\n\t// \t\treturn fmt.Errorf(\"bad field %s on type %s: %s\", fieldInfo.Name, typ, err)\n\t// \t}\n\t// \tobject.Fields[fieldInfo.Name] = built\n\t// \tif fieldInfo.KeyField {\n\t// \t\tif object.KeyField != nil {\n\t// \t\t\treturn fmt.Errorf(\"bad type %s: multiple key fields\", typ)\n\t// \t\t}\n\t// \t\tif !isScalarType(built.Type) {\n\t// \t\t\treturn fmt.Errorf(\"bad type %s: key type must be scalar, got %T\", typ, built.Type)\n\t// \t\t}\n\t// \t\tobject.KeyField = built\n\t// \t}\n\t// }\n\n\tvar names []string\n\tfor name := range methods {\n\t\tnames = append(names, name)\n\t}\n\tsort.Strings(names)\n\n\tfor _, name := range names {\n\t\tmethod := methods[name]\n\n\t\t// if method.Batch {\n\t\t// \tbatchField, err := sb.buildBatchFunctionWithFallback(typ, method)\n\t\t// \tif err != nil {\n\t\t// \t\treturn err\n\t\t// \t}\n\t\t// \tobject.Fields[name] = batchField\n\t\t// \tcontinue\n\t\t// }\n\n\t\tbuilt, err := sb.buildFunction(typ, method)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"bad method %s on type %s: %s\", name, typ, err)\n\t\t}\n\t\tobject.Fields[name] = built\n\t}\n\n\tif objectKey != \"\" {\n\t\tkeyPtr, ok := object.Fields[objectKey]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"key field doesn't exist on object\")\n\t\t}\n\n\t\tif !isTypeScalar(keyPtr.Type) {\n\t\t\treturn fmt.Errorf(\"bad type %s: key type must be scalar, got %s\", typ, keyPtr.Type.String())\n\t\t}\n\t\tobject.KeyField = keyPtr\n\t}\n\n\treturn nil\n}", "func Struct(v interface{}, name string) *Structx {\n\treturn New(v).Struct(name)\n}", "func Field(v reflect.StructField) (name string, mapped bool) {\n\tns := v.Tag.Get(\"ns\")\n\tif ns != \"\" {\n\t\tmapped = true\n\t\tname = ns\n\t\treturn\n\t}\n\tname = v.Name\n\treturn\n}", "func (k *key) Struct() *key {\n\treturn k\n}", "func (fields List) Get(name string) Field {\n\tvar isj bool\n\tvar jname string\n\tvar jpath string\n\tdot := strings.IndexByte(name, '.')\n\tif dot != -1 {\n\t\tisj = true\n\t\tjname = name[:dot]\n\t\tjpath = name[dot+1:]\n\t}\n\tb := ptob(fields.p)\n\tvar i int\n\tfor {\n\t\t// read the fname\n\t\tvar fname string\n\t\tx, n := uvarint(b[i:])\n\t\tif n == 0 {\n\t\t\tbreak\n\t\t}\n\t\tif useSharedNames {\n\t\t\tfname = sstring.Load(x)\n\t\t\ti += n\n\t\t} else {\n\t\t\tfname = btoa(b[i+n : i+n+x])\n\t\t\ti += n + x\n\t\t}\n\t\tkind := Kind(b[i])\n\t\ti++\n\t\tvar data string\n\t\tif datakind(kind) {\n\t\t\tx, n = uvarint(b[i:])\n\t\t\tdata = btoa(b[i+n : i+n+x])\n\t\t\ti += n + x\n\t\t}\n\t\tif kind == JSON && isj {\n\t\t\tif jname < fname {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif fname == jname {\n\t\t\t\tres := gjson.Get(data, jpath)\n\t\t\t\tif res.Exists() {\n\t\t\t\t\treturn bfield(name, Kind(res.Type), res.String())\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif name < fname {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif fname == name {\n\t\t\t\treturn bfield(name, kind, data)\n\t\t\t}\n\t\t}\n\t}\n\treturn ZeroField\n}", "func compileStruct(t reflect.Type) map[string]interface{} {\n\tfs := map[string]interface{}{}\n\tcount := t.NumField()\n\tfor i := 0; i < count; i++ {\n\t\tf := t.Field(i)\n\t\tvar name string\n\t\tif !f.Anonymous {\n\t\t\tname = f.Name\n\t\t\tif tName := f.Tag.Get(\"nbt\"); len(tName) > 0 {\n\t\t\t\tname = tName\n\t\t\t}\n\t\t\tif name == \"ignore\" || f.Tag.Get(\"ignore\") == \"true\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t} else {\n\t\t\tname = f.Type.Name()\n\t\t\tif tName := f.Tag.Get(\"nbt\"); len(tName) > 0 {\n\t\t\t\tname = tName\n\t\t\t}\n\t\t\tif name == \"ignore\" || f.Tag.Get(\"ignore\") == \"true\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tfs[name] = compileField(f, name)\n\t}\n\treturn fs\n}", "func fieldArgNamesStruct(obj any, path string, nest bool, allArgs map[string]reflect.Value) {\n\tif kit.IfaceIsNil(obj) {\n\t\treturn\n\t}\n\tov := reflect.ValueOf(obj)\n\tif ov.Kind() == reflect.Pointer && ov.IsNil() {\n\t\treturn\n\t}\n\tval := kit.NonPtrValue(ov)\n\ttyp := val.Type()\n\tfor i := 0; i < typ.NumField(); i++ {\n\t\tf := typ.Field(i)\n\t\tfv := val.Field(i)\n\t\tif kit.NonPtrType(f.Type).Kind() == reflect.Struct {\n\t\t\tnwPath := f.Name\n\t\t\tif path != \"\" {\n\t\t\t\tnwPath = path + \".\" + nwPath\n\t\t\t}\n\t\t\tnwNest := nest\n\t\t\tif !nwNest {\n\t\t\t\tneststr, ok := f.Tag.Lookup(\"nest\")\n\t\t\t\tif ok && (neststr == \"+\" || neststr == \"true\") {\n\t\t\t\t\tnwNest = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tfieldArgNamesStruct(kit.PtrValue(fv).Interface(), nwPath, nwNest, allArgs)\n\t\t\tcontinue\n\t\t}\n\t\tpval := kit.PtrValue(fv)\n\t\taddAllCases(f.Name, path, pval, allArgs)\n\t\tif f.Type.Kind() == reflect.Bool {\n\t\t\taddAllCases(\"No\"+f.Name, path, pval, allArgs)\n\t\t}\n\t\t// now process adding non-nested version of field\n\t\tif path == \"\" || nest {\n\t\t\tcontinue\n\t\t}\n\t\tneststr, ok := f.Tag.Lookup(\"nest\")\n\t\tif ok && (neststr == \"+\" || neststr == \"true\") {\n\t\t\tcontinue\n\t\t}\n\t\tif _, has := allArgs[f.Name]; has {\n\t\t\tmpi.Printf(\"econfig Field: %s.%s cannot be added as a non-nested %s arg because it has already been registered -- add 'nest:'+'' field tag to the one you want to keep only as a nested arg with path, to eliminate this message\\n\", path, f.Name, f.Name)\n\t\t\tcontinue\n\t\t}\n\t\taddAllCases(f.Name, \"\", pval, allArgs)\n\t\tif f.Type.Kind() == reflect.Bool {\n\t\t\taddAllCases(\"No\"+f.Name, \"\", pval, allArgs)\n\t\t}\n\t}\n}", "func (d *Data) Struct() *types.Struct {\n\tst := &types.Struct{\n\t\tFields: map[string]*types.Value{\n\t\t\tqueryField: d.Query.Value(),\n\t\t\ttokenField: toString(d.Token),\n\t\t},\n\t}\n\tif d.ServerURL != nil {\n\t\tst.Fields[serverURLField] = toString(d.ServerURL.String())\n\t}\n\tif d.MultiFrame {\n\t\tst.Fields[multiFrameField] = toBool(d.MultiFrame)\n\t}\n\tif d.MultiFrameWindowSize > 0 {\n\t\tst.Fields[multiFrameWindowSize] = toFloat64(float64(d.MultiFrameWindowSize))\n\t}\n\tif d.MultiFrameWindowAge > 0 {\n\t\tst.Fields[multiFrameWindowAge] = toFloat64(float64(d.MultiFrameWindowAge / time.Minute))\n\t}\n\treturn st\n}", "func GetStructFieldByName(st interface{}, fieldName string) interface{} {\n\tstv := reflect.ValueOf(st)\n\tif IsPtr(st) {\n\t\tstv = stv.Elem()\n\t}\n\n\tv := stv.FieldByName(fieldName)\n\tif !v.IsValid() {\n\t\treturn nil\n\t}\n\n\tswitch v.Kind() {\n\tcase reflect.Chan,\n\t\treflect.Func,\n\t\treflect.Slice,\n\t\treflect.Array,\n\t\treflect.Interface,\n\t\treflect.Ptr,\n\t\treflect.Map:\n\t\tif v.IsNil() {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\treturn v.Interface()\n}", "func getTag(t *reflect.Type, field string, tagName string) {\n var (\n tagVal string\n err error\n )\n fieldVal, ok := (*t).FieldByName(field)\n if ok {\n tagVal = fieldVal.Tag.Get(tagName)\n } else {\n err = errors.New(\"no field named:\" + field)\n }\n\n fmt.Printf(\"get struct[%s] tag[%s]: %s, error:%v\\n\", field, tagName, tagVal, err)\n fmt.Println(\"\")\n}", "func (w StructTemplater) Struct(reflect.Value) error {\n\treturn nil\n}", "func (s *Structx) Field(name string) (*Fieldx, bool) {\n\tf, ok := s.value.Type().FieldByName(name)\n\tif !ok {\n\t\treturn nil, false\n\t}\n\n\tff := &Fieldx{\n\t\tdata: f,\n\t\tvalue: s.value.FieldByName(name),\n\t}\n\n\treturn ff, true\n}", "func structsTest() {\n\ttype Data struct {\n\t\tname int\n\t\taddress int\n\t\tphone int\n\t}\n\n\tvar d1 Data\n\td1.name = 1\n\tfmt.Println(d1)\n\td2 := Data{1, 2, 3} //literal declaration, can also explicitly name with {field:value}\n\t_ = d2\n}", "func Structures() {\r\n\tdetails := myStruct{name: \"Chetan\", age: 31, frnd: friends{location: \"Bangalore\"}}\r\n\tfmt.Println(details) // {Chetan 31 {Bangalore}}\r\n\tfmt.Println(details.name) // Chetan\r\n\r\n\t// Overriding default value\r\n\tdetails.name = \"Chetan Patige\"\r\n\tfmt.Println(details.name) // Chetan Patige\r\n}", "func (node *selfNode) packToStructByFieldName(st reflect.Value) (err error) {\n\n\tnodeName := node.head.String()\n\tfor _, n := range node.values {\n\t\tif _, ok := n.(*selfNode); !ok {\n\t\t\treturn n.newPackError(\"field `\" + nodeName + \"` should be only made of lists\")\n\t\t}\n\t\tvalueNode := n.(*selfNode)\n\t\tfieldName := publicName(valueNode.head.String())\n\t\ttargetField := st.FieldByName(fieldName)\n\t\tif !targetField.IsValid() {\n\t\t\treturn valueNode.newPackError(\"undefined field `\" + fieldName + \"` for node `\" + nodeName + \"`\")\n\t\t}\n\n\t\tif err = valueNode.packIntoField(fieldName, targetField); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\treturn nil\n}", "func name(v reflect.StructField) string {\n\tif name, ok := v.Tag.Lookup(\"name\"); ok {\n\t\treturn name\n\t}\n\treturn v.Name\n}", "func Struct(s, t interface{}) error {\n\treturn defaultmasker.Struct(s, t)\n}", "func (ds *DynamicStruct) FieldByName(name string) (reflect.StructField, bool) {\n\treturn ds.rt.FieldByName(name)\n}", "func (t *Struct) String() string { return t.Name }", "func (db *DB) GetStruct(s interface{}, where string, params ...interface{}) error {\n\n structType := reflect.TypeOf(s)\n if structType.Kind() != reflect.Ptr {\n return errors.New(fmt.Sprintf(\"struct must be a pointer, but got %v\", structType))\n }\n structType = structType.Elem()\n\n v := reflect.ValueOf(s)\n if v.IsNil() {\n return errors.New(fmt.Sprintf(\"struct can not be nil, but got %v\", s))\n }\n\n qi := SqlQueryInfo{\n Limit: 1,\n Where: where,\n Params: params,\n }\n rows, fields, err := db.rawSelectByStruct(structType, qi)\n if err != nil {\n return err\n }\n defer rows.Close()\n\n if rows.Next() {\n err = rawScanStruct(v, fields, rows)\n if err != nil {\n return err\n }\n if moreThanOneRow := rows.Next(); moreThanOneRow {\n return errors.New(\"more than one row found\")\n }\n }\n return nil\n}", "func parseStructField(cache structCache, key, sk, keytail string, values []string, target reflect.Value) {\n\tl, ok := cache[sk]\n\tif !ok {\n\t\tpanic(KeyError{\n\t\t\tFullKey: key,\n\t\t\tKey: kpath(key, keytail),\n\t\t\tType: target.Type(),\n\t\t\tField: sk,\n\t\t})\n\t}\n\tf := target.Field(l.offset)\n\n\tl.parse(key, keytail, values, f)\n}", "func New(s interface{}) *Struct {\n\treturn &Struct{\n\t\traw: s,\n\t\tvalue: structVal(s),\n\t\tTagName: DefaultTagName,\n\t}\n}", "func lookup(s *types.Scope, name string) *types.Struct {\n\tif o := s.Lookup(name); o != nil {\n\t\tu := o.Type().Underlying()\n\t\tif s, ok := u.(*types.Struct); ok {\n\t\t\treturn s\n\t\t}\n\t}\n\tfor i := 0; i < s.NumChildren(); i++ {\n\t\ts := lookup(s.Child(i), name)\n\t\tif s != nil {\n\t\t\treturn s\n\t\t}\n\t}\n\treturn nil\n}", "func structName(entry *yang.Entry, forList bool) (string, error) {\n\tname, ok := entry.Annotation[\"structname\"]\n\tif !ok {\n\t\treturn \"\", status.Errorf(codes.NotFound, \"structname not found in annotations\")\n\t}\n\tif entry.IsList() && forList {\n\t\tkeys, err := listKeys(entry)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\t// if the entry is a list and we are targeting the container\n\t\t// NOTE we still need to support composite keys\n\t\treturn fmt.Sprintf(\"map[%s]*%s\", keys[0].Gotype, name), nil\n\t}\n\treturn fmt.Sprintf(\"*%s\", name), nil\n}", "func (f *Field) Field(name string) *Field {\n\tfield, ok := f.FieldOk(name)\n\tif !ok {\n\t\tpanic(\"field not found\")\n\t}\n\n\treturn field\n}", "func BuildStruct(s Servable, theType reflect.Type, theValue reflect.Value, req *http.Request) {\n\tif theValue.Kind() == reflect.Invalid {\n\t\tlog.Info(\"value is invalid, please check grpc-fieldmapping\")\n\t}\n\tconvertor := components(req).Convertor(theValue.Type().Name())\n\tif convertor != nil {\n\t\ttheValue.Set(convertor(req).Elem())\n\t\treturn\n\t}\n\n\tfieldNum := theType.NumField()\n\tfor i := 0; i < fieldNum; i++ {\n\t\tfieldName := theType.Field(i).Name\n\t\tif fieldName[0] < 'A' || fieldName[0] > 'Z' {\n\t\t\tcontinue\n\t\t}\n\t\tfieldValue := theValue.FieldByName(fieldName)\n\t\tif fieldValue.Kind() == reflect.Ptr && fieldValue.Type().Elem().Kind() == reflect.Struct {\n\t\t\tconvertor := components(req).Convertor(fieldValue.Type().Elem().Name())\n\t\t\tif convertor != nil {\n\t\t\t\tfieldValue.Set(convertor(req))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tBuildStruct(s, fieldValue.Type().Elem(), fieldValue.Elem(), req)\n\t\t\tcontinue\n\t\t}\n\t\tv, ok := findValue(fieldName, req)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\t\terr := setValue(theType.Field(i).Type, fieldValue, v)\n\t\tlogErrorIf(err)\n\t}\n}", "func toStructType(t *types.Struct, ctx GoTypeFinder) (typ reflect.Type, err error) {\n\tn := t.NumFields()\n\tflds := make([]reflect.StructField, n)\n\tfor i := 0; i < n; i++ {\n\t\tv := t.Field(i)\n\t\tif flds[i], err = toStructField(v, t.Tag(i), ctx); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\treturn reflect.StructOf(flds), nil\n}", "func Get(v reflect.Value, name string) reflect.Value {\n\tif v.Kind() == reflect.Interface {\n\t\tv = v.Elem()\n\t}\n\t// dereference pointers\n\tfor v.Kind() == reflect.Ptr {\n\t\tv = v.Elem()\n\t}\n\tswitch v.Kind() {\n\tcase reflect.Struct:\n\t\ttyp := v.Type()\n\t\tfor i := 0; i < typ.NumField(); i++ {\n\t\t\tf := typ.Field(i)\n\t\t\tif f.PkgPath != \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tns, mapped := Field(f)\n\t\t\tif (f.Anonymous && !mapped) || ns == \"-\" {\n\t\t\t\tnV := Get(v.Field(i), name)\n\t\t\t\tif nV.IsValid() {\n\t\t\t\t\treturn nV\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ns == name {\n\t\t\t\treturn v.Field(i)\n\t\t\t}\n\t\t}\n\tcase reflect.Map:\n\t\treturn v.MapIndex(reflect.ValueOf(name))\n\t}\n\treturn reflect.Value{}\n}", "func (s *Struct) nested(val reflect.Value) interface{} {\n\tvar finalVal interface{}\n\n\tv := reflect.ValueOf(val.Interface())\n\tif v.Kind() == reflect.Ptr {\n\t\tv = v.Elem()\n\t}\n\n\tswitch v.Kind() {\n\tcase reflect.Struct:\n\t\tn := New(val.Interface())\n\t\tn.TagName = s.TagName\n\t\tm := n.Map()\n\n\t\t// do not add the converted value if there are no exported fields, ie:\n\t\t// time.Time\n\t\tif len(m) == 0 {\n\t\t\tfinalVal = val.Interface()\n\t\t} else {\n\t\t\tfinalVal = m\n\t\t}\n\tcase reflect.Map:\n\t\t// get the element type of the map\n\t\tmapElem := val.Type()\n\t\tswitch val.Type().Kind() {\n\t\tcase reflect.Ptr, reflect.Array, reflect.Map,\n\t\t\treflect.Slice, reflect.Chan:\n\t\t\tmapElem = val.Type().Elem()\n\t\t\tif mapElem.Kind() == reflect.Ptr {\n\t\t\t\tmapElem = mapElem.Elem()\n\t\t\t}\n\t\t}\n\n\t\t// only iterate over struct types, ie: map[string]StructType,\n\t\t// map[string][]StructType,\n\t\tif mapElem.Kind() == reflect.Struct ||\n\t\t\t(mapElem.Kind() == reflect.Slice &&\n\t\t\t\tmapElem.Elem().Kind() == reflect.Struct) {\n\t\t\tm := make(map[string]interface{}, val.Len())\n\t\t\tfor _, k := range val.MapKeys() {\n\t\t\t\tm[k.String()] = s.nested(val.MapIndex(k))\n\t\t\t}\n\t\t\tfinalVal = m\n\t\t\tbreak\n\t\t}\n\n\t\t// TODO(arslan): should this be optional?\n\t\tfinalVal = val.Interface()\n\tcase reflect.Slice, reflect.Array:\n\t\tif val.Type().Kind() == reflect.Interface {\n\t\t\tfinalVal = val.Interface()\n\t\t\tbreak\n\t\t}\n\n\t\t// TODO(arslan): should this be optional?\n\t\t// do not iterate of non struct types, just pass the value. Ie: []int,\n\t\t// []string, co... We only iterate further if it's a struct.\n\t\t// i.e []foo or []*foo\n\t\tif val.Type().Elem().Kind() != reflect.Struct &&\n\t\t\t!(val.Type().Elem().Kind() == reflect.Ptr &&\n\t\t\t\tval.Type().Elem().Elem().Kind() == reflect.Struct) {\n\t\t\tfinalVal = val.Interface()\n\t\t\tbreak\n\t\t}\n\n\t\tslices := make([]interface{}, val.Len())\n\t\tfor x := 0; x < val.Len(); x++ {\n\t\t\tslices[x] = s.nested(val.Index(x))\n\t\t}\n\t\tfinalVal = slices\n\tdefault:\n\t\tfinalVal = val.Interface()\n\t}\n\n\treturn finalVal\n}", "func structFromProg(prog *loader.Program, packageName, objectName string) (*types.Struct, error) {\n\t// Lookup package.\n\tpkg := prog.Package(packageName)\n\tif pkg == nil {\n\t\treturn nil, errors.Errorf(\"Package %s not found\", packageName)\n\t}\n\n\t// Lookup struct object.\n\tobj := pkg.Pkg.Scope().Lookup(objectName)\n\tif obj == nil {\n\t\treturn nil, errors.Errorf(\"Definition %s.%s not found\", packageName, objectName)\n\t}\n\tobjType := obj.Type().Underlying()\n\tstructType, ok := objType.(*types.Struct)\n\tif !ok {\n\t\treturn nil, errors.Errorf(\"%s type is %T, want *types.Struct\", obj.Id(), objType)\n\t}\n\treturn structType, nil\n}", "func (t *Type) StructType() *StructType", "func StructFor(tableOrQueue string) (proto.Message, error) {\n\ttableOrQueue = strcase.ToKebab(tableOrQueue)\n\n\tif tableOrQueue == \"pkg\" || tableOrQueue == \"pkgs\" {\n\t\ttableOrQueue = TablePackages\n\t}\n\n\tswitch tableOrQueue {\n\t// N.B.: Metadata type is arbitrary on a per-key basis, so unsupported here.\n\t// case TableMetadata:\n\n\tcase inflection.Plural(TablePackages), inflection.Singular(TablePackages):\n\t\treturn &domain.Package{}, nil\n\n\tcase inflection.Plural(TablePendingReferences), inflection.Singular(TablePendingReferences):\n\t\treturn &domain.PendingReferences{}, nil\n\n\tcase inflection.Plural(TableCrawlResults), inflection.Singular(TableCrawlResults):\n\t\treturn &domain.CrawlResult{}, nil\n\n\tcase inflection.Plural(TableToCrawl), inflection.Singular(TableToCrawl):\n\t\treturn &domain.ToCrawlEntry{}, nil\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unrecognized or unsupported table or queue %q\", tableOrQueue)\n\t}\n}", "func execmStructField(_ int, p *gop.Context) {\n\targs := p.GetArgs(2)\n\tret := args[0].(*types.Struct).Field(args[1].(int))\n\tp.Ret(2, ret)\n}", "func (t *Thrift) GetStruct(name string) (*StructLike, bool) {\n\tfor _, st := range t.Structs {\n\t\tif st.Name == name {\n\t\t\treturn st, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func execNewStruct(_ int, p *gop.Context) {\n\targs := p.GetArgs(2)\n\tret := types.NewStruct(args[0].([]*types.Var), args[1].([]string))\n\tp.Ret(2, ret)\n}", "func getSymbolStructField(symbol string, symbolRate *exchangeRateTable) *ohlcData {\n\tswitch symbol {\n\tcase \"EURUSD\":\n\t\treturn &symbolRate.EURUSD\n\tcase \"GBPUSD\":\n\t\treturn &symbolRate.GBPUSD\n\tcase \"USDJPY\":\n\t\treturn &symbolRate.USDJPY\n\tcase \"AUDCAD\":\n\t\treturn &symbolRate.AUDCAD\n\tdefault:\n\t\treturn nil\n\t}\n}", "func (dec *Decoder) ReadStruct(t reflect.Type) {\n\tname := dec.ReadSafeString()\n\tcount := dec.ReadInt()\n\tnames := make([]string, count)\n\tfor i := 0; i < count; i++ {\n\t\tdec.decodeString(stringType, dec.NextByte(), &names[i])\n\t}\n\tdec.Skip()\n\tdec.ref = append(dec.ref, makeStructInfo(name, names, t))\n}", "func structToSchema(prog *Program, name, tagName string, ref Reference) (*Schema, error) {\n\tschema := &Schema{\n\t\tTitle: name,\n\t\tDescription: ref.Info,\n\t\tType: \"object\",\n\t\tProperties: map[string]*Schema{},\n\t}\n\n\tfor _, p := range ref.Fields {\n\t\tif p.KindField == nil {\n\t\t\treturn nil, fmt.Errorf(\"p.KindField is nil for %v\", name)\n\t\t}\n\n\t\tname = goutil.TagName(p.KindField, tagName)\n\n\t\tif name == \"-\" {\n\t\t\tcontinue\n\t\t}\n\t\tif name == \"\" {\n\t\t\tname = p.Name\n\t\t}\n\n\t\tprop, err := fieldToSchema(prog, name, tagName, ref, p.KindField)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot parse %v: %v\", ref.Lookup, err)\n\t\t}\n\n\t\tif !sliceutil.Contains([]string{\"path\", \"query\", \"form\"}, ref.Context) {\n\t\t\tfixRequired(schema, prop)\n\t\t}\n\n\t\tif prop == nil {\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"structToSchema: prop is nil for field %#v in %#v\",\n\t\t\t\tname, ref.Lookup)\n\t\t}\n\n\t\tschema.Properties[name] = prop\n\t}\n\n\treturn schema, nil\n}", "func (s *StructField) Name() string {\n\treturn s.name\n}", "func lookupFieldInStruct(reflectValue reflect.Value, name string) (interface{}, bool) {\n\tfield := reflectValue.FieldByName(name)\n\tif field.IsValid() {\n\t\treturn field.Interface(), truth(field)\n\t}\n\tmethod := reflectValue.MethodByName(name)\n\tif method.IsValid() && method.Type().NumIn() == 1 {\n\t\tout := method.Call(nil)[0]\n\t\treturn out.Interface(), truth(out)\n\t}\n\treturn nil, false\n}", "func newStructFLS(p interface{}) (FieldLoadSaver, error) {\n\tv := reflect.ValueOf(p)\n\tif v.Kind() != reflect.Ptr || v.IsNil() || v.Elem().Kind() != reflect.Struct {\n\t\treturn nil, ErrInvalidDocumentType\n\t}\n\treturn structFLS{v.Elem()}, nil\n}", "func (c *Context) Struct() *starlarkstruct.Struct {\n\tdict := starlark.StringDict{\n\t\t\"set\": starlark.NewBuiltin(\"set\", c.setValue),\n\t\t\"get\": starlark.NewBuiltin(\"get\", c.getValue),\n\t\t\"get_config\": starlark.NewBuiltin(\"get_config\", c.GetConfig),\n\t\t\"get_secret\": starlark.NewBuiltin(\"get_secret\", c.GetSecret),\n\t}\n\n\tfor k, v := range c.results {\n\t\tdict[k] = v\n\t}\n\n\treturn starlarkstruct.FromStringDict(starlark.String(\"context\"), dict)\n}", "func (sb *schemaBuilder) buildField(field reflect.StructField) (*graphql.Field, error) {\n\tretType, err := sb.getType(field.Type)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &graphql.Field{\n\t\tResolve: func(ctx context.Context, source, args interface{}, selectionSet *graphql.SelectionSet) (interface{}, error) {\n\t\t\tvalue := reflect.ValueOf(source)\n\t\t\tif value.Kind() == reflect.Ptr {\n\t\t\t\tvalue = value.Elem()\n\t\t\t}\n\t\t\treturn value.FieldByIndex(field.Index).Interface(), nil\n\t\t},\n\t\tType: retType,\n\t\tParseArguments: nilParseArguments,\n\t}, nil\n}", "func (*Component_Subcomponent) IsYANGGoStruct() {}", "func ReflectStruct(s interface{}) *Struct {\n\treturn &Struct{\n\t\tRef: s,\n\t\tOriginalPackage: \"\",\n\t}\n}", "func (c *Cache) create(rt reflect.Type, kind core.Kind) *StructInfo {\n\tt, _ := utils.RemovePointer(rt, false) // already removed, no need to remove again?\n\tsi := &StructInfo{\n\t\tt: t,\n\t\tFields: make(map[string]*FieldInfo),\n\t\tKind: kind,\n\t}\n\tcreateFieldInfo(si, t)\n\tif false {\n\t\tfmt.Println(\"******* print struct info *******************************************************\")\n\t\tfor k, v := range si.Fields {\n\t\t\tfmt.Println(k, \" -> \", v)\n\t\t}\n\t}\n\treturn si\n}", "func NewStructField(name string, value Value) StructField {\n\treturn StructField{Name: name, Value: value}\n}", "func Field(v interface{}, name string) (*Fieldx, bool) {\n\treturn New(v).Field(name)\n}", "func (node *selfNode) packToStruct(st reflect.Value) error {\n\n\tfor _, n := range node.values {\n\t\tswitch n.(type) {\n\t\tcase selfString:\n\t\t\treturn node.packToStructByFieldOrder(st)\n\n\t\tcase *selfNode:\n\t\t\tif !st.FieldByName(n.(*selfNode).head.String()).IsValid() {\n\t\t\t\treturn node.packToStructByFieldOrder(st)\n\t\t\t}\n\t\t}\n\t}\n\treturn node.packToStructByFieldName(st)\n}", "func (x *MyUnion) DefaultGetStructField() *MyStruct {\n if !x.IsSetStructField() {\n return NewMyStruct()\n }\n return x.StructField\n}", "func GetNameFromStruct(u interface{}) string {\n\tvar result = ReturnValue{CustomStruct: u}\n\n\t//fmt.Println(result)\n\n\tmsg, ok := result.CustomStruct.(NameOnly)\n\tif ok {\n\t\t//fmt.Printf(\"Message1 is %s\\n\", msg.Name)\n\t\treturn msg.Name\n\t} else {\n\t\treturn \"\"\n\t}\n}", "func (p TreeWriter) getFields(leaf *yaml.RNode) (treeFields, error) {\n\tfieldsByName := map[string]*treeField{}\n\n\t// index nested and non-nested fields\n\tfor i := range p.Fields {\n\t\tf := p.Fields[i]\n\t\tseq, err := leaf.Pipe(&f)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif seq == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tif fieldsByName[f.Name] == nil {\n\t\t\tfieldsByName[f.Name] = &treeField{name: f.Name}\n\t\t}\n\n\t\t// non-nested field -- add directly to the treeFields list\n\t\tif f.SubName == \"\" {\n\t\t\t// non-nested field -- only 1 element\n\t\t\tval, err := yaml.String(seq.Content()[0], yaml.Trim, yaml.Flow)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tfieldsByName[f.Name].value = val\n\t\t\tcontinue\n\t\t}\n\n\t\t// nested-field -- create a parent elem, and index by the 'match' value\n\t\tif fieldsByName[f.Name].subFieldByMatch == nil {\n\t\t\tfieldsByName[f.Name].subFieldByMatch = map[string]treeFields{}\n\t\t}\n\t\tindex := fieldsByName[f.Name].subFieldByMatch\n\t\tfor j := range seq.Content() {\n\t\t\telem := seq.Content()[j]\n\t\t\tmatches := f.Matches[elem]\n\t\t\tstr, err := yaml.String(elem, yaml.Trim, yaml.Flow)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\t// map the field by the name of the element\n\t\t\t// index the subfields by the matching element so we can put all the fields for the\n\t\t\t// same element under the same branch\n\t\t\tmatchKey := strings.Join(matches, \"/\")\n\t\t\tindex[matchKey] = append(index[matchKey], &treeField{name: f.SubName, value: str})\n\t\t}\n\t}\n\n\t// iterate over collection of all queried fields in the Resource\n\tfor _, field := range fieldsByName {\n\t\t// iterate over collection of elements under the field -- indexed by element name\n\t\tfor match, subFields := range field.subFieldByMatch {\n\t\t\t// create a new element for this collection of fields\n\t\t\t// note: we will convert name to an index later, but keep the match for sorting\n\t\t\telem := &treeField{name: match}\n\t\t\tfield.matchingElementsAndFields = append(field.matchingElementsAndFields, elem)\n\n\t\t\t// iterate over collection of queried fields for the element\n\t\t\tfor i := range subFields {\n\t\t\t\t// add to the list of fields for this element\n\t\t\t\telem.matchingElementsAndFields = append(elem.matchingElementsAndFields, subFields[i])\n\t\t\t}\n\t\t}\n\t\t// clear this cached data\n\t\tfield.subFieldByMatch = nil\n\t}\n\n\t// put the fields in a list so they are ordered\n\tfieldList := treeFields{}\n\tfor _, v := range fieldsByName {\n\t\tfieldList = append(fieldList, v)\n\t}\n\n\t// sort the fields\n\tsort.Sort(fieldList)\n\tfor i := range fieldList {\n\t\tfield := fieldList[i]\n\t\t// sort the elements under this field\n\t\tsort.Sort(field.matchingElementsAndFields)\n\n\t\tfor i := range field.matchingElementsAndFields {\n\t\t\telement := field.matchingElementsAndFields[i]\n\t\t\t// sort the elements under a list field by their name\n\t\t\tsort.Sort(element.matchingElementsAndFields)\n\t\t\t// set the name of the element to its index\n\t\t\telement.name = fmt.Sprintf(\"%d\", i)\n\t\t}\n\t}\n\n\treturn fieldList, nil\n}", "func structToMap(structPtr interface{}, depth int, prefix ...string) FieldMap {\n\tval := reflect.ValueOf(structPtr)\n\tind := reflect.Indirect(val)\n\tif val.Kind() != reflect.Ptr || ind.Kind() != reflect.Struct {\n\t\ttools.LogAndPanic(log, \"structPtr must be a pointer to a struct\", \"structPtr\", structPtr)\n\t}\n\tres := make(FieldMap)\n\tfor i := 0; i < ind.NumField(); i++ {\n\t\tvar fieldName string\n\t\tif len(prefix) > 0 {\n\t\t\tfieldName = fmt.Sprintf(\"%s.%s\", prefix[0], ind.Type().Field(i).Name)\n\t\t} else {\n\t\t\tfieldName = ind.Type().Field(i).Name\n\t\t}\n\t\tfieldValue := ind.Field(i)\n\t\tvar resVal interface{}\n\t\tif fieldValue.Kind() == reflect.Ptr {\n\t\t\t// Get the related struct if not nil\n\t\t\trelInd := reflect.Indirect(fieldValue)\n\t\t\trelTyp := fieldValue.Type().Elem()\n\t\t\tswitch relTyp.Kind() {\n\t\t\tcase reflect.Struct:\n\t\t\t\tif depth > 0 {\n\t\t\t\t\tif !relInd.IsValid() {\n\t\t\t\t\t\t// create the struct if the pointer is nil\n\t\t\t\t\t\tfieldValue = reflect.New(relTyp)\n\t\t\t\t\t}\n\t\t\t\t\t// get the related struct fields\n\t\t\t\t\trelMap := structToMap(fieldValue.Interface(), depth-1, fieldName)\n\t\t\t\t\tfor k, v := range relMap {\n\t\t\t\t\t\tres[k] = v\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif !relInd.IsValid() {\n\t\t\t\t\t\t// Skip if pointer is nil\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\t// get the ID of the related struct\n\t\t\t\t\tresVal = relInd.FieldByName(\"ID\").Interface()\n\t\t\t\t}\n\t\t\t}\n\t\t\tif relInd.Kind() != reflect.Struct {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t} else {\n\t\t\tresVal = ind.Field(i).Interface()\n\t\t}\n\t\tres[fieldName] = resVal\n\t}\n\treturn res\n}", "func AnonymousStruct() {\n\t//Biasanya dideklarasikan diluar ataupun didalam func\n\ttype orang struct {\n\t\tnama string\n\t}\n\n\t// struct ini nyaris sama seperti variabel dan tidak mempunya nama struct\n\t// hanya digunakan didalam func saja\n\tvar As1 = struct {\n\t\torang\n\t\tnegara string\n\t}{}\n\n\tAs1.nama = \"olgi\"\n\tAs1.negara = \"indonesia\"\n\n\tfmt.Println(\"Nama\\t = \", As1.nama)\n\tfmt.Println(\"Nama\\t = \", As1.negara)\n}", "func Struct(rt reflect.Type, gens map[string]gopter.Gen) gopter.Gen {\n\tif rt.Kind() == reflect.Ptr {\n\t\trt = rt.Elem()\n\t}\n\tif rt.Kind() != reflect.Struct {\n\t\treturn Fail(rt)\n\t}\n\tfieldGens := []gopter.Gen{}\n\tfieldTypes := []reflect.Type{}\n\tassignable := reflect.New(rt).Elem()\n\tfor i := 0; i < rt.NumField(); i++ {\n\t\tfieldName := rt.Field(i).Name\n\t\tif !assignable.Field(i).CanSet() {\n\t\t\tcontinue\n\t\t}\n\n\t\tgen := gens[fieldName]\n\t\tif gen != nil {\n\t\t\tfieldGens = append(fieldGens, gen)\n\t\t\tfieldTypes = append(fieldTypes, rt.Field(i).Type)\n\t\t}\n\t}\n\n\tbuildStructType := reflect.FuncOf(fieldTypes, []reflect.Type{rt}, false)\n\tunbuildStructType := reflect.FuncOf([]reflect.Type{rt}, fieldTypes, false)\n\n\tbuildStructFunc := reflect.MakeFunc(buildStructType, func(args []reflect.Value) []reflect.Value {\n\t\tresult := reflect.New(rt)\n\t\tfor i := 0; i < rt.NumField(); i++ {\n\t\t\tif _, ok := gens[rt.Field(i).Name]; !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif !assignable.Field(i).CanSet() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tresult.Elem().Field(i).Set(args[0])\n\t\t\targs = args[1:]\n\t\t}\n\t\treturn []reflect.Value{result.Elem()}\n\t})\n\tunbuildStructFunc := reflect.MakeFunc(unbuildStructType, func(args []reflect.Value) []reflect.Value {\n\t\ts := args[0]\n\t\tresults := []reflect.Value{}\n\t\tfor i := 0; i < s.NumField(); i++ {\n\t\t\tif _, ok := gens[rt.Field(i).Name]; !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif !assignable.Field(i).CanSet() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tresults = append(results, s.Field(i))\n\t\t}\n\t\treturn results\n\t})\n\n\treturn gopter.DeriveGen(\n\t\tbuildStructFunc.Interface(),\n\t\tunbuildStructFunc.Interface(),\n\t\tfieldGens...,\n\t)\n}", "func makeStruct(v interface{}, header, record []string) {\n\tval := reflect.ValueOf(v).Elem()\n\ttyp := reflect.TypeOf(v).Elem()\n\tfor i, heading := range header {\n\t\ttfield, found := typ.FieldByName(heading)\n\t\tif !found || tfield.Anonymous {\n\t\t\tcontinue\n\t\t}\n\n\t\tfieldval := val.FieldByName(heading)\n\t\tnewval := fromString(fieldval.Interface(), record[i])\n\n\t\tfieldval.Set(newval)\n\t}\n}", "func (s StructInfo) StructInfo() StructInfo {\n\treturn s\n}", "func godef(ds design.DataStructure, versioned bool, defPkg string, tabs int, jsonTags, inner, res bool) string {\n\tvar buffer bytes.Buffer\n\tdef := ds.Definition()\n\tt := def.Type\n\tswitch actual := t.(type) {\n\tcase design.Primitive:\n\t\treturn GoTypeName(t, tabs)\n\tcase *design.Array:\n\t\treturn \"[]\" + godef(actual.ElemType, versioned, defPkg, tabs, jsonTags, true, res)\n\tcase *design.Hash:\n\t\tkeyDef := godef(actual.KeyType, versioned, defPkg, tabs, jsonTags, true, res)\n\t\telemDef := godef(actual.ElemType, versioned, defPkg, tabs, jsonTags, true, res)\n\t\treturn fmt.Sprintf(\"map[%s]%s\", keyDef, elemDef)\n\tcase design.Object:\n\t\tif inner {\n\t\t\tbuffer.WriteByte('*')\n\t\t}\n\t\tbuffer.WriteString(\"struct {\\n\")\n\t\tkeys := make([]string, len(actual))\n\t\ti := 0\n\t\tfor n := range actual {\n\t\t\tkeys[i] = n\n\t\t\ti++\n\t\t}\n\t\tsort.Strings(keys)\n\t\tfor _, name := range keys {\n\t\t\tWriteTabs(&buffer, tabs+1)\n\t\t\ttypedef := godef(actual[name], versioned, defPkg, tabs+1, jsonTags, true, res)\n\t\t\tfname := Goify(name, true)\n\t\t\tvar tags string\n\t\t\tif jsonTags {\n\t\t\t\tvar omit string\n\t\t\t\tif !def.IsRequired(name) {\n\t\t\t\t\tomit = \",omitempty\"\n\t\t\t\t}\n\t\t\t\ttags = fmt.Sprintf(\" `json:\\\"%s%s\\\"`\", name, omit)\n\t\t\t}\n\t\t\tdesc := actual[name].Description\n\t\t\tif desc != \"\" {\n\t\t\t\tdesc = fmt.Sprintf(\"// %s\\n\", desc)\n\t\t\t}\n\t\t\tbuffer.WriteString(fmt.Sprintf(\"%s%s %s%s\\n\", desc, fname, typedef, tags))\n\t\t}\n\t\tWriteTabs(&buffer, tabs)\n\t\tbuffer.WriteString(\"}\")\n\t\treturn buffer.String()\n\tcase *design.UserTypeDefinition:\n\t\tname := GoPackageTypeName(actual, versioned, defPkg, tabs)\n\t\tif actual.Type.IsObject() {\n\t\t\treturn \"*\" + name\n\t\t}\n\t\treturn name\n\tcase *design.MediaTypeDefinition:\n\t\tif res && actual.Resource != nil {\n\t\t\treturn \"*\" + Goify(actual.Resource.Name, true)\n\t\t}\n\t\tname := GoPackageTypeName(actual, versioned, defPkg, tabs)\n\t\tif actual.Type.IsObject() {\n\t\t\treturn \"*\" + name\n\t\t}\n\t\treturn name\n\tdefault:\n\t\tpanic(\"goa bug: unknown data structure type\")\n\t}\n}", "func NewStruct(vs ...interface{}) Struct {\n\tstructFields := make([]StructField, len(vs)/2)\n\tfor i := range structFields {\n\t\tstructFields[i] = NewStructField(\n\t\t\tvs[2*i+0].(string),\n\t\t\tvs[2*i+1].(Value),\n\t\t)\n\t}\n\treturn Struct(structFields)\n}", "func Example_nestedStruct() {\n\tverbose := flag.Bool(\"verbose\", false, \"Verbose\")\n\tnode := flag.String(\"node\", \"\", \"Etcd node\")\n\tport := flag.String(\"port\", \"\", \"Etcd port\")\n\tflag.Parse()\n\n\t// Define nested structure.\n\tg := Group{\n\t\tName: \"staff\",\n\t\tUsers: []User{\n\t\t\tUser{\n\t\t\t\tName: \"jdoe\",\n\t\t\t\tAge: 25,\n\t\t\t\tMale: true,\n\t\t\t\tFirstName: \"John\",\n\t\t\t\tLastName: \"Doe\",\n\t\t\t},\n\t\t\tUser{\n\t\t\t\tName: \"lnemoy\",\n\t\t\t\tAge: 62,\n\t\t\t\tMale: true,\n\t\t\t\tFirstName: \"Leonard\",\n\t\t\t\tLastName: \"Nimoy\",\n\t\t\t},\n\t\t},\n\t}\n\n\t// Connect to Etcd.\n\tconn := getEnv()\n\tif node == nil && port == nil {\n\t\tconn = []string{fmt.Sprintf(\"http://%v:%v\", *node, *port)}\n\t}\n\n\tif *verbose {\n\t\tlog.Printf(\"Connecting to: %s\", conn)\n\t}\n\tclient := etcd.NewClient(conn)\n\n\t// Create directory structure based on struct.\n\terr := etcdmap.Create(client, \"/example\", reflect.ValueOf(g))\n\tif err != nil {\n\t\tlog.Fatal(err.Error())\n\t}\n\n\t// Get directory structure from Etcd.\n\tres, err := client.Get(\"/example\", true, true)\n\tif err != nil {\n\t\tlog.Fatal(err.Error())\n\t}\n\n\tj, err2 := etcdmap.JSON(res.Node)\n\tif err2 != nil {\n\t\tlog.Fatal(err2.Error())\n\t}\n\n\tfmt.Println(string(j))\n\n\t// Output:\n\t//{\"id\":\"staff\",\"users\":{\"0\":{\"age\":\"25\",\"first_name\":\"John\",\"id\":\"jdoe\",\"last_name\":\"Doe\",\"male\":\"true\"},\"1\":{\"age\":\"62\",\"first_name\":\"Leonard\",\"id\":\"lnemoy\",\"last_name\":\"Nimoy\",\"male\":\"true\"}}}\n}", "func jsonStruct(doc ElasticDocs) string {\n\n\t// Create struct instance of the Elasticsearch fields struct object\n\tdocStruct := &ElasticDocs{\n\t\tName: doc.Name,\n\t\tId: doc.Id,\n\t\tAvailable: doc.Available,\n\t\tNewField: doc.NewField,\n\t}\n\t// Marshal the struct to JSON and check for errors\n\tb, err := json.Marshal(docStruct)\n\tif err != nil {\n\t\tfmt.Println(\"json.Marshal ERROR:\", err)\n\t\treturn string(err.Error())\n\t}\n\treturn string(b)\n}", "func getElementStruct(stub shim.ChaincodeStubInterface, elementKey string, element interface{}) error {\n\telementBytes, err := getElementBytes(stub, elementKey)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn bytesToStruct(elementBytes, element)\n}", "func (e *exprHelper) NewStruct(typeName string, fieldInits ...ast.EntryExpr) ast.Expr {\n\treturn e.exprFactory.NewStruct(e.nextMacroID(), typeName, fieldInits)\n}", "func (t *Type) loadStruct(importPath string) error {\n\tstructName := t.Name\n\n\t// if import path is not define, try to import from local directory\n\tif importPath == \"\" {\n\t\timportPath = \"./\"\n\t}\n\tp, err := Program(importPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"load program: %s\", err)\n\t}\n\n\tfor _, pkg := range p.Imported {\n\t\tfor _, scope := range pkg.Scopes {\n\t\t\tst := lookup(scope.Parent(), structName)\n\t\t\tif st != nil {\n\t\t\t\tt.st = st\n\t\t\t\tt.pkg = pkg.Pkg\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}\n\treturn ErrTypeNotFound\n}", "func (_struct Struct) String() string {\n\treturn fmt.Sprintf(\"struct:%s\", _struct.Name())\n}", "func (p *Parser) parse(prefix string, s *ast.StructType) {\n\t// stop recursion for nested structs\n\tif s == nil {\n\t\treturn\n\t}\n\n\tfor _, f := range s.Fields.List {\n\t\terr := &ErrSyntax{line: p.file.Line(f.Pos())}\n\n\t\tvar (\n\t\t\ttag = err.append(p.parseTag(f)).(*types.Tag)\n\t\t\tname = prefix + err.append(p.parseName(f)).(string)\n\t\t\ttypeID = err.append(p.parseType(f)).(string)\n\t\t)\n\n\t\tswitch {\n\t\tcase err.errs != nil:\n\t\t\tp.errors = append(p.errors, err)\n\t\tcase tag == nil:\n\t\t\tp.parse(name+\".\", p.parseSubType(f))\n\t\tdefault:\n\t\t\tif tag.EnvVar == \"\" {\n\t\t\t\ttag.EnvVar = strings.ToUpper(strings.ReplaceAll(name, \".\", \"_\"))\n\t\t\t}\n\n\t\t\t// because names unique (because of prefix) we can omit checks like \"Did we find already?\"\n\t\t\tp.fields[name] = &types.Field{\n\t\t\t\tName: name,\n\t\t\t\tType: typeID,\n\t\t\t\tEnvVar: tag.EnvVar,\n\t\t\t\tAction: tag.Action,\n\t\t\t}\n\t\t}\n\t}\n}", "func (f *FieldHandler) StructField() reflect.StructField {\n\treturn f.field.structField\n}", "func (p *PropertyGenerator) StructName() string {\n\tif p.asIterator {\n\t\treturn p.Name.CamelName\n\t}\n\treturn fmt.Sprintf(\"%sProperty\", p.Name.CamelName)\n}", "func Struct(entries ...dgo.MapEntryType) dgo.StructType {\n\treturn internal.Struct(entries)\n}", "func getField(n string, i interface{}) (interface{}, bool) {\n\tre := reflect.ValueOf(i).Elem()\n\tif re.Kind() == reflect.Struct {\n\t\tf := re.FieldByName(n)\n\n\t\tif f.IsValid() {\n\t\t\treturn f.Interface(), true\n\t\t}\n\t}\n\n\treturn nil, false\n}", "func (c *Config) GetStruct(pattern string, pointer interface{}, mapping ...map[string]string) error {\n\tif j := c.getJson(); j != nil {\n\t\treturn j.GetStruct(pattern, pointer, mapping...)\n\t}\n\treturn errors.New(\"configuration not found\")\n}", "func (f Unstructured) Field(field string) Fragment {\n\tif f.fields != nil {\n\t\treturn f.fields[field]\n\t}\n\treturn nil\n}", "func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, __FieldImplementors)\n\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\n\tfor i, field := range fields {\n\t\tout.Keys[i] = field.Alias\n\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString(\"__Field\")\n\t\tcase \"name\":\n\t\t\tout.Values[i] = ec.___Field_name(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"description\":\n\t\t\tout.Values[i] = ec.___Field_description(ctx, field, obj)\n\t\tcase \"args\":\n\t\t\tout.Values[i] = ec.___Field_args(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"type\":\n\t\t\tout.Values[i] = ec.___Field_type(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"isDeprecated\":\n\t\t\tout.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"deprecationReason\":\n\t\t\tout.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)\n\t\tdefault:\n\t\t\tpanic(\"unknown field \" + strconv.Quote(field.Name))\n\t\t}\n\t}\n\n\tif invalid {\n\t\treturn graphql.Null\n\t}\n\treturn out\n}", "func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, __FieldImplementors)\n\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\n\tfor i, field := range fields {\n\t\tout.Keys[i] = field.Alias\n\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString(\"__Field\")\n\t\tcase \"name\":\n\t\t\tout.Values[i] = ec.___Field_name(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"description\":\n\t\t\tout.Values[i] = ec.___Field_description(ctx, field, obj)\n\t\tcase \"args\":\n\t\t\tout.Values[i] = ec.___Field_args(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"type\":\n\t\t\tout.Values[i] = ec.___Field_type(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"isDeprecated\":\n\t\t\tout.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"deprecationReason\":\n\t\t\tout.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)\n\t\tdefault:\n\t\t\tpanic(\"unknown field \" + strconv.Quote(field.Name))\n\t\t}\n\t}\n\n\tif invalid {\n\t\treturn graphql.Null\n\t}\n\treturn out\n}", "func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, __FieldImplementors)\n\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\n\tfor i, field := range fields {\n\t\tout.Keys[i] = field.Alias\n\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString(\"__Field\")\n\t\tcase \"name\":\n\t\t\tout.Values[i] = ec.___Field_name(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"description\":\n\t\t\tout.Values[i] = ec.___Field_description(ctx, field, obj)\n\t\tcase \"args\":\n\t\t\tout.Values[i] = ec.___Field_args(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"type\":\n\t\t\tout.Values[i] = ec.___Field_type(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"isDeprecated\":\n\t\t\tout.Values[i] = ec.___Field_isDeprecated(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"deprecationReason\":\n\t\t\tout.Values[i] = ec.___Field_deprecationReason(ctx, field, obj)\n\t\tdefault:\n\t\t\tpanic(\"unknown field \" + strconv.Quote(field.Name))\n\t\t}\n\t}\n\n\tif invalid {\n\t\treturn graphql.Null\n\t}\n\treturn out\n}", "func getStructField(v reflect.Value, ii []int) reflect.Value {\n\tif len(ii) == 0 {\n\t\treturn v.Addr()\n\t}\n\ti, ii := ii[0], ii[1:]\n\n\tiv := v.Field(i)\n\tif iv.Kind() == reflect.Ptr && iv.IsNil() {\n\t\t// If the field is a pointer to an unexported type then it won't be\n\t\t// settable, though if the user pre-sets the value it will be (I think).\n\t\tif !iv.CanSet() {\n\t\t\treturn reflect.Value{}\n\t\t}\n\t\tiv.Set(reflect.New(iv.Type().Elem()))\n\t}\n\tiv = reflect.Indirect(iv)\n\n\treturn getStructField(iv, ii)\n}", "func generateStruct(a *AnnotationDoc, packageName string, imports []string, indent string) (string, []string) {\n\tvar allAnnotationsPackages []string\n\tpossiblePackagesForA := combinePackages(imports, []string{packageName})\n\tts, foundPackageOfA, foundImportsOfA := getAnnotationStruct(a.Name, possiblePackagesForA)\n\tallAnnotationsPackages = combinePackages(allAnnotationsPackages, []string{foundPackageOfA})\n\tstr, _ := ts.Type.(*ast.StructType)\n\tvar b bytes.Buffer\n\tb.WriteString(indent)\n\tb.WriteString(foundPackageOfA)\n\tb.WriteString(\".\")\n\tb.WriteString(a.Name)\n\tb.WriteString(\"{\\n\")\n\tchildIndent := indent + \" \"\n\tfor _, f := range str.Fields.List {\n\t\tfieldName := getFieldName(f)\n\t\tdefValue := getDefaultValue(f)\n\t\tfieldKey := fieldName\n\t\t// consider special case when only default parameter is specified\n\t\tif len(str.Fields.List) == 1 && len(a.Content) == 1 {\n\t\t\tfor key := range a.Content {\n\t\t\t\tif key == DEFAULT_PARAM {\n\t\t\t\t\tfieldKey = DEFAULT_PARAM\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvalue, found := a.Content[fieldKey]\n\t\tif found {\n\t\t\tswitch t := value.(type) {\n\t\t\tcase string:\n\t\t\t\tb.WriteString(childIndent)\n\t\t\t\tb.WriteString(getLiteral(f.Type, t, false))\n\t\t\t\tb.WriteString(\",\\n\")\n\t\t\tcase []string:\n\t\t\t\tb.WriteString(childIndent)\n\t\t\t\tb.WriteString(getFieldConstructor(f.Type))\n\t\t\t\tb.WriteString(\"\\n\")\n\t\t\t\tfor _, elem := range t {\n\t\t\t\t\tb.WriteString(childIndent + \" \")\n\t\t\t\t\tb.WriteString(elem)\n\t\t\t\t\tb.WriteString(\",\\n\")\n\t\t\t\t}\n\t\t\t\tb.WriteString(childIndent)\n\t\t\t\tb.WriteString(\"}\")\n\t\t\tcase []AnnotationDoc:\n\t\t\t\t// calculate array's elements\n\t\t\t\tvar bb bytes.Buffer\n\t\t\t\tfor _, sa := range t {\n\t\t\t\t\tchildCode, foundImportsOfChild := generateStruct(&sa, foundPackageOfA, foundImportsOfA, childIndent+\" \")\n\t\t\t\t\tallAnnotationsPackages = combinePackages(allAnnotationsPackages, foundImportsOfChild)\n\t\t\t\t\tbb.WriteString(childCode)\n\t\t\t\t\tbb.WriteString(\",\\n\")\n\t\t\t\t}\n\t\t\t\tb.WriteString(childIndent)\n\t\t\t\t// insert array initialzer of child annotation type\n\t\t\t\ts := writeArrayInitializer(&b, bb.String())\n\t\t\t\t// append array of child annotations\n\t\t\t\tb.WriteString(\"{\\n\")\n\t\t\t\tb.WriteString(childIndent + \" \")\n\t\t\t\tb.WriteString(s)\n\t\t\t\tb.WriteString(childIndent)\n\t\t\t\tb.WriteString(\"},\\n\")\n\t\t\tcase AnnotationDoc:\n\t\t\t\tchildCode, foundImportsOfChild := generateStruct(&t, foundPackageOfA, foundImportsOfA, childIndent)\n\t\t\t\tallAnnotationsPackages = combinePackages(allAnnotationsPackages, foundImportsOfChild)\n\t\t\t\tb.WriteString(childIndent)\n\t\t\t\tif isOptional(f.Type) {\n\t\t\t\t\tb.WriteString(\"&\")\n\t\t\t\t}\n\t\t\t\tb.WriteString(strings.TrimLeft(childCode, \" \"))\n\t\t\t\tb.WriteString(\",\\n\")\n\t\t\tdefault:\n\t\t\t\tpanic(\"Unexpected annotation value type\")\n\t\t\t}\n\t\t} else {\n\t\t\tb.WriteString(childIndent)\n\t\t\tb.WriteString(defValue)\n\t\t\tb.WriteString(\",\\n\")\n\t\t}\n\t}\n\tb.WriteString(indent)\n\tb.WriteString(\"}\")\n\treturn b.String(), allAnnotationsPackages\n}", "func (t *SimpleChaincode) readStruct(stub shim.ChaincodeStubInterface, structName string, arg string) ([]byte, error) {\n\tfmt.Println(\"Read called for \" + structName)\n\tvar jsonResp string\n\tvar err error\n\n\tkey := arg\n\tfmt.Println(\"Reading for key: \" + key)\n\tvalAsbytes, err := stub.GetState(key)\n\tif err != nil {\n\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get object for \" + key + \"\\\"}\"\n\t\treturn nil, errors.New(jsonResp)\n\t}\n\n\tif structName == \"readProvider\" {\n\t\tvar p Provider\n\t\terr = json.Unmarshal(valAsbytes, &p)\n\t\tif err != nil {\n\t\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get Provider for \" + key + \"\\\"}\"\n\t\t\treturn nil, errors.New(jsonResp)\n\t\t}\n\t\tfmt.Println(\"Provider fetched successfully with key: \" + key)\n\t} else if structName == \"readMember\" {\n\t\tvar m Member\n\t\terr = json.Unmarshal(valAsbytes, &m)\n\t\tif err != nil {\n\t\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get Member for \" + key + \"\\\"}\"\n\t\t\treturn nil, errors.New(jsonResp)\n\t\t}\n\t\tfmt.Println(\"Member fetched successfully with key: \")\n\t} else if structName == \"readService\" {\n\t\tvar s Service\n\t\terr = json.Unmarshal(valAsbytes, &s)\n\t\tif err != nil {\n\t\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get Service for \" + key + \"\\\"}\"\n\t\t\treturn nil, errors.New(jsonResp)\n\t\t}\n\t\tfmt.Println(\"Service fetched successfully with key: \" + key)\n\t} else if structName == \"readPayer\" {\n\t\tvar pyr Payer\n\t\terr = json.Unmarshal(valAsbytes, &pyr)\n\t\tif err != nil {\n\t\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get Payer for \" + key + \"\\\"}\"\n\t\t\treturn nil, errors.New(jsonResp)\n\t\t}\n\t\tfmt.Println(\"Payer fetched successfully with key: \" + key)\n\t} else {\n\t\treturn nil, errors.New(\"Received unknown structure or key in query: \" + structName + \":\" + key)\n\t}\n\n\treturn valAsbytes, nil\n}", "func (r *Reader) PropertyStruct(pkgPath, name string, defaults reflect.Value) (*PropertyStruct, error) {\n\tps := r.getPropertyStruct(pkgPath, name)\n\n\tif ps == nil {\n\t\tpkg, err := r.goPkg(pkgPath)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tfor _, t := range pkg.Types {\n\t\t\tif t.Name == name {\n\t\t\t\tps, err = newPropertyStruct(t)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tps = r.putPropertyStruct(pkgPath, name, ps)\n\t\t\t}\n\t\t}\n\t}\n\n\tif ps == nil {\n\t\treturn nil, fmt.Errorf(\"package %q type %q not found\", pkgPath, name)\n\t}\n\n\tps = ps.Clone()\n\tps.SetDefaults(defaults)\n\n\treturn ps, nil\n}", "func (x *TerseStructWithCustomDefault) DefaultGetStructField() *MyStructWithCustomDefault {\n if !x.IsSetStructField() {\n return NewMyStructWithCustomDefault()\n }\n return x.StructField\n}", "func dbNameToStruct(db string) (d utils.DBMS, err error) {\n\tswitch strings.ToLower(db) {\n\tcase \"mysql\":\n\t\td = &dbms.MySQL{}\n\tcase \"oracle\":\n\t\td = &dbms.Oracle{}\n\tcase \"postgres\":\n\t\td = &dbms.Postgres{}\n\tdefault:\n\t\terr = fmt.Errorf(\"Unknown DBMS: %s\", db)\n\t}\n\treturn\n}", "func (r *reflex) tagInfoFrom(field reflect.StructField, pkgPath string) (*tagInfo, error) {\n\tinfo := &tagInfo{\n\t\tmethods: make(utils.HttpMethodSet, 1),\n\t}\n\n\t// lookup mir tag info from struct field\n\ttag, exist := field.Tag.Lookup(r.tagName)\n\tif !exist {\n\t\treturn nil, errNotExist\n\t}\n\n\t// Skip leading space.\n\ti := 0\n\tfor i < len(tag) && tag[i] == ' ' {\n\t\ti++\n\t}\n\ttag = tag[i:]\n\n\t// group info or method info or chain info\n\tinfo.fieldName = field.Name\n\tswitch field.Type.Kind() {\n\tcase reflect.Interface:\n\t\tif field.Type.PkgPath() != mirPkgName {\n\t\t\treturn nil, errors.New(\"not supported filed type\")\n\t\t}\n\t\tswitch field.Type.Name() {\n\t\tcase \"Chain\":\n\t\t\tinfo.isChain = true\n\t\t\treturn info, nil\n\t\tcase \"Group\":\n\t\t\tinfo.isGroup = true\n\t\t\tinfo.group = tag\n\t\t\treturn info, nil\n\t\tdefault:\n\t\t\treturn nil, errors.New(\"not supported filed type\")\n\t\t}\n\tcase reflect.Func:\n\t\tft := field.Type\n\t\tnumIn := ft.NumIn()\n\t\tnumOut := ft.NumOut()\n\t\tif numOut > 1 {\n\t\t\treturn nil, errors.New(\"func field just need one most return value\")\n\t\t}\n\t\tif numIn > 0 {\n\t\t\t// request type in latest in argument if declared\n\t\t\tit := ft.In(numIn - 1)\n\t\t\tif it.Kind() == reflect.Struct {\n\t\t\t\tcts, err := CheckStruct(it, pkgPath)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tinfo.in = it\n\t\t\t\tif it.PkgPath() != pkgPath {\n\t\t\t\t\tinfo.isBindIn = assert.AssertBinding(reflect.New(it).Interface())\n\t\t\t\t}\n\t\t\t\tinfo.inOuts = append(info.inOuts, cts...)\n\n\t\t\t\t// minus numIn to ignore latest in argument that had processed\n\t\t\t\tnumIn--\n\t\t\t}\n\n\t\t\t// process other in argument\n\t\t\tfor i := numIn - 1; i >= 0; i-- {\n\t\t\t\tit = ft.In(i)\n\t\t\t\tif it.PkgPath() != mirPkgName {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tswitch it.Name() {\n\t\t\t\tcase \"Get\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodGet)\n\t\t\t\tcase \"Put\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodPut)\n\t\t\t\tcase \"Post\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodPost)\n\t\t\t\tcase \"Delete\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodDelete)\n\t\t\t\tcase \"Head\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodHead)\n\t\t\t\tcase \"Options\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodOptions)\n\t\t\t\tcase \"Patch\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodPatch)\n\t\t\t\tcase \"Trace\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodTrace)\n\t\t\t\tcase \"Connect\":\n\t\t\t\t\tinfo.methods.Add(mir.MethodConnect)\n\t\t\t\tcase \"Any\":\n\t\t\t\t\tinfo.isAnyMethod = true\n\t\t\t\t\tinfo.methods.Add(mir.HttpMethods...)\n\t\t\t\tcase \"Chain\":\n\t\t\t\t\tinfo.isFieldChain = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// process special case for not set methods\n\t\tif len(info.methods) == 0 {\n\t\t\tinfo.isAnyMethod = true\n\t\t\tinfo.methods.Add(mir.HttpMethods...)\n\t\t}\n\t\tif numOut == 1 {\n\t\t\tot := ft.Out(i)\n\t\t\tif ot.Kind() != reflect.Struct {\n\t\t\t\treturn nil, errors.New(\"func field must return value is need struct type\")\n\t\t\t}\n\t\t\tcts, err := CheckStruct(ot, pkgPath)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tinfo.out = ot\n\t\t\tif ot.PkgPath() != pkgPath {\n\t\t\t\tinfo.isRenderOut = assert.AssertRender(reflect.New(ot).Interface())\n\t\t\t}\n\t\t\tinfo.inOuts = append(info.inOuts, cts...)\n\t\t}\n\tdefault:\n\t\treturn nil, errors.New(\"not supported filed type\")\n\t}\n\n\t// host info\n\tif len(tag) > 2 && tag[0] == '/' && tag[1] == '/' {\n\t\ti := 2\n\t\tfor i < len(tag) && tag[i] != '/' {\n\t\t\ti++\n\t\t}\n\t\tinfo.host = tag[2:i]\n\t\ttag = tag[i:]\n\t}\n\n\t// path info. must have path info if not a group field\n\tif len(tag) == 0 && !info.isGroup {\n\t\treturn nil, errNoPathInfo\n\t}\n\tfor i = 0; i < len(tag) && tag[i] != '#'; i++ {\n\t\tif !r.noneQuery && tag[i] == '?' {\n\t\t\tbreak\n\t\t}\n\t}\n\tinfo.path = tag[0:i]\n\ttag = tag[i:]\n\n\t// queries and handler info\n\tfor len(tag) != 0 {\n\t\tswitch tag[0] {\n\t\tcase '#':\n\t\t\ti := 1\n\t\t\tfor i < len(tag) && tag[i] != '?' {\n\t\t\t\ti++\n\t\t\t}\n\t\t\thandlerStr := tag[1:i]\n\t\t\ttag = tag[i:]\n\t\t\tif handlerStr != \"\" {\n\t\t\t\tif handlerStr[0] == '-' { // just contain chain func info\n\t\t\t\t\tinfo.chainFunc = handlerStr[1:]\n\t\t\t\t} else { // contain handler and inline chain info like #Handler&ChainFunc\n\t\t\t\t\thandlerChains := strings.Split(handlerStr, \"&\")\n\t\t\t\t\tinfo.handler = handlerChains[0]\n\t\t\t\t\tif len(handlerChains) > 1 { // extract chain func\n\t\t\t\t\t\tinfo.chainFunc = handlerChains[1]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tcase '?':\n\t\t\ti := 1\n\t\t\tfor i < len(tag) && tag[i] != '#' {\n\t\t\t\ti++\n\t\t\t}\n\t\t\tqueryStr := tag[1:i]\n\t\t\tif queryStr != \"\" {\n\t\t\t\tinfo.queries = r.inflateQuery(queryStr)\n\t\t\t}\n\t\t\ttag = tag[i:]\n\t\t}\n\t}\n\n\t// check handler if not group field\n\tif info.handler == \"\" {\n\t\t// assign handler name\n\t\tinfo.handler = utils.UpperFirst(field.Name)\n\t}\n\n\treturn info, nil\n}", "func (v Struct) Get(name string) Value {\n\tfor _, field := range v {\n\t\tif field.Name == name {\n\t\t\treturn field.Value\n\t\t}\n\t}\n\treturn nil\n}", "func (s *MyTestStruct) Name() string {\n\treturn s.field_Name\n}", "func (*buildingR) NewStruct() *buildingR {\n\treturn &buildingR{}\n}", "func (ds *DynamicStruct) Field(i int) reflect.StructField {\n\treturn ds.rt.Field(i)\n}", "func createFieldInfo(si *StructInfo, t reflect.Type) {\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfield := t.Field(i)\n\t\talias := fieldAlias(field)\n\t\tif alias == \"-\" { // Ignore this field.\n\t\t\tcontinue\n\t\t}\n\n\t\t//\n\t\tif field.Anonymous {\n\t\t\tanonymousType, _ := utils.RemovePointer(field.Type, false)\n\t\t\tcreateFieldInfo(si, anonymousType)\n\t\t}\n\n\t\tft, isSlice := utils.RemovePointer(field.Type, true)\n\t\tif isStruct := ft.Kind() == reflect.Struct; !isStruct {\n\t\t\t// GB: don't check if it's supported.\n\t\t\t/*\n\t\t\t\tif conv := c.conv[ft]; conv == nil {\n\t\t\t\t\t// Type is not supported.\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t*/\n\t\t}\n\t\tfi := &FieldInfo{\n\t\t\tName: field.Name,\n\t\t\tIndex: i,\n\t\t\tType: field.Type,\n\t\t\tIsSlice: isSlice,\n\t\t\tKind: core.UNKNOWN,\n\t\t}\n\t\t// TODO here judge if it's a page or component, store the type.\n\n\t\tsi.l.Lock()\n\t\tsi.Fields[strings.ToLower(alias)] = fi\n\t\tsi.l.Unlock()\n\t}\n}" ]
[ "0.7061889", "0.6469764", "0.61510986", "0.6143574", "0.6041583", "0.5890761", "0.58896327", "0.58850324", "0.587014", "0.58472174", "0.5809523", "0.580942", "0.57638764", "0.5722698", "0.5708856", "0.56878453", "0.5675025", "0.56681955", "0.56636596", "0.5662201", "0.5609322", "0.5607275", "0.5595225", "0.549378", "0.5486889", "0.54459417", "0.54374975", "0.54344517", "0.5414616", "0.54132426", "0.5409599", "0.5402012", "0.5392738", "0.5382655", "0.538209", "0.53647816", "0.53571665", "0.5351964", "0.5335954", "0.5311811", "0.5294095", "0.52830935", "0.5264315", "0.52588975", "0.5239523", "0.5234206", "0.52327806", "0.5228213", "0.5215345", "0.52144176", "0.52072734", "0.52057725", "0.5201764", "0.5193056", "0.517831", "0.516963", "0.5164607", "0.5159487", "0.51418304", "0.51341707", "0.51329434", "0.513291", "0.5120272", "0.51184905", "0.5116294", "0.5108897", "0.5104822", "0.50966626", "0.50933975", "0.50882363", "0.50880027", "0.50808156", "0.507697", "0.50749516", "0.507469", "0.5055799", "0.5054662", "0.5044169", "0.5043179", "0.5040028", "0.50378317", "0.5035981", "0.5026915", "0.501371", "0.5012485", "0.5009188", "0.5009188", "0.5009188", "0.5005291", "0.5003845", "0.4998415", "0.49850687", "0.49818617", "0.49769893", "0.4968341", "0.49670938", "0.49670735", "0.49670005", "0.49562144", "0.49502435" ]
0.6602846
1
Map returns struct name value as map
func (s *Structx) Map() map[string]interface{} { result := map[string]interface{}{} fs := s.Fields() for _, v := range fs { if !v.IsExport() { continue } result[v.Name()] = v.Value() } return result }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (self *Map) Map(key string, tagName ...string) map[typeutil.Variant]typeutil.Variant {\n\tif len(tagName) == 0 {\n\t\ttagName = []string{self.structTagKey}\n\t}\n\n\treturn self.Get(key).Map(tagName...)\n}", "func (s *simpleFieldMapper) Map(value string) map[string]string {\n\n\t// Create a new map\n\tresult := make(map[string]string)\n\n\t// Iterate over the fieldMapper field defs\n\tfor _, v := range s.FieldDefs {\n\t\t// Get the state of the field def\n\t\tstate := v.GetState(value)\n\t\t// Add the key and value of the field def to the result\n\t\tresult[state.key] = state.value\n\t}\n\n\t// Return the result\n\treturn result\n\n}", "func Struct2Map(v interface{}) (map[string]interface{}, error) {\n bytes, err := json.Marshal(v)\n if err != nil {\n return nil, err\n }\n data := make(map[string]interface{})\n if err := json.Unmarshal(bytes, &data); err != nil {\n return nil, err\n }\n return data, nil\n}", "func (*Map) Name() string { return \"map\" }", "func Map(target interface{}, useTag string) (map[string]interface{}, error) {\n\tif nil == target {\n\t\treturn nil, nil\n\t}\n\tv := reflect.ValueOf(target)\n\tfor v.Kind() == reflect.Ptr {\n\t\tv = v.Elem()\n\t}\n\tif v.Kind() != reflect.Struct {\n\t\treturn nil, ErrNoneStructTarget\n\t}\n\tt := v.Type()\n\tresult := make(map[string]interface{})\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tkeyName := getKey(t.Field(i), useTag)\n\t\tif \"\" == keyName {\n\t\t\tcontinue\n\t\t}\n\t\tresult[keyName] = v.Field(i).Interface()\n\t}\n\treturn result, nil\n}", "func jsonNameMap(structType interface{}) map[string]string {\n\tsType := reflect.TypeOf(structType)\n\tnFields := sType.NumField()\n\tret := make(map[string]string, nFields)\n\tfor i := 0; i < nFields; i++ {\n\t\tf := sType.Field(i)\n\t\tjsonName := strings.SplitN(f.Tag.Get(\"json\"), \",\", 2)[0]\n\t\tif jsonName == \"\" || jsonName == \"-\" {\n\t\t\tcontinue\n\t\t}\n\t\tret[f.Name] = jsonName\n\t}\n\treturn ret\n}", "func StructToMap(i interface{}) (values map[string]interface{}) {\n\tvalues = map[string]interface{}{}\n\tiVal := reflect.Indirect(reflect.ValueOf(&i)).Elem()\n\ttyp := iVal.Type()\n\tfor i := 0; i < iVal.NumField(); i++ {\n\t\tf := iVal.Field(i)\n\t\t// You ca use tags here...\n\t\t// tag := typ.Field(i).Tag.Get(\"tagname\")\n\t\t// Convert each type into a string for the url.Values string map\n\t\tvar v string\n\t\tswitch f.Interface().(type) {\n\t\tcase int, int8, int16, int32, int64:\n\t\t\tv = strconv.FormatInt(f.Int(), 10)\n\t\tcase uint, uint8, uint16, uint32, uint64:\n\t\t\tv = strconv.FormatUint(f.Uint(), 10)\n\t\tcase float32:\n\t\t\tv = strconv.FormatFloat(f.Float(), 'f', 4, 32)\n\t\tcase float64:\n\t\t\tv = strconv.FormatFloat(f.Float(), 'f', 4, 64)\n\t\tcase []byte:\n\t\t\tv = string(f.Bytes())\n\t\tcase string:\n\t\t\tv = f.String()\n\t\t}\n\t\tvalues[typ.Field(i).Name] = v\n\t}\n\treturn\n}", "func Struct2Map(obj interface{}) map[string]interface{} {\n\tv := reflect.ValueOf(obj)\n\tt := v.Elem()\n\ttypeOfType := t.Type()\n\n\tvar data = make(map[string]interface{})\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tvar f string\n\t\tif typeOfType.Field(i).Tag.Get(\"json\") == \"\" {\n\t\t\tf = typeOfType.Field(i).Name\n\t\t} else {\n\t\t\tf = typeOfType.Field(i).Tag.Get(\"json\")\n\t\t}\n\t\tdata[f] = t.Field(i).Interface()\n\t}\n\treturn data\n}", "func Struct2Map(st interface{}) map[string]interface{} {\n\tvt := reflect.TypeOf(st)\n\tvv := reflect.ValueOf(st)\n\tvar data = make(map[string]interface{})\n\tfor i := 0; i < vt.NumField(); i++ {\n\t\tf := vt.Field(i)\n\t\tv := vv.Field(i)\n\t\tchKey := f.Tag.Get(\"json\")\n\t\tswitch v.Kind() {\n\t\tcase reflect.String:\n\t\t\tif s, ok := v.Interface().(string); ok && s != \"\" {\n\t\t\t\tdata[chKey] = s\n\t\t\t}\n\t\tcase reflect.Int:\n\t\t\tif i, ok := v.Interface().(int); ok && i != 0 {\n\t\t\t\tdata[chKey] = i\n\t\t\t}\n\t\tcase reflect.Struct:\n\t\t\tif t, ok := v.Interface().(time.Time); ok && t != (time.Time{}) {\n\t\t\t\tdata[chKey] = t\n\t\t\t}\n\t\tcase reflect.Uint64:\n\t\t\tif u64, ok := v.Interface().(uint64); ok && u64 != 0 {\n\t\t\t\tdata[chKey] = u64\n\t\t\t}\n\t\tcase reflect.Int64:\n\t\t\tif u64, ok := v.Interface().(int64); ok && u64 != 0 {\n\t\t\t\tdata[chKey] = u64\n\t\t\t}\n\t\tcase reflect.Uint:\n\t\t\tif u, ok := v.Interface().(uint); ok && u != 0 {\n\t\t\t\tdata[chKey] = u\n\t\t\t}\n\t\tcase reflect.Float32:\n\t\t\tif u, ok := v.Interface().(float32); ok && u != 0 {\n\t\t\t\tdata[chKey] = u\n\t\t\t}\n\t\tcase reflect.Float64:\n\t\t\tif u, ok := v.Interface().(float64); ok && u != 0 {\n\t\t\t\tdata[chKey] = u\n\t\t\t}\n\t\tcase reflect.Bool:\n\t\t\tif u, ok := v.Interface().(bool); ok {\n\t\t\t\tdata[chKey] = u\n\t\t\t}\n\n\t\tdefault:\n\t\t\tglog.Error(\"unsupport common query type: \" + string(chKey))\n\t\t}\n\t}\n\treturn data\n}", "func structToMap(t reflect.Type) (out map[string]interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tmlog.Error(fmt.Sprintf(\"Panicked in structToMap. This should never happen. %v\", r))\n\t\t}\n\t}()\n\n\tif t.Kind() != reflect.Struct {\n\t\t// Should never hit this, but this will prevent a panic if that does happen somehow\n\t\treturn nil\n\t}\n\n\tout = map[string]interface{}{}\n\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfield := t.Field(i)\n\n\t\tvar value interface{}\n\n\t\tswitch field.Type.Kind() {\n\t\tcase reflect.Struct:\n\t\t\tvalue = structToMap(field.Type)\n\t\tcase reflect.Ptr:\n\t\t\tindirectType := field.Type.Elem()\n\n\t\t\tif indirectType.Kind() == reflect.Struct {\n\t\t\t\t// Follow pointers to structs since we need to define defaults for their fields\n\t\t\t\tvalue = structToMap(indirectType)\n\t\t\t} else {\n\t\t\t\tvalue = nil\n\t\t\t}\n\t\tdefault:\n\t\t\tvalue = reflect.Zero(field.Type).Interface()\n\t\t}\n\n\t\tout[field.Name] = value\n\t}\n\n\treturn\n}", "func Map(v interface{}) map[string]interface{} {\n\treturn New(v).Map()\n}", "func (qq Qualifiers) Map() map[string]string {\n\tm := make(map[string]string)\n\n\tfor i := 0; i < len(qq); i++ {\n\t\tk := qq[i].Key\n\t\tv := qq[i].Value\n\t\tm[k] = v\n\t}\n\n\treturn m\n}", "func makeMap(yamlStruct T) map[string]string {\n\turlMap := make(map[string]string)\n\tfor _, s := range yamlStruct {\n\t\turlMap[s.P] = s.U\n\t}\n\treturn urlMap\n}", "func (u *Util) StructToMap(data interface{}) (map[string]interface{}, error) {\n result := make(map[string]interface{})\n\n b, err := json.Marshal(data)\n if err != nil { return nil, err }\n\n err = json.Unmarshal(b, &result)\n return result, err\n}", "func (e *Extractor) FieldValueFromTagMap(tag string) (out map[string]interface{}, err error) {\n\n\tif err := e.isValidStruct(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tout = make(map[string]interface{})\n\ts := reflect.ValueOf(e.StructAddr).Elem()\n\tfields := e.fields(s)\n\n\tfor _, field := range fields {\n\t\tif val, ok := field.tags.Lookup(tag); ok {\n\t\t\tkey, omit := e.parseOmitempty(val, field.value)\n\t\t\tif omit {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tout[key] = field.value.Interface()\n\t\t}\n\n\t}\n\n\treturn\n}", "func (e *Extractor) TagMapping(from, to string) (out map[string]string, err error) {\n\tif err := e.isValidStruct(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tout = make(map[string]string)\n\ts := reflect.ValueOf(e.StructAddr).Elem()\n\tfields := e.fields(s)\n\n\tfor _, field := range fields {\n\t\tfromTag, fromOk := field.tags.Lookup(from)\n\t\ttoTag, toOk := field.tags.Lookup(to)\n\t\tif toOk && fromOk {\n\t\t\tout[fromTag] = toTag\n\t\t}\n\t}\n\n\treturn\n}", "func (r *ReflectMapper) FieldMap(v reflect.Value) map[string]reflect.Value {\n\tv = reflect.Indirect(v)\n\n\tret := map[string]reflect.Value{}\n\ttm := r.mapper.TypeMap(v.Type())\n\tfor tagName, fi := range tm.Names {\n\t\t//fmt.Println(tagName,fi.Parent.Zero.Kind(),fi.Parent.Field.Anonymous)\n\t\tif (fi.Parent.Zero.Kind() == reflect.Struct || (fi.Zero.Kind() == reflect.Ptr && fi.Zero.Type().Elem().Kind() == reflect.Struct)) && !fi.Parent.Field.Anonymous {\n\t\t\tcontinue\n\t\t}\n\t\tret[tagName] = reflectx.FieldByIndexes(v, fi.Index)\n\t}\n\n\treturn ret\n}", "func CreateMap(i interface{}, indent int) (map[string]interface{}, error) {\n\tm := make(map[string]interface{})\n\tv := reflect.ValueOf(i)\n\tif v.Kind() == reflect.Ptr {\n\t\tv = reflect.Indirect(v)\n\t}\n\tif v.Kind() != reflect.Struct {\n\t\treturn nil, ErrNotAStruct\n\t}\n\tif indent > 0 {\n\t\tfmt.Fprintln(writer,\"Struct: \", strings.Repeat(\" \", indent), v.Type().Name())\n\t} else {\n\t\tfmt.Fprintln(writer,\"Struct:\", v.Type().Name())\n\t}\n\tindent++\n\tscanner := bufio.NewScanner(reader)\n\tfor i := 0; i < v.NumField(); i++ {\n\t\tvar t string\n\t\tf := v.Field(i)\n\t\tn := v.Type().Field(i).Name\n\n\t\tswitch f.Kind() {\n\t\tcase reflect.Struct:\n\t\t\tfmt.Fprintf(writer, \"%sEmbedded struct: %s (name: %s)\\n\", strings.Repeat(\" \", indent+1), n, v.Type().Name())\n\t\tcase reflect.Ptr:\n\t\t\tfmt.Fprintf(writer, \"%sEmbedded pointer: %s (name: %s)\\n\", strings.Repeat(\" \", indent+1), n, v.Type().Name())\n\t\tcase reflect.Func, reflect.Uintptr, reflect.UnsafePointer, reflect.Chan:\n\t\t\tcontinue\n\t\tcase reflect.Interface:\n\t\t\t// if this isn't the empty interface we don't want to store data in it\n\t\t\tif f.NumMethod() != 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tif f.Kind() == reflect.Map || f.Kind() == reflect.Slice {\n\t\t\t// if we don't have a valid value type, skip it\n\t\t\tvtyp := reflect.New(f.Type().Elem())\n\t\t\t// TODO - fix - this shouldn't be here, too tired when working on this\n\t\t\tif !ValueTypeIsValid(vtyp, 0) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tif f.Kind() != reflect.Struct && f.Kind() != reflect.Ptr {\n\t\t\tfmt.Fprintf(writer, \"%sPlease enter a value for %s (type: %s)\", strings.Repeat(\" \", indent), n, f.Kind().String())\n\t\t\tif f.Kind() == reflect.Slice {\n\t\t\t\tfmt.Fprintf(writer, \"(%s) (enter your values as a comma separated list) ex: '1,2,3', 'I love configs!' - using double quotes will ignore commas inside them, like a csv. For slices of slices, use double quotes around each slice value: ex: \\\"1,2,3\\\",\\\"a,b,c\\\"\", f.Type().Elem())\n\t\t\t}\n\n\t\t\tif f.Kind() == reflect.Map {\n\t\t\t\tfmt.Fprintf(writer, \"KeyType: %s, ValueType:%s, (enter your values as a comma separated list of key value pairs separated by a colon) ex: 'first_key:first_value,second_key:secondvalue'\", f.Type().Key(), f.Type().Elem())\n\t\t\t}\n\n\t\t\tfmt.Fprintf(writer, \"\\n%s\", strings.Repeat(\" \", indent))\n\t\t\tscanner.Scan()\n\t\t\tt = scanner.Text()\n\t\t}\n\n\n\t\ti, err := ParseType(t, f.Type(), indent)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif i != nil {\n\t\t\tm[n] = i\n\t\t}\n\n\t}\n\treturn m, nil\n}", "func getMapping(t reflect.Type, mapFunc func(string) string) fieldMap {\n\ttype typeQueue struct {\n\t\tt reflect.Type\n\t\tp []int\n\t}\n\n\tqueue := []typeQueue{typeQueue{deref(t), []int{}}}\n\tm := fieldMap{}\n\tfor len(queue) != 0 {\n\t\t// Pop the first item off of the queue.\n\t\ttq := queue[0]\n\t\tqueue = queue[1:]\n\t\t// Iterate through all of its fields.\n\t\tfor fieldPos := 0; fieldPos < tq.t.NumField(); fieldPos++ {\n\t\t\tf := tq.t.Field(fieldPos)\n\n\t\t\tname, optlock := readTag(f.Tag.Get(tagName))\n\n\t\t\t// Breadth first search of untagged anonymous embedded structs.\n\t\t\tif f.Anonymous && f.Type.Kind() == reflect.Struct && name == \"\" {\n\t\t\t\tqueue = append(queue, typeQueue{deref(f.Type), appendIndex(tq.p, fieldPos)})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Skip unexported fields.\n\t\t\tif len(f.PkgPath) != 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// If the name is \"-\", disabled via a tag, skip it.\n\t\t\tif name == \"-\" {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif len(name) == 0 {\n\t\t\t\tif mapFunc != nil {\n\t\t\t\t\tname = mapFunc(f.Name)\n\t\t\t\t} else {\n\t\t\t\t\tname = f.Name\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If the name is shadowed by an earlier identical name in the\n\t\t\t// search, skip it.\n\t\t\tif _, ok := m[name]; ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Add it to the map at the current position.\n\t\t\tsf := f\n\t\t\tsf.Index = appendIndex(tq.p, fieldPos)\n\t\t\tm[name] = fieldDesc{sf, optlock}\n\t\t}\n\t}\n\treturn m\n}", "func MapToStruct(m map[string]interface{}, struc interface{}) error {\n\t//fmt.Printf(\"Input map: %+v\\n\", m)\n\t//fmt.Printf(\"Input struc: %+v\\n\", struc)\n\tval := r.Indirect(r.ValueOf(struc))\n\tsinfo := getStructInfo(val)\n\t//fmt.Printf(\"sinfo: %+v\\n\", sinfo)\n\tfor k, v := range m {\n\t\t//fmt.Printf(\"k: %+v v: %+v\\n\", k, v)\n\t\tif info, ok := sinfo.FieldsMap[k]; ok {\n\t\t\t//fmt.Printf(\"info: %+v\\n\", info)\n\t\t\tstructField := val.Field(info.Num)\n\t\t\t//fmt.Printf(\"type struct: %q, %q, %q\\n\", structField.Type(), structField.Type().Name(), structField.Kind())\n\t\t\t//fmt.Printf(\"type value: %q\\n\", r.TypeOf(v).Name())\n\t\t\t//fmt.Printf(\"value: %+v\\n\", r.ValueOf(v))\n\t\t\tif structField.Kind().String() == \"slice\" && r.TypeOf(v).Kind().String() == \"slice\" {\n\t\t\t\tif structField.Type().Elem() == r.TypeOf(v).Elem() {\n\t\t\t\t\t//fmt.Print(\"Slices of same type\\n\")\n\t\t\t\t\tstructField.Set(r.ValueOf(v))\n\t\t\t\t} else if structField.Type().Elem().Kind().String() == r.TypeOf(v).Elem().Kind().String() {\n\t\t\t\t\t//fmt.Print(\"Slices of same kind\\n\")\n\t\t\t\t\ts := r.ValueOf(v)\n\t\t\t\t\tresult := r.MakeSlice(structField.Type(), 0, s.Len())\n\t\t\t\t\tfor j := 0; j < s.Len(); j++ {\n\t\t\t\t\t\tresult = r.Append(result, r.ValueOf(s.Index(j).Interface()).Convert(structField.Type().Elem()))\n\t\t\t\t\t}\n\t\t\t\t\tstructField.Set(result)\n\t\t\t\t} else if r.TypeOf(v).Elem().String() == \"string\" {\n\t\t\t\t\t//fmt.Print(\"Slices of different kind\\n\")\n\t\t\t\t\tstringList := v.([]string)\n\t\t\t\t\tresult := r.MakeSlice(structField.Type(), 0, len(stringList))\n\t\t\t\t\tfor _, str := range stringList {\n\t\t\t\t\t\ttmp := r.New(structField.Type().Elem())\n\t\t\t\t\t\terr := json.Unmarshal([]byte(str), tmp.Interface())\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t//fmt.Printf(\"Unmarshal failed on: %q due to: %q!!!\\n\", str, err)\n\t\t\t\t\t\t\t//return err\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tresult = r.Append(result, r.Indirect(tmp))\n\t\t\t\t\t}\n\t\t\t\t\tstructField.Set(result)\n\t\t\t\t}\n\t\t\t} else if structField.Type().Name() == \"\" || r.TypeOf(v).Name() == \"\" {\n\t\t\t\treturn fmt.Errorf(\"WTF are these types???!!! %q %q\\n\", structField.Kind().String(), r.TypeOf(v).Kind().String())\n\t\t\t} else if structField.Type().Name() == r.TypeOf(v).Name() {\n\t\t\t\t//fmt.Print(\"Field set naturally!!!\\n\")\n\t\t\t\tstructField.Set(r.ValueOf(v))\n\t\t\t} else if structField.Kind().String() == r.TypeOf(v).Name() {\n\t\t\t\t//fmt.Print(\"Field set with convert !!!\\n\")\n\t\t\t\tstructField.Set(r.ValueOf(v).Convert(structField.Type()))\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"Please handle these types: %s with %s\\n\", structField.Kind().String(), r.TypeOf(v).Kind().String())\n\t\t\t}\n\t\t} else {\n\t\t\t//fmt.Printf(\"field %q not found\\n\", k) TODO: in which situation do we reach this point? oO\n\t\t}\n\t\t//fmt.Printf(\"Check fill struc: %+v\\n\", struc)\n\t}\n\treturn nil\n}", "func mapTags(tags []*elb.Tag) map[string]string {\n\ttagMap := make(map[string]string)\n\tfor _, t := range tags {\n\t\ttagMap[*t.Key] = *t.Value\n\t}\n\n\treturn tagMap\n}", "func (i GinJwtSignAlgorithm) NameMap() map[string]GinJwtSignAlgorithm {\n\treturn _GinJwtSignAlgorithmNameToValueMap\n}", "func (p Doc) Map() map[string]string {\n\tm := make(map[string]string)\n\n\tp.Foreach(func(v, k string) bool { m[k] = v; return true })\n\n\treturn m\n}", "func GetValueTagMap(src map[string]interface{}) map[string]interface{} {\n\tres := NewEmptyTagMap()\n\tres[\"inname\"] = \"value\"\n\tres[\"exname\"] = \"value\"\n\tres[\"type\"] = src[\"type\"]\n\tres[\"length\"] = src[\"length\"]\n\tres[\"scale\"] = src[\"scale\"]\n\tres[\"precision\"] = src[\"precision\"]\n\tres[\"fieldid\"] = src[\"fieldid\"]\n\treturn res\n}", "func (c *Config) MapStruct(key string, dst any) error {\n\treturn c.Structure(key, dst)\n}", "func (t *Type) MapType() *MapType", "func (self *Map) MapString(tagName ...string) map[string]string {\n\tvar rv = make(map[string]string)\n\n\tfor k, v := range self.MapNative(tagName...) {\n\t\trv[k] = typeutil.String(v)\n\t}\n\n\treturn rv\n}", "func Msg2Map(msg proto.Message) map[string]interface{} {\n\tt := reflect.TypeOf(msg)\n\tv := reflect.ValueOf(msg)\n\n\treturn buildStruct(t, v)\n}", "func parseMap(v interface{}) (map[string]interface{}, error) {\n\tstructRfl := reflect.ValueOf(v)\n\n\tresult := map[string]interface{}{}\n\n\t// Fail if the passed type is not a map\n\tif structRfl.Kind() != reflect.Map {\n\t\treturn result, fmt.Errorf(\"Expected map, got: %s\", structRfl.Kind().String())\n\t}\n\n\tmapRange := structRfl.MapRange()\n\tfor mapRange.Next() {\n\t\tresult[mapRange.Key().String()] = mapRange.Value().Interface()\n\t}\n\n\treturn result, nil\n}", "func getNameAndValue(m *dto.Metric) map[string]interface{} {\n\tfields := make(map[string]interface{})\n\tif m.Gauge != nil {\n\t\tif !math.IsNaN(m.GetGauge().GetValue()) {\n\t\t\t//nolint:unconvert // Conversion may be needed for float64 https://github.com/mdempsky/unconvert/issues/40\n\t\t\tfields[\"gauge\"] = float64(m.GetGauge().GetValue())\n\t\t}\n\t} else if m.Counter != nil {\n\t\tif !math.IsNaN(m.GetCounter().GetValue()) {\n\t\t\t//nolint:unconvert // Conversion may be needed for float64 https://github.com/mdempsky/unconvert/issues/40\n\t\t\tfields[\"counter\"] = float64(m.GetCounter().GetValue())\n\t\t}\n\t} else if m.Untyped != nil {\n\t\tif !math.IsNaN(m.GetUntyped().GetValue()) {\n\t\t\t//nolint:unconvert // Conversion may be needed for float64 https://github.com/mdempsky/unconvert/issues/40\n\t\t\tfields[\"value\"] = float64(m.GetUntyped().GetValue())\n\t\t}\n\t}\n\treturn fields\n}", "func ConfigToMap(in interface{}, tag string) (map[string]string, error) {\n\tout := make(map[string]string)\n\n\tv := reflect.ValueOf(in)\n\tif v.Kind() == reflect.Ptr {\n\t\tv = v.Elem()\n\t}\n\n\tif v.Kind() != reflect.Struct {\n\t\treturn nil, fmt.Errorf(\"ConfigToMap only accepts structs got %T\", v)\n\t}\n\n\ttyp := v.Type()\n\tfor i := 0; i < v.NumField(); i++ {\n\t\tfi := typ.Field(i)\n\t\tif mtag := fi.Tag.Get(tag); mtag != \"\" {\n\t\t\tout[mtag] = fmt.Sprint(v.Field(i).Interface())\n\t\t}\n\t}\n\treturn out, nil\n}", "func Map2Struct(in map[string]interface{}, out interface{}, configs ...*MapConfiguration) {\n\n\tconfig := combineConfiguration(configs...)\n\n\tfor key, value := range in {\n\t\tif config.ShouldIgnore(key) {\n\t\t\tcontinue\n\t\t}\n\t\tsetFieldValue(reflect.ValueOf(out).Elem(), config.Name(key), reflect.ValueOf(value), config)\n\t}\n}", "func (v *Value) Map() map[string]interface{} {\n\tval := make(map[string]interface{})\n\tkeys := &Value{value: C.value_array_keys(v.value)}\n\n\tfor _, k := range keys.Slice() {\n\t\tswitch key := k.(type) {\n\t\tcase int64:\n\t\t\tt := &Value{value: C.value_array_index_get(v.value, C.ulong(key))}\n\t\t\tsk := strconv.Itoa((int)(key))\n\n\t\t\tval[sk] = t.Interface()\n\t\t\tt.Destroy()\n\t\tcase string:\n\t\t\tstr := C.CString(key)\n\t\t\tt := &Value{value: C.value_array_key_get(v.value, str)}\n\t\t\tC.free(unsafe.Pointer(str))\n\n\t\t\tval[key] = t.Interface()\n\t\t\tt.Destroy()\n\t\t}\n\t}\n\n\tkeys.Destroy()\n\treturn val\n}", "func Map(vars ...Variable) map[string]interface{} {\n\tresult := map[string]interface{}{}\n\tfor _, v := range vars {\n\t\tresult[(string)(v)] = v.Value()\n\t}\n\treturn result\n}", "func compileStruct(t reflect.Type) map[string]interface{} {\n\tfs := map[string]interface{}{}\n\tcount := t.NumField()\n\tfor i := 0; i < count; i++ {\n\t\tf := t.Field(i)\n\t\tvar name string\n\t\tif !f.Anonymous {\n\t\t\tname = f.Name\n\t\t\tif tName := f.Tag.Get(\"nbt\"); len(tName) > 0 {\n\t\t\t\tname = tName\n\t\t\t}\n\t\t\tif name == \"ignore\" || f.Tag.Get(\"ignore\") == \"true\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t} else {\n\t\t\tname = f.Type.Name()\n\t\t\tif tName := f.Tag.Get(\"nbt\"); len(tName) > 0 {\n\t\t\t\tname = tName\n\t\t\t}\n\t\t\tif name == \"ignore\" || f.Tag.Get(\"ignore\") == \"true\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tfs[name] = compileField(f, name)\n\t}\n\treturn fs\n}", "func StructToMap(val interface{}) (map[string]interface{}, bool) {\n\t// indirect so function works with both structs and pointers to them\n\tstructVal := r.Indirect(r.ValueOf(val))\n\tkind := structVal.Kind()\n\tif kind != r.Struct {\n\t\treturn nil, false\n\t}\n\tsinfo := getStructInfo(structVal)\n\tmapVal := make(map[string]interface{}, len(sinfo.FieldsList))\n\tfor _, field := range sinfo.FieldsList {\n\t\tif structVal.Field(field.Num).CanInterface() {\n\t\t\tmapVal[field.Key] = structVal.Field(field.Num).Interface()\n\t\t}\n\t}\n\treturn mapVal, true\n}", "func ScanStructIntoMap(obj interface{}) (map[string]interface{}, error) {\n\tdataStruct := reflect.Indirect(reflect.ValueOf(obj))\n\tif dataStruct.Kind() != reflect.Struct {\n\t\treturn nil, errors.New(\"expected a pointer to a struct\")\n\t}\n\n\tdataStructType := dataStruct.Type()\n\n\tmapped := make(map[string]interface{})\n\n\tfor i := 0; i < dataStructType.NumField(); i++ {\n\t\tfield := dataStructType.Field(i)\n\t\tfieldName := field.Name\n\n\t\tmapKey := snakeCasedName(fieldName)\n\t\tvalue := dataStruct.FieldByName(fieldName).Interface()\n\n\t\tmapped[mapKey] = value\n\t}\n\n\treturn mapped, nil\n}", "func structToMap(structPtr interface{}, depth int, prefix ...string) FieldMap {\n\tval := reflect.ValueOf(structPtr)\n\tind := reflect.Indirect(val)\n\tif val.Kind() != reflect.Ptr || ind.Kind() != reflect.Struct {\n\t\ttools.LogAndPanic(log, \"structPtr must be a pointer to a struct\", \"structPtr\", structPtr)\n\t}\n\tres := make(FieldMap)\n\tfor i := 0; i < ind.NumField(); i++ {\n\t\tvar fieldName string\n\t\tif len(prefix) > 0 {\n\t\t\tfieldName = fmt.Sprintf(\"%s.%s\", prefix[0], ind.Type().Field(i).Name)\n\t\t} else {\n\t\t\tfieldName = ind.Type().Field(i).Name\n\t\t}\n\t\tfieldValue := ind.Field(i)\n\t\tvar resVal interface{}\n\t\tif fieldValue.Kind() == reflect.Ptr {\n\t\t\t// Get the related struct if not nil\n\t\t\trelInd := reflect.Indirect(fieldValue)\n\t\t\trelTyp := fieldValue.Type().Elem()\n\t\t\tswitch relTyp.Kind() {\n\t\t\tcase reflect.Struct:\n\t\t\t\tif depth > 0 {\n\t\t\t\t\tif !relInd.IsValid() {\n\t\t\t\t\t\t// create the struct if the pointer is nil\n\t\t\t\t\t\tfieldValue = reflect.New(relTyp)\n\t\t\t\t\t}\n\t\t\t\t\t// get the related struct fields\n\t\t\t\t\trelMap := structToMap(fieldValue.Interface(), depth-1, fieldName)\n\t\t\t\t\tfor k, v := range relMap {\n\t\t\t\t\t\tres[k] = v\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif !relInd.IsValid() {\n\t\t\t\t\t\t// Skip if pointer is nil\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\t// get the ID of the related struct\n\t\t\t\t\tresVal = relInd.FieldByName(\"ID\").Interface()\n\t\t\t\t}\n\t\t\t}\n\t\t\tif relInd.Kind() != reflect.Struct {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t} else {\n\t\t\tresVal = ind.Field(i).Interface()\n\t\t}\n\t\tres[fieldName] = resVal\n\t}\n\treturn res\n}", "func NamesMap() map[string]uint32 {\n\treturn map[string]uint32{\n\t\t\"dcOption\": DCOptionTypeID,\n\t\t\"config\": ConfigTypeID,\n\t}\n}", "func (node *selfNode) packToMap(m reflect.Value) (err error) {\n\n\tvar (\n\t\tkey interface{}\n\t\tvalue reflect.Value\n\t)\n\n\tnodeName := node.head.String()\n\tkeyType, elemType := m.Type().Key(), m.Type().Elem()\n\n\tfor _, n := range node.values {\n\t\tif _, ok := n.(*selfNode); !ok {\n\t\t\treturn n.newPackError(\"field `\" + nodeName + \"` should be only made of lists\")\n\t\t}\n\t\tvalueNode := n.(*selfNode)\n\t\tnodeHead := valueNode.head\n\t\tif key, err = nodeHead.encodeScalarField(keyType.Kind()); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tvalue = reflect.New(elemType).Elem()\n\t\tif err = valueNode.packIntoField(nodeHead.String(), value); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tm.SetMapIndex(reflect.ValueOf(key), value)\n\t}\n\treturn\n}", "func (i GinBindType) NameMap() map[string]GinBindType {\n\treturn _GinBindTypeNameToValueMap\n}", "func GetFieldMap(obj interface{}) (ret map[string]string) {\n\tval := reflect.ValueOf(obj).Elem()\n\tret = make(map[string]string)\n\tfor i := 0; i < val.NumField(); i++ {\n\t\ttypeField := val.Type().Field(i)\n\t\tkey := strings.ToLower(typeField.Name)\n\t\tif typeField.PkgPath != \"\" {\n\t\t\t// Private method\n\t\t\tcontinue\n\t\t} else {\n\t\t\tret[key] = typeField.Name\n\t\t}\n\t}\n\treturn\n}", "func (opts *ListOpts) GetMap() map[string]struct{} {\n ret := make(map[string]struct{})\n for _, k := range *opts.values {\n ret[k] = struct{}{}\n }\n return ret\n}", "func (i SNSProtocol) NameMap() map[string]SNSProtocol {\n\treturn _SNSProtocolNameToValueMap\n}", "func (kvs KeyValues) Map() map[string]string {\n\tvar m = make(map[string]string)\n\tfor idx := range kvs {\n\t\tm[kvs[idx].Key] = kvs[idx].Value\n\t}\n\treturn m\n}", "func StructToMap(in interface{}) (out map[string]interface{}) {\n\t// TODO use reflect to avoid encode-map-to-JSON then decode-JSON-to-struct\n\tout = nil\n\tif enc, err := json.Marshal(in); err == nil {\n\t\tout = make(map[string]interface{})\n\t\terr1 := json.Unmarshal(enc, &out)\n\t\tif err1 != nil {\n\t\t\tpanic(err1)\n\t\t}\n\t} else {\n\t\tpanic(err)\n\t}\n\treturn\n}", "func StructToMap(v interface{}) operator.M {\n\tdata := make(operator.M)\n\tbytes, _ := json.Marshal(v)\n\t_ = json.Unmarshal(bytes, &data)\n\treturn data\n}", "func (m *StructMapper) Map(src, dst interface{}) {\n\n\tif debug {\n\t\ttypeConversion := fmt.Sprintf(\"%s-%s\", reflect.ValueOf(src).Type(), reflect.ValueOf(dst).Type())\n\t\tfmt.Println(\"Enter Map() \", typeConversion)\n\t\tdefer fmt.Println(\"Leaving Map() \", typeConversion)\n\t}\n\n\tm.mapValue(reflect.ValueOf(src).Elem(), reflect.ValueOf(dst).Elem())\n}", "func (i SNSSubscribeAttribute) NameMap() map[string]SNSSubscribeAttribute {\n\treturn _SNSSubscribeAttributeNameToValueMap\n}", "func (node *Mapping) Map() (m map[interface{}]interface{}) {\n\tm = make(map[interface{}]interface{}, len(node.Pairs))\n\tfor _, pair := range node.Pairs {\n\t\tm[pair.Key.Data()] = pair.Value.Data()\n\t}\n\treturn\n}", "func processMap(name string, arr map[string]interface{}, value proto.Message) (reflect.Value, *adapter.ConfigErrors) {\n\tvar ce *adapter.ConfigErrors\n\tptrType := reflect.TypeOf(value)\n\tvalueType := reflect.Indirect(reflect.ValueOf(value)).Type()\n\toutmap := reflect.MakeMap(reflect.MapOf(reflect.ValueOf(\"\").Type(), ptrType))\n\tfor vname, val := range arr {\n\t\tdm := reflect.New(valueType).Interface().(proto.Message)\n\t\tif cerr := updateMsg(fmt.Sprintf(\"%s[%s]\", name, vname), val, dm, value, false); cerr != nil {\n\t\t\tce = ce.Extend(cerr)\n\t\t\tcontinue\n\t\t}\n\t\toutmap.SetMapIndex(reflect.ValueOf(vname), reflect.ValueOf(dm))\n\t}\n\treturn outmap, ce\n}", "func ConvertMapToStruct(v map[string]interface{}) (interface{}, error) {\n\tif v == nil {\n\t\treturn nil, nil\n\t}\n\n\trv := reflect.ValueOf(v)\n\tif !rv.IsValid() {\n\t\treturn nil, xerrors.Errorf(\"%#v is invalid\", v)\n\t}\n\n\tinstance := dynamicstruct.NewStruct()\n\n\ttype KeyValue struct {\n\t\tName string\n\t\tValue reflect.Value\n\t}\n\n\tkeys := rv.MapKeys()\n\tcollectedKeys := make([]KeyValue, len(keys))\n\tfor i, key := range keys {\n\t\tvalue := rv.MapIndex(key)\n\t\tif !value.CanInterface() {\n\t\t\treturn nil, xerrors.Errorf(\"cannot make interface for value of %s\", key.String())\n\t\t}\n\n\t\tif subMap, ok := value.Interface().(map[string]interface{}); ok {\n\t\t\tsubStruct, err := ConvertMapToStruct(subMap)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, xerrors.Errorf(\"cannot convert child map (key=%s) to struct: %w\", key.String(), err)\n\t\t\t}\n\t\t\tvalue = reflect.ValueOf(subStruct)\n\t\t\tif !value.CanInterface() {\n\t\t\t\treturn nil, xerrors.Errorf(\"cannot make interface for value of %s\", key.String())\n\t\t\t}\n\t\t}\n\n\t\tcollectedKeys[i] = KeyValue{\n\t\t\tName: strings.Title(key.String()),\n\t\t\tValue: value.Elem(),\n\t\t}\n\t}\n\n\t// sort keys\n\tsort.Slice(collectedKeys, func(i, j int) bool {\n\t\treturn strings.Compare(collectedKeys[i].Name, collectedKeys[j].Name) < 0\n\t})\n\n\tfor _, key := range collectedKeys {\n\t\tinstance = instance.AddField(key.Name, key.Value.Interface(), \"\")\n\t}\n\n\tst := instance.Build().New()\n\trst := reflect.ValueOf(st).Elem()\n\n\tfor _, key := range collectedKeys {\n\t\tf := rst.FieldByName(key.Name)\n\t\tif !f.IsValid() {\n\t\t\treturn nil, xerrors.Errorf(\"unable to find %s in new struct\", key.Name)\n\t\t}\n\t\tif !f.CanSet() {\n\t\t\treturn nil, xerrors.Errorf(\"unable to set value for %s in new struct\", key.Name)\n\t\t}\n\t\tf.Set(key.Value)\n\t}\n\n\treturn st, nil\n}", "func (s SliceOfBar) AsMap() map[string]*Bar {\n\tresult := make(map[string]*Bar)\n\tfor _, value := range s {\n\t\tresult[value.ID] = value\n\t}\n\treturn result\n}", "func (c *Config) Map() map[string]string {\n\treturn c.v\n}", "func ToStringStringMap(tagName string, input interface{}, properties ...string) (map[string]string, error) {\n\tvmap := make(map[string]string)\n\ts := structs.New(input)\n\ts.TagName = tagName\n\tif len(properties) == 0 {\n\t\tproperties = s.Names()\n\t}\n\n\tfor _, field := range s.Fields() {\n\t\tif !field.IsExported() {\n\t\t\tcontinue\n\t\t}\n\n\t\tif !stringInSlice(field.Name(), properties) {\n\t\t\tcontinue\n\t\t}\n\n\t\tfieldName, opts := parseTag(field.Tag(tagName))\n\t\tif fieldName == \"\" || fieldName == \"-\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tval := field.Value()\n\n\t\tif opts.Has(\"omitempty\") {\n\t\t\tif field.IsZero() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif z, ok := val.(isZeroer); ok && z.IsZero() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif z, ok := val.(isEmptier); ok && z.IsEmpty() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tkind := field.Kind()\n\t\tif kind == reflect.Ptr {\n\t\t\tv := reflect.ValueOf(val)\n\t\t\tif v.IsNil() {\n\t\t\t\tvmap[fieldName] = \"\"\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\telem := v.Elem()\n\t\t\tkind = elem.Kind()\n\t\t\tval = elem.Interface()\n\t\t}\n\n\t\tif opts.Has(\"include\") && kind == reflect.Struct {\n\t\t\tvar newProperties []string\n\t\t\tfor _, prop := range properties {\n\t\t\t\tif strings.HasPrefix(prop, fieldName+\".\") {\n\t\t\t\t\tnewProperties = append(newProperties, strings.TrimPrefix(prop, fieldName+\".\"))\n\t\t\t\t}\n\t\t\t}\n\t\t\tm, err := ToStringStringMap(tagName, val, newProperties...)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tfor k, v := range m {\n\t\t\t\tvmap[fieldName+\".\"+k] = v\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif v, ok := val.(string); ok {\n\t\t\tvmap[fieldName] = v\n\t\t\tcontinue\n\t\t} else if v, ok := val.(*string); ok {\n\t\t\tvmap[fieldName] = *v\n\t\t\tcontinue\n\t\t}\n\n\t\tif !field.IsZero() {\n\t\t\tif m, ok := val.(encoding.TextMarshaler); ok {\n\t\t\t\ttxt, err := m.MarshalText()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tvmap[fieldName] = string(txt)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif m, ok := val.(json.Marshaler); ok {\n\t\t\t\ttxt, err := m.MarshalJSON()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tvmap[fieldName] = string(txt)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tif kind == reflect.String {\n\t\t\tvmap[fieldName] = fmt.Sprint(val)\n\t\t\tcontinue\n\t\t}\n\n\t\tif txt, err := json.Marshal(val); err == nil {\n\t\t\tvmap[fieldName] = string(txt)\n\t\t\tif vmap[fieldName] == `\"\"` || vmap[fieldName] == \"null\" {\n\t\t\t\tvmap[fieldName] = \"\"\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tvmap[fieldName] = fmt.Sprintf(\"%v\", val)\n\t}\n\treturn vmap, nil\n}", "func (sl *Slice) NameToIndexMap() map[string]int {\n\tif len(*sl) == 0 {\n\t\treturn nil\n\t}\n\tnim := make(map[string]int, len(*sl))\n\tfor i, kid := range *sl {\n\t\tnim[kid.Name()] = i\n\t}\n\treturn nim\n}", "func bookInfoToMap(in BookInfo) map[string]string {\n\tret := make(map[string]string)\n\tv := reflect.ValueOf(in)\n\ttyp := v.Type()\n\tfor i := 0; i < v.NumField(); i++ {\n\t\tf := v.Field(i)\n\t\tvar v string\n\t\tswitch f.Type().Kind() {\n\t\tcase reflect.Slice, reflect.Array:\n\t\t\tv = fmt.Sprintf(\"%d\", f.Len())\n\t\tdefault:\n\t\t\tv = fmt.Sprintf(\"%s\", f.String())\n\t\t}\n\t\tret[typ.Field(i).Name] = v\n\t}\n\treturn ret\n}", "func (a *ByAttribute) newMap(data interface{}, reflectItems []*modelsNormalization.ReflectStructItem) (reflect.Value, error) {\n\tif len(reflectItems) == 0 {\n\t\treturn reflect.ValueOf(map[string]interface{}{}), nil\n\t}\n\n\tif mapElemType, equal := modelsNormalization.EqualStructItemType(reflectItems); equal {\n\t\tmapKeyType := reflect.TypeOf(string(\"\"))\n\t\tnewMap := reflect.MakeMap(reflect.MapOf(mapKeyType, mapElemType))\n\t\tfor _, item := range reflectItems {\n\t\t\tnewMap.SetMapIndex(reflect.ValueOf(item.MapKeyName), item.Value)\n\t\t}\n\t\treturn newMap, nil\n\t} else {\n\t\treturn a.newStruct(data, reflectItems)\n\t}\n}", "func mapKeysAndVals() {\r\n\tages := map[string]float64{}\r\n\r\n\tages[\"Alice\"] = 12\r\n\tages[\"Bob\"] = 9\r\n\tfmt.Println(ages[\"Alice\"], ages[\"Bob\"])\r\n}", "func Map(args ...interface{}) dgo.MapType {\n\treturn internal.MapType(args...)\n}", "func MarshallToStringMap(ni *NodeInfo) (data map[string]string) {\n\tm := make(map[string]string)\n\tm[\"ChassisSerial\"] = ni.ChassisSerial\n\tm[\"MachineID\"] = ni.MachineID\n\tm[\"CPUModelName\"] = ni.CPUModelName\n\tm[\"MemTotal\"] = fmt.Sprintf(\"%d\", ni.MemTotal)\n\tm[\"CPUMHz\"] = fmt.Sprintf(\"%f\", ni.CPUMHz)\n\tm[\"NumCPU\"] = fmt.Sprintf(\"%d\", ni.NumCPU)\n\tm[\"NumCore\"] = fmt.Sprintf(\"%d\", ni.NumCore)\n\tm[\"NumPhysicalCPU\"] = fmt.Sprintf(\"%d\", ni.NumPhysicalCPU)\n\tfor index, i := range ni.NetIntfs {\n\t\tvar buffer bytes.Buffer\n\t\tbody, _ := json.Marshal(i)\n\t\tbuffer.Write(body)\n\t\tm[\"NetIfs_\"+fmt.Sprintf(\"%d\", index)] = buffer.String()\n\t}\n\tfor index, d := range ni.Disks {\n\t\tvar buffer bytes.Buffer\n\t\tbody, _ := json.Marshal(d)\n\t\tbuffer.Write(body)\n\t\tm[\"Disks_\"+fmt.Sprintf(\"%d\", index)] = buffer.String()\n\t}\n\tlog.Printf(\"%+v\", m)\n\treturn m\n}", "func compileField(sf reflect.StructField, name string) interface{} {\n\tf := field{sField: sf.Index[0]}\n\n\tf.name = []byte(name)\n\n\tswitch sf.Type.Kind() {\n\tcase reflect.Struct:\n\t\treturn fieldStruct{f.sField, f.name, compileStruct(sf.Type)}\n\tcase reflect.Bool:\n\t\tf.write = encodeBool\n\t\tf.read = decodeBool\n\t\tf.requiredType = 1\n\tcase reflect.Int8:\n\t\tf.write = encodeInt8\n\t\tf.read = decodeInt8\n\t\tf.requiredType = 1\n\tcase reflect.Int16:\n\t\tf.write = encodeInt16\n\t\tf.read = decodeInt16\n\t\tf.requiredType = 2\n\tcase reflect.Int32:\n\t\tf.write = encodeInt32\n\t\tf.read = decodeInt32\n\t\tf.requiredType = 3\n\tcase reflect.Int64:\n\t\tf.write = encodeInt64\n\t\tf.read = decodeInt64\n\t\tf.requiredType = 4\n\tcase reflect.String:\n\t\tf.write = encodeString\n\t\tf.read = decodeString\n\t\tf.requiredType = 8\n\tcase reflect.Map:\n\t\tf.requiredType = 10\n\t\telem := sf.Type.Elem()\n\t\tvar elemField interface{}\n\t\tname := \"map:\" + sf.Name\n\t\tif elem.Kind() != reflect.Interface {\n\t\t\telemField = compileField(reflect.StructField{Type: elem, Index: []int{0}}, name)\n\t\t}\n\t\tf.write = func(w io.Writer, en *msgEncoder, fi reflect.Value) error {\n\t\t\tkeys := fi.MapKeys()\n\t\t\tfor _, key := range keys {\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tv := fi.MapIndex(key)\n\t\t\t\t\twritePrefix(en, w, []byte(key.String()), f.requiredType)\n\t\t\t\t\terr := f.write(w, en, v)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif elemField == nil {\n\t\t\t\t\t\tv := fi.MapIndex(key).Elem()\n\t\t\t\t\t\ttemp := compileField(reflect.StructField{Type: v.Type(), Index: []int{0}}, \"\")\n\t\t\t\t\t\tif f, ok := temp.(field); ok {\n\t\t\t\t\t\t\twritePrefix(en, w, []byte(key.String()), f.requiredType)\n\t\t\t\t\t\t\terr := f.write(w, en, v)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twritePrefix(en, w, []byte(key.String()), 10)\n\t\t\t\t\t\t\tfs := temp.(fieldStruct)\n\t\t\t\t\t\t\terr := write(w, en, fs.m, v)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\twritePrefix(en, w, []byte(key.String()), 10)\n\t\t\t\t\t\tfs := elemField.(fieldStruct)\n\t\t\t\t\t\tv := fi.MapIndex(key)\n\t\t\t\t\t\terr := write(w, en, fs.m, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t\tbs := en.b[:1]\n\t\t\tbs[0] = 0\n\t\t\t_, err := w.Write(bs)\n\t\t\treturn err\n\t\t}\n\t\tf.read = func(r io.Reader, de *msgDecoder, fi reflect.Value) error {\n\n\t\t\tma := reflect.MakeMap(sf.Type)\n\n\t\t\tname, t, err := readPrefix(r, de)\n\t\t\tfor ; t != 0; name, t, err = readPrefix(r, de) {\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tkeyVal := reflect.ValueOf(name)\n\n\t\t\t\tvar val reflect.Value\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tval = reflect.New(elem)\n\t\t\t\t\terr := f.read(r, de, val)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif elemField == nil {\n\t\t\t\t\t\tv, err := fallbackRead(r, de)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t\tval = reflect.ValueOf(v)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tval = reflect.New(elem)\n\t\t\t\t\t\tfs := elemField.(fieldStruct)\n\t\t\t\t\t\terr := read(r, de, fs.m, val)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tma.SetMapIndex(keyVal, val)\n\t\t\t}\n\t\t\tfi.Set(ma)\n\t\t\treturn nil\n\t\t}\n\tcase reflect.Slice:\n\t\tf.requiredType = 9\n\t\telem := sf.Type.Elem()\n\t\tswitch elem.Kind() {\n\t\tcase reflect.Uint8: //Short-cut for byte arrays\n\t\t\tf.requiredType = 7\n\t\t\tf.write = func(w io.Writer, en *msgEncoder, fi reflect.Value) error {\n\t\t\t\tl := fi.Len()\n\t\t\t\tbs := en.b[:4]\n\t\t\t\tbinary.BigEndian.PutUint32(bs, uint32(l))\n\t\t\t\t_, err := w.Write(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\t_, err = w.Write(fi.Bytes())\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tf.read = func(r io.Reader, de *msgDecoder, fi reflect.Value) error {\n\t\t\t\tbs := de.b[:4]\n\t\t\t\t_, err := r.Read(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tl := binary.BigEndian.Uint32(bs)\n\t\t\t\tout := make([]byte, l)\n\t\t\t\t_, err = r.Read(out)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tfi.SetBytes(out)\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase reflect.Int32: //Short-cut for int32 arrays\n\t\t\tf.requiredType = 11\n\t\t\tf.write = func(w io.Writer, en *msgEncoder, fi reflect.Value) error {\n\t\t\t\tl := fi.Len()\n\t\t\t\tbs := en.b[:4]\n\t\t\t\tbinary.BigEndian.PutUint32(bs, uint32(l))\n\t\t\t\t_, err := w.Write(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tdata := fi.Interface().([]int32)\n\t\t\t\tfor i := range data {\n\t\t\t\t\tbinary.BigEndian.PutUint32(bs, uint32(data[i]))\n\t\t\t\t\t_, err := w.Write(bs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tf.read = func(r io.Reader, de *msgDecoder, fi reflect.Value) error {\n\t\t\t\tbs := de.b[:4]\n\t\t\t\t_, err := r.Read(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tl := binary.BigEndian.Uint32(bs)\n\t\t\t\tout := make([]int32, l)\n\t\t\t\tfor i := range out {\n\t\t\t\t\t_, err := r.Read(bs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tout[i] = int32(binary.BigEndian.Uint32(bs))\n\t\t\t\t}\n\t\t\t\tfi.Set(reflect.ValueOf(out))\n\t\t\t\treturn nil\n\t\t\t}\n\t\tdefault:\n\t\t\tname := \"slice:\" + sf.Name\n\t\t\telemField := compileField(reflect.StructField{Type: elem, Index: []int{0}}, name)\n\t\t\tf.write = func(w io.Writer, en *msgEncoder, fi reflect.Value) error {\n\t\t\t\tl := fi.Len()\n\t\t\t\tbs := en.b[:5]\n\t\t\t\tbinary.BigEndian.PutUint32(bs[1:], uint32(l))\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tbs[0] = f.requiredType\n\t\t\t\t} else {\n\t\t\t\t\tbs[0] = 10\n\t\t\t\t}\n\t\t\t\t_, err := w.Write(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\t\t\tv := fi.Index(i)\n\t\t\t\t\t\terr := f.write(w, en, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tf := elemField.(fieldStruct)\n\t\t\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\t\t\tv := fi.Index(i)\n\t\t\t\t\t\terr := write(w, en, f.m, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tf.read = func(r io.Reader, de *msgDecoder, fi reflect.Value) error {\n\t\t\t\tbs := de.b[:5]\n\t\t\t\t_, err := r.Read(bs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tif bs[0] != f.requiredType {\n\t\t\t\t\t\treturn ErrorIncorrectType\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif bs[0] != 10 {\n\t\t\t\t\t\treturn ErrorIncorrectType\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tl := int(binary.BigEndian.Uint32(bs[1:]))\n\t\t\t\tval := reflect.MakeSlice(sf.Type, l, l)\n\t\t\t\tif f, ok := elemField.(field); ok {\n\t\t\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\t\t\tv := val.Index(i)\n\t\t\t\t\t\terr := f.read(r, de, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tf := elemField.(fieldStruct)\n\t\t\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\t\t\tv := val.Index(i)\n\t\t\t\t\t\terr := read(r, de, f.m, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfi.Set(val)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\tcase reflect.Float32:\n\t\tf.requiredType = 5\n\t\tf.write = encodeFloat32\n\t\tf.read = decodeFloat32\n\tcase reflect.Float64:\n\t\tf.requiredType = 6\n\t\tf.write = encodeFloat64\n\t\tf.read = decodeFloat64\n\tdefault:\n\t\tpanic(fmt.Errorf(\"Unhandled type %s for %s\", sf.Type.Kind().String(), sf.Name))\n\t}\n\treturn f\n}", "func (e *Extractor) FieldValueMap() (out map[string]interface{}, err error) {\n\n\tif err := e.isValidStruct(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tout = make(map[string]interface{})\n\ts := reflect.ValueOf(e.StructAddr).Elem()\n\tfields := e.fields(s)\n\n\tfor _, field := range fields {\n\t\tout[field.name] = field.value.Interface()\n\t}\n\n\treturn\n}", "func (i SNSPlatformApplicationAttribute) NameMap() map[string]SNSPlatformApplicationAttribute {\n\treturn _SNSPlatformApplicationAttributeNameToValueMap\n}", "func (p *packet) retrieveMap(value reflect.Value, tags []string) error {\n\tmatchedInstances := reflect.MakeMap(value.Type().Elem())\n\tfor tag, prv := range p.getProviders(tags) {\n\t\tinstance, err := prv.getInstance(p.ctn)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmatchedInstances.SetMapIndex(reflect.ValueOf(tag), instance)\n\t}\n\tvalue.Elem().Set(matchedInstances)\n\treturn nil\n}", "func (c combination) Map() map[string]interface{} {\n\tres := make(map[string]interface{}, len(c))\n\tfor _, p := range c {\n\t\tres[p.Dimension] = p.Value\n\t}\n\treturn res\n}", "func (p *Port) Map(name string) *Port {\n\tport, _ := p.subs[name]\n\treturn port\n}", "func NamesMap() map[string]uint32 {\n\treturn map[string]uint32{\n\t\t\"int\": 0xa8509bda,\n\t\t\"long\": 0x22076cba,\n\t\t\"double\": 0x2210c154,\n\t\t\"string\": 0xb5286e24,\n\t\t\"bytes\": 0xe937bb82,\n\t\t\"boolFalse\": 0xbc799737,\n\t\t\"boolTrue\": 0x997275b5,\n\t\t\"true\": 0x3fedd339,\n\t\t\"decryptedMessage8\": 0x1f814f1f,\n\t\t\"decryptedMessageService8\": 0xaa48327d,\n\t\t\"decryptedMessageMediaEmpty\": 0x89f5c4a,\n\t\t\"decryptedMessageMediaPhoto23\": 0x32798a8c,\n\t\t\"decryptedMessageMediaVideo8\": 0x4cee6ef3,\n\t\t\"decryptedMessageMediaGeoPoint\": 0x35480a59,\n\t\t\"decryptedMessageMediaContact\": 0x588a0a97,\n\t\t\"decryptedMessageActionSetMessageTTL\": 0xa1733aec,\n\t\t\"decryptedMessageMediaDocument23\": 0xb095434b,\n\t\t\"decryptedMessageMediaAudio8\": 0x6080758f,\n\t\t\"decryptedMessageActionReadMessages\": 0xc4f40be,\n\t\t\"decryptedMessageActionDeleteMessages\": 0x65614304,\n\t\t\"decryptedMessageActionScreenshotMessages\": 0x8ac1f475,\n\t\t\"decryptedMessageActionFlushHistory\": 0x6719e45c,\n\t\t\"decryptedMessage23\": 0x204d3878,\n\t\t\"decryptedMessageService\": 0x73164160,\n\t\t\"decryptedMessageMediaVideo23\": 0x524a415d,\n\t\t\"decryptedMessageMediaAudio\": 0x57e0a9cb,\n\t\t\"decryptedMessageLayer\": 0x1be31789,\n\t\t\"sendMessageTypingAction\": 0x16bf744e,\n\t\t\"sendMessageCancelAction\": 0xfd5ec8f5,\n\t\t\"sendMessageRecordVideoAction\": 0xa187d66f,\n\t\t\"sendMessageUploadVideoAction\": 0x92042ff7,\n\t\t\"sendMessageRecordAudioAction\": 0xd52f73f7,\n\t\t\"sendMessageUploadAudioAction\": 0xe6ac8a6f,\n\t\t\"sendMessageUploadPhotoAction\": 0x990a3c1a,\n\t\t\"sendMessageUploadDocumentAction\": 0x8faee98e,\n\t\t\"sendMessageGeoLocationAction\": 0x176f8ba1,\n\t\t\"sendMessageChooseContactAction\": 0x628cbc6f,\n\t\t\"decryptedMessageActionResend\": 0x511110b0,\n\t\t\"decryptedMessageActionNotifyLayer\": 0xf3048883,\n\t\t\"decryptedMessageActionTyping\": 0xccb27641,\n\t\t\"decryptedMessageActionRequestKey\": 0xf3c9611b,\n\t\t\"decryptedMessageActionAcceptKey\": 0x6fe1735b,\n\t\t\"decryptedMessageActionAbortKey\": 0xdd05ec6b,\n\t\t\"decryptedMessageActionCommitKey\": 0xec2e0b9b,\n\t\t\"decryptedMessageActionNoop\": 0xa82fdd63,\n\t\t\"documentAttributeImageSize\": 0x6c37c15c,\n\t\t\"documentAttributeAnimated\": 0x11b58939,\n\t\t\"documentAttributeSticker23\": 0xfb0a5727,\n\t\t\"documentAttributeVideo\": 0x5910cccb,\n\t\t\"documentAttributeAudio23\": 0x51448e5,\n\t\t\"documentAttributeFilename\": 0x15590068,\n\t\t\"photoSizeEmpty\": 0xe17e23c,\n\t\t\"photoSize\": 0x77bfb61b,\n\t\t\"photoCachedSize\": 0xe9a734fa,\n\t\t\"fileLocationUnavailable\": 0x7c596b46,\n\t\t\"fileLocation\": 0x53d69076,\n\t\t\"decryptedMessageMediaExternalDocument\": 0xfa95b0dd,\n\t\t\"documentAttributeAudio45\": 0xded218e0,\n\t\t\"decryptedMessage46\": 0x36b091de,\n\t\t\"decryptedMessageMediaPhoto\": 0xf1fa8d78,\n\t\t\"decryptedMessageMediaVideo\": 0x970c8c0e,\n\t\t\"decryptedMessageMediaDocument\": 0x7afe8ae2,\n\t\t\"documentAttributeSticker\": 0x3a556302,\n\t\t\"documentAttributeAudio\": 0x9852f9c6,\n\t\t\"messageEntityUnknown\": 0xbb92ba95,\n\t\t\"messageEntityMention\": 0xfa04579d,\n\t\t\"messageEntityHashtag\": 0x6f635b0d,\n\t\t\"messageEntityBotCommand\": 0x6cef8ac7,\n\t\t\"messageEntityUrl\": 0x6ed02538,\n\t\t\"messageEntityEmail\": 0x64e475c2,\n\t\t\"messageEntityBold\": 0xbd610bc9,\n\t\t\"messageEntityItalic\": 0x826f8b60,\n\t\t\"messageEntityCode\": 0x28a20571,\n\t\t\"messageEntityPre\": 0x73924be0,\n\t\t\"messageEntityTextUrl\": 0x76a6d327,\n\t\t\"messageEntityMentionName\": 0x352dca58,\n\t\t\"messageEntityPhone\": 0x9b69e34b,\n\t\t\"messageEntityCashtag\": 0x4c4e743f,\n\t\t\"messageEntityBankCard\": 0x761e6af4,\n\t\t\"inputStickerSetShortName\": 0x861cc8a0,\n\t\t\"inputStickerSetEmpty\": 0xffb62b95,\n\t\t\"decryptedMessageMediaVenue\": 0x8a0df56f,\n\t\t\"decryptedMessageMediaWebPage\": 0xe50511d8,\n\t\t\"sendMessageRecordRoundAction\": 0x88f27fbc,\n\t\t\"sendMessageUploadRoundAction\": 0xbb718624,\n\t\t\"documentAttributeVideo66\": 0xef02ce6,\n\t\t\"decryptedMessage\": 0x91cc4674,\n\t\t\"messageEntityUnderline\": 0x9c4e7e8b,\n\t\t\"messageEntityStrike\": 0xbf0693d4,\n\t\t\"messageEntityBlockquote\": 0x20df5d0,\n\t\t\"test.dummyFunction\": 0xc8357709,\n\t}\n}", "func StructToMap(a interface{}) (IObject, error) {\r\n\tb, err := json.Marshal(a)\r\n\tif err != nil {\r\n\t\treturn nil, TypeConvertError{}\r\n\t}\r\n\tvar f interface{}\r\n\terr = json.Unmarshal(b, &f)\r\n\tif res, ok := f.(map[string]interface{}); ok {\r\n\r\n\t\treturn NewObject(res)\r\n\t}\r\n\treturn nil, TypeConvertError{}\r\n}", "func mapfn(kvs ...interface{}) (map[string]interface{}, error) {\n\tif len(kvs)%2 != 0 {\n\t\treturn nil, errors.New(\"map requires even number of arguments.\")\n\t}\n\tm := make(map[string]interface{})\n\tfor i := 0; i < len(kvs); i += 2 {\n\t\ts, ok := kvs[i].(string)\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"even args to map must be strings.\")\n\t\t}\n\t\tm[s] = kvs[i+1]\n\t}\n\treturn m, nil\n}", "func mapCreate(name, rollNo, height, weight, averageMarks, extraCurricularGrade string) map[string]string {\n\tvar mapRet = map[string]string{\n\t\t\"name\": name,\n\t\t\"roll_no\": rollNo,\n\t\t\"weight\": weight,\n\t\t\"height\": height,\n\t\t\"avg_marks\": averageMarks,\n\t\t\"extra_curr_grades\": extraCurricularGrade,\n\t}\n\treturn mapRet\n}", "func Map2Struct(jmap interface{}, s interface{}) error {\n tmpDataJson, err := json.Marshal(jmap)\n if err != nil {\n return err\n }\n err = json.Unmarshal(tmpDataJson, &s)\n if err != nil {\n return err\n }\n return nil\n}", "func BuildTagMapping(structTemplatePointer interface{}, mappedKeyTag string, resultExclusionTag string, inheritKeyFromField bool, convertKeyToLowerCase bool, tags []string) map[string](map[string]string) {\n\treflectStructType := DiscoverTypeByKind(structTemplatePointer, reflect.Struct)\n\tvar result = make(map[string]map[string]string)\n\tvar anonymousMappings = make(map[string]map[string]string)\n\n\tfor i := 0; i < reflectStructType.NumField(); i++ {\n\t\tvar field reflect.StructField\n\t\tfield = reflectStructType.Field(i)\n\t\tkey := getTagValues(field, mappedKeyTag)\n\n\t\tif field.Anonymous && key == \"\" {\n\t\t\tvar anonymousType = DereferenceType(field.Type)\n\t\t\tif anonymousType.Kind() == reflect.Struct {\n\t\t\t\tanonymousMapping := BuildTagMapping(reflect.New(anonymousType).Interface(), mappedKeyTag, resultExclusionTag, inheritKeyFromField, convertKeyToLowerCase, tags)\n\t\t\t\tfor k, v := range anonymousMapping {\n\t\t\t\t\tanonymousMappings[k] = v\n\t\t\t\t\tanonymousMappings[k][anonymousKey] = \"true\"\n\t\t\t\t\tanonymousMappings[k][fieldIndexKey] = AsString(i)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcontinue\n\t\t}\n\n\t\tisTransient := strings.EqualFold(field.Tag.Get(resultExclusionTag), \"true\")\n\t\tif isTransient {\n\t\t\tcontinue\n\t\t}\n\n\t\tif key == \"\" {\n\t\t\tif !inheritKeyFromField {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tkey = field.Name\n\t\t}\n\n\t\tif convertKeyToLowerCase {\n\t\t\tkey = strings.ToLower(key)\n\t\t}\n\n\t\tresult[key] = make(map[string]string)\n\t\tfor _, tag := range tags {\n\t\t\ttagValue := field.Tag.Get(tag)\n\t\t\tif len(tagValue) > 0 {\n\t\t\t\tresult[key][tag] = tagValue\n\t\t\t}\n\t\t}\n\t\tresult[key][fieldNameKey] = field.Name\n\t}\n\n\tfor k, v := range anonymousMappings {\n\t\tif _, has := result[k]; !has {\n\t\t\tresult[k] = v\n\t\t}\n\t}\n\treturn result\n}", "func ToMap(componentName, src, root string) (map[string]interface{}, error) {\n\tobj, err := jsonnetParseFn(\"params.libsonnet\", src)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"parse jsonnet\")\n\t}\n\n\tcomponentObject, err := componentParams(obj, componentName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tm, err := convertObjectToMapFn(componentObject)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif componentName == \"\" {\n\t\treturn m[root].(map[string]interface{}), nil\n\t}\n\n\tparamsMap, ok := m[componentName].(map[string]interface{})\n\tif !ok {\n\t\treturn nil, errors.Errorf(\"component %q params is not an object\", componentName)\n\t}\n\n\treturn paramsMap, nil\n}", "func (c *Config) Map(w io.Writer, is ...interface{}) {\n\tvar iVals []reflect.Value\n\tfor _, i := range is {\n\t\tiVal := reflect.ValueOf(i)\n\t\tif !iVal.CanAddr() {\n\t\t\tif iVal.Kind() != reflect.Ptr && iVal.Kind() != reflect.Interface {\n\t\t\t\tfmt.Fprint(w, \"error: cannot map unaddressable value\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tiVal = iVal.Elem()\n\t\t}\n\t\tiVals = append(iVals, iVal)\n\t}\n\n\tm := &mapper{\n\t\tw,\n\t\tmap[nodeKey]nodeID{nilKey: 0},\n\t\tmap[nodeKey]string{nilKey: \"nil\"},\n\t\t5,\n\t}\n\n\tfmt.Fprintln(w, \"digraph structs {\")\n\tfmt.Fprintln(w, \" node [shape=Mrecord];\")\n\tfor _, iVal := range iVals {\n\t\tm.mapValue(iVal, 0, false)\n\t}\n\tfmt.Fprintln(w, \"}\")\n}", "func (deltaMergeImpl *DeltaMergeImpl) MapOfStringToGameObject(state *map[string]coreminer.GameObject, delta interface{}) map[string]coreminer.GameObject {\n\tdeltaMap := (*deltaMergeImpl).ToDeltaMap(delta)\n\tfor deltaKey, deltaValue := range deltaMap {\n\t\tif (*deltaMergeImpl).IsDeltaRemoved(deltaValue) {\n\t\t\tdelete(*state, deltaKey)\n\t\t} else {\n\t\t\t(*state)[deltaKey] = deltaMergeImpl.GameObject(deltaValue)\n\t\t}\n\t}\n\treturn *state\n}", "func (s StringSlice) Map() map[string]struct{} {\n\tm := map[string]struct{}{}\n\tfor _, w := range s {\n\t\tm[w] = struct{}{}\n\t}\n\treturn m\n}", "func Map(attrs []htmlgo.Attribute, children ...HTML) HTML {\n\treturn &htmlgo.Tree{Tag: \"map\", Attributes: attrs, Children: children}\n}", "func mapCreator2() {\n\n\tvar bootstrap2 = make(map[string]float64)\n\n\tbootstrap2[\"this is fun\"] = 123e9\n\n\tfmt.Println(bootstrap2)\n}", "func (flags VersionFlags) Map() map[string]int {\n\tflagMap := make(map[string]int, len(versionFlagIndices))\n\tflagValue := reflect.ValueOf(flags)\n\tfor flag, index := range versionFlagIndices {\n\t\tvalue := int(flagValue.Field(index).Int())\n\t\tflagMap[flag] = value\n\t}\n\treturn flagMap\n}", "func StructFromMapType() dgo.MapType {\n\tif sfmType == nil {\n\t\tsfmType = Parse(`map[string](dgo|type|{type:dgo|type,required?:bool,...})`).(dgo.MapType)\n\t}\n\treturn sfmType\n}", "func ParseMap(buf []byte) (map[string]interface{}, int, error) {\n\tif buf == nil {\n\t\tpanic(\"cannot parse nil byte array for structs\")\n\t}\n\n\tif len(buf) < 1 {\n\t\treturn nil, 0, errors.New(\"bytes empty, cannot parse struct\")\n\t}\n\n\tif buf[0]>>4 != 0xa && (buf[0] < 0xd8 || buf[0] > 0xda) {\n\t\treturn nil, 0, errors.New(\"expected a map\")\n\t}\n\n\tnumMembers := 0\n\tpos := 1\n\n\tif buf[0]>>4 == 0xa {\n\t\t// Tiny Map\n\t\tnumMembers = int(buf[0] & 0xf)\n\t} else {\n\t\tswitch buf[0] & 0x0f {\n\t\tcase 0x08:\n\t\t\tnumMembers = int(buf[pos])\n\t\t\tpos++\n\t\tcase 0x09:\n\t\t\tnumMembers = int(binary.BigEndian.Uint16(buf[pos : pos+2]))\n\t\t\tpos = pos + 2\n\t\tcase 0x0a:\n\t\t\tnumMembers = int(binary.BigEndian.Uint32(buf[pos : pos+4]))\n\t\t\tpos = pos + 4\n\t\tdefault:\n\t\t\treturn nil, 0, errors.New(\"invalid map prefix\")\n\t\t}\n\t}\n\n\tresult := make(map[string]interface{}, numMembers)\n\n\tfor i := 0; i < numMembers; i++ {\n\t\t// map keys are Strings\n\t\tname, n, err := ParseString(buf[pos:])\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tpos = pos + n\n\n\t\t// now for the value\n\t\tswitch buf[pos] >> 4 {\n\t\tcase 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7: // tiny-int\n\t\t\tval, err := ParseTinyInt(buf[pos])\n\t\t\tif err != nil {\n\t\t\t\treturn result, pos, err\n\t\t\t}\n\t\t\tresult[name] = val\n\t\t\tpos++\n\t\tcase 0x8: // tiny-string\n\t\t\tval, n, err := ParseTinyString(buf[pos:])\n\t\t\tif err != nil {\n\t\t\t\treturn result, pos, err\n\t\t\t}\n\t\t\tresult[name] = val\n\t\t\tpos = pos + n\n\t\tcase 0x9: // tiny-array\n\t\t\tval, n, err := ParseArray(buf[pos:])\n\t\t\tif err != nil {\n\t\t\t\treturn result, pos, err\n\t\t\t}\n\t\t\tresult[name] = val\n\t\t\tpos = pos + n\n\t\tcase 0xa: // tiny-map\n\t\t\tvalue, n, err := ParseMap(buf[pos:])\n\t\t\tif err != nil {\n\t\t\t\treturn result, pos, err\n\t\t\t}\n\t\t\tresult[name] = value\n\t\t\tpos = pos + n\n\t\tcase 0xc: // floats, nil, and bools\n\t\t\tnib := int(buf[pos] & 0xf)\n\t\t\tswitch nib {\n\t\t\tcase 0: // packed nil/null\n\t\t\t\tresult[name] = nil\n\t\t\t\tpos++\n\t\t\tcase 1: // packed float\n\t\t\t\tpanic(\"can't do floats yet\")\n\t\t\tcase 2:\n\t\t\t\tresult[name] = false\n\t\t\t\tpos++\n\t\t\tcase 3:\n\t\t\t\tresult[name] = true\n\t\t\t\tpos++\n\t\t\tcase 0x8, 0x9, 0xa, 0xb:\n\t\t\t\tval, n, err := ParseInt(buf[pos:])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn result, pos, err\n\t\t\t\t}\n\t\t\t\tresult[name] = val\n\t\t\t\tpos = pos + n\n\t\t\t}\n\t\tcase 0xd:\n\t\t\tnib := int(buf[pos] & 0xf)\n\t\t\tswitch nib {\n\t\t\tcase 0x0, 0x1, 0x2: // string\n\t\t\t\tval, n, err := ParseString(buf[pos:])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn result, pos, err\n\t\t\t\t}\n\t\t\t\tresult[name] = val\n\t\t\t\tpos = pos + n\n\t\t\tcase 0x4, 0x5, 0x6: // array\n\t\t\t\tval, n, err := ParseArray(buf[pos:])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn result, pos, err\n\t\t\t\t}\n\t\t\t\tresult[name] = val\n\t\t\t\tpos = pos + n\n\t\t\tcase 0x7:\n\t\t\t\tpanic(\"invalid prefix 0xd7\")\n\t\t\tcase 0x8, 0x9, 0xa:\n\t\t\t\t// err\n\t\t\t\tpanic(\"not ready\")\n\t\t\t}\n\n\t\tdefault:\n\t\t\terrMsg := fmt.Sprintf(\"found unsupported encoding type: %#v\\n\", buf[pos])\n\t\t\treturn result, pos, errors.New(errMsg)\n\t\t}\n\t}\n\treturn result, pos, nil\n}", "func (c Config) toMap() map[string]string {\n\tm := make(map[string]string)\n\tm[chefsolo.NAME] = meta.MC.Name\n\tm[chefsolo.CHEFREPO_GIT] = c.ChefRepoGit\n\tm[chefsolo.CHEFREPO_TARBALL] = c.ChefRepoTarball\n\tm[chefsolo.CHEFREPO_COOKBOOK] = c.Cookbook\n\treturn m\n}", "func LabelsToMap(kvs ...attribute.KeyValue) map[attribute.Key]attribute.Value {\n\tm := map[attribute.Key]attribute.Value{}\n\tfor _, label := range kvs {\n\t\tm[label.Key] = label.Value\n\t}\n\treturn m\n}", "func (h *virtualServiceHandler) Map(obj interface{}) (graph.Identifier, graph.Metadata) {\n\tvs := obj.(*kiali.VirtualService)\n\tm := k8s.NewMetadataFields(&vs.ObjectMeta)\n\treturn graph.Identifier(vs.GetUID()), k8s.NewMetadata(Manager, \"virtualservice\", m, vs, vs.Name)\n}", "func Test_interface001(t *testing.T) {\n\ts1 := make([]int, 10, 20)\n\ttest1(&s1)\n\tfmt.Println(s1)\n\n\tfmt.Println(len(s1))\n\n\ts2 := make(map[string]int)\n\ttest2(s2)\n\tfmt.Println(s2)\n\tfmt.Println(s2[\"aaaaa\"])\n\n\ts3 := make(map[string]sample1)\n\ttest2(s3)\n\tfmt.Println(s3)\n\n\ttype1 := reflect.MapOf(reflect.TypeOf(\"\"), reflect.TypeOf(1))\n\tfmt.Println(type1)\n\tfmt.Println(type1.Elem().Kind())\n\ts4 := reflect.MakeMap(type1)\n\tfmt.Println(s4.Kind())\n\tfmt.Println(s4.Type().Key().Kind())\n\tfmt.Println(s4.Type().Elem().Kind())\n\n\ts4.SetMapIndex(reflect.ValueOf(\"ccccc\"), reflect.ValueOf(3333))\n\n\tfmt.Println(s4)\n\n}", "func generateTomlKeysMap(structPtr reflect.Value, config map[string]interface{}) (map[string]interface{}, error) {\n\tstrct := structPtr.Elem()\n\ttomlMap := map[string]interface{}{}\n\tpType := strct.Type()\n\n\tfor configKey, configValue := range config {\n\t\tfield, found := pType.FieldByName(configKey)\n\n\t\tif !found {\n\t\t\treturn map[string]interface{}{}, fmt.Errorf(\"field %s did not exist on plugin\", configKey)\n\t\t}\n\n\t\ttomlTag := field.Tag.Get(\"toml\")\n\t\tif tomlTag == \"\" {\n\t\t\ttomlTag = configKey\n\t\t}\n\n\t\ttomlMap[tomlTag] = configValue\n\t}\n\n\treturn tomlMap, nil\n\n}", "func Map(m map[string]interface{}, k string, v interface{}) map[string]interface{} {\n\tm[k] = v\n\treturn m\n}", "func (p *Properties) Map() map[string]string {\n\treturn p.m\n}", "func Struct(v interface{}) (values CMap) {\n\tvalues = New()\n\tiVal := reflect.ValueOf(v)\n\tif iVal.Kind() == reflect.Ptr {\n\t\tiVal = iVal.Elem()\n\t}\n\ttyp := iVal.Type()\n\tfor i := 0; i < iVal.NumField(); i++ {\n\t\tfi := typ.Field(i)\n\t\tname := fi.Tag.Get(\"json\")\n\t\tif name == \"\" {\n\t\t\tname = fi.Name\n\t\t}\n\t\t// add support slice\n\t\tif iVal.Field(i).Kind() == reflect.Slice {\n\t\t\tvar buf bytes.Buffer\n\t\t\tbuf.WriteString(\"[\")\n\t\t\tiValArr := iVal.Field(i)\n\t\t\tfor j := 0; j < iValArr.Len(); j++ {\n\t\t\t\tbuf.WriteString(fmt.Sprint(`\"`, iValArr.Index(j), `\",`))\n\t\t\t}\n\t\t\tval := string(buf.Bytes()[:buf.Len()-1])\n\t\t\tval += \"]\"\n\t\t\tvalues.Set(name, val)\n\t\t\tcontinue\n\t\t}\n\t\tvalues.Set(name, fmt.Sprint(iVal.Field(i)))\n\t}\n\treturn\n}", "func (p Payload) Map() map[string]interface{} {\n\toutput := make(map[string]interface{})\n\terr := mapstructure.Decode(p, &output)\n\n\tif err != nil {\n\t\toutput = map[string]interface{}{\n\t\t\t\"error\": \"error in parsing response payload.\",\n\t\t}\n\t}\n\n\treturn output\n}", "func mapFilter(\n\tm map[string]*dynamodb.AttributeValue,\n\tnames ...string,\n) (n map[string]*dynamodb.AttributeValue) {\n\tn = make(map[string]*dynamodb.AttributeValue)\n\tfor _, name := range names {\n\t\tif name == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tif _, ok := m[name]; !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tn[name] = m[name]\n\t}\n\treturn\n}", "func (h *sizeHistogram) toMap() map[string]uint64 {\n\tres := make(map[string]uint64, dataUsageBucketLen)\n\tfor i, count := range h {\n\t\tres[ObjectsHistogramIntervals[i].name] = count\n\t}\n\treturn res\n}", "func (parser *Parser) parseMap(input string, targetType reflect.Type) (interface{}, error) {\n\tmatrix, err := parseHTMLTable(input)\n\tif err != nil {\n\t\treturn nil, toErrorf(\"'%v' is not a valid specification for '%v'\", input, targetType)\n\t}\n\tlength := len(matrix)\n\treturnValue := reflect.MakeMapWithSize(targetType, length)\n\tfor _, row := range matrix {\n\t\tif len(row) != 2 {\n\t\t\treturn nil, toErrorf(\"row '%v' in hash '%v' does not have two cells\", row, targetType)\n\t\t}\n\t\tvar key, value interface{}\n\t\tvar err error\n\t\tif key, err = parser.Parse(row[0], targetType.Key()); err != nil {\n\t\t\treturn nil, toErrorf(\"Could not parse key '%v' in hash '%v'\", row[0], targetType)\n\t\t}\n\t\tif value, err = parser.Parse(row[1], targetType.Elem()); err != nil {\n\t\t\treturn nil, toErrorf(\"Could not parse value '%v' in hash '%v'\", row[1], targetType)\n\t\t}\n\t\treturnValue.SetMapIndex(reflect.ValueOf(key), reflect.ValueOf(value))\n\t}\n\treturn returnValue.Interface(), nil\n}", "func StructToMap(s *structpb.Struct) map[string]interface{} {\n\tif s == nil {\n\t\treturn nil\n\t}\n\tm := map[string]interface{}{}\n\tfor k, v := range s.Fields {\n\t\tm[k] = decodeValue(v)\n\t}\n\treturn m\n}", "func mapFields(fields []string) map[string]uint16 {\n\trv := make(map[string]uint16, len(fields))\n\tfor i, fieldName := range fields {\n\t\trv[fieldName] = uint16(i) + 1\n\t}\n\treturn rv\n}", "func structName(entry *yang.Entry, forList bool) (string, error) {\n\tname, ok := entry.Annotation[\"structname\"]\n\tif !ok {\n\t\treturn \"\", status.Errorf(codes.NotFound, \"structname not found in annotations\")\n\t}\n\tif entry.IsList() && forList {\n\t\tkeys, err := listKeys(entry)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\t// if the entry is a list and we are targeting the container\n\t\t// NOTE we still need to support composite keys\n\t\treturn fmt.Sprintf(\"map[%s]*%s\", keys[0].Gotype, name), nil\n\t}\n\treturn fmt.Sprintf(\"*%s\", name), nil\n}", "func mapEncoder(e *encodeState, v reflect.Value) error {\n\ttype kvPair struct {\n\t\tk1 interface{}\n\t\tv1 interface{}\n\t\tk2 interface{}\n\t\tv2 interface{}\n\t}\n\n\tkeys := v.MapKeys()\n\tkvPairs := make([]kvPair, 0, (len(keys)+1)/2)\n\n\tif len(keys) == 0 {\n\t\treturn nil\n\t}\n\n\tvar (\n\t\tp kvPair\n\t\tisOdd bool\n\t)\n\n\tfor _, k := range keys {\n\t\tval := v.MapIndex(k)\n\t\tif !isOdd {\n\t\t\tp.k1, p.v1 = k.Interface(), val.Interface()\n\t\t} else {\n\t\t\tp.k2, p.v2 = k.Interface(), val.Interface()\n\t\t\tkvPairs = append(kvPairs, p)\n\t\t}\n\n\t\tisOdd = !isOdd\n\t}\n\n\tif !isOdd {\n\t\tkvPairs = append(kvPairs, p)\n\t}\n\n\treturn sliceEncoder(e, reflect.ValueOf(kvPairs))\n\n}", "func (this *DmnList) Map() (DmnMap, error) {\n\n\tdm := make(DmnMap)\n\n\tfor _, di := range *this {\n\n\t\tif dm[di.Key] == nil {\n\t\t\tdm[di.Key] = make(map[int]*DmnInfo)\n\t\t}\n\n\t\tdm[di.Key][di.Version] = di\n\t}\n\n\treturn dm, nil\n}", "func makeNodeMapperByLabel() (protocol.TreeFunc, func() map[int]*Node) {\n\tnodeMap := make(map[int]*Node)\n\n\tmapNode := func(t *protocol.Tree) { nodeMap[t.Node.(*Node).Label] = t.Node.(*Node) }\n\tgetNodeMap := func() map[int]*Node { return nodeMap }\n\n\treturn mapNode, getNodeMap\n}" ]
[ "0.6550753", "0.6488883", "0.63773406", "0.63028806", "0.6241015", "0.6223389", "0.61835444", "0.6182754", "0.6062261", "0.60056233", "0.5981603", "0.595988", "0.5907082", "0.5865792", "0.58084315", "0.5807308", "0.5769133", "0.573662", "0.57096326", "0.5690888", "0.5673567", "0.56454176", "0.5636232", "0.5604629", "0.5582723", "0.55700314", "0.556275", "0.55330545", "0.55089223", "0.5507531", "0.5501836", "0.54941887", "0.54886985", "0.54829454", "0.5480869", "0.5469815", "0.54688555", "0.5461785", "0.54411817", "0.5441106", "0.54364425", "0.5434295", "0.5433389", "0.5433006", "0.5432668", "0.5430304", "0.542877", "0.5405719", "0.5402013", "0.54019594", "0.53878784", "0.5381109", "0.53754807", "0.5375398", "0.5366907", "0.5346095", "0.5341997", "0.5338716", "0.53349465", "0.53329104", "0.53236425", "0.5321484", "0.53202206", "0.5309061", "0.52935547", "0.52919924", "0.5290974", "0.5288093", "0.5278047", "0.5276703", "0.5271783", "0.5259627", "0.5258068", "0.52580297", "0.5253407", "0.52502435", "0.5250119", "0.52460134", "0.5243124", "0.5218592", "0.5216123", "0.5214663", "0.52083784", "0.51805395", "0.5173114", "0.5170362", "0.5161843", "0.51575226", "0.5151872", "0.5144939", "0.51428145", "0.51357335", "0.51320624", "0.5131277", "0.5128481", "0.51134527", "0.5107609", "0.51072586", "0.51024055", "0.5101945" ]
0.6947698
0
Names returns names of struct
func (s *Structx) Names() []string { var result []string fs := s.Fields() for _, v := range fs { result = append(result, v.Name()) } return result }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (e *Extractor) Names() (out []string, err error) {\n\n\tif err := e.isValidStruct(); err != nil {\n\t\treturn nil, err\n\t}\n\n\ts := reflect.ValueOf(e.StructAddr).Elem()\n\tfields := e.fields(s)\n\tfor _, field := range fields {\n\t\tout = append(out, field.name)\n\t}\n\n\treturn\n}", "func Names(v interface{}) []string {\n\treturn New(v).Names()\n}", "func (r *Recorder) names() []string {\n\tvar names []string\n\tfor _, h := range r.snapshot {\n\t\tnames = append(names, h.Name)\n\t}\n\treturn names\n}", "func Names(v interface{}, prev ...string) [][]string {\n\tval := reflect.ValueOf(v)\n\treturn names(val, prev)\n}", "func dataStructFieldNames(dataStruct reflect.Value) []string {\n\tfields := make([]string, dataStruct.NumField())\n\tstructType := dataStruct.Type()\n\tn := 0\n\tfor i := 0; i < len(fields); i++ {\n\t\tsf := structType.Field(i)\n\t\tname := sf.Name\n\t\tif r, _ := utf8.DecodeRuneInString(name); unicode.IsUpper(r) == false {\n\t\t\tcontinue\n\t\t}\n\t\tfields[n] = name\n\t\tn++\n\t}\n\treturn fields[:n]\n}", "func (a Fields) Names() []string {\n\tnames := make([]string, len(a))\n\tfor i, f := range a {\n\t\tnames[i] = f.Name\n\t}\n\treturn names\n}", "func getFieldsNames(v interface{}) []string {\n\tvalue := reflect.Indirect(reflect.ValueOf(v))\n\tvar result []string\n\tfor i := 0; i < value.NumField(); i++ {\n\t\tresult = append(result, value.Type().Field(i).Name)\n\t}\n\treturn result\n}", "func getFieldNames(v interface{}) (fieldNames []string) {\n\te := reflect.ValueOf(v).Elem()\n\teType := e.Type()\n\tfor i := 0; i < e.NumField(); i++ {\n\t\tvarName := eType.Field(i).Name\n\t\tfieldNames = append(fieldNames, varName)\n\t}\n\treturn\n}", "func objToNames(obj interface{}, names []string, tag string) []string {\n\tvar typ reflect.Type\n\n\tif sf, ok := obj.(reflect.StructField); ok {\n\t\ttyp = sf.Type\n\t} else {\n\t\ttyp = reflect.TypeOf(obj)\n\t\tif typ.Kind() == reflect.Ptr {\n\t\t\ttyp = typ.Elem()\n\t\t}\n\t}\n\n\tfor i := 0; i < typ.NumField(); i++ {\n\t\tfield := typ.Field(i)\n\n\t\tif field.Type.Kind() == reflect.Struct {\n\t\t\tnames = objToNames(field, names, tag)\n\t\t\tcontinue\n\t\t}\n\n\t\t// If tag is passed to the function, we only append if the field is tagged and that it matches tag.\n\t\tif tag == \"\" || field.Tag.Get(tag) != \"\" {\n\t\t\tnames = append(names, field.Name)\n\t\t}\n\t}\n\n\treturn names\n}", "func (mb *MutableBag) Names() []string {\n\ti := 0\n\tkeys := make([]string, len(mb.values))\n\tfor k := range mb.values {\n\t\tkeys[i] = k\n\t\ti++\n\t}\n\treturn append(keys, mb.parent.Names()...)\n}", "func (def *Definition) Fieldnames() []string {\n\ttypeList := make([]string, 0)\n\tt := TraverserMethods{EnterFunction: func(adaType IAdaType, parentType IAdaType, level int, x interface{}) error {\n\t\ttypeList = append(typeList, adaType.Name())\n\t\treturn nil\n\t}}\n\n\t_ = def.TraverseTypes(t, true, typeList)\n\treturn typeList\n}", "func (t *Struct) String() string { return t.Name }", "func GetNames(result []interface{})[]string{\n\tvar names []string\n\tfor _, poi := range result {\n\t\t//fmt.Println(poi.(map[string]interface{})[\"name\"])\n\t\tnames = append(names, poi.(map[string]interface{})[\"name\"].(string))\n\t}\n\treturn names\n}", "func (d data) GetNames(name string) []string {\n\tv := reflect.ValueOf(d.src).Elem().FieldByName(name)\n\tif v.Kind() != reflect.Slice {\n\t\treturn nil\n\t}\n\tnames := make([]string, v.Len())\n\tfor i := range names {\n\t\tsv := v.Index(i)\n\t\tvname := sv.FieldByName(\"Name\")\n\t\tif vname == (reflect.Value{}) {\n\t\t\tnames[i] = \"?\"\n\t\t} else {\n\t\t\tnames[i] = vname.String()\n\t\t}\n\t}\n\treturn names\n}", "func fields(spec *ast.TypeSpec) []*ast.Field {\n\ts := make([]*ast.Field, 0)\n\tif structType, ok := spec.Type.(*ast.StructType); ok {\n\t\tfor _, field := range structType.Fields.List {\n\t\t\tif keyname(field) != \"\" {\n\t\t\t\ts = append(s, field)\n\t\t\t}\n\t\t}\n\t}\n\treturn s\n}", "func StructFields(t reflect.Type) string {\n\tfields := make([]string, 0)\n\tif t.Kind() == reflect.Struct {\n\t\tfor i := 0; i < t.NumField(); i ++ {\n\t\t\tname := t.Field(i).Name\n\t\t\tif t.Field(i).Type.Kind() == reflect.Struct {\n\t\t\t\ts := StructFields(t.Field(i).Type)\n\t\t\t\tf := strings.Split(s, \", \")\n\t\t\t\tleft := FirstLower(name)\n\t\t\t\tfor _, v := range f {\n\t\t\t\t\tfields = append(fields, fmt.Sprintf(\"%s.%s\", left, FirstLower(v)))\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfields = append(fields, FirstLower(name))\n\t\t}\n\t}\n\n\treturn strings.Join(fields, \", \")\n}", "func (d *TagAny) NameS() []string {\n\treturn nvp.NameS(d)\n}", "func UConverterGetAvailableNames() (_swig_ret []string)", "func enumStructFields(t reflect.Type) []reflect.StructField {\n\t// We use this queue to visit every field in the struct (both immediate\n\t// ones and those in embedded structs), breadth-first.\n\tqueue := make([][]int, t.NumField())\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tqueue[i] = []int{i}\n\t}\n\n\tvar names = make(map[string]bool)\n\tvar fields []reflect.StructField\n\n\t// Work through the queue.\n\tfor ; len(queue) > 0; queue = queue[1:] {\n\t\tindex := queue[0]\n\t\tfield := t.FieldByIndex(index)\n\n\t\t// todo: Distinguish between empty struct tags and ones that are\n\t\t// simply missing.\n\t\tname := field.Tag.Get(\"binn\")\n\n\t\t// Visit the fields any embedded structs.\n\t\tif field.Anonymous && field.Type.Kind() == reflect.Struct && name == \"\" {\n\t\t\tindex = index[:len(index):len(index)]\n\t\t\tfor j := 0; j < field.Type.NumField(); j++ {\n\t\t\t\tqueue = append(queue, append(index, field.Type.Field(j).Index...))\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\t// Ignore unexported fields and fields without a \"binn\" tag.\n\t\tif field.PkgPath != \"\" && name == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tfield.Name = name\n\t\tfield.Index = index\n\t\tfields = append(fields, field)\n\n\t\tnames[name] = true\n\t}\n\n\t// Order the fields by their position in the root struct.\n\tsort.Sort(fieldsByIndex(fields))\n\n\treturn fields\n}", "func (o GetNodeTypesResultOutput) Names() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v GetNodeTypesResult) []string { return v.Names }).(pulumi.StringArrayOutput)\n}", "func getNames(elements []element) string {\n\tvar names string\n\tfor i, el := range elements {\n\t\tif i != 0 {\n\t\t\tnames += \" \"\n\t\t}\n\t\tnames += el.name\n\t}\n\treturn names\n}", "func (o GetFlowlogsResultOutput) Names() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v GetFlowlogsResult) []string { return v.Names }).(pulumi.StringArrayOutput)\n}", "func (n *dnode) Names() []string {\n\tn.mutex.RLock()\n\tdefer n.mutex.RUnlock()\n\n\ttmp := make([]string, 0, len(n.children))\n\tfor k := range n.children {\n\t\ttmp = append(tmp, k)\n\t}\n\tsort.Strings(tmp)\n\treturn tmp\n}", "func fieldNames(value interface{}) []ProcessClass {\n\tcountType := reflect.TypeOf(value)\n\tnames := make([]ProcessClass, 0, countType.NumField())\n\tfor index := 0; index < countType.NumField(); index++ {\n\t\ttag := strings.Split(countType.Field(index).Tag.Get(\"json\"), \",\")\n\t\tnames = append(names, ProcessClass(tag[0]))\n\t}\n\treturn names\n}", "func (m *ShowMeasurementsMapper) Fields() []string { return []string{\"name\"} }", "func (e *Extractor) NamesFromTag(tag string) (out []string, err error) {\n\n\tif err := e.isValidStruct(); err != nil {\n\t\treturn nil, err\n\t}\n\n\ts := reflect.ValueOf(e.StructAddr).Elem()\n\tfields := e.fields(s)\n\n\tfor _, field := range fields {\n\t\tif val, ok := field.tags.Lookup(tag); ok {\n\t\t\tkey, omit := e.parseOmitempty(val, field.value)\n\t\t\tif omit {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tout = append(out, key)\n\t\t}\n\t}\n\n\treturn\n}", "func (mb *MutableBag) Names() []string {\n\tif mb == nil {\n\t\treturn []string{}\n\t}\n\n\tif mb.parent == nil {\n\t\tpanic(fmt.Errorf(\"attempt to use a bag after its Done method has been called\"))\n\t}\n\n\tparentNames := mb.parent.Names()\n\n\tm := make(map[string]bool, len(parentNames)+len(mb.values))\n\tfor _, name := range parentNames {\n\t\tm[name] = true\n\t}\n\n\tfor name := range mb.values {\n\t\tm[name] = true\n\t}\n\n\ti := 0\n\tnames := make([]string, len(m))\n\tfor name := range m {\n\t\tnames[i] = name\n\t\ti++\n\t}\n\n\treturn names\n}", "func (g *Generator) fieldNames(n int) []string {\n\tif n > len(g.fieldStack) {\n\t\tn = len(g.fieldStack)\n\t}\n\tresult := make([]string, n)\n\tloopDepth := 0\n\tfor i := 0; i < n; i++ {\n\t\tf := g.fieldStack[i]\n\t\tif f.IsRepeated() {\n\t\t\tresult[i] = fmt.Sprintf(\"%s[%s]\", g.cName(f), loopVars[loopDepth])\n\t\t\tloopDepth++\n\t\t} else {\n\t\t\tresult[i] = g.cName(f)\n\t\t}\n\t}\n\treturn result\n}", "func GetNameFromStruct(u interface{}) string {\n\tvar result = ReturnValue{CustomStruct: u}\n\n\t//fmt.Println(result)\n\n\tmsg, ok := result.CustomStruct.(NameOnly)\n\tif ok {\n\t\t//fmt.Printf(\"Message1 is %s\\n\", msg.Name)\n\t\treturn msg.Name\n\t} else {\n\t\treturn \"\"\n\t}\n}", "func printNames(names []pkix.AttributeTypeAndValue, buf *bytes.Buffer) []string {\n values := []string{} \n for _, name := range names {\n oid := name.Type\n if len(oid) == 4 && oid[0] == 2 && oid[1] == 5 && oid[2] == 4 {\n switch oid[3] {\n case 3:\n values = append(values, fmt.Sprintf(\"CN=%s\", name.Value))\n case 6:\n values = append(values, fmt.Sprintf(\"C=%s\", name.Value))\n case 8:\n values = append(values, fmt.Sprintf(\"ST=%s\", name.Value))\n case 10:\n values = append(values, fmt.Sprintf(\"O=%s\", name.Value))\n case 11:\n values = append(values, fmt.Sprintf(\"OU=%s\", name.Value))\n default: \n values = append(values, fmt.Sprintf(\"UnknownOID=%s\", name.Type.String()))\n }\n } else if oid.Equal(oidEmailAddress) {\n values = append(values, fmt.Sprintf(\"emailAddress=%s\", name.Value))\n } else {\n values = append(values, fmt.Sprintf(\"UnknownOID=%s\", name.Type.String()))\n }\n }\n\nif len(values) > 0 {\n buf.WriteString(values[0])\n for i := 1; i < len(values); i++ {\n buf.WriteString(\",\" + values[i])\n }\n buf.WriteString(\"\\n\")\n }\n return values\n}", "func structName(entry *yang.Entry, forList bool) (string, error) {\n\tname, ok := entry.Annotation[\"structname\"]\n\tif !ok {\n\t\treturn \"\", status.Errorf(codes.NotFound, \"structname not found in annotations\")\n\t}\n\tif entry.IsList() && forList {\n\t\tkeys, err := listKeys(entry)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\t// if the entry is a list and we are targeting the container\n\t\t// NOTE we still need to support composite keys\n\t\treturn fmt.Sprintf(\"map[%s]*%s\", keys[0].Gotype, name), nil\n\t}\n\treturn fmt.Sprintf(\"*%s\", name), nil\n}", "func (pl List) names() []string {\n\tret := make([]string, len(pl))\n\tfor i, p := range pl {\n\t\tret[i] = p.String()\n\t}\n\treturn ret\n}", "func (o GetOpenApiPricingModulesResultOutput) Names() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v GetOpenApiPricingModulesResult) []string { return v.Names }).(pulumi.StringArrayOutput)\n}", "func (n Notes) Names() []string {\n\tnames := make([]string, 0)\n\tfor _, v := range n {\n\t\tnames = append(names, v.Name())\n\t}\n\treturn names\n}", "func (p *BaseProvider) Names() []string {\n\tnames := make([]string, 0, len(p.defs))\n\n\tfor name := range p.defs {\n\t\tnames = append(names, name)\n\t}\n\n\tsort.Strings(names)\n\n\treturn names\n}", "func (t *typeStruct) Name() string {\n\treturn t.name\n}", "func (t *SentryTaggedStruct) GetName() string {\n\treturn \"\"\n}", "func NameAnonStructs() {\n\tanonNamer := func(t reflect.StructField) string {\n\t\treturn fmt.Sprintf(\"WasAnon%s\", t.Name)\n\t}\n\tts, err := bel.Extract(NestedStuff{}, bel.NameAnonStructs(anonNamer))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\terr = bel.Render(ts)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}", "func (_DelegateProfile *DelegateProfileSession) FieldNames(arg0 *big.Int) (string, error) {\n\treturn _DelegateProfile.Contract.FieldNames(&_DelegateProfile.CallOpts, arg0)\n}", "func FieldArgNames(obj any, allArgs map[string]reflect.Value) {\n\tfieldArgNamesStruct(obj, \"\", false, allArgs)\n}", "func (rs Repos) Names() []string {\n\tnames := make([]string, len(rs))\n\tfor i := range rs {\n\t\tnames[i] = rs[i].Name\n\t}\n\treturn names\n}", "func (obj *ExitStatus) Names() []string {\n\treturn []string{\n\t\t\"OK\",\n\t\t\"ERROR\",\n\t}\n}", "func GetFields(m interface{}) (ns []string) {\n\ttyp := GetType(m)\n\t// Only structs are supported so return an empty result if the passed object\n\t// isn't a struct\n\tif typ.Kind() != reflect.Struct {\n\t\tfmt.Printf(\"%v type can't have attributes inspected\\n\", typ.Kind())\n\t\treturn\n\t}\n\t// loop through the struct's fields\n\tfor i := 0; i < typ.NumField(); i++ {\n\t\tf := typ.Field(i)\n\t\tif f.Anonymous {\n\t\t\tfkind := f.Type.Kind()\n\t\t\tif fkind == reflect.Struct || fkind == reflect.Ptr {\n\t\t\t\tfns := GetFields(reflect.New(f.Type).Interface())\n\t\t\t\tfor _, fn := range fns {\n\t\t\t\t\tif String(fn).IsInArray(ns) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tns = append(ns, fn)\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif String(f.Name).IsInArray(ns) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tns = append(ns, f.Name)\n\t\t}\n\t}\n\treturn ns\n}", "func (*unifinames) Name() string { return \"unifi-names\" }", "func (o GetSecretsResultOutput) Names() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v GetSecretsResult) []string { return v.Names }).(pulumi.StringArrayOutput)\n}", "func (_DelegateProfile *DelegateProfileCallerSession) FieldNames(arg0 *big.Int) (string, error) {\n\treturn _DelegateProfile.Contract.FieldNames(&_DelegateProfile.CallOpts, arg0)\n}", "func (s *Structx) Name() string {\n\treturn s.value.Type().Name()\n}", "func (e *Encoder) getColNames(v interface{}) []string {\n\ttyp := reflect.TypeOf(v)\n\tval := reflect.ValueOf(v)\n\tvar cols []string\n\tfor i := 0; i < typ.NumField(); i++ {\n\t\t// skip unexported\n\t\ttF := typ.Field(i)\n\t\tif len(tF.PkgPath) > 0 {\n\t\t\tcontinue\n\t\t}\n\t\tname := e.getFieldName(tF)\n\t\tif name == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tvF := val.Field(i)\n\t\tswitch vF.Kind() {\n\t\tcase reflect.Struct:\n\t\t\ttmp := e.getColNames(vF.Interface())\n\t\t\tcols = append(cols, tmp...)\n\t\t\tcontinue\n\t\tdefault:\n\t\t\tok := supportedBaseKind(vF)\n\t\t\tif !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tcols = append(cols, name)\n\t}\n\treturn cols\n}", "func (b bindingContainer) InterfaceNames() (keys []string) {\n\t//TODO: use Interfaces() here.\n\tkeys = make([]string, len(b))\n\ti := 0\n\tfor k, _ := range b {\n\t\tkeys[i] = k\n\t\ti++\n\t}\n\treturn\n}", "func (t Tags) Names() []string {\n\tset := map[string]string{}\n\tfor _, s := range t {\n\t\tset[s.Name] = \"\"\n\t}\n\n\tres := make([]string, 0, len(set))\n\n\tfor k := range set {\n\t\tres = append(res, k)\n\t}\n\n\tsort.Strings(res)\n\n\treturn res\n}", "func (p *Params) Names() []string {\n\treturn p.names\n}", "func (mfbp ProviderList) Names() []string {\n\tkeys := []string{}\n\tfor k := range mfbp {\n\t\tkeys = append(keys, k)\n\t}\n\n\tsort.Strings(keys)\n\n\treturn keys\n}", "func (g *generator) structFields(t reflect.Type) []field {\n\tvar fields []field\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tf := t.Field(i)\n\t\tif g.ignoreField(t, f) {\n\t\t\tcontinue\n\t\t}\n\t\tname, _ := parseTag(g.fieldTagKey, f.Tag)\n\t\tif name == \"\" {\n\t\t\tname = f.Name\n\t\t}\n\t\tfields = append(fields, field{\n\t\t\tName: name,\n\t\t\tType: f.Type,\n\t\t\tZero: zeroValue(f.Type),\n\t\t})\n\t}\n\treturn fields\n}", "func (m *Measurement) FieldNames() (a []string) {\n\tm.mu.RLock()\n\tdefer m.mu.RUnlock()\n\n\tfor n, _ := range m.fieldNames {\n\t\ta = append(a, n)\n\t}\n\treturn\n}", "func getNames(sub pkix.Name) []Name {\n\t// anonymous func for finding the max of a list of integer\n\tmax := func(v1 int, vn ...int) (max int) {\n\t\tmax = v1\n\t\tfor i := 0; i < len(vn); i++ {\n\t\t\tif vn[i] > max {\n\t\t\t\tmax = vn[i]\n\t\t\t}\n\t\t}\n\t\treturn max\n\t}\n\n\tnc := len(sub.Country)\n\tnorg := len(sub.Organization)\n\tnou := len(sub.OrganizationalUnit)\n\tnl := len(sub.Locality)\n\tnp := len(sub.Province)\n\n\tn := max(nc, norg, nou, nl, np)\n\n\tnames := make([]Name, n)\n\tfor i := range names {\n\t\tif i < nc {\n\t\t\tnames[i].C = sub.Country[i]\n\t\t}\n\t\tif i < norg {\n\t\t\tnames[i].O = sub.Organization[i]\n\t\t}\n\t\tif i < nou {\n\t\t\tnames[i].OU = sub.OrganizationalUnit[i]\n\t\t}\n\t\tif i < nl {\n\t\t\tnames[i].L = sub.Locality[i]\n\t\t}\n\t\tif i < np {\n\t\t\tnames[i].ST = sub.Province[i]\n\t\t}\n\t}\n\treturn names\n}", "func (s *FabricInterfaceSet) Names() []string {\n\tif s == nil {\n\t\treturn []string{}\n\t}\n\treturn s.byName.keys()\n}", "func (s *MyTestStruct) Name() string {\n\treturn s.field_Name\n}", "func (p Packet) ValueNames() []string {\n\tr := make([]string, len(p.DataTypes))\n\tfor i := range p.DataTypes {\n\t\tname := p.Name()\n\t\tvar valueName string\n\t\tswitch {\n\t\tcase p.Plugin == \"df\" && i == 0:\n\t\t\tvalueName = \"\"\n\t\tcase p.Plugin == \"memory\" && i == 0:\n\t\t\tvalueName = \"\"\n\t\tcase p.Plugin == \"interface\" && i == 0:\n\t\t\tvalueName = \"tx\"\n\t\tcase p.Plugin == \"interface\" && i == 1:\n\t\t\tvalueName = \"rx\"\n\t\tcase p.Plugin == \"load\" && i == 0:\n\t\t\tvalueName = \"1\"\n\t\tcase p.Plugin == \"load\" && i == 1:\n\t\t\tvalueName = \"5\"\n\t\tcase p.Plugin == \"load\" && i == 2:\n\t\t\tvalueName = \"15\"\n\t\tdefault:\n\t\t\tvalueName = strconv.FormatInt(int64(i), 10)\n\t\t}\n\t\tif valueName == \"\" {\n\t\t\tr[i] = name\n\t\t} else {\n\t\t\tr[i] = fmt.Sprintf(\"%s_%s\", name, valueName)\n\t\t}\n\t}\n\treturn r\n}", "func name(v reflect.StructField) string {\n\tif name, ok := v.Tag.Lookup(\"name\"); ok {\n\t\treturn name\n\t}\n\treturn v.Name\n}", "func (_DelegateProfile *DelegateProfileCaller) FieldNames(opts *bind.CallOpts, arg0 *big.Int) (string, error) {\n\tvar (\n\t\tret0 = new(string)\n\t)\n\tout := ret0\n\terr := _DelegateProfile.contract.Call(opts, out, \"fieldNames\", arg0)\n\treturn *ret0, err\n}", "func Names() []string {\n\t// TODO eliminate duplicates\n\tvar names []string\n\tfor _, f := range factories {\n\t\tnames = append(names, f.Names()...)\n\t}\n\treturn names\n}", "func (n *NameProvider) GetJSONNames(subject interface{}) []string {\n\tn.lock.Lock()\n\tdefer n.lock.Unlock()\n\ttpe := reflect.Indirect(reflect.ValueOf(subject)).Type()\n\tnames, ok := n.index[tpe]\n\tif !ok {\n\t\tnames = n.makeNameIndex(tpe)\n\t}\n\n\tres := make([]string, 0, len(names.jsonNames))\n\tfor k := range names.jsonNames {\n\t\tres = append(res, k)\n\t}\n\treturn res\n}", "func Names(tmpl Template) (names []string) {\n\ttS := tmpl.Templates()\n\tsort.Slice(tS, func(i, j int) bool { return (tS[i].Name() < tS[j].Name()) })\n\tfor i := range tS {\n\t\tnames = append(names, tS[i].Name())\n\t}\n\treturn\n}", "func (da *DataFrame) Names() []string {\n\treturn da.names\n}", "func (c Completer) Names() []string {\n\tnames := make([]string, 0, c.scope.Size())\n\tc.scope.Range(func(k string, v values.Value) {\n\t\tnames = append(names, k)\n\t})\n\tsort.Strings(names)\n\treturn names\n}", "func (n *Declarator) ParameterNames() []int { return n.DirectDeclarator.parameterNames() }", "func (s *Struct) structFields() []reflect.StructField {\n\tt := s.value.Type()\n\n\tvar f []reflect.StructField\n\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfield := t.Field(i)\n\t\t// we can't access the value of unexported fields\n\t\tif field.PkgPath != \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\t// don't check if it's omitted\n\t\tif tag := field.Tag.Get(s.TagName); tag == \"-\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tf = append(f, field)\n\t}\n\n\treturn f\n}", "func (d *DynamoDB) GetAllNames(table string) ([]string, error) {\n\titems, err := d.Scan(table)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar names []string\n\tfor _, item := range items {\n\t\tnames = append(names, *item[\"name\"].S)\n\t}\n\n\treturn names, nil\n}", "func mustGetNames(objects []runtime.Object) []string {\n\tvar names []string\n\tfor _, obj := range objects {\n\t\tmetaAccessor, err := meta.Accessor(obj)\n\t\tif err != nil {\n\t\t\tframework.Failf(\"error getting accessor for %T: %v\", obj, err)\n\t\t}\n\t\tname := metaAccessor.GetName()\n\t\tnames = append(names, name)\n\t}\n\tsort.Strings(names)\n\treturn names\n}", "func AllNames() []string {\n\tret := make([]string, 0, len(unitByName))\n\tfor n := range unitByName {\n\t\tif n == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tret = append(ret, n)\n\t}\n\tsort.Strings(ret)\n\treturn ret\n}", "func (t *Type) GetName() string { return t.Name }", "func (col Columns) Names() []string {\n\tnames := make([]string, col.Len())\n\tfor i, mn := range col.MultiNames() {\n\t\tname := strings.Join(mn, values.GetMultiColNameSeparator())\n\t\tnames[i] = name\n\t}\n\treturn names\n}", "func (sl *Slice) TypeAndNames() kit.TypeAndNameList {\n\tif len(*sl) == 0 {\n\t\treturn nil\n\t}\n\ttn := make(kit.TypeAndNameList, len(*sl))\n\tfor _, kid := range *sl {\n\t\ttn.Add(kid.Type(), kid.Name())\n\t}\n\treturn tn\n}", "func (c *Command) Names() []string {\n\tnames := strings.Split(c.Name, \",\")\n\tfor i, name := range names {\n\t\tnames[i] = strings.TrimSpace(name)\n\t}\n\treturn names\n}", "func (this *SIPMessage) GetHeaderNames() *list.List {\n\treturn this.headers\n\t// ListIterator li = this.headers.listIterator();\n\t// LinkedList retval = new LinkedList();\n\t// while (li.hasNext()) {\n\t// SIPHeader sipHeader = (SIPHeader) li.next();\n\t// String name = sipHeader.GetName();\n\t// retval.add(name);\n\t// }\n\t// return retval.listIterator();\n}", "func (e *Encoder) GetColNames(v interface{}) ([]string, error) {\n\tif reflect.TypeOf(v).Kind() != reflect.Struct {\n\t\treturn nil, StructRequiredError{reflect.TypeOf(v).Kind()}\n\t}\n\t// the returned bool is ignored because it's only used for recursive calls.\n\tnames := e.getColNames(v)\n\t// keep a copy\n\te.colNames = make([]string, len(names))\n\t_ = copy(e.colNames, names)\n\treturn names, nil\n}", "func (m *Workbook) GetNames()([]WorkbookNamedItemable) {\n return m.names\n}", "func typeNames(vars []*types.Var) string {\n\tif len(vars) == 0 {\n\t\treturn \"\"\n\t}\n\tvar buf strings.Builder\n\tfor i, v := range vars {\n\t\tif i != 0 {\n\t\t\tbuf.WriteString(\", \")\n\t\t}\n\t\tbuf.WriteString(nameOf(v.Type()))\n\t}\n\treturn buf.String()\n}", "func StructFields(t reflect.Type) interface{} {\n\treturn structInfoForType(t).fields\n}", "func (u *Union) Name() string { return u.TypeName }", "func (a *Aliens) Names() []string {\n\tnames := make([]string, len(*a))\n\tfor i, alien := range *a {\n\t\tnames[i] = alien.Name\n\t}\n\treturn names\n}", "func (c *ContainerContext) Names() string {\n\tnames := formatter.StripNamePrefix(c.c.Names)\n\tif c.trunc {\n\t\tfor _, name := range names {\n\t\t\tif len(strings.Split(name, \"/\")) == 1 {\n\t\t\t\tnames = []string{name}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\treturn strings.Join(names, \",\")\n}", "func (e *Enforcer) GetAllNamedObjects(ptype string) []string {\n\treturn e.model.GetValuesForFieldInPolicy(\"p\", ptype, 1)\n}", "func printStructField(t *reflect.Type) {\n fieldNum := (*t).NumField()\n for i := 0; i < fieldNum; i++ {\n fmt.Printf(\"conf's field: %s\\n\", (*t).Field(i).Name)\n }\n fmt.Println(\"\")\n}", "func Keys(i interface{}) (keys []string, ok bool) {\n\tkeys = make([]string, 0)\n\tv, k := preprocess(i)\n\tswitch k {\n\tcase reflect.Map:\n\t\tk := v.MapKeys()\n\t\tfor i := range k {\n\t\t\ts, ok := k[i].Interface().(string)\n\t\t\tif !ok {\n\t\t\t\treturn nil, false\n\t\t\t}\n\t\t\tkeys = append(keys, s)\n\t\t}\n\t\treturn keys, true\n\tcase reflect.Struct:\n\t\tt := v.Type()\n\t\tfor i := 0; i < v.NumField(); i++ {\n\t\t\tt2 := t.Field(i)\n\t\t\tfname := t2.Tag.Get(\"duck\")\n\t\t\tif fname != \"-\" {\n\t\t\t\tif fname == \"\" {\n\t\t\t\t\tfname = t2.Name\n\t\t\t\t}\n\t\t\t\tkeys = append(keys, fname)\n\t\t\t}\n\t\t}\n\t\treturn keys, true\n\t}\n\treturn nil, false\n}", "func (o GetInstanceAttachmentsResultOutput) Names() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v GetInstanceAttachmentsResult) []string { return v.Names }).(pulumi.StringArrayOutput)\n}", "func (p PropertyList) GetNames() []string {\n\tkeys := []string{}\n\tfor _, k := range p {\n\t\tkeys = append(keys, k.Name)\n\t}\n\n\t// Without this, the ordering is (intentionally) pseudorandom and inconsistent.\n\tsort.Strings(keys)\n\treturn keys\n}", "func (checker *CheckerType) VarNames() (obtained, expected string) {\n return \"obtained\", \"expected\"\n}", "func (flag *SliceFlag[T]) Names() []string {\n\treturn append([]string{flag.Name}, flag.Aliases...)\n}", "func (r *Registry) Names() []string {\n\tkeys := []string{}\n\tfor key := range r.registrants {\n\t\tkeys = append(keys, key)\n\t}\n\tsort.Strings(keys)\n\treturn keys\n}", "func (m *WorkbookWorksheet) GetNames()([]WorkbookNamedItemable) {\n return m.names\n}", "func (s *Struct) Fields() map[string]string {\n\tff := map[string]string{}\n\n\tfor _, f := range s.RawFields() {\n\t\tff[f.Field.Name] = f.Typ.String()\n\t}\n\n\treturn ff\n}", "func (obj *object) getStructName(line string) {\n\t/*nested := false\n\tif !strings.Contains(line, \"type \") {\n\t\tnested = true\n\t}*/\n\n\tline = strings.TrimSpace(line)\n\tline = strings.TrimPrefix(strings.TrimSuffix(line, \"{\"), \"type\")\n\tline = strings.TrimSpace(line)\n\tobj.Name = strings.TrimSpace(strings.TrimSuffix(line, \"struct\"))\n\tif strings.Contains(obj.Name, \"[]\") {\n\t\tobj.Name = strings.TrimSpace(strings.TrimSuffix(obj.Name, \"[]\"))\n\t}\n\tobj.Tp = obj.Name\n\tobj.JsonKey = obj.Name\n\t/*if nested {\n\t\tobj.CommonFileds = append(obj.CommonFileds, &field{JsonKey: obj.Name, Tp: obj.Name})\n\t}*/\n}", "func walkNames(exp Expr) []string {\n\tswitch expr := exp.(type) {\n\tcase *VarRef:\n\t\treturn []string{expr.Val}\n\tcase *Call:\n\t\tif len(expr.Args) == 0 {\n\t\t\treturn nil\n\t\t}\n\t\tlit, ok := expr.Args[0].(*VarRef)\n\t\tif !ok {\n\t\t\treturn nil\n\t\t}\n\n\t\treturn []string{lit.Val}\n\tcase *UnaryExpr:\n\t\treturn walkNames(expr.Expr)\n\tcase *BinaryExpr:\n\t\tvar ret []string\n\t\tret = append(ret, walkNames(expr.LHS)...)\n\t\tret = append(ret, walkNames(expr.RHS)...)\n\t\treturn ret\n\tcase *Case:\n\t\tvar ret []string\n\t\tfor _, cond := range expr.WhenThens {\n\t\t\tret = append(ret, walkNames(cond.When)...)\n\t\t\tret = append(ret, walkNames(cond.Then)...)\n\t\t}\n\t\tif expr.Else != nil {\n\t\t\tret = append(ret, walkNames(expr.Else)...)\n\t\t}\n\t\treturn ret\n\tcase *ParenExpr:\n\t\treturn walkNames(expr.Expr)\n\t}\n\n\treturn nil\n}", "func (cmd *CmdStruct) Name() string {\n\treturn MessageType(cmd.CmdID).String()\n}", "func (hdr RPMHeader) TagNames() []string {\n\ttags := []string{}\n\tfor _, tag := range hdr.Tags {\n\t\ttags = append(tags, tag.Name)\n\t}\n\treturn tags\n}", "func (e *EnumMatcher) GetName() string { return e.Name }", "func (o *Service) GetNamesOk() ([]string, bool) {\n\tif o == nil || o.Names == nil {\n\t\tvar ret []string\n\t\treturn ret, false\n\t}\n\treturn *o.Names, true\n}", "func ListNames(db *bolt.DB) ([]string, error) {\n\treturn dbutil.ListNames(db, dbutil.TOTPBucket)\n}", "func toStringFields(value reflect.Value, fieldNames []string) string {\n\tvar w bytes.Buffer\n\t// If value is a nil pointer, Indirect returns a zero Value!\n\t// Therefor we need to check for a zero value,\n\t// as CreateFieldByName could panic\n\tif indirectValue := reflect.Indirect(value); indirectValue.IsValid() {\n\t\tfor _, fieldName := range fieldNames {\n\t\t\tif fieldValue := indirectValue.FieldByName(fieldName); fieldValue.IsValid() {\n\t\t\t\ts := toString(fieldValue.Interface())\n\t\t\t\tif s == \"\" {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif w.Len() == 0 {\n\t\t\t\t\tw.WriteString(s)\n\t\t\t\t} else {\n\t\t\t\t\tw.WriteString(\"_\" + s)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn w.String()\n}" ]
[ "0.7588833", "0.6606947", "0.6471602", "0.64051765", "0.6401359", "0.63857347", "0.6371387", "0.6339941", "0.6253955", "0.62511194", "0.60572946", "0.60088223", "0.6007971", "0.5964404", "0.596039", "0.59451365", "0.5940028", "0.59323174", "0.5923466", "0.59138364", "0.5899827", "0.58126265", "0.57936966", "0.57861143", "0.57817996", "0.57734877", "0.5765923", "0.5733768", "0.57310116", "0.5723221", "0.5699389", "0.5696261", "0.56775266", "0.56728244", "0.5672804", "0.5670142", "0.56511873", "0.56360644", "0.5633906", "0.562456", "0.5620891", "0.5614059", "0.56088525", "0.56072295", "0.55495065", "0.5548502", "0.5534785", "0.5534192", "0.55287325", "0.55253834", "0.55167663", "0.55152005", "0.5510479", "0.55099386", "0.55031663", "0.54968727", "0.54864573", "0.54791284", "0.5477416", "0.5470214", "0.5468823", "0.5464027", "0.54586667", "0.54383737", "0.54363275", "0.5426113", "0.54248327", "0.542457", "0.5411303", "0.5405594", "0.5393388", "0.53792745", "0.5365517", "0.536432", "0.5343329", "0.5337602", "0.5337401", "0.5335077", "0.5330937", "0.5326291", "0.5317599", "0.5309694", "0.53064734", "0.5291121", "0.5287923", "0.527709", "0.52669597", "0.52605313", "0.525299", "0.5237339", "0.52311325", "0.522464", "0.52166086", "0.5215514", "0.520842", "0.5206319", "0.5206183", "0.52037126", "0.52025396", "0.519582" ]
0.7442672
1
Tags returns tags of struct
func (s *Structx) Tags(key string) (map[string]string, error) { result := map[string]string{} fs := s.Fields() for _, v := range fs { if !v.IsExport() { continue } result[v.Name()] = v.Tag(key) } return result, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *Field) GetTags() string {\n\tif f == nil {\n\t\treturn \"\"\n\t}\n\n\tjsonTag := \"`json:\\\"\" + f.Name\n\n\tif f.Type.IsInputObject() || !f.Type.IsNonNull() {\n\t\tjsonTag += \",omitempty\"\n\t}\n\n\ttags := jsonTag + \"\\\"`\"\n\n\t// log.Print(\"\\n\\n **************************** \\n\")\n\t// log.Printf(\"\\n Struct Tags: %s \\n\", f)\n\t// log.Printf(\"\\n Struct Tags: %s \\n\", jsonTag)\n\t// log.Print(\"\\n **************************** \\n\\n\")\n\t// time.Sleep(5 * time.Second)\n\n\treturn tags\n}", "func tags(field *ast.Field) []string {\n\tvar tag string\n\tif field.Tag != nil {\n\t\ttag = field.Tag.Value[1 : len(field.Tag.Value)-1]\n\t\ttag = reflect.StructTag(tag).Get(\"json\")\n\t}\n\treturn strings.Split(tag, \",\")\n}", "func (r *RepositoryV2) Tags() (out []struct {\n\tName string\n\tImage string\n}, err error) {\n\turl := fmt.Sprintf(\"https://%s/v2/%s/tags/list\", r.Registry, r.Image)\n\treq, err := http.NewRequest(http.MethodGet, url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar apiResp struct {\n\t\tTags []string `json:\"tags\"`\n\t}\n\terr = json.NewDecoder(resp.Body).Decode(&apiResp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, tagName := range apiResp.Tags {\n\t\tout = append(out, struct {\n\t\t\tName string\n\t\t\tImage string\n\t\t}{\n\t\t\tName: tagName,\n\t\t\tImage: fmt.Sprintf(\"%s/%s:%s\", r.Registry, r.Image, tagName),\n\t\t})\n\t}\n\treturn out, nil\n}", "func (o InstanceOutput) Tags() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *Instance) pulumi.StringArrayOutput { return v.Tags }).(pulumi.StringArrayOutput)\n}", "func (o InstanceOutput) Tags() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *Instance) pulumi.StringArrayOutput { return v.Tags }).(pulumi.StringArrayOutput)\n}", "func (o InstanceFromTemplateOutput) Tags() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *InstanceFromTemplate) pulumi.StringArrayOutput { return v.Tags }).(pulumi.StringArrayOutput)\n}", "func (r *PrivateVirtualInterface) Tags() pulumi.MapOutput {\n\treturn (pulumi.MapOutput)(r.s.State[\"tags\"])\n}", "func (o BucketOutput) Tags() pulumi.MapOutput {\n\treturn o.ApplyT(func(v *Bucket) pulumi.MapOutput { return v.Tags }).(pulumi.MapOutput)\n}", "func (o BucketMetricFilterPtrOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *BucketMetricFilter) map[string]string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Tags\n\t}).(pulumi.StringMapOutput)\n}", "func (point *Point) GetTags(noarray bool, separator string) map[string]string {\n\ttags := map[string]string{}\n\ttags[\"vcenter\"] = point.VCenter\n\ttags[\"type\"] = point.ObjectType\n\ttags[\"name\"] = point.ObjectName\n\tif noarray {\n\t\tif len(point.Datastore) > 0 {\n\t\t\ttags[\"datastore\"] = point.Datastore[0]\n\t\t}\n\t} else {\n\t\tif len(point.Datastore) > 0 {\n\t\t\ttags[\"datastore\"] = strings.Join(point.Datastore, separator)\n\t\t}\n\t}\n\tif noarray {\n\t\tif len(point.Network) > 0 {\n\t\t\ttags[\"network\"] = point.Network[0]\n\t\t}\n\t} else {\n\t\tif len(point.Network) > 0 {\n\t\t\ttags[\"network\"] = strings.Join(point.Network, separator)\n\t\t}\n\t}\n\tif len(point.ESXi) > 0 {\n\t\ttags[\"host\"] = point.ESXi\n\t}\n\tif len(point.Cluster) > 0 {\n\t\ttags[\"cluster\"] = point.Cluster\n\t}\n\tif len(point.Instance) > 0 {\n\t\ttags[\"instance\"] = point.Instance\n\t}\n\tif len(point.ResourcePool) > 0 {\n\t\ttags[\"resourcepool\"] = point.ResourcePool\n\t}\n\tif len(point.Folder) > 0 {\n\t\ttags[\"folder\"] = point.Folder\n\t}\n\tif noarray {\n\t\tif len(point.ViTags) > 0 {\n\t\t\ttags[\"vitags\"] = point.ViTags[0]\n\t\t}\n\t} else {\n\t\tif len(point.ViTags) > 0 {\n\t\t\ttags[\"vitags\"] = strings.Join(point.ViTags, separator)\n\t\t}\n\t}\n\t/*\n\t\tif point.NumCPU != 0 {\n\t\t\ttags[\"numcpu\"] = strconv.FormatInt(int64(point.NumCPU), 10)\n\t\t}\n\t\tif point.MemorySizeMB != 0 {\n\t\t\ttags[\"memorysizemb\"] = strconv.FormatInt(int64(point.MemorySizeMB), 10)\n\t\t}\n\t*/\n\treturn tags\n}", "func (hdr RPMHeader) Tag(tagname string) []string {\n\tfor _, tag := range hdr.Tags {\n\t\tif tag.Name == tagname {\n\t\t\treturn tag.Values\n\t\t}\n\t}\n\treturn []string{\"\"}\n}", "func (o TrackerOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Tracker) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o BucketOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Bucket) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func parseTags(st reflect.StructTag) tags {\n\ts := st.Get(ndrNameSpace)\n\tt := tags{\n\t\tValues: []string{},\n\t\tMap: make(map[string]string),\n\t}\n\tif s != \"\" {\n\t\tndrTags := strings.Trim(s, `\"`)\n\t\tfor _, tag := range strings.Split(ndrTags, \",\") {\n\t\t\tif strings.Contains(tag, \":\") {\n\t\t\t\tm := strings.SplitN(tag, \":\", 2)\n\t\t\t\tt.Map[m[0]] = m[1]\n\t\t\t} else {\n\t\t\t\tt.Values = append(t.Values, tag)\n\t\t\t}\n\t\t}\n\t}\n\treturn t\n}", "func (r *Repository) Tags() (out []struct {\n\tName string\n\tImage string\n}, err error) {\n\terr = r.Parse()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tswitch {\n\tcase r.V2 != nil:\n\t\treturn r.V2.Tags()\n\tcase r.DockerHub != nil:\n\t\treturn r.DockerHub.Tags()\n\tdefault:\n\t\treturn nil, errors.New(\"no docker Repository defined\")\n\t}\n}", "func (o BucketIntelligentTieringConfigurationFilterPtrOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *BucketIntelligentTieringConfigurationFilter) map[string]string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Tags\n\t}).(pulumi.StringMapOutput)\n}", "func ListTags() []string {\n\treturn _tags\n}", "func (self *Client) Tags(t MetricType, id string, o ...Modifier) (map[string]string, error) {\n\to = prepend(o, self.Url(\"GET\", TypeEndpoint(t), SingleMetricEndpoint(id), TagEndpoint()))\n\n\tr, err := self.Send(o...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer r.Body.Close()\n\n\tif r.StatusCode == http.StatusOK {\n\t\tb, err := ioutil.ReadAll(r.Body)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttags := make(map[string]string)\n\t\tif b != nil {\n\t\t\tif err = json.Unmarshal(b, &tags); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\treturn tags, nil\n\t} else if r.StatusCode > 399 {\n\t\treturn nil, self.parseErrorResponse(r)\n\t}\n\n\treturn nil, nil\n}", "func (o NetworkOutput) Tags() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *Network) pulumi.StringArrayOutput { return v.Tags }).(pulumi.StringArrayOutput)\n}", "func Tags(v interface{}, key string) (map[string]string, error) {\n\treturn New(v).Tags(key)\n}", "func (c *Client) Tags(t MetricType, id string, o ...Modifier) (map[string]string, error) {\n\to = prepend(o, c.Url(\"GET\", TypeEndpoint(t), SingleMetricEndpoint(id), TagEndpoint()))\n\n\tr, err := c.Send(o...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer r.Body.Close()\n\n\tif r.StatusCode == http.StatusOK {\n\t\tb, err := ioutil.ReadAll(r.Body)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttags := make(map[string]string)\n\t\tif b != nil {\n\t\t\tif err = json.Unmarshal(b, &tags); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\treturn tags, nil\n\t} else if r.StatusCode > 399 {\n\t\treturn nil, c.parseErrorResponse(r)\n\t}\n\n\treturn nil, nil\n}", "func getTags(s interface{}, tag string) []string {\n\tvar columns []string\n\ttblStructType := reflect.TypeOf(s)\n\n\tfor fnum := 0; fnum < tblStructType.NumField(); fnum++ {\n\t\tfield := tblStructType.Field(fnum)\n\t\tif fieldName, ok := field.Tag.Lookup(tag); ok {\n\t\t\tif fieldName != \"\" {\n\t\t\t\tcolumns = append(columns, fieldName)\n\t\t\t}\n\t\t}\n\t}\n\treturn columns\n}", "func (aiService *AppinsightsMonitorService) getTags(tagType string, name string) map[string]*string {\n\n\ttags := make(map[string]*string)\n\n\tcomponentHiddenlink := fmt.Sprintf(\"hidden-link:/subscriptions/%s/resourceGroups/%s/providers/microsoft.insights/components/%s\", aiService.subscriptionID, aiService.resourceGroup, aiService.name)\n\twebtestHiddenlink := fmt.Sprintf(\"hidden-link:/subscriptions/%s/resourceGroups/%s/providers/microsoft.insights/webtests/%s\", aiService.subscriptionID, aiService.resourceGroup, name)\n\tvalue := \"Resource\"\n\n\tif tagType == \"webtest\" {\n\t\ttags[componentHiddenlink] = &value\n\t}\n\n\tif tagType == \"alert\" {\n\n\t\ttags[componentHiddenlink] = &value\n\t\ttags[webtestHiddenlink] = &value\n\t}\n\n\treturn tags\n}", "func (f Fess) GetTags() []string {\n\ttags := []string{\n\t\t\"full size\",\n\t\t\"ordinary\",\n\t}\n\treturn tags\n}", "func GetTags() [10]string {\n\treturn tags\n}", "func (o SubnetOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Subnet) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (r Roundel) GetTags() []string {\n\ttags := []string{\n\t\t\"ordinary\",\n\t}\n\treturn tags\n}", "func (r *Bucket) Tags() pulumi.MapOutput {\n\treturn (pulumi.MapOutput)(r.s.State[\"tags\"])\n}", "func (o OpenZfsVolumeOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *OpenZfsVolume) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func Tags(tags tftags.KeyValueTags) []*inspector.Tag {\n\tresult := make([]*inspector.Tag, 0, len(tags))\n\n\tfor k, v := range tags.Map() {\n\t\ttag := &inspector.Tag{\n\t\t\tKey: aws.String(k),\n\t\t\tValue: aws.String(v),\n\t\t}\n\n\t\tresult = append(result, tag)\n\t}\n\n\treturn result\n}", "func (o FleetOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Fleet) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (is *IfaceStat) GetTags() []string {\n\tvar tags []string\n\tvalueMap := structs.Map(is)\n\tfor k := range valueMap {\n\t\ttags = append(tags, k)\n\t}\n\n\treturn tags\n}", "func (o SnapshotOutput) Tags() pulumi.MapOutput {\n\treturn o.ApplyT(func(v *Snapshot) pulumi.MapOutput { return v.Tags }).(pulumi.MapOutput)\n}", "func (o EntityRecognizerOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *EntityRecognizer) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func GetStructTags(mode string, tagname string, input interface{}, options ...interface{}) []string {\n\n\tcolumns := make([]string, 0)\n\tvalue := reflect.ValueOf(input)\n\n\t// Originally used to rule out id field when insert\n\tvar skipFields []string\n\tif options != nil {\n\t\tskipFields = options[0].([]string)\n\t}\n\nFindTags:\n\tfor i := 0; i < value.NumField(); i++ {\n\n\t\tfield := value.Type().Field(i)\n\t\tfieldType := field.Type\n\t\tfieldValue := value.Field(i)\n\n\t\t// Use Type() to get struct tags\n\t\ttag := value.Type().Field(i).Tag.Get(tagname)\n\t\t// Skip fields if there are denoted\n\t\tif len(skipFields) > 0 {\n\n\t\t\tfor _, f := range skipFields {\n\t\t\t\tif tag == f {\n\t\t\t\t\tcontinue FindTags\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif mode == \"full\" {\n\t\t\tcolumns = append(columns, tag)\n\t\t} else if mode == \"non-null\" {\n\t\t\t// Append each tag for non-null field\n\t\t\tswitch fieldType.Name() {\n\t\t\tcase \"string\":\n\t\t\t\tif fieldValue.String() != \"\" {\n\t\t\t\t\tcolumns = append(columns, tag)\n\t\t\t\t}\n\t\t\tcase \"int64\", \"int\":\n\t\t\t\tif fieldValue.Int() != 0 {\n\t\t\t\t\tcolumns = append(columns, tag)\n\t\t\t\t}\n\t\t\tcase \"uint32\":\n\t\t\t\tif fieldValue.Uint() != 0 {\n\t\t\t\t\tcolumns = append(columns, tag)\n\t\t\t\t}\n\t\t\tcase \"NullString\", \"NullInt\", \"NullTime\", \"NullBool\":\n\t\t\t\tif fieldValue.FieldByName(\"Valid\").Bool() {\n\t\t\t\t\tcolumns = append(columns, tag)\n\t\t\t\t}\n\t\t\tcase \"bool\":\n\t\t\t\tcolumns = append(columns, tag)\n\t\t\tdefault:\n\t\t\t\tfmt.Println(\"unrecognised format: \", value.Field(i).Type())\n\t\t\t}\n\t\t}\n\t}\n\treturn columns\n}", "func (l *Log) Tags() (res []string) {\n\tres = l.tags\n\treturn\n}", "func getTagValues(f reflect.StructField, tag string) string {\n\treturn f.Tag.Get(tag)\n}", "func getTags(operation *openapi3.Operation) string {\n\treturn strings.Replace(operation.Tags[0], \" \", \"-\", -1)\n}", "func (g *GitLocal) Tags(dir string) ([]string, error) {\n\treturn g.GitCLI.Tags(dir)\n}", "func (s *Safe) Tags() ([]*safe.Tag, error) {\n\tres := make([]*safe.Tag, 0)\n\terr := s.db.View(func(tx *bolt.Tx) error {\n\t\treturn tx.Bucket([]byte(TagTable)).ForEach(func(k, v []byte) (err error) {\n\t\t\tvar d safe.Tag\n\t\t\tif err = json.Unmarshal(v, &d); err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tres = append(res, &d)\n\t\t\treturn\n\t\t})\n\t})\n\treturn res, err\n}", "func (m *MyMetric) TagList() []*protocol.Tag {\n\treturn m.Tags\n}", "func GetTags(registry string, github GitHub) ([]string, error) {\n\trepo := dockerRepo(github)\n\tvar tags []string\n\tfor _, t := range staticTags() {\n\t\ttags = append(tags, toFullTag(registry, repo, t))\n\t}\n\tif withRef, err := tagWithRef(); err != nil {\n\t\treturn nil, err\n\t} else if withRef {\n\t\tswitch github.Reference.Type {\n\t\tcase GitRefHead:\n\t\t\tif github.Reference.Name == \"master\" || github.Reference.Name == \"main\" {\n\t\t\t\ttags = append(tags, toFullTag(registry, repo, \"latest\"))\n\t\t\t} else {\n\t\t\t\ttags = appendGitRefTag(tags, registry, repo, github.Reference.Name)\n\t\t\t}\n\t\tcase GitRefPullRequest:\n\t\t\ttags = appendGitRefTag(tags, registry, repo, fmt.Sprintf(\"pr-%s\", github.Reference.Name))\n\n\t\tcase GitRefTag:\n\t\t\ttags = appendGitRefTag(tags, registry, repo, github.Reference.Name)\n\t\t}\n\t}\n\tif withSha, err := tagWithSha(); err != nil {\n\t\treturn nil, err\n\t} else if withSha {\n\t\ttags = appendShortGitShaTag(tags, github, registry, repo)\n\t}\n\treturn tags, nil\n}", "func (o LanguageModelOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *LanguageModel) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (t *SentryTaggedStruct) BuildTags(v interface{}) (tags map[string]string, err error) {\n\titems := make(map[string]string)\n\tfor prop, name := range t.Tags {\n\t\tif _, value, e := t.GetProperty(v, prop); e == nil {\n\t\t\titems[name] = value\n\t\t} else {\n\t\t\terr = e\n\t\t\treturn\n\t\t}\n\t}\n\n\ttags = items\n\treturn\n}", "func (o ReservedInstanceOutput) Tags() pulumi.MapOutput {\n\treturn o.ApplyT(func(v *ReservedInstance) pulumi.MapOutput { return v.Tags }).(pulumi.MapOutput)\n}", "func (f *flags) Tags() []string {\n\tif f.opt.Tags == modeFlagUnUsed {\n\t\treturn nil\n\t}\n\treturn f.exclude(f.getvalue(f.opt.Tags, \"tags\", \"t\"),\n\t\tf.getvalue(f.opt.ExcludeTags, \"nt\", \"\"))\n\n}", "func (o BucketMetricFilterOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v BucketMetricFilter) map[string]string { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (t *SentryTaggedStruct) GetTags() SentryTags {\n\treturn t.Tags\n}", "func (search *Search) Tags(tag string) (*SearchResult, error) {\n\tinsta := search.inst\n\tbody, err := insta.sendRequest(\n\t\t&reqOptions{\n\t\t\tEndpoint: urlSearchTag,\n\t\t\tQuery: map[string]string{\n\t\t\t\t\"is_typeahead\": \"true\",\n\t\t\t\t\"rank_token\": insta.rankToken,\n\t\t\t\t\"q\": tag,\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tres := &SearchResult{}\n\terr = json.Unmarshal(body, res)\n\treturn res, err\n}", "func (n *node) Tags() []string {\n\treturn n.tags\n}", "func (o RunBookOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *RunBook) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o BucketIntelligentTieringConfigurationFilterOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v BucketIntelligentTieringConfigurationFilter) map[string]string { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (d *DiskIOState) GetTags() []string {\n\tvar tags []string\n\tvalueMap := structs.Map(d)\n\tfor k := range valueMap {\n\t\ttags = append(tags, k)\n\t}\n\n\treturn tags\n}", "func (o BucketOutput) Tags() BucketTagArrayOutput {\n\treturn o.ApplyT(func(v *Bucket) BucketTagArrayOutput { return v.Tags }).(BucketTagArrayOutput)\n}", "func (o BucketOutput) Tags() BucketTagArrayOutput {\n\treturn o.ApplyT(func(v *Bucket) BucketTagArrayOutput { return v.Tags }).(BucketTagArrayOutput)\n}", "func Tag(name string, events ...imageapi.TagEvent) namedTagEventList {\n\treturn namedTagEventList{\n\t\tname: name,\n\t\tevents: imageapi.TagEventList{\n\t\t\tItems: events,\n\t\t},\n\t}\n}", "func getFieldTags(t reflect.StructField) (res []string) {\n\tif tags := t.Tag.Get(mapEnvTagName); len(tags) > 0 {\n\t\tfor _, s := range strings.Split(tags, \",\") {\n\t\t\tif len(s) > 0 {\n\t\t\t\tres = append(res, s)\n\t\t\t}\n\t\t}\n\t}\n\n\t// ignore json tags and field name if mpe tag is present\n\tif len(res) > 0 {\n\t\treturn\n\t}\n\n\tif tags := t.Tag.Get(\"json\"); len(tags) > 0 {\n\t\tjsonTags := strings.Split(tags, \",\")\n\t\tif len(jsonTags) > 0 && len(jsonTags[0]) > 0 {\n\t\t\tres = append(res, jsonTags[0])\n\t\t}\n\t}\n\n\t// ignore field name if json tag is present\n\tif len(res) > 0 {\n\t\treturn\n\t}\n\n\tres = append(res, t.Name)\n\n\treturn\n}", "func (o *ShortenBitlinkBodyAllOf) GetTags() []string {\n\tif o == nil || o.Tags == nil {\n\t\tvar ret []string\n\t\treturn ret\n\t}\n\treturn *o.Tags\n}", "func (p Pale) GetTags() []string {\n\ttags := []string{\n\t\t\"full size\",\n\t\t\"ordinary\",\n\t}\n\treturn tags\n}", "func (o ListenerOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v Listener) map[string]string { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o LinkOutput) Tags() LinkTagArrayOutput {\n\treturn o.ApplyT(func(v *Link) LinkTagArrayOutput { return v.Tags }).(LinkTagArrayOutput)\n}", "func (o LookupOpenZfsSnapshotResultOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v LookupOpenZfsSnapshotResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o VolumeGroupSapHanaVolumeOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v VolumeGroupSapHanaVolume) map[string]string { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (r *Registry) Tags(ctx context.Context, repository string) ([]Tag, error) {\n tagNames, err := r.TagNames(ctx, repository)\n if err != nil {\n\t\treturn nil, err\n\t}\n\n\ttags := make([]Tag, len(tagNames))\n\tfor i := range tags {\n\t\ttags[i] = Tag {\n\t\t\tName: tagNames[i],\n\t\t\tRepository: repository,\n\t\t\tRegistry: r,\n\t\t}\n\t}\n\treturn tags, nil\n}", "func (ce *CustomEvent) GetTags() []string {\n\treturn append(ce.tags, \"type:\"+ce.GetType())\n}", "func (o LookupTestCaseResultOutput) Tags() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v LookupTestCaseResult) []string { return v.Tags }).(pulumi.StringArrayOutput)\n}", "func (o ThingGroupOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *ThingGroup) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (db *BotDB) GetTags(guild uint64) []struct {\n\tName string\n\tCount int\n} {\n\tq, err := db.sqlGetTags.Query(guild)\n\terr = db.standardErr(err)\n\tif db.CheckError(\"GetTags\", err) != nil {\n\t\treturn []struct {\n\t\t\tName string\n\t\t\tCount int\n\t\t}{}\n\t}\n\tdefer q.Close()\n\tr := make([]struct {\n\t\tName string\n\t\tCount int\n\t}, 0, 10)\n\tfor q.Next() {\n\t\tp := struct {\n\t\t\tName string\n\t\t\tCount int\n\t\t}{}\n\t\tif err := q.Scan(&p.Name, &p.Count); err == nil {\n\t\t\tr = append(r, p)\n\t\t}\n\t}\n\treturn r\n}", "func GetTypeTags(typ reflect.Type, tagNames []string, fs ...func(reflect.StructTag) bool) map[string]GF[string] {\n\tvar (\n\t\ttags = make(map[string]GF[string])\n\t)\n\tfor _, tagName := range tagNames {\n\t\ttags[tagName] = GetTypeTag(typ, tagName, fs...)\n\t}\n\treturn tags\n}", "func (a *API) Tags(ctx context.Context, params TagsParams) (*TagsResult, error) {\n\tres := &TagsResult{}\n\t_, err := a.get(ctx, api.BuildPath(tags, params.AssetType), params, res)\n\n\treturn res, err\n}", "func GetTags() []string {\n\ttags := []string{\n\t\t\"script\",\n\t\t\"iframe\",\n\t\t\"svg\",\n\t\t\"img\",\n\t\t\"video\",\n\t\t\"audio\",\n\t\t\"meta\",\n\t\t\"object\",\n\t\t\"embed\",\n\t\t\"style\",\n\t\t\"frame\",\n\t\t\"frameset\",\n\t\t\"applet\",\n\t}\n\treturn tags\n}", "func (e *Extractor) NamesFromTag(tag string) (out []string, err error) {\n\n\tif err := e.isValidStruct(); err != nil {\n\t\treturn nil, err\n\t}\n\n\ts := reflect.ValueOf(e.StructAddr).Elem()\n\tfields := e.fields(s)\n\n\tfor _, field := range fields {\n\t\tif val, ok := field.tags.Lookup(tag); ok {\n\t\t\tkey, omit := e.parseOmitempty(val, field.value)\n\t\t\tif omit {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tout = append(out, key)\n\t\t}\n\t}\n\n\treturn\n}", "func (v *vcsCmd) tags(dir string) ([]string, error) {\n\tvar tags []string\n\tfor _, tc := range v.tagCmd {\n\t\tout, err := v.runOutput(dir, tc.cmd)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tre := regexp.MustCompile(`(?m-s)` + tc.pattern)\n\t\tfor _, m := range re.FindAllStringSubmatch(string(out), -1) {\n\t\t\ttags = append(tags, m[1])\n\t\t}\n\t}\n\treturn tags, nil\n}", "func (o VpcLinkOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *VpcLink) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o FaqOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Faq) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func typeTags(structType reflect.Type) (tags []byte) {\n\ttagStr := structType.Field(0).Tag.Get(\"sshtype\")\n\n\tfor _, tag := range strings.Split(tagStr, \"|\") {\n\t\ti, err := strconv.Atoi(tag)\n\t\tif err == nil {\n\t\t\ttags = append(tags, byte(i))\n\t\t}\n\t}\n\n\treturn tags\n}", "func (r *Document) Tags() pulumi.MapOutput {\n\treturn (pulumi.MapOutput)(r.s.State[\"tags\"])\n}", "func (o ListenerPtrOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Listener) map[string]string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Tags\n\t}).(pulumi.StringMapOutput)\n}", "func (t *Transaction) Tags() ([]Tag, error) {\n\ttags := []Tag{}\n\tfor _, tag := range t.tags {\n\t\t// access name\n\t\ttagName, err := utils.DecodeString(tag.Name)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttagValue, err := utils.DecodeString(tag.Value)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttags = append(tags, Tag{Name: string(tagName), Value: string(tagValue)})\n\t}\n\treturn tags, nil\n}", "func buildTags() string {\n\treturn *tags\n}", "func (o GetVolumeGroupSapHanaVolumeOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v GetVolumeGroupSapHanaVolume) map[string]string { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o LookupVirtualNetworkResultOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v LookupVirtualNetworkResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (r *Rule) Tags() pulumi.MapOutput {\n\treturn (pulumi.MapOutput)(r.s.State[\"tags\"])\n}", "func (lv *LogicalVolume) Tags() ([]string, error) {\n\tresult := new(lvsOutput)\n\tif err := run(\"lvs\", result, \"--options=lv_tags\", lv.vg.name+\"/\"+lv.name); err != nil {\n\t\tif IsLogicalVolumeNotFound(err) {\n\t\t\treturn nil, ErrLogicalVolumeNotFound\n\t\t}\n\t\treturn nil, err\n\t}\n\tfor _, report := range result.Report {\n\t\tfor _, lv := range report.Lv {\n\t\t\treturn lv.tagList(), nil\n\t\t}\n\t}\n\treturn nil, ErrLogicalVolumeNotFound\n}", "func (t ISILTagger) Tags(is finc.IntermediateSchema) []string {\n\tisils := container.NewStringSet()\n\tfor isil, filters := range t {\n\t\tfor _, f := range filters {\n\t\t\tif f.Apply(is) {\n\t\t\t\tisils.Add(isil)\n\t\t\t}\n\t\t}\n\t}\n\treturn isils.Values()\n}", "func (o ScheduledAuditOutput) Tags() ScheduledAuditTagArrayOutput {\n\treturn o.ApplyT(func(v *ScheduledAudit) ScheduledAuditTagArrayOutput { return v.Tags }).(ScheduledAuditTagArrayOutput)\n}", "func (o VirtualGatewayOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *VirtualGateway) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o AnalyzerOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Analyzer) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o AnalyzerOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Analyzer) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o DomainOutput) Tags() pulumi.MapOutput {\n\treturn o.ApplyT(func(v *Domain) pulumi.MapOutput { return v.Tags }).(pulumi.MapOutput)\n}", "func (o RepositoryOutput) Tags() RepositoryTagArrayOutput {\n\treturn o.ApplyT(func(v *Repository) RepositoryTagArrayOutput { return v.Tags }).(RepositoryTagArrayOutput)\n}", "func Tags(val []string) zap.Field {\n\treturn zap.Field{Key: FieldTags, Type: zapcore.SkipType, Interface: val}\n}", "func (sp *Space) GetTags() []string {\n\tif len(*sp) > 0 {\n\t\treturn (*sp)[0].GetTags()\n\t}\n\treturn []string{}\n}", "func (m *Application) GetTags()([]string) {\n return m.tags\n}", "func (o CachesIscsiVolumeOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *CachesIscsiVolume) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "func (o StudioOutput) Tags() StudioTagArrayOutput {\n\treturn o.ApplyT(func(v *Studio) StudioTagArrayOutput { return v.Tags }).(StudioTagArrayOutput)\n}", "func (c Cross) GetTags() []string {\n\ttags := []string{\n\t\t\"full size\",\n\t\t\"ordinary\",\n\t}\n\treturn tags\n}", "func (o LookupDetectorModelResultOutput) Tags() DetectorModelTagArrayOutput {\n\treturn o.ApplyT(func(v LookupDetectorModelResult) []DetectorModelTag { return v.Tags }).(DetectorModelTagArrayOutput)\n}", "func (m FieldMap) Tags() []Tag {\n\ttags := make([]Tag, 0, len(m.tagLookup))\n\tfor t := range m.tagLookup {\n\t\ttags = append(tags, t)\n\t}\n\n\treturn tags\n}", "func (o OceanLaunchSpecOutput) Tags() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *OceanLaunchSpec) pulumi.StringArrayOutput { return v.Tags }).(pulumi.StringArrayOutput)\n}" ]
[ "0.6812187", "0.662246", "0.6557578", "0.64463", "0.64463", "0.6434869", "0.64187056", "0.64000773", "0.6397878", "0.63918966", "0.63834083", "0.6358394", "0.6354617", "0.63435465", "0.63312256", "0.63297874", "0.6329586", "0.6325723", "0.6320472", "0.63034225", "0.62952924", "0.6293875", "0.6293222", "0.6272951", "0.6271133", "0.6270027", "0.6269127", "0.6253629", "0.6244772", "0.62371594", "0.6236854", "0.62183976", "0.62020993", "0.61867434", "0.61806506", "0.6180196", "0.6169418", "0.61655384", "0.6152274", "0.6146125", "0.6131537", "0.6124739", "0.61236244", "0.6123234", "0.61150575", "0.6112322", "0.61103237", "0.6101857", "0.6093065", "0.6078722", "0.60779375", "0.6074663", "0.60710156", "0.60699964", "0.60699964", "0.6067895", "0.60611206", "0.6059571", "0.6058191", "0.605534", "0.6051761", "0.6038896", "0.6030711", "0.602959", "0.60249156", "0.6024602", "0.60242534", "0.6014877", "0.60137564", "0.60133964", "0.6009763", "0.60080194", "0.6004529", "0.5997459", "0.59934574", "0.5987844", "0.5981705", "0.5976986", "0.5975538", "0.5975033", "0.5962965", "0.59597707", "0.59523124", "0.59506935", "0.5946875", "0.59451735", "0.593869", "0.5933934", "0.5933934", "0.5933358", "0.59327567", "0.5931301", "0.5926761", "0.5923919", "0.5923057", "0.5922226", "0.5915596", "0.59138024", "0.59132314", "0.5907288" ]
0.63906616
10
Values returns values of struct
func (s *Structx) Values() []interface{} { var result []interface{} fs := s.Fields() for _, v := range fs { if !v.IsExport() { continue } result = append(result, v.Value()) } return result }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (e *Extractor) Values() (out []interface{}, err error) {\n\n\tif err := e.isValidStruct(); err != nil {\n\t\treturn nil, err\n\t}\n\n\ts := reflect.ValueOf(e.StructAddr).Elem()\n\tfields := e.fields(s)\n\n\tfor _, field := range fields {\n\t\tout = append(out, field.value.Interface())\n\n\t}\n\n\treturn\n}", "func (s Struct) Value() []StructField {\n\treturn s.fields\n}", "func (m *Value) Values() []xmlrpc.Value { return m.ValuesMock() }", "func (c *Capture) Values() []interface{} {\n\tret := make([]interface{}, 8)\n\n\tret[0] = c.Timestamp\n\tret[1] = c.ColIP.String()\n\tret[2] = c.PeerIP.String()\n\tret[3] = pq.Array(c.ASPath)\n\tret[4] = c.NextHop.String()\n\tret[5] = c.Origin\n\n\tadvArr := util.PrefixesToPQArray(c.Advertised)\n\twdrArr := util.PrefixesToPQArray(c.Withdrawn)\n\tret[6] = advArr\n\tret[7] = wdrArr\n\n\treturn ret\n}", "func (pb *PageBuffer) Values() interface{} {\n offset := pb.pageOffset(pb.page_no)\n return pb.buffer.Slice(offset, offset + pb.idx).Interface()\n}", "func (c *AdapterMemory) Values(ctx context.Context) ([]interface{}, error) {\n\treturn c.data.Values()\n}", "func (s *Store) Values() []interface{} {\n\ts.access.RLock()\n\tdefer s.access.RUnlock()\n\n\tcpy := make([]interface{}, len(s.data))\n\ti := 0\n\tfor _, value := range s.data {\n\t\tcpy[i] = value\n\t\ti++\n\t}\n\treturn cpy\n}", "func (v *Version) Values(ctx context.Context) ([]byte, error) {\n\tlock := v.Chart.Space.SpaceManager.Lock.Get(v.Chart.Space.Name(), v.Chart.Name(), v.Number())\n\tif !lock.RLock(v.Chart.Space.SpaceManager.LockTimeout) {\n\t\treturn nil, ErrorLocking.Format(\"version\", v.Chart.Space.Name()+\"/\"+v.Chart.Name()+\"/\"+v.Number())\n\t}\n\tdefer lock.RUnlock()\n\tif err := v.Validate(ctx); err != nil {\n\t\treturn nil, err\n\t}\n\tpath := path.Join(v.Prefix, valuesName)\n\tdata, err := v.Backend.GetContent(ctx, path)\n\tif err != nil {\n\t\treturn nil, ErrorContentNotFound.Format(v.Prefix)\n\t}\n\treturn data, nil\n}", "func (e *Entity) Values() []interface{} {\n\tpqPrefs := util.PrefixesToPQArray(e.OwnedPrefixes)\n\tvals := make([]interface{}, 4)\n\tvals[0] = util.SanitizeDBString(e.Name)\n\tvals[1] = util.SanitizeDBString(e.Email)\n\tvals[2] = pq.Array(e.OwnedOrigins)\n\tvals[3] = pqPrefs\n\n\treturn vals\n}", "func (b *Buffer) Values() interface{} {\n return b.buffer.Slice(0, b.idx).Interface()\n}", "func (page MemberCollectionPage) Values() []Member {\n\tif page.mc.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.mc.Value\n}", "func (t Tuple) Values() []float64 {\n\treturn t\n}", "func (_TellorMesosphere *TellorMesosphereCaller) Values(opts *bind.CallOpts, arg0 *big.Int, arg1 *big.Int) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _TellorMesosphere.contract.Call(opts, &out, \"values\", arg0, arg1)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (lst List) Value() []Value {\n\treturn lst.values\n}", "func (nData *NaiveData) Value() []gotypes.Value {\n\treturn nData.Val\n}", "func (g *GrowingBuffer) Values() interface{} {\n return g.bufferPtr.Elem().Interface()\n}", "func (_SimpleStorage *SimpleStorageCallerSession) GetValues() (struct {\n\tIntValue *big.Int\n\tStringValue string\n}, error) {\n\treturn _SimpleStorage.Contract.GetValues(&_SimpleStorage.CallOpts)\n}", "func Values(v interface{}) []interface{} {\n\treturn New(v).Values()\n}", "func (page ListResultPage) Values() []Model {\n\tif page.lr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.lr.Value\n}", "func (f *observable) Value() map[string]interface{} {\n\ttoReturn := map[string]interface{}{}\n\tfor k, v := range f.ObsFields {\n\t\ttoReturn[k] = v\n\t}\n\treturn toReturn\n}", "func (t *Tags) Values() map[string]interface{} {\n\treturn t.values\n}", "func (o FleetMetricAggregationTypePtrOutput) Values() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *FleetMetricAggregationType) []string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Values\n\t}).(pulumi.StringArrayOutput)\n}", "func (InstanceGeneration) Values() []InstanceGeneration {\n\treturn []InstanceGeneration{\n\t\t\"current\",\n\t\t\"previous\",\n\t}\n}", "func (page ProviderOperationsMetadataListResultPage) Values() []ProviderOperationsMetadata {\n\tif page.pomlr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.pomlr.Value\n}", "func (it *Iter) Values() (uint32, float64) {\n\treturn it.T, it.Val\n}", "func (s SExp) Value() []Value {\n\treturn s.values\n}", "func (page VaultListResultPage) Values() []Vault {\n\tif page.vlr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.vlr.Value\n}", "func (rec Record) Values() []string {\n\trow := make([]string, numExported(rec.t))\n\tvar k int\n\tfor i := 0; i < rec.t.NumField(); i++ {\n\t\tif isExported(rec.t.Field(i)) {\n\t\t\trow[k] = fmt.Sprint(rec.v.Field(i))\n\t\t\tk++\n\t\t}\n\t}\n\treturn row\n}", "func (_SimpleStorage *SimpleStorageSession) GetValues() (struct {\n\tIntValue *big.Int\n\tStringValue string\n}, error) {\n\treturn _SimpleStorage.Contract.GetValues(&_SimpleStorage.CallOpts)\n}", "func (c *Cache) Values() ([]interface{}, error) {\n\treturn c.adapter.Values(c.getCtx())\n}", "func (page SasTokenInformationListResultPage) Values() []SasTokenInformation {\n\tif page.stilr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.stilr.Value\n}", "func (RecordWrapper) Values() []RecordWrapper {\n\treturn []RecordWrapper{\n\t\t\"None\",\n\t\t\"RecordIO\",\n\t}\n}", "func (v *Value) Data() interface{} {\n return v.data\n}", "func (m *Mutate) Values() map[string]map[string][]byte {\n\treturn m.values\n}", "func (_SimpleStorage *SimpleStorageCaller) GetValues(opts *bind.CallOpts) (struct {\n\tIntValue *big.Int\n\tStringValue string\n}, error) {\n\tret := new(struct {\n\t\tIntValue *big.Int\n\t\tStringValue string\n\t})\n\tout := ret\n\terr := _SimpleStorage.contract.Call(opts, out, \"getValues\")\n\treturn *ret, err\n}", "func (c *Scratch) Values() map[string]any {\n\tc.mu.RLock()\n\tdefer c.mu.RUnlock()\n\treturn c.values\n}", "func (f *FieldsWithValue) Values() []string {\n\tvalues := make([]string, len(f.fields))\n\tfor i := range f.fields {\n\t\tvalues[i] = f.fields[i].Value\n\t}\n\treturn values\n}", "func (page StorageAccountInformationListResultPage) Values() []StorageAccountInformation {\n\tif page.sailr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.sailr.Value\n}", "func (entry LogEntry) GetValues() []interface{} {\n\treturn entry.valueList\n}", "func Values(live bool) Model {\n\t// prepare model\n\tmodel := Auto(&glut.Model{}, \"value\", \"Value\", \"Values\", nil)\n\tmodel.Watchable = live\n\tmodel.Immediate = live\n\tmodel.Creatable = false\n\n\treturn model\n}", "func (tree *Tree) Values() []interface{} {\n\tvalues := make([]interface{}, tree.size)\n\tit := tree.Iterator()\n\tfor i := 0; it.Next(); i++ {\n\t\tvalues[i] = it.Value()\n\t}\n\treturn values\n}", "func (TrafficMirrorSessionField) Values() []TrafficMirrorSessionField {\n\treturn []TrafficMirrorSessionField{\n\t\t\"packet-length\",\n\t\t\"description\",\n\t\t\"virtual-network-id\",\n\t}\n}", "func (q *PriorityQueue) Values() []interface{} {\n\tsize := q.data.Size()\n\tvalues := q.data.Values()\n\tres := make([]interface{}, size)\n\tfor i := 0; i < size; i++ {\n\t\tres[i] = values[i].(*pqItem).value\n\t}\n\treturn res\n}", "func (p Packet) Values() ([]Value) {\n\tvalues := make([]Value, len(p.DataTypes))\n\tfor i := range values {\n\t\tvalues[i] = Value{p.DataTypes[i], p.Bytes[i*8 : 8+(i*8)] }\n\t}\n\treturn values\n}", "func (page ListPage) Values() []Response {\n\tif page.l.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.l.Value\n}", "func (t Tags) Values() []Tag {\n\treturn t.values\n}", "func (p Profile) Values() map[*structs.Field][]interface{} {\n\tvar v = make(map[*structs.Field][]interface{})\n\tfor i, f := range structs.Fields(p.First()) {\n\t\tfor _, a := range p.FieldPerms {\n\t\t\tv[f] = append(v[f], structs.Values(a)[i])\n\t\t}\n\t}\n\treturn v\n}", "func (page UsageAggregationListResultPage) Values() []UsageAggregation {\n\tif page.ualr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.ualr.Value\n}", "func Struct(v interface{}) (values CMap) {\n\tvalues = New()\n\tiVal := reflect.ValueOf(v)\n\tif iVal.Kind() == reflect.Ptr {\n\t\tiVal = iVal.Elem()\n\t}\n\ttyp := iVal.Type()\n\tfor i := 0; i < iVal.NumField(); i++ {\n\t\tfi := typ.Field(i)\n\t\tname := fi.Tag.Get(\"json\")\n\t\tif name == \"\" {\n\t\t\tname = fi.Name\n\t\t}\n\t\t// add support slice\n\t\tif iVal.Field(i).Kind() == reflect.Slice {\n\t\t\tvar buf bytes.Buffer\n\t\t\tbuf.WriteString(\"[\")\n\t\t\tiValArr := iVal.Field(i)\n\t\t\tfor j := 0; j < iValArr.Len(); j++ {\n\t\t\t\tbuf.WriteString(fmt.Sprint(`\"`, iValArr.Index(j), `\",`))\n\t\t\t}\n\t\t\tval := string(buf.Bytes()[:buf.Len()-1])\n\t\t\tval += \"]\"\n\t\t\tvalues.Set(name, val)\n\t\t\tcontinue\n\t\t}\n\t\tvalues.Set(name, fmt.Sprint(iVal.Field(i)))\n\t}\n\treturn\n}", "func (list *List) Values() []interface{} {\n\tvalues := make([]interface{}, list.size, list.size)\n\tfor e, element := 0, list.first; element != nil; e, element = e+1, element.next {\n\t\tvalues[e] = element.value\n\t}\n\treturn values\n}", "func (page AvailableSkusResultPage) Values() []SkuInformation {\n\tif page.asr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.asr.Value\n}", "func (o *Object) Value() interface{} { return o }", "func (it *Iterator) Value() interface{} { return it.n.v }", "func (it *Iterator) Value() interface{} { return it.n.v }", "func (page PrivateCloudListPage) Values() []PrivateCloud {\n\tif page.pcl.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.pcl.Value\n}", "func structVals(v reflect.Value, cols []string) []interface{} {\n\tvar vals []interface{}\n\tfor idx := range cols {\n\t\tif idx >= v.NumField() {\n\t\t\tbreak\n\t\t}\n\n\t\tval := v.Field(idx)\n\t\tif val.Kind() != reflect.Ptr {\n\t\t\tval = val.Addr()\n\t\t}\n\n\t\tvals = append(vals, val.Interface())\n\t}\n\treturn vals\n}", "func (i Information) Values() map[string]string {\n\treturn map[string]string{\n\t\t\"version\": i.Version,\n\t\t\"revision\": i.Revision,\n\t\t\"branch\": i.Branch,\n\t\t\"build_user\": i.BuildUser,\n\t\t\"build_date\": i.BuildDate,\n\t\t\"go_version\": i.GoVersion,\n\t}\n}", "func Values(mp any) (values []any) {\n\trv := reflect.Indirect(reflect.ValueOf(mp))\n\tif rv.Kind() != reflect.Map {\n\t\treturn\n\t}\n\n\tvalues = make([]any, 0, rv.Len())\n\tfor _, key := range rv.MapKeys() {\n\t\tvalues = append(values, rv.MapIndex(key).Interface())\n\t}\n\treturn\n}", "func (f *Filter) Values() Values {\n\treturn f.values\n}", "func (p Properties) Values() []interface{} {\n\tvalues := make([]interface{}, len(p))\n\tfor i, v := range p {\n\t\tvalues[i] = v.InterValue\n\t}\n\treturn values\n}", "func (page StorageInsightListResultPage) Values() []StorageInsight {\n\tif page.silr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.silr.Value\n}", "func (page StorageInsightListResultPage) Values() []StorageInsight {\n\tif page.silr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.silr.Value\n}", "func (l UpdateLabels) Values() []string {\n\treturn []string{l.Type, l.Result}\n}", "func (page DatabaseListResultPage) Values() []Database {\n if page.dlr.IsEmpty() {\n return nil\n }\n return *page.dlr.Value\n }", "func (s *GoObject) Value() interface{} {\n\treturn s.data\n}", "func getValues(l layer) []float64 {\n\tinputs := make([]float64, len(l))\n\tfor i := range l {\n\t\tinputs[i] = l[i].value\n\t}\n\treturn inputs\n}", "func (o RegistryTaskEncodedStepPtrOutput) Values() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *RegistryTaskEncodedStep) map[string]string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Values\n\t}).(pulumi.StringMapOutput)\n}", "func (page ProductResultValuePage) Values() []Product {\n\tif page.prv.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.prv.Value\n}", "func (b *Uniform) Values() []float64 {\n\treturn b.values\n}", "func (list *ArrayList) Values() []interface{} {\n\tnewE := make([]interface{}, list.size, list.size)\n\tcopy(newE, list.elements[:list.size])\n\treturn newE\n}", "func (e *Enum) Values() []interface{} {\n\treturn e.values\n}", "func (page DefinitionListResultPage) Values() []Definition {\n\tif page.dlr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.dlr.Value\n}", "func (this *record) Value() interface{} {\n\tswitch this._Type {\n\tcase sensors.OT_DATATYPE_UDEC_0:\n\t\tif value, err := this.UintValue(); err != nil {\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn value\n\t\t}\n\tcase sensors.OT_DATATYPE_UDEC_4, sensors.OT_DATATYPE_UDEC_8, sensors.OT_DATATYPE_UDEC_12, sensors.OT_DATATYPE_UDEC_16, sensors.OT_DATATYPE_UDEC_20, sensors.OT_DATATYPE_UDEC_24:\n\t\tif value, err := this.FloatValue(); err != nil {\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn value\n\t\t}\n\tcase sensors.OT_DATATYPE_STRING:\n\t\tif value, err := this.StringValue(); err != nil {\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn value\n\t\t}\n\tcase sensors.OT_DATATYPE_DEC_0:\n\t\tif value, err := this.IntValue(); err != nil {\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn value\n\t\t}\n\tcase sensors.OT_DATATYPE_DEC_8, sensors.OT_DATATYPE_DEC_16, sensors.OT_DATATYPE_DEC_24:\n\t\tif value, err := this.FloatValue(); err != nil {\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn value\n\t\t}\n\tdefault:\n\t\tif value, err := this.Data(); err != nil {\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn value\n\t\t}\n\t}\n}", "func (s *SequenceItemValue) GetValue() interface{} { return s.elements }", "func (a UserGroupAggregateRow) Values() m.UserData {\n\treturn a.values\n}", "func (rows *Rows) Values() ([]interface{}, error) {\n\tif rows.closed {\n\t\treturn nil, errors.New(\"rows is closed\")\n\t}\n\n\tvalues := make([]interface{}, 0, len(rows.fields))\n\n\tfor range rows.fields {\n\t\tvr, _ := rows.nextColumn()\n\n\t\tif vr.Len() == -1 {\n\t\t\tvalues = append(values, nil)\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch vr.Type().FormatCode {\n\t\t// All intrinsic types (except string) are encoded with binary\n\t\t// encoding so anything else should be treated as a string\n\t\tcase TextFormatCode:\n\t\t\tvalues = append(values, vr.ReadString(vr.Len()))\n\t\tcase BinaryFormatCode:\n\t\t\tswitch vr.Type().DataType {\n\t\t\tcase TextOid, VarcharOid:\n\t\t\t\tvalues = append(values, decodeText(vr))\n\t\t\tcase BoolOid:\n\t\t\t\tvalues = append(values, decodeBool(vr))\n\t\t\tcase ByteaOid:\n\t\t\t\tvalues = append(values, decodeBytea(vr))\n\t\t\tcase Int8Oid:\n\t\t\t\tvalues = append(values, decodeInt8(vr))\n\t\t\tcase Int2Oid:\n\t\t\t\tvalues = append(values, decodeInt2(vr))\n\t\t\tcase Int4Oid:\n\t\t\t\tvalues = append(values, decodeInt4(vr))\n\t\t\tcase OidOid:\n\t\t\t\tvalues = append(values, decodeOid(vr))\n\t\t\tcase Float4Oid:\n\t\t\t\tvalues = append(values, decodeFloat4(vr))\n\t\t\tcase Float8Oid:\n\t\t\t\tvalues = append(values, decodeFloat8(vr))\n\t\t\tcase BoolArrayOid:\n\t\t\t\tvalues = append(values, decodeBoolArray(vr))\n\t\t\tcase Int2ArrayOid:\n\t\t\t\tvalues = append(values, decodeInt2Array(vr))\n\t\t\tcase Int4ArrayOid:\n\t\t\t\tvalues = append(values, decodeInt4Array(vr))\n\t\t\tcase Int8ArrayOid:\n\t\t\t\tvalues = append(values, decodeInt8Array(vr))\n\t\t\tcase Float4ArrayOid:\n\t\t\t\tvalues = append(values, decodeFloat4Array(vr))\n\t\t\tcase Float8ArrayOid:\n\t\t\t\tvalues = append(values, decodeFloat8Array(vr))\n\t\t\tcase TextArrayOid, VarcharArrayOid:\n\t\t\t\tvalues = append(values, decodeTextArray(vr))\n\t\t\tcase TimestampArrayOid, TimestampTzArrayOid:\n\t\t\t\tvalues = append(values, decodeTimestampArray(vr))\n\t\t\tcase DateOid:\n\t\t\t\tvalues = append(values, decodeDate(vr))\n\t\t\tcase TimestampTzOid:\n\t\t\t\tvalues = append(values, decodeTimestampTz(vr))\n\t\t\tcase TimestampOid:\n\t\t\t\tvalues = append(values, decodeTimestamp(vr))\n\t\t\tcase InetOid, CidrOid:\n\t\t\t\tvalues = append(values, decodeInet(vr))\n\t\t\tcase JsonOid:\n\t\t\t\tvar d interface{}\n\t\t\t\tdecodeJSON(vr, &d)\n\t\t\t\tvalues = append(values, d)\n\t\t\tcase JsonbOid:\n\t\t\t\tvar d interface{}\n\t\t\t\tdecodeJSON(vr, &d)\n\t\t\t\tvalues = append(values, d)\n\t\t\tdefault:\n\t\t\t\trows.Fatal(errors.New(\"Values cannot handle binary format non-intrinsic types\"))\n\t\t\t}\n\t\tdefault:\n\t\t\trows.Fatal(errors.New(\"Unknown format code\"))\n\t\t}\n\n\t\tif vr.Err() != nil {\n\t\t\trows.Fatal(vr.Err())\n\t\t}\n\n\t\tif rows.Err() != nil {\n\t\t\treturn nil, rows.Err()\n\t\t}\n\t}\n\n\treturn values, rows.Err()\n}", "func (q *ColumnQueryAPI) Values(ctx context.Context, req *pb.ValuesRequest) (*pb.ValuesResponse, error) {\n\tvals, err := q.querier.Values(ctx, req.LabelName, req.Match, req.Start.AsTime(), req.End.AsTime())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &pb.ValuesResponse{\n\t\tLabelValues: vals,\n\t}, nil\n}", "func Values(i interface{}) ([]interface{}) {\n\tvar result []interface{}\n\tv := reflect.ValueOf(i)\n\n\tif v.Kind() != reflect.Map {\n\t\tfmt.Fprintf(os.Stderr, \"Input type is not a map type: %v\", v)\n\t\treturn nil\n\t}\n\n\tfor _,key := range (v.MapKeys()) {\n\t\tresult = append(result, v.MapIndex(key).Interface())\n\t}\n\n\treturn result\n}", "func FieldsAndValues(val interface{}) ([]string, []interface{}, bool) {\n\t// indirect so function works with both structs and pointers to them\n\tstructVal := r.Indirect(r.ValueOf(val))\n\tkind := structVal.Kind()\n\tif kind != r.Struct {\n\t\treturn nil, nil, false\n\t}\n\tsinfo := getStructInfo(structVal)\n\tfields := make([]string, len(sinfo.FieldsList))\n\tvalues := make([]interface{}, len(sinfo.FieldsList))\n\tfor i, info := range sinfo.FieldsList {\n\t\tfield := structVal.Field(info.Num)\n\t\tfields[i] = info.Key\n\t\tvalues[i] = field.Interface()\n\t}\n\treturn fields, values, true\n}", "func (page PeerAsnListResultPage) Values() []PeerAsn {\n\tif page.palr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.palr.Value\n}", "func (page ServiceProviderListResultPage) Values() []ServiceProvider {\n\tif page.splr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.splr.Value\n}", "func (page ConsortiumMemberCollectionPage) Values() []ConsortiumMember {\n\tif page.cmc.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.cmc.Value\n}", "func (value *Value) Value() interface{} {\n\treturn value.value\n}", "func (v Vector) Values() []float64 {\n\treturn v\n}", "func (d data) getPropertyValues(name string, index int, fieldname string) ([]string, error) {\n\tv := reflect.ValueOf(d.src).Elem().FieldByName(name)\n\tvar valueStruct reflect.Value\n\tswitch v.Kind() {\n\tcase reflect.Slice:\n\t\tif index < 0 || index >= v.Len() {\n\t\t\treturn nil, fmt.Errorf(\"%s[%d]: index out of range\", name, index)\n\t\t}\n\t\tvalueStruct = v.Index(index)\n\tcase reflect.Struct:\n\t\tvalueStruct = v\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown primary field type: %v\", v.Kind())\n\t}\n\n\ttoString := func(element reflect.Value) string {\n\t\tvar s string\n\t\tstringType := reflect.TypeOf(s)\n\t\t_, isStringer := element.Type().MethodByName(\"String\")\n\t\tif element.Kind() == reflect.Bool {\n\t\t\treturn strconv.FormatBool(element.Bool())\n\t\t} else if element.Kind() == reflect.Int {\n\t\t\treturn strconv.FormatInt(element.Int(), 10)\n\t\t} else if element.Kind() == reflect.Float64 {\n\t\t\treturn strconv.FormatFloat(element.Float(), 'g', -1, 64)\n\t\t} else if isStringer {\n\t\t\t// This panics, if the String method takes input arguments, or returns anything else than a single string.\n\t\t\tstringValues := element.MethodByName(\"String\").Call(nil)\n\t\t\treturn stringValues[0].String()\n\t\t}\n\t\tif element.Type().ConvertibleTo(stringType) {\n\t\t\ts = element.Convert(stringType).Interface().(string)\n\t\t\treturn s\n\t\t}\n\t\treturn \"<?>\"\n\t}\n\n\tvar values []string\n\tvar zero reflect.Value\n\tfield := valueStruct.FieldByName(fieldname)\n\tif field == zero {\n\t\treturn nil, fmt.Errorf(\"%s.%s: field does not exist\", name, fieldname)\n\t}\n\tif field.Kind() == reflect.Slice {\n\t\tvalues = make([]string, field.Len())\n\t\tfor i := range values {\n\t\t\tvalues[i] = toString(field.Index(i))\n\t\t}\n\t} else {\n\t\tvalues = []string{toString(field)}\n\t}\n\treturn values, nil\n}", "func (l RegistrationLabels) Values() []string {\n\treturn []string{l.Result, l.Type.String(), l.Src.String()}\n}", "func (page DataLakeAnalyticsAccountListResultPage) Values() []DataLakeAnalyticsAccountBasic {\n\tif page.dlaalr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.dlaalr.Value\n}", "func (page AccountsPage) Values() []Account {\n\tif page.a.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.a.Value\n}", "func (d *adapterMemoryData) Values() ([]interface{}, error) {\n\td.mu.RLock()\n\tvar (\n\t\tindex = 0\n\t\tvalues = make([]interface{}, len(d.data))\n\t)\n\tfor _, v := range d.data {\n\t\tif !v.IsExpired() {\n\t\t\tvalues[index] = v.v\n\t\t\tindex++\n\t\t}\n\t}\n\td.mu.RUnlock()\n\treturn values, nil\n}", "func (o RegistryTaskEncodedStepOutput) Values() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v RegistryTaskEncodedStep) map[string]string { return v.Values }).(pulumi.StringMapOutput)\n}", "func (p Point) Values() []float64 {\n\treturn p\n}", "func (p *VCardProperty) Values() []string {\n\tstrings := make([]string, 0, 1)\n\n\tp.appendValueStrings(p.Value, &strings, 0)\n\n\treturn strings\n}", "func (p *PKGBUILD) GetValues() map[string]string {\n\treturn p.info.GetValues()\n}", "func (m *MultiMap) Values() []interface{} {\n\tvalues := make([]interface{}, m.Size())\n\tcount := 0\n\tfor _, vs := range m.m {\n\t\tfor _, value := range vs {\n\t\t\tvalues[count] = value\n\t\t\tcount++\n\t\t}\n\t}\n\treturn values\n}", "func Valueize(values ...reflect.Value) []reflect.Value {\n\treturn values\n}", "func (o *InlineObject794) GetValues() AnyOfobject {\n\tif o == nil || o.Values == nil {\n\t\tvar ret AnyOfobject\n\t\treturn ret\n\t}\n\treturn *o.Values\n}", "func (ps *peerStore) Values(infoHash InfoHash) []net.UDPAddr {\n\tset := ps.Set(infoHash)\n\tif set == nil {\n\t\treturn nil\n\t}\n\n\treturn set.Next()\n}", "func (o ApiOperationRequestRepresentationFormParameterOutput) Values() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v ApiOperationRequestRepresentationFormParameter) []string { return v.Values }).(pulumi.StringArrayOutput)\n}", "func (_TellorMesosphere *TellorMesosphereSession) Values(arg0 *big.Int, arg1 *big.Int) (*big.Int, error) {\n\treturn _TellorMesosphere.Contract.Values(&_TellorMesosphere.CallOpts, arg0, arg1)\n}", "func (page RegisteredAsnListResultPage) Values() []RegisteredAsn {\n\tif page.ralr.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.ralr.Value\n}" ]
[ "0.749085", "0.7193369", "0.70431256", "0.6553561", "0.6546634", "0.6514496", "0.6409118", "0.6362563", "0.6319657", "0.6272307", "0.62592447", "0.6233262", "0.6200429", "0.61777216", "0.6162476", "0.615272", "0.61421496", "0.6132722", "0.6131156", "0.61253464", "0.6119984", "0.60929567", "0.6087474", "0.60855603", "0.6081215", "0.6078335", "0.6071396", "0.60385567", "0.6032541", "0.60316736", "0.60242385", "0.60202354", "0.6011651", "0.60097116", "0.6007157", "0.59963894", "0.59935945", "0.5984117", "0.598346", "0.5967576", "0.59656066", "0.59630847", "0.5960114", "0.59585196", "0.595637", "0.59449166", "0.59427243", "0.59359753", "0.5927966", "0.5915933", "0.59159154", "0.5910997", "0.5910469", "0.5910469", "0.59076756", "0.5907574", "0.58990115", "0.5897618", "0.58943653", "0.5879604", "0.58795106", "0.58795106", "0.58743197", "0.5871471", "0.58650976", "0.5858465", "0.5858264", "0.58575326", "0.5855975", "0.5848261", "0.58441794", "0.5841845", "0.5840151", "0.58385885", "0.5832451", "0.5824317", "0.5819769", "0.58187777", "0.58140534", "0.5811576", "0.58099544", "0.58018196", "0.58018136", "0.5801699", "0.5799609", "0.57958513", "0.5794724", "0.5786098", "0.57857764", "0.57852906", "0.5785126", "0.5780899", "0.57790625", "0.5777796", "0.577477", "0.5770592", "0.57698137", "0.5769177", "0.57688797", "0.576725" ]
0.7038614
3
Fields return fields of struct
func (s *Structx) Fields() []*Fieldx { tt := s.value.Type() fields := []*Fieldx{} for i := 0; i < tt.NumField(); i++ { field := tt.Field(i) f := &Fieldx{ data: field, value: s.value.FieldByName(field.Name), } fields = append(fields, f) } return fields }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (g *generator) structFields(t reflect.Type) []field {\n\tvar fields []field\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tf := t.Field(i)\n\t\tif g.ignoreField(t, f) {\n\t\t\tcontinue\n\t\t}\n\t\tname, _ := parseTag(g.fieldTagKey, f.Tag)\n\t\tif name == \"\" {\n\t\t\tname = f.Name\n\t\t}\n\t\tfields = append(fields, field{\n\t\t\tName: name,\n\t\t\tType: f.Type,\n\t\t\tZero: zeroValue(f.Type),\n\t\t})\n\t}\n\treturn fields\n}", "func (_struct *Struct) Fields() (Fields, error) {\n\tvar goFields Fields\n\tstructType := _struct.StructType()\n\tif structType == nil {\n\t\treturn nil, fmt.Errorf(\"no struct type in %#+v\", _struct)\n\t}\n\tfor idx, field := range structType.Fields.List {\n\t\ttyp, err := _struct.toType(field.Type)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to lookup type '%s': %w\", field.Type, err)\n\t\t}\n\t\tgoFields = append(goFields, &Field{\n\t\t\tField: *field,\n\t\t\tStruct: _struct,\n\t\t\tNames: field.Names,\n\t\t\tIndex: uint(idx),\n\t\t\tTypeValue: typ,\n\t\t})\n\t}\n\treturn goFields, nil\n}", "func StructFields(t reflect.Type) interface{} {\n\treturn structInfoForType(t).fields\n}", "func (s *Struct) Fields() map[string]string {\n\tff := map[string]string{}\n\n\tfor _, f := range s.RawFields() {\n\t\tff[f.Field.Name] = f.Typ.String()\n\t}\n\n\treturn ff\n}", "func StructFields(v interface{}) (vType reflect.Type, vFields []*TField) {\n\tvar (\n\t\tfield reflect.StructField\n\t)\n\tvType = reflect.Indirect(reflect.ValueOf(v)).Type()\n\tnumFields := vType.NumField()\n\tvFields = make([]*TField, 0, numFields)\n\tfor i := 0; i < numFields; i++ {\n\t\tfield = vType.Field(i)\n\t\tfieldInfo := &TField{\n\t\t\tFname: field.Name,\n\t\t\tFtype: field.Type.String(),\n\t\t\tFkind: field.Type.Kind(),\n\t\t\tFtags: field.Tag,\n\t\t}\n\t\tif field.PkgPath == \"\" {\n\t\t\tfieldInfo.Fexported = true\n\t\t}\n\t\tvFields = append(vFields, fieldInfo)\n\t}\n\treturn\n}", "func fields(spec *ast.TypeSpec) []*ast.Field {\n\ts := make([]*ast.Field, 0)\n\tif structType, ok := spec.Type.(*ast.StructType); ok {\n\t\tfor _, field := range structType.Fields.List {\n\t\t\tif keyname(field) != \"\" {\n\t\t\t\ts = append(s, field)\n\t\t\t}\n\t\t}\n\t}\n\treturn s\n}", "func (ds *DynamicStruct) Fields() []reflect.StructField {\n\treturn ds.fields\n}", "func StructFields() {\n\tv := vertex{1, 2}\n\tv.X = 11\n\n\tfmt.Println(v.X, v.Y)\n}", "func (s *Struct) structFields() []reflect.StructField {\n\tt := s.value.Type()\n\n\tvar f []reflect.StructField\n\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfield := t.Field(i)\n\t\t// we can't access the value of unexported fields\n\t\tif field.PkgPath != \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\t// don't check if it's omitted\n\t\tif tag := field.Tag.Get(s.TagName); tag == \"-\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tf = append(f, field)\n\t}\n\n\treturn f\n}", "func (e *Extractor) fields(s reflect.Value) []field {\n\tfields := make([]field, 0, s.NumField())\n\n\tfor i := 0; i < s.NumField(); i++ {\n\t\tif isIgnored(s.Type().Field(i).Name, e.ignoredFields) {\n\t\t\tcontinue\n\t\t}\n\n\t\tif s.Type().Field(i).Anonymous {\n\t\t\tif e.useEmbeddedStructs {\n\t\t\t\tfields = append(fields, e.fields(s.Field(i))...)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\ttag := s.Type().Field(i).Tag\n\t\tname := s.Type().Field(i).Name\n\t\tvalue := s.Field(i)\n\t\tfields = append(fields, field{value, name, tag})\n\t}\n\n\treturn fields\n}", "func (s *scanner) structFields(structType reflect.Type) ([]*r.Field, error) {\n\tfmPtr := reflect.New(structType).Interface()\n\tm, err := r.StructFieldMap(fmPtr, true)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not decode struct of type %T: %v\", fmPtr, err)\n\t}\n\n\tstructFields := make([]*r.Field, len(s.stmt.fieldNames))\n\tfor i, fieldName := range s.stmt.fieldNames {\n\t\tfield, ok := m[strings.ToLower(fieldName)]\n\t\tif !ok { // the field doesn't have a destination\n\t\t\tstructFields[i] = nil\n\t\t} else {\n\t\t\tstructFields[i] = &field\n\t\t}\n\t}\n\treturn structFields, nil\n}", "func (e TypeReflectCacheEntry) Fields() map[string]*FieldCacheEntry {\n\treturn e.structFields\n}", "func (f Fields) Fields() map[string]interface{} {\n\treturn f\n}", "func printStructField(t *reflect.Type) {\n fieldNum := (*t).NumField()\n for i := 0; i < fieldNum; i++ {\n fmt.Printf(\"conf's field: %s\\n\", (*t).Field(i).Name)\n }\n fmt.Println(\"\")\n}", "func (sh *Hook) Fields() map[string]interface{} {\n\treturn sh.fields\n}", "func StructFields(t reflect.Type) string {\n\tfields := make([]string, 0)\n\tif t.Kind() == reflect.Struct {\n\t\tfor i := 0; i < t.NumField(); i ++ {\n\t\t\tname := t.Field(i).Name\n\t\t\tif t.Field(i).Type.Kind() == reflect.Struct {\n\t\t\t\ts := StructFields(t.Field(i).Type)\n\t\t\t\tf := strings.Split(s, \", \")\n\t\t\t\tleft := FirstLower(name)\n\t\t\t\tfor _, v := range f {\n\t\t\t\t\tfields = append(fields, fmt.Sprintf(\"%s.%s\", left, FirstLower(v)))\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfields = append(fields, FirstLower(name))\n\t\t}\n\t}\n\n\treturn strings.Join(fields, \", \")\n}", "func (entry *Entry) Fields() Fields {\n\treturn entry.fields\n}", "func (self *mergeState) getFields() []string {\n\tfields := make([]string, len(self.fields))\n\tfor f, i := range self.fields {\n\t\tfields[i] = f\n\t}\n\treturn fields\n}", "func (s *Syncthing) Fields() log.Fields {\n\treturn debug.StructFields(s)\n}", "func GetFields(reader *os.File) []Field {\n\tvar curbuf []byte\n\tdbfhead := GetDbfHead(reader)\n\n\toff := dbfhead.Headerlen - 32 - 264\n\tif off < 1 {\n\t\tpanic(\"invalid header\")\n\t}\n\tfieldlist := make([]Field, off/32)\n\tbuf := make([]byte, off)\n\t_, err := reader.ReadAt(buf, 32)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfor i, val := range fieldlist {\n\t\ta := i * 32\n\t\tcurbuf = buf[a:]\n\t\tval.Name = copyUpToNull(curbuf[0:11])\n\t\tval.Fieldtype = fmt.Sprintf(\"%s\", curbuf[11:12])\n\t\tval.FieldDataaddress = curbuf[12:16]\n\t\tval.FieldLen = Changebytetoint(curbuf[16:17])\n\t\tval.DecimalCount = curbuf[17:18]\n\t\tval.Workareaid = curbuf[20:21]\n\t\tfieldlist[i] = val\n\t}\n\treturn fieldlist\n}", "func (s *Spec) Fields() log.Fields {\n\treturn s.Details.Fields()\n}", "func (game *Game) Fields() Fields {\n\treturn game.currentFields\n}", "func getFields(s interface{}) []interface{} {\n\tv := reflect.ValueOf(s)\n\tv = dereference(v)\n\tfields := []interface{}{}\n\tfor i := 0; i < v.NumField(); i++ {\n\t\tfield := v.Field(i)\n\t\tif field.CanInterface() {\n\t\t\tfields = append(fields, field.Interface())\n\t\t}\n\t}\n\treturn fields\n}", "func (u User) Fields() map[string]interface{} {\n\tfields := map[string]interface{}{\n\t\t\"hash\": u.Hash,\n\t\t\"email\": u.Email,\n\t\t\"private_id\": u.PrivateID,\n\t\t\"public_id\": u.PublicID,\n\t}\n\n\tif u.Profile != nil {\n\t\tfields[\"profile\"] = u.Profile.Fields()\n\t}\n\n\treturn fields\n}", "func (pce *ppdCacheEntry) getFields() (cdd.PrinterDescriptionSection, string, string, lib.DuplexVendorMap) {\n\tpce.mutex.Lock()\n\tdefer pce.mutex.Unlock()\n\treturn pce.description, pce.manufacturer, pce.model, pce.duplexMap\n}", "func (r *Route) Fields() RouteInfo {\n\tr.mu.RLock()\n\tdefer r.mu.RUnlock()\n\treturn r.fieldsLocked()\n}", "func (i PullAll) Fields() []interface{} {\n\treturn nil\n}", "func (d Document) Fields() []string {\n\treturn d.data.fields\n}", "func (Card) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.Int64(\"id\"),\n\t\tfield.String(\"name\"),\n\t\tfield.String(\"card_no\"),\n\t\tfield.String(\"ccv\"),\n\t\tfield.String(\"expires\"),\n\t\tfield.Time(\"created_at\").\n\t\t\tDefault(time.Now).SchemaType(map[string]string{\n\t\t\tdialect.MySQL: \"datetime\",\n\t\t}),\n\t\tfield.Time(\"updated_at\").\n\t\t\tDefault(time.Now).SchemaType(map[string]string{\n\t\t\tdialect.MySQL: \"datetime\",\n\t\t}),\n\t}\n}", "func (n *Node) Fields() []uintptr {\n\t// we store the offsets for the fields in type properties\n\ttprops := kit.Types.Properties(n.Type(), true) // true = makeNew\n\tpnm := \"__FieldOffs\"\n\tif foff, ok := tprops[pnm]; ok {\n\t\treturn foff.([]uintptr)\n\t}\n\tfoff := make([]uintptr, 0)\n\tkitype := KiType()\n\tFlatFieldsValueFunc(n.This, func(stru interface{}, typ reflect.Type, field reflect.StructField, fieldVal reflect.Value) bool {\n\t\tif fieldVal.Kind() == reflect.Struct && kit.EmbeddedTypeImplements(field.Type, kitype) {\n\t\t\tfoff = append(foff, field.Offset)\n\t\t}\n\t\treturn true\n\t})\n\ttprops[pnm] = foff\n\treturn foff\n}", "func (Recordfood) Fields() []ent.Field {\n\treturn nil\n}", "func (fm *FinalModelStructBytes) GetFields(fbeValue *StructBytes) (int, error) {\n var err error = nil\n fbeCurrentOffset := 0\n fbeCurrentSize := 0\n fbeFieldSize := 0\n\n fm.F1.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F1, fbeFieldSize, err = fm.F1.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F2.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F2, fbeFieldSize, err = fm.F2.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F3.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F3, fbeFieldSize, err = fm.F3.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n return fbeCurrentSize, err\n}", "func (o *NotificationAllOf) GetFields() map[string]interface{} {\n\tif o == nil || o.Fields == nil {\n\t\tvar ret map[string]interface{}\n\t\treturn ret\n\t}\n\treturn *o.Fields\n}", "func (sc *Scanner) Fields() []string {\n\treturn sc.fields\n}", "func GetFields(m interface{}) (ns []string) {\n\ttyp := GetType(m)\n\t// Only structs are supported so return an empty result if the passed object\n\t// isn't a struct\n\tif typ.Kind() != reflect.Struct {\n\t\tfmt.Printf(\"%v type can't have attributes inspected\\n\", typ.Kind())\n\t\treturn\n\t}\n\t// loop through the struct's fields\n\tfor i := 0; i < typ.NumField(); i++ {\n\t\tf := typ.Field(i)\n\t\tif f.Anonymous {\n\t\t\tfkind := f.Type.Kind()\n\t\t\tif fkind == reflect.Struct || fkind == reflect.Ptr {\n\t\t\t\tfns := GetFields(reflect.New(f.Type).Interface())\n\t\t\t\tfor _, fn := range fns {\n\t\t\t\t\tif String(fn).IsInArray(ns) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tns = append(ns, fn)\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif String(f.Name).IsInArray(ns) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tns = append(ns, f.Name)\n\t\t}\n\t}\n\treturn ns\n}", "func (m *ccMetric) Fields() map[string]interface{} {\n\treturn m.fields\n}", "func (svc record) readableFields(m *types.Module) []string {\n\tff := make([]string, 0)\n\n\t_ = m.Fields.Walk(func(f *types.ModuleField) error {\n\t\tif svc.ac.CanReadRecordValue(svc.ctx, f) {\n\t\t\tff = append(ff, f.Name)\n\t\t}\n\n\t\treturn nil\n\t})\n\n\treturn ff\n}", "func (fm *FinalModelStructOptional) GetFields(fbeValue *StructOptional) (int, error) {\n var err error = nil\n fbeCurrentOffset := 0\n fbeCurrentSize := 0\n fbeFieldSize := 0\n\n fm.FinalModelStructSimple.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.FinalModelStructSimple.GetFields(fbeValue.StructSimple); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F100.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F100, fbeFieldSize, err = fm.F100.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F101.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F101, fbeFieldSize, err = fm.F101.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F102.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F102, fbeFieldSize, err = fm.F102.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F103.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F103, fbeFieldSize, err = fm.F103.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F104.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F104, fbeFieldSize, err = fm.F104.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F105.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F105, fbeFieldSize, err = fm.F105.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F106.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F106, fbeFieldSize, err = fm.F106.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F107.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F107, fbeFieldSize, err = fm.F107.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F108.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F108, fbeFieldSize, err = fm.F108.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F109.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F109, fbeFieldSize, err = fm.F109.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F110.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F110, fbeFieldSize, err = fm.F110.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F111.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F111, fbeFieldSize, err = fm.F111.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F112.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F112, fbeFieldSize, err = fm.F112.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F113.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F113, fbeFieldSize, err = fm.F113.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F114.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F114, fbeFieldSize, err = fm.F114.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F115.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F115, fbeFieldSize, err = fm.F115.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F116.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F116, fbeFieldSize, err = fm.F116.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F117.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F117, fbeFieldSize, err = fm.F117.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F118.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F118, fbeFieldSize, err = fm.F118.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F119.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F119, fbeFieldSize, err = fm.F119.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F120.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F120, fbeFieldSize, err = fm.F120.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F121.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F121, fbeFieldSize, err = fm.F121.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F122.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F122, fbeFieldSize, err = fm.F122.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F123.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F123, fbeFieldSize, err = fm.F123.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F124.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F124, fbeFieldSize, err = fm.F124.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F125.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F125, fbeFieldSize, err = fm.F125.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F126.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F126, fbeFieldSize, err = fm.F126.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F127.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F127, fbeFieldSize, err = fm.F127.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F128.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F128, fbeFieldSize, err = fm.F128.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F129.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F129, fbeFieldSize, err = fm.F129.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F130.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F130, fbeFieldSize, err = fm.F130.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F131.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F131, fbeFieldSize, err = fm.F131.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F132.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F132, fbeFieldSize, err = fm.F132.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F133.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F133, fbeFieldSize, err = fm.F133.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F134.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F134, fbeFieldSize, err = fm.F134.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F135.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F135, fbeFieldSize, err = fm.F135.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F136.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F136, fbeFieldSize, err = fm.F136.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F137.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F137, fbeFieldSize, err = fm.F137.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F138.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F138, fbeFieldSize, err = fm.F138.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F139.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F139, fbeFieldSize, err = fm.F139.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F140.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F140, fbeFieldSize, err = fm.F140.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F141.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F141, fbeFieldSize, err = fm.F141.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F142.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F142, fbeFieldSize, err = fm.F142.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F143.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F143, fbeFieldSize, err = fm.F143.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F144.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F144, fbeFieldSize, err = fm.F144.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F145.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F145, fbeFieldSize, err = fm.F145.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F146.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F146, fbeFieldSize, err = fm.F146.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F147.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F147, fbeFieldSize, err = fm.F147.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F148.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F148, fbeFieldSize, err = fm.F148.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F149.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F149, fbeFieldSize, err = fm.F149.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F150.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F150, fbeFieldSize, err = fm.F150.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F151.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F151, fbeFieldSize, err = fm.F151.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F152.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F152, fbeFieldSize, err = fm.F152.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F153.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F153, fbeFieldSize, err = fm.F153.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F154.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F154, fbeFieldSize, err = fm.F154.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F155.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F155, fbeFieldSize, err = fm.F155.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F156.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F156, fbeFieldSize, err = fm.F156.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F157.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F157, fbeFieldSize, err = fm.F157.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F158.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F158, fbeFieldSize, err = fm.F158.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F159.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F159, fbeFieldSize, err = fm.F159.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F160.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F160, fbeFieldSize, err = fm.F160.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F161.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F161, fbeFieldSize, err = fm.F161.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F162.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F162, fbeFieldSize, err = fm.F162.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F163.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F163, fbeFieldSize, err = fm.F163.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F164.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F164, fbeFieldSize, err = fm.F164.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F165.SetFBEOffset(fbeCurrentOffset)\n if fbeValue.F165, fbeFieldSize, err = fm.F165.Get(); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n return fbeCurrentSize, err\n}", "func (m *ShowMeasurementsMapper) Fields() []string { return []string{\"name\"} }", "func (BaseMixin) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.UUID(\"id\", uuid.UUID{}).Default(uuid.New),\n\t\tfield.String(\"some_field\"),\n\t}\n}", "func (t *Type) FieldSlice() []*Field", "func (c Class) Fields() map[string]string {\n\tfields := make(map[string]string)\n\t//Interface\n\tfields[\"{{Interface.FileName}}\"] = c.InheritedInterface.FileName\n\tfields[\"{{Interface.Name}}\"] = c.InheritedInterface.Name\n\n\t//Class\n\tfields[\"{{Class.Name}}\"] = c.Name\n\n\t// Header\n\tfields[\"{{Class.Header.FileName}}\"] = c.HeaderFileName\n\tfields[\"{{Class.Header.DefineName}}\"] = c.DefineName\n\tfields[\"{{Class.Header.Includes}}\"] = c.HeaderIncludesString\n\tfields[\"{{Class.Header.ForwardDeclares}}\"] = c.ForwardDeclares\n\tfields[\"{{Class.Header.FunctionDeclarations}}\"] = c.FunctionDeclarations\n\tfields[\"{{Class.Header.QtSignalDeclarations}}\"] = c.QtSignalDeclarations\n\n\t//Implementation\n\tfields[\"{{Class.Implementation.FileName}}\"] = c.ImplementationFileName\n\tfields[\"{{Class.Implementation.Includes}}\"] = c.ImplementationIncludesString\n\tfields[\"{{Class.Implementation.FunctionDefinitions}}\"] = c.FunctionDefinitions\n\tfields[\"{{Class.Implementation.QtSignalDefinitions}}\"] = c.QtSignalDefinitions\n\treturn fields\n}", "func (Sample) Fields() []ent.Field {\n\treturn nil\n}", "func (PatientInfo) Fields() []ent.Field {\r\n\treturn []ent.Field{\r\n\t\tfield.String(\"cardNumber\").NotEmpty().Unique(),\r\n\t\tfield.String(\"name\").NotEmpty(),\r\n\t\tfield.String(\"gender\").NotEmpty(),\r\n\t\tfield.Int(\"age\").Positive(),\r\n\t}\r\n}", "func (tfs TwoFactorSession) Fields() (map[string]interface{}, error) {\n\treturn mapper.MapFrom(\"json\", &tfs)\n}", "func (e FailError) Fields() vals.StructMap { return failFields{e} }", "func (Borrow) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.Time(\"date\").Default(time.Now).Immutable(),\n\t}\n}", "func (Medicalfile) Fields() []ent.Field {\n return []ent.Field{\n\t\tfield.String(\"detail\").NotEmpty(),\n\t\tfield.Time(\"added_time\"),\n }\n}", "func (Patientrecord) Fields() []ent.Field {\n\treturn []ent.Field{\n\n field.String(\"Name\"),\n\n }\n}", "func (Car) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.String(\"model\"),\n\t\tfield.Time(\"registered_at\"),\n\t}\n}", "func GetStructFieldsData(i interface{}) ([]FieldData, error) {\n\tt := reflect.TypeOf(i)\n\tv := reflect.ValueOf(i)\n\tif t.Kind() == reflect.Ptr {\n\t\tt = t.Elem()\n\t\tv = v.Elem()\n\t}\n\n\tif t.Kind() != reflect.Struct {\n\t\treturn nil, errors.New(\"argument is not a struct\")\n\t}\n\n\tvar ret []FieldData\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfieldData := FieldData{}\n\t\tfieldData.Name = t.Field(i).Name\n\t\tfieldData.Type = t.Field(i).Type\n\t\tfieldData.Tags = t.Field(i).Tag\n\t\tfieldData.Exported = t.Field(i).PkgPath == \"\"\n\t\tfieldData.Anonymous = t.Field(i).Anonymous\n\n\t\tif fieldData.Exported {\n\t\t\tfieldData.Value = v.Field(i).Interface()\n\t\t} else {\n\t\t\tfieldData.Value = nil\n\t\t}\n\n\t\tret = append(ret, fieldData)\n\t}\n\n\treturn ret, nil\n}", "func (User) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.String(\"email\"),\n\t\tfield.String(\"password\"),\n\t\tfield.String(\"name\"),\n\t\tfield.String(\"age\"),\n\t\tfield.Time(\"birthday\"),\n\t\tfield.String(\"tel\"),\n\t}\n}", "func (o *PublicViewInfo) GetFields() []PublicField {\n\tif o == nil {\n\t\tvar ret []PublicField\n\t\treturn ret\n\t}\n\n\treturn o.Fields\n}", "func (e Account) EntFields() ent.Fields { return ent_Account_fields }", "func (e Account) EntFields() ent.Fields { return ent_Account_fields }", "func (fs *FollowService) Fields() ([]string, error) {\n\tf, err := fs.client.getFields(fs.end)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"cannot get Follow fields\")\n\t}\n\n\treturn f, nil\n}", "func (m *Message) Fields() map[string]interface{} {\n\treturn map[string]interface{}{\n\t\t\"groupId\": m.GroupID,\n\t\t\"memberId\": m.MemberID,\n\t\t\"trial\": m.Trial,\n\t}\n}", "func (Status) Fields() []ent.Field {\n\treturn nil\n}", "func (fm *FieldModelOrder) GetFields(fbeValue *Order, fbeStructSize int) {\n fbeCurrentSize := 4 + 4\n\n if (fbeCurrentSize + fm.Id.FBESize()) <= fbeStructSize {\n fbeValue.Id, _ = fm.Id.Get()\n } else {\n fbeValue.Id = 0\n }\n fbeCurrentSize += fm.Id.FBESize()\n\n if (fbeCurrentSize + fm.Symbol.FBESize()) <= fbeStructSize {\n fbeValue.Symbol, _ = fm.Symbol.Get()\n } else {\n fbeValue.Symbol = \"\"\n }\n fbeCurrentSize += fm.Symbol.FBESize()\n\n if (fbeCurrentSize + fm.Side.FBESize()) <= fbeStructSize {\n _ = fm.Side.GetValue(&fbeValue.Side)\n } else {\n fbeValue.Side = *NewOrderSide()\n }\n fbeCurrentSize += fm.Side.FBESize()\n\n if (fbeCurrentSize + fm.Type.FBESize()) <= fbeStructSize {\n _ = fm.Type.GetValue(&fbeValue.Type)\n } else {\n fbeValue.Type = *NewOrderType()\n }\n fbeCurrentSize += fm.Type.FBESize()\n\n if (fbeCurrentSize + fm.Price.FBESize()) <= fbeStructSize {\n fbeValue.Price, _ = fm.Price.GetDefault(float64(0.0))\n } else {\n fbeValue.Price = float64(0.0)\n }\n fbeCurrentSize += fm.Price.FBESize()\n\n if (fbeCurrentSize + fm.Volume.FBESize()) <= fbeStructSize {\n fbeValue.Volume, _ = fm.Volume.GetDefault(float64(0.0))\n } else {\n fbeValue.Volume = float64(0.0)\n }\n fbeCurrentSize += fm.Volume.FBESize()\n}", "func (msg *Message) Fields() []*Field {\n\treturn msg.fields\n}", "func (msg *Message) Fields() []*Field {\n\n\treturn msg.fields\n}", "func (n Node) AllFields() []interface{} {\n\tlabels := make([]interface{}, len(n.Labels))\n\tfor i, label := range n.Labels {\n\t\tlabels[i] = label\n\t}\n\treturn []interface{}{n.NodeIdentity, labels, n.Properties}\n}", "func (b Build) Fields() map[string]interface{} {\n\treturn map[string]interface{}{\n\t\t\"app\": b.App,\n\t\t\"build_date\": b.Date,\n\t\t\"commit\": b.Commit,\n\t}\n}", "func (Short) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.String(\"key\").NotEmpty().Unique().Immutable(),\n\t\tfield.UUID(\"value\", uuid.UUID{}).Immutable(),\n\t}\n}", "func (Token) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.UUID(\"id\", uuid.UUID{}).\n\t\t\tImmutable(),\n\t\tfield.String(\"name\").\n\t\t\tMinLen(1).\n\t\t\tMaxLen(64).\n\t\t\tNotEmpty(),\n\t\tfield.String(\"secret\").\n\t\t\tNotEmpty().\n\t\t\tMinLen(40).\n\t\t\tMaxLen(80).\n\t\t\tSensitive(),\n\t\tfield.Enum(\"permissions\").\n\t\t\tImmutable().\n\t\t\tValues(\"Read\", \"Write\", \"ReadWrite\").\n\t\t\tDefault(\"ReadWrite\"),\n\t\tfield.Time(\"created_at\").\n\t\t\tImmutable().\n\t\t\tDefault(time.Now),\n\t\tfield.Time(\"last_used\").\n\t\t\tOptional(),\n\t}\n}", "func (i Interface) Fields() map[string]string {\n\tfields := make(map[string]string)\n\tfields[\"{{Interface.Name}}\"] = i.Name\n\tfields[\"{{FileName}}\"] = i.FileName\n\tfields[\"{{Interface.DefineName}}\"] = i.DefineName\n\treturn fields\n}", "func (Complaint) Fields() []ent.Field {\n\treturn nil\n}", "func (Meta) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.Time(\"created_at\").\n\t\t\tDefault(time.Now),\n\t\tfield.Time(\"updated_at\").\n\t\t\tDefault(time.Now),\n\t\tfield.String(\"key\"),\n\t\tfield.String(\"value\").MaxLen(4095),\n\t}\n}", "func (cs *CoverService) Fields() ([]string, error) {\n\tf, err := cs.client.getFields(cs.end)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"cannot get Cover fields\")\n\t}\n\n\treturn f, nil\n}", "func (Player) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.String(\"name\").MinLen(1).MaxLen(16),\n\t\tfield.Enum(\"color\").Values(\"blue\", \"orange\", \"red\", \"white\"),\n\t}\n}", "func Fields() error {\n\treturn devtools.GenerateFieldsYAML()\n}", "func (Like) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.String(\"user_id\"),\n\t}\n}", "func (l *Logger) Fields() Fields {\n\treturn l.fields\n}", "func (Book) Fields() []ent.Field {\n\treturn []ent.Field{\t\t \n\t\tfield.Time(\"RESERVATIONS\"), \n\t}\n}", "func dumpfields(bv bitvector) {\n\tdumpbv(&bv, 0)\n\tdumpint(fieldKindEol)\n}", "func (Session) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.UUID(\"id\", uuid.UUID{}),\n\t\tfield.Bool(\"new_user\"),\n\t\tfield.Bool(\"is_unique\"),\n\t\tfield.Bool(\"is_bounce\"),\n\t\tfield.Bool(\"is_finished\"),\n\t\tfield.Int(\"duration\").Optional(),\n\t\tfield.Time(\"started_at\"),\n\t\tfield.Time(\"finished_at\").Nillable().Optional(),\n\t}\n}", "func (UnitOfMedicine) Fields() []ent.Field {\r\n\treturn []ent.Field{\r\n\t\tfield.String(\"name\"),\r\n\t}\r\n}", "func (cs *CharacterMugshotService) Fields() ([]string, error) {\n\tf, err := cs.client.getFields(cs.end)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"cannot get CharacterMugshot fields\")\n\t}\n\n\treturn f, nil\n}", "func (Group) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.UUID(\"id\", uuid.UUID{}).Default(uuid.New),\n\t\tfield.String(\"name\").NotEmpty(),\n\t\tfield.String(\"description\").NotEmpty().Optional(),\n\t\tfield.JSON(\"metadata\", map[string]interface{}{}).Optional(),\n\t\tfield.Time(\"created_at\").Immutable().Default(time.Now),\n\t\tfield.Time(\"updated_at\").Default(time.Now).UpdateDefault(time.Now),\n\t}\n}", "func (DrugAllergy) Fields() []ent.Field {\n return []ent.Field{\n \n }\n }", "func (Metric) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.Time(\"ts\"),\n\t\tfield.Float(\"value\"),\n\n\t\tfield.Uint(\"endpointId\"),\n\t\tfield.Uint(\"typeId\"),\n\t\tfield.Uint(\"nameId\"),\n\t\tfield.Uint(\"labelId\"),\n\n\t\tfield.Uint(\"clusterId\"),\n\t\tfield.Uint(\"nodeId\"),\n\t\tfield.Uint(\"procesId\"),\n\t\tfield.Uint(\"containerId\"),\n\t}\n}", "func (tc TraceContext) Fields() []string {\n\treturn []string{traceparentHeader, tracestateHeader}\n}", "func (Blob) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.Text(\"network_id\"),\n\t\tfield.Text(\"type\"),\n\t\tfield.Text(\"key\"),\n\t\tfield.Bytes(\"value\").\n\t\t\tOptional(),\n\t\tfield.Uint64(\"version\").\n\t\t\tDefault(0),\n\t}\n}", "func IterFields(t *Type) (*Field, Iter)", "func (s Struct) Value() []StructField {\n\treturn s.fields\n}", "func (Pet) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.UUID(\"id\", uuid.Nil).\n\t\t\tDefault(uuid.New),\n\t\tfield.UUID(\"best_friend_id\", uuid.Nil).\n\t\t\tAnnotations(\n\t\t\t\tentsql.Default(uuid.Nil.String()),\n\t\t\t),\n\t\tfield.Int(\"owner_id\").\n\t\t\tDefault(0),\n\t}\n}", "func (Builder) Fields() []ent.Field {\n\treturn nil\n}", "func (Bookreturn) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.Time(\"RETURN_TIME\"),\n\t\tfield.Int(\"DAMAGED_POINT\").Range(-1, 10),\n\t\t\n\t\tfield.String(\"DAMAGED_POINTNAME\").Validate(func(s string) error {\n\t\t\tmatch, _ := regexp.MatchString(\"^[a-zA-Z, ]+$\", s)\n\t\t\tif !match {\n\t\t\t\treturn errors.New(\"จุดที่เสียหายเป็นภาษาอังกฤษเท่านั้น เช่น TopFront,BottomBack\")\n\t\t\t}\n\t\t\treturn nil\n\t\t}),\n\t\tfield.String(\"LOST\").Validate(func(s string) error {\n\t\t\tmatch, _ := regexp.MatchString(\"^[a-zA-Z]+$\", s)\n\t\t\tif !match {\n\t\t\t\treturn errors.New(\"ถ้าหายให้พิมพ์ lost ถ้าไม่พิมพ์ no\")\n\t\t\t}\n\t\t\treturn nil\n\t\t}).MaxLen(5),\n\t}\n}", "func (m *RawMapper) Fields() []string { return append(m.selectFields, m.selectTags...) }", "func (f *Field) Fields() []*Field {\n\treturn getFields(f.value, f.defaultTag)\n}", "func (Dentist) Fields() []ent.Field {\n return []ent.Field{\n\tfield.String(\"name\").NotEmpty(),\n\tfield.Int(\"age\").Positive(),\n\tfield.String(\"cardid\").NotEmpty(),\n\tfield.Time(\"birthday\"),\n\tfield.String(\"experience\").NotEmpty(),\n\tfield.String(\"tel\").NotEmpty(),\n\tfield.String(\"email\").NotEmpty(),\n\tfield.String(\"password\").NotEmpty(),\n\n }\n}", "func (o *NotificationAllOf) GetFieldsOk() (*map[string]interface{}, bool) {\n\tif o == nil || o.Fields == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Fields, true\n}", "func (u ConfluenceServerUserV1) GetFields() logrus.Fields {\n\treturn logrus.Fields{\n\t\t\"Host\": u.Host,\n\t\t\"Port\": u.Port,\n\t\t\"Description\": u.Description,\n\t\t\"Auth\": u.Auth.GetFields(),\n\t}\n}", "func (m *message) Fields() (fs []*MessageField) {\n\tm.mu.RLock()\n\tfs = m.fields\n\tm.mu.RUnlock()\n\treturn\n}", "func (Checkout) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.Time(\"checkout_date\"),\n\t}\n}", "func (LevelOfDangerous) Fields() []ent.Field {\r\n\treturn []ent.Field{\r\n\t\tfield.String(\"name\"),\r\n\t}\r\n}", "func (OSContext) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.String(\"name\"),\n\t\tfield.String(\"family\"),\n\t\tfield.String(\"platform\").Optional(),\n\t\tfield.String(\"version\"),\n\t}\n}", "func (User) Fields() []ent.Field {\n\t// 添加实体字段\n\treturn []ent.Field{\n\t\tfield.Int(\"age\").Positive(),\n\t\tfield.String(\"name\").NotEmpty(),\n\t\tfield.Bool(\"sex\").Optional(),\n\t\tfield.String(\"address\"),\n\t}\n}", "func (Physician) Fields() []ent.Field {\n return []ent.Field{\n field.String(\"Physicianname\"),\n field.String(\"Physicianemail\"). \n Unique(), \n field.String(\"Password\"), \n } \n}", "func (u UpdateUser) Fields() map[string]interface{} {\n\treturn map[string]interface{}{\n\t\t\"email\": u.Email,\n\t\t\"public_id\": u.PublicID,\n\t}\n}" ]
[ "0.75068235", "0.7504617", "0.7480527", "0.7158599", "0.71165246", "0.70371705", "0.70371604", "0.70308304", "0.6974181", "0.6914422", "0.6902291", "0.6891259", "0.68756706", "0.68355393", "0.6823067", "0.6750258", "0.67315525", "0.67079526", "0.67078584", "0.66911334", "0.6661075", "0.6657865", "0.6647803", "0.66258925", "0.661139", "0.6594657", "0.6592684", "0.6521726", "0.6506695", "0.64922905", "0.6487828", "0.6478109", "0.6477042", "0.6470792", "0.6460926", "0.64247286", "0.6413925", "0.64045167", "0.63989", "0.63944054", "0.6387932", "0.63753754", "0.63510066", "0.63500684", "0.63466716", "0.63461006", "0.6341394", "0.6333909", "0.63293386", "0.63140386", "0.63055897", "0.6305512", "0.63046455", "0.629242", "0.629242", "0.6285764", "0.62691915", "0.62661403", "0.62501496", "0.62370217", "0.62333685", "0.62271", "0.6226976", "0.62268865", "0.62204075", "0.62088686", "0.6206521", "0.61982185", "0.61833405", "0.61826855", "0.6178651", "0.6173471", "0.6169355", "0.61672485", "0.6166943", "0.61667055", "0.61636084", "0.61561084", "0.6154422", "0.6150378", "0.6144748", "0.6144114", "0.61426854", "0.61307037", "0.61270237", "0.6126125", "0.61255354", "0.61251694", "0.61225075", "0.6119657", "0.61170894", "0.61069816", "0.6103636", "0.60912794", "0.6079048", "0.6077752", "0.60762656", "0.607503", "0.6072843", "0.60702467" ]
0.6436323
35
HasField returns field is exists
func (s *Structx) HasField(name string) bool { _, ok := s.value.Type().FieldByName(name) return ok }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *Model) HasField(field string) (bool, error) {\n\treturn m.db.GetCore().HasField(m.GetCtx(), m.tablesInit, field)\n}", "func (o *StatusDescriptorDTO) HasField() bool {\n\tif o != nil && o.Field != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func IsHasField(st interface{}, fieldName string) bool {\n\treturn HasField(st, fieldName)\n}", "func (o *RiskRulesListAllOfData) HasField() bool {\n\tif o != nil && !IsNil(o.Field) {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (s *Struct) HasField(name string) bool {\n\tfor _, f := range s.Fields {\n\t\tif f.Name == name {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (c *Configuration) Has(field string) bool {\n\tout := getField(c.App, field)\n\tif out == nil {\n\t\tout = getField(c.Base, field)\n\t}\n\n\treturn out != nil\n}", "func (o *SyntheticsGlobalVariableParseTestOptions) HasField() bool {\n\treturn o != nil && o.Field != nil\n}", "func (m *ccMetric) HasField(key string) bool {\n\t_, ok := m.fields[key]\n\treturn ok\n}", "func (o *FieldError) HasField() bool {\n\tif o != nil && o.Field != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (m *Measurement) HasField(name string) bool {\n\tm.mu.RLock()\n\tdefer m.mu.RUnlock()\n\t_, hasField := m.fieldNames[name]\n\treturn hasField\n}", "func HasField(st interface{}, fieldName string) bool {\n\tvalueIface := reflect.ValueOf(st)\n\n\t// Check if the passed interface is a pointer\n\tif valueIface.Type().Kind() != reflect.Ptr {\n\t\t// Create a new type of Iface's Type, so we have a pointer to work with\n\t\tvalueIface = reflect.New(reflect.TypeOf(st))\n\t}\n\n\t// 'dereference' with Elem() and get the field by name\n\tfield := valueIface.Elem().FieldByName(fieldName)\n\treturn field.IsValid()\n}", "func (ls Set) Has(field string) bool {\n\t_, exists := ls[field]\n\treturn exists\n}", "func (f Unstructured) HasByName(field string) bool {\n\tif f.IsUndefined() {\n\t\treturn true\n\t}\n\t_, ok := f.fields[field]\n\treturn ok\n}", "func (x *fastReflection_ModuleOptions) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.autocli.v1.ModuleOptions.tx\":\n\t\treturn x.Tx != nil\n\tcase \"cosmos.autocli.v1.ModuleOptions.query\":\n\t\treturn x.Query != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.autocli.v1.ModuleOptions\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.autocli.v1.ModuleOptions does not contain field %s\", fd.FullName()))\n\t}\n}", "func (this *Collection) Has(fields interface{}) (bool, error) {\n\tsession, err := mgo.Dial(this.address)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tdefer session.Close()\n\tsession.SetSafe(&mgo.Safe{})\n\tcollection := session.DB(this.database).C(this.collection)\n\tif count, err := collection.Find(fields).Limit(1).Count(); err != nil {\n\t\treturn false, err\n\t} else if count != 1 {\n\t\treturn false, nil\n\t} else {\n\t\treturn true, nil\n\t}\n}", "func (s Strategy) HasArrayField(t Entity) bool {\n\t//Fields []map[string]interface{}\n\n\tfor _, f := range t.Fields {\n\t\tif f[\"type\"] == \"Array\" {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func fieldContains(fl FieldLevel) bool {\n\tfield := fl.Field()\n\n\tcurrentField, _, ok := fl.GetStructFieldOK()\n\n\tif !ok {\n\t\treturn false\n\t}\n\n\treturn strings.Contains(field.String(), currentField.String())\n}", "func (f *Form) Has(field string, r *http.Request) bool {\n\tx := r.Form.Get(field)\n\tif x == \"\" {\n\t\treturn false\n\t}\n\treturn true\n}", "func (f *FieldsWithValue) Contains(field string) bool {\n\t_, ok := f.innerRegistry[field]\n\treturn ok\n}", "func (x *fastReflection_QueryModuleAccountByNameRequest) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.QueryModuleAccountByNameRequest.name\":\n\t\treturn x.Name != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryModuleAccountByNameRequest\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryModuleAccountByNameRequest does not contain field %s\", fd.FullName()))\n\t}\n}", "func (i *Index) existenceField() *Field {\n\ti.mu.RLock()\n\tdefer i.mu.RUnlock()\n\n\treturn i.existenceFld\n}", "func (x *fastReflection_QueryAccountsRequest) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.QueryAccountsRequest.pagination\":\n\t\treturn x.Pagination != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryAccountsRequest\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryAccountsRequest does not contain field %s\", fd.FullName()))\n\t}\n}", "func (p RedisDsl) HASH_FIELD_EXISTS(key, field string) (bool, error) {\n\tif len(key) == 0 {\n\t\treturn false, fmt.Errorf(\"Empty key\")\n\t}\n\tif len(field) == 0 {\n\t\treturn false, fmt.Errorf(\"Empty field\")\n\t}\n\n\treturn ReplyToBool(p.Cmd(\"HEXISTS\", key, field))\n}", "func HasFields(field string, fields ...string) Condition {\n\treturn func(_ context.Context, m ent.Mutation) bool {\n\t\tif _, exists := m.Field(field); !exists {\n\t\t\treturn false\n\t\t}\n\t\tfor _, field := range fields {\n\t\t\tif _, exists := m.Field(field); !exists {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n}", "func (q *Q) ExistsByField(db api.IRecord, field string, value string) (found bool, ID string, err error) {\n\tif q.Mock != nil && q.Mock.Enabled() {\n\t\treturn q.Mock.Bool(), q.Mock.String(), q.Mock.Error()\n\t}\n\n\terr = q.db.QueryRowScan(&ID, fmt.Sprintf(`\n\t\tSELECT %s FROM %s\n\t\tWHERE %s = ?\n\t\tLIMIT 1`, db.PrimaryKey(), db.Table(), field),\n\t\tvalue)\n\n\treturn q.db.RecordExistsString(err, ID)\n}", "func (x *fastReflection_ValidatorSlashEventRecord) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.ValidatorSlashEventRecord.validator_address\":\n\t\treturn x.ValidatorAddress != \"\"\n\tcase \"cosmos.distribution.v1beta1.ValidatorSlashEventRecord.height\":\n\t\treturn x.Height != uint64(0)\n\tcase \"cosmos.distribution.v1beta1.ValidatorSlashEventRecord.period\":\n\t\treturn x.Period != uint64(0)\n\tcase \"cosmos.distribution.v1beta1.ValidatorSlashEventRecord.validator_slash_event\":\n\t\treturn x.ValidatorSlashEvent != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.ValidatorSlashEventRecord\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.ValidatorSlashEventRecord does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_QueryModuleAccountByNameResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.QueryModuleAccountByNameResponse.account\":\n\t\treturn x.Account != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryModuleAccountByNameResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryModuleAccountByNameResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_QueryModuleAccountsResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.QueryModuleAccountsResponse.accounts\":\n\t\treturn len(x.Accounts) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryModuleAccountsResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryModuleAccountsResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (wfq *WithFieldsQuery) Exist(ctx context.Context) (bool, error) {\n\tif err := wfq.prepareQuery(ctx); err != nil {\n\t\treturn false, err\n\t}\n\treturn wfq.sqlExist(ctx)\n}", "func (r *resolution) includeField(res Result, field string) (bool, Result, error) {\n\t// https://tools.ietf.org/html/rfc7208#section-5.2\n\tincdomain := field[len(\"include:\"):]\n\tir, err := r.Check(incdomain)\n\tswitch ir {\n\tcase Pass:\n\t\treturn true, res, err\n\tcase Fail, SoftFail, Neutral:\n\t\treturn false, ir, err\n\tcase TempError:\n\t\treturn true, TempError, err\n\tcase PermError, None:\n\t\treturn true, PermError, err\n\t}\n\n\treturn false, \"\", fmt.Errorf(\"This should never be reached\")\n\n}", "func (field Field) IsDefined() bool {\n\treturn field.Var != nil\n}", "func (x *fastReflection_QueryModuleAccountsRequest) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryModuleAccountsRequest\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryModuleAccountsRequest does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_QueryAccountResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.QueryAccountResponse.account\":\n\t\treturn x.Account != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryAccountResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryAccountResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_Input) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.bank.v1beta1.Input.address\":\n\t\treturn x.Address != \"\"\n\tcase \"cosmos.bank.v1beta1.Input.coins\":\n\t\treturn len(x.Coins) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.Input\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.Input does not contain field %s\", fd.FullName()))\n\t}\n}", "func (meta metadata) hasRelation() bool {\n\tfor _, field := range meta.fields {\n\t\tif field.hasRelation() {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (x *fastReflection_QueryAccountRequest) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.QueryAccountRequest.address\":\n\t\treturn x.Address != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryAccountRequest\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryAccountRequest does not contain field %s\", fd.FullName()))\n\t}\n}", "func fieldExists(typ reflect.Type, name string) bool {\n\tfields := chainedFieldNameToFieldNames(name)\n\n\tfor i, field := range fields {\n\t\tf, ok := typ.FieldByName(field)\n\t\tif !ok {\n\t\t\treturn false\n\t\t}\n\n\t\tif i == len(fields)-1 {\n\t\t\tbreak\n\t\t}\n\n\t\t// TODO: Optimize me for only type struct or *struct is valid\n\t\ttyp = f.Type\n\t\tif typ.Kind() == reflect.Ptr {\n\t\t\ttyp = typ.Elem()\n\t\t}\n\t}\n\n\treturn true\n}", "func (x *fastReflection_QueryParamsRequest) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryParamsRequest\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryParamsRequest does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_QueryAccountsResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.QueryAccountsResponse.accounts\":\n\t\treturn len(x.Accounts) != 0\n\tcase \"cosmos.auth.v1beta1.QueryAccountsResponse.pagination\":\n\t\treturn x.Pagination != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryAccountsResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryAccountsResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (m FieldMap) Has(tag Tag) bool {\n\t_, ok := m.tagLookup[tag]\n\treturn ok\n}", "func (x *fastReflection_QueryParamsResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.QueryParamsResponse.params\":\n\t\treturn x.Params != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryParamsResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryParamsResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_Supply) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.bank.v1beta1.Supply.total\":\n\t\treturn len(x.Total) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.Supply\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.Supply does not contain field %s\", fd.FullName()))\n\t}\n}", "func HasAddedFields(field string, fields ...string) Condition {\n\treturn func(_ context.Context, m ent.Mutation) bool {\n\t\tif _, exists := m.AddedField(field); !exists {\n\t\t\treturn false\n\t\t}\n\t\tfor _, field := range fields {\n\t\t\tif _, exists := m.AddedField(field); !exists {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n}", "func (x *fastReflection_QueryAccountInfoRequest) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.QueryAccountInfoRequest.address\":\n\t\treturn x.Address != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryAccountInfoRequest\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryAccountInfoRequest does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_SendEnabled) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.bank.v1beta1.SendEnabled.denom\":\n\t\treturn x.Denom != \"\"\n\tcase \"cosmos.bank.v1beta1.SendEnabled.enabled\":\n\t\treturn x.Enabled != false\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.SendEnabled\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.SendEnabled does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_Metadata) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.bank.v1beta1.Metadata.description\":\n\t\treturn x.Description != \"\"\n\tcase \"cosmos.bank.v1beta1.Metadata.denom_units\":\n\t\treturn len(x.DenomUnits) != 0\n\tcase \"cosmos.bank.v1beta1.Metadata.base\":\n\t\treturn x.Base != \"\"\n\tcase \"cosmos.bank.v1beta1.Metadata.display\":\n\t\treturn x.Display != \"\"\n\tcase \"cosmos.bank.v1beta1.Metadata.name\":\n\t\treturn x.Name != \"\"\n\tcase \"cosmos.bank.v1beta1.Metadata.symbol\":\n\t\treturn x.Symbol != \"\"\n\tcase \"cosmos.bank.v1beta1.Metadata.uri\":\n\t\treturn x.Uri != \"\"\n\tcase \"cosmos.bank.v1beta1.Metadata.uri_hash\":\n\t\treturn x.UriHash != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.Metadata\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.Metadata does not contain field %s\", fd.FullName()))\n\t}\n}", "func (f Unstructured) Has(v ...interface{}) bool {\n\thf, err := ParseUnstructured(v)\n\tif f.fields == nil {\n\t\treturn true\n\t}\n\tif err != nil {\n\t\treturn false\n\t}\n\tif hf.IsUndefined() {\n\t\treturn false\n\t}\n\tmissing := hf.FindField(func(fieldName string, fieldFragment Fragment) bool {\n\t\tif fieldFragment.IsUndefined() {\n\t\t\treturn !f.HasByName(fieldName)\n\t\t} else if !f.HasByName(fieldName) {\n\t\t\treturn true\n\t\t} else {\n\t\t\tcurrentFieldFragment := f.Field(fieldName)\n\t\t\tif currentFieldFragment == nil || currentFieldFragment.IsUndefined() {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn currentFieldFragment.Has(fieldFragment)\n\t\t}\n\t})\n\treturn missing == nil\n}", "func (x *fastReflection_EventCreateClass) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"regen.ecocredit.v1alpha1.EventCreateClass.class_id\":\n\t\treturn x.ClassId != \"\"\n\tcase \"regen.ecocredit.v1alpha1.EventCreateClass.admin\":\n\t\treturn x.Admin != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: regen.ecocredit.v1alpha1.EventCreateClass\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message regen.ecocredit.v1alpha1.EventCreateClass does not contain field %s\", fd.FullName()))\n\t}\n}", "func (def *Definition) CheckField(name string) bool {\n\t_, ok := def.activeFields[name]\n\tif len(def.activeFields) == 0 && len(def.Values) > 0 {\n\t\treturn true\n\t}\n\tCentral.Log.Debugf(\"returning %v %d %d\", ok, len(def.activeFields), len(def.Values))\n\treturn ok\n}", "func (x *fastReflection_QueryAccountInfoResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.QueryAccountInfoResponse.info\":\n\t\treturn x.Info != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryAccountInfoResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryAccountInfoResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func HasValue(field reflect.Value) bool {\n\tswitch field.Kind() {\n\tcase reflect.Slice, reflect.Map, reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Func:\n\t\treturn !field.IsNil()\n\tdefault:\n\t\treturn field.IsValid() && field.Interface() != reflect.Zero(field.Type()).Interface()\n\t}\n}", "func (o *ProvenanceOptionsDTO) HasSearchableFields() bool {\n\tif o != nil && o.SearchableFields != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (x *fastReflection_MsgFundCommunityPool) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.MsgFundCommunityPool.amount\":\n\t\treturn len(x.Amount) != 0\n\tcase \"cosmos.distribution.v1beta1.MsgFundCommunityPool.depositor\":\n\t\treturn x.Depositor != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgFundCommunityPool\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgFundCommunityPool does not contain field %s\", fd.FullName()))\n\t}\n}", "func Has(from Getter, t string) bool {\n\treturn Get(from, t) != nil\n}", "func (x *fastReflection_EventRetire) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"regen.ecocredit.v1alpha1.EventRetire.retirer\":\n\t\treturn x.Retirer != \"\"\n\tcase \"regen.ecocredit.v1alpha1.EventRetire.batch_denom\":\n\t\treturn x.BatchDenom != \"\"\n\tcase \"regen.ecocredit.v1alpha1.EventRetire.amount\":\n\t\treturn x.Amount != \"\"\n\tcase \"regen.ecocredit.v1alpha1.EventRetire.location\":\n\t\treturn x.Location != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: regen.ecocredit.v1alpha1.EventRetire\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message regen.ecocredit.v1alpha1.EventRetire does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_Bech32PrefixResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.Bech32PrefixResponse.bech32_prefix\":\n\t\treturn x.Bech32Prefix != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.Bech32PrefixResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.Bech32PrefixResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (o *InlineObject1187) HasFields() bool {\n\tif o != nil && o.Fields != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (x *fastReflection_MsgCommunityPoolSpend) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.MsgCommunityPoolSpend.authority\":\n\t\treturn x.Authority != \"\"\n\tcase \"cosmos.distribution.v1beta1.MsgCommunityPoolSpend.recipient\":\n\t\treturn x.Recipient != \"\"\n\tcase \"cosmos.distribution.v1beta1.MsgCommunityPoolSpend.amount\":\n\t\treturn len(x.Amount) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgCommunityPoolSpend\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgCommunityPoolSpend does not contain field %s\", fd.FullName()))\n\t}\n}", "func (o *MicrosoftGraphListItem) HasFields() bool {\n\tif o != nil && o.Fields != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (o *KanbanViewView) HasSingleSelectField() bool {\n\tif o != nil && o.SingleSelectField.IsSet() {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (x *fastReflection_Evidence) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"tendermint.types.Evidence.duplicate_vote_evidence\":\n\t\tif x.Sum == nil {\n\t\t\treturn false\n\t\t} else if _, ok := x.Sum.(*Evidence_DuplicateVoteEvidence); ok {\n\t\t\treturn true\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\tcase \"tendermint.types.Evidence.light_client_attack_evidence\":\n\t\tif x.Sum == nil {\n\t\t\treturn false\n\t\t} else if _, ok := x.Sum.(*Evidence_LightClientAttackEvidence); ok {\n\t\t\treturn true\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: tendermint.types.Evidence\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message tendermint.types.Evidence does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_ValidatorCurrentRewardsRecord) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.ValidatorCurrentRewardsRecord.validator_address\":\n\t\treturn x.ValidatorAddress != \"\"\n\tcase \"cosmos.distribution.v1beta1.ValidatorCurrentRewardsRecord.rewards\":\n\t\treturn x.Rewards != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.ValidatorCurrentRewardsRecord\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.ValidatorCurrentRewardsRecord does not contain field %s\", fd.FullName()))\n\t}\n}", "func (m *Map) HasMember(field string) bool {\n\tm.convert()\n\t_, hasMember := m.items[field]\n\n\treturn hasMember\n}", "func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.bank.v1beta1.Params.send_enabled\":\n\t\treturn len(x.SendEnabled) != 0\n\tcase \"cosmos.bank.v1beta1.Params.default_send_enabled\":\n\t\treturn x.DefaultSendEnabled != false\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.Params\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.Params does not contain field %s\", fd.FullName()))\n\t}\n}", "func (state ZenformState) ExistsTicketField(slug string) bool {\n\treturn state.TicketFields[slug].ID != NotFoundID\n}", "func (x *fastReflection_ValidatorAccumulatedCommissionRecord) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.ValidatorAccumulatedCommissionRecord.validator_address\":\n\t\treturn x.ValidatorAddress != \"\"\n\tcase \"cosmos.distribution.v1beta1.ValidatorAccumulatedCommissionRecord.accumulated\":\n\t\treturn x.Accumulated != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.ValidatorAccumulatedCommissionRecord\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.ValidatorAccumulatedCommissionRecord does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_MsgDepositValidatorRewardsPool) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.MsgDepositValidatorRewardsPool.depositor\":\n\t\treturn x.Depositor != \"\"\n\tcase \"cosmos.distribution.v1beta1.MsgDepositValidatorRewardsPool.validator_address\":\n\t\treturn x.ValidatorAddress != \"\"\n\tcase \"cosmos.distribution.v1beta1.MsgDepositValidatorRewardsPool.amount\":\n\t\treturn len(x.Amount) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgDepositValidatorRewardsPool\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgDepositValidatorRewardsPool does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_FlagOptions) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.autocli.v1.FlagOptions.name\":\n\t\treturn x.Name != \"\"\n\tcase \"cosmos.autocli.v1.FlagOptions.shorthand\":\n\t\treturn x.Shorthand != \"\"\n\tcase \"cosmos.autocli.v1.FlagOptions.usage\":\n\t\treturn x.Usage != \"\"\n\tcase \"cosmos.autocli.v1.FlagOptions.default_value\":\n\t\treturn x.DefaultValue != \"\"\n\tcase \"cosmos.autocli.v1.FlagOptions.deprecated\":\n\t\treturn x.Deprecated != \"\"\n\tcase \"cosmos.autocli.v1.FlagOptions.shorthand_deprecated\":\n\t\treturn x.ShorthandDeprecated != \"\"\n\tcase \"cosmos.autocli.v1.FlagOptions.hidden\":\n\t\treturn x.Hidden != false\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.autocli.v1.FlagOptions\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.autocli.v1.FlagOptions does not contain field %s\", fd.FullName()))\n\t}\n}", "func (o *SingleSelectFieldField) HasPrimary() bool {\n\tif o != nil && !IsNil(o.Primary) {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func Has(db *gorm.DB, model TableInterface, scopes ...func(*gorm.DB) *gorm.DB) (bool, error) {\n\tvar result int\n\tdbSession := db.Session(&gorm.Session{NewDB: true, DryRun: true})\n\tstmt := dbSession.Model(model).Select(model.PrimaryKey()).Scopes(scopes...).Find(model).Statement\n\tsql := db.Dialector.Explain(stmt.SQL.String(), stmt.Vars...)\n\trow := db.Raw(\"SELECT EXISTS(?)\", gorm.Expr(sql)).Row()\n\tif row == nil {\n\t\treturn false, nil\n\t}\n\n\tif err := row.Scan(&result); err != nil {\n\t\treturn false, err\n\t}\n\n\treturn result > 0, nil\n}", "func (p RedisDsl) HASHES_FIELD_EXISTS(keys []string, field string) ([]bool, error) {\n\tif len(field) == 0 {\n\t\treturn nil, fmt.Errorf(\"Empty field\")\n\t}\n\tfor i, key := range keys {\n\t\tif len(field) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"Empty key[%d]\", i)\n\t\t}\n\t\tp.Append(\"HEXISTS\", key, field)\n\t}\n\n\toutput := make([]bool, len(keys))\n\tfor i := range keys {\n\t\tb, err := ReplyToBool(p.GetReply())\n\t\tif nil != err {\n\t\t\treturn nil, err\n\t\t}\n\n\t\toutput[i] = b\n\t}\n\n\treturn output, nil\n}", "func (x *fastReflection_Output) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.bank.v1beta1.Output.address\":\n\t\treturn x.Address != \"\"\n\tcase \"cosmos.bank.v1beta1.Output.coins\":\n\t\treturn len(x.Coins) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.Output\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.Output does not contain field %s\", fd.FullName()))\n\t}\n}", "func (r Record) Has(key string) bool {\n\tif r.dropped {\n\t\tlog.Fatalf(\"Int called on dropped record\")\n\t}\n\n\tval, ok := r.values[key]\n\tif !ok {\n\t\treturn false\n\t}\n\n\tswitch val := val.(type) {\n\tcase nil:\n\t\treturn false\n\tcase []interface{}:\n\t\treturn len(val) > 0\n\tcase map[string]interface{}:\n\t\treturn len(val) > 0\n\t}\n\n\treturn true\n}", "func (x *fastReflection_ValidatorHistoricalRewardsRecord) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.ValidatorHistoricalRewardsRecord.validator_address\":\n\t\treturn x.ValidatorAddress != \"\"\n\tcase \"cosmos.distribution.v1beta1.ValidatorHistoricalRewardsRecord.period\":\n\t\treturn x.Period != uint64(0)\n\tcase \"cosmos.distribution.v1beta1.ValidatorHistoricalRewardsRecord.rewards\":\n\t\treturn x.Rewards != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.ValidatorHistoricalRewardsRecord\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.ValidatorHistoricalRewardsRecord does not contain field %s\", fd.FullName()))\n\t}\n}", "func (o *NotificationAllOf) HasFields() bool {\n\tif o != nil && o.Fields != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (x *fastReflection_MsgWithdrawValidatorCommission) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission.validator_address\":\n\t\treturn x.ValidatorAddress != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_LightClientAttackEvidence) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"tendermint.types.LightClientAttackEvidence.conflicting_block\":\n\t\treturn x.ConflictingBlock != nil\n\tcase \"tendermint.types.LightClientAttackEvidence.common_height\":\n\t\treturn x.CommonHeight != int64(0)\n\tcase \"tendermint.types.LightClientAttackEvidence.byzantine_validators\":\n\t\treturn len(x.ByzantineValidators) != 0\n\tcase \"tendermint.types.LightClientAttackEvidence.total_voting_power\":\n\t\treturn x.TotalVotingPower != int64(0)\n\tcase \"tendermint.types.LightClientAttackEvidence.timestamp\":\n\t\treturn x.Timestamp != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: tendermint.types.LightClientAttackEvidence\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message tendermint.types.LightClientAttackEvidence does not contain field %s\", fd.FullName()))\n\t}\n}", "func ValueExists(p *Page, field interface{}) bool {\n\to := convert(field)\n\tv, ok := p.FormValues[o.Key]\n\tif !ok {\n\t\treturn false\n\t}\n\n\treturn len(v) > 0\n}", "func (e *Entity) Has(property string) bool {\n\te.lock.Lock()\n\tdefer e.lock.Unlock()\n\t_, exists := e.Properties[property]\n\treturn exists\n}", "func (w *Wrapper) Has() (has bool, err error) {\n\terr = w.Limit(1).Get()\n\tif err != nil {\n\t\thas = false\n\t\treturn\n\t}\n\tif w.Count() > 0 {\n\t\thas = true\n\t\treturn\n\t}\n\treturn\n}", "func (x *fastReflection_MsgFundCommunityPoolResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgFundCommunityPoolResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgFundCommunityPoolResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (d UserData) HasCountry() bool {\n\treturn d.ModelData.Has(models.NewFieldName(\"Country\", \"country_id\"))\n}", "func (x *fastReflection_ValidatorOutstandingRewardsRecord) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.ValidatorOutstandingRewardsRecord.validator_address\":\n\t\treturn x.ValidatorAddress != \"\"\n\tcase \"cosmos.distribution.v1beta1.ValidatorOutstandingRewardsRecord.outstanding_rewards\":\n\t\treturn len(x.OutstandingRewards) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.ValidatorOutstandingRewardsRecord\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.ValidatorOutstandingRewardsRecord does not contain field %s\", fd.FullName()))\n\t}\n}", "func ContainsField(path string, allowedPaths []string) bool {\n\tfor _, allowedPath := range allowedPaths {\n\t\tif path == allowedPath {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (x *fastReflection_Bech32PrefixRequest) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.Bech32PrefixRequest\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.Bech32PrefixRequest does not contain field %s\", fd.FullName()))\n\t}\n}", "func (d UserData) HasCompany() bool {\n\treturn d.ModelData.Has(models.NewFieldName(\"Company\", \"company_id\"))\n}", "func (s *Badger) Has(k []byte) (bool, error) {\n\t// return s.db.Exists(k)\n\tval, err := s.Get(k)\n\tif string(val) == \"\" && err != nil {\n\t\treturn false, err\n\t}\n\n\treturn true, err\n}", "func includeField(f reflect.StructField, exclude ExcludeFieldTag) bool {\n\tfieldName := GetFieldFirstTag(f, \"json\")\n\tif fieldName == \"\" {\n\t\treturn false\n\t}\n\tgqlexclude := f.Tag.Get(GqlExcludeTagName)\n\tif gqlexclude == \"\" {\n\t\t// No exclusions\n\t\treturn true\n\t}\n\tfor _, s := range strings.Split(gqlexclude, \",\") {\n\t\tif strings.Trim(s, \" \") == string(exclude) {\n\t\t\t// excluded\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func (x *fastReflection_DelegatorWithdrawInfo) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.DelegatorWithdrawInfo.delegator_address\":\n\t\treturn x.DelegatorAddress != \"\"\n\tcase \"cosmos.distribution.v1beta1.DelegatorWithdrawInfo.withdraw_address\":\n\t\treturn x.WithdrawAddress != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.DelegatorWithdrawInfo\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.DelegatorWithdrawInfo does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_QueryAccountAddressByIDResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.QueryAccountAddressByIDResponse.account_address\":\n\t\treturn x.AccountAddress != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryAccountAddressByIDResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryAccountAddressByIDResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_QueryAccountAddressByIDRequest) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.QueryAccountAddressByIDRequest.id\":\n\t\treturn x.Id != int64(0)\n\tcase \"cosmos.auth.v1beta1.QueryAccountAddressByIDRequest.account_id\":\n\t\treturn x.AccountId != uint64(0)\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryAccountAddressByIDRequest\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryAccountAddressByIDRequest does not contain field %s\", fd.FullName()))\n\t}\n}", "func isFieldOverWritable(field string, meta map[string]MetaData, m map[string]interface{}) bool {\n\tif meta != nil && m[field] != nil {\n\t\tif metaData, exists := meta[field]; exists && metaData.OverWritable != nil {\n\t\t\treturn *metaData.OverWritable\n\t\t}\n\t}\n\treturn true\n}", "func (o *CustomfieldRequest) HasCustomfield() bool {\n\tif o != nil && o.Customfield != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (m *SnapshotPrepare) Field(fieldpath []string) (string, bool) {\n\tif len(fieldpath) == 0 {\n\t\treturn \"\", false\n\t}\n\tswitch fieldpath[0] {\n\tcase \"key\":\n\t\treturn string(m.Key), len(m.Key) > 0\n\tcase \"parent\":\n\t\treturn string(m.Parent), len(m.Parent) > 0\n\tcase \"snapshotter\":\n\t\treturn string(m.Snapshotter), len(m.Snapshotter) > 0\n\t}\n\treturn \"\", false\n}", "func (d UserData) HasTitle() bool {\n\treturn d.ModelData.Has(models.NewFieldName(\"Title\", \"title_id\"))\n}", "func fieldExistenceBitField(metadata *pb.TestMetadata) uint8 {\n\tbitField := uint8(0)\n\tbitFieldOrder := []string{\n\t\t\"name\",\n\t\t\"location.repo\",\n\t\t\"location.file_name\",\n\t\t\"location.line\",\n\t\t\"bug_component\",\n\t}\n\tfor i, k := range bitFieldOrder {\n\t\tif exist(strings.Split(k, \".\"), metadata.ProtoReflect()) {\n\t\t\tbitField += uint8(math.Pow(2, float64(i)))\n\t\t}\n\t}\n\treturn bitField\n}", "func getField(n string, i interface{}) (interface{}, bool) {\n\tre := reflect.ValueOf(i).Elem()\n\tif re.Kind() == reflect.Struct {\n\t\tf := re.FieldByName(n)\n\n\t\tif f.IsValid() {\n\t\t\treturn f.Interface(), true\n\t\t}\n\t}\n\n\treturn nil, false\n}", "func (x *fastReflection_MsgUpdateParams) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.MsgUpdateParams.authority\":\n\t\treturn x.Authority != \"\"\n\tcase \"cosmos.distribution.v1beta1.MsgUpdateParams.params\":\n\t\treturn x.Params != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgUpdateParams\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgUpdateParams does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_MsgCommunityPoolSpendResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgCommunityPoolSpendResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgCommunityPoolSpendResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_MsgWithdrawValidatorCommissionResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.MsgWithdrawValidatorCommissionResponse.amount\":\n\t\treturn len(x.Amount) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgWithdrawValidatorCommissionResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgWithdrawValidatorCommissionResponse does not contain field %s\", fd.FullName()))\n\t}\n}" ]
[ "0.7261434", "0.70997816", "0.69505", "0.688207", "0.68492347", "0.6732724", "0.6667359", "0.66266596", "0.66261625", "0.6545041", "0.63476", "0.63033026", "0.6287312", "0.6181342", "0.61592114", "0.6153436", "0.6124436", "0.6121026", "0.6062587", "0.6048789", "0.6042881", "0.60205173", "0.6012642", "0.601053", "0.5996671", "0.5960701", "0.5953036", "0.5938933", "0.59344506", "0.5915841", "0.5910472", "0.58961135", "0.58939236", "0.5883467", "0.58748144", "0.5871428", "0.5868039", "0.58679277", "0.58519495", "0.5846603", "0.58321416", "0.58159804", "0.5793034", "0.5777802", "0.5763267", "0.57501036", "0.574738", "0.57327133", "0.57297134", "0.5714538", "0.5709112", "0.5708671", "0.5704336", "0.5703294", "0.5688607", "0.5686782", "0.5679397", "0.5676851", "0.5675232", "0.5658355", "0.5657578", "0.56572765", "0.5655332", "0.5645461", "0.5627793", "0.5623705", "0.5603258", "0.5588558", "0.55831903", "0.55589056", "0.5555041", "0.5550454", "0.55206376", "0.55181086", "0.551542", "0.55095506", "0.5491611", "0.54895157", "0.5488302", "0.548633", "0.54847425", "0.5481807", "0.54755586", "0.54698765", "0.54662114", "0.54631966", "0.5463029", "0.5456743", "0.5455838", "0.54374474", "0.5433731", "0.5432145", "0.5431303", "0.54224974", "0.54214686", "0.54191476", "0.5396017", "0.539407", "0.5392624", "0.5378192" ]
0.70268536
2
MustField returns a field with name, panic if error
func (s *Structx) MustField(name string) *Fieldx { f, ok := s.Field(name) if !ok { panic(ErrNotField) } return f }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *Field) Field(name string) *Field {\n\tfield, ok := f.FieldOk(name)\n\tif !ok {\n\t\tpanic(\"field not found\")\n\t}\n\n\treturn field\n}", "func MustField(v interface{}, name string) *Fieldx {\n\treturn New(v).MustField(name)\n}", "func (m *SnapshotPrepare) Field(fieldpath []string) (string, bool) {\n\tif len(fieldpath) == 0 {\n\t\treturn \"\", false\n\t}\n\tswitch fieldpath[0] {\n\tcase \"key\":\n\t\treturn string(m.Key), len(m.Key) > 0\n\tcase \"parent\":\n\t\treturn string(m.Parent), len(m.Parent) > 0\n\tcase \"snapshotter\":\n\t\treturn string(m.Snapshotter), len(m.Snapshotter) > 0\n\t}\n\treturn \"\", false\n}", "func (m *Command) MustCreateField(tb testing.TB, index, field string, opts ...pilosa.FieldOption) *pilosa.Field {\n\ttb.Helper()\n\tf, err := m.API.CreateField(context.Background(), index, field, opts...)\n\tif err != nil {\n\t\ttb.Fatalf(\"creating field: %s in index: %s err: %v\", field, index, err)\n\t}\n\treturn f\n}", "func (msg *Message) Field(fieldName string) *Field {\n\treturn msg.fieldByName[fieldName]\n}", "func (ds *DynamicStruct) FieldByName(name string) (reflect.StructField, bool) {\n\treturn ds.rt.FieldByName(name)\n}", "func (f *Field) FieldOk(name string) (*Field, bool) {\n\tvalue := &f.value\n\t// value must be settable so we need to make sure it holds the address of the\n\t// variable and not a copy, so we can pass the pointer to strctVal instead of a\n\t// copy (which is not assigned to any variable, hence not settable).\n\t// see \"https://blog.golang.org/laws-of-reflection#TOC_8.\"\n\tif f.value.Kind() != reflect.Ptr {\n\t\ta := f.value.Addr()\n\t\tvalue = &a\n\t}\n\tv := strctVal(value.Interface())\n\tt := v.Type()\n\n\tfield, ok := t.FieldByName(name)\n\tif !ok {\n\t\treturn nil, false\n\t}\n\n\treturn &Field{\n\t\tfield: field,\n\t\tvalue: v.FieldByName(name),\n\t}, true\n}", "func (s *Structx) Field(name string) (*Fieldx, bool) {\n\tf, ok := s.value.Type().FieldByName(name)\n\tif !ok {\n\t\treturn nil, false\n\t}\n\n\tff := &Fieldx{\n\t\tdata: f,\n\t\tvalue: s.value.FieldByName(name),\n\t}\n\n\treturn ff, true\n}", "func (v *Validator) Field(name string) (*app.Field, error) {\n\tfor _, field := range v.schema.Fields {\n\t\tif field.Name == name {\n\t\t\treturn field, nil\n\t\t}\n\t}\n\treturn nil, ErrNoField\n}", "func (s *StructLike) GetField(name string) (*Field, bool) {\n\tfor _, fi := range s.Fields {\n\t\tif fi.Name == name {\n\t\t\treturn fi, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func (s *StructField) Field(name string) (*StructField, error) {\n\treturn Field(s.Value(), name)\n}", "func (i Item) GetField(name string) interface{} {\n\treturn getField(name, i.Payload)\n}", "func (_DelegateProfile *DelegateProfileCaller) GetFieldByName(opts *bind.CallOpts, _name string) (struct {\n\tVerifier common.Address\n\tDeprecated bool\n}, error) {\n\tret := new(struct {\n\t\tVerifier common.Address\n\t\tDeprecated bool\n\t})\n\tout := ret\n\terr := _DelegateProfile.contract.Call(opts, out, \"getFieldByName\", _name)\n\treturn *ret, err\n}", "func (e CacheValidationError) Field() string { return e.field }", "func (m *ContainerCreate_Runtime) Field(fieldpath []string) (string, bool) {\n\tif len(fieldpath) == 0 {\n\t\treturn \"\", false\n\t}\n\n\tswitch fieldpath[0] {\n\tcase \"name\":\n\t\treturn string(m.Name), len(m.Name) > 0\n\tcase \"options\":\n\t\tdecoded, err := github_com_containerd_typeurl.UnmarshalAny(m.Options)\n\t\tif err != nil {\n\t\t\treturn \"\", false\n\t\t}\n\n\t\tadaptor, ok := decoded.(interface{ Field([]string) (string, bool) })\n\t\tif !ok {\n\t\t\treturn \"\", false\n\t\t}\n\t\treturn adaptor.Field(fieldpath[1:])\n\t}\n\treturn \"\", false\n}", "func getField(fieldName string, data interface{}) (string, error) {\n\tr := reflect.ValueOf(data)\n\tval := reflect.Indirect(r).FieldByName(fieldName).Interface()\n\n\tswitch v := val.(type) {\n\tcase string:\n\t\treturn v, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"only string type is supported\")\n\t}\n}", "func (v *ClassValue) field(s *scope, name string) Value {\n\tfield, ok := v.Fields[name]\n\tif !ok {\n\t\tpanic(fmt.Errorf(\"ClassValue %v did not contain field %v\", v.Type().Name(), name))\n\t}\n\treturn field\n}", "func getField(n string, i interface{}) (interface{}, bool) {\n\tre := reflect.ValueOf(i).Elem()\n\tif re.Kind() == reflect.Struct {\n\t\tf := re.FieldByName(n)\n\n\t\tif f.IsValid() {\n\t\t\treturn f.Interface(), true\n\t\t}\n\t}\n\n\treturn nil, false\n}", "func (entry *Entry) Field(name string) (value string, err error) {\n\tvalue, ok := entry.fields[name]\n\tif !ok {\n\t\terr = fmt.Errorf(\"field '%v' does not found in record %+v\", name, *entry)\n\t}\n\treturn\n}", "func (e ResponseMapperValidationError) Field() string { return e.field }", "func (e JwtRequirementValidationError) Field() string { return e.field }", "func (m *message) GetFieldByName(name string) (f *MessageField, ok bool) {\n\tm.mu.RLock()\n\tf, ok = m.fieldNameToField[name]\n\tm.mu.RUnlock()\n\treturn\n}", "func (e GetDisscusReqValidationError) Field() string { return e.field }", "func (res Result) GetField(fields ...string) interface{} {\n\tif len(fields) == 0 {\n\t\treturn res\n\t}\n\n\treturn res.get(fields)\n}", "func (e GetRequestValidationError) Field() string { return e.field }", "func (e GetRequestValidationError) Field() string { return e.field }", "func (e SimpleRequestValidationError) Field() string { return e.field }", "func (e JwtClaimToHeaderValidationError) Field() string { return e.field }", "func (e ChannelPayRequestValidationError) Field() string { return e.field }", "func (m *ContainerCreate) Field(fieldpath []string) (string, bool) {\n\tif len(fieldpath) == 0 {\n\t\treturn \"\", false\n\t}\n\n\tswitch fieldpath[0] {\n\tcase \"id\":\n\t\treturn string(m.ID), len(m.ID) > 0\n\tcase \"image\":\n\t\treturn string(m.Image), len(m.Image) > 0\n\tcase \"runtime\":\n\t\t// NOTE(stevvooe): This is probably not correct in many cases.\n\t\t// We assume that the target message also implements the Field\n\t\t// method, which isn't likely true in a lot of cases.\n\t\t//\n\t\t// If you have a broken build and have found this comment,\n\t\t// you may be closer to a solution.\n\t\tif m.Runtime == nil {\n\t\t\treturn \"\", false\n\t\t}\n\n\t\treturn m.Runtime.Field(fieldpath[1:])\n\t}\n\treturn \"\", false\n}", "func (e HTTPRequestValidationError) Field() string { return e.field }", "func (m FieldMap) GetField(tag Tag, parser FieldValueReader) MessageRejectError {\n\ttagValues, ok := m.tagLookup[tag]\n\tif !ok {\n\t\treturn ConditionallyRequiredFieldMissing(tag)\n\t}\n\n\tif err := parser.Read(tagValues[0].value); err != nil {\n\t\treturn IncorrectDataFormatForValue(tag)\n\t}\n\n\treturn nil\n}", "func (e GetMovableObjectRequestValidationError) Field() string { return e.field }", "func (_DelegateProfile *DelegateProfileCallerSession) GetFieldByName(_name string) (struct {\n\tVerifier common.Address\n\tDeprecated bool\n}, error) {\n\treturn _DelegateProfile.Contract.GetFieldByName(&_DelegateProfile.CallOpts, _name)\n}", "func (_DelegateProfile *DelegateProfileSession) GetFieldByName(_name string) (struct {\n\tVerifier common.Address\n\tDeprecated bool\n}, error) {\n\treturn _DelegateProfile.Contract.GetFieldByName(&_DelegateProfile.CallOpts, _name)\n}", "func (o *CreateRiskRulesData) GetFieldOk() (*string, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn &o.Field, true\n}", "func (s UserSet) FieldGet(field models.FieldName) *models.FieldInfo {\n\tres := s.Collection().Call(\"FieldGet\", field)\n\tresTyped, _ := res.(*models.FieldInfo)\n\treturn resTyped\n}", "func (e CreateTodoRequestValidationError) Field() string { return e.field }", "func (m *message) GetMapFieldByName(name string) (f *MapField, ok bool) {\n\tm.mu.RLock()\n\tf, ok = m.mapFieldNameToMapField[name]\n\tm.mu.RUnlock()\n\treturn\n}", "func (e JsonToMetadataValidationError) Field() string { return e.field }", "func (e HeaderMatchValidationError) Field() string { return e.field }", "func (e CreateDisscussReqValidationError) Field() string { return e.field }", "func (e HelloRequestValidationError) Field() string { return e.field }", "func (m *RoomInfoMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase roominfo.FieldInfo:\n\t\treturn m.Info()\n\t}\n\treturn nil, false\n}", "func (f *Flow) getFieldInterface(field string) (_ interface{}, err error) {\n\tswitch field {\n\tcase \"Metric\":\n\t\treturn f.Metric, nil\n\tcase \"LastUpdateMetric\":\n\t\treturn f.LastUpdateMetric, nil\n\tcase \"TCPMetric\":\n\t\treturn f.TCPMetric, nil\n\tcase \"Link\":\n\t\treturn f.Link, nil\n\tcase \"Network\":\n\t\treturn f.Network, nil\n\tcase \"ICMP\":\n\t\treturn f.ICMP, nil\n\tcase \"Transport\":\n\t\treturn f.Transport, nil\n\t}\n\n\t// check extra layers\n\tif _, ok := extraLayersMap[field]; ok {\n\t\tif value, ok := lookupPath(*f, field, reflect.Struct); ok && value.IsValid() {\n\t\t\treturn value.Interface(), nil\n\t\t}\n\t}\n\n\treturn 0, getter.ErrFieldNotFound\n}", "func (e MinioComponentValidationError) Field() string { return e.field }", "func (e GetApplicationPubSubRequestValidationError) Field() string { return e.field }", "func (e JwtComponentValidationError) Field() string { return e.field }", "func (e ResolveRequestValidationError) Field() string { return e.field }", "func (rec *Record) GetField(name string) (Field, error) {\n\tfor _, fld := range rec.Fields {\n\t\tif fld.Name == name {\n\t\t\treturn fld, nil\n\t\t}\n\t}\n\treturn Field{}, fmt.Errorf(\"No Field named \\\"%s\\\" in Record \\\"%s\\\"\", name, rec.Name)\n}", "func (m *ccMetric) GetField(key string) (interface{}, bool) {\n\tv, ok := m.fields[key]\n\treturn v, ok\n}", "func (e CreatePurchaseRequestValidationError) Field() string { return e.field }", "func (m *ResourceMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase resource.FieldName:\n\t\treturn m.Name()\n\tcase resource.FieldType:\n\t\treturn m.GetType()\n\t}\n\treturn nil, false\n}", "func (e Matcher_OnMatchValidationError) Field() string { return e.field }", "func (m *MapValue) GetField(name string) (*MapField, bool) {\n\tfield, found := m.fieldMap[name]\n\treturn field, found\n}", "func (e JwtCacheConfigValidationError) Field() string { return e.field }", "func (typ *Type) Field(n string) (*Field, bool) {\n\tidx, ok := typ.fieldIdx[n]\n\tif !ok {\n\t\treturn nil, false\n\t}\n\treturn typ.Fields[idx], true\n}", "func (e Matcher_MatcherTree_MatchMapValidationError) Field() string { return e.field }", "func (m *ContainerUpdate) Field(fieldpath []string) (string, bool) {\n\tif len(fieldpath) == 0 {\n\t\treturn \"\", false\n\t}\n\n\tswitch fieldpath[0] {\n\tcase \"id\":\n\t\treturn string(m.ID), len(m.ID) > 0\n\tcase \"image\":\n\t\treturn string(m.Image), len(m.Image) > 0\n\tcase \"labels\":\n\t\t// Labels fields have been special-cased by name. If this breaks,\n\t\t// add better special casing to fieldpath plugin.\n\t\tif len(m.Labels) == 0 {\n\t\t\treturn \"\", false\n\t\t}\n\t\tvalue, ok := m.Labels[strings.Join(fieldpath[1:], \".\")]\n\t\treturn value, ok\n\tcase \"snapshot_key\":\n\t\treturn string(m.SnapshotKey), len(m.SnapshotKey) > 0\n\t}\n\treturn \"\", false\n}", "func (o *FieldError) GetFieldOk() (*string, bool) {\n\tif o == nil || o.Field == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Field, true\n}", "func (e CreateTodoResponseValidationError) Field() string { return e.field }", "func (m *StreetMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase street.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e HealthCheck_GrpcHealthCheckValidationError) Field() string { return e.field }", "func (m *PatientrecordMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase patientrecord.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e CreateMovableObjectRequestValidationError) Field() string { return e.field }", "func (e GetResponseValidationError) Field() string { return e.field }", "func (s *state) evalField(dot reflect.Value, fieldName string, node parse.Node, args []parse.Node, final, receiver reflect.Value) reflect.Value {\n\tif !receiver.IsValid() {\n\t\treturn zero\n\t}\n\ttyp := receiver.Type()\n\treceiver, _ = indirect(receiver)\n\t// Unless it's an interface, need to get to a value of type *T to guarantee\n\t// we see all methods of T and *T.\n\tptr := receiver\n\tif ptr.Kind() != reflect.Interface && ptr.CanAddr() {\n\t\tptr = ptr.Addr()\n\t}\n\tif method := ptr.MethodByName(fieldName); method.IsValid() {\n\t\treturn s.evalCall(dot, method, node, fieldName, args, final)\n\t}\n\thasArgs := len(args) > 1 || final.IsValid()\n\t// It's not a method; must be a field of a struct or an element of a map. The receiver must not be nil.\n\treceiver, isNil := indirect(receiver)\n\tif isNil {\n\t\ts.errorf(\"nil pointer evaluating %s.%s\", typ, fieldName)\n\t}\n\tswitch receiver.Kind() {\n\tcase reflect.Struct:\n\t\ttField, ok := receiver.Type().FieldByName(fieldName)\n\t\tif ok {\n\t\t\tfield := receiver.FieldByIndex(tField.Index)\n\t\t\tif tField.PkgPath != \"\" { // field is unexported\n\t\t\t\ts.errorf(\"%s is an unexported field of struct type %s\", fieldName, typ)\n\t\t\t}\n\t\t\t// If it's a function, we must call it.\n\t\t\tif hasArgs {\n\t\t\t\ts.errorf(\"%s has arguments but cannot be invoked as function\", fieldName)\n\t\t\t}\n\t\t\treturn field\n\t\t}\n\t\ts.errorf(\"%s is not a field of struct type %s\", fieldName, typ)\n\tcase reflect.Map:\n\t\t// If it's a map, attempt to use the field name as a key.\n\t\tnameVal := reflect.ValueOf(fieldName)\n\t\tif nameVal.Type().AssignableTo(receiver.Type().Key()) {\n\t\t\tif hasArgs {\n\t\t\t\ts.errorf(\"%s is not a method but has arguments\", fieldName)\n\t\t\t}\n\t\t\treturn receiver.MapIndex(nameVal)\n\t\t}\n\t}\n\ts.errorf(\"can't evaluate field %s in type %s\", fieldName, typ)\n\tpanic(\"not reached\")\n}", "func (e SimpleResponseValidationError) Field() string { return e.field }", "func (e MovableObjectValidationError) Field() string { return e.field }", "func (e GetUserRequestValidationError) Field() string { return e.field }", "func (e RequestValidationError) Field() string { return e.field }", "func (def *Definition) CheckField(name string) bool {\n\t_, ok := def.activeFields[name]\n\tif len(def.activeFields) == 0 && len(def.Values) > 0 {\n\t\treturn true\n\t}\n\tCentral.Log.Debugf(\"returning %v %d %d\", ok, len(def.activeFields), len(def.Values))\n\treturn ok\n}", "func (e MaintemplateComponentValidationError) Field() string { return e.field }", "func (o *RiskRulesListAllOfData) GetFieldOk() (*string, bool) {\n\tif o == nil || IsNil(o.Field) {\n\t\treturn nil, false\n\t}\n\treturn o.Field, true\n}", "func (e CreateRequestValidationError) Field() string { return e.field }", "func (e CreateRequestValidationError) Field() string { return e.field }", "func (e LoggingValidationError) Field() string { return e.field }", "func (e PassiveHealthCheckUnhealthyValidationError) Field() string { return e.field }", "func (e HelloResponseValidationError) Field() string { return e.field }", "func (e GetMessageRequestValidationError) Field() string { return e.field }", "func (e GetUserCommentReqValidationError) Field() string { return e.field }", "func (e CreateDisscusRespValidationError) Field() string { return e.field }", "func (e HealthCheck_RedisHealthCheckValidationError) Field() string { return e.field }", "func (e RanfunctionNameValidationError) Field() string { return e.field }", "func (e PassiveHealthCheckValidationError) Field() string { return e.field }", "func (e GcpComponentValidationError) Field() string { return e.field }", "func (e BodyResponseValidationError) Field() string { return e.field }", "func (e GetDisscusRespValidationError) Field() string { return e.field }", "func (e PurchaseValidationError) Field() string { return e.field }", "func (e ScopedRoutes_ScopeKeyBuilder_FragmentBuilder_HeaderValueExtractorValidationError) Field() string {\n\treturn e.field\n}", "func (e JsonToMetadata_RuleValidationError) Field() string { return e.field }", "func (m *GroupMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase group.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (m *LevelMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase level.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e JwtHeaderValidationError) Field() string { return e.field }", "func (e ActiveHealthCheckUnhealthyValidationError) Field() string { return e.field }", "func (d Document) GetField(field string) (interface{}, error) {\n\tif d.m != nil {\n\t\tx, ok := d.m[field]\n\t\tif !ok {\n\t\t\treturn nil, gcerr.Newf(gcerr.NotFound, nil, \"field %q not found in map\", field)\n\t\t}\n\t\treturn x, nil\n\t}\n\tpanic(\"unimplemented\")\n}", "func (e CreateDocV1RequestValidationError) Field() string { return e.field }", "func (r *ReflectMapper) FieldByName(v reflect.Value, name string) reflect.Value {\n\treturn r.mapper.FieldByName(v, name)\n}", "func (f Unstructured) Field(field string) Fragment {\n\tif f.fields != nil {\n\t\treturn f.fields[field]\n\t}\n\treturn nil\n}", "func (e JsonToMetadata_SelectorValidationError) Field() string { return e.field }" ]
[ "0.6989746", "0.6792741", "0.6542752", "0.6461606", "0.64479554", "0.6440115", "0.64128304", "0.64117295", "0.6288998", "0.62609345", "0.62533206", "0.6217395", "0.6214679", "0.61926746", "0.61853856", "0.61795163", "0.61721337", "0.6158753", "0.61470354", "0.61338425", "0.6122211", "0.6109387", "0.60985166", "0.6096451", "0.6092287", "0.6092287", "0.60605407", "0.6057582", "0.6056773", "0.60525995", "0.6049454", "0.60461026", "0.60381037", "0.6036499", "0.60348", "0.6032372", "0.6029774", "0.6028805", "0.60285956", "0.6015517", "0.60090804", "0.59983844", "0.5997523", "0.5995324", "0.59771544", "0.59737504", "0.5973336", "0.5970758", "0.59704757", "0.59678644", "0.5966693", "0.596552", "0.59644955", "0.59617525", "0.5955405", "0.59480494", "0.5947799", "0.5946009", "0.5945903", "0.5937695", "0.5936017", "0.5928487", "0.592617", "0.5925575", "0.59250814", "0.592502", "0.5923338", "0.5922731", "0.59206814", "0.59202963", "0.5918935", "0.5914424", "0.5911818", "0.59113127", "0.5910552", "0.5910552", "0.59067583", "0.5903325", "0.5902591", "0.59015524", "0.5899994", "0.58997047", "0.58992386", "0.5899057", "0.58975226", "0.5891486", "0.5890141", "0.58897257", "0.5888298", "0.58850574", "0.58822376", "0.5877016", "0.5875899", "0.5875742", "0.587493", "0.5874788", "0.58673865", "0.58670574", "0.5866519", "0.5866047" ]
0.74230164
0
Field returns a field with name
func (s *Structx) Field(name string) (*Fieldx, bool) { f, ok := s.value.Type().FieldByName(name) if !ok { return nil, false } ff := &Fieldx{ data: f, value: s.value.FieldByName(name), } return ff, true }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (msg *Message) Field(fieldName string) *Field {\n\treturn msg.fieldByName[fieldName]\n}", "func (f *Field) Field(name string) *Field {\n\tfield, ok := f.FieldOk(name)\n\tif !ok {\n\t\tpanic(\"field not found\")\n\t}\n\n\treturn field\n}", "func (p *GetField) Name() string { return p.name }", "func (entry *Entry) Field(name string) (value string, err error) {\n\tvalue, ok := entry.fields[name]\n\tif !ok {\n\t\terr = fmt.Errorf(\"field '%v' does not found in record %+v\", name, *entry)\n\t}\n\treturn\n}", "func Field(name, from, reference string) (string, error) {\n\treturn makeRequest(\"field\", name, from, reference)\n}", "func (i Item) GetField(name string) interface{} {\n\treturn getField(name, i.Payload)\n}", "func (v *Validator) Field(name string) (*app.Field, error) {\n\tfor _, field := range v.schema.Fields {\n\t\tif field.Name == name {\n\t\t\treturn field, nil\n\t\t}\n\t}\n\treturn nil, ErrNoField\n}", "func (i *Index) Field(name string) *Field {\n\ti.mu.RLock()\n\tdefer i.mu.RUnlock()\n\treturn i.field(name)\n}", "func (typ *Type) Field(n string) (*Field, bool) {\n\tidx, ok := typ.fieldIdx[n]\n\tif !ok {\n\t\treturn nil, false\n\t}\n\treturn typ.Fields[idx], true\n}", "func (e RanfunctionNameValidationError) Field() string { return e.field }", "func getField(fieldName string, data interface{}) (string, error) {\n\tr := reflect.ValueOf(data)\n\tval := reflect.Indirect(r).FieldByName(fieldName).Interface()\n\n\tswitch v := val.(type) {\n\tcase string:\n\t\treturn v, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"only string type is supported\")\n\t}\n}", "func (e IdentifierValidationError) Field() string { return e.field }", "func (db *DB) Field(name, field string) (fieldID uint8, typ influxql.DataType) {\n\t// Find measurement.\n\tm := db.measurements[name]\n\tif m == nil {\n\t\treturn\n\t}\n\n\t// Find field.\n\tf := m.fields[field]\n\tif f == nil {\n\t\treturn\n\t}\n\n\treturn f.id, f.typ\n}", "func (tbl *STable) Field(name string, alias ...string) IQueryField {\n\t// name = reflectutils.StructFieldName(name)\n\tname = utils.CamelSplit(name, \"_\")\n\tspec := tbl.spec.ColumnSpec(name)\n\tif spec == nil {\n\t\tlog.Warningf(\"column %s not found in table %s\", name, tbl.spec.Name())\n\t\treturn nil\n\t}\n\tcol := STableField{table: tbl, spec: spec}\n\tif len(alias) > 0 {\n\t\tcol.Label(alias[0])\n\t}\n\treturn &col\n}", "func (s *StructField) Field(name string) (*StructField, error) {\n\treturn Field(s.Value(), name)\n}", "func Field(v reflect.StructField) (name string, mapped bool) {\n\tns := v.Tag.Get(\"ns\")\n\tif ns != \"\" {\n\t\tmapped = true\n\t\tname = ns\n\t\treturn\n\t}\n\tname = v.Name\n\treturn\n}", "func (q *Query) GetField(name string) *Field {\n\tfor _, f := range q.Fields {\n\t\tif f.Name == name {\n\t\t\treturn f\n\t\t}\n\t}\n\treturn nil\n}", "func (e SimpleRequestValidationError) Field() string { return e.field }", "func (e GetRequestValidationError) Field() string { return e.field }", "func (e GetRequestValidationError) Field() string { return e.field }", "func Field(v interface{}, name string) (*Fieldx, bool) {\n\treturn New(v).Field(name)\n}", "func (e GetInstanceRequestValidationError) Field() string { return e.field }", "func (m *EventMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase event.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (f Unstructured) Field(field string) Fragment {\n\tif f.fields != nil {\n\t\treturn f.fields[field]\n\t}\n\treturn nil\n}", "func (rec *Record) GetField(name string) (Field, error) {\n\tfor _, fld := range rec.Fields {\n\t\tif fld.Name == name {\n\t\t\treturn fld, nil\n\t\t}\n\t}\n\treturn Field{}, fmt.Errorf(\"No Field named \\\"%s\\\" in Record \\\"%s\\\"\", name, rec.Name)\n}", "func (m *ContainerCreate_Runtime) Field(fieldpath []string) (string, bool) {\n\tif len(fieldpath) == 0 {\n\t\treturn \"\", false\n\t}\n\n\tswitch fieldpath[0] {\n\tcase \"name\":\n\t\treturn string(m.Name), len(m.Name) > 0\n\tcase \"options\":\n\t\tdecoded, err := github_com_containerd_typeurl.UnmarshalAny(m.Options)\n\t\tif err != nil {\n\t\t\treturn \"\", false\n\t\t}\n\n\t\tadaptor, ok := decoded.(interface{ Field([]string) (string, bool) })\n\t\tif !ok {\n\t\t\treturn \"\", false\n\t\t}\n\t\treturn adaptor.Field(fieldpath[1:])\n\t}\n\treturn \"\", false\n}", "func (e RanparameterNameValidationError) Field() string { return e.field }", "func (e GetEventByIDRequestValidationError) Field() string { return e.field }", "func (e GetMessageRequestValidationError) Field() string { return e.field }", "func (e ArfcnValidationError) Field() string { return e.field }", "func (s UserSet) FieldGet(field models.FieldName) *models.FieldInfo {\n\tres := s.Collection().Call(\"FieldGet\", field)\n\tresTyped, _ := res.(*models.FieldInfo)\n\treturn resTyped\n}", "func (m *PatientrecordMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase patientrecord.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (m *GroupMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase group.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (m *DiseaseMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase disease.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e GitopsCFValidationError) Field() string { return e.field }", "func (e HTTPRequestValidationError) Field() string { return e.field }", "func (e GetDisscusReqValidationError) Field() string { return e.field }", "func (m *LevelMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase level.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e LoggingValidationError) Field() string { return e.field }", "func (e EutracgiValidationError) Field() string { return e.field }", "func (e RanparameterDefItemValidationError) Field() string { return e.field }", "func (e DocValidationError) Field() string { return e.field }", "func (field Field) Name() string {\n\tif len(field.Names) > 0 {\n\t\treturn field.Names[0].String()\n\t}\n\n\t// The field has no name, so we use Type name as the field name.\n\treturn itemTypeName(field.TypeValue.Type).Name\n}", "func (e GetMovableObjectRequestValidationError) Field() string { return e.field }", "func (e PurchaseValidationError) Field() string { return e.field }", "func (m *StreetMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase street.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e RetrieveRequestValidationError) Field() string { return e.field }", "func (m *ResourceMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase resource.FieldName:\n\t\treturn m.Name()\n\tcase resource.FieldType:\n\t\treturn m.GetType()\n\t}\n\treturn nil, false\n}", "func FieldByName(name string) func(interface{}) interface{} {\n\treturn func(record interface{}) interface{} {\n\t\treturn reflect.ValueOf(record).FieldByName(name).Interface()\n\t}\n}", "func (e SkillValidationError) Field() string { return e.field }", "func (f *Flow) GetField(field string) (interface{}, error) {\n\tif i, err := f.getFieldInterface(field); err == nil {\n\t\treturn i, nil\n\t}\n\n\tif i, err := f.GetFieldInt64(field); err == nil {\n\t\treturn i, nil\n\t}\n\n\treturn f.GetFieldString(field)\n}", "func (e AdminValidationError) Field() string { return e.field }", "func (e TagSpecifierValidationError) Field() string { return e.field }", "func (v *ClassValue) field(s *scope, name string) Value {\n\tfield, ok := v.Fields[name]\n\tif !ok {\n\t\tpanic(fmt.Errorf(\"ClassValue %v did not contain field %v\", v.Type().Name(), name))\n\t}\n\treturn field\n}", "func (e PathCFValidationError) Field() string { return e.field }", "func fieldname(field *ast.Field) string {\n\treturn field.Names[0].Name\n}", "func (e CreateTodoRequestValidationError) Field() string { return e.field }", "func (e RanparameterItemValidationError) Field() string { return e.field }", "func (e RetrieveCurrentRequestValidationError) Field() string { return e.field }", "func (m *PermissionMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase permission.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e MovableObjectValidationError) Field() string { return e.field }", "func (e StatItem) GetField(key string) interface{} {\n\tswitch key {\n\tcase \"HeapAlloc\":\n\t\treturn e.HeapAlloc\n\tcase \"StackInuse\":\n\t\treturn e.StackInuse\n\tcase \"NumGC\":\n\t\treturn e.NumGC\n\tcase \"Goroutines\":\n\t\treturn e.Goroutines\n\tcase \"TotalAlloc\":\n\t\treturn e.TotalAlloc\n\tcase \"Mallocs\":\n\t\treturn e.Mallocs\n\tcase \"Frees\":\n\t\treturn e.Frees\n\tcase \"HeapObjects\":\n\t\treturn e.HeapObjects\n\tcase \"GCCPUFraction\":\n\t\treturn e.GCCPUFraction\n\tcase \"GCPauseUs\":\n\t\treturn e.GCPauseUs\n\t}\n\treturn nil\n}", "func (e ResolveRequestValidationError) Field() string { return e.field }", "func (e RdsValidationError) Field() string { return e.field }", "func (e RanparameterIdValidationError) Field() string { return e.field }", "func (e MaintemplateComponentValidationError) Field() string { return e.field }", "func (e MessageDValidationError) Field() string { return e.field }", "func (e ScopedRdsValidationError) Field() string { return e.field }", "func (e JwtComponentValidationError) Field() string { return e.field }", "func (c *Column) Field() string {\n\treturn c.field\n}", "func (e GetResponseValidationError) Field() string { return e.field }", "func (e RequestValidationError) Field() string { return e.field }", "func (e NrarfcnValidationError) Field() string { return e.field }", "func (e NoOneofsValidationError) Field() string { return e.field }", "func (e GetUserRequestValidationError) Field() string { return e.field }", "func (s *StructLike) GetField(name string) (*Field, bool) {\n\tfor _, fi := range s.Fields {\n\t\tif fi.Name == name {\n\t\t\treturn fi, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func (e CreatePaymentRequestValidationError) Field() string { return e.field }", "func (e GetDisscusRespValidationError) Field() string { return e.field }", "func (e PublishRequestValidationError) Field() string { return e.field }", "func (t *Type) Field(i int) *Field", "func (e GetApplicationPubSubRequestValidationError) Field() string { return e.field }", "func (e RetrievePaymentRequestValidationError) Field() string { return e.field }", "func (m *TenantMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase tenant.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e CacheValidationError) Field() string { return e.field }", "func (m *CleanernameMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase cleanername.FieldCleanername:\n\t\treturn m.Cleanername()\n\t}\n\treturn nil, false\n}", "func (c *Checker) getFieldName(field reflect.StructField) string {\n\tname := field.Name\n\tif c.JSONTag != nil {\n\t\tif val, ok := field.Tag.Lookup(\"json\"); ok {\n\t\t\tname = strings.Split(val, \",\")[0]\n\t\t}\n\t}\n\tif name == \"-\" {\n\t\tif !c.JSONTag.IgnoreDashFields {\n\t\t\tname = field.Name\n\t\t}\n\t}\n\treturn name\n}", "func (e BitStringValidationError) Field() string { return e.field }", "func (e ManifestProjectCFValidationError) Field() string { return e.field }", "func (m *ExchangeMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase exchange.FieldCode:\n\t\treturn m.Code()\n\tcase exchange.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e ApplicationPubSubValidationError) Field() string { return e.field }", "func (e CreatePurchaseRequestValidationError) Field() string { return e.field }", "func (e MatcherValidationError) Field() string { return e.field }", "func (e RetrieveMyCardsRequestValidationError) Field() string { return e.field }", "func (e GetInstanceResponseValidationError) Field() string { return e.field }", "func (e SXGValidationError) Field() string { return e.field }", "func (e SimpleResponseValidationError) Field() string { return e.field }", "func (e NrtValidationError) Field() string { return e.field }", "func (e GetEventByIDResponseValidationError) Field() string { return e.field }", "func (e NrcgiValidationError) Field() string { return e.field }", "func (e ChannelPayRequestValidationError) Field() string { return e.field }" ]
[ "0.7775857", "0.77345854", "0.74935126", "0.73585737", "0.7355919", "0.73011225", "0.7235797", "0.71676767", "0.70273715", "0.7023392", "0.7013657", "0.6991286", "0.69764125", "0.6976257", "0.69483006", "0.6941868", "0.6929807", "0.69133073", "0.69127744", "0.69127744", "0.6887245", "0.68830323", "0.6865768", "0.68641937", "0.68576205", "0.6827762", "0.6822214", "0.6808312", "0.68078387", "0.6800825", "0.6797324", "0.6793458", "0.67859876", "0.67857474", "0.67818385", "0.67783284", "0.6771548", "0.6764539", "0.67530245", "0.6751863", "0.67483616", "0.67482626", "0.6746906", "0.67464006", "0.67458874", "0.6742949", "0.6741088", "0.6740917", "0.6737908", "0.673625", "0.67333126", "0.6731638", "0.67276543", "0.6724225", "0.67225415", "0.67169154", "0.6712727", "0.6712214", "0.6707202", "0.67068595", "0.6704307", "0.66984195", "0.6695589", "0.66878045", "0.6687594", "0.6683799", "0.6682492", "0.668221", "0.66790557", "0.667469", "0.6674543", "0.66718996", "0.66714203", "0.66683507", "0.6667785", "0.6666932", "0.66648155", "0.66608775", "0.66599435", "0.6659827", "0.6658803", "0.6655476", "0.66506517", "0.66503465", "0.6648327", "0.6647826", "0.6646551", "0.664473", "0.66435385", "0.66428894", "0.6641389", "0.6640816", "0.66392326", "0.6639018", "0.6638517", "0.66381454", "0.66374624", "0.6637279", "0.66348237", "0.6630783" ]
0.67714995
37
IsStruct returns if field name is a struct
func (s *Structx) IsStruct(name string) bool { f, ok := s.Field(name) if !ok { return false } return IsStruct(f.Value()) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func isStruct(aType *toolbox.TypeInfo) bool {\n\treturn len(aType.Fields()) > 0\n}", "func IsStruct(value interface{}) bool {\n\treturn kindOf(value) == reflect.Struct\n}", "func (f *Frugal) IsStruct(t *Type) bool {\n\tt = f.UnderlyingType(t)\n\tif _, ok := frugalBaseTypes[t.Name]; ok {\n\t\treturn false\n\t}\n\treturn t.KeyType == nil && t.ValueType == nil && !f.IsEnum(t)\n}", "func structFieldByName(typ reflect.Type, name string) (*reflect.StructField, bool) {\n\tvar field *reflect.StructField\n\n\tfieldNames := chainedFieldNameToFieldNames(name)\n\tif len(fieldNames) == 0 {\n\t\treturn nil, false\n\t}\n\n\tfor i, fieldName := range fieldNames {\n\t\tf, ok := typ.FieldByName(fieldName)\n\t\tif !ok {\n\t\t\treturn nil, false\n\t\t}\n\t\tfield = &f\n\n\t\tif i == len(fieldNames)-1 {\n\t\t\tbreak\n\t\t}\n\n\t\ttyp = f.Type\n\t\tif typ.Kind() == reflect.Ptr {\n\t\t\ttyp = typ.Elem()\n\t\t}\n\t}\n\n\treturn field, true\n}", "func (ctx *ASTNodeTypeInfo) IsStruct() bool {\n\t_, ok := ctx.Type.Underlying().(*types.Struct)\n\treturn ok\n}", "func IsStruct(v interface{}) bool {\n\tr := elconv.AsValueRef(reflect.ValueOf(v))\n\treturn r.Kind() == reflect.Struct\n}", "func isStructType(v interface{}) bool {\n\treturn !isBasicType(v) && !isListType(v) && !isMapType(v) && !isEnumType(v)\n}", "func (L *State) IsGoStruct(index int) bool {\n\treturn C.clua_isgostruct(L.s, C.int(index)) != 0\n}", "func IsStruct(v interface{}) bool {\n\tvv := reflect.ValueOf(v)\n\tif vv.Kind() == reflect.Ptr {\n\t\tvv = vv.Elem()\n\t}\n\n\treturn vv.Kind() == reflect.Struct\n}", "func (*Component_Subcomponent) IsYANGGoStruct() {}", "func IsStruct(v interface{}) bool {\n\tt := reflect.TypeOf(v)\n\tif t.Kind() == reflect.Ptr {\n\t\tt = t.Elem()\n\t}\n\treturn t.Kind() == reflect.Struct\n}", "func (*Component) IsYANGGoStruct() {}", "func IsStructFieldExist(structObject interface{}, FieldName string) bool {\n\tValueInterface := reflect.ValueOf(structObject)\n\t// Check if the passed interface is a pointer\n\tif ValueInterface.Type().Kind() != reflect.Ptr {\n\t\t// Create a new type of structObject's Type, so we have a pointer to work with\n\t\tValueInterface = reflect.New(reflect.TypeOf(structObject))\n\t}\n\t// 'dereference' with Elem() and get the field by name\n\tField := ValueInterface.Elem().FieldByName(FieldName)\n\tif !Field.IsValid() {\n\t\treturn false\n\t}\n\treturn true\n}", "func (c *TypeConverter) isRecursiveStruct(fields []*compile.FieldSpec) bool {\n\tfor _, field := range fields {\n\t\tif isRecursiveStruct(field.Type, make(map[string]bool)) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (*Component_Property) IsYANGGoStruct() {}", "func isRecursiveStruct(spec compile.TypeSpec, seenSoFar map[string]bool) bool {\n\tswitch t := spec.(type) {\n\tcase *compile.StructSpec:\n\t\t// detected cycle; second time seeing this type\n\t\tif _, found := seenSoFar[t.Name]; found {\n\t\t\treturn true\n\t\t}\n\n\t\t// mark this type as seen\n\t\tseenSoFar[t.Name] = true\n\n\t\t// search all fields of this struct\n\t\tfor _, field := range t.Fields {\n\t\t\tif isRecursiveStruct(field.Type, seenSoFar) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\n\t\t// unmark\n\t\tdelete(seenSoFar, t.Name)\n\n\t// for lists and maps, check element/key types the same way\n\tcase *compile.MapSpec:\n\t\tif isRecursiveStruct(t.KeySpec, seenSoFar) || isRecursiveStruct(t.ValueSpec, seenSoFar) {\n\t\t\treturn true\n\t\t}\n\tcase *compile.ListSpec:\n\t\tif isRecursiveStruct(t.ValueSpec, seenSoFar) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func (*Component_Port) IsYANGGoStruct() {}", "func isNeCrossStructField(fl FieldLevel) bool {\n\tfield := fl.Field()\n\tkind := field.Kind()\n\n\ttopField, currentKind, ok := fl.GetStructFieldOK()\n\tif !ok || currentKind != kind {\n\t\treturn true\n\t}\n\n\tswitch kind {\n\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn topField.Int() != field.Int()\n\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn topField.Uint() != field.Uint()\n\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn topField.Float() != field.Float()\n\n\tcase reflect.Slice, reflect.Map, reflect.Array:\n\t\treturn int64(topField.Len()) != int64(field.Len())\n\n\tcase reflect.Bool:\n\t\treturn topField.Bool() != field.Bool()\n\n\tcase reflect.Struct:\n\n\t\tfieldType := field.Type()\n\n\t\tif fieldType.ConvertibleTo(timeType) && topField.Type().ConvertibleTo(timeType) {\n\n\t\t\tt := field.Convert(timeType).Interface().(time.Time)\n\t\t\tfieldTime := topField.Convert(timeType).Interface().(time.Time)\n\n\t\t\treturn !fieldTime.Equal(t)\n\t\t}\n\n\t\t// Not Same underlying type i.e. struct and time\n\t\tif fieldType != topField.Type() {\n\t\t\treturn true\n\t\t}\n\t}\n\n\t// default reflect.String:\n\treturn topField.String() != field.String()\n}", "func (v *Validator) Struct(structure interface{}) (bool, error) {\n\tif err := v.Validate.Struct(structure); err != nil {\n\t\treturn false, fmt.Errorf(\"invalid structure: %w\", err)\n\t}\n\n\treturn true, nil\n}", "func (*Visibility_Visibility_Visibility) IsYANGGoStruct() {}", "func (*Device) IsYANGGoStruct() {}", "func (*Device) IsYANGGoStruct() {}", "func (*Device) IsYANGGoStruct() {}", "func (*Device) IsYANGGoStruct() {}", "func (*Device) IsYANGGoStruct() {}", "func (*Device) IsYANGGoStruct() {}", "func (*Device) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A_List5) IsYANGGoStruct() {}", "func (t *Type) IsFuncArgStruct() bool", "func (*Component_Fan) IsYANGGoStruct() {}", "func (*Component_Memory) IsYANGGoStruct() {}", "func (*Test1_Cont1A_Cont2D) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A_List4) IsYANGGoStruct() {}", "func (*Component_Storage) IsYANGGoStruct() {}", "func GetStructFieldByName(st interface{}, fieldName string) interface{} {\n\tstv := reflect.ValueOf(st)\n\tif IsPtr(st) {\n\t\tstv = stv.Elem()\n\t}\n\n\tv := stv.FieldByName(fieldName)\n\tif !v.IsValid() {\n\t\treturn nil\n\t}\n\n\tswitch v.Kind() {\n\tcase reflect.Chan,\n\t\treflect.Func,\n\t\treflect.Slice,\n\t\treflect.Array,\n\t\treflect.Interface,\n\t\treflect.Ptr,\n\t\treflect.Map:\n\t\tif v.IsNil() {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\treturn v.Interface()\n}", "func lookupFieldInStruct(reflectValue reflect.Value, name string) (interface{}, bool) {\n\tfield := reflectValue.FieldByName(name)\n\tif field.IsValid() {\n\t\treturn field.Interface(), truth(field)\n\t}\n\tmethod := reflectValue.MethodByName(name)\n\tif method.IsValid() && method.Type().NumIn() == 1 {\n\t\tout := method.Call(nil)[0]\n\t\treturn out.Interface(), truth(out)\n\t}\n\treturn nil, false\n}", "func (*Component_Backplane) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A_Cont2D) IsYANGGoStruct() {}", "func (src Source) IsStructMap() {}", "func (*UseCase_UseCase) IsYANGGoStruct() {}", "func (*DeviceGroup_DeviceGroup_DeviceGroup) IsYANGGoStruct() {}", "func (*UseCase_UseCase_UseCase) IsYANGGoStruct() {}", "func (*Test1_Cont1A_Cont2A) IsYANGGoStruct() {}", "func (*UseCase_UseCase_UseCase_Visibility) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A) IsYANGGoStruct() {}", "func (*Component_Cpu) IsYANGGoStruct() {}", "func (t *Thrift) GetStruct(name string) (*StructLike, bool) {\n\tfor _, st := range t.Structs {\n\t\tif st.Name == name {\n\t\t\treturn st, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func (*Test1_Cont1A_List2A) IsYANGGoStruct() {}", "func IsStructObject(data interface{}) bool {\n\treturn typeIs(data, reflect.Struct)\n}", "func (*Test1_Cont1BState_List2B) IsYANGGoStruct() {}", "func (*DeviceGroup_DeviceGroup) IsYANGGoStruct() {}", "func fieldExists(typ reflect.Type, name string) bool {\n\tfields := chainedFieldNameToFieldNames(name)\n\n\tfor i, field := range fields {\n\t\tf, ok := typ.FieldByName(field)\n\t\tif !ok {\n\t\t\treturn false\n\t\t}\n\n\t\tif i == len(fields)-1 {\n\t\t\tbreak\n\t\t}\n\n\t\t// TODO: Optimize me for only type struct or *struct is valid\n\t\ttyp = f.Type\n\t\tif typ.Kind() == reflect.Ptr {\n\t\t\ttyp = typ.Elem()\n\t\t}\n\t}\n\n\treturn true\n}", "func (*OnfTest1_Cont1A_Cont2A) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A_Cont2A) IsYANGGoStruct() {}", "func (obj *object) getStructName(line string) {\n\t/*nested := false\n\tif !strings.Contains(line, \"type \") {\n\t\tnested = true\n\t}*/\n\n\tline = strings.TrimSpace(line)\n\tline = strings.TrimPrefix(strings.TrimSuffix(line, \"{\"), \"type\")\n\tline = strings.TrimSpace(line)\n\tobj.Name = strings.TrimSpace(strings.TrimSuffix(line, \"struct\"))\n\tif strings.Contains(obj.Name, \"[]\") {\n\t\tobj.Name = strings.TrimSpace(strings.TrimSuffix(obj.Name, \"[]\"))\n\t}\n\tobj.Tp = obj.Name\n\tobj.JsonKey = obj.Name\n\t/*if nested {\n\t\tobj.CommonFileds = append(obj.CommonFileds, &field{JsonKey: obj.Name, Tp: obj.Name})\n\t}*/\n}", "func (*Visibility_Visibility) IsYANGGoStruct() {}", "func (*OnfTest1_List1A) IsYANGGoStruct() {}", "func (*OnfTest1Choice_Vehicle) IsYANGGoStruct() {}", "func (*Test1_Cont1BState_Cont2C) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A_List2A) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A_List2A) IsYANGGoStruct() {}", "func (ds *DynamicStruct) FieldByName(name string) (reflect.StructField, bool) {\n\treturn ds.rt.FieldByName(name)\n}", "func (*UseCase_UseCase_UseCase_DeviceGroup) IsYANGGoStruct() {}", "func isNeField(fl FieldLevel) bool {\n\tfield := fl.Field()\n\tkind := field.Kind()\n\n\tcurrentField, currentKind, ok := fl.GetStructFieldOK()\n\n\tif !ok || currentKind != kind {\n\t\treturn true\n\t}\n\n\tswitch kind {\n\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn field.Int() != currentField.Int()\n\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn field.Uint() != currentField.Uint()\n\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn field.Float() != currentField.Float()\n\n\tcase reflect.Slice, reflect.Map, reflect.Array:\n\t\treturn int64(field.Len()) != int64(currentField.Len())\n\n\tcase reflect.Bool:\n\t\treturn field.Bool() != currentField.Bool()\n\n\tcase reflect.Struct:\n\n\t\tfieldType := field.Type()\n\n\t\tif fieldType.ConvertibleTo(timeType) && currentField.Type().ConvertibleTo(timeType) {\n\n\t\t\tt := currentField.Interface().(time.Time)\n\t\t\tfieldTime := field.Interface().(time.Time)\n\n\t\t\treturn !fieldTime.Equal(t)\n\t\t}\n\n\t\t// Not Same underlying type i.e. struct and time\n\t\tif fieldType != currentField.Type() {\n\t\t\treturn true\n\t\t}\n\t}\n\n\t// default reflect.String:\n\treturn field.String() != currentField.String()\n}", "func (*Test1_Cont1A) IsYANGGoStruct() {}", "func IsValueStruct(v reflect.Value) bool {\n\treturn v.Kind() == reflect.Struct\n}", "func (*OnfTest1_Cont1BState) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1BState) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1A_List4_List4A) IsYANGGoStruct() {}", "func (*Component_Fabric) IsYANGGoStruct() {}", "func (*Test1_Cont1BState) IsYANGGoStruct() {}", "func (*OpenconfigLacp_Lacp_Interfaces_Interface_Members_Member) IsYANGGoStruct() {}", "func (*OpenconfigLacp_Lacp_Interfaces_Interface_Members_Member_State) IsYANGGoStruct() {}", "func (*MapStructTestOne) IsYANGGoStruct() {}", "func isSameStruct(firstVal, secondVal reflect.Value) (ret bool, err error) {\n\tfirstNum := firstVal.NumField()\n\tsecondNum := secondVal.NumField()\n\tif firstNum != secondNum {\n\t\tret = false\n\t\treturn\n\t}\n\n\tfor idx := 0; idx < firstNum; idx++ {\n\t\tfirstField := firstVal.Field(idx)\n\t\tsecondField := secondVal.Field(idx)\n\t\tret, err = IsSameVal(firstField, secondField)\n\t\tif !ret || err != nil {\n\t\t\tret = false\n\t\t\treturn\n\t\t}\n\t}\n\n\tret = true\n\treturn\n}", "func (*Component_Temperature) IsYANGGoStruct() {}", "func (*OnfTest1Choice_Vehicle_UnderCarriage) IsYANGGoStruct() {}", "func (*Component_Transceiver) IsYANGGoStruct() {}", "func (field Field) Struct() *Struct {\n\treturn field.Parent.Parent.Parent.StructByName(field.Field.ItemTypeName().Name)\n}", "func (*Component_Chassis) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1BState_List2B) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1BState_List2B) IsYANGGoStruct() {}", "func (*Enterprise_Enterprise_Enterprise) IsYANGGoStruct() {}", "func (*OnfSwitch_Switch_Port) IsYANGGoStruct() {}", "func (*Component_OpticalPort) IsYANGGoStruct() {}", "func isStructPtr(t reflect.Type) bool {\n\treturn t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Struct\n}", "func (*MapStructTestOneChild) IsYANGGoStruct() {}", "func isLteCrossStructField(fl FieldLevel) bool {\n\tfield := fl.Field()\n\tkind := field.Kind()\n\n\ttopField, topKind, ok := fl.GetStructFieldOK()\n\tif !ok || topKind != kind {\n\t\treturn false\n\t}\n\n\tswitch kind {\n\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn field.Int() <= topField.Int()\n\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn field.Uint() <= topField.Uint()\n\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn field.Float() <= topField.Float()\n\n\tcase reflect.Slice, reflect.Map, reflect.Array:\n\t\treturn int64(field.Len()) <= int64(topField.Len())\n\n\tcase reflect.Struct:\n\n\t\tfieldType := field.Type()\n\n\t\tif fieldType.ConvertibleTo(timeType) && topField.Type().ConvertibleTo(timeType) {\n\n\t\t\tfieldTime := field.Convert(timeType).Interface().(time.Time)\n\t\t\ttopTime := topField.Convert(timeType).Interface().(time.Time)\n\n\t\t\treturn fieldTime.Before(topTime) || fieldTime.Equal(topTime)\n\t\t}\n\n\t\t// Not Same underlying type i.e. struct and time\n\t\tif fieldType != topField.Type() {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// default reflect.String:\n\treturn field.String() <= topField.String()\n}", "func (*OnfSwitchModel_SwitchModel_Port) IsYANGGoStruct() {}", "func (*OnfTest1_Cont1BState_Cont2C) IsYANGGoStruct() {}", "func (*OnfTest1Choice_Vehicle_ElectricMotor) IsYANGGoStruct() {}", "func (*DeviceRange_DeviceRange_DeviceRange_DeviceGroup) IsYANGGoStruct() {}", "func (*OnfSwitchModel_SwitchModel_Attribute) IsYANGGoStruct() {}", "func typeIsPointerToStruct(typ reflect.Type) bool {\n\treturn typ.Kind() == reflect.Ptr && typ.Elem().Kind() == reflect.Struct\n}", "func (*OnfTest1Choice_Vehicle_Battery) IsYANGGoStruct() {}", "func (f *FieldHandler) StructField() reflect.StructField {\n\treturn f.field.structField\n}", "func (*Enterprise_Enterprise) IsYANGGoStruct() {}", "func IsStructMethodExist(structObject interface{}, MethodName string) bool {\n\tValueInterface := reflect.ValueOf(structObject)\n\t// Check if the passed interface is a pointer\n\tif ValueInterface.Type().Kind() != reflect.Ptr {\n\t\t// Create a new type of structObject, so we have a pointer to work with\n\t\tValueInterface = reflect.New(reflect.TypeOf(structObject))\n\t}\n\t// Get the method by name\n\tMethod := ValueInterface.MethodByName(MethodName)\n\tif !Method.IsValid() {\n\t\treturn false\n\t}\n\treturn true\n}", "func (*OnfSwitch_Switch_Attribute) IsYANGGoStruct() {}" ]
[ "0.7687825", "0.72234344", "0.70588535", "0.6954803", "0.69227856", "0.68713754", "0.6829933", "0.6793955", "0.6726297", "0.6669709", "0.6660877", "0.6638737", "0.6592279", "0.65219784", "0.64682996", "0.6446459", "0.64411604", "0.6427048", "0.63174933", "0.63074785", "0.6306086", "0.6306086", "0.6306086", "0.6306086", "0.6306086", "0.6306086", "0.6306086", "0.63030964", "0.62996906", "0.6298934", "0.6291637", "0.6269611", "0.62437433", "0.62374884", "0.62217903", "0.6198873", "0.6188339", "0.6177289", "0.61762214", "0.61630154", "0.6159126", "0.615721", "0.61448395", "0.6141996", "0.6137582", "0.6137582", "0.61363167", "0.6135836", "0.61241096", "0.611124", "0.60993457", "0.60917175", "0.6085013", "0.6061101", "0.6061101", "0.605988", "0.6054832", "0.60490036", "0.60486007", "0.60402304", "0.6034436", "0.6034436", "0.6033761", "0.60177004", "0.6012796", "0.601239", "0.60113657", "0.60092294", "0.60092294", "0.6007906", "0.6005322", "0.6000908", "0.59988284", "0.59901655", "0.598212", "0.5979797", "0.5978817", "0.5976413", "0.5961827", "0.5960154", "0.5935538", "0.5924243", "0.5924243", "0.5918676", "0.59151703", "0.5913807", "0.59087884", "0.59062904", "0.5901296", "0.58974266", "0.5892587", "0.58773184", "0.58772284", "0.58771205", "0.58639824", "0.5858363", "0.5855381", "0.58462954", "0.5843257", "0.5843025" ]
0.76137424
1
Set set value to the field name, must be exported field
func (s *Structx) Set(name string, value interface{}) error { f, ok := s.Field(name) if !ok { return ErrNotField } return f.Set(value) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *Actionmap) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Wfmagent) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *SeriesMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase series.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Series field %s\", name)\n}", "func (o *Directrouting) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (r *Wrapper) Set(name string, val any) error {\n\tfv := r.rv.FieldByName(name)\n\tif !fv.IsValid() {\n\t\treturn errors.New(\"field not found\")\n\t}\n\n\tif !fv.CanSet() {\n\t\treturn errors.New(\"field can not set value\")\n\t}\n\n\tfv.Set(reflect.ValueOf(val))\n\treturn nil\n}", "func (o *Createshareresponse) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Workitemwrapup) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Integrationtype) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *ModelStructRecord) SetField(name string, value reflect.Value) {\n\tif name == \"\" {\n\t\treturn\n\t}\n\tfieldValue := m.FieldValues[name]\n\t//if value.Kind() == reflect.Ptr {\n\t//\tpanic(\"RecordFieldSetError: value cannot be a ptr\")\n\t//}\n\tif fieldValue.IsValid() == false {\n\t\tm.VirtualFieldValues[name] = reflect.New(m.model.GetFieldWithName(name).StructField().Type).Elem()\n\t\tfieldValue = m.VirtualFieldValues[name]\n\t}\n\t//fieldValue = LoopIndirectAndNew(fieldValue)\n\tsafeSet(fieldValue, value)\n}", "func (m *DiseaseMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase disease.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Disease field %s\", name)\n}", "func (o *Webchatmemberinfo) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *ExchangeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase exchange.FieldCode:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCode(v)\n\t\treturn nil\n\tcase exchange.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Exchange field %s\", name)\n}", "func (m *ToolMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase tool.FieldToolName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetToolName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Tool field %s\", name)\n}", "func (o *Wfmbushorttermforecastimportcompletetopicbuforecastmodification) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (df *DataFrame) SetField(name string, val starlark.Value) error {\n\tif df.frozen {\n\t\treturn fmt.Errorf(\"cannot set, DataFrame is frozen\")\n\t}\n\n\tif name == \"columns\" {\n\t\tidx, ok := val.(*Index)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"cannot assign to 'columns', wrong type\")\n\t\t}\n\t\tdf.columns = idx\n\t\treturn nil\n\t}\n\treturn starlark.NoSuchAttrError(name)\n}", "func setField(obj interface{}, name string, value interface{}) error {\n\tstructValue := reflect.ValueOf(obj).Elem()\n\tstructFieldValue := structValue.FieldByName(name)\n\n\tif !structFieldValue.IsValid() {\n\t\treturn fmt.Errorf(\"No such field: %s in obj\", name)\n\t}\n\n\tif !structFieldValue.CanSet() {\n\t\treturn fmt.Errorf(\"Cannot set %s field value\", name)\n\t}\n\n\tstructFieldType := structFieldValue.Type()\n\n\tvar val reflect.Value\n\tswitch structFieldType.String() {\n\tcase \"int\":\n\t\ti, _ := strconv.Atoi(value.(js.Value).String())\n\t\tval = reflect.ValueOf(i)\n\t\tbreak\n\tcase \"float64\":\n\t\ti, _ := strconv.ParseFloat(value.(js.Value).String(), 64)\n\t\tval = reflect.ValueOf(i)\n\t\tbreak\n\tcase \"bool\":\n\t\ti, _ := strconv.ParseBool(value.(js.Value).String())\n\t\tval = reflect.ValueOf(i)\n\t\tbreak\n\tcase \"string\":\n\t\tval = reflect.ValueOf(value.(js.Value).String())\n\t\tbreak\n\tdefault:\n\t\tval = reflect.ValueOf(value)\n\t\tbreak\n\t}\n\n\tstructFieldValue.Set(val)\n\treturn nil\n}", "func (o *Appevent) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *CompanyMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase company.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Company field %s\", name)\n}", "func (m *EventMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase event.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Event field %s\", name)\n}", "func (m *GroupMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase group.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Group field %s\", name)\n}", "func (m *StreetMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase street.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Street field %s\", name)\n}", "func setValueByName(target interface{}, fieldName string, fieldValue interface{}) (err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = exception.Newf(\"Error setting field: %v\", r)\n\t\t}\n\t}()\n\ttypeCheck := reflect.TypeOf(target)\n\tif typeCheck.Kind() != reflect.Ptr {\n\t\treturn exception.New(\"Cannot modify non-pointer target\")\n\t}\n\n\ttargetValue := reflectValue(target)\n\ttargetType := reflectType(target)\n\trelevantField, hasField := targetType.FieldByName(fieldName)\n\n\tif !hasField {\n\t\treturn exception.Newf(\"Field not found %s.%s\", targetType.Name(), fieldName)\n\t}\n\n\tfield := targetValue.FieldByName(relevantField.Name)\n\tfieldType := field.Type()\n\tif !field.CanSet() {\n\t\treturn exception.Newf(\"Cannot set field %s\", fieldName)\n\t}\n\n\tvalueReflected := reflectValue(fieldValue)\n\tif !valueReflected.IsValid() {\n\t\treturn exception.New(\"Reflected value is invalid, cannot continue.\")\n\t}\n\n\tif valueReflected.Type().AssignableTo(fieldType) {\n\t\tfield.Set(valueReflected)\n\t\treturn nil\n\t}\n\n\tif field.Kind() == reflect.Ptr {\n\t\tif valueReflected.CanAddr() {\n\t\t\tconvertedValue := valueReflected.Convert(fieldType.Elem())\n\t\t\tif convertedValue.CanAddr() {\n\t\t\t\tfield.Set(convertedValue.Addr())\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\treturn exception.New(\"Cannot take address of value for assignment to field pointer\")\n\t}\n\n\tif fieldAsString, isString := valueReflected.Interface().(string); isString {\n\t\tvar parsedValue reflect.Value\n\t\thandledType := true\n\t\tswitch fieldType.Kind() {\n\t\tcase reflect.Int:\n\t\t\tintValue, err := strconv.Atoi(fieldAsString)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(intValue)\n\t\tcase reflect.Int64:\n\t\t\tint64Value, err := strconv.ParseInt(fieldAsString, 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(int64Value)\n\t\tcase reflect.Uint16:\n\t\t\tintValue, err := strconv.Atoi(fieldAsString)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(uint16(intValue))\n\t\tcase reflect.Uint: //a.k.a. uint32\n\t\t\tintValue, err := strconv.Atoi(fieldAsString)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(uint(intValue))\n\t\tcase reflect.Uint32:\n\t\t\tintValue, err := strconv.Atoi(fieldAsString)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(uint32(intValue))\n\t\tcase reflect.Uint64:\n\t\t\tintValue, err := strconv.Atoi(fieldAsString)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(uint64(intValue))\n\t\tcase reflect.Float32:\n\t\t\tfloatValue, err := strconv.ParseFloat(fieldAsString, 32)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(floatValue)\n\t\tcase reflect.Float64:\n\t\t\tfloatValue, err := strconv.ParseFloat(fieldAsString, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(floatValue)\n\t\tdefault:\n\t\t\thandledType = false\n\t\t}\n\t\tif handledType {\n\t\t\tfield.Set(parsedValue)\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tconvertedValue := valueReflected.Convert(fieldType)\n\tif convertedValue.IsValid() && convertedValue.Type().AssignableTo(fieldType) {\n\t\tfield.Set(convertedValue)\n\t\treturn nil\n\t}\n\n\treturn exception.New(\"Couldnt set field %s.%s\", targetType.Name(), fieldName)\n}", "func (f *Field) Set(val interface{}) error {\n\t// we can't set unexported fields, so be sure this field is exported\n\tif !f.IsExported() {\n\t\treturn errNotExported\n\t}\n\n\t// do we get here? not sure...\n\tif !f.value.CanSet() {\n\t\treturn errNotSettable\n\t}\n\n\tgiven := reflect.ValueOf(val)\n\n\tif f.value.Kind() != given.Kind() {\n\t\treturn fmt.Errorf(\"wrong kind. got: %s want: %s\", given.Kind(), f.value.Kind())\n\t}\n\n\tf.value.Set(given)\n\treturn nil\n}", "func (m *BedtypeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase bedtype.FieldBedtypename:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetBedtypename(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Bedtype field %s\", name)\n}", "func (m *NametitleMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase nametitle.FieldTitle:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetTitle(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Nametitle field %s\", name)\n}", "func (o *Oauthclientrequest) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *DataSourceMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase datasource.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase datasource.FieldAddress:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddress(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown DataSource field %s\", name)\n}", "func (o *Wfmintradaydataupdatetopicintradayhistoricalqueuedata) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *StatusdMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase statusd.FieldStatusdname:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetStatusdname(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Statusd field %s\", name)\n}", "func (o *Posttextresponse) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Contentmanagementworkspacedocumentstopicdocumentdatav2) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func Set(target, source interface{}) error {\n\tconverter := &Converter{\n\t\tTagName: \"field\",\n\t}\n\n\treturn converter.Convert(source, target)\n}", "func (f *Field) Set(l *Location, val string, seps *Delimeters) error {\n\tloc := l.Comp\n\tif loc < 0 {\n\t\tloc = 0\n\t}\n\tif x := loc - len(f.Components) + 1; x > 0 {\n\t\tf.Components = append(f.Components, make([]Component, x)...)\n\t}\n\terr := f.Components[loc].Set(l, val, seps)\n\tif err != nil {\n\t\treturn err\n\t}\n\tf.Value = f.encode(seps)\n\treturn nil\n}", "func (m *PlayerMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase player.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase player.FieldColor:\n\t\tv, ok := value.(player.Color)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetColor(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Player field %s\", name)\n}", "func (m *OperativeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase operative.FieldOperativeName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetOperativeName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Operative field %s\", name)\n}", "func (m *ClassifierMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase classifier.FieldEQUIPMENTCLASSIFIER:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEQUIPMENTCLASSIFIER(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Classifier field %s\", name)\n}", "func (m *PermissionMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase permission.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Permission field %s\", name)\n}", "func (m *SettlementMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase settlement.FieldX:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetX(v)\n\t\treturn nil\n\tcase settlement.FieldY:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetY(v)\n\t\treturn nil\n\tcase settlement.FieldIsCity:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetIsCity(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Settlement field %s\", name)\n}", "func setField(name string, field reflect.Value, usage string) {\n\tswitch field.Kind() {\n\tcase reflect.Bool:\n\t\tpflag.Bool(name, false, usage)\n\tcase reflect.Float64:\n\t\tpflag.Float64(name, 0, usage)\n\tcase reflect.Uint:\n\t\tpflag.Uint(name, 0, usage)\n\tcase reflect.String:\n\t\tpflag.String(name, \"\", usage)\n\tcase reflect.Slice:\n\t\tslice := field.Interface()\n\t\tif _, ok := slice.([]string); ok {\n\t\t\tpflag.StringSlice(name, []string{}, usage)\n\t\t} else if _, ok := slice.([]float64); ok {\n\t\t\tpflag.Float64Slice(name, []float64{}, usage)\n\t\t} else if _, ok := slice.([]uint); ok {\n\t\t\tpflag.UintSlice(name, []uint{}, usage)\n\t\t}\n\t\tpanic(\"unsupported slice type\")\n\tdefault:\n\t\tpanic(\"unsupported type\")\n\t}\n\tviper.BindPFlag(strings.ReplaceAll(name, \"-\", \".\"), pflag.Lookup(name))\n}", "func (m *PatientrecordMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase patientrecord.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Patientrecord field %s\", name)\n}", "func (m *CleanernameMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase cleanername.FieldCleanername:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCleanername(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Cleanername field %s\", name)\n}", "func (f *Fieldx) Set(v interface{}) error {\n\tif !f.IsExport() {\n\t\treturn ErrNotExported\n\t}\n\n\tif !f.value.CanSet() {\n\t\treturn errNotSettable\n\t}\n\n\tvv := reflect.ValueOf(v)\n\tif f.Kind() != vv.Kind() {\n\t\treturn fmt.Errorf(\"xstruct: value kind not match, want: %s but got %s\", f.Kind(), vv.Kind())\n\t}\n\n\tf.value.Set(vv)\n\n\treturn nil\n}", "func (cli *SetWrapper) SetName(name string) error {\n\treturn cli.set.SetValue(fieldSetName, name)\n}", "func (m *MenuMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase menu.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase menu.FieldDescription:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDescription(v)\n\t\treturn nil\n\tcase menu.FieldIsOption:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetIsOption(v)\n\t\treturn nil\n\tcase menu.FieldPrice:\n\t\tv, ok := value.(*money.Money)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPrice(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Menu field %s\", name)\n}", "func (m *ManagerMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase manager.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase manager.FieldEmail:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEmail(v)\n\t\treturn nil\n\tcase manager.FieldPassword:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPassword(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Manager field %s\", name)\n}", "func (m *RepairingMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase repairing.FieldRepairpart:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetRepairpart(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Repairing field %s\", name)\n}", "func (m *PaymentchannelMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase paymentchannel.FieldBank:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetBank(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Paymentchannel field %s\", name)\n}", "func (o *Edge) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *SystemMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase system.FieldCreateByUser:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCreateByUser(v)\n\t\treturn nil\n\tcase system.FieldUpdateByUser:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetUpdateByUser(v)\n\t\treturn nil\n\tcase system.FieldCreateTime:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCreateTime(v)\n\t\treturn nil\n\tcase system.FieldUpdateTime:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetUpdateTime(v)\n\t\treturn nil\n\tcase system.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown System field %s\", name)\n}", "func (m *DayMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase day.FieldDay:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDay(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Day field %s\", name)\n}", "func (m *ZoneproductMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase zoneproduct.FieldZone:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetZone(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Zoneproduct field %s\", name)\n}", "func SetField(obj interface{}, name string, value interface{}) error {\n\tstructValue := reflect.ValueOf(obj).Elem()\n\tstructFieldValue := structValue.FieldByName(name)\n\n\tif !structFieldValue.IsValid() {\n\t\treturn fmt.Errorf(\"No such field: %s in obj\", name)\n\t}\n\n\tif !structFieldValue.CanSet() {\n\t\treturn fmt.Errorf(\"Cannot set %s field value\", name)\n\t}\n\n\tstructFieldType := structFieldValue.Type()\n\tval := reflect.ValueOf(value)\n\tif structFieldType != val.Type() {\n\t\treturn errors.New(\"Provided value type didn't match obj field type\")\n\t}\n\n\tstructFieldValue.Set(val)\n\treturn nil\n}", "func (m *PaymentMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase payment.FieldPaymentname:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPaymentname(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Payment field %s\", name)\n}", "func (m *LevelMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase level.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Level field %s\", name)\n}", "func (s *Struct) SetField(key string, to Item) (err error) {\n\treqType, ok := s.ty.Fields[key]\n\tif !ok {\n\t\treturn newError(ErrIndex, \"cannot retrieve undefined field %s\")\n\t}\n\tif !to.Type().Equals(reqType) {\n\t\treturn newError(\n\t\t\tErrType,\n\t\t\t\"field %s of type %s cannot be assigned to a %s\",\n\t\t\tkey,\n\t\t\treqType,\n\t\t\tto.Type(),\n\t\t)\n\t}\n\n\ts.value[key] = to\n\n\treturn nil\n}", "func (m *InviteePartyMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase inviteeparty.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase inviteeparty.FieldCode:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCode(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown InviteeParty field %s\", name)\n}", "func setField(obj interface{}, name string, value interface{}) error {\n\tstructValue := reflect.ValueOf(obj).Elem()\n\tstructType := reflect.TypeOf(obj).Elem()\n\tstructFieldValue := structValue.FieldByName(name)\n\n\tfor i := 0; i < structType.NumField(); i++ {\n\t\tfield := structType.Field(i)\n\t\ttag := field.Tag.Get(\"query\")\n\n\t\tif tag == name {\n\t\t\tstructFieldValue = structValue.Field(i)\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !structFieldValue.IsValid() || !structFieldValue.CanSet() {\n\t\treturn errors.New(fmt.Sprintf(\"%s is not allowed\", name))\n\t}\n\n\tstructFieldType := structFieldValue.Type()\n\tval := reflect.ValueOf(value)\n\n\tif structFieldType.Kind() == reflect.Bool {\n\t\tswitch val.String() {\n\t\tcase \"false\":\n\t\t\tstructFieldValue.SetBool(false)\n\t\t\treturn nil\n\t\tcase \"true\":\n\t\t\tstructFieldValue.SetBool(true)\n\t\t\treturn nil\n\t\tdefault:\n\t\t\treturn errors.New(fmt.Sprintf(\"%s must be a boolean\", name))\n\t\t}\n\t} else {\n\t\tstructFieldValue.Set(val)\n\t\treturn nil\n\t}\n}", "func (m *PetruleMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase petrule.FieldPetrule:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPetrule(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Petrule field %s\", name)\n}", "func (m *CityMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase city.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown City field %s\", name)\n}", "func (m *StaytypeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase staytype.FieldStaytype:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetStaytype(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Staytype field %s\", name)\n}", "func (o *Voicemailmessagestopicvoicemailmessage) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (entry *Entry) SetField(name string, value string) {\n\tentry.fields[name] = value\n}", "func SetStrByName(o interface{}, name string, val string) {\n\tif fd := reflect.ValueOf(o).Elem().FieldByName(name); fd.IsValid() {\n\t\tfd.SetString(val)\n\t}\n}", "func (m *TypeproductMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase typeproduct.FieldTypeproduct:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetTypeproduct(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Typeproduct field %s\", name)\n}", "func (m *WifiMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase wifi.FieldWifiname:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetWifiname(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Wifi field %s\", name)\n}", "func (o *Outcomequantilecondition) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Digitalcondition) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *StatisticMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase statistic.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Statistic field %s\", name)\n}", "func (m *ZoneMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase zone.FieldEQUIPMENTZONE:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEQUIPMENTZONE(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Zone field %s\", name)\n}", "func (s *StructField) Set(v interface{}) error {\n\tif s.field.PkgPath != \"\" {\n\t\treturn errors.New(\"Field is not exported\")\n\t}\n\n\tif !s.CanSet() {\n\t\treturn errors.New(\"Field cannot be set\")\n\t}\n\n\tgiven := reflect.ValueOf(v)\n\n\tif s.value.Kind() != given.Kind() {\n\t\treturn errors.New(\"Field and value kind don't match\")\n\t}\n\n\ts.value.Set(given)\n\treturn nil\n}", "func (v *ClassValue) setField(s *scope, name string, val Value) Value {\n\tout := v.Clone().(*ClassValue)\n\tout.Fields[name] = val\n\treturn out\n}", "func (m *AuthorizeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase authorize.FieldProvider:\n\t\tv, ok := value.(authorize.Provider)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetProvider(v)\n\t\treturn nil\n\tcase authorize.FieldServiceID:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetServiceID(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Authorize field %s\", name)\n}", "func (f *FieldHeaderNames) SetValue(val interface{}) {\n\t*f = val.(FieldHeaderNames)\n}", "func (m *UserMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase user.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase user.FieldAddress:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddress(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown User field %s\", name)\n}", "func (m *RoomInfoMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase roominfo.FieldInfo:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetInfo(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown RoomInfo field %s\", name)\n}", "func (m *EntityMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase entity.FieldActive:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetActive(v)\n\t\treturn nil\n\tcase entity.FieldTicker:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetTicker(v)\n\t\treturn nil\n\tcase entity.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase entity.FieldDescription:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDescription(v)\n\t\treturn nil\n\tcase entity.FieldListDate:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetListDate(v)\n\t\treturn nil\n\tcase entity.FieldDelisted:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDelisted(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Entity field %s\", name)\n}", "func (m *PurposeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase purpose.FieldObjective:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetObjective(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Purpose field %s\", name)\n}", "func (m *HospitalMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase hospital.FieldHospital:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetHospital(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Hospital field %s\", name)\n}", "func (m *TenantMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase tenant.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Tenant field %s\", name)\n}", "func (m *DiseasetypeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase diseasetype.FieldDiseaseTypeName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDiseaseTypeName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Diseasetype field %s\", name)\n}", "func (m *RegistryKeyState) SetValueName(value *string)() {\n m.valueName = value\n}", "func (m *EmployeeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase employee.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase employee.FieldEmail:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEmail(v)\n\t\treturn nil\n\tcase employee.FieldPassword:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPassword(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Employee field %s\", name)\n}", "func (m *StockMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase stock.FieldIDstock:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetIDstock(v)\n\t\treturn nil\n\tcase stock.FieldPriceproduct:\n\t\tv, ok := value.(float64)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPriceproduct(v)\n\t\treturn nil\n\tcase stock.FieldAmount:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAmount(v)\n\t\treturn nil\n\tcase stock.FieldTime:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetTime(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Stock field %s\", name)\n}", "func (m *EquipmenttypeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase equipmenttype.FieldEQUIPMENTTYPE:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEQUIPMENTTYPE(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Equipmenttype field %s\", name)\n}", "func (o *Dialercampaignconfigchangecampaign) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *CustomerMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase customer.FieldCustomerName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCustomerName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Customer field %s\", name)\n}", "func (o *Initialconfiguration) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *PaymenttypeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase paymenttype.FieldTYPE:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetTYPE(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Paymenttype field %s\", name)\n}", "func (m *InsuranceMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase insurance.FieldCompany:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCompany(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Insurance field %s\", name)\n}", "func (m *RestaurantMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase restaurant.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase restaurant.FieldDescription:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDescription(v)\n\t\treturn nil\n\tcase restaurant.FieldURI:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetURI(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Restaurant field %s\", name)\n}", "func (m *CardMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase card.FieldNumber:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetNumber(v)\n\t\treturn nil\n\tcase card.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase card.FieldOwnerID:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetOwnerID(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Card field %s\", name)\n}", "func (o *Compliance) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *DevelopperMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase developper.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase developper.FieldAge:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAge(v)\n\t\treturn nil\n\tcase developper.FieldSchool:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetSchool(v)\n\t\treturn nil\n\tcase developper.FieldExperience:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetExperience(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Developper field %s\", name)\n}", "func (m *CategoryMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase category.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Category field %s\", name)\n}", "func (m *AssessmentMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase assessment.FieldAssessment:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAssessment(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Assessment field %s\", name)\n}", "func (m *ResourceMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase resource.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase resource.FieldType:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetType(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Resource field %s\", name)\n}", "func (m *RepairinvoiceMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase repairinvoice.FieldBequipment:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetBequipment(v)\n\t\treturn nil\n\tcase repairinvoice.FieldEmtell:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEmtell(v)\n\t\treturn nil\n\tcase repairinvoice.FieldNum:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetNum(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Repairinvoice field %s\", name)\n}", "func (m *InsuranceMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase insurance.FieldInsurancecompany:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetInsurancecompany(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Insurance field %s\", name)\n}", "func (m *NodeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase node.FieldValue:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetValue(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Node field %s\", name)\n}", "func (m *PromotiontypeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase promotiontype.FieldTYPE:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetTYPE(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Promotiontype field %s\", name)\n}" ]
[ "0.6948246", "0.69475335", "0.6852958", "0.68402", "0.6839158", "0.6825246", "0.6811636", "0.6794739", "0.6747628", "0.6737102", "0.6725907", "0.66940546", "0.6676845", "0.6675546", "0.6666642", "0.6664172", "0.66604984", "0.66535085", "0.6643923", "0.663431", "0.6629868", "0.6624399", "0.66197765", "0.6612956", "0.660484", "0.6603518", "0.6580616", "0.65783274", "0.656996", "0.6566626", "0.6563003", "0.65603006", "0.6559072", "0.65467405", "0.6546214", "0.6538942", "0.65292317", "0.6528147", "0.6524439", "0.65214884", "0.65209043", "0.65075755", "0.65055597", "0.6501506", "0.65009063", "0.6499957", "0.6498905", "0.6498187", "0.64966536", "0.64950013", "0.649496", "0.6493297", "0.648943", "0.64842683", "0.6476373", "0.6453069", "0.64328796", "0.64278495", "0.64274865", "0.6424343", "0.64192694", "0.64181733", "0.6412463", "0.6408901", "0.6406262", "0.6405429", "0.64020884", "0.64019275", "0.6399452", "0.6397096", "0.6395173", "0.63937384", "0.6391441", "0.63904595", "0.63871783", "0.6386384", "0.6386289", "0.6383655", "0.63817656", "0.6378933", "0.6375889", "0.6371928", "0.6370337", "0.6363098", "0.63565737", "0.6353812", "0.63506985", "0.63482374", "0.6346569", "0.6343536", "0.6341941", "0.63298523", "0.6329339", "0.6326933", "0.6325001", "0.6318453", "0.63177484", "0.63163584", "0.63146615", "0.6313162" ]
0.6569884
29
Zero set zero value to the field name, must be exported field
func (s *Structx) Zero(name string) error { f, ok := s.Field(name) if !ok { return ErrNotField } return f.Zero() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *Fieldx) Zero() error {\n\tzero := reflect.Zero(f.value.Type()).Interface()\n\treturn f.Set(zero)\n}", "func (f *Field) Zero() error {\n\tzero := reflect.Zero(f.value.Type()).Interface()\n\treturn f.Set(zero)\n}", "func (p *Pet) SetFieldZeroValue(field *mapping.StructField) error {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\tp.ID = 0\n\tcase 1: // Name\n\t\tp.Name = \"\"\n\tcase 3: // OwnerID\n\t\tp.OwnerID = 0\n\tdefault:\n\t\treturn errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n\t}\n\treturn nil\n}", "func (u *User) SetFieldZeroValue(field *mapping.StructField) error {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\tu.ID = 0\n\tcase 1: // Name\n\t\tu.Name = \"\"\n\tcase 2: // CreatedAt\n\t\tu.CreatedAt = time.Time{}\n\tcase 3: // CreatedAtIso\n\t\tu.CreatedAtIso = time.Time{}\n\tcase 5: // MotherID\n\t\tu.MotherID = 0\n\tcase 7: // FatherID\n\t\tu.FatherID = 0\n\tdefault:\n\t\treturn errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n\t}\n\treturn nil\n}", "func (dt *FieldTraits) AllowZeroValue(p Path) { dt.add(p, FieldTypeAllowZeroValue) }", "func (u *User) GetFieldZeroValue(field *mapping.StructField) (interface{}, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn 0, nil\n\tcase 1: // Name\n\t\treturn \"\", nil\n\tcase 2: // CreatedAt\n\t\treturn time.Time{}, nil\n\tcase 3: // CreatedAtIso\n\t\treturn time.Time{}, nil\n\tcase 5: // MotherID\n\t\treturn 0, nil\n\tcase 7: // FatherID\n\t\treturn 0, nil\n\tdefault:\n\t\treturn nil, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n\t}\n}", "func (p *Pet) GetFieldZeroValue(field *mapping.StructField) (interface{}, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn 0, nil\n\tcase 1: // Name\n\t\treturn \"\", nil\n\tcase 3: // OwnerID\n\t\treturn 0, nil\n\tdefault:\n\t\treturn nil, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n\t}\n}", "func (v *DataRateIndexValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *DataRateOffsetValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (t systemSetType) Zero() interface{} {\n\treturn \"\"\n}", "func (v *FCtrl) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"ack\":\n\t\treturn !v.Ack\n\tcase \"adr\":\n\t\treturn !v.ADR\n\tcase \"adr_ack_req\":\n\t\treturn !v.ADRAckReq\n\tcase \"class_b\":\n\t\treturn !v.ClassB\n\tcase \"f_pending\":\n\t\treturn !v.FPending\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *FHDR) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"dev_addr\":\n\t\treturn v.DevAddr == types.DevAddr{}\n\tcase \"f_cnt\":\n\t\treturn v.FCnt == 0\n\tcase \"f_ctrl\":\n\t\treturn v.FCtrl == FCtrl{}\n\tcase \"f_ctrl.ack\":\n\t\treturn v.FCtrl.FieldIsZero(\"ack\")\n\tcase \"f_ctrl.adr\":\n\t\treturn v.FCtrl.FieldIsZero(\"adr\")\n\tcase \"f_ctrl.adr_ack_req\":\n\t\treturn v.FCtrl.FieldIsZero(\"adr_ack_req\")\n\tcase \"f_ctrl.class_b\":\n\t\treturn v.FCtrl.FieldIsZero(\"class_b\")\n\tcase \"f_ctrl.f_pending\":\n\t\treturn v.FCtrl.FieldIsZero(\"f_pending\")\n\tcase \"f_opts\":\n\t\treturn v.FOpts == nil\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (u *User) IsFieldZero(field *mapping.StructField) (bool, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn u.ID == 0, nil\n\tcase 1: // Name\n\t\treturn u.Name == \"\", nil\n\tcase 2: // CreatedAt\n\t\treturn u.CreatedAt == time.Time{}, nil\n\tcase 3: // CreatedAtIso\n\t\treturn u.CreatedAtIso == time.Time{}, nil\n\tcase 5: // MotherID\n\t\treturn u.MotherID == 0, nil\n\tcase 7: // FatherID\n\t\treturn u.FatherID == 0, nil\n\t}\n\treturn false, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n}", "func (v *FrequencyValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (p *Pet) IsFieldZero(field *mapping.StructField) (bool, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn p.ID == 0, nil\n\tcase 1: // Name\n\t\treturn p.Name == \"\", nil\n\tcase 3: // OwnerID\n\t\treturn p.OwnerID == 0, nil\n\t}\n\treturn false, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n}", "func zeroValue(t reflect.Type) string {\n\tswitch t.Kind() {\n\tcase reflect.Bool:\n\t\treturn \"false\"\n\tcase reflect.String:\n\t\treturn `\"\"`\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn \"0\"\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn \"0\"\n\tcase reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128:\n\t\treturn \"0\"\n\tcase reflect.Ptr, reflect.Slice, reflect.Map, reflect.Interface:\n\t\treturn \"nil\"\n\tdefault:\n\t\treturn \"\"\n\t}\n}", "func (v *MHDR) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"m_type\":\n\t\treturn v.MType == 0\n\tcase \"major\":\n\t\treturn v.Major == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func noEmptyField(target FormatResult, args ...string) string {\n\tfor _, field := range args {\n\t\tif cur, ok := target[field]; ok && cur != \"\" {\n\t\t\treturn cur\n\t\t}\n\t}\n\treturn \"\"\n}", "func TestZeroWithMapField(t *testing.T) {\n\ttype MapFieldStruct struct {\n\t\tMapField map[string]int\n\t}\n\tsimpleMapStruct := new(MapFieldStruct)\n\tZero(simpleMapStruct)\n\t// This would panic if executed pre-Zero\n\tsimpleMapStruct.MapField[\"test\"] = 25\n}", "func (v *AggregatedDutyCycleValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func mungeSetZeroValue(i int, rec []interface{}, destMeta sqlz.RecordMeta) {\n\t// REVISIT: do we need to do special handling for kind.Datetime\n\t// and kind.Time (e.g. \"00:00\" for time)?\n\tz := reflect.Zero(destMeta[i].ScanType()).Interface()\n\trec[i] = z\n}", "func (p *property) zeroString() string {\n\tif p.Type == reflect.TypeOf(false) {\n\t\treturn \"false\"\n\t} else if p.Type == reflect.TypeOf(0) {\n\t\treturn \"0\"\n\t} else if p.Type == reflect.TypeOf(0.0) {\n\t\treturn \"0\"\n\t} else if p.Type == reflect.TypeOf(\"\") {\n\t\treturn \"\"\n\t} else {\n\t\tv := reflect.New(p.Type)\n\t\tif f := v.MethodByName(\"ZeroString\"); f == (reflect.Value{}) {\n\t\t\treturn \"\"\n\t\t} else {\n\t\t\tret := f.Call(nil)\n\t\t\tif len(ret) != 1 {\n\t\t\t\treturn \"\"\n\t\t\t} else {\n\t\t\t\treturn ret[0].String()\n\t\t\t}\n\t\t}\n\t}\n}", "func (v *DLSettings) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"opt_neg\":\n\t\treturn !v.OptNeg\n\tcase \"rx1_dr_offset\":\n\t\treturn v.Rx1DROffset == 0\n\tcase \"rx2_dr\":\n\t\treturn v.Rx2DR == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *RejoinRequestPayload) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"dev_eui\":\n\t\treturn v.DevEUI == types.EUI64{}\n\tcase \"join_eui\":\n\t\treturn v.JoinEUI == types.EUI64{}\n\tcase \"net_id\":\n\t\treturn v.NetID == types.NetID{}\n\tcase \"rejoin_cnt\":\n\t\treturn v.RejoinCnt == 0\n\tcase \"rejoin_type\":\n\t\treturn v.RejoinType == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *ADRAckDelayExponentValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *ADRAckLimitExponentValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func formatZeroValue(T types.Type, qf types.Qualifier) string {\n\tswitch u := T.Underlying().(type) {\n\tcase *types.Basic:\n\t\tswitch {\n\t\tcase u.Info()&types.IsNumeric > 0:\n\t\t\treturn \"0\"\n\t\tcase u.Info()&types.IsString > 0:\n\t\t\treturn `\"\"`\n\t\tcase u.Info()&types.IsBoolean > 0:\n\t\t\treturn \"false\"\n\t\tdefault:\n\t\t\treturn \"\"\n\t\t}\n\tcase *types.Pointer, *types.Interface, *types.Chan, *types.Map, *types.Slice, *types.Signature:\n\t\treturn \"nil\"\n\tdefault:\n\t\treturn types.TypeString(T, qf) + \"{}\"\n\t}\n}", "func TestZeroWithPrivateField(t *testing.T) {\n\ttype PrivateFieldStruct struct {\n\t\tprivField *int\n\t\tPublicField *int\n\t}\n\tpfstruct := new(PrivateFieldStruct)\n\n\terr := Zero(pfstruct)\n\n\tif err != nil {\n\t\tt.Errorf(\"Private field struct produced error: %v\", err)\n\t}\n\n\tif pfstruct.privField != nil {\n\t\tt.Errorf(\"Private field is not nil: %v\", pfstruct.privField)\n\t}\n\n\tif pfstruct.PublicField == nil || *pfstruct.PublicField != 0 {\n\t\tt.Errorf(\"Public field was not allocated correctly: %v\", pfstruct.PublicField)\n\t}\n}", "func (v *PingSlotPeriodValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *RxDelayValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *JoinRequestPayload) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"dev_eui\":\n\t\treturn v.DevEUI == types.EUI64{}\n\tcase \"dev_nonce\":\n\t\treturn v.DevNonce == types.DevNonce{}\n\tcase \"join_eui\":\n\t\treturn v.JoinEUI == types.EUI64{}\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *ApplicationIdentifiers) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"application_id\":\n\t\treturn v.ApplicationId == \"\"\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *CFList) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"ch_masks\":\n\t\treturn v.ChMasks == nil\n\tcase \"freq\":\n\t\treturn v.Freq == nil\n\tcase \"type\":\n\t\treturn v.Type == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func SetStructFieldIfZeroValue(strukt interface{}, fieldName string, value interface{}) (bool, error) {\n\tfieldType := reflect.TypeOf(value)\n\treturn setStructField(strukt, fieldName, value, fieldType, true)\n}", "func Zero(v interface{}, name string) error {\n\treturn New(v).Zero(name)\n}", "func ZeroValue(t JType) interface{} {\n\tif t.IsPrimitive() {\n\t\treturn basicZeroValue(t.Orig.Underlying().(*types.Basic))\n\t} else {\n\t\tv := \"new \" + t.JName() + \"(\"\n\t\tif t.NeedsAddress() {\n\t\t\tv += fmt.Sprint(FakeAddressFor(t.Ident))\n\t\t}\n\t\tv += \")\"\n\t\treturn v\n\t}\n}", "func (v *MACPayload) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"decoded_payload\":\n\t\treturn v.DecodedPayload == nil\n\tcase \"f_hdr\":\n\t\treturn fieldsAreZero(&v.FHDR, FHDRFieldPathsTopLevel...)\n\tcase \"f_hdr.dev_addr\":\n\t\treturn v.FHDR.FieldIsZero(\"dev_addr\")\n\tcase \"f_hdr.f_cnt\":\n\t\treturn v.FHDR.FieldIsZero(\"f_cnt\")\n\tcase \"f_hdr.f_ctrl\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl\")\n\tcase \"f_hdr.f_ctrl.ack\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.ack\")\n\tcase \"f_hdr.f_ctrl.adr\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.adr\")\n\tcase \"f_hdr.f_ctrl.adr_ack_req\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.adr_ack_req\")\n\tcase \"f_hdr.f_ctrl.class_b\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.class_b\")\n\tcase \"f_hdr.f_ctrl.f_pending\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.f_pending\")\n\tcase \"f_hdr.f_opts\":\n\t\treturn v.FHDR.FieldIsZero(\"f_opts\")\n\tcase \"f_port\":\n\t\treturn v.FPort == 0\n\tcase \"frm_payload\":\n\t\treturn v.FRMPayload == nil\n\tcase \"full_f_cnt\":\n\t\treturn v.FullFCnt == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func CopyNoneZeroField(from, to interface{}) {\n\tfValue := reflect.ValueOf(from)\n\ttValue := reflect.ValueOf(to)\n\tif fValue.Type() != tValue.Type() {\n\t\tpanic(fmt.Sprintf(\"from/to must by same type:from=%v, to=%v\", fValue.Type(), tValue.Type()))\n\t}\n\tfValue = fValue.Elem()\n\ttValue = tValue.Elem()\n\tif !tValue.CanAddr() {\n\t\tpanic(\"copy destination must be CanAddr\")\n\t}\n\n\tfor i := 0; i < fValue.NumField(); i++ {\n\t\tfield := fValue.Field(i)\n\t\tif !field.IsZero() && field.CanSet() {\n\t\t\ttValue.Field(i).Set(field)\n\t\t}\n\t}\n}", "func ZeroString(v interface{}) string {\n\treturn String(v)\n}", "func (v *Message) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"Payload\":\n\t\treturn v.Payload == nil\n\tcase \"Payload.join_accept_payload\":\n\t\treturn v.GetJoinAcceptPayload() == nil\n\tcase \"Payload.join_accept_payload.cf_list\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"cf_list\")\n\tcase \"Payload.join_accept_payload.cf_list.ch_masks\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"cf_list.ch_masks\")\n\tcase \"Payload.join_accept_payload.cf_list.freq\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"cf_list.freq\")\n\tcase \"Payload.join_accept_payload.cf_list.type\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"cf_list.type\")\n\tcase \"Payload.join_accept_payload.dev_addr\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"dev_addr\")\n\tcase \"Payload.join_accept_payload.dl_settings\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"dl_settings\")\n\tcase \"Payload.join_accept_payload.dl_settings.opt_neg\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"dl_settings.opt_neg\")\n\tcase \"Payload.join_accept_payload.dl_settings.rx1_dr_offset\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"dl_settings.rx1_dr_offset\")\n\tcase \"Payload.join_accept_payload.dl_settings.rx2_dr\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"dl_settings.rx2_dr\")\n\tcase \"Payload.join_accept_payload.encrypted\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"encrypted\")\n\tcase \"Payload.join_accept_payload.join_nonce\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"join_nonce\")\n\tcase \"Payload.join_accept_payload.net_id\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"net_id\")\n\tcase \"Payload.join_accept_payload.rx_delay\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"rx_delay\")\n\tcase \"Payload.join_request_payload\":\n\t\treturn v.GetJoinRequestPayload() == nil\n\tcase \"Payload.join_request_payload.dev_eui\":\n\t\treturn v.GetJoinRequestPayload().FieldIsZero(\"dev_eui\")\n\tcase \"Payload.join_request_payload.dev_nonce\":\n\t\treturn v.GetJoinRequestPayload().FieldIsZero(\"dev_nonce\")\n\tcase \"Payload.join_request_payload.join_eui\":\n\t\treturn v.GetJoinRequestPayload().FieldIsZero(\"join_eui\")\n\tcase \"Payload.mac_payload\":\n\t\treturn v.GetMACPayload() == nil\n\tcase \"Payload.mac_payload.decoded_payload\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"decoded_payload\")\n\tcase \"Payload.mac_payload.f_hdr\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr\")\n\tcase \"Payload.mac_payload.f_hdr.dev_addr\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.dev_addr\")\n\tcase \"Payload.mac_payload.f_hdr.f_cnt\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_cnt\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl.ack\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl.ack\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl.adr\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl.adr\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl.adr_ack_req\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl.adr_ack_req\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl.class_b\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl.class_b\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl.f_pending\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl.f_pending\")\n\tcase \"Payload.mac_payload.f_hdr.f_opts\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_opts\")\n\tcase \"Payload.mac_payload.f_port\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_port\")\n\tcase \"Payload.mac_payload.frm_payload\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"frm_payload\")\n\tcase \"Payload.mac_payload.full_f_cnt\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"full_f_cnt\")\n\tcase \"Payload.rejoin_request_payload\":\n\t\treturn v.GetRejoinRequestPayload() == nil\n\tcase \"Payload.rejoin_request_payload.dev_eui\":\n\t\treturn v.GetRejoinRequestPayload().FieldIsZero(\"dev_eui\")\n\tcase \"Payload.rejoin_request_payload.join_eui\":\n\t\treturn v.GetRejoinRequestPayload().FieldIsZero(\"join_eui\")\n\tcase \"Payload.rejoin_request_payload.net_id\":\n\t\treturn v.GetRejoinRequestPayload().FieldIsZero(\"net_id\")\n\tcase \"Payload.rejoin_request_payload.rejoin_cnt\":\n\t\treturn v.GetRejoinRequestPayload().FieldIsZero(\"rejoin_cnt\")\n\tcase \"Payload.rejoin_request_payload.rejoin_type\":\n\t\treturn v.GetRejoinRequestPayload().FieldIsZero(\"rejoin_type\")\n\tcase \"m_hdr\":\n\t\treturn v.MHDR == MHDR{}\n\tcase \"m_hdr.m_type\":\n\t\treturn v.MHDR.FieldIsZero(\"m_type\")\n\tcase \"m_hdr.major\":\n\t\treturn v.MHDR.FieldIsZero(\"major\")\n\tcase \"mic\":\n\t\treturn v.MIC == nil\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (l *LangPackStringPluralized) SetZeroValue(value string) {\n\tl.Flags.Set(0)\n\tl.ZeroValue = value\n}", "func (wv *Spectrum) SetZero() {\n\tfor k := 0; k < 4; k++ {\n\t\twv.C[k] = 0\n\t}\n\n}", "func (n *Uint256) Zero() {\n\tn.n[0], n.n[1], n.n[2], n.n[3] = 0, 0, 0, 0\n}", "func (String) Zero(c *compiler.Compiler) (expression compiler.Expression) {\n\texpression = c.NewExpression()\n\texpression.Type = String{}\n\n\texpression.Go.WriteString(`\"\"`)\n\texpression.JS.WriteString(`\"\"`)\n\n\treturn\n}", "func (n Name) Zero() bool {\n\treturn len(n) == 0\n}", "func (this *Iter_UServ_UpdateNameToFoo) Zero() error {\n\trow, ok := this.Next()\n\tif row != nil && row.err != nil && row.err != io.EOF {\n\t\treturn row.err\n\t}\n\tif ok {\n\t\treturn fmt.Errorf(\"expected exactly 0 results from query 'UpdateNameToFoo'\")\n\t}\n\treturn nil\n}", "func (self *T) mZERO() {\r\n \r\n \r\n\t\t_type := T_ZERO\r\n\t\t_channel := antlr3rt.DEFAULT_TOKEN_CHANNEL\r\n\t\t// C:/dev/antlr.github/antlr/runtime/Go/antlr/test/T.g:8:5: ( '0' )\r\n\t\t// C:/dev/antlr.github/antlr/runtime/Go/antlr/test/T.g:8:7: '0'\r\n\t\t{\r\n\t\tself.MatchChar('0') \r\n\r\n\r\n\t\t}\r\n\r\n\t\tself.State().SetType( _type )\r\n\t\tself.State().SetChannel( _channel )\r\n}", "func (z *Element22) SetZero() *Element22 {\n\tz[0] = 0\n\tz[1] = 0\n\tz[2] = 0\n\tz[3] = 0\n\tz[4] = 0\n\tz[5] = 0\n\tz[6] = 0\n\tz[7] = 0\n\tz[8] = 0\n\tz[9] = 0\n\tz[10] = 0\n\tz[11] = 0\n\tz[12] = 0\n\tz[13] = 0\n\tz[14] = 0\n\tz[15] = 0\n\tz[16] = 0\n\tz[17] = 0\n\tz[18] = 0\n\tz[19] = 0\n\tz[20] = 0\n\tz[21] = 0\n\treturn z\n}", "func (v *JoinAcceptPayload) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"cf_list\":\n\t\treturn v.CFList == nil\n\tcase \"cf_list.ch_masks\":\n\t\treturn v.CFList.FieldIsZero(\"ch_masks\")\n\tcase \"cf_list.freq\":\n\t\treturn v.CFList.FieldIsZero(\"freq\")\n\tcase \"cf_list.type\":\n\t\treturn v.CFList.FieldIsZero(\"type\")\n\tcase \"dev_addr\":\n\t\treturn v.DevAddr == types.DevAddr{}\n\tcase \"dl_settings\":\n\t\treturn v.DLSettings == DLSettings{}\n\tcase \"dl_settings.opt_neg\":\n\t\treturn v.DLSettings.FieldIsZero(\"opt_neg\")\n\tcase \"dl_settings.rx1_dr_offset\":\n\t\treturn v.DLSettings.FieldIsZero(\"rx1_dr_offset\")\n\tcase \"dl_settings.rx2_dr\":\n\t\treturn v.DLSettings.FieldIsZero(\"rx2_dr\")\n\tcase \"encrypted\":\n\t\treturn v.Encrypted == nil\n\tcase \"join_nonce\":\n\t\treturn v.JoinNonce == types.JoinNonce{}\n\tcase \"net_id\":\n\t\treturn v.NetID == types.NetID{}\n\tcase \"rx_delay\":\n\t\treturn v.RxDelay == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func TestZeroWithPointerMapField(t *testing.T) {\n\ttype PtrMapFieldStruct struct {\n\t\tMapField *map[string]int\n\t}\n\tptrMapStruct := new(PtrMapFieldStruct)\n\tZero(ptrMapStruct)\n\t// This would panic if executed pre-Zero\n\t(*ptrMapStruct.MapField)[\"test\"] = 25\n}", "func (r1 *csvTable) Zero() interface{} {\n\treturn r1.zero\n}", "func (v *EndDeviceIdentifiers) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"application_ids\":\n\t\treturn v.ApplicationIds == nil\n\tcase \"application_ids.application_id\":\n\t\treturn v.ApplicationIds.FieldIsZero(\"application_id\")\n\tcase \"dev_addr\":\n\t\treturn v.DevAddr == nil\n\tcase \"dev_eui\":\n\t\treturn v.DevEui == nil\n\tcase \"device_id\":\n\t\treturn v.DeviceId == \"\"\n\tcase \"join_eui\":\n\t\treturn v.JoinEui == nil\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *Vector) SetZero() {\n\tv.X = 0\n\tv.Y = 0\n\tv.Z = 0\n}", "func (e *Zero) Reset() {}", "func (v *Vec3i) SetZero() {\n\tv.SetScalar(0)\n}", "func (e *GT) Zero() *GT {\n\tif e.p == nil {\n\t\te.p = &gfP12{}\n\t}\n\te.p.SetZero()\n\treturn e\n}", "func zeroFill(prefix string, width int, suffix string) string {\n\treturn prefix + strings.Repeat(\"0\", width-len(suffix)) + suffix\n}", "func zeroFill(prefix string, width int, suffix string) string {\n\treturn prefix + strings.Repeat(\"0\", width-len(suffix)) + suffix\n}", "func zeroFill(prefix string, width int, suffix string) string {\n\treturn prefix + strings.Repeat(\"0\", width-len(suffix)) + suffix\n}", "func (dc *ByteArrayDictConverter) FillZero(out interface{}) {\n\to := out.([]parquet.ByteArray)\n\to[0] = dc.zeroVal\n\tfor i := 1; i < len(o); i *= 2 {\n\t\tcopy(o[i:], o[:i])\n\t}\n}", "func (this *otherActivityStruct) Zero() bool {\n\tenergyKJ := this.energyKJ\n\tresult := energyKJ == 0\n\treturn result\n}", "func Zero() Vect { return Vect{} }", "func zeroNID(n nid) error {\n\tname := trimNIDs(n.name())\n\tid := strings.ToLower(trimNIDs(n.id()))\n\n\tif name == \"\" && id == \"\" {\n\t\treturn errors.New(\"id and name can not both be empty\")\n\t}\n\tif id == \"\" {\n\t\tid = idFromName(name)\n\t}\n\tif strings.ContainsAny(id, \" .\") {\n\t\treturn errors.New(\"a specified id can not contain spaces or full stops\")\n\t}\n\tif name == \"\" {\n\t\tname = nameFromID(id)\n\t}\n\n\tn.setID(id)\n\tn.setName(name)\n\treturn nil\n}", "func NullValue() Value { return Value{Typ: '$', Null: true} }", "func NonZeroFields(msg interface{ FieldIsZero(string) bool }, fields ...string) []string {\n\tnonZeroFields := make([]string, 0, len(fields))\n\tfor _, field := range fields {\n\t\tif !msg.FieldIsZero(field) {\n\t\t\tnonZeroFields = append(nonZeroFields, field)\n\t\t}\n\t}\n\treturn nonZeroFields\n}", "func getZeroLiteral(e ast.Expr) string {\n\tswitch t := e.(type) {\n\tcase *ast.StarExpr:\n\t\treturn \"nil\"\n\tcase *ast.Ident:\n\t\tswitch t.Name {\n\t\tcase \"string\":\n\t\t\treturn \"\\\"\\\"\"\n\t\tcase \"int\", \"int8\", \"int16\", \"int32\", \"int64\",\n\t\t\t\"uint\", \"uint8\", \"uint16\", \"uint32\", \"uint64\",\n\t\t\t\"float32\", \"float64\", \"byte\", \"rune\":\n\t\t\treturn \"0\"\n\t\tdefault:\n\t\t\tpanic(\"Type '\" + t.Name + \"' doesn't support default value for annotation field\")\n\t\t}\n\tcase *ast.ArrayType:\n\t\treturn \"nil\"\n\tdefault:\n\t\tpanic(\"Unsupported fied type in annotation definition\")\n\t}\n}", "func (s *Scalar) Zero() *Scalar {\n\ts.s = scalar.Scalar{}\n\treturn s\n}", "func (v *Vec4) Zero() {\n\tv.X = 0.0\n\tv.Y = 0.0\n\tv.Z = 0.0\n\tv.W = 0.0\n}", "func (d *Decoder) ZeroEmpty(z bool) {\n\td.zeroEmpty = z\n}", "func (e EmptyValidationError) Field() string { return e.field }", "func (util *stringUtil) FillZero(num string, digit int) string {\n\tfor fillNum := len(num) - digit; fillNum > 0; fillNum-- {\n\t\tnum = \"0\" + num\n\t}\n\treturn num\n}", "func (t systemIntType) Zero() interface{} {\n\treturn int64(0)\n}", "func (t systemIntType) Zero() interface{} {\n\treturn int64(0)\n}", "func ZeroHeader() Header {\n\treturn Header{}\n}", "func (f *Fieldx) IsZero() bool {\n\tzero := reflect.Zero(f.value.Type()).Interface()\n\treturn reflect.DeepEqual(f.Value(), zero)\n}", "func zeroval(ival int) {\n\tival = 0\n}", "func zeroval(ival int) {\n\tival = 0\n}", "func zeroval(ival int) {\n\tival = 0\n}", "func zeroval(ival int) {\n\tival = 0\n}", "func (f *Field) IsZero() bool {\n\tzero := reflect.Zero(f.value.Type()).Interface()\n\tcurrent := f.Value()\n\n\treturn reflect.DeepEqual(current, zero)\n}", "func (dc *FixedLenByteArrayDictConverter) FillZero(out interface{}) {\n\to := out.([]parquet.FixedLenByteArray)\n\to[0] = dc.zeroVal\n\tfor i := 1; i < len(o); i *= 2 {\n\t\tcopy(o[i:], o[:i])\n\t}\n}", "func (e StartElement) isZero() bool {\n\treturn len(e.Name.Local) == 0\n}", "func setTblIfNonZeroMs(event *beat.Event, tableName string, fieldName string, valueMS int64) {\n\tif valueMS > 0 {\n\t\tevent.Fields[fmt.Sprintf(\"p4.tbl.%s.%s\", strings.ToLower(tableName), fieldName)] = float64(valueMS) / 1000.0\n\t}\n}", "func (feature Feature) UnnsetField(index int) {\n\tC.OGR_F_UnsetField(feature.cval, C.int(index))\n}", "func Zero() ID {\n\treturn nilID\n}", "func (s *StructField) IsZero() bool {\n\treturn reflect2.IsZero(s.value)\n}", "func (dc *Float64DictConverter) FillZero(out interface{}) {\n\to := out.([]float64)\n\to[0] = dc.zeroVal\n\tfor i := 1; i < len(o); i *= 2 {\n\t\tcopy(o[i:], o[:i])\n\t}\n}", "func (feature Feature) SetFieldNull(index int) {\n\tC.OGR_F_SetFieldNull(feature.cval, C.int(index))\n}", "func publicName(fieldName string) string {\n\tif len(fieldName) == 0 {\n\t\treturn fieldName\n\t} else {\n\t\treturn string(unicode.ToUpper(rune(fieldName[0]))) + fieldName[1:]\n\t}\n}", "func (m *SystemMutation) ResetField(name string) error {\n\tswitch name {\n\tcase system.FieldCreateByUser:\n\t\tm.ResetCreateByUser()\n\t\treturn nil\n\tcase system.FieldUpdateByUser:\n\t\tm.ResetUpdateByUser()\n\t\treturn nil\n\tcase system.FieldCreateTime:\n\t\tm.ResetCreateTime()\n\t\treturn nil\n\tcase system.FieldUpdateTime:\n\t\tm.ResetUpdateTime()\n\t\treturn nil\n\tcase system.FieldName:\n\t\tm.ResetName()\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown System field %s\", name)\n}", "func (m *MarketHoursMutation) ResetField(name string) error {\n\tswitch name {\n\tcase markethours.FieldDate:\n\t\tm.ResetDate()\n\t\treturn nil\n\tcase markethours.FieldStartTime:\n\t\tm.ResetStartTime()\n\t\treturn nil\n\tcase markethours.FieldEndTime:\n\t\tm.ResetEndTime()\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown MarketHours field %s\", name)\n}", "func ZeroBytes() []byte {\n\treturn zeroLabelBytes\n}", "func (t JsonType) Zero() interface{} {\n\t// MySQL throws an error for INSERT IGNORE, UPDATE IGNORE, etc. when bad json is encountered:\n\t// ERROR 3140 (22032): Invalid JSON text: \"Invalid value.\" at position 0 in value for column 'table.column'.\n\treturn nil\n}", "func (a Attribute) IsZero() bool {\n\treturn a.Key == \"\"\n}", "func ZeroKey(k *ecdsa.PrivateKey) {\n\tb := k.D.Bits()\n\tfor i := range b {\n\t\tb[i] = 0\n\t}\n}", "func Zero[T Number](val T, a ...any) {\n\tif val != 0 {\n\t\tdefMsg := fmt.Sprintf(assertionMsg+\": got '%v', want (== '0')\", val)\n\t\tDefault().reportAssertionFault(defMsg, a...)\n\t}\n}", "func (zf *ZeroField) Literal(value interface{}) (string, error) {\n\tswitch v := value.(type) {\n\tcase bool, float32, float64, int32, uint32:\n\t\treturn fmt.Sprintf(\"%v\", v), nil\n\tcase int64, uint64:\n\t\treturn fmt.Sprintf(`%s(%d)`, zf.Int64Type(), v), nil\n\tcase string:\n\t\treturn dart.RawString(v), nil\n\tcase []byte:\n\t\treturn \"const <int>[\" + util.BytesLiteral(v) + \"]\", nil\n\tcase pgs.EnumValue:\n\t\ttargetFullEnumClass, err := zf.Zeros().FullPbEnum(v.Enum())\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn targetFullEnumClass.Dot(zf.File.Dart.NameOf(v)).String(), nil\n\tcase *any.Any:\n\t\treturn zf.AnyType().Init().\n\t\t\tDotString(\".typeUrl=\" + v.TypeUrl).\n\t\t\tDotString(\".value=const <int>[\" + util.BytesLiteral(v.Value) + \"]\").\n\t\t\tString(), nil\n\tcase *duration.Duration:\n\t\treturn zf.DurationType().Init().\n\t\t\tDotString(fmt.Sprintf(\".seconds=%d\", v.Seconds)).\n\t\t\tDotString(fmt.Sprintf(\".nanos=%d\", v.Nanos)).\n\t\t\tString(), nil\n\tcase *timestamp.Timestamp:\n\t\treturn zf.TimestampType().Init().\n\t\t\tDotString(fmt.Sprintf(\".seconds=%d\", v.Seconds)).\n\t\t\tDotString(fmt.Sprintf(\".nanos=%d\", v.Nanos)).\n\t\t\tString(), nil\n\tcase *ZeroEvalNow:\n\t\tt := v.Format.Dot(\"ofTime(DateTime.now())\").String()\n\t\tif v.Add != 0 {\n\t\t\tt += fmt.Sprintf(\"%+d\", v.Add)\n\t\t}\n\t\treturn t, nil\n\tcase *wrappers.DoubleValue:\n\t\treturn fmt.Sprintf(\"%s.DoubleValue()..value=%v\",\n\t\t\tzf.WrappersFile(), v.Value), nil\n\tcase *wrappers.FloatValue:\n\t\treturn fmt.Sprintf(\"%s.FloatValue()..value=%v\",\n\t\t\tzf.WrappersFile(), v.Value), nil\n\tcase *wrappers.Int64Value:\n\t\treturn fmt.Sprintf(\"%s.Int64Value()..value=%s(%d)\",\n\t\t\tzf.WrappersFile(), zf.Int64Type(), v.Value), nil\n\tcase *wrappers.UInt64Value:\n\t\treturn fmt.Sprintf(\"%s.UInt64Value()..value=%s(%d)\",\n\t\t\tzf.WrappersFile(), zf.Int64Type(), v.Value), nil\n\tcase *wrappers.Int32Value:\n\t\treturn fmt.Sprintf(\"%s.Int32Value()..value=%v\",\n\t\t\tzf.WrappersFile(), v.Value), nil\n\tcase *wrappers.UInt32Value:\n\t\treturn fmt.Sprintf(\"%s.UInt32Value()..value=%v\",\n\t\t\tzf.WrappersFile(), v.Value), nil\n\tcase *wrappers.BoolValue:\n\t\treturn fmt.Sprintf(\"%s.BoolValue()..value=%v\",\n\t\t\tzf.WrappersFile(), v.Value), nil\n\tcase *wrappers.StringValue:\n\t\treturn fmt.Sprintf(\"%s.StringValue()..value=%s\",\n\t\t\tzf.WrappersFile(), dart.RawString(v.Value)), nil\n\tcase *wrappers.BytesValue:\n\t\treturn fmt.Sprintf(\"%s.BytesValue()..value=const <int>[%s]\",\n\t\t\tzf.WrappersFile(), util.BytesLiteral(v.Value)), nil\n\tcase proto.Message:\n\t\tb, err := proto.Marshal(v)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tembed, err := zf.Zeros().FullPbClass(zf.ElementOrEmbed())\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn fmt.Sprintf(\"%s.fromBuffer(const <int>[%s])\",\n\t\t\tembed, util.BytesLiteral(b)), nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"bug: unsupported literal type: %#T\", value)\n\t}\n}", "func fieldIsEmpty(p unsafe.Pointer) bool {\n\treturn uintptr(p) == uintptr(0)\n}", "func zeroInt(s string) string {\n\tn, _ := strconv.Atoi(s)\n\treturn strconv.FormatInt(int64(n), 10)\n}", "func TestPetNameForZeroWords(t *testing.T) {\n\tname := Generate(0, 0, \"\")\n\tif name != \"\" {\n\t\tt.Fatalf(\"Generated a 0-word name, '%s'\", name)\n\t}\n}" ]
[ "0.7071071", "0.6937787", "0.6822378", "0.67894715", "0.66243315", "0.64448553", "0.6401543", "0.63275677", "0.6122518", "0.6109088", "0.6105732", "0.60884833", "0.60584295", "0.6056281", "0.6009469", "0.60008335", "0.599678", "0.5995564", "0.59935313", "0.59933484", "0.5980133", "0.5976903", "0.5970654", "0.5965744", "0.59431744", "0.59359837", "0.59292686", "0.59230506", "0.5916892", "0.59079206", "0.5885411", "0.5872884", "0.5811082", "0.57672125", "0.5744787", "0.56807023", "0.56791854", "0.5630574", "0.56259406", "0.5624408", "0.5578623", "0.5556238", "0.5550103", "0.55475485", "0.5547468", "0.5541518", "0.5499962", "0.54953694", "0.54937685", "0.54708123", "0.5469101", "0.54685885", "0.54654384", "0.546017", "0.54438883", "0.5437915", "0.5393902", "0.5393902", "0.5393902", "0.53886473", "0.53739953", "0.53685963", "0.53535765", "0.5351539", "0.5344566", "0.5341291", "0.5333004", "0.5320557", "0.53121704", "0.5308661", "0.5304016", "0.53009945", "0.53009945", "0.52897155", "0.52875197", "0.52818227", "0.52818227", "0.52818227", "0.52818227", "0.52672446", "0.5245441", "0.5236206", "0.52294457", "0.5224362", "0.52192765", "0.52091426", "0.5208578", "0.5201859", "0.5201397", "0.519244", "0.5191783", "0.5188684", "0.5186965", "0.51829696", "0.51605356", "0.5158342", "0.51534665", "0.51511276", "0.51499605", "0.5148349" ]
0.68677104
2
Name returns name of field
func (f *Fieldx) Name() string { return f.data.Name }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (p *GetField) Name() string { return p.name }", "func (f *Field) Name() string {\n\treturn f.field.Name\n}", "func (field Field) Name() string {\n\tif len(field.Names) > 0 {\n\t\treturn field.Names[0].String()\n\t}\n\n\t// The field has no name, so we use Type name as the field name.\n\treturn itemTypeName(field.TypeValue.Type).Name\n}", "func (f *Field) Name() string {\n\tjsonTag := reflect.StructTag(f.Tag.Value[1 : len(f.Tag.Value)-1]).Get(\"json\") // Delete first and last quotation\n\tjsonTag = strings.Split(jsonTag, \",\")[0] // This can return \"-\"\n\tif jsonTag != \"\" {\n\t\treturn jsonTag\n\t}\n\n\tif f.Names != nil {\n\t\treturn f.Names[0].Name\n\t}\n\n\treturn f.Type.(*ast.Ident).Name\n}", "func (c *STableField) Name() string {\n\tif len(c.alias) > 0 {\n\t\treturn c.alias\n\t}\n\treturn c.spec.Name()\n}", "func (s *StructField) Name() string {\n\treturn s.name\n}", "func name(v reflect.StructField) string {\n\tif name, ok := v.Tag.Lookup(\"name\"); ok {\n\t\treturn name\n\t}\n\treturn v.Name\n}", "func (o *SingleSelectFieldField) GetName() string {\n\tif o == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\n\treturn o.Name\n}", "func fieldname(field *ast.Field) string {\n\treturn field.Names[0].Name\n}", "func (f *DialectMessageField) GetName() string {\n\treturn f.name\n}", "func (c *Checker) getFieldName(field reflect.StructField) string {\n\tname := field.Name\n\tif c.JSONTag != nil {\n\t\tif val, ok := field.Tag.Lookup(\"json\"); ok {\n\t\t\tname = strings.Split(val, \",\")[0]\n\t\t}\n\t}\n\tif name == \"-\" {\n\t\tif !c.JSONTag.IgnoreDashFields {\n\t\t\tname = field.Name\n\t\t}\n\t}\n\treturn name\n}", "func (e *Encoder) getFieldName(field reflect.StructField) string {\n\tif e.useTags {\n\t\tname := field.Tag.Get(e.tag)\n\t\t// skip columns tagged with -\n\t\tif name == \"-\" {\n\t\t\treturn \"\"\n\t\t}\n\t\tif name != \"\" {\n\t\t\treturn name\n\t\t}\n\t}\n\treturn field.Name\n\n}", "func (c FieldsCollection) Name() *models.Field {\n\treturn c.MustGet(\"Name\")\n}", "func (f *Field) GetName() string {\n\treturn formatGoName(f.Name)\n}", "func (o FieldOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v Field) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func getFieldName(f reflect.StructField) string {\n\tn := f.Name\n\ttag, found := f.Tag.Lookup(\"json\")\n\tif found {\n\t\t// If we have a json field, and the first part of it before the\n\t\t// first comma is non-empty, that's our field name.\n\t\tparts := strings.Split(tag, \",\")\n\t\tif parts[0] != \"\" {\n\t\t\tn = parts[0]\n\t\t}\n\t}\n\treturn n\n}", "func (f BinaryField) GetName() string {\n\treturn f.name\n}", "func (e ErrorSyntax) FieldName() string {\n\treturn e.fieldName\n}", "func (e ErrorValidation) FieldName() string {\n\treturn e.fieldName\n}", "func (o *FormField) GetName() string {\n\tif o == nil || o.Name == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Name\n}", "func (p *gte) FieldName() (fieldOrOperatorName string) {\n\treturn p.Field\n}", "func (e IdentifierValidationError) Field() string { return e.field }", "func (s *MyTestStruct) Name() string {\n\treturn s.field_Name\n}", "func (info *TodoPropertyInfo) FieldName() string {\n\treturn info.fieldName\n}", "func (e RanfunctionNameValidationError) Field() string { return e.field }", "func (f BooleanField) GetName() string {\n\treturn f.name\n}", "func FieldName(name string, buf []byte) []byte {\n\tbuf = String(name, buf)\n\treturn append(buf, ':')\n}", "func (e SkillValidationError) Field() string { return e.field }", "func (e RanparameterNameValidationError) Field() string { return e.field }", "func getFieldNameByTag(v reflect.Value, name, tagKey string) string {\n\tvt := reflect.TypeOf(v.Interface())\n\tfor i := 0; i < vt.NumField(); i++ {\n\t\tfield := vt.Field(i)\n\t\talias := field.Tag.Get(tagKey)\n\t\tif alias == name {\n\t\t\treturn field.Name\n\t\t}\n\t}\n\treturn name\n}", "func (c CSRF) Name() string { return c.FieldName }", "func (t *Type) GetName() string { return t.Name }", "func getNameFromTag(f reflect.StructField, tagName string) string {\n\ttag, _ := parseTag(f, tagName)\n\tif tag != \"\" {\n\t\treturn tag\n\t}\n\treturn f.Name\n}", "func (bw *BufWriter) FieldName(name string) {\n\tif bw.Error != nil {\n\t\treturn\n\t}\n\tbw.stringBuf = String(name, bw.stringBuf[:0])\n\tbw.stringBuf = append(bw.stringBuf, ':')\n\t_, bw.Error = bw.writer.Write(bw.stringBuf)\n}", "func (e NoOneofsValidationError) Field() string { return e.field }", "func (o *OutputField) GetFieldName() string {\n\tif o == nil || IsNil(o.FieldName) {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.FieldName\n}", "func (e SimpleRequestValidationError) Field() string { return e.field }", "func ExtractFieldName(field *ast.Field) string {\r\n\tif field != nil && len(field.Names) > 0 {\r\n\t\treturn field.Names[0].Name\r\n\t}\r\n\r\n\treturn \"\"\r\n}", "func (Functions) CFieldName(obj interface{}) string {\n\t// Use goKeywords here as cgo seems to get confused when using go keywords\n\t// in C code. :(\n\treturn nameOptions{Remap: goKeywords}.convert(nameOf(obj))\n}", "func (tt *EnumTable) FieldGoName(i int) string {\n\tif i >= len(tt.FieldNames) {\n\t\treturn \"\"\n\t}\n\tfn := tt.FieldNames[i]\n\tfn = UpperCaseIdentifier(fn)\n\treturn fn\n}", "func (o IndexingConfigurationThingIndexingConfigurationManagedFieldOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v IndexingConfigurationThingIndexingConfigurationManagedField) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func targetFieldName(s *types.Struct, i int) string {\n\ttag := reflect.StructTag(s.Tag(i)).Get(\"rgo\")\n\tif tag != \"\" {\n\t\treturn tag\n\t}\n\treturn s.Field(i).Name()\n}", "func Field(v reflect.StructField) (name string, mapped bool) {\n\tns := v.Tag.Get(\"ns\")\n\tif ns != \"\" {\n\t\tmapped = true\n\t\tname = ns\n\t\treturn\n\t}\n\tname = v.Name\n\treturn\n}", "func (o FieldResponseOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v FieldResponse) string { return v.Name }).(pulumi.StringOutput)\n}", "func (e JwtComponentValidationError) Field() string { return e.field }", "func getColumnName(sf reflect.StructField, tag reflect.StructTag) string {\n\tdbTag := tag.Get(\"db\")\n\tif dbTag == \"\" {\n\t\treturn strings.ToLower(sf.Name)\n\t}\n\treturn dbTag\n}", "func (e ArfcnValidationError) Field() string { return e.field }", "func (e RicStyleNameValidationError) Field() string { return e.field }", "func fieldFlagName(fieldName string) (ret string) {\n\t// defer func() { log.Println(fieldName, ret) }()\n\t// TCP\n\tif ss := regexp.MustCompile(\"^[[:upper:]]{2,}$\").FindStringSubmatch(fieldName); ss != nil {\n\t\treturn strings.ToLower(ss[0])\n\t}\n\t// TCPAddr\n\tif ss := regexp.MustCompile(\"^([[:upper:]]+)([[:upper:]][^[:upper:]].*?)$\").FindStringSubmatch(fieldName); ss != nil {\n\t\treturn strings.ToLower(ss[1]) + ss[2]\n\t}\n\t// Addr\n\tif ss := regexp.MustCompile(\"^([[:upper:]])(.*)$\").FindStringSubmatch(fieldName); ss != nil {\n\t\treturn strings.ToLower(ss[1]) + ss[2]\n\t}\n\tpanic(fieldName)\n}", "func (e TableValidationError) Field() string { return e.field }", "func (e NrtValidationError) Field() string { return e.field }", "func (e SXGValidationError) Field() string { return e.field }", "func (f *Field) TypeName() string {\n\treturn typeName(f.Type)\n}", "func (e GetInstanceRequestValidationError) Field() string { return e.field }", "func (e AdminValidationError) Field() string { return e.field }", "func (e NrarfcnValidationError) Field() string { return e.field }", "func (p FloatFormalParam) GetFieldName() string {\n\treturn p.Name\n}", "func (e MovableObjectValidationError) Field() string { return e.field }", "func keyname(field *ast.Field) string {\n\ttags := tags(field)\n\n\tif len(tags) > 0 {\n\t\tif len(tags[0]) == 0 {\n\t\t\treturn fieldname(field)\n\t\t} else if tags[0] == \"-\" {\n\t\t\treturn \"\"\n\t\t} else {\n\t\t\treturn tags[0]\n\t\t}\n\t} else {\n\t\treturn fieldname(field)\n\t}\n}", "func (e NamespaceValidationError) Field() string { return e.field }", "func (c *Column) Field() string {\n\treturn c.field\n}", "func (o FieldOutput) JsonName() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v Field) *string { return v.JsonName }).(pulumi.StringPtrOutput)\n}", "func (e JwtHeaderValidationError) Field() string { return e.field }", "func (e RequestValidationError) Field() string { return e.field }", "func (e HelloRequestValidationError) Field() string { return e.field }", "func (f *Field) Key() *Name {\n\tif f.Alias != nil {\n\t\treturn f.Alias\n\t}\n\treturn f.Name\n}", "func (e CreateEmployeeRequestValidationError) Field() string { return e.field }", "func (e LoggingValidationError) Field() string { return e.field }", "func (m *EventMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase event.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (e GetRequestValidationError) Field() string { return e.field }", "func (e GetRequestValidationError) Field() string { return e.field }", "func (e GetEventByIDRequestValidationError) Field() string { return e.field }", "func (e HTTPRequestValidationError) Field() string { return e.field }", "func (e EutracgiValidationError) Field() string { return e.field }", "func (e CreateTodoRequestValidationError) Field() string { return e.field }", "func (e CreateRequestValidationError) Field() string { return e.field }", "func (e CreateRequestValidationError) Field() string { return e.field }", "func (f *Field) String() string {\n\tif f.name != \"\" {\n\t\treturn f.name + \" \" + f.typ.toTypString()\n\t}\n\n\treturn f.typ.toTypString()\n}", "func (e GetUserRequestValidationError) Field() string { return e.field }", "func (e CreateNamespaceReqValidationError) Field() string { return e.field }", "func (e RdsValidationError) Field() string { return e.field }", "func (e GitopsCFValidationError) Field() string { return e.field }", "func (e TagSpecifierValidationError) Field() string { return e.field }", "func (e GetNamespaceReqValidationError) Field() string { return e.field }", "func GetInstNameField(objID string) string {\n\tswitch objID {\n\tcase BKInnerObjIDApp:\n\t\treturn BKAppNameField\n\tcase BKInnerObjIDSet:\n\t\treturn BKSetNameField\n\tcase BKInnerObjIDModule:\n\t\treturn BKModuleNameField\n\tcase BKInnerObjIDObject:\n\t\treturn BKInstNameField\n\tcase BKInnerObjIDHost:\n\t\treturn BKHostNameField\n\tcase BKInnerObjIDProc:\n\t\treturn BKProcNameField\n\tcase BKInnerObjIDPlat:\n\t\treturn BKCloudNameField\n\tcase BKTableNameInstAsst:\n\t\treturn BKFieldID\n\tdefault:\n\t\tif IsObjectInstAsstShardingTable(objID) {\n\t\t\treturn BKFieldID\n\t\t}\n\t\treturn BKInstNameField\n\t}\n}", "func (e NrcgiValidationError) Field() string { return e.field }", "func (d UserData) Name() string {\n\tval := d.ModelData.Get(models.NewFieldName(\"Name\", \"name\"))\n\tif !d.Has(models.NewFieldName(\"Name\", \"name\")) {\n\t\treturn *new(string)\n\t}\n\treturn val.(string)\n}", "func (s *Structx) Name() string {\n\treturn s.value.Type().Name()\n}", "func getFieldColumnName(field reflect.StructField) string {\n\ttag, ok := field.Tag.Lookup(packageTagName)\n\tif ok && tag != \"\" {\n\t\tif col := lookForSetting(tag, \"col\"); col != \"\" && col != \"col\" {\n\t\t\treturn col\n\t\t}\n\t}\n\treturn strcase.ToSnake(field.Name)\n}", "func (e TwoOneofsValidationError) Field() string { return e.field }", "func (e MinioComponentValidationError) Field() string { return e.field }", "func (t Scalar) Name() string {\n\treturn strings.Title(t.Type)\n}", "func (e JsonToMetadataValidationError) Field() string { return e.field }", "func (e CreatePaymentRequestValidationError) Field() string { return e.field }", "func (e SearchRequestValidationError) Field() string { return e.field }", "func (e GetUsersRequestValidationError) Field() string { return e.field }", "func (e GetMessageRequestValidationError) Field() string { return e.field }", "func (f *Field) String() string {\n\treturn fmt.Sprintf(\"Name: %s, ID: %d\", f.Name, f.ID)\n}", "func (e CreateBookingRequestValidationError) Field() string { return e.field }", "func (m *DiseaseMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase disease.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}" ]
[ "0.832963", "0.7992543", "0.7985175", "0.7853335", "0.7773557", "0.754141", "0.7497088", "0.74856347", "0.73485583", "0.7335375", "0.7331214", "0.7308102", "0.7304467", "0.7294199", "0.72129047", "0.7151427", "0.71134114", "0.70237076", "0.6984971", "0.6883465", "0.6881271", "0.6872163", "0.6867819", "0.6842361", "0.6719139", "0.67140484", "0.6682224", "0.6644594", "0.6639321", "0.6632763", "0.66161823", "0.65994143", "0.6566606", "0.6566087", "0.65555793", "0.65490806", "0.6548159", "0.6537266", "0.6536884", "0.65368694", "0.65261304", "0.65123963", "0.6508065", "0.6498189", "0.6483257", "0.6479988", "0.64511436", "0.64419115", "0.6440527", "0.6438524", "0.64381593", "0.64283156", "0.6425721", "0.6422755", "0.6420746", "0.64092183", "0.6406251", "0.640309", "0.6401213", "0.63956064", "0.63932574", "0.6390186", "0.6386123", "0.63848", "0.63837093", "0.63768315", "0.63733965", "0.6362391", "0.6361718", "0.6361649", "0.6361649", "0.6360669", "0.63538015", "0.63510936", "0.6349651", "0.6348149", "0.6348149", "0.63440406", "0.6340678", "0.6338552", "0.63370174", "0.6335291", "0.6331691", "0.63280505", "0.63255405", "0.6322683", "0.63203996", "0.631943", "0.6312784", "0.6311896", "0.6311358", "0.63107216", "0.63101274", "0.6308405", "0.6308331", "0.63078684", "0.63074106", "0.6306446", "0.63063306", "0.6306317" ]
0.7724901
5
Kind returns kind of field
func (f *Fieldx) Kind() reflect.Kind { return f.value.Kind() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *Field) Kind() reflect.Kind {\n\treturn f.value.Kind()\n}", "func (s *StructField) Kind() reflect.Kind {\n\treturn s.value.Kind()\n}", "func (f *Field) FieldType() int {\r\n\r\n\tswitch f.Value.(type) {\r\n\tcase int:\r\n\t\treturn 0x00\r\n\tcase bool:\r\n\t\treturn 0x01\r\n\tcase float64:\r\n\t\treturn 0x02\r\n\tcase string:\r\n\t\treturn 0x03\r\n\t}\r\n\t// panic(\"asdf\")\r\n\t// Should never be able to come here because it will overflow byte\r\n\t// ###Make better solution\r\n\treturn -1\r\n}", "func (d Document) Kind() string { return d.kind }", "func (t *Type) Kind() string {\n\treturn t.kind\n}", "func (f *Field) TypeName() string {\n\treturn typeName(f.Type)\n}", "func (p *GetField) Type() sql.Type {\n\treturn p.fieldType\n}", "func (c Column) Kind() string {\n\tif c.DataType.IsInt() {\n\t\treturn c.DataType.String()\n\t}\n\tvar a []string\n\tif c.DataSize > 0 {\n\t\ta = append(a, ds.Unit(c.DataSize).String())\n\t}\n\tif c.DataType.IsString() {\n\t\ta = append(a, c.Charset)\n\t}\n\tif s := strings.Join(a, \", \"); s != \"\" {\n\t\treturn fmt.Sprintf(\"%s(%s)\", c.DataType.String(), s)\n\t}\n\treturn c.DataType.String()\n}", "func (d *Descriptor) Kind() Kind {\n\treturn d.kind\n}", "func (p Typed) Kind() uint32 {\n\treturn p.TypeId & TypeIDMaskKind\n}", "func getType(field *ast.Field) string {\n\tif ident, ok := field.Type.(*ast.Ident); ok {\n\t\treturn ident.Name\n\t} else if _, ok := field.Type.(*ast.StarExpr); ok {\n\t\treturn \"*\"\n\t} else if _, ok := field.Type.(*ast.ArrayType); ok {\n\t\treturn \"[]\"\n\t}\n\treturn \"\"\n}", "func (t TypeField) getType() string {\n\treturn t.IsType\n}", "func (meta *Metadata) GetKind() string {\n\treturn meta.Kind\n}", "func (m *Device) GetKind() (val string, set bool) {\n\tif m.Kind == nil {\n\t\treturn\n\t}\n\n\treturn *m.Kind, true\n}", "func kindFromDBTypeName(log lg.Log, colName, dbTypeName string) kind.Kind {\n\tvar knd kind.Kind\n\tdbTypeName = strings.ToUpper(dbTypeName)\n\n\t// Given variations such as VARCHAR(255), we first trim the parens\n\t// parts. Thus VARCHAR(255) becomes VARCHAR.\n\ti := strings.IndexRune(dbTypeName, '(')\n\tif i > 0 {\n\t\tdbTypeName = dbTypeName[0:i]\n\t}\n\n\tswitch dbTypeName {\n\tdefault:\n\t\tlog.Warnf(\"Unknown MySQL database type %q for column %q: using %q\", dbTypeName, colName, kind.Unknown)\n\t\tknd = kind.Unknown\n\tcase \"\":\n\t\tknd = kind.Unknown\n\tcase \"INTEGER\", \"INT\", \"TINYINT\", \"SMALLINT\", \"MEDIUMINT\", \"BIGINT\", \"YEAR\", \"BIT\":\n\t\tknd = kind.Int\n\tcase \"DECIMAL\", \"NUMERIC\":\n\t\tknd = kind.Decimal\n\tcase \"CHAR\", \"VARCHAR\", \"TEXT\", \"TINYTEXT\", \"MEDIUMTEXT\", \"LONGTEXT\":\n\t\tknd = kind.Text\n\tcase \"ENUM\", \"SET\":\n\t\tknd = kind.Text\n\tcase \"JSON\":\n\t\tknd = kind.Text\n\tcase \"VARBINARY\", \"BINARY\", \"BLOB\", \"MEDIUMBLOB\", \"LONGBLOB\", \"TINYBLOB\":\n\t\tknd = kind.Bytes\n\tcase \"DATETIME\", \"TIMESTAMP\":\n\t\tknd = kind.Datetime\n\tcase \"DATE\":\n\t\tknd = kind.Date\n\tcase \"TIME\":\n\t\tknd = kind.Time\n\tcase \"FLOAT\", \"DOUBLE\", \"DOUBLE PRECISION\", \"REAL\":\n\t\tknd = kind.Float\n\tcase \"BOOL\", \"BOOLEAN\":\n\t\t// In practice these are not returned by the mysql driver.\n\t\tknd = kind.Bool\n\t}\n\n\treturn knd\n}", "func GetFieldType(v interface{}, field string) reflect.Kind {\n\tvar immutable reflect.Value\n\timmutable = GetReflectValue(v)\n\tval := immutable.FieldByName(field)\n\treturn val.Kind()\n}", "func (g GoType) Kind() Expr {\n\tif g == \"\" || g == GoBytes {\n\t\treturn \"\"\n\t}\n\treturn \"reflect.\" + Expr(strings.ToUpper(string(g[:1]))+string(g[1:]))\n}", "func (field Field) CountType() string {\n\tif countType, ok := field.TagGet(\"countType\"); ok {\n\t\treturn countType\n\t}\n\treturn \"uint16\"\n}", "func (c EntityObject) Kind() string {\n\treturn c.kind\n}", "func (t *Type) DDDField() *Type", "func (f OrdTypeField) Tag() quickfix.Tag { return tag.OrdType }", "func TestParser_GetKind(t *testing.T) {\n\tp := &Parser{}\n\trequire.Equal(t, model.KindTerraform, p.GetKind())\n}", "func getKind(t reflect.Type) reflect.Kind {\n\tif t == nil {\n\t\treturn reflect.Interface\n\t}\n\n\treturn t.Kind()\n}", "func (s *Structured) GetKind() string {\n\treturn s.cloudEvent.Source\n}", "func (f *tmplFuncs) fieldType(field *descriptor.FieldDescriptorProto) string {\n\tif field.TypeName != nil {\n\t\treturn f.cleanType(*field.TypeName)\n\t}\n\treturn util.FieldTypeName(field.Type)\n}", "func GetKind(node *yaml.RNode, path string) string {\n\treturn GetStringField(node, path, \"kind\")\n}", "func (lbase *Logbase) GetKind(name string) (*Node, bool, error) {\n\treturn lbase.NewNode(name, LBTYPE_KIND, false)\n}", "func getFieldType(typ reflect.Type) tools.FieldType {\n\tk := typ.Kind()\n\tswitch {\n\tcase k == reflect.Bool:\n\t\treturn tools.BOOLEAN\n\tcase k >= reflect.Int && k <= reflect.Uint64:\n\t\treturn tools.INTEGER\n\tcase k == reflect.Float32 || k == reflect.Float64:\n\t\treturn tools.FLOAT\n\tcase k == reflect.String:\n\t\treturn tools.CHAR\n\tcase k == reflect.Ptr:\n\t\tindTyp := typ.Elem()\n\t\tswitch indTyp.Kind() {\n\t\tcase reflect.Struct:\n\t\t\treturn tools.MANY2ONE\n\t\tcase reflect.Slice:\n\t\t\treturn tools.ONE2MANY\n\t\t}\n\t}\n\tswitch typ {\n\tcase reflect.TypeOf(DateTime{}):\n\t\treturn tools.DATETIME\n\tcase reflect.TypeOf(Date{}):\n\t\treturn tools.DATE\n\t}\n\ttools.LogAndPanic(log, \"Unable to match field type with go Type. Please specify 'type()' in struct tag\", \"type\", typ)\n\treturn tools.NO_TYPE\n}", "func (p Primitive) Kind() Kind { return Kind(p) }", "func fieldTypeString(f index.FieldType) (string, error) {\n\tswitch f {\n\tcase index.TextField:\n\t\treturn \"string\", nil\n\tcase index.NumericField:\n\t\treturn \"double\", nil\n\tdefault:\n\t\treturn \"\", errors.New(\"Unsupported field type\")\n\t}\n}", "func (v Value) Kind() Kind {\n\tswitch x := v.any.(type) {\n\tcase Kind:\n\t\treturn x\n\tcase stringptr:\n\t\treturn KindString\n\tcase timeLocation:\n\t\treturn KindTime\n\tcase groupptr:\n\t\treturn KindGroup\n\tcase LogValuer:\n\t\treturn KindLogValuer\n\tcase kind: // a kind is just a wrapper for a Kind\n\t\treturn KindAny\n\tdefault:\n\t\treturn KindAny\n\t}\n}", "func TestParser_GetKind(t *testing.T) {\n\tp := &Parser{}\n\trequire.Equal(t, model.KindJSON, p.GetKind())\n}", "func (f ExtensionField) Type() protoreflect.ExtensionType {\n\treturn f.typ\n}", "func (h *ResourceHeader) GetKind() string {\n\treturn h.Kind\n}", "func FieldType(v interface{}) (fieldType string, repeated bool) {\n\tswitch val := v.(type) {\n\tcase float64:\n\t\tfieldType = FieldTypeFloat\n\t\tif (val/10)*10 == val {\n\t\t\tfieldType = FieldTypeInt\n\t\t}\n\tcase int, uint, int8, int16, int32, int64, uint8, uint16, uint32, uint64:\n\t\tfieldType = FieldTypeInt\n\tcase bool:\n\t\tfieldType = FieldTypeBool\n\tcase []interface{}:\n\t\tif len(val) > 0 {\n\t\t\tfieldType, _ = FieldType(val[0])\n\t\t}\n\t\trepeated = true\n\tcase map[string]interface{}:\n\t\tfieldType = FieldTypeRecord\n\tdefault:\n\t\tfieldType = FieldTypeString\n\t}\n\treturn fieldType, repeated\n}", "func (c FieldsCollection) Type() *models.Field {\n\treturn c.MustGet(\"Type\")\n}", "func (k *Key) Kind() string { return k.toks[len(k.toks)-1].Kind }", "func CastField(p Persistable, name string, kind reflect.Kind) interface{} {\n // @TODO improve support of other Type (float, string, etc...)\n r := reflect.ValueOf(p)\n f := reflect.Indirect(r).FieldByName(name)\n if kind == reflect.Int || kind == reflect.Int64 {\n return f.Int()\n }\n\n return f.String()\n}", "func (plainFloat) Kind() datamodel.Kind {\n\treturn datamodel.Kind_Float\n}", "func (ft FieldType) String() string {\n\tswitch ft {\n\tcase WorkFlowID:\n\t\treturn \"workflowId\"\n\tcase ExecutionID:\n\t\treturn \"executionId\"\n\tcase NodeID:\n\t\treturn \"nodeId\"\n\tcase InstanceID:\n\t\treturn \"instanceId\"\n\tcase InterfaceName:\n\t\treturn \"interfaceName\"\n\tcase OperationName:\n\t\treturn \"operationName\"\n\tcase TypeID:\n\t\treturn \"type\"\n\t}\n\treturn \"\"\n}", "func (o *ManualDependency) GetKind() string {\n\tif o == nil || o.Kind == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Kind\n}", "func (fd FileDescriptor) Type() byte {\n\treturn fd.TypeAndNameLength >> 4\n}", "func (r Resource) Kind() string {\n\treturn r.kind\n}", "func (af *filtBase) GetKindName() string {\n\treturn af.kind\n}", "func (s *DatabaseServerV3) GetKind() string {\n\treturn s.Kind\n}", "func isGtField(fl FieldLevel) bool {\n\tfield := fl.Field()\n\tkind := field.Kind()\n\n\tcurrentField, currentKind, ok := fl.GetStructFieldOK()\n\tif !ok || currentKind != kind {\n\t\treturn false\n\t}\n\n\tswitch kind {\n\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\n\t\treturn field.Int() > currentField.Int()\n\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\n\t\treturn field.Uint() > currentField.Uint()\n\n\tcase reflect.Float32, reflect.Float64:\n\n\t\treturn field.Float() > currentField.Float()\n\n\tcase reflect.Struct:\n\n\t\tfieldType := field.Type()\n\n\t\tif fieldType.ConvertibleTo(timeType) && currentField.Type().ConvertibleTo(timeType) {\n\n\t\t\tt := currentField.Convert(timeType).Interface().(time.Time)\n\t\t\tfieldTime := field.Convert(timeType).Interface().(time.Time)\n\n\t\t\treturn fieldTime.After(t)\n\t\t}\n\n\t\t// Not Same underlying type i.e. struct and time\n\t\tif fieldType != currentField.Type() {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// default reflect.String\n\treturn len(field.String()) > len(currentField.String())\n}", "func (d Document) Type() string { return fmt.Sprintf(\"%s.%s\", d.apiVersion, d.kind) }", "func (o *SingleSelectFieldField) GetTypeOk() (*string, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn &o.Type, true\n}", "func (pf field) WTFType() string {\n\tswitch {\n\tcase pf.isList && pf.isFormField:\n\t\treturn fmt.Sprintf(\"FieldList(FormField(%v))\", pf.Type)\n\tcase pf.isList:\n\t\treturn fmt.Sprintf(\"FieldList(%v('%v', [required()]), %v)\", pf.Type, pf.Name, pf.Validators)\n\tcase pf.isFormField:\n\t\treturn fmt.Sprintf(\"FormField(%v)\", pf.Type)\n\tdefault:\n\t\treturn fmt.Sprintf(\"%v(validators=[%v])\", pf.Type, pf.Validators)\n\t}\n}", "func (c *Column) GetTypeDesc() string {\n\tdesc := c.FieldType.CompactStr()\n\tif mysql.HasUnsignedFlag(c.Flag) && c.Tp != mysql.TypeBit && c.Tp != mysql.TypeYear {\n\t\tdesc += \" unsigned\"\n\t}\n\tif mysql.HasZerofillFlag(c.Flag) && c.Tp != mysql.TypeYear {\n\t\tdesc += \" zerofill\"\n\t}\n\treturn desc\n}", "func (t *Type) IsKind(et EType) bool", "func fieldType(e *xmlTree) string {\n\tif e.Cdata {\n\t\treturn e.Name\n\t}\n\treturn e.Type\n}", "func (op *GenericOperation) Kind() uint8 {\n\t// Must be at least long enough to get the kind byte\n\tif len(op.hex) <= 33 {\n\t\treturn opKindUnknown\n\t}\n\n\treturn op.hex[33]\n}", "func (ft *FieldType) String() string {\n\tvar builder strings.Builder\n\tbuilder.WriteString(\"FieldType(\")\n\tbuilder.WriteString(fmt.Sprintf(\"id=%v, \", ft.ID))\n\tbuilder.WriteString(\"int=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Int))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"int8=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Int8))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"int16=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Int16))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"int32=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Int32))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"int64=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Int64))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"optional_int=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.OptionalInt))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"optional_int8=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.OptionalInt8))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"optional_int16=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.OptionalInt16))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"optional_int32=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.OptionalInt32))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"optional_int64=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.OptionalInt64))\n\tbuilder.WriteString(\", \")\n\tif v := ft.NillableInt; v != nil {\n\t\tbuilder.WriteString(\"nillable_int=\")\n\t\tbuilder.WriteString(fmt.Sprintf(\"%v\", *v))\n\t}\n\tbuilder.WriteString(\", \")\n\tif v := ft.NillableInt8; v != nil {\n\t\tbuilder.WriteString(\"nillable_int8=\")\n\t\tbuilder.WriteString(fmt.Sprintf(\"%v\", *v))\n\t}\n\tbuilder.WriteString(\", \")\n\tif v := ft.NillableInt16; v != nil {\n\t\tbuilder.WriteString(\"nillable_int16=\")\n\t\tbuilder.WriteString(fmt.Sprintf(\"%v\", *v))\n\t}\n\tbuilder.WriteString(\", \")\n\tif v := ft.NillableInt32; v != nil {\n\t\tbuilder.WriteString(\"nillable_int32=\")\n\t\tbuilder.WriteString(fmt.Sprintf(\"%v\", *v))\n\t}\n\tbuilder.WriteString(\", \")\n\tif v := ft.NillableInt64; v != nil {\n\t\tbuilder.WriteString(\"nillable_int64=\")\n\t\tbuilder.WriteString(fmt.Sprintf(\"%v\", *v))\n\t}\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"validate_optional_int32=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.ValidateOptionalInt32))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"optional_uint=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.OptionalUint))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"optional_uint8=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.OptionalUint8))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"optional_uint16=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.OptionalUint16))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"optional_uint32=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.OptionalUint32))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"optional_uint64=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.OptionalUint64))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"state=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.State))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"optional_float=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.OptionalFloat))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"optional_float32=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.OptionalFloat32))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"text=\")\n\tbuilder.WriteString(ft.Text)\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"datetime=\")\n\tbuilder.WriteString(ft.Datetime.Format(time.ANSIC))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"decimal=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Decimal))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"link_other=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.LinkOther))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"link_other_func=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.LinkOtherFunc))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"mac=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.MAC))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"string_array=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.StringArray))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"password=<sensitive>\")\n\tbuilder.WriteString(\", \")\n\tif v := ft.StringScanner; v != nil {\n\t\tbuilder.WriteString(\"string_scanner=\")\n\t\tbuilder.WriteString(fmt.Sprintf(\"%v\", *v))\n\t}\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"duration=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Duration))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"dir=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Dir))\n\tbuilder.WriteString(\", \")\n\tif v := ft.Ndir; v != nil {\n\t\tbuilder.WriteString(\"ndir=\")\n\t\tbuilder.WriteString(fmt.Sprintf(\"%v\", *v))\n\t}\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"str=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Str))\n\tbuilder.WriteString(\", \")\n\tif v := ft.NullStr; v != nil {\n\t\tbuilder.WriteString(\"null_str=\")\n\t\tbuilder.WriteString(fmt.Sprintf(\"%v\", *v))\n\t}\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"link=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Link))\n\tbuilder.WriteString(\", \")\n\tif v := ft.NullLink; v != nil {\n\t\tbuilder.WriteString(\"null_link=\")\n\t\tbuilder.WriteString(fmt.Sprintf(\"%v\", *v))\n\t}\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"active=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Active))\n\tbuilder.WriteString(\", \")\n\tif v := ft.NullActive; v != nil {\n\t\tbuilder.WriteString(\"null_active=\")\n\t\tbuilder.WriteString(fmt.Sprintf(\"%v\", *v))\n\t}\n\tbuilder.WriteString(\", \")\n\tif v := ft.Deleted; v != nil {\n\t\tbuilder.WriteString(\"deleted=\")\n\t\tbuilder.WriteString(fmt.Sprintf(\"%v\", *v))\n\t}\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"deleted_at=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.DeletedAt))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"raw_data=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.RawData))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"sensitive=<sensitive>\")\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"ip=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.IP))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"null_int64=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.NullInt64))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"schema_int=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.SchemaInt))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"schema_int8=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.SchemaInt8))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"schema_int64=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.SchemaInt64))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"schema_float=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.SchemaFloat))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"schema_float32=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.SchemaFloat32))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"null_float=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.NullFloat))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"role=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Role))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"priority=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Priority))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"optional_uuid=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.OptionalUUID))\n\tbuilder.WriteString(\", \")\n\tif v := ft.NillableUUID; v != nil {\n\t\tbuilder.WriteString(\"nillable_uuid=\")\n\t\tbuilder.WriteString(fmt.Sprintf(\"%v\", *v))\n\t}\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"strings=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Strings))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"pair=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Pair))\n\tbuilder.WriteString(\", \")\n\tif v := ft.NilPair; v != nil {\n\t\tbuilder.WriteString(\"nil_pair=\")\n\t\tbuilder.WriteString(fmt.Sprintf(\"%v\", *v))\n\t}\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"vstring=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Vstring))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"triple=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.Triple))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"big_int=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", ft.BigInt))\n\tbuilder.WriteString(\", \")\n\tbuilder.WriteString(\"password_other=<sensitive>\")\n\tbuilder.WriteByte(')')\n\treturn builder.String()\n}", "func kindOf(value interface{}) reflect.Kind {\n\tif value == nil {\n\t\treturn reflect.Invalid\n\t}\n\treturn reflect.TypeOf(value).Kind()\n}", "func istype(field *ast.Field, typ string) bool {\n\treturn getType(field) == typ\n}", "func (r Source) GetKind() string {\n\treturn r.Kind\n}", "func (s *FieldStep) Type() interface{} {\n\treturn TypeStructField\n}", "func (f CxlTypeField) Tag() quickfix.Tag { return tag.CxlType }", "func (lbase *Logbase) Kind(name string) (*Node, bool, error) {\n\treturn lbase.NewNode(name, LBTYPE_KIND, true)\n}", "func (r APIVersionKind) GetKind() string {\n\treturn r.Kind\n}", "func (o *operatorRef) Kind() string {\n\treturn o.kind\n}", "func (m Manifest) Kind() string {\n\treturn m[\"kind\"].(string)\n}", "func TypeOf(f Field) FieldType {\n\tswitch f.(type) {\n\tcase string:\n\t\tif Quoted(f) {\n\t\t\treturn QuotedString\n\t\t} else if len(f.(string)) > 0 {\n\t\t\treturn Atom\n\t\t}\n\tcase uint32:\n\t\treturn Number\n\tcase []Field:\n\t\treturn List\n\tcase []byte:\n\t\treturn Bytes\n\tcase Literal:\n\t\treturn LiteralString\n\tcase nil:\n\t\treturn NIL\n\t}\n\treturn 0\n}", "func (t *Type) Field(i int) *Field", "func (o *ReconciliationTarget) GetKind() string {\n\tif o == nil || o.Kind == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Kind\n}", "func (o *FormField) GetFieldTypeOk() (*string, bool) {\n\tif o == nil || o.FieldType == nil {\n\t\treturn nil, false\n\t}\n\treturn o.FieldType, true\n}", "func (p *Parser) GetKind() model.FileKind {\n\treturn model.KindDOCKER\n}", "func isLteField(fl FieldLevel) bool {\n\tfield := fl.Field()\n\tkind := field.Kind()\n\n\tcurrentField, currentKind, ok := fl.GetStructFieldOK()\n\tif !ok || currentKind != kind {\n\t\treturn false\n\t}\n\n\tswitch kind {\n\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\n\t\treturn field.Int() <= currentField.Int()\n\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\n\t\treturn field.Uint() <= currentField.Uint()\n\n\tcase reflect.Float32, reflect.Float64:\n\n\t\treturn field.Float() <= currentField.Float()\n\n\tcase reflect.Struct:\n\n\t\tfieldType := field.Type()\n\n\t\tif fieldType.ConvertibleTo(timeType) && currentField.Type().ConvertibleTo(timeType) {\n\n\t\t\tt := currentField.Convert(timeType).Interface().(time.Time)\n\t\t\tfieldTime := field.Convert(timeType).Interface().(time.Time)\n\n\t\t\treturn fieldTime.Before(t) || fieldTime.Equal(t)\n\t\t}\n\n\t\t// Not Same underlying type i.e. struct and time\n\t\tif fieldType != currentField.Type() {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// default reflect.String\n\treturn len(field.String()) <= len(currentField.String())\n}", "func (t *ValType) Kind() ValKind {\n\tret := ValKind(C.wasm_valtype_kind(t.ptr()))\n\truntime.KeepAlive(t)\n\treturn ret\n}", "func isLtField(fl FieldLevel) bool {\n\tfield := fl.Field()\n\tkind := field.Kind()\n\n\tcurrentField, currentKind, ok := fl.GetStructFieldOK()\n\tif !ok || currentKind != kind {\n\t\treturn false\n\t}\n\n\tswitch kind {\n\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\n\t\treturn field.Int() < currentField.Int()\n\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\n\t\treturn field.Uint() < currentField.Uint()\n\n\tcase reflect.Float32, reflect.Float64:\n\n\t\treturn field.Float() < currentField.Float()\n\n\tcase reflect.Struct:\n\n\t\tfieldType := field.Type()\n\n\t\tif fieldType.ConvertibleTo(timeType) && currentField.Type().ConvertibleTo(timeType) {\n\n\t\t\tt := currentField.Convert(timeType).Interface().(time.Time)\n\t\t\tfieldTime := field.Convert(timeType).Interface().(time.Time)\n\n\t\t\treturn fieldTime.Before(t)\n\t\t}\n\n\t\t// Not Same underlying type i.e. struct and time\n\t\tif fieldType != currentField.Type() {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// default reflect.String\n\treturn len(field.String()) < len(currentField.String())\n}", "func (f *Field) Name() string {\n\tjsonTag := reflect.StructTag(f.Tag.Value[1 : len(f.Tag.Value)-1]).Get(\"json\") // Delete first and last quotation\n\tjsonTag = strings.Split(jsonTag, \",\")[0] // This can return \"-\"\n\tif jsonTag != \"\" {\n\t\treturn jsonTag\n\t}\n\n\tif f.Names != nil {\n\t\treturn f.Names[0].Name\n\t}\n\n\treturn f.Type.(*ast.Ident).Name\n}", "func (t *TypeField) Format() error {\n\t// todo\n\treturn nil\n}", "func (e TagSpecifierValidationError) Field() string { return e.field }", "func (card Card) firstFieldByType(typeName string) (value string, err error) {\n fields := card.fieldsByType(typeName)\n if len(fields) > 0 && fields[0].Value != \"\" {\n value = fields[0].Value\n } else {\n err = fmt.Errorf(\"Card has no fields of type '%s'\", typeName)\n }\n\n return\n}", "func (f UnderlyingSecurityTypeField) Tag() quickfix.Tag { return tag.UnderlyingSecurityType }", "func isEqField(fl FieldLevel) bool {\n\tfield := fl.Field()\n\tkind := field.Kind()\n\n\tcurrentField, currentKind, ok := fl.GetStructFieldOK()\n\tif !ok || currentKind != kind {\n\t\treturn false\n\t}\n\n\tswitch kind {\n\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn field.Int() == currentField.Int()\n\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn field.Uint() == currentField.Uint()\n\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn field.Float() == currentField.Float()\n\n\tcase reflect.Slice, reflect.Map, reflect.Array:\n\t\treturn int64(field.Len()) == int64(currentField.Len())\n\n\tcase reflect.Bool:\n\t\treturn field.Bool() == currentField.Bool()\n\n\tcase reflect.Struct:\n\n\t\tfieldType := field.Type()\n\n\t\tif fieldType.ConvertibleTo(timeType) && currentField.Type().ConvertibleTo(timeType) {\n\n\t\t\tt := currentField.Convert(timeType).Interface().(time.Time)\n\t\t\tfieldTime := field.Convert(timeType).Interface().(time.Time)\n\n\t\t\treturn fieldTime.Equal(t)\n\t\t}\n\n\t\t// Not Same underlying type i.e. struct and time\n\t\tif fieldType != currentField.Type() {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// default reflect.String:\n\treturn field.String() == currentField.String()\n}", "func (f SecurityTypeField) Tag() quickfix.Tag { return tag.SecurityType }", "func GoFieldType(n *ecsgen.Node) string {\n\t// create a buffer to determine type\n\ttypeBuf := new(bytes.Buffer)\n\n\t// add array syntax if the field normalizes out to an array\n\tif n.IsArray() {\n\t\ttypeBuf.WriteString(\"[]\")\n\t}\n\n\t// if Node is an Object, we need to return this object's type. For example,\n\t// Node(\"client.nat\") needs to return \"ClientNAT\" as it's Go type.\n\tif n.IsObject() {\n\t\ttypeBuf.WriteString(n.TypeIdent().Pascal())\n\t\treturn typeBuf.String()\n\t}\n\n\t// Special cases denoted by the ECS developers.\n\tswitch {\n\tcase n.Name == \"duration\" && n.Definition.Type == \"long\":\n\t\ttypeBuf.WriteString(\"time.Duration\")\n\t\treturn typeBuf.String()\n\tcase n.Name == \"args\" && n.Definition.Type == \"keyword\":\n\t\ttypeBuf.WriteString(\"[]string\")\n\t\treturn typeBuf.String()\n\tcase n.Path == \"labels\":\n\t\ttypeBuf.WriteString(\"map[string]interface{}\")\n\t\treturn typeBuf.String()\n\t}\n\n\t// Find the right type!\n\tswitch n.Definition.Type {\n\tcase \"keyword\", \"text\", \"ip\", \"geo_point\":\n\t\ttypeBuf.WriteString(\"string\")\n\t\treturn typeBuf.String()\n\tcase \"long\":\n\t\ttypeBuf.WriteString(\"int64\")\n\t\treturn typeBuf.String()\n\tcase \"integer\":\n\t\ttypeBuf.WriteString(\"int32\")\n\t\treturn typeBuf.String()\n\tcase \"float\":\n\t\ttypeBuf.WriteString(\"float64\")\n\t\treturn typeBuf.String()\n\tcase \"date\":\n\t\ttypeBuf.WriteString(\"time.Time\")\n\t\treturn typeBuf.String()\n\tcase \"boolean\":\n\t\ttypeBuf.WriteString(\"bool\")\n\t\treturn typeBuf.String()\n\tcase \"object\":\n\t\ttypeBuf.WriteString(\"map[string]interface{}\")\n\t\treturn typeBuf.String()\n\tdefault:\n\t\tpanic(fmt.Errorf(\"no translation for %v (field %s)\", n.Definition.Type, n.Name))\n\t}\n}", "func Field(v reflect.StructField) (name string, mapped bool) {\n\tns := v.Tag.Get(\"ns\")\n\tif ns != \"\" {\n\t\tmapped = true\n\t\tname = ns\n\t\treturn\n\t}\n\tname = v.Name\n\treturn\n}", "func GetTypeEnum(val reflect.Type) (ret int, err error) {\n\tswitch val.Kind() {\n\tcase reflect.Int8:\n\t\tret = TypeBitField\n\tcase reflect.Uint8:\n\t\tret = TypePositiveBitField\n\tcase reflect.Int16:\n\t\tret = TypeSmallIntegerField\n\tcase reflect.Uint16:\n\t\tret = TypePositiveSmallIntegerField\n\tcase reflect.Int32:\n\t\tret = TypeInteger32Field\n\tcase reflect.Uint32:\n\t\tret = TypePositiveInteger32Field\n\tcase reflect.Int64:\n\t\tret = TypeBigIntegerField\n\tcase reflect.Uint64:\n\t\tret = TypePositiveBigIntegerField\n\tcase reflect.Int:\n\t\tret = TypeIntegerField\n\tcase reflect.Uint:\n\t\tret = TypePositiveIntegerField\n\tcase reflect.Float32:\n\t\tret = TypeFloatField\n\tcase reflect.Float64:\n\t\tret = TypeDoubleField\n\tcase reflect.Bool:\n\t\tret = TypeBooleanField\n\tcase reflect.String:\n\t\tret = TypeStringField\n\tcase reflect.Struct:\n\t\tswitch val.String() {\n\t\tcase \"time.Time\":\n\t\t\tret = TypeDateTimeField\n\t\tdefault:\n\t\t\tret = TypeStructField\n\t\t}\n\tcase reflect.Slice:\n\t\tret = TypeSliceField\n\tdefault:\n\t\terr = fmt.Errorf(\"unsupport field type:%v\", val.String())\n\t}\n\n\treturn\n}", "func (e RicStyleTypeValidationError) Field() string { return e.field }", "func (s *tsLibrary) Kind() string {\n\treturn s.KindName\n}", "func (attribute *Attribute) Kind() data.Kind {\n\treturn AttributeKind\n}", "func (e JsonToMetadataValidationError) Field() string { return e.field }", "func (h *datastoreHandler) Kind(ctx context.Context, src interface{}) string {\n\treturn FromContext(ctx).Kind(src)\n}", "func (o *operator) Kind() string {\n\treturn o.kind\n}", "func (copy Copy) GetKind() string {\n\treturn copy.Kind\n}", "func (d Document) Type(field string) (reflect.Type, bool) {\n\tif i, ok := d.data.index[field]; ok {\n\t\tvar (\n\t\t\tft = d.rt.Field(i).Type\n\t\t)\n\n\t\tif ft.Kind() == reflect.Ptr {\n\t\t\tft = ft.Elem()\n\t\t} else if ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Ptr {\n\t\t\tft = reflect.SliceOf(ft.Elem().Elem())\n\t\t}\n\n\t\treturn ft, true\n\t}\n\n\treturn nil, false\n}", "func (v *Value) Kind() Kind {\n\treturn (Kind)(C.value_kind(v.value))\n}", "func (o *AddOn) Kind() string {\n\tif o == nil {\n\t\treturn AddOnNilKind\n\t}\n\tif o.bitmap_&1 != 0 {\n\t\treturn AddOnLinkKind\n\t}\n\treturn AddOnKind\n}", "func getSchemaType(field reflect.StructField) (string, error) {\n\tswitch t := reflect.New(field.Type).Interface().(type) {\n\tcase *bool, *int, *int8, *int16, *int32, *int64:\n\t\treturn columnTypeInteger, nil\n\tcase *float32, *float64:\n\t\treturn columnTypeFloat, nil\n\tcase *string:\n\t\treturn columnTypeString, nil\n\tcase *[]byte:\n\t\treturn columnTypeBlob, nil\n\tcase *time.Time:\n\t\treturn columnTypeTime, nil\n\tcase *LatLong:\n\t\treturn columnTypeLatLong, nil\n\tcase *IntegerSet:\n\t\treturn columnTypeIntegerSet, nil\n\tcase *StringSet:\n\t\treturn columnTypeStringSet, nil\n\tcase *IntegerMap:\n\t\treturn columnTypeIntegerMap, nil\n\tcase *StringMap:\n\t\treturn columnTypeStringMap, nil\n\tdefault:\n\t\treturn \"\", util.Errorf(\"invalid type %v; only integer, float, string, time, latlong, integerset, stringset, integermap, stringmap are allowed\", t)\n\t}\n}", "func (p *ProvisionTokenV2) GetKind() string {\n\treturn p.Kind\n}", "func hclTypeName(i interface{}) string {\n\tswitch k := reflect.Indirect(reflect.ValueOf(i)).Kind(); k {\n\tcase reflect.Bool:\n\t\treturn \"boolean\"\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,\n\t\treflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32,\n\t\treflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64:\n\t\treturn \"number\"\n\tcase reflect.Array, reflect.Slice:\n\t\treturn \"list\"\n\tcase reflect.Map:\n\t\treturn \"map\"\n\tcase reflect.String:\n\t\treturn \"string\"\n\tdefault:\n\t\t// fall back to the Go type if there's no match\n\t\treturn k.String()\n\t}\n}", "func (typ *Type) Field(n string) (*Field, bool) {\n\tidx, ok := typ.fieldIdx[n]\n\tif !ok {\n\t\treturn nil, false\n\t}\n\treturn typ.Fields[idx], true\n}", "func getDatastoreKind(kind reflect.Type) (dsKind string) {\n\tdsKind = kind.String()\n\tif li := strings.LastIndex(dsKind, \".\"); li >= 0 {\n\t\t//Format kind to be in a standard format used for datastore\n\t\tdsKind = dsKind[li+1:]\n\t}\n\treturn\n}", "func (o *SingleSelectFieldField) GetType() string {\n\tif o == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\n\treturn o.Type\n}", "func baseKind(typ reflect.Type) (k, v reflect.Kind) {\n\tswitch typ.Kind() {\n\tcase reflect.Ptr:\n\t\treturn baseKind(typ.Elem())\n\tcase reflect.Array, reflect.Slice:\n\t\treturn baseKind(typ.Elem())\n\tcase reflect.Map:\n\t\treturn baseMapKind(typ)\n\t}\n\treturn typ.Kind(), v\n}", "func (c Claim) Field() string {\n\tswitch strings.ToLower(c.Key) {\n\tcase \"issuer\", Issuer:\n\t\treturn Issuer\n\tcase \"subject\", Subject:\n\t\treturn Subject\n\tcase \"audience\", Audience:\n\t\treturn Audience\n\tcase \"expires\", Expires:\n\t\treturn Expires\n\tcase \"notbefore\", NotBefore:\n\t\treturn NotBefore\n\tcase \"issued\", Issued:\n\t\treturn Issued\n\tcase \"id\", ID:\n\t\treturn ID\n\tdefault:\n\t\treturn c.Key\n\t}\n}", "func (f *FieldSet) DatabaseTypeName(idx int) string {\n\treturn f.fields[idx].typeCode().typeName()\n}" ]
[ "0.8147924", "0.76955324", "0.654674", "0.63921", "0.6350089", "0.63476145", "0.634156", "0.63220066", "0.6085066", "0.60765535", "0.60757846", "0.60478234", "0.6044766", "0.60117584", "0.6009119", "0.5945335", "0.59276253", "0.59146184", "0.5896767", "0.5896631", "0.5881111", "0.5872139", "0.5860883", "0.58538723", "0.58524734", "0.5829355", "0.58254397", "0.58066255", "0.5804841", "0.5793894", "0.57873523", "0.5771697", "0.5766757", "0.5756135", "0.5752464", "0.5751994", "0.57503855", "0.5726464", "0.57244", "0.5715283", "0.57149374", "0.5690959", "0.56878424", "0.5681892", "0.5675059", "0.5674077", "0.56659055", "0.56522864", "0.5644184", "0.5643691", "0.56424516", "0.5640002", "0.5635307", "0.5626577", "0.56256634", "0.5609803", "0.5608236", "0.5592915", "0.55847883", "0.5573982", "0.5569732", "0.55671316", "0.5565888", "0.5560856", "0.5557931", "0.55447775", "0.55423826", "0.5534526", "0.5518048", "0.5507049", "0.5505864", "0.5504458", "0.5490891", "0.54889613", "0.5487984", "0.54811186", "0.54791206", "0.5474327", "0.54641914", "0.5462528", "0.5459588", "0.5459229", "0.54563254", "0.5448483", "0.5446593", "0.54429877", "0.544294", "0.54290384", "0.5421091", "0.5417184", "0.5414957", "0.5402609", "0.5399003", "0.53930765", "0.53865844", "0.53845227", "0.5380475", "0.5379286", "0.53765815", "0.5369798" ]
0.7663187
2
Tag returns tag of field by key
func (f *Fieldx) Tag(key string) string { return f.data.Tag.Get(key) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *Field) Tag(key string) string {\n\treturn f.field.Tag.Get(key)\n}", "func (s *StructField) Tag(k string) string {\n\treturn s.field.Tag.Get(k)\n}", "func (f *Feature) Tag(key string) string {\n\treturn string(f.tags[key])\n}", "func (field Field) TagGet(key string) (string, bool) {\n\tif field.Tag == nil {\n\t\treturn \"\", false\n\t}\n\ttags, err := structtag.Parse(strings.Trim(field.Tag.Value, \"`\"))\n\tif err != nil {\n\t\treturn \"\", false\n\t}\n\ttag, err := tags.Get(key)\n\tif err != nil {\n\t\treturn \"\", false\n\t}\n\treturn tag.Value(), true\n}", "func getTag(t *reflect.Type, field string, tagName string) {\n var (\n tagVal string\n err error\n )\n fieldVal, ok := (*t).FieldByName(field)\n if ok {\n tagVal = fieldVal.Tag.Get(tagName)\n } else {\n err = errors.New(\"no field named:\" + field)\n }\n\n fmt.Printf(\"get struct[%s] tag[%s]: %s, error:%v\\n\", field, tagName, tagVal, err)\n fmt.Println(\"\")\n}", "func getTagValues(f reflect.StructField, tag string) string {\n\treturn f.Tag.Get(tag)\n}", "func GetTag(v interface{}, fieldName string, tag string) (string, bool) {\n\ttyp := reflect.TypeOf(v)\n\t// if a pointer to a struct is passed, get the type of the dereferenced object\n\tif typ.Kind() == reflect.Ptr {\n\t\ttyp = typ.Elem()\n\t}\n\tif typ.Kind() == reflect.Slice {\n\t\ttyp = typ.Elem()\n\t}\n\n\tf, b := typ.FieldByName(fieldName)\n\t// not found field.\n\tif !b {\n\t\treturn \"\", false\n\t}\n\tr := f.Tag.Get(tag)\n\treturn string(r), true\n}", "func (field *Field) Get(name string) string {\n\ttext := field.StructField.Tag.Get(name)\n\tif len(text) > 0 {\n\t\treturn text\n\t}\n\treturn \"\"\n}", "func tagValueOf(stack cloudformation.Stack, key string) string {\n\tfor _, tag := range stack.Tags {\n\t\ttagk := *tag.Key\n\t\tif tagk == key {\n\t\t\treturn *tag.Value\n\t\t}\n\t}\n\treturn \"\"\n}", "func getFieldNameByTag(v reflect.Value, name, tagKey string) string {\n\tvt := reflect.TypeOf(v.Interface())\n\tfor i := 0; i < vt.NumField(); i++ {\n\t\tfield := vt.Field(i)\n\t\talias := field.Tag.Get(tagKey)\n\t\tif alias == name {\n\t\t\treturn field.Name\n\t\t}\n\t}\n\treturn name\n}", "func (tag StructTag) Get(key string) string {\n}", "func (f *LogFile) TagKey(name, key []byte) TagKeyElem {\n\tf.mu.RLock()\n\tdefer f.mu.RUnlock()\n\n\tmm, ok := f.mms[string(name)]\n\tif !ok {\n\t\treturn nil\n\t}\n\n\ttk, ok := mm.tagSet[string(key)]\n\tif !ok {\n\t\treturn nil\n\t}\n\n\treturn &tk\n}", "func (f SymbolField) Tag() quickfix.Tag { return tag.Symbol }", "func (t *Tracer) getTag(key string) (interface{}, bool) {\n\tfor _, tag := range t.tags {\n\t\tif tag.key == key {\n\t\t\treturn tag.value, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func (f UnderlyingSymbolField) Tag() quickfix.Tag { return tag.UnderlyingSymbol }", "func (f RefTagIDField) Tag() quickfix.Tag { return tag.RefTagID }", "func (self *Map) Tag(key string) *Map {\n\tself.structTagKey = key\n\treturn self\n}", "func (f SignatureField) Tag() quickfix.Tag { return tag.Signature }", "func (lg *logger) Tag(k, v string) {\n\n\tlg.buffer.Tags[k] = v\n\n}", "func parseTag(f reflect.StructField, tag string) (string, tagOptions) {\n\treturn splitTags(getTagValues(f, tag))\n}", "func (f EncodedTextField) Tag() quickfix.Tag { return tag.EncodedText }", "func getNameFromTag(field reflect.StructField) tagInfo {\n\tfieldName, tags := ParseTag(field.Tag.Get(\"provider\"))\n\tif fieldName == \"\" {\n\t\trawFieldName, _ := ParseTag(field.Tag.Get(\"json\"))\n\t\tfieldName = ToSnakeCase(rawFieldName)\n\t}\n\tif fieldName == \"\" {\n\t\tfieldName = field.Name\n\t}\n\treturn tagInfo{\n\t\tname: fieldName,\n\t\tisId: tags.Contains(\"id\"),\n\t\tflatten: tags.Contains(\"flatten\"),\n\t\tignore: tags.Contains(\"ignore\"),\n\t}\n}", "func tagKey(dir string, context *build.Context, tags []string) string {\n\tctags := map[string]bool{\n\t\tcontext.GOOS: true,\n\t\tcontext.GOARCH: true,\n\t}\n\tif context.CgoEnabled {\n\t\tctags[\"cgo\"] = true\n\t}\n\tfor _, tag := range context.BuildTags {\n\t\tctags[tag] = true\n\t}\n\t// TODO: ReleaseTags (need to load default)\n\tkey := dir\n\n\t// explicit on GOOS and GOARCH as global cache will use \"all\" cached packages for\n\t// an indirect imported package. See https://github.com/golang/go/issues/21181\n\t// for more detail.\n\ttags = append(tags, context.GOOS, context.GOARCH)\n\tsort.Strings(tags)\n\n\tfor _, tag := range tags {\n\t\tif ctags[tag] {\n\t\t\tkey += \",\" + tag\n\t\t\tctags[tag] = false\n\t\t}\n\t}\n\treturn key\n}", "func (s *Structx) Tags(key string) (map[string]string, error) {\n\tresult := map[string]string{}\n\n\tfs := s.Fields()\n\tfor _, v := range fs {\n\t\tif !v.IsExport() {\n\t\t\tcontinue\n\t\t}\n\t\tresult[v.Name()] = v.Tag(key)\n\t}\n\n\treturn result, nil\n}", "func getNameFromTag(f reflect.StructField, tagName string) string {\n\ttag, _ := parseTag(f, tagName)\n\tif tag != \"\" {\n\t\treturn tag\n\t}\n\treturn f.Name\n}", "func (t Tags) GetTag(key string) (string, bool) {\n\tret, ok := t[key]\n\treturn string(ret), ok\n}", "func (f DlvyInstField) Tag() quickfix.Tag { return tag.DlvyInst }", "func getTagValue(val reflect.Value, name, tagName string) string {\n\tfield, ok := val.Type().FieldByName(name)\n\tif !ok {\n\t\treturn \"\"\n\t}\n\n\ttag := field.Tag.Get(tagName)\n\tif tag == tagIgnore {\n\t\treturn \"\"\n\t}\n\n\treturn splitTag(tag)[0]\n}", "func tags(field *ast.Field) []string {\n\tvar tag string\n\tif field.Tag != nil {\n\t\ttag = field.Tag.Value[1 : len(field.Tag.Value)-1]\n\t\ttag = reflect.StructTag(tag).Get(\"json\")\n\t}\n\treturn strings.Split(tag, \",\")\n}", "func name(v reflect.StructField) string {\n\tif name, ok := v.Tag.Lookup(\"name\"); ok {\n\t\treturn name\n\t}\n\treturn v.Name\n}", "func (f TextField) Tag() quickfix.Tag { return tag.Text }", "func (r *Record) Tag(tag []byte) (v Aux, ok bool) {\n\tif len(tag) < 2 {\n\t\tpanic(\"sam: tag too short\")\n\t}\n\tfor _, aux := range r.AuxFields {\n\t\tif aux.matches(tag) {\n\t\t\treturn aux, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func (mem *MemberKey) Tag() []byte {\n\treturn mem.a.Marshal()\n}", "func (f RawDataField) Tag() quickfix.Tag { return tag.RawData }", "func (f *IndexFile) TagKey(name, key []byte) TagKeyElem {\n\ttblk := f.tblks[string(name)]\n\tif tblk == nil {\n\t\treturn nil\n\t}\n\treturn tblk.TagKeyElem(key)\n}", "func getFieldTags(t reflect.StructField) (res []string) {\n\tif tags := t.Tag.Get(mapEnvTagName); len(tags) > 0 {\n\t\tfor _, s := range strings.Split(tags, \",\") {\n\t\t\tif len(s) > 0 {\n\t\t\t\tres = append(res, s)\n\t\t\t}\n\t\t}\n\t}\n\n\t// ignore json tags and field name if mpe tag is present\n\tif len(res) > 0 {\n\t\treturn\n\t}\n\n\tif tags := t.Tag.Get(\"json\"); len(tags) > 0 {\n\t\tjsonTags := strings.Split(tags, \",\")\n\t\tif len(jsonTags) > 0 && len(jsonTags[0]) > 0 {\n\t\t\tres = append(res, jsonTags[0])\n\t\t}\n\t}\n\n\t// ignore field name if json tag is present\n\tif len(res) > 0 {\n\t\treturn\n\t}\n\n\tres = append(res, t.Name)\n\n\treturn\n}", "func (f AdvIdField) Tag() quickfix.Tag { return tag.AdvId }", "func (m *ccMetric) GetTag(key string) (string, bool) {\n\tvalue, ok := m.tags[key]\n\treturn value, ok\n}", "func Tags(v interface{}, key string) (map[string]string, error) {\n\treturn New(v).Tags(key)\n}", "func (f UnderlyingPutOrCallField) Tag() quickfix.Tag { return tag.UnderlyingPutOrCall }", "func (i Info) Get(tag string) string {\n\treturn i[tag]\n}", "func (f DeskIDField) Tag() quickfix.Tag { return tag.DeskID }", "func (c *Config) GetTag(structType reflect.Type, field reflect.StructField) (*Tag, error) {\n\tif c.TagName == \"\" {\n\t\treturn nil, nil\n\t}\n\tsname := structType.Name()\n\tif sname != \"\" {\n\t\tkey := structType.PkgPath() + \".\" + structType.Name() + \".\" + field.Name\n\t\tt, ok := c.CachedTags.Load(key)\n\t\tif ok {\n\t\t\treturn t.(*Tag), nil\n\t\t}\n\t\ttag, err := c.TagParser(c, field.Tag.Get(c.TagName))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tc.CachedTags.Store(key, tag)\n\t\treturn tag, nil\n\t}\n\treturn c.TagParser(c, field.Tag.Get(c.TagName))\n}", "func (f PutOrCallField) Tag() quickfix.Tag { return tag.PutOrCall }", "func keyname(field *ast.Field) string {\n\ttags := tags(field)\n\n\tif len(tags) > 0 {\n\t\tif len(tags[0]) == 0 {\n\t\t\treturn fieldname(field)\n\t\t} else if tags[0] == \"-\" {\n\t\t\treturn \"\"\n\t\t} else {\n\t\t\treturn tags[0]\n\t\t}\n\t} else {\n\t\treturn fieldname(field)\n\t}\n}", "func resolveKeyForField(Struct reflect.Type, name string) string {\n\tif f, ok := Struct.FieldByName(name); ok {\n\t\ttag := f.Tag.Get(\"bson\")\n\t\tparts := strings.Split(tag, \",\")\n\t\tif len(parts) > 0 && parts[0] != \"\" && parts[0] != \"-\" {\n\t\t\treturn parts[0]\n\t\t} else {\n\t\t\treturn strings.ToLower(f.Name)\n\t\t}\n\t}\n\treturn \"\"\n}", "func (d *Decoder) NextTag() (key, value []byte, err error) {\n\tif ok, err := d.advanceToSection(tagSection); err != nil {\n\t\treturn nil, nil, err\n\t} else if !ok {\n\t\treturn nil, nil, nil\n\t}\n\tif d.ensure(1) && fieldSeparatorSpace.get(d.at(0)) {\n\t\td.take(fieldSeparatorSpace)\n\t\td.section = fieldSection\n\t\treturn nil, nil, nil\n\t}\n\ttagKey, i0, err := d.takeEsc(tagKeyChars, &tagKeyEscapes.revTable)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tif len(tagKey) == 0 || !d.ensure(1) || d.at(0) != '=' {\n\t\tif !d.ensure(1) {\n\t\t\treturn nil, nil, d.syntaxErrorf(i0, \"empty tag name\")\n\t\t}\n\t\tif len(tagKey) > 0 {\n\t\t\treturn nil, nil, d.syntaxErrorf(i0, \"expected '=' after tag key %q, but got %q instead\", tagKey, d.at(0))\n\t\t}\n\t\treturn nil, nil, d.syntaxErrorf(i0, \"expected tag key or field but found %q instead\", d.at(0))\n\t}\n\td.advance(1)\n\ttagVal, i0, err := d.takeEsc(tagValChars, &tagValEscapes.revTable)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tif len(tagVal) == 0 {\n\t\treturn nil, nil, d.syntaxErrorf(i0, \"expected tag value after tag key %q, but none found\", tagKey)\n\t}\n\tif !d.ensure(1) {\n\t\t// There's no more data after the tag value. Instead of returning an error\n\t\t// immediately, advance to the field section and return the tag and value.\n\t\t// This means that we'll see all the tags even when there's no value,\n\t\t// and it also allows a client to parse the tags in isolation even when there\n\t\t// are no keys. We'll return an error if the client tries to read values from here.\n\t\td.section = fieldSection\n\t\treturn tagKey, tagVal, nil\n\t}\n\tif err := d.advanceTagComma(); err != nil {\n\t\treturn nil, nil, err\n\t}\n\treturn tagKey, tagVal, nil\n}", "func (f *Field) GetTags() string {\n\tif f == nil {\n\t\treturn \"\"\n\t}\n\n\tjsonTag := \"`json:\\\"\" + f.Name\n\n\tif f.Type.IsInputObject() || !f.Type.IsNonNull() {\n\t\tjsonTag += \",omitempty\"\n\t}\n\n\ttags := jsonTag + \"\\\"`\"\n\n\t// log.Print(\"\\n\\n **************************** \\n\")\n\t// log.Printf(\"\\n Struct Tags: %s \\n\", f)\n\t// log.Printf(\"\\n Struct Tags: %s \\n\", jsonTag)\n\t// log.Print(\"\\n **************************** \\n\\n\")\n\t// time.Sleep(5 * time.Second)\n\n\treturn tags\n}", "func (f InViewOfCommonField) Tag() quickfix.Tag { return tag.InViewOfCommon }", "func (f HandlInstField) Tag() quickfix.Tag { return tag.HandlInst }", "func queryByTag(key, value []byte) bleveQuery.Query {\n\tquery := bleve.NewTermQuery(string(value))\n\tquery.SetField(fmt.Sprintf(\"%s.%s\", fieldTags, string(key)))\n\treturn query\n}", "func parseFieldTags(f reflect.StructField) fieldTags {\n\tvar ret fieldTags\n\n\tfor i, s := range strings.Split(f.Tag.Get(\"json\"), \",\") {\n\t\tswitch {\n\t\tcase i == 0 && s == \"-\":\n\t\t\tret.omit = true\n\t\tcase i == 0:\n\t\t\tret.name = s\n\t\tcase s == \"omitempty\":\n\t\t\tret.omitEmpty = true\n\t\tcase s == \"!omitempty\":\n\t\t\tret.noOmitEmpty = true\n\t\tcase s == \"string\":\n\t\t\tret.asString = true\n\t\tcase s == \"required\":\n\t\t\tret.required = true\n\t\tcase s == \"intern\":\n\t\t\tret.intern = true\n\t\tcase s == \"nocopy\":\n\t\t\tret.noCopy = true\n\t\t}\n\t}\n\n\treturn ret\n}", "func (f AggregatedBookField) Tag() quickfix.Tag { return tag.AggregatedBook }", "func (f MDMktField) Tag() quickfix.Tag { return tag.MDMkt }", "func (t Tags) Get(key string) string {\n\tswitch vs := t[key].(type) {\n\tcase string:\n\t\treturn vs\n\tcase []string:\n\t\treturn vs[0]\n\t}\n\treturn \"\"\n}", "func Tag(key string, value interface{}) Option {\n\treturn func(c *Options) {\n\t\tc.tags = append(c.tags, opentracing.Tag{Key: key, Value: value})\n\t}\n}", "func (t Tags) FindByKey(key string) string {\n\tfor _, tag := range t {\n\t\tif aws.StringValue(tag.Key) == key {\n\t\t\treturn aws.StringValue(tag.Value)\n\t\t}\n\t}\n\treturn \"\"\n}", "func (f EncodedSecurityDescField) Tag() quickfix.Tag { return tag.EncodedSecurityDesc }", "func (f PriceField) Tag() quickfix.Tag { return tag.Price }", "func (p *Parser) switchFieldToTag(tags map[string]string, fields map[string]interface{}) (map[string]string, map[string]interface{}) {\n\tfor name, value := range fields {\n\t\tif p.tagFilter == nil {\n\t\t\tcontinue\n\t\t}\n\t\t// skip switch statement if tagkey doesn't match fieldname\n\t\tif !p.tagFilter.Match(name) {\n\t\t\tcontinue\n\t\t}\n\t\t// switch any fields in TagKeys into tags\n\t\tswitch t := value.(type) {\n\t\tcase string:\n\t\t\ttags[name] = t\n\t\t\tdelete(fields, name)\n\t\tcase bool:\n\t\t\ttags[name] = strconv.FormatBool(t)\n\t\t\tdelete(fields, name)\n\t\tcase float64:\n\t\t\ttags[name] = strconv.FormatFloat(t, 'f', -1, 64)\n\t\t\tdelete(fields, name)\n\t\tdefault:\n\t\t\tp.Log.Errorf(\"Unrecognized type %T\", value)\n\t\t}\n\t}\n\n\t// remove any additional string/bool values from fields\n\tfor fk := range fields {\n\t\tswitch fields[fk].(type) {\n\t\tcase string, bool:\n\t\t\tif p.stringFilter != nil && p.stringFilter.Match(fk) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdelete(fields, fk)\n\t\t}\n\t}\n\treturn tags, fields\n}", "func (f Function) Tag(t string, v interface{}) Function {\n\tf.tags[t] = v\n\treturn f\n}", "func GetTag(e interface{}) string {\n\ttag := reflect.TypeOf(e).Elem().Field(0).Tag\n\treturn tag.Get(\"db\")\n}", "func TagsIDField() TagsField {\n\treturn tagsIDField\n}", "func (r RegistryPath) Tag() string {\n\tif strings.Contains(string(r), \"@\") || !strings.Contains(string(r), \":\") {\n\t\treturn \"\"\n\t}\n\n\ttagTokens := strings.Split(string(r), \":\")\n\treturn tagTokens[1]\n}", "func (w KyTeaWord) Tag(i, j int, util StringUtil) (string, float64) {\n\ttag := C.kytea_word_tag(w.word, C.int(i), C.int(j), util.util)\n\tdefer C.kytea_std_string_destroy(tag.feature)\n\treturn C.GoString(C.kytea_std_string_cstring(tag.feature)), float64(tag.score)\n}", "func (f AdvRefIDField) Tag() quickfix.Tag { return tag.AdvRefID }", "func (f OrdTypeField) Tag() quickfix.Tag { return tag.OrdType }", "func parseTag(key string, t reflect.StructTag) (name string, omit bool) {\n\ts := t.Get(key)\n\tparts := strings.Split(s, \",\")\n\tif parts[0] == \"-\" {\n\t\treturn \"\", true\n\t}\n\treturn parts[0], false\n}", "func GetFieldFirstTag(field reflect.StructField, tag string) string {\n\treturn strings.Trim(strings.Split(field.Tag.Get(tag), \",\")[0], \" \")\n}", "func (f BidIDField) Tag() quickfix.Tag { return tag.BidID }", "func (f XmlDataField) Tag() quickfix.Tag { return tag.XmlData }", "func (e TagSpecifierValidationError) Field() string { return e.field }", "func (f EncryptMethodField) Tag() quickfix.Tag { return tag.EncryptMethod }", "func NewTagField(label string, value string) *TagField {\n\treturn &TagField{label, value}\n}", "func newTagInfo(field reflect.StructField) (*tagInfo, bool) {\n if isIgnoredType(field) {\n return nil, false\n }\n\n tag := field.Tag.Get(\"polymer\")\n if tag == \"-\" {\n return nil, false // explicitly not mapped\n }\n\n // tag defaults\n ti := &tagInfo {\n Name: field.Name,\n Alias: field.Name,\n Handler: field.Name + \"Changed\",\n }\n\n // split tag parts out\n parts := strings.Split(strings.TrimSpace(tag), \",\")\n if len(parts) > 0 {\n // first property is the alias name iff it doesn't look like a pair\n startIndex := 0\n alias := parts[0]\n if alias != \"\" && strings.Index(alias, \":\") == -1 {\n ti.Alias = alias\n startIndex = 1\n }\n\n // iterate over remaining parts\n for ii := startIndex; ii < len(parts); ii++ {\n var name, val string\n\n // break things down into <name> or <name>:<val> pairs\n args := strings.Split(parts[ii], \":\")\n switch len(args) {\n case 0:\n continue // nothing to do, keep going\n case 1:\n name = strings.TrimSpace(args[0])\n default:\n name = strings.TrimSpace(args[0])\n val = strings.TrimSpace(args[1])\n }\n\n // handle supported attributes\n switch name {\n case \"ignore\":\n return nil, false // explicitly not mapped\n case \"alias\":\n ti.Alias = val\n case \"onchange\":\n ti.Handler = val\n }\n }\n }\n\n // return completed tag info\n return ti, true\n}", "func (f UnderlyingSymbolSfxField) Tag() quickfix.Tag { return tag.UnderlyingSymbolSfx }", "func (f FairValueField) Tag() quickfix.Tag { return tag.FairValue }", "func (f OptAttributeField) Tag() quickfix.Tag { return tag.OptAttribute }", "func (e *Encoder) getFieldName(field reflect.StructField) string {\n\tif e.useTags {\n\t\tname := field.Tag.Get(e.tag)\n\t\t// skip columns tagged with -\n\t\tif name == \"-\" {\n\t\t\treturn \"\"\n\t\t}\n\t\tif name != \"\" {\n\t\t\treturn name\n\t\t}\n\t}\n\treturn field.Name\n\n}", "func (c *TCache) getTagName(tag string) string {\n\treturn tagPrefixCache + tag\n}", "func (f LiquidityValueField) Tag() quickfix.Tag { return tag.LiquidityValue }", "func (f SecurityIDField) Tag() quickfix.Tag { return tag.SecurityID }", "func (f SecurityDescField) Tag() quickfix.Tag { return tag.SecurityDesc }", "func (p *Parse) Tag(finalState *TableState) string {\n\tif finalState == nil {\n\t\treturn \"\"\n\t}\n\treturn finalState.Rb.Terms[0].Value\n}", "func SetTag(key string, value interface{}) opentracing.Tag {\n\treturn opentracing.Tag{Key: key, Value: value}\n}", "func (f BidDescriptorField) Tag() quickfix.Tag { return tag.BidDescriptor }", "func T(key, value string) Tag {\n\treturn Tag{\n\t\tKey: key,\n\t\tValue: value,\n\t}\n}", "func (f RoutingIDField) Tag() quickfix.Tag { return tag.RoutingID }", "func (o DataSetRowLevelPermissionTagRuleOutput) TagKey() pulumi.StringOutput {\n\treturn o.ApplyT(func(v DataSetRowLevelPermissionTagRule) string { return v.TagKey }).(pulumi.StringOutput)\n}", "func (f ProcessCodeField) Tag() quickfix.Tag { return tag.ProcessCode }", "func (f IDSourceField) Tag() quickfix.Tag { return tag.IDSource }", "func (*TagKey) Descriptor() ([]byte, []int) {\n\treturn file_arista_tag_v2_tag_proto_rawDescGZIP(), []int{0}\n}", "func (f ListNameField) Tag() quickfix.Tag { return tag.ListName }", "func (f UnderlyingOptAttributeField) Tag() quickfix.Tag { return tag.UnderlyingOptAttribute }", "func (r *Repository) Tag(h plumbing.Hash) (*Tag, error) {\n\ttag, err := r.Object(plumbing.TagObject, h)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn tag.(*Tag), nil\n}", "func (f LiquidityIndTypeField) Tag() quickfix.Tag { return tag.LiquidityIndType }", "func (*TagKey) Descriptor() ([]byte, []int) {\n\treturn file_arista_tag_v1_tag_proto_rawDescGZIP(), []int{0}\n}", "func (f MessageEncodingField) Tag() quickfix.Tag { return tag.MessageEncoding }", "func (addr *Address) Tag() []byte {\n\tvar a = make([]byte, 32)\n\tcopy(a, addr.calcDoubleHash()[32:])\n\treturn a\n}", "func (f BidTypeField) Tag() quickfix.Tag { return tag.BidType }" ]
[ "0.82288235", "0.77249855", "0.73751974", "0.7305909", "0.6847717", "0.67421174", "0.67233205", "0.66461927", "0.664495", "0.66103345", "0.6562071", "0.6474098", "0.6356589", "0.63518935", "0.62750554", "0.6253511", "0.6252165", "0.6250972", "0.6249634", "0.62475234", "0.61924106", "0.613657", "0.61164635", "0.6115464", "0.6031", "0.60159993", "0.6000219", "0.59744203", "0.5962822", "0.5960451", "0.5957185", "0.59354883", "0.5912674", "0.58858824", "0.58848286", "0.588167", "0.5880482", "0.58578056", "0.5848173", "0.5843555", "0.5836688", "0.5833835", "0.58327776", "0.5818334", "0.58144414", "0.5813318", "0.58028716", "0.5790864", "0.57756704", "0.57622707", "0.57598406", "0.5752982", "0.5740055", "0.5731535", "0.5719698", "0.571931", "0.5719116", "0.57177985", "0.57045525", "0.56938046", "0.56860626", "0.5685358", "0.56591195", "0.5651317", "0.564929", "0.56476647", "0.5643745", "0.5639932", "0.56316596", "0.5628994", "0.5627621", "0.56209034", "0.5617457", "0.56171227", "0.5613381", "0.5611039", "0.56089866", "0.560237", "0.56004137", "0.5595062", "0.5594259", "0.5592417", "0.55894214", "0.55766", "0.5567034", "0.5566421", "0.5564006", "0.55630577", "0.5562639", "0.55609614", "0.55604774", "0.55508053", "0.55495024", "0.5549126", "0.55436337", "0.55352575", "0.5534283", "0.55305874", "0.5521835", "0.5512856" ]
0.8173703
1
Value returns value of field
func (f *Fieldx) Value() interface{} { return f.value.Interface() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *Field) Value() interface{} {\n\treturn f.value.Interface()\n}", "func (f *TagField) Value() string {\n\treturn f.value\n}", "func (f Fields) ValueForField(fieldName string) string {\n\treturn f.ValueForFieldOfType(fieldName, \"\")\n}", "func FieldValue(field *InputField) string {\n\treturn field.value\n}", "func (f *FieldHandler) Value(initZero bool) reflect.Value {\n\treturn f.field.reflectValueGetter(f.expr.ptr, initZero)\n}", "func (f *field) Val() interface{} {\n\treturn f.v\n}", "func (options *Options) Value(name string) interface{} {\n\tvalue := options.eval.evalField(options.eval.curCtx(), name, false)\n\tif !value.IsValid() {\n\t\treturn nil\n\t}\n\n\treturn value.Interface()\n}", "func (d Document) Value(field string) (interface{}, bool) {\n\tif i, ok := d.data.index[field]; ok {\n\t\tvar (\n\t\t\tvalue interface{}\n\t\t\tfv = d.rv.Field(i)\n\t\t\tft = fv.Type()\n\t\t)\n\n\t\tif ft.Kind() == reflect.Ptr {\n\t\t\tif !fv.IsNil() {\n\t\t\t\tvalue = fv.Elem().Interface()\n\t\t\t}\n\t\t} else {\n\t\t\tvalue = fv.Interface()\n\t\t}\n\n\t\treturn value, true\n\t}\n\n\treturn nil, false\n}", "func (self Param) Value() string { return self.value }", "func GetFieldValue(v interface{}, field string) (r string) {\n\tvar immutable reflect.Value\n\timmutable = GetReflectValue(v)\n\tval := immutable.FieldByName(field)\n\tswitch val.Kind() {\n\tcase reflect.Int64, reflect.Int32, reflect.Int:\n\t\tr = fmt.Sprintf(\"%d\", val.Int())\n\tcase reflect.Float64, reflect.Float32:\n\t\tr = fmt.Sprintf(\"%.2f\", val.Float())\n\tdefault:\n\t\t// process time\n\t\tvi := val.Interface()\n\t\tif vc, ok := vi.(time.Time); ok {\n\t\t\tr = FormatTime(vc)\n\t\t\tbreak\n\t\t}\n\t\tr = fmt.Sprintf(\"%v\", val)\n\t}\n\treturn\n}", "func (m Model) Value() string {\n\treturn string(m.value)\n}", "func (f DefaultField) Value() interface{} {\n\treturn f.V\n}", "func FieldValue(p *Page, key string) string {\n\tv, ok := p.FormValues[key]\n\tif !ok {\n\t\treturn \"\"\n\t}\n\n\treturn v\n}", "func (s *solrDocument) getRawValue(field string) interface{} {\n\treturn (*s)[field]\n}", "func (e RanparameterValueValidationError) Field() string { return e.field }", "func (id PlannerID) Value() string { return id.value }", "func (b *box) getFieldValue(x, y int) int {\n\treturn b.values[x+y*3]\n}", "func (u *User) GetFieldValue(field *mapping.StructField) (interface{}, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn u.ID, nil\n\tcase 1: // Name\n\t\treturn u.Name, nil\n\tcase 2: // CreatedAt\n\t\treturn u.CreatedAt, nil\n\tcase 3: // CreatedAtIso\n\t\treturn u.CreatedAtIso, nil\n\tcase 5: // MotherID\n\t\treturn u.MotherID, nil\n\tcase 7: // FatherID\n\t\treturn u.FatherID, nil\n\t}\n\treturn nil, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field: '%s' for given model: User'\", field.Name())\n}", "func (c *IssueLabel) Value() interface{} {\n\tswitch c.oneOfField {\n\tcase \"asString\":\n\t\treturn c.asString\n\tcase \"issueLabelAsObject\":\n\t\treturn c.issueLabelAsObject\n\t}\n\treturn nil\n}", "func (f *ExtensionField) Value() protoreflect.Value {\n\tif f.lazy != nil {\n\t\tif atomic.LoadUint32(&f.lazy.atomicOnce) == 0 {\n\t\t\tf.lazyInit()\n\t\t}\n\t\treturn f.lazy.value\n\t}\n\treturn f.value\n}", "func getValue(valueField string, as *args.Store) (result *string) {\n\t// No input? No result!\n\tif !utils.IsSet(valueField) {\n\t\treturn nil\n\t}\n\n\t// check whether a parameter reference was provided, i.e. something like \"param:<name>\"\n\tparamName := regexParamValue.FindStringSubmatch(valueField)\n\tif len(paramName) > 0 {\n\t\tutils.Assert(len(paramName) == 2, \"Should contain the matching text plus a single capturing group\")\n\n\t\targValue, exists := as.Get(paramName[1])\n\t\tif exists {\n\t\t\treturn &argValue\n\t\t}\n\t\treturn nil\n\t}\n\n\t// else assume that provided value was a static text\n\treturn &valueField\n}", "func (r *Person) Value(col string) (interface{}, error) {\n\tswitch col {\n\tcase \"id\":\n\t\treturn r.ID, nil\n\tcase \"name\":\n\t\treturn r.Name, nil\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"kallax: invalid column in Person: %s\", col)\n\t}\n}", "func (po *Post) Value(name string) (ent.Value, error) {\n\treturn po.selectValues.Get(name)\n}", "func (i *Item) GetValue(field string) string {\n\tif i == nil || len(i.Fields) == 0 {\n\t\treturn \"\"\n\t}\n\n\tsectionFilter := false\n\tsectionLabel := \"\"\n\tfieldLabel := field\n\tif strings.Contains(field, \".\") {\n\t\tparts := strings.Split(field, \".\")\n\n\t\t// Test to make sure the . isn't the last character\n\t\tif len(parts) == 2 {\n\t\t\tsectionFilter = true\n\t\t\tsectionLabel = parts[0]\n\t\t\tfieldLabel = parts[1]\n\t\t}\n\t}\n\n\tfor _, f := range i.Fields {\n\t\tif sectionFilter {\n\t\t\tif f.Section != nil {\n\t\t\t\tif sectionLabel != i.SectionLabelForID(f.Section.ID) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif fieldLabel == f.Label {\n\t\t\treturn f.Value\n\t\t}\n\t}\n\n\treturn \"\"\n}", "func (v *ClassValue) field(s *scope, name string) Value {\n\tfield, ok := v.Fields[name]\n\tif !ok {\n\t\tpanic(fmt.Errorf(\"ClassValue %v did not contain field %v\", v.Type().Name(), name))\n\t}\n\treturn field\n}", "func (p *Pet) GetFieldValue(field *mapping.StructField) (interface{}, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn p.ID, nil\n\tcase 1: // Name\n\t\treturn p.Name, nil\n\tcase 3: // OwnerID\n\t\treturn p.OwnerID, nil\n\t}\n\treturn nil, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field: '%s' for given model: Pet'\", field.Name())\n}", "func (d *dbBase) collectFieldValue(mi *modelInfo, fi *fieldInfo, ind reflect.Value, insert bool, tz *time.Location) (interface{}, error) {\n\tvar value interface{}\n\tif fi.pk {\n\t\t_, value, _ = getExistPk(mi, ind)\n\t} else {\n\t\tfield := ind.FieldByIndex(fi.fieldIndex)\n\t\tif fi.isFielder {\n\t\t\tf := field.Addr().Interface().(Fielder)\n\t\t\tvalue = f.RawValue()\n\t\t} else {\n\t\t\tswitch fi.fieldType {\n\t\t\tcase TypeBooleanField:\n\t\t\t\tif nb, ok := field.Interface().(sql.NullBool); ok {\n\t\t\t\t\tvalue = nil\n\t\t\t\t\tif nb.Valid {\n\t\t\t\t\t\tvalue = nb.Bool\n\t\t\t\t\t}\n\t\t\t\t} else if field.Kind() == reflect.Ptr {\n\t\t\t\t\tif field.IsNil() {\n\t\t\t\t\t\tvalue = nil\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalue = field.Elem().Bool()\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tvalue = field.Bool()\n\t\t\t\t}\n\t\t\tcase TypeVarCharField, TypeCharField, TypeTextField, TypeJSONField, TypeJsonbField:\n\t\t\t\tif ns, ok := field.Interface().(sql.NullString); ok {\n\t\t\t\t\tvalue = nil\n\t\t\t\t\tif ns.Valid {\n\t\t\t\t\t\tvalue = ns.String\n\t\t\t\t\t}\n\t\t\t\t} else if field.Kind() == reflect.Ptr {\n\t\t\t\t\tif field.IsNil() {\n\t\t\t\t\t\tvalue = nil\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalue = field.Elem().String()\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tvalue = field.String()\n\t\t\t\t}\n\t\t\tcase TypeFloatField, TypeDecimalField:\n\t\t\t\tif nf, ok := field.Interface().(sql.NullFloat64); ok {\n\t\t\t\t\tvalue = nil\n\t\t\t\t\tif nf.Valid {\n\t\t\t\t\t\tvalue = nf.Float64\n\t\t\t\t\t}\n\t\t\t\t} else if field.Kind() == reflect.Ptr {\n\t\t\t\t\tif field.IsNil() {\n\t\t\t\t\t\tvalue = nil\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalue = field.Elem().Float()\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tvu := field.Interface()\n\t\t\t\t\tif _, ok := vu.(float32); ok {\n\t\t\t\t\t\tvalue, _ = StrTo(ToStr(vu)).Float64()\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalue = field.Float()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase TypeTimeField, TypeDateField, TypeDateTimeField:\n\t\t\t\tvalue = field.Interface()\n\t\t\t\tif t, ok := value.(time.Time); ok {\n\t\t\t\t\td.ins.TimeToDB(&t, tz)\n\t\t\t\t\tif t.IsZero() {\n\t\t\t\t\t\tvalue = nil\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalue = t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tswitch {\n\t\t\t\tcase fi.fieldType&IsPositiveIntegerField > 0:\n\t\t\t\t\tif field.Kind() == reflect.Ptr {\n\t\t\t\t\t\tif field.IsNil() {\n\t\t\t\t\t\t\tvalue = nil\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvalue = field.Elem().Uint()\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalue = field.Uint()\n\t\t\t\t\t}\n\t\t\t\tcase fi.fieldType&IsIntegerField > 0:\n\t\t\t\t\tif ni, ok := field.Interface().(sql.NullInt64); ok {\n\t\t\t\t\t\tvalue = nil\n\t\t\t\t\t\tif ni.Valid {\n\t\t\t\t\t\t\tvalue = ni.Int64\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if field.Kind() == reflect.Ptr {\n\t\t\t\t\t\tif field.IsNil() {\n\t\t\t\t\t\t\tvalue = nil\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvalue = field.Elem().Int()\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalue = field.Int()\n\t\t\t\t\t}\n\t\t\t\tcase fi.fieldType&IsRelField > 0:\n\t\t\t\t\tif field.IsNil() {\n\t\t\t\t\t\tvalue = nil\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif _, vu, ok := getExistPk(fi.relModelInfo, reflect.Indirect(field)); ok {\n\t\t\t\t\t\t\tvalue = vu\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvalue = nil\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif !fi.null && value == nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"field `%s` cannot be NULL\", fi.fullName)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tswitch fi.fieldType {\n\t\tcase TypeTimeField, TypeDateField, TypeDateTimeField:\n\t\t\tif fi.autoNow || fi.autoNowAdd && insert {\n\t\t\t\tif insert {\n\t\t\t\t\tif t, ok := value.(time.Time); ok && !t.IsZero() {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttnow := time.Now()\n\t\t\t\td.ins.TimeToDB(&tnow, tz)\n\t\t\t\tvalue = tnow\n\t\t\t\tif fi.isFielder {\n\t\t\t\t\tf := field.Addr().Interface().(Fielder)\n\t\t\t\t\tf.SetRaw(tnow.In(DefaultTimeLoc))\n\t\t\t\t} else if field.Kind() == reflect.Ptr {\n\t\t\t\t\tv := tnow.In(DefaultTimeLoc)\n\t\t\t\t\tfield.Set(reflect.ValueOf(&v))\n\t\t\t\t} else {\n\t\t\t\t\tfield.Set(reflect.ValueOf(tnow.In(DefaultTimeLoc)))\n\t\t\t\t}\n\t\t\t}\n\t\tcase TypeJSONField, TypeJsonbField:\n\t\t\tif s, ok := value.(string); (ok && len(s) == 0) || value == nil {\n\t\t\t\tif fi.colDefault && fi.initial.Exist() {\n\t\t\t\t\tvalue = fi.initial.String()\n\t\t\t\t} else {\n\t\t\t\t\tvalue = nil\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn value, nil\n}", "func (r *Pet) Value(col string) (interface{}, error) {\n\tswitch col {\n\tcase \"id\":\n\t\treturn r.ID, nil\n\tcase \"name\":\n\t\treturn r.Name, nil\n\tcase \"kind\":\n\t\treturn (string)(r.Kind), nil\n\tcase \"person_id\":\n\t\treturn r.Model.VirtualColumn(col), nil\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"kallax: invalid column in Pet: %s\", col)\n\t}\n}", "func (value *Value) Value() interface{} {\n\treturn value.value\n}", "func (e AssessmentResultValidationError) Field() string { return e.field }", "func (e ResultValidationError) Field() string { return e.field }", "func (src Tag) Value() (driver.Value, error) {\n\tconst api = \"Tag.Value\"\n\n\treturn src.ID, nil\n}", "func (c *Email) Value() interface{} {\n\tswitch c.oneOfField {\n\tcase \"emailAsObject\":\n\t\treturn c.emailAsObject\n\tcase \"asString\":\n\t\treturn c.asString\n\t}\n\treturn nil\n}", "func (e *Element) Value() interface{} {\n\treturn e.value\n}", "func (e *Element) Value() interface{} {\n\treturn e.value\n}", "func (e GetInstanceResponseValidationError) Field() string { return e.field }", "func (p provider) Value() interface{} {\n\treturn p.value\n}", "func (self *FieldValue) GetValue() (interface{}, bool) {\n\tif self.StringValue != nil {\n\t\treturn *self.StringValue, true\n\t}\n\n\tif self.DoubleValue != nil {\n\t\tfv := *self.DoubleValue\n\t\tif math.IsNaN(fv) || math.IsInf(fv, 0) {\n\t\t\treturn 0, false\n\t\t}\n\t\treturn fv, true\n\t}\n\n\tif self.Int64Value != nil {\n\t\treturn *self.Int64Value, true\n\t}\n\n\tif self.BoolValue != nil {\n\t\treturn *self.BoolValue, true\n\t}\n\n\t// TODO: should we do something here ?\n\treturn nil, true\n}", "func (e InternalUpstreamTransport_MetadataValueSourceValidationError) Field() string { return e.field }", "func (rev PlannerRevision) Value() string { return rev.value }", "func (r *User) Value(col string) (interface{}, error) {\n\tswitch col {\n\tcase \"id\":\n\t\treturn r.ID, nil\n\tcase \"created_at\":\n\t\treturn r.Timestamps.CreatedAt, nil\n\tcase \"updated_at\":\n\t\treturn r.Timestamps.UpdatedAt, nil\n\tcase \"login\":\n\t\treturn r.Login, nil\n\tcase \"name\":\n\t\treturn r.Name, nil\n\tcase \"password\":\n\t\treturn r.Password, nil\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"kallax: invalid column in User: %s\", col)\n\t}\n}", "func (f *Field) Get(l *Location) (string, error) {\n\tif l.Comp == -1 {\n\t\treturn string(f.Value), nil\n\t}\n\tcomp, err := f.Component(l.Comp)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn comp.Get(l)\n}", "func (e AllowedValuesValidationError) Field() string { return e.field }", "func (s *StructField) Value() interface{} {\n\tif s.Kind() == reflect.Ptr && s.IsZero() {\n\t\te := s.value.Type().Elem()\n\t\tif e.Kind() == reflect.Ptr {\n\t\t\treturn nil\n\t\t}\n\n\t\tz := reflect.New(e)\n\t\ts.value.Set(z)\n\t}\n\n\tif s.Kind() == reflect.Struct {\n\t\ts.value = reflect.ValueOf(s.value.Addr().Interface())\n\t}\n\n\treturn s.value.Interface()\n}", "func (i I)Field(r,c int, value string)string{\n return value\n}", "func (f Formal) Value() string {\n\treturn string(f)\n}", "func (id ID) Value() (driver.Value, error) {\n\tif id.IsZero() {\n\t\treturn nil, nil\n\t}\n\tb, err := id.MarshalText()\n\treturn string(b), err\n}", "func (n *ResourceName) Value() (driver.Value, error) {\n\tif n == nil {\n\t\treturn nil, nil\n\t}\n\n\treturn n.String(), nil\n}", "func (e RanparameterItemValidationError) Field() string { return e.field }", "func (e RetrieveResponseValidationError) Field() string { return e.field }", "func (f *Factor) Value() string { return f.driver().name() }", "func (ip IPv4) Value() string {\n\treturn ip.value\n}", "func (e GetResponseValidationError) Field() string { return e.field }", "func (m *NumberTokenMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase numbertoken.FieldValue:\n\t\treturn m.Value()\n\t}\n\treturn nil, false\n}", "func (e RetrieveBookingResponseValidationError) Field() string { return e.field }", "func (e GetInstanceRequestValidationError) Field() string { return e.field }", "func (l *Label) Value() string {\n\treturn l.value\n}", "func (i *Item) Value() interface{} {\n\treturn i.value\n}", "func (i *Item) Value() interface{} {\n\treturn i.value\n}", "func (e ApplicationPubSubValidationError) Field() string { return e.field }", "func (f Fields) ValueForFieldOfType(fieldName, typ string) string {\n\tfor _, field := range f {\n\t\tif field.Var == fieldName && field.Type == typ && len(field.Values) > 0 {\n\t\t\treturn field.Values[0]\n\t\t}\n\t}\n\treturn \"\"\n}", "func (p *Pet) GetHashableFieldValue(field *mapping.StructField) (interface{}, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn p.ID, nil\n\tcase 1: // Name\n\t\treturn p.Name, nil\n\tcase 3: // OwnerID\n\t\treturn p.OwnerID, nil\n\t}\n\treturn nil, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field: '%s' for given model: 'Pet'\", field.Name())\n}", "func (p *Property) Value() interface{} {\n\tif p.IsBool() {\n\t\treturn p.ValueBool()\n\t}\n\treturn p.ValueString()\n}", "func (e PaymentInputValidationError) Field() string { return e.field }", "func (u PageType) Value() (driver.Value, error) { return int64(u), nil }", "func (p ByName) ValueName() string { return p.valueName }", "func (e ApplicationPubSubsValidationError) Field() string { return e.field }", "func (e ResolveResponseValidationError) Field() string { return e.field }", "func (e PublishResponseValidationError) Field() string { return e.field }", "func (f FunctionSelector) Value() (driver.Value, error) {\n\treturn f.Bytes(), nil\n}", "func (u *User) GetHashableFieldValue(field *mapping.StructField) (interface{}, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn u.ID, nil\n\tcase 1: // Name\n\t\treturn u.Name, nil\n\tcase 2: // CreatedAt\n\t\treturn u.CreatedAt, nil\n\tcase 3: // CreatedAtIso\n\t\treturn u.CreatedAtIso, nil\n\tcase 5: // MotherID\n\t\treturn u.MotherID, nil\n\tcase 7: // FatherID\n\t\treturn u.FatherID, nil\n\t}\n\treturn nil, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field: '%s' for given model: 'User'\", field.Name())\n}", "func (args *Args) Value(label string) string {\n if val, ok := (*args)[label]; ok {\n return val\n }\n return \"\"\n}", "func (e GetUserResponseValidationError) Field() string { return e.field }", "func (e GetMovableObjectResponseValidationError) Field() string { return e.field }", "func (m *productModel) Value(row, col int) interface{} {\n\n\tGoRec(row+1, \"product\")\n\n\tzname := Lower(Field(col, \"product\").Name)\n\tzv := FieldValue(zname, \"product\")\n\n\tswitch zname {\n\tcase \"pid\", \"pname\", \"categid\":\n\t\treturn zv\n\tcase \"price\":\n\t\t//fmt.Println(\"zv:\", zv, Val(zv))\n\t\treturn Val(zv)\n\t}\n\n\tpanic(\"unexpected col\")\n}", "func (e GetUsersResponseValidationError) Field() string { return e.field }", "func (e RanparameterIdValidationError) Field() string { return e.field }", "func (r *PollOption) Value(col string) (interface{}, error) {\n\tswitch col {\n\tcase \"id\":\n\t\treturn r.ID, nil\n\tcase \"poll_id\":\n\t\tv := r.Model.VirtualColumn(col)\n\t\tif v == nil {\n\t\t\treturn nil, kallax.ErrEmptyVirtualColumn\n\t\t}\n\t\treturn v, nil\n\tcase \"content\":\n\t\treturn r.Content, nil\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"kallax: invalid column in PollOption: %s\", col)\n\t}\n}", "func (id MatchID) Value() (driver.Value, error) {\n\treturn id[:], nil // []byte\n}", "func (e GetEventByIDResponseValidationError) Field() string { return e.field }", "func (e GetMessageResponseValidationError) Field() string { return e.field }", "func (e Response_DataValidationError) Field() string { return e.field }", "func (e ChannelPayResponseValidationError) Field() string { return e.field }", "func (id *ID) Value() (driver.Value, error) {\n\treturn id.String(), nil\n}", "func (e RanparameterNameValidationError) Field() string { return e.field }", "func (o GetTxtRecordRecordOutput) Value() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetTxtRecordRecord) string { return v.Value }).(pulumi.StringOutput)\n}", "func (o GetTxtRecordRecordOutput) Value() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetTxtRecordRecord) string { return v.Value }).(pulumi.StringOutput)\n}", "func getFieldValue(e reflect.Value, name string) interface{} {\n\tswitch e.Kind() {\n\tcase reflect.Ptr:\n\t\telem := e.Elem()\n\t\treturn getFieldValue(elem, name)\n\tcase reflect.Struct:\n\t\tf := e.FieldByName(strings.Title(name))\n\t\tif f.IsValid() {\n\t\t\treturn f.Interface()\n\t\t}\n\tcase reflect.Map:\n\t\tm, _ := e.Interface().(map[string]interface{})\n\t\treturn m[name]\n\t}\n\treturn nil\n}", "func (e RanparameterDefItemValidationError) Field() string { return e.field }", "func (e BatchGetResponseValidationError) Field() string { return e.field }", "func (e AutocompleteResultValidationError) Field() string { return e.field }", "func (n Number) Value() (driver.Value, error) {\n\treturn string(n), nil\n}", "func (e PciValidationError) Field() string { return e.field }", "func (e RetrievePurchaseResponseValidationError) Field() string { return e.field }", "func (c *CustomID) Value() int64 {\n\treturn c.value\n}", "func (country Country) Value() (value driver.Value, err error) {\n\tif country == \"\" {\n\t\treturn \"\", nil\n\t}\n\n\tif err = country.Validate(); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn country.String(), nil\n}", "func (e BitStringValidationError) Field() string { return e.field }", "func (m *PromotionamountMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase promotionamount.FieldAMOUNT:\n\t\treturn m.AMOUNT()\n\t}\n\treturn nil, false\n}", "func (p *Parameter) Value() interface{} {\n\treturn p.value\n}", "func (e SimpleResponseValidationError) Field() string { return e.field }" ]
[ "0.78044575", "0.7680545", "0.73264855", "0.73037875", "0.7210174", "0.71595913", "0.7142725", "0.7027207", "0.6973662", "0.69686407", "0.69252616", "0.6924671", "0.6916548", "0.6883484", "0.6877567", "0.68529385", "0.67927307", "0.67806816", "0.6757554", "0.6691187", "0.6673348", "0.6659601", "0.6656322", "0.66551495", "0.66449666", "0.6638704", "0.66209143", "0.66137964", "0.6607813", "0.65084314", "0.6503772", "0.64934355", "0.645177", "0.6449752", "0.6449752", "0.6443858", "0.64361936", "0.64084005", "0.6404396", "0.64005935", "0.6395323", "0.6391512", "0.6376201", "0.6375699", "0.63753855", "0.6365241", "0.633791", "0.63350797", "0.6329831", "0.63282734", "0.63209355", "0.6319531", "0.63193154", "0.6315142", "0.63022935", "0.6288181", "0.6284995", "0.62831426", "0.62831426", "0.6273358", "0.62659645", "0.6260941", "0.6259931", "0.6255689", "0.6245658", "0.6242086", "0.62400526", "0.62364477", "0.6233172", "0.6231596", "0.62273204", "0.62269455", "0.622578", "0.6223297", "0.62222207", "0.62190545", "0.62188077", "0.62148154", "0.62117773", "0.6211713", "0.62074816", "0.6202366", "0.61944693", "0.6193622", "0.6191539", "0.6191424", "0.6191424", "0.61907566", "0.6187649", "0.6186149", "0.6177769", "0.6176351", "0.61726063", "0.61680114", "0.61667085", "0.6166465", "0.61653465", "0.61619055", "0.616036", "0.61600876" ]
0.777079
1
IsAnonymous returns if field is anonymous
func (f *Fieldx) IsAnonymous() bool { return f.data.Anonymous }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (u User) IsAnonymous() bool { return u == \"\" }", "func (u *User) IsAnonymous() bool { return u.userData.Anonymous }", "func (a Anonymous) Authenticated() bool { return false }", "func (v *ApiVisitor) VisitAnonymousFiled(ctx *api.AnonymousFiledContext) interface{} {\n\tstart := ctx.GetStart()\n\tstop := ctx.GetStop()\n\tvar field TypeField\n\tfield.IsAnonymous = true\n\tif ctx.GetStar() != nil {\n\t\tnameExpr := v.newExprWithTerminalNode(ctx.ID())\n\t\tfield.DataType = &Pointer{\n\t\t\tPointerExpr: v.newExprWithText(ctx.GetStar().GetText()+ctx.ID().GetText(), start.GetLine(), start.GetColumn(), start.GetStart(), stop.GetStop()),\n\t\t\tStar: v.newExprWithToken(ctx.GetStar()),\n\t\t\tName: nameExpr,\n\t\t}\n\t} else {\n\t\tnameExpr := v.newExprWithTerminalNode(ctx.ID())\n\t\tfield.DataType = &Literal{Literal: nameExpr}\n\t}\n\tfield.DocExpr = v.getDoc(ctx)\n\tfield.CommentExpr = v.getComment(ctx)\n\treturn &field\n}", "func (user User) IsAnon() bool {\n\treturn user.ID == UserAnon\n}", "func (f *Field) IsEmbedded() bool {\n\treturn f.field.Anonymous\n}", "func (rec *RawEventCreate) SetAnonymous(b bool) *RawEventCreate {\n\trec.mutation.SetAnonymous(b)\n\treturn rec\n}", "func structFieldIgnored(f reflect.StructField) bool {\n\tif !f.Anonymous {\n\t\treturn true // if not anonymous(embedded), ignore it.\n\t}\n\n\ts := f.Tag.Get(\"ignore\")\n\treturn s == \"true\" // if has an ignore tag then ignore it.\n}", "func (u User) IsAnonymous() bool {\n\treturn u.HasRole(AnonymousRole)\n}", "func EnableAnonymous() {\n\tanonFlag = true\n}", "func (e *Encoder) SetAnonymousMode(mode AnonymousMode) {\n\te.embedAnonymous = mode == AnonymousEmbed\n}", "func fieldReadable(v interface{}, f reflect.StructField) bool {\n\treturn !f.Anonymous\n}", "func NewMockAnonymous(ctrl *gomock.Controller) *MockAnonymous {\n\tmock := &MockAnonymous{ctrl: ctrl}\n\tmock.recorder = &MockAnonymousMockRecorder{mock}\n\treturn mock\n}", "func (u *User) Deanonimize() { u.userData.Anonymous = false }", "func (c *Client) Anonymous(userId string) *Client {\n\tanonymous := *c\n\tanonymous.userHeader = \"user-id\"\n\tanonymous.user = userId\n\treturn &anonymous\n}", "func (a Anonymous) ID() string { return \"anonymous\" }", "func hasInterfaceMarkerEmbedded(typ reflect.Type) bool {\n\tfor i := 0; i < typ.NumField(); i++ {\n\t\tfield := typ.Field(i)\n\t\tif field.Anonymous && field.Type == reflect.TypeOf(Interface{}) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (o ArgoCDSpecOutput) UsersAnonymousEnabled() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v ArgoCDSpec) *bool { return v.UsersAnonymousEnabled }).(pulumi.BoolPtrOutput)\n}", "func (bkd *Backend) AnonymousLogin() (smtp.User, error) {\n\treturn nil, smtp.ErrAuthRequired\n}", "func (s *SMTPMain) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session, error) {\n\tlogger.Infof(\"Anonymous login from %v\", state.RemoteAddr)\n\treturn &Session{logger: logger.WithFields(logrus.Fields{\n\t\t\"remote\": state.RemoteAddr.String(),\n\t\t\"auth\": \"anonymous\"}),\n\t\tremote: state.RemoteAddr.String()}, nil\n\t//return nil, smtp.ErrAuthRequired\n}", "func (u *AnonUser) IsAuthenticated() bool {\n\treturn false\n}", "func (uc *UserCreate) SetIsAnonymous(b bool) *UserCreate {\n\tuc.mutation.SetIsAnonymous(b)\n\treturn uc\n}", "func AnonymousStruct() {\n\t//Biasanya dideklarasikan diluar ataupun didalam func\n\ttype orang struct {\n\t\tnama string\n\t}\n\n\t// struct ini nyaris sama seperti variabel dan tidak mempunya nama struct\n\t// hanya digunakan didalam func saja\n\tvar As1 = struct {\n\t\torang\n\t\tnegara string\n\t}{}\n\n\tAs1.nama = \"olgi\"\n\tAs1.negara = \"indonesia\"\n\n\tfmt.Println(\"Nama\\t = \", As1.nama)\n\tfmt.Println(\"Nama\\t = \", As1.negara)\n}", "func (r *Reader) AnonymousIP(ipAddress net.IP) (*AnonymousIP, error) {\n\tif isAnonymousIP&r.databaseType == 0 {\n\t\treturn nil, InvalidMethodError{\"AnonymousIP\", r.Metadata().DatabaseType}\n\t}\n\tvar anonIP AnonymousIP\n\terr := r.mmdbReader.Lookup(ipAddress, &anonIP)\n\treturn &anonIP, err\n}", "func NewAnonymousFile() *AnonymousFile {\n\treturn &AnonymousFile{contents: make([]byte, 0)}\n}", "func (o ArgoCDSpecPtrOutput) UsersAnonymousEnabled() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v *ArgoCDSpec) *bool {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.UsersAnonymousEnabled\n\t}).(pulumi.BoolPtrOutput)\n}", "func (handlers *SMTPHandlers) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session, error) {\n\treturn &Session{}, nil\n}", "func (p *GetField) IsNullable() bool {\n\treturn p.nullable\n}", "func (bkd *Backend) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session, error) {\n\treturn nil, smtp.ErrAuthRequired\n}", "func (bkd *backend) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session, error) {\n\treturn nil, smtp.ErrAuthRequired\n}", "func anonymous(vars []*types.Var, prefix string, typed bool) string {\n\tif len(vars) == 0 {\n\t\treturn \"\"\n\t}\n\tvar buf strings.Builder\n\tfor i, v := range vars {\n\t\tif i != 0 {\n\t\t\tbuf.WriteString(\", \")\n\t\t}\n\t\tif !typed {\n\t\t\tbuf.WriteString(fmt.Sprintf(\"%s%d\", prefix, i))\n\t\t\tcontinue\n\t\t}\n\t\tname := v.Name()\n\t\tif name == \"\" {\n\t\t\tname = fmt.Sprintf(\"%s%d\", prefix, i)\n\t\t}\n\t\tbuf.WriteString(fmt.Sprintf(\"%s %s\", name, path.Base(v.Type().String())))\n\t}\n\treturn buf.String()\n}", "func (m *AuthorizeMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase authorize.FieldProvider:\n\t\treturn m.Provider()\n\tcase authorize.FieldServiceID:\n\t\treturn m.ServiceID()\n\t}\n\treturn nil, false\n}", "func hasUnionMarkerEmbedded(typ reflect.Type) bool {\n\tfor i := 0; i < typ.NumField(); i++ {\n\t\tfield := typ.Field(i)\n\t\tif field.Anonymous && field.Type == unionType {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (a *Parser) getAnonymousMapParameter() *Param {\n\tif p, ok := a.params[\"\"]; ok {\n\t\tif reflValue(p.target).Kind() == reflect.Map {\n\t\t\treturn p\n\t\t}\n\t}\n\treturn nil\n}", "func (req fedSearchRequest) nameOnly() bool {\n\treturn req.Name != \"\" && req.RoutingNumber == \"\" && req.City == \"\" &&\n\t\treq.State == \"\" && req.PostalCode == \"\"\n}", "func (a *Anonymous) Type() Type {\n\treturn a.CredentialType\n}", "func (u *User) IsFieldZero(field *mapping.StructField) (bool, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn u.ID == 0, nil\n\tcase 1: // Name\n\t\treturn u.Name == \"\", nil\n\tcase 2: // CreatedAt\n\t\treturn u.CreatedAt == time.Time{}, nil\n\tcase 3: // CreatedAtIso\n\t\treturn u.CreatedAtIso == time.Time{}, nil\n\tcase 5: // MotherID\n\t\treturn u.MotherID == 0, nil\n\tcase 7: // FatherID\n\t\treturn u.FatherID == 0, nil\n\t}\n\treturn false, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n}", "func (s *scope) Anonymous(init Value) Variable {\n\tv := Variable(s.len())\n\tlevel := s.levels[len(s.levels)-1]\n\tlevel.init[v] = init\n\ts.maxLen++\n\treturn v\n}", "func (bot *BotAPI) RestrictAnonymousChatMember(groupID int64, flag string, duration time.Duration) (APIResponse, error) {\n\treturn bot.Do(RestrictChatMemberConfig{\n\t\tChatMemberConfig: ChatMemberConfig{\n\t\t\tGroupID: groupID,\n\t\t\tAnonymousFlag: flag,\n\t\t},\n\t\tDuration: duration,\n\t})\n}", "func (a Anonymous) HasAnyRole(roles ...string) bool { return false }", "func NewGetBlockAnonymousSettingOK() *GetBlockAnonymousSettingOK {\n\treturn &GetBlockAnonymousSettingOK{}\n}", "func (s *BasePlSqlParserListener) EnterAnonymous_block(ctx *Anonymous_blockContext) {}", "func (feature Feature) IsFieldNull(index int) bool {\n\tisnull := C.OGR_F_IsFieldNull(feature.cval, C.int(index))\n\treturn int(isnull) == 1\n}", "func (f *GetSessionField) IsNullable() bool { return f.value == nil }", "func (v *ApiVisitor) VisitField(ctx *api.FieldContext) interface{} {\n\tiAnonymousFiled := ctx.AnonymousFiled()\n\tiNormalFieldContext := ctx.NormalField()\n\tif iAnonymousFiled != nil {\n\t\treturn iAnonymousFiled.Accept(v).(*TypeField)\n\t}\n\tif iNormalFieldContext != nil {\n\t\treturn iNormalFieldContext.Accept(v).(*TypeField)\n\t}\n\treturn nil\n}", "func IsNullable(f ast.Field) bool {\n\t_, ok := f.Type.(*ast.StarExpr)\n\t// This is a StarExpr, which is a pointer\n\treturn ok\n}", "func (f *GetSessionField) Resolved() bool { return true }", "func (_DelegateProfile *DelegateProfileCallerSession) GetFieldByName(_name string) (struct {\n\tVerifier common.Address\n\tDeprecated bool\n}, error) {\n\treturn _DelegateProfile.Contract.GetFieldByName(&_DelegateProfile.CallOpts, _name)\n}", "func (p *GetField) Resolved() bool {\n\treturn true\n}", "func (m *Member) IsPublished() bool { return m.Published }", "func (f Unstructured) IsUndefined() bool {\n\treturn f.fields == nil\n}", "func (s *UserSuite) TestUserAttachedToRequestAuthenticatedRegisteredUseridentifierReturnsAnonymousUser(c *C) {\n\thandler := u.Handler()\n\n\tIdentifyUsersWith(FakeAuth)\n\treq, _ := http.NewRequest(\"GET\", \"http://127.0.0.1:8000/auth-status\", nil)\n\tresp := httptest.NewRecorder()\n\thandler(resp, req)\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tc.Assert(err, IsNil)\n\tc.Assert(string(body), Equals, \"false\")\n}", "func (t *Type) IsEmptyInterface() bool", "func TestWhoAmI_Anonymous_Parallel(t *testing.T) {\n\t_ = testlib.IntegrationEnv(t).WithCapability(testlib.AnonymousAuthenticationSupported)\n\n\tctx, cancel := context.WithTimeout(context.Background(), time.Minute)\n\tdefer cancel()\n\n\tanonymousConfig := testlib.NewAnonymousClientRestConfig(t)\n\n\twhoAmI, err := testlib.NewKubeclient(t, anonymousConfig).PinnipedConcierge.IdentityV1alpha1().WhoAmIRequests().\n\t\tCreate(ctx, &identityv1alpha1.WhoAmIRequest{}, metav1.CreateOptions{})\n\trequire.NoError(t, err)\n\n\t// this also asserts that all users, even unauthenticated ones, can call this API when anonymous is enabled\n\trequire.Equal(t,\n\t\t&identityv1alpha1.WhoAmIRequest{\n\t\t\tStatus: identityv1alpha1.WhoAmIRequestStatus{\n\t\t\t\tKubernetesUserInfo: identityv1alpha1.KubernetesUserInfo{\n\t\t\t\t\tUser: identityv1alpha1.UserInfo{\n\t\t\t\t\t\tUsername: \"system:anonymous\",\n\t\t\t\t\t\tGroups: []string{\n\t\t\t\t\t\t\t\"system:unauthenticated\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\twhoAmI,\n\t)\n}", "func (Anonymous) Login(username, password string) AccessType {\n\tif strings.ToLower(username) == \"anonymous\" && len(password) != 0 {\n\t\treturn ReadOnly\n\t} else {\n\t\treturn NoPermission\n\t}\n}", "func isJWT(fl FieldLevel) bool {\n\treturn jWTRegex.MatchString(fl.Field().String())\n}", "func (m *AuthMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase auth.FieldLastAuthTime:\n\t\treturn m.LastAuthTime()\n\tcase auth.FieldAuthType:\n\t\treturn m.AuthType()\n\t}\n\treturn nil, false\n}", "func isFieldStringable(tpe ast.Expr) bool {\n\tif ident, ok := tpe.(*ast.Ident); ok {\n\t\tswitch ident.Name {\n\t\tcase \"int\", \"int8\", \"int16\", \"int32\", \"int64\",\n\t\t\t\"uint\", \"uint8\", \"uint16\", \"uint32\", \"uint64\",\n\t\t\t\"float64\", \"string\", \"bool\":\n\t\t\treturn true\n\t\t}\n\t} else if starExpr, ok := tpe.(*ast.StarExpr); ok {\n\t\treturn isFieldStringable(starExpr.X)\n\t} else {\n\t\treturn false\n\t}\n\treturn false\n}", "func (m *AuthorizeMutation) FieldCleared(name string) bool {\n\t_, ok := m.clearedFields[name]\n\treturn ok\n}", "func isDefault(fl FieldLevel) bool {\n\treturn !hasValue(fl)\n}", "func anonymous(){\n\td1 := struct {\n\t\tname string\n\t\tage int\n\t}{\n\t\tname: \"Bob\",\n\t\tage: 20,\n\t}\n\n\n\tfmt.Println(d1, d1.name, d1.age)\n}", "func (*NamedTypeDummy) isType() {}", "func (_DelegateProfile *DelegateProfileSession) GetFieldByName(_name string) (struct {\n\tVerifier common.Address\n\tDeprecated bool\n}, error) {\n\treturn _DelegateProfile.Contract.GetFieldByName(&_DelegateProfile.CallOpts, _name)\n}", "func fieldIsEmpty(p unsafe.Pointer) bool {\n\treturn uintptr(p) == uintptr(0)\n}", "func IsNameOnly(ref Named) bool {\n\tif _, ok := ref.(NamedTagged); ok {\n\t\treturn false\n\t}\n\tif _, ok := ref.(Canonical); ok {\n\t\treturn false\n\t}\n\treturn true\n}", "func isUnitType(t reflect.Type) bool {\n\tif isStructPtr(t) == false {\n\t\treturn false\n\t}\n\tt = t.Elem()\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tf := t.Field(i)\n\t\tif f.Anonymous && equalsType(f.Type, unitType) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func isExportedField(field *lang.DefineFieldExpr) bool {\n\treturn unicode.IsUpper(rune(field.Name[0]))\n}", "func eachField(T types.Type, fn func(*types.Var)) {\n\t// TODO(adonovan): this algorithm doesn't exclude ambiguous\n\t// selections that match more than one field/method.\n\t// types.NewSelectionSet should do that for us.\n\n\t// for termination on recursive types\n\tvar seen typeutil.Map\n\n\tvar visit func(T types.Type)\n\tvisit = func(T types.Type) {\n\t\tif T, ok := source.Deref(T).Underlying().(*types.Struct); ok {\n\t\t\tif seen.At(T) != nil {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tfor i := 0; i < T.NumFields(); i++ {\n\t\t\t\tf := T.Field(i)\n\t\t\t\tfn(f)\n\t\t\t\tif f.Anonymous() {\n\t\t\t\t\tseen.Set(T, true)\n\t\t\t\t\tvisit(f.Type())\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tvisit(T)\n}", "func (e *Environment) GetAnonymous() Namespace {\n\troot := e.GetRoot()\n\treturn chain(root, &anonymous{\n\t\tNamespace: e.New(AnonymousDomain),\n\t})\n}", "func includeField(f reflect.StructField, exclude ExcludeFieldTag) bool {\n\tfieldName := GetFieldFirstTag(f, \"json\")\n\tif fieldName == \"\" {\n\t\treturn false\n\t}\n\tgqlexclude := f.Tag.Get(GqlExcludeTagName)\n\tif gqlexclude == \"\" {\n\t\t// No exclusions\n\t\treturn true\n\t}\n\tfor _, s := range strings.Split(gqlexclude, \",\") {\n\t\tif strings.Trim(s, \" \") == string(exclude) {\n\t\t\t// excluded\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func FilterName(name string) bool {\n\tif name == \"?\" || name == \"<anonymous>\" {\n\t\t// Bogus/V8-noise/unusable; don't aggregate\n\t\treturn true\n\t} else if _, err := strconv.ParseInt(name, 10, 64); err == nil {\n\t\t// Numeric property--do not aggregate\n\t\treturn true\n\t} else {\n\t\treturn false\n\t}\n}", "func NewAnonymousHTTPClient(transport http.RoundTripper) *HTTPClient {\n\treturn &HTTPClient{\n\t\tClient: http.Client{\n\t\t\tTransport: transport,\n\t\t},\n\t}\n}", "func (m *PurposeMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase purpose.FieldObjective:\n\t\treturn m.Objective()\n\t}\n\treturn nil, false\n}", "func (t *TypeField) Equal(v interface{}) bool {\n\tif v == nil {\n\t\treturn false\n\t}\n\n\tf, ok := v.(*TypeField)\n\tif !ok {\n\t\treturn false\n\t}\n\n\tif t.IsAnonymous != f.IsAnonymous {\n\t\treturn false\n\t}\n\n\tif !t.DataType.Equal(f.DataType) {\n\t\treturn false\n\t}\n\n\tif !t.IsAnonymous {\n\t\tif !t.Name.Equal(f.Name) {\n\t\t\treturn false\n\t\t}\n\n\t\tif t.Tag != nil {\n\t\t\tif !t.Tag.Equal(f.Tag) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\n\treturn EqualDoc(t, f)\n}", "func (me TEventType) IsAssignmentSubmitted() bool { return me.String() == \"AssignmentSubmitted\" }", "func (m *AreaMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase area.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (m *PermissionMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase permission.FieldName:\n\t\treturn m.Name()\n\t}\n\treturn nil, false\n}", "func (m *SessionMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase session.FieldToken:\n\t\treturn m.Token()\n\tcase session.FieldExpiredAt:\n\t\treturn m.ExpiredAt()\n\tcase session.FieldCreatedAt:\n\t\treturn m.CreatedAt()\n\tcase session.FieldUpdatedAt:\n\t\treturn m.UpdatedAt()\n\t}\n\treturn nil, false\n}", "func (m *NurseMutation) FieldCleared(name string) bool {\n\t_, ok := m.clearedFields[name]\n\treturn ok\n}", "func (o *NotificationAllOf) HasFields() bool {\n\tif o != nil && o.Fields != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (m *UserMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase user.FieldName:\n\t\treturn m.Name()\n\tcase user.FieldEmail:\n\t\treturn m.Email()\n\tcase user.FieldPassword:\n\t\treturn m.Password()\n\t}\n\treturn nil, false\n}", "func (j JSON) IsNull() bool {\n\treturn !j.Valid\n}", "func (m *MemberMutation) Field(name string) (ent.Value, bool) {\n\tswitch name {\n\tcase member.FieldMEMBERID:\n\t\treturn m.MEMBERID()\n\tcase member.FieldMEMBERNAME:\n\t\treturn m.MEMBERNAME()\n\t}\n\treturn nil, false\n}", "func (e Expiration) IsNull() bool {\n\treturn e.IsDaysNull() && e.IsDateNull()\n}", "func (m *Member) IsActive() bool { return m.State == \"active\" }", "func (m *UserMutation) Field(name string) (ent.Value, bool) {\n\treturn nil, false\n}", "func (f Unstructured) HasByName(field string) bool {\n\tif f.IsUndefined() {\n\t\treturn true\n\t}\n\t_, ok := f.fields[field]\n\treturn ok\n}", "func (u *User) AllowedFields() []string{\n\treturn Fields{\"id\", \"name\", \"email\", \"createdAt\"}\n}", "func IsMember(next echo.HandlerFunc) echo.HandlerFunc {\n\treturn func(c echo.Context) error {\n\t\tvar (\n\t\t\tres = response.Echo{C: c}\n\t\t)\n\t\tuser := c.Get(\"user\").(*jwt.Token)\n\t\tclaims := user.Claims.(jwt.MapClaims)\n\t\trole := claims[\"role\"].(bool)\n\t\tif !role {\n\t\t\tres.Response(http.StatusUnauthorized, \"Unauthorized\", nil)\n\t\t\treturn echo.ErrUnauthorized\n\t\t}\n\t\tres.Response(http.StatusOK, \"\", nil)\n\t\treturn next(c)\n\t}\n}", "func (*InstUIToFP) isValue() {}", "func (e UserRequired) IsUserRequired() {}", "func (u User) IsEmpty() bool {\n\treturn u.Name == \"\" && u.Gender == \"\" && u.Age == 0 && u.ID == \"\"\n}", "func (m *InviteePartyMutation) FieldCleared(name string) bool {\n\t_, ok := m.clearedFields[name]\n\treturn ok\n}", "func (m *AuthMutation) FieldCleared(name string) bool {\n\t_, ok := m.clearedFields[name]\n\treturn ok\n}", "func (s Field) IsEmpty() bool {\n\treturn s.Equal(Field{})\n}", "func (m *AreaMutation) FieldCleared(name string) bool {\n\t_, ok := m.clearedFields[name]\n\treturn ok\n}", "func (m *AreaMutation) FieldCleared(name string) bool {\n\t_, ok := m.clearedFields[name]\n\treturn ok\n}", "func is_anon(n string) bool {\n\t// ellipsis would screw us up...\n\tnn := strings.Replace(n, \"...\", \"\", -1)\n\tif strings.IndexAny(nn, \".$\") != -1 {\n\t\treturn true\n\t}\n\treturn false\n}", "func readAnonymousMessage(r *http.Request) string {\n\terr := r.ParseForm()\n\t// TODO: Change HTTP status code\n\tif err != nil {\n\t\treturn string(err.Error())\n\t}\n\t// Incoming POST's token should match the one set in Heroku\n\tif len(r.Form[keyToken]) == 0 || r.Form[keyToken][0] != os.Getenv(tokenConfig) {\n\t\treturn \"Config error.\"\n\t}\n\tif len(r.Form[keyText]) == 0 {\n\t\treturn \"Slack bug; inform the team.\"\n\t}\n\tmsg := strings.TrimSpace(r.Form[keyText][0])\n\tmatches := payloadExp.FindStringSubmatch(msg)\n\tif matches == nil {\n\t\treturn \"Message should be like: /cultureshift #channelname ThisIsTheAnnouncement\"\n\t}\n\tuser := matches[1]\n\tmsg = strings.TrimSpace(matches[2])\n\terr = sendAnonymousMessage(user, msg)\n\tif err != nil {\n\t\treturn \"Failed to send message.\"\n\t}\n\treturn fmt.Sprintf(\"Sent [%s] to %s\", msg, user)\n}", "func (me TEventType) IsAssignmentApproved() bool { return me.String() == \"AssignmentApproved\" }" ]
[ "0.69357014", "0.6896947", "0.6249964", "0.6154933", "0.60467505", "0.5950111", "0.5785039", "0.57002443", "0.5689679", "0.54320973", "0.5427697", "0.53811777", "0.53437966", "0.52690166", "0.52450204", "0.5144951", "0.50902295", "0.50505567", "0.5047496", "0.5007263", "0.49952412", "0.49667662", "0.49564973", "0.49491197", "0.49323675", "0.4915869", "0.49117362", "0.48823", "0.48788282", "0.4864767", "0.4851645", "0.4820979", "0.48048198", "0.47985038", "0.478651", "0.47782636", "0.47781727", "0.47687405", "0.47458237", "0.47270223", "0.46887675", "0.4666595", "0.4666277", "0.46571514", "0.4637087", "0.4632111", "0.45797274", "0.4549356", "0.4548316", "0.45415813", "0.45362902", "0.45355758", "0.45261607", "0.4526138", "0.45131892", "0.45016226", "0.4500157", "0.44794637", "0.44791046", "0.44768375", "0.44754204", "0.4474516", "0.44660828", "0.4442338", "0.44301742", "0.44278708", "0.44166368", "0.4410296", "0.44007286", "0.43884942", "0.43871862", "0.4363183", "0.43618327", "0.4356671", "0.4354437", "0.43464997", "0.43290365", "0.4319139", "0.43176305", "0.43136555", "0.43076888", "0.4304698", "0.42984617", "0.42953384", "0.42950732", "0.42900693", "0.42880392", "0.42872372", "0.42866862", "0.4284119", "0.4278738", "0.42770854", "0.42757642", "0.42738375", "0.42710155", "0.42707995", "0.42707995", "0.42689988", "0.4268667", "0.4263307" ]
0.836871
0
IsExport returns if field is exported
func (f *Fieldx) IsExport() bool { return f.data.PkgPath == "" }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *Field) IsExported() bool {\n\treturn f.field.PkgPath == \"\"\n}", "func (f *RawStructFieldType) Exported() bool {\n\treturn strings.Title(f.Field.Name) == f.Field.Name\n}", "func isExportedField(field *lang.DefineFieldExpr) bool {\n\treturn unicode.IsUpper(rune(field.Name[0]))\n}", "func (id *Ident) IsExported() bool { return IsExported(id.Name) }", "func IsExported(name string) bool {\n\treturn token.IsExported(name)\n}", "func (e *ProgramEnv) IsExporter() bool {\n\treturn true\n}", "func (s *JSONStructFinder) isExported(nodeType *ast.TypeSpec) bool {\n\tfirstRune, _ := utf8.DecodeRuneInString(nodeType.Name.Name)\n\treturn unicode.IsUpper(firstRune)\n}", "func IsExported(name string) bool {\n\tch, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(ch)\n}", "func (fs fields) Exported() fields {\n\tvar out fields\n\tfor _, f := range fs {\n\t\tif f.Exported {\n\t\t\tout = append(out, f)\n\t\t}\n\t}\n\treturn out\n}", "func TestIsExported(t *testing.T) {\n\ttables := []struct {\n\t\tname string\n\t\tresult bool\n\t}{\n\t\t{\"Exported\", true},\n\t\t{\"isExported\", false},\n\t\t{\"\", false},\n\t}\n\n\tfor _, table := range tables {\n\t\texportedMethod := isExported(table.name)\n\t\tif exportedMethod != table.result {\n\t\t\tt.Errorf(\"input %s, got %t, expected %t\", table.name, exportedMethod, table.result)\n\t\t}\n\t}\n}", "func IsExported(name string) bool {\n\tif r := name[0]; r < utf8.RuneSelf {\n\t\treturn 'A' <= r && r <= 'Z'\n\t}\n\tr, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(r)\n}", "func fieldsAccessible(s *types.Struct, p *types.Package) bool {\n\tfor i := 0; i < s.NumFields(); i++ {\n\t\tf := s.Field(i)\n\t\tif f.Exported() || f.Pkg() == p {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (g ServerGroup) IsExportMetrics() bool {\n\tswitch g {\n\tcase ServerGroupCoordinators, ServerGroupDBServers, ServerGroupSingle:\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}", "func (o *ExportData) IsEvented() bool {\n\treturn false\n}", "func isExported(s string) bool {\n\tif len(s) == 0 {\n\t\treturn false\n\t}\n\tl := string(byte(s[0]))\n\treturn strings.ToUpper(l) == l\n}", "func exported(name string) bool {\n\tr, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(r)\n}", "func isExportedType(d DataType) bool {\n\tif d == FUNCPOINTER {\n\t\treturn false\n\t}\n\treturn true\n}", "func (e *OverlayEnv) IsExporter() bool {\n\t// do we have an overlay to work with?\n\tif e == nil {\n\t\treturn false\n\t}\n\n\t// do any of our overlays export anything?\n\tfor _, env := range e.envs {\n\t\tif env.IsExporter() {\n\t\t\treturn true\n\t\t}\n\t}\n\n\t// sadly, they do not\n\treturn false\n}", "func isExported(name string) bool {\n\tr, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(r)\n}", "func isExported(name string) bool {\n\tr, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(r)\n}", "func isExported(name string) bool {\n\tr, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(r)\n}", "func isExported(name string) bool {\n\tr, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(r)\n}", "func isExported(name string) bool {\n\trune, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(rune)\n}", "func isExported(name string) bool {\n\trune, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(rune)\n}", "func isExported(name string) bool {\n\trune, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(rune)\n}", "func isExported(name string) bool {\n\trune, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(rune)\n}", "func isExported(name string) bool {\n\trune, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(rune)\n}", "func isExported(name string) bool {\n\trune, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(rune)\n}", "func isExported(name string) bool {\n\trune, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(rune)\n}", "func isExported(name string) bool {\n\trune, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(rune)\n}", "func exportedFrom(obj types.Object, pkg *types.Package) bool {\n\tswitch obj := obj.(type) {\n\tcase *types.Func:\n\t\treturn obj.Exported() && obj.Pkg() == pkg ||\n\t\t\tobj.Type().(*types.Signature).Recv() != nil\n\tcase *types.Var:\n\t\treturn obj.Exported() && obj.Pkg() == pkg ||\n\t\t\tobj.IsField()\n\tcase *types.TypeName, *types.Const:\n\t\treturn true\n\t}\n\treturn false // Nil, Builtin, Label, or PkgName\n}", "func isExported(name string) bool {\n\ts, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(s)\n}", "func typeIsExported(t *vdl.Type, env *Env) bool {\n\t// Stop at the first defined type that we encounter; if it is exported, we are\n\t// already guaranteed that all subtypes are also exported.\n\t//\n\t// Note that all types are composed of defined types; the built-in types\n\t// bootstrap the whole system.\n\tif def := env.FindTypeDef(t); def != nil {\n\t\treturn def.Exported\n\t}\n\t// Check composite types recursively.\n\tswitch t.Kind() {\n\tcase vdl.Optional, vdl.Array, vdl.List:\n\t\treturn typeIsExported(t.Elem(), env)\n\tcase vdl.Set:\n\t\treturn typeIsExported(t.Key(), env)\n\tcase vdl.Map:\n\t\treturn typeIsExported(t.Key(), env) && typeIsExported(t.Elem(), env)\n\tcase vdl.Struct, vdl.Union:\n\t\tfor ix := 0; ix < t.NumField(); ix++ {\n\t\t\tif !typeIsExported(t.Field(ix).Type, env) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\tpanic(fmt.Errorf(\"vdl: typeIsExported unhandled type %v\", t))\n}", "func isExported(id string) bool {\n\tr, _ := utf8.DecodeRuneInString(id)\n\treturn unicode.IsUpper(r)\n}", "func isExported(name string) bool {\n rune, _ := utf8.DecodeRuneInString(name)\n return unicode.IsUpper(rune)\n}", "func (s *fakeTracerProviderStore) HasExporter() bool {\n\treturn len(s.exporters) > 0\n}", "func (me TAttlistArticlePubModel) IsPrint() bool { return me.String() == \"Print\" }", "func IsExportedName(name string) bool {\n\trune, _ := utf8.DecodeRuneInString(name)\n\treturn unicode.IsUpper(rune)\n}", "func (g *Pin) export() {\n\tinfo,_ := os.Stat(g.path)\n\tif info == nil {\n\t\tfile,err := os.OpenFile(EXPORT_FILE,os.O_WRONLY,os.ModeExclusive)\n\t\tdefer file.Close()\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tfile.WriteString(strconv.Itoa(int(g.pin)))\n\t}\n\n\tg.setActiveLowConfig()\n\tg.setDirectionConfig()\n\tg.SetValue(false)\n\n\treturn\n}", "func (ExportTask) Fields() []ent.Field {\n\treturn []ent.Field{\n\t\tfield.Enum(\"type\").\n\t\t\tNamedValues(\n\t\t\t\t\"Equipment\", \"EQUIPMENT\",\n\t\t\t\t\"Location\", \"LOCATION\",\n\t\t\t\t\"Port\", \"PORT\",\n\t\t\t\t\"Link\", \"LINK\",\n\t\t\t\t\"Service\", \"SERVICE\",\n\t\t\t\t\"WorkOrder\", \"WORK_ORDER\",\n\t\t\t\t\"SingleWorkOrder\", \"SINGLE_WORK_ORDER\",\n\t\t\t\t\"Project\", \"PROJECT\",\n\t\t\t),\n\t\tfield.Enum(\"status\").\n\t\t\tNamedValues(\n\t\t\t\t\"Pending\", \"PENDING\",\n\t\t\t\t\"InProgress\", \"IN_PROGRESS\",\n\t\t\t\t\"Succeeded\", \"SUCCEEDED\",\n\t\t\t\t\"Failed\", \"FAILED\",\n\t\t\t),\n\t\tfield.Float(\"progress\").\n\t\t\tDefault(0).\n\t\t\tRange(0, 100),\n\t\tfield.Text(\"filters\").\n\t\t\tDefault(\"[]\"),\n\t\tfield.String(\"store_key\").\n\t\t\tNillable().\n\t\t\tOptional(),\n\t\tfield.Int(\"wo_id_to_export\").\n\t\t\tNillable().\n\t\t\tOptional(),\n\t}\n}", "func (o *Object) ExportType() reflect.Type {\n\treturn o.self.exportType()\n}", "func (svc record) Export(filter types.RecordFilter, enc Encoder) (err error) {\n\tvar (\n\t\taProps = &recordActionProps{filter: &filter}\n\t)\n\n\terr = func() error {\n\t\tm, err := svc.loadModule(filter.NamespaceID, filter.ModuleID)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tset, err := svc.recordRepo.Export(m, filter)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err = svc.preloadValues(m, set...); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn set.Walk(enc.Record)\n\t}()\n\n\treturn svc.recordAction(svc.ctx, aProps, RecordActionExport, err)\n}", "func isDagExportRequest(req *HttpRequest) bool {\n\tvalues, err := url.ParseQuery(req.QueryString)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\tif strings.ToUpper(values.Get(\"export-dag\")) == \"TRUE\" {\n\t\treturn true\n\t}\n\treturn false\n}", "func (s *opentelemetryTracerProviderStore) HasExporter() bool {\n\treturn len(s.exporters) > 0\n}", "func (o *ReadStorageV1alpha1VolumeAttachmentParams) SetExport(export *bool) {\n\to.Export = export\n}", "func (o *ReadStorageV1CSIDriverParams) SetExport(export *bool) {\n\to.Export = export\n}", "func (m *EntityDTO_StorageData) GetExportPath() string {\n\tif m != nil && m.ExportPath != nil {\n\t\treturn *m.ExportPath\n\t}\n\treturn \"\"\n}", "func (m *AccessPackageCatalog) GetIsExternallyVisible()(*bool) {\n return m.isExternallyVisible\n}", "func isExportedOrBuiltin(t reflect.Type) bool {\n\tfor t.Kind() == reflect.Ptr {\n\t\tt = t.Elem()\n\t}\n\t// PkgPath will be non-empty even for an exported type,\n\t// so we need to check the type name as well.\n\treturn isExported(t.Name()) || t.PkgPath() == \"\"\n}", "func isExportedOrBuiltin(t reflect.Type) bool {\n\tfor t.Kind() == reflect.Ptr {\n\t\tt = t.Elem()\n\t}\n\t// PkgPath will be non-empty even for an exported type,\n\t// so we need to check the type name as well.\n\treturn isExported(t.Name()) || t.PkgPath() == \"\"\n}", "func isUnExported(name string) bool {\n\treturn reLower.Match([]byte(name))\n}", "func (config *Configuration) ShouldExport(typeName astmodel.TypeName) (result ShouldExportResult, because string) {\n\tfor _, f := range config.ExportFilters {\n\t\tif f.AppliesToType(typeName) {\n\t\t\tswitch f.Action {\n\t\t\tcase ExportFilterExclude:\n\t\t\t\treturn Skip, f.Because\n\t\t\tcase ExportFilterInclude:\n\t\t\t\treturn Export, f.Because\n\t\t\tdefault:\n\t\t\t\tpanic(errors.Errorf(\"unknown exportfilter directive: %s\", f.Action))\n\t\t\t}\n\t\t}\n\t}\n\n\t// By default we export all types\n\treturn Export, \"\"\n}", "func FieldNameIsGlobal(name string) bool {\n\tfor _, n := range GlobalFieldNames() {\n\t\tif n == name {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func (o *OutputField) HasFieldName() bool {\n\tif o != nil && !IsNil(o.FieldName) {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (o *ExportData) IsMaterialized() bool {\n\treturn false\n}", "func (o *ExportOptions) Changed(fieldName string) bool {\n\treturn util.Changed(o, fieldName)\n}", "func (p *PWMPin) Export() error {\n\treturn p.writeFile(\"export\", p.fn)\n}", "func (me TrestrictionType) IsPublic() bool { return me.String() == \"public\" }", "func (f *STAGFields) HasDEI() bool {\n\treturn has2ndBit(f.Flags)\n}", "func (x *fastReflection_Output) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.bank.v1beta1.Output.address\":\n\t\treturn x.Address != \"\"\n\tcase \"cosmos.bank.v1beta1.Output.coins\":\n\t\treturn len(x.Coins) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.Output\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.Output does not contain field %s\", fd.FullName()))\n\t}\n}", "func GetExportedName(field string) string {\n\tif strings.Contains(field, \"interface{}\") ||\n\t\tstrings.Contains(field, \"Interface{}\") {\n\t\treturn \"Interface\"\n\t}\n\n\t// Convert \"[]byte\" into \"byteSlice\". This also works with multiple slices,\n\t// like \"[][]byte\" to \"byteSliceSlice\".\n\tfor len(field) > 2 && field[:2] == \"[]\" {\n\t\tfield = field[2:] + \"Slice\"\n\t}\n\n\t// NotFunc(int)()\n\tfield = strings.Replace(field, \"(\", \"_\", -1)\n\tfield = strings.Replace(field, \")\", \"_\", -1)\n\n\treturn Ucfirst(strings.TrimLeft(field, \"*_\"))\n}", "func (o *Options) DumpAdaptationField() bool { return o.dumpAdaptationField }", "func isPinExported(number int) (bool, error) {\n\t_, err := os.Stat(fmt.Sprintf(\"/sys/class/gpio/gpio%d\", number))\n\tif err != nil {\n\t\tif !os.IsNotExist(err) {\n\t\t\treturn false, err\n\t\t}\n\t\treturn false, nil\n\t}\n\treturn true, nil\n}", "func (o *CreateImageExportTaskResponse) HasImageExportTask() bool {\n\tif o != nil && o.ImageExportTask != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (me TAttlistIssnIssnType) IsPrint() bool { return me.String() == \"Print\" }", "func (me TartIdTypeInt) IsBookaccession() bool { return me.String() == \"bookaccession\" }", "func (fn *Function) exportedRuntime() bool {\n\tname := fn.Name\n\tconst n = len(\"runtime.\")\n\treturn len(name) > n && name[:n] == \"runtime.\" && 'A' <= name[n] && name[n] <= 'Z'\n}", "func Export(exporter Exporter) error {\n\treturn exporter.Export()\n}", "func isFieldOverWritable(field string, meta map[string]MetaData, m map[string]interface{}) bool {\n\tif meta != nil && m[field] != nil {\n\t\tif metaData, exists := meta[field]; exists && metaData.OverWritable != nil {\n\t\t\treturn *metaData.OverWritable\n\t\t}\n\t}\n\treturn true\n}", "func (kb *Keybase) Export(name string) (armor string, err error) {\n\tkb.mx.Lock()\n\tdefer kb.mx.Unlock()\n\treturn kb.kb.Export(name)\n}", "func (d *Driver) IsImporting() bool {\n\treturn d.importer.IsImporting()\n}", "func (l *Loader) isModule() bool {\n\t// Either 1 of these checks is technically sufficient but let's be extra careful.\n\treturn l.globals.OnExportsChange != nil && l.globals.ControllerID != \"\"\n}", "func (m *SnapshotRemove) Field(fieldpath []string) (string, bool) {\n\tif len(fieldpath) == 0 {\n\t\treturn \"\", false\n\t}\n\tswitch fieldpath[0] {\n\tcase \"key\":\n\t\treturn string(m.Key), len(m.Key) > 0\n\tcase \"snapshotter\":\n\t\treturn string(m.Snapshotter), len(m.Snapshotter) > 0\n\t}\n\treturn \"\", false\n}", "func (o *IPFixField) isEnterprise() bool {\n\tif o.Type&0x8000 == 0 {\n\t\t// Enterprise Bit is 0.\n\t\treturn false\n\t}\n\t// Enterprise bit is 1.\n\treturn true\n}", "func (meta metadata) hasFieldWithIndex() bool {\n\tfor _, field := range meta.fields {\n\t\tif field.index == true {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (m *SnapshotPrepare) Field(fieldpath []string) (string, bool) {\n\tif len(fieldpath) == 0 {\n\t\treturn \"\", false\n\t}\n\tswitch fieldpath[0] {\n\tcase \"key\":\n\t\treturn string(m.Key), len(m.Key) > 0\n\tcase \"parent\":\n\t\treturn string(m.Parent), len(m.Parent) > 0\n\tcase \"snapshotter\":\n\t\treturn string(m.Snapshotter), len(m.Snapshotter) > 0\n\t}\n\treturn \"\", false\n}", "func ExportCard() string {\n\treturn \"I can see you!\"\n}", "func (o *StatusDescriptorDTO) HasField() bool {\n\tif o != nil && o.Field != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func isDefault(fl FieldLevel) bool {\n\treturn !hasValue(fl)\n}", "func (me TpubStatusInt) IsPubmedr() bool { return me.String() == \"pubmedr\" }", "func (o *ExportData) IsMutable() bool {\n\treturn false\n}", "func (fn *Func) IsPublic() bool {\n\treturn isPublicName(fn.Name)\n}", "func (me TxsdFeCompositeTypeOperator) IsOut() bool { return me.String() == \"out\" }", "func (m *Member) IsPrivate() bool { return !m.Published }", "func isExportedOrBuiltinType(t reflect.Type) bool {\n for t.Kind() == reflect.Ptr {\n t = t.Elem()\n }\n // PkgPath will be non-empty even for an exported type,\n // so we need to check the type name as well.\n return isExported(t.Name()) || t.PkgPath() == \"\"\n}", "func (typ *Type) IsPublic() bool {\n\treturn isPublicName(typ.Name)\n}", "func (self *PEFile) Exports() []string {\n\tself.mu.Lock()\n\tdefer self.mu.Unlock()\n\n\tif self.exports == nil {\n\t\tself.forwards = []string{}\n\t\tself.exports = []string{}\n\n\t\texport_desc, err := self.nt_header.ExportDirectory(self.rva_resolver)\n\t\tif err == nil && export_desc != nil {\n\t\t\tfor _, desc := range self.nt_header.ExportTable(self.rva_resolver) {\n\t\t\t\tif desc.Forwarder != \"\" {\n\t\t\t\t\tself.forwards = append(self.forwards, desc.Forwarder)\n\t\t\t\t} else if desc.Name == \"\" {\n\t\t\t\t\tself.exports = append(self.exports,\n\t\t\t\t\t\tfmt.Sprintf(\"%s:#%d\", desc.DLLName, desc.Ordinal))\n\t\t\t\t} else {\n\t\t\t\t\tself.exports = append(self.exports,\n\t\t\t\t\t\tfmt.Sprintf(\"%s:%s\", desc.DLLName, desc.Name))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn self.exports\n}", "func (me TAttlistJournalIssueCitedMedium) IsPrint() bool { return me.String() == \"Print\" }", "func (f *Field) IsList() bool {\n\treturn f.Type.IsList()\n}", "func (me TdtypeType) IsCsv() bool { return me.String() == \"csv\" }", "func (w *BatchedFileWriter) IsAccessible() bool {\n\t_, err := w.getStats()\n\treturn err == nil\n}", "func (m *AccessPackage) GetIsHidden()(*bool) {\n return m.isHidden\n}", "func isFieldStringable(tpe ast.Expr) bool {\n\tif ident, ok := tpe.(*ast.Ident); ok {\n\t\tswitch ident.Name {\n\t\tcase \"int\", \"int8\", \"int16\", \"int32\", \"int64\",\n\t\t\t\"uint\", \"uint8\", \"uint16\", \"uint32\", \"uint64\",\n\t\t\t\"float64\", \"string\", \"bool\":\n\t\t\treturn true\n\t\t}\n\t} else if starExpr, ok := tpe.(*ast.StarExpr); ok {\n\t\treturn isFieldStringable(starExpr.X)\n\t} else {\n\t\treturn false\n\t}\n\treturn false\n}", "func (me TxsdInvoiceType) IsFs() bool { return me.String() == \"FS\" }", "func (o *CreateSnapshotExportTaskRequest) GetOsuExportOk() (*OsuExportToCreate, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn &o.OsuExport, true\n}", "func (me TAttlistArticlePubModel) IsElectronicPrint() bool { return me.String() == \"Electronic-Print\" }", "func (c *MockFileStorageClient) GetExport(ctx context.Context, request filestorage.GetExportRequest) (response filestorage.GetExportResponse, err error) {\n\treturn filestorage.GetExportResponse{\n\t\tExport: filestorage.Export{\n\t\t\tId: common.String(exportID),\n\t\t\tFileSystemId: &fileSystemID,\n\t\t\tExportSetId: &exportSetID,\n\t\t\tLifecycleState: filestorage.ExportLifecycleStateActive,\n\t\t\tPath: common.String(\"/\" + fileSystemID),\n\t\t},\n\t}, nil\n}", "func (so SchemaObj) Export() SchemaObj {\n\treturn SchemaObj{\n\t\tRef: so.Ref,\n\t\tTypeName: so.TypeName,\n\t}\n}", "func (z *Zone) Export() (Export, error) {\n\tmyError := new(Error)\n\texportSling := z.PowerDNSHandle.makeSling()\n\treq, err := exportSling.New().Get(strings.TrimRight(z.URL, \".\") + \"/export\").Request()\n\tresp, err := http.DefaultClient.Do(req)\n\n\tif err == nil && resp.StatusCode >= 400 {\n\t\tmyError.Message = strings.Join([]string{resp.Status, myError.Message}, \" \")\n\t\treturn \"\", myError\n\t}\n\n\tbodyBytes, err := ioutil.ReadAll(resp.Body)\n\treturn Export(bodyBytes), nil\n}", "func (p *GetField) IsNullable() bool {\n\treturn p.nullable\n}" ]
[ "0.7942144", "0.7447053", "0.7007186", "0.6894166", "0.6413923", "0.629122", "0.5990713", "0.59261256", "0.5923288", "0.5887067", "0.5830909", "0.58021146", "0.57487935", "0.57351464", "0.5712679", "0.5651064", "0.56369025", "0.5623521", "0.5584422", "0.5584422", "0.5584422", "0.5584422", "0.55707717", "0.55707717", "0.55707717", "0.55707717", "0.55707717", "0.55707717", "0.55707717", "0.55707717", "0.5542777", "0.5534313", "0.5519537", "0.54975605", "0.54891926", "0.5434379", "0.5389836", "0.5335057", "0.5306473", "0.5293039", "0.528366", "0.52693903", "0.5269193", "0.5247194", "0.52320707", "0.5219365", "0.51878583", "0.5181664", "0.5176098", "0.5176098", "0.51685786", "0.5159165", "0.5153842", "0.5133192", "0.5131032", "0.510854", "0.5094643", "0.50657314", "0.50577873", "0.50471586", "0.5046709", "0.50450116", "0.5033974", "0.50299627", "0.5017921", "0.5006215", "0.50015396", "0.497904", "0.4960431", "0.4959156", "0.49475726", "0.49462396", "0.4940675", "0.49274245", "0.49049702", "0.49049604", "0.48976395", "0.48924094", "0.4892032", "0.4884203", "0.48673627", "0.48613426", "0.4858738", "0.48415613", "0.4836273", "0.48361737", "0.48340437", "0.48339108", "0.4826236", "0.4820571", "0.4814181", "0.48030877", "0.48008648", "0.47929037", "0.4786535", "0.47791007", "0.47759283", "0.47663504", "0.4763629", "0.4755087" ]
0.8320898
0
IsZero returns if field have zero value, for example not initialized it panic if field is not exported
func (f *Fieldx) IsZero() bool { zero := reflect.Zero(f.value.Type()).Interface() return reflect.DeepEqual(f.Value(), zero) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v *AggregatedDutyCycleValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *FCtrl) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"ack\":\n\t\treturn !v.Ack\n\tcase \"adr\":\n\t\treturn !v.ADR\n\tcase \"adr_ack_req\":\n\t\treturn !v.ADRAckReq\n\tcase \"class_b\":\n\t\treturn !v.ClassB\n\tcase \"f_pending\":\n\t\treturn !v.FPending\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *MACPayload) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"decoded_payload\":\n\t\treturn v.DecodedPayload == nil\n\tcase \"f_hdr\":\n\t\treturn fieldsAreZero(&v.FHDR, FHDRFieldPathsTopLevel...)\n\tcase \"f_hdr.dev_addr\":\n\t\treturn v.FHDR.FieldIsZero(\"dev_addr\")\n\tcase \"f_hdr.f_cnt\":\n\t\treturn v.FHDR.FieldIsZero(\"f_cnt\")\n\tcase \"f_hdr.f_ctrl\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl\")\n\tcase \"f_hdr.f_ctrl.ack\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.ack\")\n\tcase \"f_hdr.f_ctrl.adr\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.adr\")\n\tcase \"f_hdr.f_ctrl.adr_ack_req\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.adr_ack_req\")\n\tcase \"f_hdr.f_ctrl.class_b\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.class_b\")\n\tcase \"f_hdr.f_ctrl.f_pending\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.f_pending\")\n\tcase \"f_hdr.f_opts\":\n\t\treturn v.FHDR.FieldIsZero(\"f_opts\")\n\tcase \"f_port\":\n\t\treturn v.FPort == 0\n\tcase \"frm_payload\":\n\t\treturn v.FRMPayload == nil\n\tcase \"full_f_cnt\":\n\t\treturn v.FullFCnt == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *MHDR) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"m_type\":\n\t\treturn v.MType == 0\n\tcase \"major\":\n\t\treturn v.Major == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *DataRateIndexValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *ADRAckDelayExponentValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *DataRateOffsetValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *FHDR) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"dev_addr\":\n\t\treturn v.DevAddr == types.DevAddr{}\n\tcase \"f_cnt\":\n\t\treturn v.FCnt == 0\n\tcase \"f_ctrl\":\n\t\treturn v.FCtrl == FCtrl{}\n\tcase \"f_ctrl.ack\":\n\t\treturn v.FCtrl.FieldIsZero(\"ack\")\n\tcase \"f_ctrl.adr\":\n\t\treturn v.FCtrl.FieldIsZero(\"adr\")\n\tcase \"f_ctrl.adr_ack_req\":\n\t\treturn v.FCtrl.FieldIsZero(\"adr_ack_req\")\n\tcase \"f_ctrl.class_b\":\n\t\treturn v.FCtrl.FieldIsZero(\"class_b\")\n\tcase \"f_ctrl.f_pending\":\n\t\treturn v.FCtrl.FieldIsZero(\"f_pending\")\n\tcase \"f_opts\":\n\t\treturn v.FOpts == nil\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *ADRAckLimitExponentValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *DLSettings) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"opt_neg\":\n\t\treturn !v.OptNeg\n\tcase \"rx1_dr_offset\":\n\t\treturn v.Rx1DROffset == 0\n\tcase \"rx2_dr\":\n\t\treturn v.Rx2DR == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *RxDelayValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *FrequencyValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *PingSlotPeriodValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *Message) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"Payload\":\n\t\treturn v.Payload == nil\n\tcase \"Payload.join_accept_payload\":\n\t\treturn v.GetJoinAcceptPayload() == nil\n\tcase \"Payload.join_accept_payload.cf_list\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"cf_list\")\n\tcase \"Payload.join_accept_payload.cf_list.ch_masks\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"cf_list.ch_masks\")\n\tcase \"Payload.join_accept_payload.cf_list.freq\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"cf_list.freq\")\n\tcase \"Payload.join_accept_payload.cf_list.type\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"cf_list.type\")\n\tcase \"Payload.join_accept_payload.dev_addr\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"dev_addr\")\n\tcase \"Payload.join_accept_payload.dl_settings\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"dl_settings\")\n\tcase \"Payload.join_accept_payload.dl_settings.opt_neg\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"dl_settings.opt_neg\")\n\tcase \"Payload.join_accept_payload.dl_settings.rx1_dr_offset\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"dl_settings.rx1_dr_offset\")\n\tcase \"Payload.join_accept_payload.dl_settings.rx2_dr\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"dl_settings.rx2_dr\")\n\tcase \"Payload.join_accept_payload.encrypted\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"encrypted\")\n\tcase \"Payload.join_accept_payload.join_nonce\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"join_nonce\")\n\tcase \"Payload.join_accept_payload.net_id\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"net_id\")\n\tcase \"Payload.join_accept_payload.rx_delay\":\n\t\treturn v.GetJoinAcceptPayload().FieldIsZero(\"rx_delay\")\n\tcase \"Payload.join_request_payload\":\n\t\treturn v.GetJoinRequestPayload() == nil\n\tcase \"Payload.join_request_payload.dev_eui\":\n\t\treturn v.GetJoinRequestPayload().FieldIsZero(\"dev_eui\")\n\tcase \"Payload.join_request_payload.dev_nonce\":\n\t\treturn v.GetJoinRequestPayload().FieldIsZero(\"dev_nonce\")\n\tcase \"Payload.join_request_payload.join_eui\":\n\t\treturn v.GetJoinRequestPayload().FieldIsZero(\"join_eui\")\n\tcase \"Payload.mac_payload\":\n\t\treturn v.GetMACPayload() == nil\n\tcase \"Payload.mac_payload.decoded_payload\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"decoded_payload\")\n\tcase \"Payload.mac_payload.f_hdr\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr\")\n\tcase \"Payload.mac_payload.f_hdr.dev_addr\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.dev_addr\")\n\tcase \"Payload.mac_payload.f_hdr.f_cnt\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_cnt\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl.ack\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl.ack\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl.adr\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl.adr\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl.adr_ack_req\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl.adr_ack_req\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl.class_b\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl.class_b\")\n\tcase \"Payload.mac_payload.f_hdr.f_ctrl.f_pending\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_ctrl.f_pending\")\n\tcase \"Payload.mac_payload.f_hdr.f_opts\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_hdr.f_opts\")\n\tcase \"Payload.mac_payload.f_port\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"f_port\")\n\tcase \"Payload.mac_payload.frm_payload\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"frm_payload\")\n\tcase \"Payload.mac_payload.full_f_cnt\":\n\t\treturn v.GetMACPayload().FieldIsZero(\"full_f_cnt\")\n\tcase \"Payload.rejoin_request_payload\":\n\t\treturn v.GetRejoinRequestPayload() == nil\n\tcase \"Payload.rejoin_request_payload.dev_eui\":\n\t\treturn v.GetRejoinRequestPayload().FieldIsZero(\"dev_eui\")\n\tcase \"Payload.rejoin_request_payload.join_eui\":\n\t\treturn v.GetRejoinRequestPayload().FieldIsZero(\"join_eui\")\n\tcase \"Payload.rejoin_request_payload.net_id\":\n\t\treturn v.GetRejoinRequestPayload().FieldIsZero(\"net_id\")\n\tcase \"Payload.rejoin_request_payload.rejoin_cnt\":\n\t\treturn v.GetRejoinRequestPayload().FieldIsZero(\"rejoin_cnt\")\n\tcase \"Payload.rejoin_request_payload.rejoin_type\":\n\t\treturn v.GetRejoinRequestPayload().FieldIsZero(\"rejoin_type\")\n\tcase \"m_hdr\":\n\t\treturn v.MHDR == MHDR{}\n\tcase \"m_hdr.m_type\":\n\t\treturn v.MHDR.FieldIsZero(\"m_type\")\n\tcase \"m_hdr.major\":\n\t\treturn v.MHDR.FieldIsZero(\"major\")\n\tcase \"mic\":\n\t\treturn v.MIC == nil\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *JoinRequestPayload) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"dev_eui\":\n\t\treturn v.DevEUI == types.EUI64{}\n\tcase \"dev_nonce\":\n\t\treturn v.DevNonce == types.DevNonce{}\n\tcase \"join_eui\":\n\t\treturn v.JoinEUI == types.EUI64{}\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *CFList) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"ch_masks\":\n\t\treturn v.ChMasks == nil\n\tcase \"freq\":\n\t\treturn v.Freq == nil\n\tcase \"type\":\n\t\treturn v.Type == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (s *StructField) IsZero() bool {\n\treturn reflect2.IsZero(s.value)\n}", "func (v *JoinAcceptPayload) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"cf_list\":\n\t\treturn v.CFList == nil\n\tcase \"cf_list.ch_masks\":\n\t\treturn v.CFList.FieldIsZero(\"ch_masks\")\n\tcase \"cf_list.freq\":\n\t\treturn v.CFList.FieldIsZero(\"freq\")\n\tcase \"cf_list.type\":\n\t\treturn v.CFList.FieldIsZero(\"type\")\n\tcase \"dev_addr\":\n\t\treturn v.DevAddr == types.DevAddr{}\n\tcase \"dl_settings\":\n\t\treturn v.DLSettings == DLSettings{}\n\tcase \"dl_settings.opt_neg\":\n\t\treturn v.DLSettings.FieldIsZero(\"opt_neg\")\n\tcase \"dl_settings.rx1_dr_offset\":\n\t\treturn v.DLSettings.FieldIsZero(\"rx1_dr_offset\")\n\tcase \"dl_settings.rx2_dr\":\n\t\treturn v.DLSettings.FieldIsZero(\"rx2_dr\")\n\tcase \"encrypted\":\n\t\treturn v.Encrypted == nil\n\tcase \"join_nonce\":\n\t\treturn v.JoinNonce == types.JoinNonce{}\n\tcase \"net_id\":\n\t\treturn v.NetID == types.NetID{}\n\tcase \"rx_delay\":\n\t\treturn v.RxDelay == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *ApplicationIdentifiers) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"application_id\":\n\t\treturn v.ApplicationId == \"\"\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *RejoinRequestPayload) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"dev_eui\":\n\t\treturn v.DevEUI == types.EUI64{}\n\tcase \"join_eui\":\n\t\treturn v.JoinEUI == types.EUI64{}\n\tcase \"net_id\":\n\t\treturn v.NetID == types.NetID{}\n\tcase \"rejoin_cnt\":\n\t\treturn v.RejoinCnt == 0\n\tcase \"rejoin_type\":\n\t\treturn v.RejoinType == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func fieldIsEmpty(p unsafe.Pointer) bool {\n\treturn uintptr(p) == uintptr(0)\n}", "func TestZeroWithPrivateField(t *testing.T) {\n\ttype PrivateFieldStruct struct {\n\t\tprivField *int\n\t\tPublicField *int\n\t}\n\tpfstruct := new(PrivateFieldStruct)\n\n\terr := Zero(pfstruct)\n\n\tif err != nil {\n\t\tt.Errorf(\"Private field struct produced error: %v\", err)\n\t}\n\n\tif pfstruct.privField != nil {\n\t\tt.Errorf(\"Private field is not nil: %v\", pfstruct.privField)\n\t}\n\n\tif pfstruct.PublicField == nil || *pfstruct.PublicField != 0 {\n\t\tt.Errorf(\"Public field was not allocated correctly: %v\", pfstruct.PublicField)\n\t}\n}", "func (f *Field) IsZero() bool {\n\tzero := reflect.Zero(f.value.Type()).Interface()\n\tcurrent := f.Value()\n\n\treturn reflect.DeepEqual(current, zero)\n}", "func (p *Pet) IsFieldZero(field *mapping.StructField) (bool, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn p.ID == 0, nil\n\tcase 1: // Name\n\t\treturn p.Name == \"\", nil\n\tcase 3: // OwnerID\n\t\treturn p.OwnerID == 0, nil\n\t}\n\treturn false, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n}", "func (u *User) IsFieldZero(field *mapping.StructField) (bool, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn u.ID == 0, nil\n\tcase 1: // Name\n\t\treturn u.Name == \"\", nil\n\tcase 2: // CreatedAt\n\t\treturn u.CreatedAt == time.Time{}, nil\n\tcase 3: // CreatedAtIso\n\t\treturn u.CreatedAtIso == time.Time{}, nil\n\tcase 5: // MotherID\n\t\treturn u.MotherID == 0, nil\n\tcase 7: // FatherID\n\t\treturn u.FatherID == 0, nil\n\t}\n\treturn false, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n}", "func (f *Field) Zero() error {\n\tzero := reflect.Zero(f.value.Type()).Interface()\n\treturn f.Set(zero)\n}", "func (v *EndDeviceIdentifiers) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"application_ids\":\n\t\treturn v.ApplicationIds == nil\n\tcase \"application_ids.application_id\":\n\t\treturn v.ApplicationIds.FieldIsZero(\"application_id\")\n\tcase \"dev_addr\":\n\t\treturn v.DevAddr == nil\n\tcase \"dev_eui\":\n\t\treturn v.DevEui == nil\n\tcase \"device_id\":\n\t\treturn v.DeviceId == \"\"\n\tcase \"join_eui\":\n\t\treturn v.JoinEui == nil\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func IsZero(v reflect.Value) bool {\n\t//switch v.Kind() {\n\t//case reflect.Bool:\n\t//\treturn !v.Bool()\n\t//case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t//\treturn v.Int() == 0\n\t//case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t//\treturn v.Uint() == 0\n\t//case reflect.Float32, reflect.Float64:\n\t//\treturn math.Float64bits(v.Float()) == 0\n\t//case reflect.Complex64, reflect.Complex128:\n\t//\tc := v.Complex()\n\t//\treturn math.Float64bits(real(c)) == 0 && math.Float64bits(imag(c)) == 0\n\t//case reflect.Array:\n\t//\treturn isZeroArray(v)\n\t//case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:\n\t//\treturn v.IsNil()\n\t//case reflect.UnsafePointer:\n\t//\treturn isNil(v)\n\t//case reflect.String:\n\t//\treturn v.Len() == 0\n\t//case reflect.Struct:\n\t//\treturn isZeroStruct(v)\n\t//default:\n\t//\t// This should never happens, but will act as a safeguard for\n\t//\t// later, as a default value doesn't makes sense here.\n\t//\tpanic(fmt.Sprintf(\"reflect.Value.IsZero, kind=%b\", v.Kind()))\n\t//}\n\tswitch v.Kind() {\n\tcase reflect.Bool:\n\t\treturn !v.Bool()\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn v.Int() == 0\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn v.Uint() == 0\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn math.Float64bits(v.Float()) == 0\n\tcase reflect.Complex64, reflect.Complex128:\n\t\tc := v.Complex()\n\t\treturn math.Float64bits(real(c)) == 0 && math.Float64bits(imag(c)) == 0\n\tcase reflect.Array:\n\t\tfor i := 0; i < v.Len(); i++ {\n\t\t\tif !v.Index(i).IsZero() {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t\t// return isZeroArray(v)\n\tcase reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:\n\t\treturn IsNil(v)\n\tcase reflect.UnsafePointer:\n\t\treturn IsNil(v)\n\tcase reflect.String:\n\t\treturn v.Len() == 0\n\tcase reflect.Struct:\n\t\tfor i := 0; i < v.NumField(); i++ {\n\t\t\tif !v.Field(i).IsZero() {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t\t// return isZeroStruct(v)\n\tdefault:\n\t\t// This should never happens, but will act as a safeguard for\n\t\t// later, as a default value doesn't makes sense here.\n\t\t// panic(fmt.Sprintf(\"reflect.Value.IsZero, kind=%b\", v.Kind()))\n\t\treturn false\n\t}\n}", "func (f *Fieldx) Zero() error {\n\tzero := reflect.Zero(f.value.Type()).Interface()\n\treturn f.Set(zero)\n}", "func IsZero(v reflect.Value) bool {\n\tswitch v.Kind() {\n\tcase reflect.Struct:\n\t\tzero := true\n\t\tfor i := 0; i < v.NumField(); i++ {\n\t\t\tzero = zero && IsZero(v.Field(i))\n\t\t}\n\n\t\tif typ := v.Type(); typ != nil && v.IsValid() {\n\t\t\tf, ok := typ.MethodByName(\"IsZero\")\n\t\t\t// if not found\n\t\t\t// if has input arguments (1 is for the value receiver, so > 1 for the actual input args)\n\t\t\t// if output argument is not boolean\n\t\t\t// then skip this IsZero user-defined function.\n\t\t\tif !ok || f.Type.NumIn() > 1 || f.Type.NumOut() != 1 && f.Type.Out(0).Kind() != reflect.Bool {\n\t\t\t\treturn zero\n\t\t\t}\n\n\t\t\tmethod := v.Method(f.Index)\n\t\t\t// no needed check but:\n\t\t\tif method.IsValid() && !method.IsNil() {\n\t\t\t\t// it shouldn't panic here.\n\t\t\t\tzero = method.Call(EmptyIn)[0].Interface().(bool)\n\t\t\t}\n\t\t}\n\n\t\treturn zero\n\tcase reflect.Func, reflect.Map, reflect.Slice:\n\t\treturn v.IsNil()\n\tcase reflect.Array:\n\t\tzero := true\n\t\tfor i := 0; i < v.Len(); i++ {\n\t\t\tzero = zero && IsZero(v.Index(i))\n\t\t}\n\t\treturn zero\n\t}\n\t// if not any special type then use the reflect's .Zero\n\t// usually for fields, but remember if it's boolean and it's false\n\t// then it's zero, even if set-ed.\n\n\tif !v.CanInterface() {\n\t\t// if can't interface, i.e return value from unexported field or method then return false\n\t\treturn false\n\t}\n\n\tzero := reflect.Zero(v.Type())\n\treturn v.Interface() == zero.Interface()\n}", "func (s *Structx) Zero(name string) error {\n\tf, ok := s.Field(name)\n\tif !ok {\n\t\treturn ErrNotField\n\t}\n\n\treturn f.Zero()\n}", "func (this *otherActivityStruct) Zero() bool {\n\tenergyKJ := this.energyKJ\n\tresult := energyKJ == 0\n\treturn result\n}", "func IsZero(v interface{}) bool {\n\tvalue := reflect.ValueOf(v)\n\tif !value.IsValid() {\n\t\treturn true\n\t}\n\n\tswitch value.Kind() {\n\tcase reflect.Bool:\n\t\treturn value.Bool() == false\n\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn value.Int() == 0\n\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32,\n\t\treflect.Uint64, reflect.Uintptr:\n\t\treturn value.Uint() == 0\n\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn value.Float() == 0\n\n\tcase reflect.Complex64, reflect.Complex128:\n\t\treturn value.Complex() == 0\n\n\tcase reflect.Ptr, reflect.Interface:\n\t\treturn IsZero(value.Elem())\n\n\tcase reflect.Array:\n\t\tfor i := 0; i < value.Len(); i++ {\n\t\t\tif !IsZero(value.Index(i)) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\n\tcase reflect.Slice, reflect.String, reflect.Map:\n\t\treturn value.Len() == 0\n\n\tcase reflect.Struct:\n\t\tfor i, n := 0, value.NumField(); i < n; i++ {\n\t\t\tif !IsZero(value.Field(i)) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t// reflect.Chan, reflect.UnsafePointer, reflect.Func\n\tdefault:\n\t\treturn value.IsNil()\n\t}\n}", "func IsZero(x interface{}) bool {\n\tv := reflect.ValueOf(x)\n\treturn !v.IsValid() || reflect.DeepEqual(v.Interface(), reflect.Zero(v.Type()).Interface())\n}", "func (a ACME) IsZero() bool {\n\treturn !a.Enable &&\n\t\ta.Endpoint == \"\" &&\n\t\ta.Dir == \"\" &&\n\t\ta.Email == \"\" &&\n\t\tlen(a.Hosts) == 0\n}", "func (v Value) IsZero() bool {\n\tswitch v.Kind() {\n\tcase reflect.Bool:\n\t\treturn !v.Bool()\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn v.Int() == 0\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn v.Uint() == 0\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn math.Float64bits(v.Float()) == 0\n\tcase reflect.Complex64, reflect.Complex128:\n\t\tc := v.Complex()\n\t\treturn math.Float64bits(real(c)) == 0 && math.Float64bits(imag(c)) == 0\n\tcase reflect.Array:\n\t\tfor i := 0; i < v.Len(); i++ {\n\t\t\tif !v.Index(i).IsZero() {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t\t// return isZeroArray(v)\n\tcase reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:\n\t\treturn v.IsNil()\n\tcase reflect.UnsafePointer:\n\t\treturn v.IsNil()\n\tcase reflect.String:\n\t\treturn v.Len() == 0\n\tcase reflect.Struct:\n\t\tfor i := 0; i < v.NumField(); i++ {\n\t\t\tif !v.Field(i).IsZero() {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t\t// return isZeroStruct(v)\n\tdefault:\n\t\t// This should never happens, but will act as a safeguard for\n\t\t// later, as a default value doesn't makes sense here.\n\t\t// panic(fmt.Sprintf(\"reflect.Value.IsZero, kind=%b\", v.Kind()))\n\t\treturn false\n\t}\n}", "func IsZero(v interface{}) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\n\tvar rv reflect.Value\n\n\tif tv, ok := v.(reflect.Value); ok {\n\t\trv = tv\n\t} else {\n\t\trv = reflect.ValueOf(v)\n\t}\n\tif !rv.IsValid() {\n\t\treturn true\n\t}\n\n\treturn !nonzero(rv)\n}", "func IsZero(v interface{}) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tif z, ok := v.(IsZeroer); ok {\n\t\treturn z.IsZero()\n\t}\n\trv := reflect.ValueOf(v)\n\tswitch rv.Kind() {\n\t// We consider an Array to be of Zero Value when all of its elements are\n\t// that type's Zero Value.\n\tcase reflect.Array:\n\t\tret := true\n\t\tfor i := 0; i < rv.Len(); i++ {\n\t\t\tif !IsValueZero(rv.Index(i)) {\n\t\t\t\tret = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn ret\n\tcase reflect.Struct:\n\t\tret := true\n\t\tfor i := 0; i < rv.NumField(); i++ {\n\t\t\tif !IsValueZero(rv.Field(i)) {\n\t\t\t\tret = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn ret\n\tcase reflect.Map, reflect.Slice, reflect.String:\n\t\treturn rv.Len() == 0\n\tcase reflect.Bool:\n\t\treturn !rv.Bool()\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn rv.Int() == 0\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn rv.Uint() == 0\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn rv.Float() == 0\n\tcase reflect.Complex64, reflect.Complex128:\n\t\treturn rv == reflect.Zero(reflect.TypeOf(rv)).Interface()\n\tcase reflect.Chan, reflect.Func, reflect.Interface, reflect.Ptr:\n\t\treturn rv.IsNil()\n\t}\n\treturn false\n}", "func (info Info) IsZero() bool {\n\treturn reflect.ValueOf(info).IsZero()\n}", "func (dt *FieldTraits) AllowZeroValue(p Path) { dt.add(p, FieldTypeAllowZeroValue) }", "func Zero(t testing.TB, object interface{}, msgAndArgs ...interface{}) bool {\n\tif !IsObjectZero(object) {\n\t\treturn failTest(t, 1, fmt.Sprintf(\"Zero: expected to be zero value, actual `%#v`\", object), msgAndArgs...)\n\t}\n\n\treturn true\n}", "func (this *cyclingActivityStruct) Zero() bool {\n\tduration := this.duration\n\tdistanceKM := this.distanceKM\n\tdistanceKMZero := distanceKM.zero()\n\tenergyKJ := this.energyKJ\n\tresult := (duration == 0) && (distanceKMZero) && (energyKJ == 0)\n\treturn result\n}", "func rvIsZeroValue(rv reflect.Value, tt *Type) (bool, error) {\n\t// Walk pointers and interfaces, and handle nil values.\n\tfor rv.Kind() == reflect.Ptr || rv.Kind() == reflect.Interface {\n\t\tif rv.IsNil() {\n\t\t\t// All nil pointers and nil interfaces are considered to be zero. Note\n\t\t\t// that we may have a non-optional type that happens to be represented by\n\t\t\t// a pointer; technically nil might be considered an error, but it's\n\t\t\t// easier for the user (and for us) to treat it as zero.\n\t\t\treturn true, nil\n\t\t}\n\t\trv = rv.Elem()\n\t}\n\trt := rv.Type()\n\t// Now we know that rv isn't a pointer or interface, and also can't be nil.\n\t// Call VDLIsZero if it exists. This handles the vdl.Value/vom.RawBytes\n\t// cases, as well generated code and user-implemented VDLIsZero methods.\n\tif rt.Implements(rtIsZeroer) {\n\t\treturn rv.Interface().(IsZeroer).VDLIsZero(), nil\n\t}\n\tif reflect.PtrTo(rt).Implements(rtIsZeroer) {\n\t\tif rv.CanAddr() {\n\t\t\treturn rv.Addr().Interface().(IsZeroer).VDLIsZero(), nil\n\t\t}\n\t\t// Handle the harder case where *T implements IsZeroer, but we can't take\n\t\t// the address of rv to turn it into *T. Create a new *T value and fill it\n\t\t// in with rv, so that we can call VDLIsZero. This is conceptually similar\n\t\t// to storing rv in a temporary variable, so that we can take the address.\n\t\trvPtr := reflect.New(rt)\n\t\trvPtr.Elem().Set(rv)\n\t\treturn rvPtr.Interface().(IsZeroer).VDLIsZero(), nil\n\t}\n\t// Handle native types, by converting and checking the wire value for zero.\n\tif ni := nativeInfoFromNative(rt); ni != nil {\n\t\trvWirePtr := reflect.New(ni.WireType)\n\t\tif err := ni.FromNative(rvWirePtr, rv); err != nil {\n\t\t\treturn false, err\n\t\t}\n\t\treturn rvIsZeroValue(rvWirePtr.Elem(), tt)\n\t}\n\t// Optional is only zero if it is a nil pointer, which was handled above. The\n\t// interface form of any was also handled above, while the non-interface forms\n\t// were handled via VDLIsZero.\n\tif tt.Kind() == Optional || tt.Kind() == Any {\n\t\treturn false, nil\n\t}\n\t// TODO(toddw): We could consider adding a \"fastpath\" here to check against\n\t// the go zero value, or the zero value created by rvZeroValue, and possibly\n\t// returning early. This is tricky though; we can't use this fastpath if rt\n\t// contains any native types, but the only way to know whether rt contains any\n\t// native types is to look through the entire type, which might actually be\n\t// slower than the benefit of this \"fastpath\". The cases where it'll help are\n\t// large arrays or structs.\n\t//\n\t// Handle all reflect cases.\n\tswitch rv.Kind() {\n\tcase reflect.Bool:\n\t\treturn !rv.Bool(), nil\n\tcase reflect.String:\n\t\treturn rv.String() == \"\", nil\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn rv.Int() == 0, nil\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn rv.Uint() == 0, nil\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn rv.Float() == 0, nil\n\tcase reflect.Complex64, reflect.Complex128:\n\t\treturn rv.Complex() == 0, nil\n\tcase reflect.UnsafePointer:\n\t\treturn rv.Pointer() == 0, nil\n\tcase reflect.Slice, reflect.Map:\n\t\treturn rv.Len() == 0, nil\n\tcase reflect.Array:\n\t\tfor ix := 0; ix < rv.Len(); ix++ {\n\t\t\tif z, err := rvIsZeroValue(rv.Index(ix), tt.Elem()); err != nil || !z {\n\t\t\t\treturn false, err\n\t\t\t}\n\t\t}\n\t\treturn true, nil\n\tcase reflect.Struct:\n\t\tswitch tt.Kind() {\n\t\tcase Struct:\n\t\t\tfor ix := 0; ix < tt.NumField(); ix++ {\n\t\t\t\tfield := tt.Field(ix)\n\t\t\t\tif z, err := rvIsZeroValue(rv.FieldByName(field.Name), field.Type); err != nil || !z {\n\t\t\t\t\treturn false, err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true, nil\n\t\tcase Union:\n\t\t\t// We already handled the nil union interface case above in the regular\n\t\t\t// pointer/interface walking. Here we check to make sure the union field\n\t\t\t// struct represents field 0, and is set to its zero value.\n\t\t\t//\n\t\t\t// TypeFromReflect already validated Index(); call without error checking.\n\t\t\tif index := rv.Interface().(indexer).Index(); index != 0 {\n\t\t\t\treturn false, nil\n\t\t\t}\n\t\t\treturn rvIsZeroValue(rv.Field(0), tt.Field(0).Type)\n\t\t}\n\t}\n\treturn false, fmt.Errorf(\"vdl: rvIsZeroValue unhandled rt: %v tt: %v\", rt, tt)\n}", "func Zero(t Testing, v interface{}, formatAndArgs ...interface{}) bool {\n\tif v != nil && !reflect.DeepEqual(v, reflect.Zero(reflect.TypeOf(v)).Interface()) {\n\t\treturn Fail(t,\n\t\t\tpretty.Sprintf(\"Should be zero, but got: %# v\", v),\n\t\t\tformatAndArgs...)\n\t}\n\n\treturn true\n}", "func (f FlowRef) NonZero() bool {\n\treturn f.ID != \"\" && f.Ver != 0\n}", "func (n *Number) Zero() bool {\n\tif n.isInteger {\n\t\treturn n.integer.Cmp(&big.Int{}) == 0\n\t} else {\n\t\treturn n.floating == 0\n\t}\n}", "func (self *T) IsZero() bool {\n\treturn *self == Zero\n}", "func IsZero(v interface{}) bool {\n\treturn isZero(reflect.ValueOf(v))\n}", "func Zero[T any](t testing.TB, value T, msgAndArgs ...interface{}) {\n\tvar zero T\n\tif objectsAreEqual(value, zero) {\n\t\treturn\n\t}\n\tval := reflect.ValueOf(value)\n\tif (val.Kind() == reflect.Slice || val.Kind() == reflect.Map || val.Kind() == reflect.Array) && val.Len() == 0 {\n\t\treturn\n\t}\n\tt.Helper()\n\tmsg := formatMsgAndArgs(\"Expected a zero value but got:\", msgAndArgs...)\n\tt.Fatalf(\"%s\\n%s\", msg, repr.String(value, repr.Indent(\" \")))\n}", "func (o *protoObj) IsZeroValue() bool {\n\treturn proto.Equal(o.value, o.typeDesc.Zero())\n}", "func (side *Side) IsZero() bool {\n\tif string(*side) == \"ZERO\" {\n\t\treturn true\n\t}\n\treturn false\n}", "func (t T) Zero() bool { return t.cb == nil }", "func (this *runningActivityStruct) Zero() bool {\n\tduration := this.duration\n\tdistanceKM := this.distanceKM\n\tdistanceKMZero := distanceKM.zero()\n\tstepCount := this.stepCount\n\tenergyKJ := this.energyKJ\n\tresult := (duration == 0) && (distanceKMZero) && (stepCount == 0) && (energyKJ == 0)\n\treturn result\n}", "func (e *GT) IsZero() bool {\n\tif e.p == nil {\n\t\treturn true\n\t}\n\treturn e.p.IsZero()\n}", "func IsZeroValue(data interface{}) bool {\n\tif data == nil {\n\t\treturn true\n\t} else if value, ok := data.(string); ok {\n\t\treturn value == \"\"\n\t} else if value, ok := data.(bool); ok {\n\t\treturn value == false\n\t} else if value, ok := data.(float32); ok {\n\t\treturn value == 0\n\t} else if value, ok := data.(float64); ok {\n\t\treturn value == 0\n\t} else if value, ok := data.(int); ok {\n\t\treturn value == 0\n\t} else if value, ok := data.(int8); ok {\n\t\treturn value == 0\n\t} else if value, ok := data.(int16); ok {\n\t\treturn value == 0\n\t} else if value, ok := data.(int32); ok {\n\t\treturn value == 0\n\t} else if value, ok := data.(int64); ok {\n\t\treturn value == 0\n\t} else if value, ok := data.(uint); ok {\n\t\treturn value == 0\n\t} else if value, ok := data.(uint8); ok {\n\t\treturn value == 0\n\t} else if value, ok := data.(uint16); ok {\n\t\treturn value == 0\n\t} else if value, ok := data.(uint32); ok {\n\t\treturn value == 0\n\t} else if value, ok := data.(uint64); ok {\n\t\treturn value == 0\n\t} else if value, ok := data.(uintptr); ok {\n\t\treturn value == 0\n\t} else if value, ok := data.(complex64); ok {\n\t\tvalue128 := complex128(value)\n\t\treturn math.Float64bits(real(value128)) == 0 && math.Float64bits(imag(value128)) == 0\n\t} else if value, ok := data.(complex128); ok {\n\t\treturn math.Float64bits(real(value)) == 0 && math.Float64bits(imag(value)) == 0\n\t} else {\n\t\tif IsStructObject(data) {\n\t\t\tif IsNil(data) {\n\t\t\t\treturn true\n\t\t\t}\n\n\t\t\tvalueOfData := reflect.ValueOf(data)\n\t\t\tfor i := 0; i < valueOfData.NumField(); i++ {\n\t\t\t\tif !IsZeroValue(valueOfData.Field(i).Interface()) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif IsNil(data) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true\n}", "func (c *Counter) CounterIsZero() bool {\n\treturn c.value == 0\n}", "func uint64IsZero(x uint64) int {\n\tx = ^x\n\tx &= x >> 32\n\tx &= x >> 16\n\tx &= x >> 8\n\tx &= x >> 4\n\tx &= x >> 2\n\tx &= x >> 1\n\treturn int(x & 1)\n}", "func (f funcData) IsZero() bool {\n\treturn f.t == nil && f.data == nil\n}", "func ExampleTime_IsZero() {\n\tgt := gtime.New(\"2018-08-08 08:08:08\")\n\n\tfmt.Println(gt.IsZero())\n\n\t// Output:\n\t// false\n}", "func (p IPPort) IsZero() bool { return p == IPPort{} }", "func (me TClipFillRuleType) IsNonzero() bool { return me.String() == \"nonzero\" }", "func NotZero(t testing.TB, object interface{}, msgAndArgs ...interface{}) bool {\n\tif IsObjectZero(object) {\n\t\treturn failTest(t, 1, fmt.Sprintf(\"NotZero: expected not to be zero value, actual `%#v`\", object), msgAndArgs...)\n\t}\n\n\treturn true\n}", "func IsZero(v interface{}) bool {\n\treturn isZero(reflect.ValueOf(v), v)\n}", "func (d *Document) IsZero() bool {\n\treturn d == nil || (d.Version == \"\" && len(d.Markups) == 0 &&\n\t\tlen(d.Atoms) == 0 && len(d.Cards) == 0 && len(d.Sections) == 0)\n}", "func uint64IsZero(x uint64) int {\r\n\tx = ^x\r\n\tx &= x >> 32\r\n\tx &= x >> 16\r\n\tx &= x >> 8\r\n\tx &= x >> 4\r\n\tx &= x >> 2\r\n\tx &= x >> 1\r\n\treturn int(x & 1)\r\n}", "func (i NullInt) IsZero() bool {\n\treturn !i.Valid\n}", "func (d Decomposition) IsZero() bool {\n\treturn len(d.monomes) == 0\n}", "func (self *T) IsZero() bool {\n\treturn self[0] == 0 && self[1] == 0\n}", "func IsZeroSafe(v reflect.Value) bool {\n\treturn IsZero(v)\n}", "func NotZero[T any](t testing.TB, value T, msgAndArgs ...interface{}) {\n\tvar zero T\n\tif !objectsAreEqual(value, zero) {\n\t\tval := reflect.ValueOf(value)\n\t\tif !((val.Kind() == reflect.Slice || val.Kind() == reflect.Map || val.Kind() == reflect.Array) && val.Len() == 0) {\n\t\t\treturn\n\t\t}\n\t}\n\tt.Helper()\n\tmsg := formatMsgAndArgs(\"Did not expect the zero value:\", msgAndArgs...)\n\tt.Fatalf(\"%s\\n%s\", msg, repr.String(value))\n}", "func (d DockerNetworkStatsDelta) IsZero() bool {\n\treturn d.Bytes == 0 && d.Packets == 0 && d.Dropped == 0 && d.Errors == 0\n}", "func TestZeroWithMapField(t *testing.T) {\n\ttype MapFieldStruct struct {\n\t\tMapField map[string]int\n\t}\n\tsimpleMapStruct := new(MapFieldStruct)\n\tZero(simpleMapStruct)\n\t// This would panic if executed pre-Zero\n\tsimpleMapStruct.MapField[\"test\"] = 25\n}", "func NotZero(t Testing, v interface{}, formatAndArgs ...interface{}) bool {\n\tif v == nil || reflect.DeepEqual(v, reflect.Zero(reflect.TypeOf(v)).Interface()) {\n\t\treturn Fail(t,\n\t\t\tpretty.Sprintf(\"Should NOT be zero, but got: %# v\", v),\n\t\t\tformatAndArgs...)\n\t}\n\n\treturn true\n}", "func Test_Zero(t *testing.T) {\n\n\tvar zeroConcrete *ConcreteType\n\tvar zeroNested *NestedType\n\n\tinputs := []interface{}{\n\t\tConcreteType{},\n\t\tzeroConcrete,\n\t\tNestedType{},\n\t\tzeroNested,\n\t}\n\n\tfor i, input := range inputs {\n\t\tif !zero(reflect.ValueOf(input)) {\n\t\t\tt.Errorf(\"[%d] Value not zero\", i)\n\t\t}\n\t}\n}", "func (self *Map) IsZero(key string) bool {\n\treturn self.Get(key).IsZero()\n}", "func (a Attribute) IsZero() bool {\n\treturn a.Key == \"\"\n}", "func (ver *Version) IsZero() bool {\n\treturn reflect.ValueOf(ver.Version).IsZero()\n}", "func IsEmpty(val reflect.Value) bool {\n\ttypeStr := val.Kind().String()\n\tswitch typeStr {\n\tcase \"int\", \"int8\", \"int16\", \"int32\", \"int64\":\n\t\treturn val.Int() == 0\n\tcase \"float\", \"float8\", \"float16\", \"float32\", \"float64\":\n\t\treturn val.Float() == 0\n\tcase \"string\":\n\t\treturn val.String() == \"\"\n\tcase \"slice\", \"ptr\", \"map\", \"chan\", \"func\":\n\t\t// Check for empty slices and props\n\t\treturn val.IsNil()\n\tcase \"struct\":\n\t\tfieldCount := val.NumField()\n\t\tfor i := 0; i < fieldCount; i++ {\n\t\t\tfield := val.Field(i)\n\t\t\t// They passed in a value for this field, update our DB user\n\t\t\tif field.IsValid() && !IsEmpty(field) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}", "func (f *Field) IsExported() bool {\n\treturn f.field.PkgPath == \"\"\n}", "func IsZeroVal(x interface{}) bool {\n\treturn x == nil || reflect.DeepEqual(x, reflect.Zero(reflect.TypeOf(x)).Interface())\n}", "func (s NullString) IsZero() bool {\n\treturn !s.Valid\n}", "func (d Date) IsZero() bool {\n\treturn d.Year == 0 && d.Month == 0 && d.Day == 0\n}", "func (d *GF255e) IsZero() uint64 {\n\treturn gf_iszero((*[4]uint64)(d), mq255e)\n}", "func (ip IP) IsZero() bool { return ip == IP{} }", "func (s Snowflake) IsZero() bool {\n\treturn uint64(s) == 0\n}", "func (dt DateTime) IsZero() bool {\n\treturn dt.src.IsZero()\n}", "func TestStringZeroForNotEmptyString(t *testing.T) {\n\n\t// Arrange.\n\n\ts := \"Hello utilities\"\n\n\t// Act.\n\n\tresult := IsZero(s)\n\n\t// Assert.\n\n\tassert.False(t, result)\n}", "func (d Date) IsZero() bool {\n\treturn d.Year == 0 && d.Month == time.Month(0) && d.Day == 0\n}", "func Zero(t TestingT, v interface{}, extras ...interface{}) bool {\n\tif v != nil && !reflect.DeepEqual(v, reflect.Zero(reflect.TypeOf(v)).Interface()) {\n\t\texps, acts := toString(reflect.Zero(reflect.TypeOf(v)).Interface(), v)\n\n\t\treturn Errorf(t, \"Expect to be zero\", []labeledOutput{\n\t\t\t{\n\t\t\t\tlabel: labelMessages,\n\t\t\t\tcontent: formatExtras(extras...),\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: \"-expected\",\n\t\t\t\tcontent: exps,\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: \"+received\",\n\t\t\t\tcontent: acts,\n\t\t\t},\n\t\t})\n\t}\n\n\treturn true\n}", "func (q *QueueBuilder) IsZero() bool {\n\treturn q.name == \"\" && q.kvs == nil\n}", "func (r *RatioMetric) IsZeroToOne() bool {\n\tif r.ZeroToOne == nil {\n\t\treturn DefaultZeroToOne\n\t}\n\treturn *r.ZeroToOne\n}", "func notZeroRecursive(t *testing.T, i interface{}, path string) bool {\n\ttypeOfI := reflect.TypeOf(i)\n\n\tif i == nil || reflect.DeepEqual(i, reflect.Zero(typeOfI).Interface()) {\n\t\tt.Errorf(\"%s: should not have been zero, but was %v\", path, i)\n\t\treturn false\n\t}\n\n\tvalid := true\n\tkind := typeOfI.Kind()\n\tvalue := reflect.ValueOf(i)\n\tswitch kind {\n\tcase reflect.Pointer:\n\t\tif !notZeroRecursive(t, value.Elem().Interface(), path) {\n\t\t\tvalid = false\n\t\t}\n\tcase reflect.Struct:\n\t\tfor i := 0; i < typeOfI.NumField(); i++ {\n\t\t\tif !typeOfI.Field(i).IsExported() {\n\t\t\t\t// Cannot access value.\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif typeOfI.Field(i).Tag.Get(\"json\") == \"-\" {\n\t\t\t\t// unserialized field\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif !notZeroRecursive(t, value.Field(i).Interface(), path+\".\"+typeOfI.Field(i).Name) {\n\t\t\t\tvalid = false\n\t\t\t}\n\t\t}\n\tcase reflect.Map:\n\t\titer := value.MapRange()\n\t\tfor iter.Next() {\n\t\t\tk := iter.Key()\n\t\t\tv := iter.Value()\n\t\t\tif !notZeroRecursive(t, k.Interface(), path+\".\"+\"<key>\") {\n\t\t\t\tvalid = false\n\t\t\t}\n\t\t\tif !notZeroRecursive(t, v.Interface(), path+\"[\"+fmt.Sprintf(\"%v\", k.Interface())+\"]\") {\n\t\t\t\tvalid = false\n\t\t\t}\n\t\t}\n\tcase reflect.Slice, reflect.Array:\n\t\tfor i := 0; i < value.Len(); i++ {\n\t\t\tif !notZeroRecursive(t, value.Index(i).Interface(), path+\"[\"+fmt.Sprintf(\"%d\", i)+\"]\") {\n\t\t\t\tvalid = false\n\t\t\t}\n\t\t}\n\t}\n\n\treturn valid\n}", "func (e Endpoint) IsZero() bool {\n\tswitch {\n\tcase e.Unresolveable != aws.UnknownTernary:\n\t\treturn false\n\tcase len(e.Hostname) != 0:\n\t\treturn false\n\tcase len(e.Protocols) != 0:\n\t\treturn false\n\tcase e.CredentialScope != (CredentialScope{}):\n\t\treturn false\n\tcase len(e.SignatureVersions) != 0:\n\t\treturn false\n\t}\n\treturn true\n}", "func (f *Flag) defaultIsZeroValue() bool {\n\tswitch f.Value.(type) {\n\tcase boolFlag:\n\t\treturn f.DefValue == \"false\"\n\tcase *durationValue:\n\t\t// Beginning in Go 1.7, duration zero values are \"0s\"\n\t\treturn f.DefValue == \"0\" || f.DefValue == \"0s\"\n\tcase *intValue, *int8Value, *int32Value, *int64Value, *uintValue, *uint8Value, *uint16Value, *uint32Value, *uint64Value, *countValue, *float32Value, *float64Value:\n\t\treturn f.DefValue == \"0\"\n\tcase *stringValue:\n\t\treturn f.DefValue == \"\"\n\tcase *ipValue, *ipMaskValue, *ipNetValue:\n\t\treturn f.DefValue == \"<nil>\"\n\tcase *intSliceValue, *stringSliceValue, *stringArrayValue:\n\t\treturn f.DefValue == \"[]\"\n\tdefault:\n\t\tswitch f.Value.String() {\n\t\tcase \"false\":\n\t\t\treturn true\n\t\tcase \"<nil>\":\n\t\t\treturn true\n\t\tcase \"\":\n\t\t\treturn true\n\t\tcase \"0\":\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n}", "func (f Frac) IsZero() bool {\n\treturn f.n == 0\n}", "func (n Name) Zero() bool {\n\treturn len(n) == 0\n}", "func (this *unsignedFixed) zero() bool {\n\tm := this.mantissa\n\tresult := m == 0\n\treturn result\n}", "func IsZeroFilled(b []byte) bool {\n\treturn isZeroFilledSimple(b)\n}", "func (id ID) IsZero() bool {\n\treturn id.td.IsZero()\n}", "func (s RepoSpec) IsZero() bool { return s.URI == \"\" }" ]
[ "0.76043546", "0.7460436", "0.73974884", "0.73912054", "0.7389284", "0.7320315", "0.7317287", "0.7259666", "0.72409093", "0.72366846", "0.7227143", "0.7223447", "0.71935904", "0.7121024", "0.7034144", "0.7012459", "0.6996373", "0.6978928", "0.6935796", "0.68634236", "0.6811397", "0.6724526", "0.6700752", "0.6494179", "0.6459126", "0.64410824", "0.6435759", "0.6422517", "0.6403189", "0.6398876", "0.6197301", "0.61653036", "0.61631584", "0.6160448", "0.61076415", "0.6084051", "0.6070434", "0.6068251", "0.60329986", "0.6027898", "0.6000703", "0.59567386", "0.5924898", "0.58779484", "0.5844005", "0.5831007", "0.582474", "0.5775628", "0.5763913", "0.57599205", "0.5757989", "0.57558787", "0.57469434", "0.57369256", "0.57354736", "0.5727619", "0.5726861", "0.57265204", "0.57263064", "0.57012165", "0.5700593", "0.56923234", "0.56835014", "0.5676008", "0.56754655", "0.5654233", "0.5653014", "0.5637358", "0.56267184", "0.562076", "0.56184083", "0.5615409", "0.56115806", "0.5603124", "0.560168", "0.56006324", "0.55968755", "0.5584571", "0.55829453", "0.55790484", "0.5567655", "0.5556685", "0.5555121", "0.5548496", "0.55440295", "0.55431545", "0.55403095", "0.55391586", "0.5535932", "0.553093", "0.55254656", "0.55232304", "0.55214995", "0.5520423", "0.5520419", "0.5508479", "0.5504777", "0.549973", "0.5493097", "0.5485391" ]
0.6695712
23
Set set value to the field, must be exported field
func (f *Fieldx) Set(v interface{}) error { if !f.IsExport() { return ErrNotExported } if !f.value.CanSet() { return errNotSettable } vv := reflect.ValueOf(v) if f.Kind() != vv.Kind() { return fmt.Errorf("xstruct: value kind not match, want: %s but got %s", f.Kind(), vv.Kind()) } f.value.Set(vv) return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *Field) Set(val interface{}) error {\n\t// we can't set unexported fields, so be sure this field is exported\n\tif !f.IsExported() {\n\t\treturn errNotExported\n\t}\n\n\t// do we get here? not sure...\n\tif !f.value.CanSet() {\n\t\treturn errNotSettable\n\t}\n\n\tgiven := reflect.ValueOf(val)\n\n\tif f.value.Kind() != given.Kind() {\n\t\treturn fmt.Errorf(\"wrong kind. got: %s want: %s\", given.Kind(), f.value.Kind())\n\t}\n\n\tf.value.Set(given)\n\treturn nil\n}", "func (f *Field) Set(l *Location, val string, seps *Delimeters) error {\n\tloc := l.Comp\n\tif loc < 0 {\n\t\tloc = 0\n\t}\n\tif x := loc - len(f.Components) + 1; x > 0 {\n\t\tf.Components = append(f.Components, make([]Component, x)...)\n\t}\n\terr := f.Components[loc].Set(l, val, seps)\n\tif err != nil {\n\t\treturn err\n\t}\n\tf.Value = f.encode(seps)\n\treturn nil\n}", "func (f *Field) SetValue(newValue interface{}) {\n\tf.Call(\"setValue\", newValue)\n}", "func (s *StructField) Set(v interface{}) error {\n\tif s.field.PkgPath != \"\" {\n\t\treturn errors.New(\"Field is not exported\")\n\t}\n\n\tif !s.CanSet() {\n\t\treturn errors.New(\"Field cannot be set\")\n\t}\n\n\tgiven := reflect.ValueOf(v)\n\n\tif s.value.Kind() != given.Kind() {\n\t\treturn errors.New(\"Field and value kind don't match\")\n\t}\n\n\ts.value.Set(given)\n\treturn nil\n}", "func (field *Field) Set(value interface{}) (err error) {\n if !field.Field.IsValid() {\n return errors.New(\"field value not valid\")\n }\n\n if !field.Field.CanAddr() {\n return ErrUnaddressable\n }\n\n reflectValue, ok := value.(reflect.Value)\n if !ok {\n reflectValue = reflect.ValueOf(value)\n }\n\n fieldValue := field.Field\n if reflectValue.IsValid() {\n if reflectValue.Type().ConvertibleTo(fieldValue.Type()) {\n fieldValue.Set(reflectValue.Convert(fieldValue.Type()))\n } else {\n if fieldValue.Kind() == reflect.Ptr {\n if fieldValue.IsNil() {\n fieldValue.Set(reflect.New(field.Struct.Type.Elem()))\n }\n fieldValue = fieldValue.Elem()\n }\n\n if reflectValue.Type().ConvertibleTo(fieldValue.Type()) {\n fieldValue.Set(reflectValue.Convert(fieldValue.Type()))\n } else if scanner, ok := fieldValue.Addr().Interface().(sql.Scanner); ok {\n v := reflectValue.Interface()\n if valuer, ok := v.(driver.Valuer); ok {\n if v, err = valuer.Value(); err == nil {\n err = scanner.Scan(v)\n }\n } else {\n err = scanner.Scan(v)\n }\n } else {\n err = fmt.Errorf(\"could not convert argument of field %s from %s to %s\", field.Name, reflectValue.Type(), fieldValue.Type())\n }\n }\n } else {\n field.Field.Set(reflect.Zero(field.Field.Type()))\n }\n\n field.IsBlank = isBlank(field.Field)\n return err\n}", "func (field *Field) Set(value interface{}) (err error) {\n\tif !field.Field.IsValid() {\n\t\treturn errors.New(\"field value not valid\")\n\t}\n\n\tif !field.Field.CanAddr() {\n\t\treturn ErrUnaddressable\n\t}\n\n\treflectValue, ok := value.(reflect.Value)\n\tif !ok {\n\t\treflectValue = reflect.ValueOf(value)\n\t}\n\n\tfieldValue := field.Field\n\tif reflectValue.IsValid() {\n\t\tif reflectValue.Type().ConvertibleTo(fieldValue.Type()) {\n\t\t\tfieldValue.Set(reflectValue.Convert(fieldValue.Type()))\n\t\t} else {\n\t\t\tif fieldValue.Kind() == reflect.Ptr {\n\t\t\t\tif fieldValue.IsNil() {\n\t\t\t\t\tfieldValue.Set(reflect.New(field.Struct.Type.Elem()))\n\t\t\t\t}\n\t\t\t\tfieldValue = fieldValue.Elem()\n\t\t\t}\n\n\t\t\tif reflectValue.Type().ConvertibleTo(fieldValue.Type()) {\n\t\t\t\tfieldValue.Set(reflectValue.Convert(fieldValue.Type()))\n\t\t\t} else {\n\t\t\t\terr = fmt.Errorf(\"could not convert argument of field %s from %s to %s\", field.Name, reflectValue.Type(), fieldValue.Type())\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfield.Field.Set(reflect.Zero(field.Field.Type()))\n\t}\n\n\treturn err\n}", "func (o *Wfmbushorttermforecastimportcompletetopicbuforecastmodification) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Wfmagent) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (r *Wrapper) Set(name string, val any) error {\n\tfv := r.rv.FieldByName(name)\n\tif !fv.IsValid() {\n\t\treturn errors.New(\"field not found\")\n\t}\n\n\tif !fv.CanSet() {\n\t\treturn errors.New(\"field can not set value\")\n\t}\n\n\tfv.Set(reflect.ValueOf(val))\n\treturn nil\n}", "func (o *Workitemwrapup) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (b *box) setFieldValue(x, y, v int) {\n\t// Matrix conversion, see: https://stackoverflow.com/a/14015582\n\tb.values[x+y*3] = v\n}", "func (o *Integrationtype) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func Set(target, source interface{}) error {\n\tconverter := &Converter{\n\t\tTagName: \"field\",\n\t}\n\n\treturn converter.Convert(source, target)\n}", "func (field *Field) SetValue(parser *ArgParse, args ...string) (size int, err error) {\n\tsize = 1\n\t// the basic setter\n\tif size, err = field.setValue(field.Value, args...); err != nil {\n\t\treturn\n\t}\n\n\tif fn := GetCallback(parser.Value, field.Callback); fn != nil {\n\t\tlog.Debug(\"try execute %v\", field.Callback)\n\t\t// trigger the callback, exit when callback return true\n\t\tif fn(parser) && ExitWhenCallback {\n\t\t\tlog.Info(\"execute callback %v, and exit 0\", field.Callback)\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\n\tfield.BeenSet = true\n\tif field.Value.Kind() == reflect.Ptr && field.Value.Elem().Kind() == reflect.Slice {\n\t\t// can set repeat\n\t\tfield.BeenSet = false\n\t}\n\tlog.Info(\"set %v as %v (%d)\", field.Name, field.Value, size)\n\treturn\n}", "func (f *TagField) SetValue(v string) {\n\tf.value = v\n}", "func (o *Contentmanagementworkspacedocumentstopicdocumentdatav2) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (s *LoadSaver) SetValue(id ident.Id, value interface{}) (err error) {\n\tif field, ok := s.data[id]; ok {\n\t\tfield.Value = value\n\t\ts.data[id] = field // record value back; it's not a pointer.\n\t\ts.changed = true\n\t} else if prop, ok := s.GetProperty(id); !ok {\n\t\terr = fmt.Errorf(\"couldnt find property %s.%s\", s, id)\n\t} else {\n\t\ts.data[id] = FieldValue{prop.GetType(), value}\n\t\ts.changed = true\n\t}\n\treturn\n}", "func (m *ModelStructRecord) SetField(name string, value reflect.Value) {\n\tif name == \"\" {\n\t\treturn\n\t}\n\tfieldValue := m.FieldValues[name]\n\t//if value.Kind() == reflect.Ptr {\n\t//\tpanic(\"RecordFieldSetError: value cannot be a ptr\")\n\t//}\n\tif fieldValue.IsValid() == false {\n\t\tm.VirtualFieldValues[name] = reflect.New(m.model.GetFieldWithName(name).StructField().Type).Elem()\n\t\tfieldValue = m.VirtualFieldValues[name]\n\t}\n\t//fieldValue = LoopIndirectAndNew(fieldValue)\n\tsafeSet(fieldValue, value)\n}", "func (fm *FinalModelStructOptional) Set(fbeValue *StructOptional) (int, error) {\n fm.buffer.Shift(fm.FBEOffset())\n fbeResult, err := fm.SetFields(fbeValue)\n fm.buffer.Unshift(fm.FBEOffset())\n return fbeResult, err\n}", "func setFieldValue(field *reflect.Value, value reflect.Value) {\n\tswitch field.Type().Kind() {\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\tfield.SetInt(int64(value.Float()))\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:\n\t\tfield.SetUint(uint64(value.Float()))\n\tdefault:\n\t\tfield.Set(value)\n\t}\n}", "func (o *Createshareresponse) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Wfmintradaydataupdatetopicintradayhistoricalqueuedata) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Directrouting) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (d Document) SetValue(field string, value interface{}) bool {\n\tif i, ok := d.data.index[field]; ok {\n\t\tvar (\n\t\t\trv reflect.Value\n\t\t\trt reflect.Type\n\t\t\tfv = d.rv.Field(i)\n\t\t\tft = fv.Type()\n\t\t)\n\n\t\tswitch v := value.(type) {\n\t\tcase nil:\n\t\t\trv = reflect.Zero(ft)\n\t\tcase reflect.Value:\n\t\t\trv = reflect.Indirect(v)\n\t\tdefault:\n\t\t\trv = reflect.Indirect(reflect.ValueOf(value))\n\t\t}\n\n\t\trt = rv.Type()\n\n\t\tif fv.Type() == rt || rt.AssignableTo(ft) {\n\t\t\tfv.Set(rv)\n\t\t\treturn true\n\t\t}\n\n\t\tif rt.ConvertibleTo(ft) {\n\t\t\treturn setConvertValue(ft, fv, rt, rv)\n\t\t}\n\n\t\tif ft.Kind() == reflect.Ptr {\n\t\t\treturn setPointerValue(ft, fv, rt, rv)\n\t\t}\n\t}\n\n\treturn false\n}", "func (o *Actionmap) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (r *Record) SetValue(fid int, val *Value) {\n\tif len(r.Fields) == 0 {\n\t\tr.Fields = make(map[int]*Value)\n\t}\n\tr.Fields[fid] = val\n}", "func (f *FieldNames) SetValue(val interface{}) {\n\t*f = val.(FieldNames)\n}", "func (v *ClassValue) setField(s *scope, name string, val Value) Value {\n\tout := v.Clone().(*ClassValue)\n\tout.Fields[name] = val\n\treturn out\n}", "func (r *Record) SetValue(value string) {\n\tr.Value = value\n}", "func (s *Struct) SetField(key string, to Item) (err error) {\n\treqType, ok := s.ty.Fields[key]\n\tif !ok {\n\t\treturn newError(ErrIndex, \"cannot retrieve undefined field %s\")\n\t}\n\tif !to.Type().Equals(reqType) {\n\t\treturn newError(\n\t\t\tErrType,\n\t\t\t\"field %s of type %s cannot be assigned to a %s\",\n\t\t\tkey,\n\t\t\treqType,\n\t\t\tto.Type(),\n\t\t)\n\t}\n\n\ts.value[key] = to\n\n\treturn nil\n}", "func (o *Posttextresponse) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (i *Info) SetField(column string, value interface{}) error {\n\tfieldName, ok := i.Metadata.Fields[column]\n\tif !ok {\n\t\treturn fmt.Errorf(\"SetField: column %s not found in orm info\", column)\n\t}\n\tfieldValue := reflect.ValueOf(i.Obj).Elem().FieldByName(fieldName)\n\n\tif !fieldValue.Type().AssignableTo(reflect.TypeOf(value)) {\n\t\treturn fmt.Errorf(\"column %s: native value %v (%s) is not assignable to field %s (%s)\",\n\t\t\tcolumn, value, reflect.TypeOf(value), fieldName, fieldValue.Type())\n\t}\n\tfieldValue.Set(reflect.ValueOf(value))\n\treturn nil\n}", "func (m *SettlementMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase settlement.FieldX:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetX(v)\n\t\treturn nil\n\tcase settlement.FieldY:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetY(v)\n\t\treturn nil\n\tcase settlement.FieldIsCity:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetIsCity(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Settlement field %s\", name)\n}", "func (f Field) Set(x, y int, b bool) {\n\tf.s[y][x] = b\n}", "func (o *Appevent) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Outcomequantilecondition) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Voicemailmessagestopicvoicemailmessage) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func SetFieldValue(i interface{}, field string, value interface{}) {\n\tv := reflect.ValueOf(i)\n\n\tif v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Struct {\n\t\tpanic(\"input must be a pointer to a struct\")\n\t}\n\n\tfieldVal := v.Elem().FieldByName(field)\n\n\tswitch fieldVal.Kind() {\n\tcase reflect.Bool:\n\t\tfieldVal.SetBool(value.(bool))\n\tcase reflect.Int:\n\tcase reflect.Int8:\n\tcase reflect.Int16:\n\tcase reflect.Int32:\n\tcase reflect.Int64:\n\t\tfieldVal.SetInt(value.(int64))\n\tcase reflect.Uint:\n\tcase reflect.Uint8:\n\tcase reflect.Uint16:\n\tcase reflect.Uint32:\n\tcase reflect.Uint64:\n\t\tfieldVal.SetUint(value.(uint64))\n\tcase reflect.Float32:\n\tcase reflect.Float64:\n\t\tfieldVal.SetFloat(value.(float64))\n\tcase reflect.Complex64:\n\tcase reflect.Complex128:\n\t\tfieldVal.SetComplex(value.(complex128))\n\tcase reflect.String:\n\t\tfieldVal.SetString(value.(string))\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"Unsupported type [%s]\", fieldVal.Kind().String()))\n\t}\n}", "func (o *Webchatmemberinfo) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Oauthclientrequest) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Edge) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (b *Bitfield) Set(field Bitfield, value bool) {\n\tif value {\n\t\t*b |= field\n\t} else {\n\t\t*b &= Bitfield(^uint8(field))\n\t}\n}", "func (m *WorkbookNamedItem) SetValue(value Jsonable)() {\n err := m.GetBackingStore().Set(\"value\", value)\n if err != nil {\n panic(err)\n }\n}", "func (stmt *statement) Set(field string, value interface{}) Statement {\n\treturn stmt.SetExpr(field, \"?\", value)\n}", "func (f *ExtensionField) Set(t protoreflect.ExtensionType, v protoreflect.Value) {\n\tf.typ = t\n\tf.value = v\n\tf.lazy = nil\n}", "func (o *Dialercampaignconfigchangecampaign) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (x *fastReflection_Supply) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {\n\tswitch fd.FullName() {\n\tcase \"cosmos.bank.v1beta1.Supply.total\":\n\t\tlv := value.List()\n\t\tclv := lv.(*_Supply_1_list)\n\t\tx.Total = *clv.list\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.Supply\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.Supply does not contain field %s\", fd.FullName()))\n\t}\n}", "func (fm *FinalModelStructBytes) Set(fbeValue *StructBytes) (int, error) {\n fm.buffer.Shift(fm.FBEOffset())\n fbeResult, err := fm.SetFields(fbeValue)\n fm.buffer.Unshift(fm.FBEOffset())\n return fbeResult, err\n}", "func setField(obj interface{}, name string, value interface{}) error {\n\tstructValue := reflect.ValueOf(obj).Elem()\n\tstructFieldValue := structValue.FieldByName(name)\n\n\tif !structFieldValue.IsValid() {\n\t\treturn fmt.Errorf(\"No such field: %s in obj\", name)\n\t}\n\n\tif !structFieldValue.CanSet() {\n\t\treturn fmt.Errorf(\"Cannot set %s field value\", name)\n\t}\n\n\tstructFieldType := structFieldValue.Type()\n\n\tvar val reflect.Value\n\tswitch structFieldType.String() {\n\tcase \"int\":\n\t\ti, _ := strconv.Atoi(value.(js.Value).String())\n\t\tval = reflect.ValueOf(i)\n\t\tbreak\n\tcase \"float64\":\n\t\ti, _ := strconv.ParseFloat(value.(js.Value).String(), 64)\n\t\tval = reflect.ValueOf(i)\n\t\tbreak\n\tcase \"bool\":\n\t\ti, _ := strconv.ParseBool(value.(js.Value).String())\n\t\tval = reflect.ValueOf(i)\n\t\tbreak\n\tcase \"string\":\n\t\tval = reflect.ValueOf(value.(js.Value).String())\n\t\tbreak\n\tdefault:\n\t\tval = reflect.ValueOf(value)\n\t\tbreak\n\t}\n\n\tstructFieldValue.Set(val)\n\treturn nil\n}", "func (o *Compliance) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (this *TriggerAction) Set(field string, value interface{}) {\n switch field {\n case \"id\":\n this.SetId(value.(int64))\n break\n case \"agentName\":\n this.agentName = value.(string)\n break\n case \"propertyName\":\n this.propertyName = value.(string)\n break\n case \"propertyValue\":\n this.propertyValue = value.(string)\n break\n }\n}", "func SetField(obj interface{}, name string, value interface{}) error {\n\tstructValue := reflect.ValueOf(obj).Elem()\n\tstructFieldValue := structValue.FieldByName(name)\n\n\tif !structFieldValue.IsValid() {\n\t\treturn fmt.Errorf(\"No such field: %s in obj\", name)\n\t}\n\n\tif !structFieldValue.CanSet() {\n\t\treturn fmt.Errorf(\"Cannot set %s field value\", name)\n\t}\n\n\tstructFieldType := structFieldValue.Type()\n\tval := reflect.ValueOf(value)\n\tif structFieldType != val.Type() {\n\t\treturn errors.New(\"Provided value type didn't match obj field type\")\n\t}\n\n\tstructFieldValue.Set(val)\n\treturn nil\n}", "func (e *Element) SetValue(val interface{}) {\n\te.value = val\n}", "func (o *ObjectRef) SetField(env *Env, fieldName string, value interface{}) error {\n\tclass, err := o.getClass(env)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvType, vClassName, err := typeOfValue(value)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar fieldSig string\n\tif env.preCalcSig != \"\" {\n\t\tfieldSig = env.preCalcSig\n\t\tenv.preCalcSig = \"\"\n\t} else {\n\t\tfieldSig = typeSignature(vType, vClassName)\n\t}\n\n\tfid, err := env.callGetFieldID(false, class, fieldName, fieldSig)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tswitch v := value.(type) {\n\tcase bool:\n\t\tsetBooleanField(env.jniEnv, o.jobject, fid, fromBool(v))\n\tcase byte:\n\t\tsetByteField(env.jniEnv, o.jobject, fid, jbyte(v))\n\tcase uint16:\n\t\tsetCharField(env.jniEnv, o.jobject, fid, jchar(v))\n\tcase int16:\n\t\tsetShortField(env.jniEnv, o.jobject, fid, jshort(v))\n\tcase int32:\n\t\tsetIntField(env.jniEnv, o.jobject, fid, jint(v))\n\tcase int:\n\t\tsetIntField(env.jniEnv, o.jobject, fid, jint(int32(v)))\n\tcase int64:\n\t\tsetLongField(env.jniEnv, o.jobject, fid, jlong(v))\n\tcase float32:\n\t\tsetFloatField(env.jniEnv, o.jobject, fid, jfloat(v))\n\tcase float64:\n\t\tsetDoubleField(env.jniEnv, o.jobject, fid, jdouble(v))\n\tcase jobj:\n\t\tsetObjectField(env.jniEnv, o.jobject, fid, v.jobj())\n\tcase []bool, []byte, []int16, []uint16, []int32, []int, []int64, []float32, []float64:\n\t\tarray, err := env.toJavaArray(v)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer deleteLocalRef(env.jniEnv, array)\n\t\tsetObjectField(env.jniEnv, o.jobject, fid, jobject(array))\n\tdefault:\n\t\treturn errors.New(\"JNIGI unknown field value\")\n\t}\n\n\tif env.exceptionCheck() {\n\t\treturn env.handleException()\n\t}\n\n\treturn nil\n}", "func setValueByName(target interface{}, fieldName string, fieldValue interface{}) (err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = exception.Newf(\"Error setting field: %v\", r)\n\t\t}\n\t}()\n\ttypeCheck := reflect.TypeOf(target)\n\tif typeCheck.Kind() != reflect.Ptr {\n\t\treturn exception.New(\"Cannot modify non-pointer target\")\n\t}\n\n\ttargetValue := reflectValue(target)\n\ttargetType := reflectType(target)\n\trelevantField, hasField := targetType.FieldByName(fieldName)\n\n\tif !hasField {\n\t\treturn exception.Newf(\"Field not found %s.%s\", targetType.Name(), fieldName)\n\t}\n\n\tfield := targetValue.FieldByName(relevantField.Name)\n\tfieldType := field.Type()\n\tif !field.CanSet() {\n\t\treturn exception.Newf(\"Cannot set field %s\", fieldName)\n\t}\n\n\tvalueReflected := reflectValue(fieldValue)\n\tif !valueReflected.IsValid() {\n\t\treturn exception.New(\"Reflected value is invalid, cannot continue.\")\n\t}\n\n\tif valueReflected.Type().AssignableTo(fieldType) {\n\t\tfield.Set(valueReflected)\n\t\treturn nil\n\t}\n\n\tif field.Kind() == reflect.Ptr {\n\t\tif valueReflected.CanAddr() {\n\t\t\tconvertedValue := valueReflected.Convert(fieldType.Elem())\n\t\t\tif convertedValue.CanAddr() {\n\t\t\t\tfield.Set(convertedValue.Addr())\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\treturn exception.New(\"Cannot take address of value for assignment to field pointer\")\n\t}\n\n\tif fieldAsString, isString := valueReflected.Interface().(string); isString {\n\t\tvar parsedValue reflect.Value\n\t\thandledType := true\n\t\tswitch fieldType.Kind() {\n\t\tcase reflect.Int:\n\t\t\tintValue, err := strconv.Atoi(fieldAsString)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(intValue)\n\t\tcase reflect.Int64:\n\t\t\tint64Value, err := strconv.ParseInt(fieldAsString, 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(int64Value)\n\t\tcase reflect.Uint16:\n\t\t\tintValue, err := strconv.Atoi(fieldAsString)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(uint16(intValue))\n\t\tcase reflect.Uint: //a.k.a. uint32\n\t\t\tintValue, err := strconv.Atoi(fieldAsString)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(uint(intValue))\n\t\tcase reflect.Uint32:\n\t\t\tintValue, err := strconv.Atoi(fieldAsString)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(uint32(intValue))\n\t\tcase reflect.Uint64:\n\t\t\tintValue, err := strconv.Atoi(fieldAsString)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(uint64(intValue))\n\t\tcase reflect.Float32:\n\t\t\tfloatValue, err := strconv.ParseFloat(fieldAsString, 32)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(floatValue)\n\t\tcase reflect.Float64:\n\t\t\tfloatValue, err := strconv.ParseFloat(fieldAsString, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn exception.Wrap(err)\n\t\t\t}\n\t\t\tparsedValue = reflect.ValueOf(floatValue)\n\t\tdefault:\n\t\t\thandledType = false\n\t\t}\n\t\tif handledType {\n\t\t\tfield.Set(parsedValue)\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tconvertedValue := valueReflected.Convert(fieldType)\n\tif convertedValue.IsValid() && convertedValue.Type().AssignableTo(fieldType) {\n\t\tfield.Set(convertedValue)\n\t\treturn nil\n\t}\n\n\treturn exception.New(\"Couldnt set field %s.%s\", targetType.Name(), fieldName)\n}", "func (fm *FieldModelOrder) Set(fbeValue *Order) error {\n fbeBegin, err := fm.SetBegin()\n if fbeBegin == 0 {\n return err\n }\n\n err = fm.SetFields(fbeValue)\n fm.SetEnd(fbeBegin)\n return err\n}", "func (m *InviteeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase invitee.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase invitee.FieldIsChild:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetIsChild(v)\n\t\treturn nil\n\tcase invitee.FieldHasPlusOne:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetHasPlusOne(v)\n\t\treturn nil\n\tcase invitee.FieldIsBridesmaid:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetIsBridesmaid(v)\n\t\treturn nil\n\tcase invitee.FieldIsGroomsman:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetIsGroomsman(v)\n\t\treturn nil\n\tcase invitee.FieldPlusOneName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPlusOneName(v)\n\t\treturn nil\n\tcase invitee.FieldPhone:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPhone(v)\n\t\treturn nil\n\tcase invitee.FieldEmail:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEmail(v)\n\t\treturn nil\n\tcase invitee.FieldAddressLine1:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddressLine1(v)\n\t\treturn nil\n\tcase invitee.FieldAddressLine2:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddressLine2(v)\n\t\treturn nil\n\tcase invitee.FieldAddressCity:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddressCity(v)\n\t\treturn nil\n\tcase invitee.FieldAddressState:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddressState(v)\n\t\treturn nil\n\tcase invitee.FieldAddressPostalCode:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddressPostalCode(v)\n\t\treturn nil\n\tcase invitee.FieldAddressCountry:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddressCountry(v)\n\t\treturn nil\n\tcase invitee.FieldRsvpResponse:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetRsvpResponse(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Invitee field %s\", name)\n}", "func (n *Node) SetField(field string, val interface{}) bool {\n\tfv := kit.FlatFieldValueByName(n.This, field)\n\tif !fv.IsValid() {\n\t\tlog.Printf(\"ki.SetField, could not find field %v on node %v\\n\", field, n.PathUnique())\n\t\treturn false\n\t}\n\tupdt := n.UpdateStart()\n\tok := kit.SetRobust(kit.PtrValue(fv).Interface(), val)\n\tif ok {\n\t\tbitflag.Set(n.Flags(), int(FieldUpdated))\n\t}\n\tn.UpdateEnd(updt)\n\treturn ok\n}", "func (m *HarborMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase harbor.FieldX:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetX(v)\n\t\treturn nil\n\tcase harbor.FieldY:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetY(v)\n\t\treturn nil\n\tcase harbor.FieldResource:\n\t\tv, ok := value.(harbor.Resource)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetResource(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Harbor field %s\", name)\n}", "func (df *DataFrame) SetField(name string, val starlark.Value) error {\n\tif df.frozen {\n\t\treturn fmt.Errorf(\"cannot set, DataFrame is frozen\")\n\t}\n\n\tif name == \"columns\" {\n\t\tidx, ok := val.(*Index)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"cannot assign to 'columns', wrong type\")\n\t\t}\n\t\tdf.columns = idx\n\t\treturn nil\n\t}\n\treturn starlark.NoSuchAttrError(name)\n}", "func (me *TKerningValue) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (f *Fields) Set(s []*Field)", "func (m *FeedMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase feed.FieldFeedID:\n\t\tv, ok := value.(uuid.UUID)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetFeedID(v)\n\t\treturn nil\n\tcase feed.FieldAudioURL:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAudioURL(v)\n\t\treturn nil\n\tcase feed.FieldCaption:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCaption(v)\n\t\treturn nil\n\tcase feed.FieldTranscript:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetTranscript(v)\n\t\treturn nil\n\tcase feed.FieldPrivacy:\n\t\tv, ok := value.(feed.Privacy)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPrivacy(v)\n\t\treturn nil\n\tcase feed.FieldOwnerID:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetOwnerID(v)\n\t\treturn nil\n\tcase feed.FieldCreatedAt:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCreatedAt(v)\n\t\treturn nil\n\tcase feed.FieldUpdatedAt:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetUpdatedAt(v)\n\t\treturn nil\n\tcase feed.FieldDeletedAt:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDeletedAt(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Feed field %s\", name)\n}", "func SetFieldValue(v interface{}, field string, newValue interface{}) interface{} {\n\tvar immutable reflect.Value\n\timmutable = GetReflectValue(v)\n\tf := immutable.FieldByName(field)\n\tif f.IsValid() && f.CanSet() {\n\t\tif f.Kind() == reflect.Int {\n\t\t\tf.SetInt(newValue.(int64))\n\t\t} else {\n\t\t\tf.Set(reflect.ValueOf(newValue))\n\t\t}\n\t}\n\treturn v\n}", "func (d Document) Set(fp []string, val interface{}) error {\n\td2, err := d.getDocument(fp[:len(fp)-1], true)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn d2.SetField(fp[len(fp)-1], val)\n}", "func (field *Field) Set(x, y int, b bool) {\n\tfield.states[y][x] = b\n}", "func setField(name string, field reflect.Value, usage string) {\n\tswitch field.Kind() {\n\tcase reflect.Bool:\n\t\tpflag.Bool(name, false, usage)\n\tcase reflect.Float64:\n\t\tpflag.Float64(name, 0, usage)\n\tcase reflect.Uint:\n\t\tpflag.Uint(name, 0, usage)\n\tcase reflect.String:\n\t\tpflag.String(name, \"\", usage)\n\tcase reflect.Slice:\n\t\tslice := field.Interface()\n\t\tif _, ok := slice.([]string); ok {\n\t\t\tpflag.StringSlice(name, []string{}, usage)\n\t\t} else if _, ok := slice.([]float64); ok {\n\t\t\tpflag.Float64Slice(name, []float64{}, usage)\n\t\t} else if _, ok := slice.([]uint); ok {\n\t\t\tpflag.UintSlice(name, []uint{}, usage)\n\t\t}\n\t\tpanic(\"unsupported slice type\")\n\tdefault:\n\t\tpanic(\"unsupported type\")\n\t}\n\tviper.BindPFlag(strings.ReplaceAll(name, \"-\", \".\"), pflag.Lookup(name))\n}", "func (fm *FieldModelFlagsSimple) Set(value *FlagsSimple) error {\n return fm.SetValue(*value)\n}", "func (o *Digitalcondition) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (field *Field) SetField() {\n\tdefer func() {\n\t\tif err := recover(); err != nil {\n\t\t}\n\t}()\n\n\tfield.SetDefault()\n\tfield.SetName()\n\tfield.SetIgnore()\n\tfield.SetDoc()\n\t//\tfield.SetShort()\n\tfield.SetOmit()\n\tfield.SetRequired()\n\tfield.SetKeyName()\n\tfield.SetFlagName()\n\tfield.SetValueFromEnv()\n\tfield.SetType()\n\t// Must run last if referencing any info from field settings\n\tif field.UseFlags {\n\t\tfield.AddFlag()\n\t}\n}", "func (m *CleaningroomMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase cleaningroom.FieldNote:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetNote(v)\n\t\treturn nil\n\tcase cleaningroom.FieldDateandstarttime:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDateandstarttime(v)\n\t\treturn nil\n\tcase cleaningroom.FieldPhonenumber:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPhonenumber(v)\n\t\treturn nil\n\tcase cleaningroom.FieldNumofem:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetNumofem(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Cleaningroom field %s\", name)\n}", "func (m *BookcourseMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase bookcourse.FieldACCESS:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetACCESS(v)\n\t\treturn nil\n\tcase bookcourse.FieldPHONE:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPHONE(v)\n\t\treturn nil\n\tcase bookcourse.FieldDETAIL:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDETAIL(v)\n\t\treturn nil\n\tcase bookcourse.FieldBOOKTIME:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetBOOKTIME(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Bookcourse field %s\", name)\n}", "func (suo *SettingUpdateOne) SetValue(s string) *SettingUpdateOne {\n\tsuo.mutation.SetValue(s)\n\treturn suo\n}", "func (d Document) SetField(field string, value interface{}) error {\n\tif d.m != nil {\n\t\td.m[field] = value\n\t\treturn nil\n\t}\n\tpanic(\"unimplemented\")\n}", "func (m *AuthorizeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase authorize.FieldProvider:\n\t\tv, ok := value.(authorize.Provider)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetProvider(v)\n\t\treturn nil\n\tcase authorize.FieldServiceID:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetServiceID(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Authorize field %s\", name)\n}", "func (m *InviteePartyMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase inviteeparty.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase inviteeparty.FieldCode:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCode(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown InviteeParty field %s\", name)\n}", "func (m *PaymentMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase payment.FieldPAYMENTAMOUNT:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPAYMENTAMOUNT(v)\n\t\treturn nil\n\tcase payment.FieldPHONENUMBER:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPHONENUMBER(v)\n\t\treturn nil\n\tcase payment.FieldEMAIL:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEMAIL(v)\n\t\treturn nil\n\tcase payment.FieldPAYMENTDATE:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPAYMENTDATE(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Payment field %s\", name)\n}", "func (o *OutputField) SetValue(v SqlExpression) {\n\to.Value = &v\n}", "func (m *SeriesMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase series.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Series field %s\", name)\n}", "func (this *AppItem) Set(field string, value interface{}) {\n switch field {\n case \"id\":\n this.SetId(value.(int64))\n break\n }\n}", "func (u ConstraintUpdater) SetValue(value string) ConstraintUpdater {\n\tu.fields[string(ConstraintDBSchema.Value)] = value\n\treturn u\n}", "func (m *OperativeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase operative.FieldOperativeName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetOperativeName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Operative field %s\", name)\n}", "func (o *VerifiableAddress) SetValue(v string) {\n\to.Value = v\n}", "func (o *Initialconfiguration) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *DepositMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase deposit.FieldAddedtime:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddedtime(v)\n\t\treturn nil\n\tcase deposit.FieldInfo:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetInfo(v)\n\t\treturn nil\n\tcase deposit.FieldDepositorname:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDepositorname(v)\n\t\treturn nil\n\tcase deposit.FieldDepositortell:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDepositortell(v)\n\t\treturn nil\n\tcase deposit.FieldRecipienttell:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetRecipienttell(v)\n\t\treturn nil\n\tcase deposit.FieldParcelcode:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetParcelcode(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Deposit field %s\", name)\n}", "func setField(obj interface{}, name string, value interface{}) error {\n\tstructValue := reflect.ValueOf(obj).Elem()\n\tstructType := reflect.TypeOf(obj).Elem()\n\tstructFieldValue := structValue.FieldByName(name)\n\n\tfor i := 0; i < structType.NumField(); i++ {\n\t\tfield := structType.Field(i)\n\t\ttag := field.Tag.Get(\"query\")\n\n\t\tif tag == name {\n\t\t\tstructFieldValue = structValue.Field(i)\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !structFieldValue.IsValid() || !structFieldValue.CanSet() {\n\t\treturn errors.New(fmt.Sprintf(\"%s is not allowed\", name))\n\t}\n\n\tstructFieldType := structFieldValue.Type()\n\tval := reflect.ValueOf(value)\n\n\tif structFieldType.Kind() == reflect.Bool {\n\t\tswitch val.String() {\n\t\tcase \"false\":\n\t\t\tstructFieldValue.SetBool(false)\n\t\t\treturn nil\n\t\tcase \"true\":\n\t\t\tstructFieldValue.SetBool(true)\n\t\t\treturn nil\n\t\tdefault:\n\t\t\treturn errors.New(fmt.Sprintf(\"%s must be a boolean\", name))\n\t\t}\n\t} else {\n\t\tstructFieldValue.Set(val)\n\t\treturn nil\n\t}\n}", "func (f *fragment) setValue(columnID uint64, bitDepth uint, value int64) (changed bool, err error) {\n\treturn f.setValueBase(columnID, bitDepth, value, false)\n}", "func (d *dbBase) setFieldValue(fi *fieldInfo, value interface{}, field reflect.Value) (interface{}, error) {\n\tfieldType := fi.fieldType\n\tisNative := !fi.isFielder\n\nsetValue:\n\tswitch {\n\tcase fieldType == TypeBooleanField:\n\t\tif isNative {\n\t\t\tif nb, ok := field.Interface().(sql.NullBool); ok {\n\t\t\t\tif value == nil {\n\t\t\t\t\tnb.Valid = false\n\t\t\t\t} else {\n\t\t\t\t\tnb.Bool = value.(bool)\n\t\t\t\t\tnb.Valid = true\n\t\t\t\t}\n\t\t\t\tfield.Set(reflect.ValueOf(nb))\n\t\t\t} else if field.Kind() == reflect.Ptr {\n\t\t\t\tif value != nil {\n\t\t\t\t\tv := value.(bool)\n\t\t\t\t\tfield.Set(reflect.ValueOf(&v))\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif value == nil {\n\t\t\t\t\tvalue = false\n\t\t\t\t}\n\t\t\t\tfield.SetBool(value.(bool))\n\t\t\t}\n\t\t}\n\tcase fieldType == TypeVarCharField || fieldType == TypeCharField || fieldType == TypeTextField || fieldType == TypeJSONField || fieldType == TypeJsonbField:\n\t\tif isNative {\n\t\t\tif ns, ok := field.Interface().(sql.NullString); ok {\n\t\t\t\tif value == nil {\n\t\t\t\t\tns.Valid = false\n\t\t\t\t} else {\n\t\t\t\t\tns.String = value.(string)\n\t\t\t\t\tns.Valid = true\n\t\t\t\t}\n\t\t\t\tfield.Set(reflect.ValueOf(ns))\n\t\t\t} else if field.Kind() == reflect.Ptr {\n\t\t\t\tif value != nil {\n\t\t\t\t\tv := value.(string)\n\t\t\t\t\tfield.Set(reflect.ValueOf(&v))\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif value == nil {\n\t\t\t\t\tvalue = \"\"\n\t\t\t\t}\n\t\t\t\tfield.SetString(value.(string))\n\t\t\t}\n\t\t}\n\tcase fieldType == TypeTimeField || fieldType == TypeDateField || fieldType == TypeDateTimeField:\n\t\tif isNative {\n\t\t\tif value == nil {\n\t\t\t\tvalue = time.Time{}\n\t\t\t} else if field.Kind() == reflect.Ptr {\n\t\t\t\tif value != nil {\n\t\t\t\t\tv := value.(time.Time)\n\t\t\t\t\tfield.Set(reflect.ValueOf(&v))\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfield.Set(reflect.ValueOf(value))\n\t\t\t}\n\t\t}\n\tcase fieldType == TypePositiveBitField && field.Kind() == reflect.Ptr:\n\t\tif value != nil {\n\t\t\tv := uint8(value.(uint64))\n\t\t\tfield.Set(reflect.ValueOf(&v))\n\t\t}\n\tcase fieldType == TypePositiveSmallIntegerField && field.Kind() == reflect.Ptr:\n\t\tif value != nil {\n\t\t\tv := uint16(value.(uint64))\n\t\t\tfield.Set(reflect.ValueOf(&v))\n\t\t}\n\tcase fieldType == TypePositiveIntegerField && field.Kind() == reflect.Ptr:\n\t\tif value != nil {\n\t\t\tif field.Type() == reflect.TypeOf(new(uint)) {\n\t\t\t\tv := uint(value.(uint64))\n\t\t\t\tfield.Set(reflect.ValueOf(&v))\n\t\t\t} else {\n\t\t\t\tv := uint32(value.(uint64))\n\t\t\t\tfield.Set(reflect.ValueOf(&v))\n\t\t\t}\n\t\t}\n\tcase fieldType == TypePositiveBigIntegerField && field.Kind() == reflect.Ptr:\n\t\tif value != nil {\n\t\t\tv := value.(uint64)\n\t\t\tfield.Set(reflect.ValueOf(&v))\n\t\t}\n\tcase fieldType == TypeBitField && field.Kind() == reflect.Ptr:\n\t\tif value != nil {\n\t\t\tv := int8(value.(int64))\n\t\t\tfield.Set(reflect.ValueOf(&v))\n\t\t}\n\tcase fieldType == TypeSmallIntegerField && field.Kind() == reflect.Ptr:\n\t\tif value != nil {\n\t\t\tv := int16(value.(int64))\n\t\t\tfield.Set(reflect.ValueOf(&v))\n\t\t}\n\tcase fieldType == TypeIntegerField && field.Kind() == reflect.Ptr:\n\t\tif value != nil {\n\t\t\tif field.Type() == reflect.TypeOf(new(int)) {\n\t\t\t\tv := int(value.(int64))\n\t\t\t\tfield.Set(reflect.ValueOf(&v))\n\t\t\t} else {\n\t\t\t\tv := int32(value.(int64))\n\t\t\t\tfield.Set(reflect.ValueOf(&v))\n\t\t\t}\n\t\t}\n\tcase fieldType == TypeBigIntegerField && field.Kind() == reflect.Ptr:\n\t\tif value != nil {\n\t\t\tv := value.(int64)\n\t\t\tfield.Set(reflect.ValueOf(&v))\n\t\t}\n\tcase fieldType&IsIntegerField > 0:\n\t\tif fieldType&IsPositiveIntegerField > 0 {\n\t\t\tif isNative {\n\t\t\t\tif value == nil {\n\t\t\t\t\tvalue = uint64(0)\n\t\t\t\t}\n\t\t\t\tfield.SetUint(value.(uint64))\n\t\t\t}\n\t\t} else {\n\t\t\tif isNative {\n\t\t\t\tif ni, ok := field.Interface().(sql.NullInt64); ok {\n\t\t\t\t\tif value == nil {\n\t\t\t\t\t\tni.Valid = false\n\t\t\t\t\t} else {\n\t\t\t\t\t\tni.Int64 = value.(int64)\n\t\t\t\t\t\tni.Valid = true\n\t\t\t\t\t}\n\t\t\t\t\tfield.Set(reflect.ValueOf(ni))\n\t\t\t\t} else {\n\t\t\t\t\tif value == nil {\n\t\t\t\t\t\tvalue = int64(0)\n\t\t\t\t\t}\n\t\t\t\t\tfield.SetInt(value.(int64))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tcase fieldType == TypeFloatField || fieldType == TypeDecimalField:\n\t\tif isNative {\n\t\t\tif nf, ok := field.Interface().(sql.NullFloat64); ok {\n\t\t\t\tif value == nil {\n\t\t\t\t\tnf.Valid = false\n\t\t\t\t} else {\n\t\t\t\t\tnf.Float64 = value.(float64)\n\t\t\t\t\tnf.Valid = true\n\t\t\t\t}\n\t\t\t\tfield.Set(reflect.ValueOf(nf))\n\t\t\t} else if field.Kind() == reflect.Ptr {\n\t\t\t\tif value != nil {\n\t\t\t\t\tif field.Type() == reflect.TypeOf(new(float32)) {\n\t\t\t\t\t\tv := float32(value.(float64))\n\t\t\t\t\t\tfield.Set(reflect.ValueOf(&v))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tv := value.(float64)\n\t\t\t\t\t\tfield.Set(reflect.ValueOf(&v))\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\n\t\t\t\tif value == nil {\n\t\t\t\t\tvalue = float64(0)\n\t\t\t\t}\n\t\t\t\tfield.SetFloat(value.(float64))\n\t\t\t}\n\t\t}\n\tcase fieldType&IsRelField > 0:\n\t\tif value != nil {\n\t\t\tfieldType = fi.relModelInfo.fields.pk.fieldType\n\t\t\tmf := reflect.New(fi.relModelInfo.addrField.Elem().Type())\n\t\t\tfield.Set(mf)\n\t\t\tf := mf.Elem().FieldByIndex(fi.relModelInfo.fields.pk.fieldIndex)\n\t\t\tfield = f\n\t\t\tgoto setValue\n\t\t}\n\t}\n\n\tif !isNative {\n\t\tfd := field.Addr().Interface().(Fielder)\n\t\terr := fd.SetRaw(value)\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"converted value `%v` set to Fielder `%s` failed, err: %s\", value, fi.fullName, err)\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn value, nil\n}", "func (m *OrganizationMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase organization.FieldCreateByUser:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCreateByUser(v)\n\t\treturn nil\n\tcase organization.FieldUpdateByUser:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetUpdateByUser(v)\n\t\treturn nil\n\tcase organization.FieldCreateTime:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCreateTime(v)\n\t\treturn nil\n\tcase organization.FieldUpdateTime:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetUpdateTime(v)\n\t\treturn nil\n\tcase organization.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Organization field %s\", name)\n}", "func (m *RepairinvoiceMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase repairinvoice.FieldBequipment:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetBequipment(v)\n\t\treturn nil\n\tcase repairinvoice.FieldEmtell:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEmtell(v)\n\t\treturn nil\n\tcase repairinvoice.FieldNum:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetNum(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Repairinvoice field %s\", name)\n}", "func (j *JetStreamRecord) SetValue(v string) *JetStreamRecord {\n\tj.value = []byte(v)\n\treturn j\n}", "func (c Connector) SetValue(key string, value interface{}) {\n\terr := c.Client.Set(key, value, 0).Err()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}", "func (m *NodeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase node.FieldValue:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetValue(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Node field %s\", name)\n}", "func (m *SystemMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase system.FieldCreateByUser:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCreateByUser(v)\n\t\treturn nil\n\tcase system.FieldUpdateByUser:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetUpdateByUser(v)\n\t\treturn nil\n\tcase system.FieldCreateTime:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCreateTime(v)\n\t\treturn nil\n\tcase system.FieldUpdateTime:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetUpdateTime(v)\n\t\treturn nil\n\tcase system.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown System field %s\", name)\n}", "func (m *MarketInfoMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase marketinfo.FieldHoursStart:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetHoursStart(v)\n\t\treturn nil\n\tcase marketinfo.FieldHoursEnd:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetHoursEnd(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown MarketInfo field %s\", name)\n}", "func (m *RoadMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase road.FieldX:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetX(v)\n\t\treturn nil\n\tcase road.FieldY:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetY(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Road field %s\", name)\n}", "func (m *RepairinvoiceMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase repairinvoice.FieldSymptomid:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetSymptomid(v)\n\t\treturn nil\n\tcase repairinvoice.FieldDeviceid:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDeviceid(v)\n\t\treturn nil\n\tcase repairinvoice.FieldUserid:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetUserid(v)\n\t\treturn nil\n\tcase repairinvoice.FieldStatusrepairid:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetStatusrepairid(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Repairinvoice field %s\", name)\n}", "func (m *StockMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase stock.FieldIDstock:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetIDstock(v)\n\t\treturn nil\n\tcase stock.FieldPriceproduct:\n\t\tv, ok := value.(float64)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPriceproduct(v)\n\t\treturn nil\n\tcase stock.FieldAmount:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAmount(v)\n\t\treturn nil\n\tcase stock.FieldTime:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetTime(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Stock field %s\", name)\n}", "func (m *EndWorkMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase endwork.FieldEndWork:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEndWork(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown EndWork field %s\", name)\n}", "func (m *BillMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase bill.FieldPrice:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPrice(v)\n\t\treturn nil\n\tcase bill.FieldTime:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetTime(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Bill field %s\", name)\n}" ]
[ "0.7465701", "0.72227156", "0.71931934", "0.7178279", "0.70525277", "0.70517707", "0.6954857", "0.6877703", "0.68667024", "0.68172044", "0.681091", "0.6808195", "0.6804601", "0.6799116", "0.67883015", "0.67820585", "0.67766744", "0.6732145", "0.67154026", "0.67043096", "0.6703355", "0.6637951", "0.66248876", "0.6613797", "0.6584867", "0.6582336", "0.6566604", "0.6551594", "0.65459925", "0.65421987", "0.6541566", "0.6531544", "0.653147", "0.652447", "0.6508856", "0.65064555", "0.6489401", "0.64866024", "0.64677155", "0.646655", "0.64526075", "0.6450631", "0.6444108", "0.64437366", "0.64367723", "0.64333504", "0.64126986", "0.6406765", "0.63940495", "0.6383998", "0.63671815", "0.6364148", "0.6363635", "0.6356521", "0.63488644", "0.6335782", "0.6309248", "0.6300153", "0.6298046", "0.6296627", "0.6292542", "0.6290084", "0.6289484", "0.6285681", "0.6267986", "0.6264854", "0.6258981", "0.62570244", "0.6250006", "0.62497944", "0.6246341", "0.6238711", "0.6237581", "0.6232751", "0.6232719", "0.623218", "0.6230218", "0.6227756", "0.6225253", "0.6220857", "0.6218688", "0.6218404", "0.6215734", "0.6207796", "0.62073386", "0.62066466", "0.62015253", "0.61982864", "0.61965954", "0.619588", "0.61922145", "0.6190153", "0.6185502", "0.61849093", "0.61844", "0.6182046", "0.61810976", "0.6177948", "0.6176613", "0.6175189" ]
0.72300845
1
Zero set field to zero value, must be exported field
func (f *Fieldx) Zero() error { zero := reflect.Zero(f.value.Type()).Interface() return f.Set(zero) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *Field) Zero() error {\n\tzero := reflect.Zero(f.value.Type()).Interface()\n\treturn f.Set(zero)\n}", "func (dt *FieldTraits) AllowZeroValue(p Path) { dt.add(p, FieldTypeAllowZeroValue) }", "func (p *Pet) SetFieldZeroValue(field *mapping.StructField) error {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\tp.ID = 0\n\tcase 1: // Name\n\t\tp.Name = \"\"\n\tcase 3: // OwnerID\n\t\tp.OwnerID = 0\n\tdefault:\n\t\treturn errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n\t}\n\treturn nil\n}", "func (u *User) SetFieldZeroValue(field *mapping.StructField) error {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\tu.ID = 0\n\tcase 1: // Name\n\t\tu.Name = \"\"\n\tcase 2: // CreatedAt\n\t\tu.CreatedAt = time.Time{}\n\tcase 3: // CreatedAtIso\n\t\tu.CreatedAtIso = time.Time{}\n\tcase 5: // MotherID\n\t\tu.MotherID = 0\n\tcase 7: // FatherID\n\t\tu.FatherID = 0\n\tdefault:\n\t\treturn errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n\t}\n\treturn nil\n}", "func mungeSetZeroValue(i int, rec []interface{}, destMeta sqlz.RecordMeta) {\n\t// REVISIT: do we need to do special handling for kind.Datetime\n\t// and kind.Time (e.g. \"00:00\" for time)?\n\tz := reflect.Zero(destMeta[i].ScanType()).Interface()\n\trec[i] = z\n}", "func (z *Element22) SetZero() *Element22 {\n\tz[0] = 0\n\tz[1] = 0\n\tz[2] = 0\n\tz[3] = 0\n\tz[4] = 0\n\tz[5] = 0\n\tz[6] = 0\n\tz[7] = 0\n\tz[8] = 0\n\tz[9] = 0\n\tz[10] = 0\n\tz[11] = 0\n\tz[12] = 0\n\tz[13] = 0\n\tz[14] = 0\n\tz[15] = 0\n\tz[16] = 0\n\tz[17] = 0\n\tz[18] = 0\n\tz[19] = 0\n\tz[20] = 0\n\tz[21] = 0\n\treturn z\n}", "func (v *Vec3i) SetZero() {\n\tv.SetScalar(0)\n}", "func (v *Vector) SetZero() {\n\tv.X = 0\n\tv.Y = 0\n\tv.Z = 0\n}", "func TestZeroWithPrivateField(t *testing.T) {\n\ttype PrivateFieldStruct struct {\n\t\tprivField *int\n\t\tPublicField *int\n\t}\n\tpfstruct := new(PrivateFieldStruct)\n\n\terr := Zero(pfstruct)\n\n\tif err != nil {\n\t\tt.Errorf(\"Private field struct produced error: %v\", err)\n\t}\n\n\tif pfstruct.privField != nil {\n\t\tt.Errorf(\"Private field is not nil: %v\", pfstruct.privField)\n\t}\n\n\tif pfstruct.PublicField == nil || *pfstruct.PublicField != 0 {\n\t\tt.Errorf(\"Public field was not allocated correctly: %v\", pfstruct.PublicField)\n\t}\n}", "func CopyNoneZeroField(from, to interface{}) {\n\tfValue := reflect.ValueOf(from)\n\ttValue := reflect.ValueOf(to)\n\tif fValue.Type() != tValue.Type() {\n\t\tpanic(fmt.Sprintf(\"from/to must by same type:from=%v, to=%v\", fValue.Type(), tValue.Type()))\n\t}\n\tfValue = fValue.Elem()\n\ttValue = tValue.Elem()\n\tif !tValue.CanAddr() {\n\t\tpanic(\"copy destination must be CanAddr\")\n\t}\n\n\tfor i := 0; i < fValue.NumField(); i++ {\n\t\tfield := fValue.Field(i)\n\t\tif !field.IsZero() && field.CanSet() {\n\t\t\ttValue.Field(i).Set(field)\n\t\t}\n\t}\n}", "func (wv *Spectrum) SetZero() {\n\tfor k := 0; k < 4; k++ {\n\t\twv.C[k] = 0\n\t}\n\n}", "func (e *Zero) Reset() {}", "func (s *Structx) Zero(name string) error {\n\tf, ok := s.Field(name)\n\tif !ok {\n\t\treturn ErrNotField\n\t}\n\n\treturn f.Zero()\n}", "func (n *Uint256) Zero() {\n\tn.n[0], n.n[1], n.n[2], n.n[3] = 0, 0, 0, 0\n}", "func TestZeroWithMapField(t *testing.T) {\n\ttype MapFieldStruct struct {\n\t\tMapField map[string]int\n\t}\n\tsimpleMapStruct := new(MapFieldStruct)\n\tZero(simpleMapStruct)\n\t// This would panic if executed pre-Zero\n\tsimpleMapStruct.MapField[\"test\"] = 25\n}", "func zeroval(ival int) {\n\tival = 0\n}", "func zeroval(ival int) {\n\tival = 0\n}", "func zeroval(ival int) {\n\tival = 0\n}", "func zeroval(ival int) {\n\tival = 0\n}", "func (v *DataRateIndexValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (this *otherActivityStruct) Zero() bool {\n\tenergyKJ := this.energyKJ\n\tresult := energyKJ == 0\n\treturn result\n}", "func (e *GT) Zero() *GT {\n\tif e.p == nil {\n\t\te.p = &gfP12{}\n\t}\n\te.p.SetZero()\n\treturn e\n}", "func Zero() Vect { return Vect{} }", "func (this *unsignedFixed) zero() bool {\n\tm := this.mantissa\n\tresult := m == 0\n\treturn result\n}", "func (dc *ByteArrayDictConverter) FillZero(out interface{}) {\n\to := out.([]parquet.ByteArray)\n\to[0] = dc.zeroVal\n\tfor i := 1; i < len(o); i *= 2 {\n\t\tcopy(o[i:], o[:i])\n\t}\n}", "func (v *DataRateOffsetValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func SetStructFieldIfZeroValue(strukt interface{}, fieldName string, value interface{}) (bool, error) {\n\tfieldType := reflect.TypeOf(value)\n\treturn setStructField(strukt, fieldName, value, fieldType, true)\n}", "func (s *Scalar) Zero() *Scalar {\n\ts.s = scalar.Scalar{}\n\treturn s\n}", "func (v *Vec4) Zero() {\n\tv.X = 0.0\n\tv.Y = 0.0\n\tv.Z = 0.0\n\tv.W = 0.0\n}", "func (dc *Float64DictConverter) FillZero(out interface{}) {\n\to := out.([]float64)\n\to[0] = dc.zeroVal\n\tfor i := 1; i < len(o); i *= 2 {\n\t\tcopy(o[i:], o[:i])\n\t}\n}", "func (t systemIntType) Zero() interface{} {\n\treturn int64(0)\n}", "func (t systemIntType) Zero() interface{} {\n\treturn int64(0)\n}", "func (t systemSetType) Zero() interface{} {\n\treturn \"\"\n}", "func (dc *FixedLenByteArrayDictConverter) FillZero(out interface{}) {\n\to := out.([]parquet.FixedLenByteArray)\n\to[0] = dc.zeroVal\n\tfor i := 1; i < len(o); i *= 2 {\n\t\tcopy(o[i:], o[:i])\n\t}\n}", "func (t *Dense) Zero() {\n\tif t.IsMaterializable() {\n\t\tif err := t.zeroIter(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\tif t.IsMasked() {\n\t\tt.ResetMask()\n\t}\n\tswitch t.t.Kind() {\n\tcase reflect.Bool:\n\t\tdata := t.bools()\n\t\tfor i := range data {\n\t\t\tdata[i] = false\n\n\t\t}\n\tcase reflect.Int:\n\t\tdata := t.ints()\n\t\tfor i := range data {\n\t\t\tdata[i] = 0\n\t\t}\n\tcase reflect.Int8:\n\t\tdata := t.int8s()\n\t\tfor i := range data {\n\t\t\tdata[i] = 0\n\t\t}\n\tcase reflect.Int16:\n\t\tdata := t.int16s()\n\t\tfor i := range data {\n\t\t\tdata[i] = 0\n\t\t}\n\tcase reflect.Int32:\n\t\tdata := t.int32s()\n\t\tfor i := range data {\n\t\t\tdata[i] = 0\n\t\t}\n\tcase reflect.Int64:\n\t\tdata := t.int64s()\n\t\tfor i := range data {\n\t\t\tdata[i] = 0\n\t\t}\n\tcase reflect.Uint:\n\t\tdata := t.uints()\n\t\tfor i := range data {\n\t\t\tdata[i] = 0\n\t\t}\n\tcase reflect.Uint8:\n\t\tdata := t.uint8s()\n\t\tfor i := range data {\n\t\t\tdata[i] = 0\n\t\t}\n\tcase reflect.Uint16:\n\t\tdata := t.uint16s()\n\t\tfor i := range data {\n\t\t\tdata[i] = 0\n\t\t}\n\tcase reflect.Uint32:\n\t\tdata := t.uint32s()\n\t\tfor i := range data {\n\t\t\tdata[i] = 0\n\t\t}\n\tcase reflect.Uint64:\n\t\tdata := t.uint64s()\n\t\tfor i := range data {\n\t\t\tdata[i] = 0\n\t\t}\n\tcase reflect.Uintptr:\n\t\tdata := t.uintptrs()\n\t\tfor i := range data {\n\t\t\tdata[i] = 0\n\t\t}\n\tcase reflect.Float32:\n\t\tdata := t.float32s()\n\t\tfor i := range data {\n\t\t\tdata[i] = 0\n\t\t}\n\tcase reflect.Float64:\n\t\tdata := t.float64s()\n\t\tfor i := range data {\n\t\t\tdata[i] = 0\n\t\t}\n\tcase reflect.Complex64:\n\t\tdata := t.complex64s()\n\t\tfor i := range data {\n\t\t\tdata[i] = 0\n\t\t}\n\tcase reflect.Complex128:\n\t\tdata := t.complex128s()\n\t\tfor i := range data {\n\t\t\tdata[i] = 0\n\t\t}\n\tcase reflect.String:\n\t\tdata := t.strings()\n\t\tfor i := range data {\n\t\t\tdata[i] = \"\"\n\n\t\t}\n\tcase reflect.UnsafePointer:\n\t\tdata := t.unsafePointers()\n\t\tfor i := range data {\n\t\t\tdata[i] = nil\n\n\t\t}\n\tdefault:\n\t\tptr := uintptr(t.data)\n\t\tfor i := 0; i < t.hdr.Len; i++ {\n\t\t\twant := ptr + uintptr(i)*t.t.Size()\n\t\t\tval := reflect.NewAt(t.t, unsafe.Pointer(want))\n\t\t\tval = reflect.Indirect(val)\n\t\t\tval.Set(reflect.Zero(t.t))\n\t\t}\n\t}\n}", "func (r1 *csvTable) Zero() interface{} {\n\treturn r1.zero\n}", "func TestZeroWithPointerMapField(t *testing.T) {\n\ttype PtrMapFieldStruct struct {\n\t\tMapField *map[string]int\n\t}\n\tptrMapStruct := new(PtrMapFieldStruct)\n\tZero(ptrMapStruct)\n\t// This would panic if executed pre-Zero\n\t(*ptrMapStruct.MapField)[\"test\"] = 25\n}", "func (self *T) mZERO() {\r\n \r\n \r\n\t\t_type := T_ZERO\r\n\t\t_channel := antlr3rt.DEFAULT_TOKEN_CHANNEL\r\n\t\t// C:/dev/antlr.github/antlr/runtime/Go/antlr/test/T.g:8:5: ( '0' )\r\n\t\t// C:/dev/antlr.github/antlr/runtime/Go/antlr/test/T.g:8:7: '0'\r\n\t\t{\r\n\t\tself.MatchChar('0') \r\n\r\n\r\n\t\t}\r\n\r\n\t\tself.State().SetType( _type )\r\n\t\tself.State().SetChannel( _channel )\r\n}", "func (v *ADRAckLimitExponentValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func zero(x int) {\n\tfmt.Printf(\"in zero, &x: %p\\n\", &x)\n\tx = 0\n}", "func deepZero(st reflect.Type) (result reflect.Value) {\n\tresult = reflect.Indirect(reflect.New(st))\n\n\tif result.Kind() == reflect.Struct {\n\t\tfor i := 0; i < result.NumField(); i++ {\n\t\t\tif f := result.Field(i); f.Kind() == reflect.Ptr {\n\t\t\t\tif f.CanInterface() {\n\t\t\t\t\tif ft := reflect.TypeOf(f.Interface()); ft.Elem().Kind() == reflect.Struct {\n\t\t\t\t\t\tresult.Field(i).Set(recursivePointerTo(deepZero(ft.Elem())))\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn\n}", "func (v *AggregatedDutyCycleValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (d *Decoder) ZeroEmpty(z bool) {\n\td.zeroEmpty = z\n}", "func (c *Int64) ToZero() {\n\tc.mu.Lock()\n\tc.v = 0\n\tc.mu.Unlock()\n}", "func (v *FrequencyValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (dc *Int64DictConverter) FillZero(out interface{}) {\n\to := out.([]int64)\n\to[0] = dc.zeroVal\n\tfor i := 1; i < len(o); i *= 2 {\n\t\tcopy(o[i:], o[:i])\n\t}\n}", "func (l *LangPackStringPluralized) SetZeroValue(value string) {\n\tl.Flags.Set(0)\n\tl.ZeroValue = value\n}", "func Zero[T Number](val T, a ...any) {\n\tif val != 0 {\n\t\tdefMsg := fmt.Sprintf(assertionMsg+\": got '%v', want (== '0')\", val)\n\t\tDefault().reportAssertionFault(defMsg, a...)\n\t}\n}", "func (v *ADRAckDelayExponentValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (u *User) GetFieldZeroValue(field *mapping.StructField) (interface{}, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn 0, nil\n\tcase 1: // Name\n\t\treturn \"\", nil\n\tcase 2: // CreatedAt\n\t\treturn time.Time{}, nil\n\tcase 3: // CreatedAtIso\n\t\treturn time.Time{}, nil\n\tcase 5: // MotherID\n\t\treturn 0, nil\n\tcase 7: // FatherID\n\t\treturn 0, nil\n\tdefault:\n\t\treturn nil, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n\t}\n}", "func (dc *Float32DictConverter) FillZero(out interface{}) {\n\to := out.([]float32)\n\to[0] = dc.zeroVal\n\tfor i := 1; i < len(o); i *= 2 {\n\t\tcopy(o[i:], o[:i])\n\t}\n}", "func (c *Int) ToZero() {\n\tc.mu.Lock()\n\tc.v = 0\n\tc.mu.Unlock()\n}", "func (v *PingSlotPeriodValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *RxDelayValue) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"value\":\n\t\treturn v.Value == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (f *Flow) zero() error {\n\tif err := zeroNID(f); err != nil {\n\t\treturn err\n\t}\n\n\tfr := FlowRef{\n\t\tID: f.ID,\n\t\tVer: f.Ver,\n\t}\n\n\tids := map[string]int{}\n\tfor i, t := range f.Triggers {\n\t\tif err := t.zero(NcTrigger, fr); err != nil {\n\t\t\treturn fmt.Errorf(\"%s %d - %v\", NcTrigger, i, err)\n\t\t}\n\t\tids[t.id()]++\n\t}\n\tfor i, t := range f.Tasks {\n\t\tif err := t.zero(NcTask, fr); err != nil {\n\t\t\treturn fmt.Errorf(\"%s %d - %v\", NcTask, i, err)\n\t\t}\n\t\tids[t.id()]++\n\t}\n\n\t// check for unique id's\n\tfor k, c := range ids {\n\t\tif c != 1 {\n\t\t\treturn fmt.Errorf(\"%d nodes have id: %s\", c, k)\n\t\t}\n\t}\n\n\t// convert to json-able options\n\tf.fixupOpts()\n\n\treturn nil\n}", "func (v *DLSettings) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"opt_neg\":\n\t\treturn !v.OptNeg\n\tcase \"rx1_dr_offset\":\n\t\treturn v.Rx1DROffset == 0\n\tcase \"rx2_dr\":\n\t\treturn v.Rx2DR == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (fds *FDSet) Zero() {\n\tcopy(fds.X__fds_bits[:], (nullFdSet).X__fds_bits[:])\n}", "func (dc *Int96DictConverter) FillZero(out interface{}) {\n\to := out.([]parquet.Int96)\n\to[0] = dc.zeroVal\n\tfor i := 1; i < len(o); i *= 2 {\n\t\tcopy(o[i:], o[:i])\n\t}\n}", "func Zero(c currency.Currency) Money {\n\treturn Make(decimal.New(0, 0), c)\n}", "func (p *Pet) GetFieldZeroValue(field *mapping.StructField) (interface{}, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn 0, nil\n\tcase 1: // Name\n\t\treturn \"\", nil\n\tcase 3: // OwnerID\n\t\treturn 0, nil\n\tdefault:\n\t\treturn nil, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n\t}\n}", "func (d *Object) resetWrite() {\n\td.setSize(offsetFieldList)\n\td.setFieldCount(0)\n}", "func (s Seed) Zero() {\n\t// This is how hdkeychain clears bytes\n\tlens := len(s)\n\tfor i := 0; i < lens; i++ {\n\t\ts[i] = 0\n\t}\n}", "func (vn *VecN) Zero(n int) {\n\tvn.Resize(n)\n\tfor i := range vn.vec {\n\t\tvn.vec[i] = 0\n\t}\n}", "func (v *FCtrl) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"ack\":\n\t\treturn !v.Ack\n\tcase \"adr\":\n\t\treturn !v.ADR\n\tcase \"adr_ack_req\":\n\t\treturn !v.ADRAckReq\n\tcase \"class_b\":\n\t\treturn !v.ClassB\n\tcase \"f_pending\":\n\t\treturn !v.FPending\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func FD_ZERO(p *syscall.FdSet) {\n\tfor i := range p.Bits {\n\t\tp.Bits[i] = 0\n\t}\n}", "func (this *cyclingActivityStruct) Zero() bool {\n\tduration := this.duration\n\tdistanceKM := this.distanceKM\n\tdistanceKMZero := distanceKM.zero()\n\tenergyKJ := this.energyKJ\n\tresult := (duration == 0) && (distanceKMZero) && (energyKJ == 0)\n\treturn result\n}", "func (s Counters) Zero() {\n\tfor i := range s {\n\t\tc := &s[i]\n\t\tc.Count = 0\n\t}\n}", "func (v *MHDR) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"m_type\":\n\t\treturn v.MType == 0\n\tcase \"major\":\n\t\treturn v.Major == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func zero(xPtr *int){\n\t// When we write *xPtr = 0, we are saying \"store the int 0 in the memory location xPtr refers to\"\n\t*xPtr = 0\n}", "func (dc *Int32DictConverter) FillZero(out interface{}) {\n\to := out.([]int32)\n\to[0] = dc.zeroVal\n\tfor i := 1; i < len(o); i *= 2 {\n\t\tcopy(o[i:], o[:i])\n\t}\n}", "func (feature Feature) SetFieldNull(index int) {\n\tC.OGR_F_SetFieldNull(feature.cval, C.int(index))\n}", "func (v *FHDR) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"dev_addr\":\n\t\treturn v.DevAddr == types.DevAddr{}\n\tcase \"f_cnt\":\n\t\treturn v.FCnt == 0\n\tcase \"f_ctrl\":\n\t\treturn v.FCtrl == FCtrl{}\n\tcase \"f_ctrl.ack\":\n\t\treturn v.FCtrl.FieldIsZero(\"ack\")\n\tcase \"f_ctrl.adr\":\n\t\treturn v.FCtrl.FieldIsZero(\"adr\")\n\tcase \"f_ctrl.adr_ack_req\":\n\t\treturn v.FCtrl.FieldIsZero(\"adr_ack_req\")\n\tcase \"f_ctrl.class_b\":\n\t\treturn v.FCtrl.FieldIsZero(\"class_b\")\n\tcase \"f_ctrl.f_pending\":\n\t\treturn v.FCtrl.FieldIsZero(\"f_pending\")\n\tcase \"f_opts\":\n\t\treturn v.FOpts == nil\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (u *User) IsFieldZero(field *mapping.StructField) (bool, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn u.ID == 0, nil\n\tcase 1: // Name\n\t\treturn u.Name == \"\", nil\n\tcase 2: // CreatedAt\n\t\treturn u.CreatedAt == time.Time{}, nil\n\tcase 3: // CreatedAtIso\n\t\treturn u.CreatedAtIso == time.Time{}, nil\n\tcase 5: // MotherID\n\t\treturn u.MotherID == 0, nil\n\tcase 7: // FatherID\n\t\treturn u.FatherID == 0, nil\n\t}\n\treturn false, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n}", "func (p thinPoly) Zero() thinPoly {\n\tfor i := range p {\n\t\tp[i] = 0\n\t}\n\treturn p\n}", "func (s *CPUSet) Zero() {\n\tfor i := range s {\n\t\ts[i] = 0\n\t}\n}", "func ZeroKey(k *ecdsa.PrivateKey) {\n\tb := k.D.Bits()\n\tfor i := range b {\n\t\tb[i] = 0\n\t}\n}", "func Zero(v interface{}, name string) error {\n\treturn New(v).Zero(name)\n}", "func (v *RejoinRequestPayload) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"dev_eui\":\n\t\treturn v.DevEUI == types.EUI64{}\n\tcase \"join_eui\":\n\t\treturn v.JoinEUI == types.EUI64{}\n\tcase \"net_id\":\n\t\treturn v.NetID == types.NetID{}\n\tcase \"rejoin_cnt\":\n\t\treturn v.RejoinCnt == 0\n\tcase \"rejoin_type\":\n\t\treturn v.RejoinType == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (p *Pet) IsFieldZero(field *mapping.StructField) (bool, error) {\n\tswitch field.Index[0] {\n\tcase 0: // ID\n\t\treturn p.ID == 0, nil\n\tcase 1: // Name\n\t\treturn p.Name == \"\", nil\n\tcase 3: // OwnerID\n\t\treturn p.OwnerID == 0, nil\n\t}\n\treturn false, errors.Wrapf(mapping.ErrInvalidModelField, \"provided invalid field name: '%s'\", field.Name())\n}", "func setTblIfNonZeroMs(event *beat.Event, tableName string, fieldName string, valueMS int64) {\n\tif valueMS > 0 {\n\t\tevent.Fields[fmt.Sprintf(\"p4.tbl.%s.%s\", strings.ToLower(tableName), fieldName)] = float64(valueMS) / 1000.0\n\t}\n}", "func (v *MACPayload) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"decoded_payload\":\n\t\treturn v.DecodedPayload == nil\n\tcase \"f_hdr\":\n\t\treturn fieldsAreZero(&v.FHDR, FHDRFieldPathsTopLevel...)\n\tcase \"f_hdr.dev_addr\":\n\t\treturn v.FHDR.FieldIsZero(\"dev_addr\")\n\tcase \"f_hdr.f_cnt\":\n\t\treturn v.FHDR.FieldIsZero(\"f_cnt\")\n\tcase \"f_hdr.f_ctrl\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl\")\n\tcase \"f_hdr.f_ctrl.ack\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.ack\")\n\tcase \"f_hdr.f_ctrl.adr\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.adr\")\n\tcase \"f_hdr.f_ctrl.adr_ack_req\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.adr_ack_req\")\n\tcase \"f_hdr.f_ctrl.class_b\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.class_b\")\n\tcase \"f_hdr.f_ctrl.f_pending\":\n\t\treturn v.FHDR.FieldIsZero(\"f_ctrl.f_pending\")\n\tcase \"f_hdr.f_opts\":\n\t\treturn v.FHDR.FieldIsZero(\"f_opts\")\n\tcase \"f_port\":\n\t\treturn v.FPort == 0\n\tcase \"frm_payload\":\n\t\treturn v.FRMPayload == nil\n\tcase \"full_f_cnt\":\n\t\treturn v.FullFCnt == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func Zero() ID {\n\treturn nilID\n}", "func (fp *Fp2Element) Zeroize() {\n\t// Zeroizing in 2 seperated loops tells compiler to\n\t// use fast runtime.memclr()\n\tfor i := range fp.A {\n\t\tfp.A[i] = 0\n\t}\n\tfor i := range fp.B {\n\t\tfp.B[i] = 0\n\t}\n}", "func (bio *BinaryIO) Zero(off int64, count int) {\n\tbuf := makeBuf(count)\n\tfor count > 0 {\n\t\tbuf = truncBuf(buf, count)\n\t\tbio.WriteAt(off, buf)\n\t\tcount -= len(buf)\n\t\toff += int64(len(buf))\n\t}\n}", "func (f *Field) IsZero() bool {\n\tzero := reflect.Zero(f.value.Type()).Interface()\n\tcurrent := f.Value()\n\n\treturn reflect.DeepEqual(current, zero)\n}", "func (f *Fieldx) IsZero() bool {\n\tzero := reflect.Zero(f.value.Type()).Interface()\n\treturn reflect.DeepEqual(f.Value(), zero)\n}", "func ZeroValue(t JType) interface{} {\n\tif t.IsPrimitive() {\n\t\treturn basicZeroValue(t.Orig.Underlying().(*types.Basic))\n\t} else {\n\t\tv := \"new \" + t.JName() + \"(\"\n\t\tif t.NeedsAddress() {\n\t\t\tv += fmt.Sprint(FakeAddressFor(t.Ident))\n\t\t}\n\t\tv += \")\"\n\t\treturn v\n\t}\n}", "func Zero[T any](t testing.TB, value T, msgAndArgs ...interface{}) {\n\tvar zero T\n\tif objectsAreEqual(value, zero) {\n\t\treturn\n\t}\n\tval := reflect.ValueOf(value)\n\tif (val.Kind() == reflect.Slice || val.Kind() == reflect.Map || val.Kind() == reflect.Array) && val.Len() == 0 {\n\t\treturn\n\t}\n\tt.Helper()\n\tmsg := formatMsgAndArgs(\"Expected a zero value but got:\", msgAndArgs...)\n\tt.Fatalf(\"%s\\n%s\", msg, repr.String(value, repr.Indent(\" \")))\n}", "func (t JsonType) Zero() interface{} {\n\t// MySQL throws an error for INSERT IGNORE, UPDATE IGNORE, etc. when bad json is encountered:\n\t// ERROR 3140 (22032): Invalid JSON text: \"Invalid value.\" at position 0 in value for column 'table.column'.\n\treturn nil\n}", "func (s Set) Zero() Set {\r\n\tfor i := 0; i < len(s); i++ {\r\n\t\ts[i] = 0\r\n\t}\r\n\treturn s\r\n}", "func zeroValue(t reflect.Type) string {\n\tswitch t.Kind() {\n\tcase reflect.Bool:\n\t\treturn \"false\"\n\tcase reflect.String:\n\t\treturn `\"\"`\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn \"0\"\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn \"0\"\n\tcase reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128:\n\t\treturn \"0\"\n\tcase reflect.Ptr, reflect.Slice, reflect.Map, reflect.Interface:\n\t\treturn \"nil\"\n\tdefault:\n\t\treturn \"\"\n\t}\n}", "func TestFloat64Zero(t *testing.T) {\n\n\t// Arrange.\n\n\tvar f float64\n\tf = 9.99\n\n\t// Act.\n\n\tresult := reflect.Zero(reflect.TypeOf(f)).Interface()\n\n\t// Assert.\n\n\tassert.Equal(t, float64(0), result)\n}", "func (v *CFList) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"ch_masks\":\n\t\treturn v.ChMasks == nil\n\tcase \"freq\":\n\t\treturn v.Freq == nil\n\tcase \"type\":\n\t\treturn v.Type == 0\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func (v *ApplicationIdentifiers) FieldIsZero(p string) bool {\n\tif v == nil {\n\t\treturn true\n\t}\n\tswitch p {\n\tcase \"application_id\":\n\t\treturn v.ApplicationId == \"\"\n\t}\n\tpanic(fmt.Sprintf(\"unknown path '%s'\", p))\n}", "func Zero(t testing.TB, object interface{}, msgAndArgs ...interface{}) bool {\n\tif !IsObjectZero(object) {\n\t\treturn failTest(t, 1, fmt.Sprintf(\"Zero: expected to be zero value, actual `%#v`\", object), msgAndArgs...)\n\t}\n\n\treturn true\n}", "func zeroFunc(time.Duration) float64 { return 0 }", "func (Logical) Zero(c *compiler.Compiler) (expression compiler.Expression) {\n\texpression = c.NewExpression()\n\texpression.Type = Logical{}\n\n\texpression.Go.WriteString(`false`)\n\n\treturn\n}", "func (this *runningActivityStruct) Zero() bool {\n\tduration := this.duration\n\tdistanceKM := this.distanceKM\n\tdistanceKMZero := distanceKM.zero()\n\tstepCount := this.stepCount\n\tenergyKJ := this.energyKJ\n\tresult := (duration == 0) && (distanceKMZero) && (stepCount == 0) && (energyKJ == 0)\n\treturn result\n}", "func (n *Number) Zero() bool {\n\tif n.isInteger {\n\t\treturn n.integer.Cmp(&big.Int{}) == 0\n\t} else {\n\t\treturn n.floating == 0\n\t}\n}", "func (t *TriDense) Zero() {\n\tif t.isUpper() {\n\t\tfor i := 0; i < t.mat.N; i++ {\n\t\t\tzero(t.mat.Data[i*t.mat.Stride+i : i*t.mat.Stride+t.mat.N])\n\t\t}\n\t\treturn\n\t}\n\tfor i := 0; i < t.mat.N; i++ {\n\t\tzero(t.mat.Data[i*t.mat.Stride : i*t.mat.Stride+i+1])\n\t}\n}" ]
[ "0.76958394", "0.7169645", "0.70839614", "0.70075035", "0.6945009", "0.6762313", "0.6735866", "0.6724727", "0.66552305", "0.66209203", "0.6607081", "0.66033936", "0.65720856", "0.65431416", "0.65297574", "0.6425331", "0.6425331", "0.6425331", "0.6425331", "0.63963276", "0.6351561", "0.6304054", "0.630377", "0.62987506", "0.62813276", "0.62524635", "0.62498105", "0.6243641", "0.6217027", "0.6167861", "0.61584395", "0.61584395", "0.6142265", "0.6122804", "0.611153", "0.61000144", "0.608898", "0.6078813", "0.6074738", "0.60736775", "0.6065825", "0.6060409", "0.60479903", "0.6047804", "0.6038369", "0.60370725", "0.60134846", "0.6006651", "0.6003705", "0.5986305", "0.5972125", "0.5964849", "0.5946507", "0.593975", "0.5936133", "0.59310263", "0.59188664", "0.5913265", "0.5909189", "0.59050584", "0.58799124", "0.58738893", "0.5872219", "0.5834802", "0.5833075", "0.5829855", "0.5813779", "0.58080053", "0.57792383", "0.57743734", "0.57733697", "0.5772383", "0.57698745", "0.5758843", "0.57566386", "0.57547307", "0.5722954", "0.5718372", "0.57157075", "0.5715432", "0.5708059", "0.5705778", "0.57042414", "0.5695093", "0.5693623", "0.568914", "0.56722003", "0.5662012", "0.5656185", "0.56452507", "0.5641609", "0.5631879", "0.56203985", "0.56171227", "0.5610257", "0.5594939", "0.5594822", "0.5592925", "0.5590948", "0.5584976" ]
0.77790207
0
Set n and theta
func (tpe *TPE) Setup(n int, theta float64) { tpe.setup.N = n tpe.setup.Theta = theta }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (ds DataSet) SetTheta(t [][][]float64) {\n\tfor i, matrix := range t {\n\t\tfor j, row := range matrix {\n\t\t\tds.NN.Thetas[i].SetRow(j, row)\n\t\t}\n\t}\n}", "func Nagon(n int, radius float64) v2.VecSet {\n\tif n < 3 {\n\t\treturn nil\n\t}\n\tm := Rotate(Tau / float64(n))\n\tv := make(v2.VecSet, n)\n\tp := v2.Vec{radius, 0}\n\tfor i := 0; i < n; i++ {\n\t\tv[i] = p\n\t\tp = m.MulPosition(p)\n\t}\n\treturn v\n}", "func GenParams(N int64, Q nt.Integer) *NTTParams {\n\t// setting up initial parameters\n\tvar nttParams = &NTTParams{\n\t\tn: N,\n\t\tnRev: nt.ModInv(nt.FromInt64(int64(N)), &Q).Uint64(),\n\t\tq: Q,\n\t}\n\t// computing Psi terms\n\tg := primitiveRoot(&Q)\n\tfi := nt.Sub(&Q, nt.One)\n\n\t// compute the 2-nth root of unity and its inverse\n\t// psi = g^(fi/2n) mod q\n\t// psiInv = psi^-1 mod q\n\ttwoN := nt.FromInt64(2 * N)\n\texp := nt.Div(fi, twoN)\n\tpsi := nt.ModExp(g, exp, &Q)\n\tpsiInv := nt.ModInv(psi, &Q)\n\t// compute the powers of psi and psiInv\n\tnttParams.PsiRev = make([]*nt.Integer, N)\n\tnttParams.PsiInvRev = make([]*nt.Integer, N)\n\tvar Nbitlen uint32\n\tfor i := 32 - 1; i >= 0; i-- {\n\t\tif N&(1<<uint(i)) != 0 {\n\t\t\tNbitlen = uint32(i)\n\t\t\tbreak\n\t\t}\n\t}\n\tvar idxRev uint32\n\tvar i nt.Integer\n\tvar k int64\n\tfor k = 0; k < N; k++ {\n\t\ti.SetInt64(k)\n\t\tidxRev = bitRev(k, Nbitlen)\n\t\tnttParams.PsiRev[idxRev] = nt.ModExp(psi, &i, &Q)\n\t\tnttParams.PsiInvRev[idxRev] = nt.ModExp(psiInv, &i, &Q)\n\t}\n\n\t// compute the montgomery rep of psi and psiInv\n\tnttParams.PsiRevMont = make([]*big.Int, N)\n\tnttParams.PsiInvRevMont = make([]*big.Int, N)\n\n\tQbitlen := int64(Q.BitLen() + 5)\n\tR := nt.ModExp(nt.FromInt64(2), nt.FromInt64(Qbitlen), &Q)\n\n\tfor k = 0; k < N; k++ {\n\t\tnttParams.PsiRevMont[k] = nt.ModMul(R, nttParams.PsiRev[k], &Q)\n\t\tnttParams.PsiInvRevMont[k] = nt.ModMul(R, nttParams.PsiInvRev[k], &Q)\n\t}\n\tnttParams.bitlength = uint64(Qbitlen)\n\t// computing qInv (montgomery reduction param)\n\tR = R.Lsh(nt.One, uint(Qbitlen))\n\tRInv := nt.ModInv(R, &Q)\n\tnttParams.qInv = nt.Div(nt.Sub(nt.Mul(R, RInv), nt.One), &Q)\n\n\treturn nttParams\n}", "func involuteTheta(\n\tr float64, // base radius\n\td float64, // involute radial distance\n) float64 {\n\tx := d / r\n\treturn math.Sqrt(x*x - 1)\n}", "func NewTransactionN(n int) *Transaction {\n\treturn &Transaction{Deltas: make([]Delta, 0, n), deltas: make(map[Delta]struct{}, n)}\n}", "func (neuralNet *NeuralNet) f(theta []float64) (sum float64) {\n\tneuralNet.setAllWeights(theta)\n\n\tneuralNet.doBackPropagation(neuralNet.getInputs(), neuralNet.guess)\n\n\tfor _, outputNeuron := range neuralNet.outputLayer.neurons {\n\t\t// fmt.Println(\"outputNeuron\", outputNeuron)\n\t\tsum += math.Pow(outputNeuron.delta, 2.0)\n\t}\n\treturn\n}", "func Nuttal(input VectorComplex) VectorComplex {\n\tvh := input.Copy()\n\ttheta := 2.0 * math.Pi / float64(len(vh)-1)\n\ta0 := complex(0.355768, 0.0)\n\ta1 := complex(0.487396, 0.0)\n\ta2 := complex(0.144232, 0.0)\n\ta3 := complex(0.012604, 0.0)\n\n\tfor i := 0; i < len(vh); i++ {\n\t\tx := complex(theta*float64(i), 0)\n\t\tvh[i] *= a0 - a1*cmplx.Cos(x) + a2*cmplx.Cos(2.0*x) + a3*cmplx.Cos(3.0*x)\n\t}\n\treturn vh\n}", "func pi(n int) float64 {\n\tvar x float64\n\tvar a = 1\n\tvar b = 1\n\tfor i := 0; i < n; i++ {\n\t\tx += float64(a) / float64(b)\n\t\ta *= -1\n\t\tb += 2\n\t}\n\treturn x * 4.0\n}", "func (v Vector) Set(n int, data float64) {\n\tv.data[n] = data\n}", "func zetaStatic(st, n int64, theta, initialSum float64) float64 {\n\tsum := initialSum\n\tfor i := st; i < n; i++ {\n\t\tsum += 1 / math.Pow(float64(i+1), theta)\n\t}\n\treturn sum\n}", "func (c *CSR) Set(m, n int, v float64) {\n\tc.matrix.Set(m, n, v)\n}", "func pi(n int32) float64 {\n\tf := 0.0\n\tfor k := int32(0); k <= n; k++ {\n\t\tf += term(k)\n\t}\n\treturn f\n}", "func (r *IncrementRand) Intn(n int) int {\n\tif n <= 0 {\n\t\tpanic(\"invalid argument to Intn\")\n\t}\n\n\tif n <= int(r.value) {\n\t\tr.value = 0\n\t}\n\n\tv := r.value\n\n\tr.value++\n\n\treturn int(v)\n}", "func NumTrees(n int) int {\n\t//fmt.Println(\"NumTrees\")\n\tdpt := make([]int, n+1) //dynamic programming table\n\tdpt[0], dpt[1] = 1, 1\n\tfor i := 2; i <= n; i++ {\n\t\tfor j := 1; j <= i; j++ {\n\t\t\tdpt[i] += dpt[j-1] * dpt[i-j]\n\t\t}\n\t}\n\treturn dpt[n]\n}", "func (o *ParamsReg) Init(nFeatures int) {\n\to.theta = la.NewVector(nFeatures)\n\to.bkpTheta = la.NewVector(nFeatures)\n}", "func (cpu *CPU) set_N(i uint16) {\r\n\tcpu.regs[2] = (cpu.regs[2] & 0xfb) | ((i & 1) << 2)\r\n}", "func (c *CSC) Set(m, n int, v float64) {\n\tc.matrix.Set(n, m, v)\n}", "func (g *GeneratorJakes) GenerateN(tstart, tinterval float64, N int) []complex128 {\n\tg.tInterval = tinterval\n\tresult := make([]complex128, N)\n\tt := tstart\n\tfor i, _ := range result {\n\t\tresult[i] = g.generate(t)\n\t\tt += tinterval\n\t}\n\treturn result\n}", "func (this *NurbsCurve) nonRationalPointGivenN(n int, u float64) HomoPoint {\n\tdegree := this.degree\n\tcontrolPoints := this.controlPoints\n\tknots := this.knots\n\n\tif !areValidRelations(degree, len(controlPoints), len(knots)) {\n\t\tpanic(\"Invalid relations between control points, knot Array, and n\")\n\t}\n\n\tknotSpanIndex := knots.SpanGivenN(n, degree, u)\n\tbasisValues := BasisFunctionsGivenKnotSpanIndex(knotSpanIndex, u, degree, knots)\n\tvar position HomoPoint\n\n\tfor j := 0; j <= degree; j++ {\n\t\tscaled := controlPoints[knotSpanIndex-degree+j]\n\t\tscaled.Scale(basisValues[j])\n\t\tposition.Add(&scaled)\n\t}\n\n\treturn position\n}", "func geometricProgression(a, r, n int) int {\n\treturn a*r ^ (n - 1)\n}", "func (g *gaugeMetric) Set(n float64) {\n\tatomic.StoreUint64(&g.value, toUint64(n, 2))\n}", "func (r *ConstantRand) Intn(n int) int {\n\tif n <= 0 {\n\t\tpanic(\"invalid argument to Intn\")\n\t}\n\n\tif int(r.seed) > n-1 {\n\t\treturn n\n\t}\n\n\treturn int(r.seed)\n}", "func NilakanthaPiTerms(n int) float64 {\n\n\tpi := 3.\n\tfor i := 1; i <= n; i++ {\n\t\tsignal := 1.\n\t\tif i%2 == 0 {\n\t\t\tsignal = -1.\n\t\t}\n\n\t\t// 2*3*4, 4*5*6, 6*7*8, 8*9*10 ...\n\t\tdivisor := (i * 2) * (i*2 + 1) * (i*2 + 2)\n\n\t\t// 4/(2*3*4), -4/(4*5*6), 4/(6*7*8), -4/(8*9*10) ...\n\t\tterm := 4. / (signal * float64(divisor))\n\n\t\tpi = pi + term\n\t}\n\n\treturn pi\n}", "func (self *State)Tan(a any)any{\n self.IncOperations(self.coeff[\"tan\"]+self.off[\"tan\"])\n return wrap1(a,math.Tan)\n}", "func Hann(x float64, n int) float64 {\n\treturn 0.5 - 0.5*math.Cos(2*x*math.Pi/float64(n))\n}", "func numTrees(n int) int {\n\tarray := make([]int, n+2)\n\tarray[0] = 1\n\tarray[1] = 1\n\n\tfor i := 2; i <= n; i++ {\n\t\tfor j := 0; j < i; j++ {\n\t\t\tarray[i] += array[j] * array[i-j-1]\n\t\t}\n\t}\n\n\treturn array[n]\n}", "func Intn(n int) int { return globalRand.Intn(n) }", "func Intn(n int) int { return globalRand.Intn(n) }", "func Intn(n int) int { return globalRand.Intn(n) }", "func updateN(n int, b *testing.B) {\n\tb.StopTimer()\n\tw := benchWorld()\n\tp := benchPlayer()\n\n\tvar bds boids\n\tboidVal := bds.Generate(rand.New(rand.NewSource(rand.Int63())), n)\n\tbds = boidVal.Interface().(boids)\n\tb.StartTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tUpdateBoids(uint(i), bds, p, w)\n\t}\n}", "func (cc *ConstructionCreate) SetY(i int) *ConstructionCreate {\n\tcc.mutation.SetY(i)\n\treturn cc\n}", "func setY(n int16) {\n\tyDirection = byte(0x02)\n\tif n < 0 {\n\t\tyDirection = forward\n\t} else if n > 0 {\n\t\tyDirection = backward\n\t}\n}", "func (p *ProcStat) setN(data int) {\n\tif data&BIT_7 == BIT_7 {\n\t\tp.n = 1\n\t} else {\n\t\tp.n = 0\n\t}\n}", "func Pentagonal(n int) int{\r\n\treturn n*((3*n)-1)/2\r\n}", "func (d *Device1Receiver) SetN(n int) {\n\td.n = n\n}", "func RandomN(n int16) int16 {\n\treturn int16(rand.Int63n(int64(n)))\n}", "func (p Perceptron) init() {\n\trand.Seed(time.Now().UnixNano())\n\tfor k := range p {\n\t\tp[k] = rand.Float64() - float64(rand.Intn(1))\n\t}\n}", "func pi(n int) float64 {\n\tch := make(chan float64)\n\tfor k := 0; k <= n; k++ {\n\t\tgo term(ch, float64(k))\n\t}\n\tf := 0.0\n\tfor k := 0; k <= n; k++ {\n\t\tf += <-ch\n\t}\n\treturn f\n}", "func involuteXY(\n\tr float64, // base radius\n\ttheta float64, // involute angle\n) v2.Vec {\n\tc := math.Cos(theta)\n\ts := math.Sin(theta)\n\treturn v2.Vec{\n\t\tr * (c + theta*s),\n\t\tr * (s - theta*c),\n\t}\n}", "func NewKingGeneratorN(n int) *KingGenerator {\n\trows, cols := estimateRowsCols(n)\n\treturn &KingGenerator{\n\t\trows: rows,\n\t\tcols: cols,\n\t}\n}", "func (r *Rand) Intn(n int) int {\n\tif x, err := r.cryptoRand.Intn(n); err == nil {\n\t\treturn x\n\t}\n\treturn r.mathRand.Intn(n)\n}", "func zeta(st, n int64, theta, initialSum float64) (int64, float64) {\n\tcountForzata := n\n\treturn countForzata, zetaStatic(st, n, theta, initialSum)\n}", "func GenerateBeaverTriplet(N *big.Int) [3]*big.Int {\n\tvar triplet [3]*big.Int\n\n\tx, y := getRandom(N), getRandom(N)\n\n\tif mr.Intn(2) > 0 {\n\t\t// u = x, v = y, w = xy mod N\n\t\tw := new(big.Int).Mul(x, y)\n\t\ttriplet[0] = w.Mod(w, N)\n\t\ttriplet[1] = x\n\t\ttriplet[2] = y\n\t} else {\n\t\t// v = x, w = y, u = (xy^-1)^-1 mod N\n\t\tu := new(big.Int).Mul(x, new(big.Int).ModInverse(y, N))\n\t\ttriplet[0] = y\n\t\ttriplet[1] = x\n\t\ttriplet[2] = u.ModInverse(u, N)\n\t}\n\n\treturn triplet\n}", "func (m *SettlementMutation) SetY(i int) {\n\tm.y = &i\n\tm.addy = nil\n}", "func init() {\n\txBacking := tensor.Random(Float, N*feats)\n\twBacking := tensor.Random(Float, feats)\n\tvar yBacking interface{}\n\tswitch Float {\n\tcase tensor.Float64:\n\t\tbacking := make([]float64, N)\n\t\tfor i := range backing {\n\t\t\tbacking[i] = float64(rand.Intn(2))\n\t\t}\n\t\tyBacking = backing\n\tcase tensor.Float32:\n\t\tbacking := make([]float32, N)\n\t\tfor i := range backing {\n\t\t\tbacking[i] = float32(rand.Intn(2))\n\t\t}\n\t\tyBacking = backing\n\t}\n\n\txT = tensor.New(tensor.WithBacking(xBacking), tensor.WithShape(N, feats))\n\tyT = tensor.New(tensor.WithBacking(yBacking), tensor.WithShape(N))\n\twT = tensor.New(tensor.WithBacking(wBacking), tensor.WithShape(feats))\n}", "func Totient(n int) int {\n\tphi := 1\n\tfor p, k := range Factor(n) {\n\t\tphi *= PowInt(p, k-1) * (p - 1)\n\t}\n\n\treturn phi\n}", "func (n Nodes) SetIndex(i int, node *Node)", "func tripleGenerator(k int, x uint16) (int, uint32, uint32) {\n\tl, _, _ := intermediateSymbols(k)\n\tlprime := smallestPrimeGreaterOrEqual(l)\n\tq := uint32(65521) // largest prime < 2^16\n\tjk := uint32(systematicIndextable[k])\n\n\ta := uint32((53591 + (uint64(jk) * 997)) % uint64(q))\n\tb := (10267 * (jk + 1)) % q\n\ty := uint32((uint64(b) + (uint64(x) * uint64(a))) % uint64(q))\n\tv := raptorRand(y, 0, 1048576) // 1048576 == 2^20\n\td := deg(v)\n\ta = 1 + raptorRand(y, 1, uint32(lprime-1))\n\tb = raptorRand(y, 2, uint32(lprime))\n\n\treturn d, a, b\n}", "func (z *Int) Rand(rnd *rand.Rand, n *Int) *Int {}", "func (o *Bspline) recursiveN(t float64, i int, p int) float64 {\n\tif math.Abs(t-o.tmax) < 1e-14 {\n\t\tt = o.tmax - 1e-14 // remove noise. e.g. 1.000000000000002\n\t}\n\tif p == 0 {\n\t\tif t < o.T[i] {\n\t\t\treturn 0.0\n\t\t}\n\t\tif t < o.T[i+1] {\n\t\t\treturn 1.0\n\t\t}\n\t\treturn 0.0\n\t}\n\td1 := o.T[i+p] - o.T[i]\n\td2 := o.T[i+p+1] - o.T[i+1]\n\tvar N1, N2 float64\n\tif math.Abs(d1) < 1e-14 {\n\t\tN1, d1 = 0.0, 1.0\n\t} else {\n\t\tN1 = o.recursiveN(t, i, p-1)\n\t}\n\tif math.Abs(d2) < 1e-14 {\n\t\tN2, d2 = 0.0, 1.0\n\t} else {\n\t\tN2 = o.recursiveN(t, i+1, p-1)\n\t}\n\treturn (t-o.T[i])*N1/d1 + (o.T[i+p+1]-t)*N2/d2\n}", "func (a Ant) Paso() {\n //Primero calculamos el valor aleatorio q\n q := a.random.Float64()\n //Calculamos el valor RN poara todos los vertices \n rnvalues := a.GetVertexesRNValue() \n //sumrnValues nos rive para guardar la suma de los valores rn de todos los vertices\n sumrnValues := 0.0\n //maxrnvalue nos srive para guardar el valor maximo de los valores rn\n maxrnValue := 0.0\n //indexmasrnValue nos sirve para guardar el indice del vertice con el valor rn maximo\n indexmaxrnValue := -1 \n count := 0;\n //Dentro de este ciclo calculamos sumrnValues, maxrnValue y indexmaxrnValue\n for count < len(rnvalues) {\n //fmt.Printf(\"IndexV: %d RN: %f\\n\", count, rnvalues[count])\n if maxrnValue <= rnvalues[count] {\n maxrnValue = rnvalues[count]\n indexmaxrnValue = count\n }\n sumrnValues = sumrnValues + rnvalues[count]\n count = count+1\n } \n\n\n //Si el q es menor al valor dado q0 entonces vamos a agregar a la solucion el vertice con indice indexmaxrnValue\n //Actualzamos la feromona de manera local para el mismo vertice, y por ulitmo para ese vertice aremos a todas\n //Las aristas que inciden en el con valor 0\n if q < a.q0{\n //fmt.Printf(\"Feromona antes: %f\\n\", (*(*a.graph).vertexes)[indexmaxrnValue].pheromone)\n a.AgregaASolucion(indexmaxrnValue)\n a.ActualizaFeromonaLocalmente(indexmaxrnValue)\n (*a.graph).FullEdgesTo0ForVertex(indexmaxrnValue)\n //fmt.Printf(\"Se agrego %d\\n\", indexmaxrnValue)\n //fmt.Printf(\"Feromona Despues: %f\\n\", (*(*a.graph).vertexes)[indexmaxrnValue].pheromone)\n //a.PrintSolution()\n\n //Si q no es menor al valor dado q0\n }else{\n //Mientras que no da un paso la hormiga haremos lo sigueinte\n dioPaso := false\n for dioPaso != true{\n //Calculamos un indice de los vertices de manera aleatoria\n randomIndex := rand.Intn(len(rnvalues))\n //Calcualmos la probabilidad (como en el pdf) que la hormiga de un paso a este vertice\n indexProb := (rnvalues[randomIndex]/sumrnValues)\n //Calculamos otro numero aletaorioa entre 0 y 1\n randonNumber := a.random.Float64()\n //fmt.Printf(\"Random Index: %d indexProb: %f RandomNumber: %f\\n\", randomIndex, indexProb, randonNumber)\n //Si el numeor aleatorio calculado es menor o igual a la probabilidad de que la hormiga diera el paso a ese vertice\n //Entonces damos el paso a ese vertice\n //Vamos a agregar a la solucion el vertice con indice randomIndex\n //Actualzamos la feromona de manera local para el mismo vertice, y por ulitmo para ese vertice aremos a todas\n //Las aristas que inciden en el con valor 0\n if randonNumber <= indexProb{\n a.AgregaASolucion(randomIndex)\n a.ActualizaFeromonaLocalmente(randomIndex)\n (*a.graph).FullEdgesTo0ForVertex(randomIndex)\n //fmt.Printf(\"Se agrego %d\\n\", randomIndex)\n //Si damos el paso entonces hacemos este fvalor true de tal manera que esta fucnion se detendra\n dioPaso = true\n }\n }\n }\n //fmt.Printf(\"%f\\n\", q)\n //fmt.Printf(\"%t q=%f < %f=q0\\n\", q < a.q0, q, a.q0)\n}", "func testSetN(n int, hm HashMaper) {\n\tfor i := 0; i < n; i++ {\n\t\thm.Set(Key(i), i)\n\t}\n}", "func (ps *PrjnStru) SetNIdxSt(n *[]int32, avgmax *minmax.AvgMax32, idxst *[]int32, tn *etensor.Int32) int32 {\n\tln := tn.Len()\n\ttnv := tn.Values\n\t*n = make([]int32, ln)\n\t*idxst = make([]int32, ln)\n\tidx := int32(0)\n\tavgmax.Init()\n\tfor i := 0; i < ln; i++ {\n\t\tnv := tnv[i]\n\t\t(*n)[i] = nv\n\t\t(*idxst)[i] = idx\n\t\tidx += nv\n\t\tavgmax.UpdateVal(float32(nv), int32(i))\n\t}\n\tavgmax.CalcAvg()\n\treturn idx\n}", "func likelihood(pi float64, x int, n int) float64 {\n\treturn math.Pow(pi, float64(x)) * math.Pow(1 - pi, float64(n - x))\n}", "func (ch Channel_v2) radialIntegrate(n int32, xy Channel_v2, m Channel_f32, dt float32) {\n\tfor i := int32(0); i < n; i++ {\n\t\tnormal := [2]float32{0, 0}\n\t\tp := xy[i]\n\n\t\tif p[0] != 0 || p[1] != 0 {\n\t\t\tnormalize(p[0], p[1], &normal)\n\t\t}\n\n\t\tch[i][0] += m[i] * normal[0] * dt\n\t\tch[i][1] += m[i] * normal[1] * dt\n\t}\n}", "func numTrees(n int) int {\n\tdp := make([]int, n+1)\n\tdp[0], dp[1] = 1, 1\n\tfor i := 2; i <= n; i++ {\n\t\tfor j := 0; j <= (i-1)/2; j++ {\n\t\t\tif j == i-1-j {\n\t\t\t\tdp[i] += dp[j] * dp[j]\n\t\t\t} else {\n\t\t\t\tdp[i] += 2 * dp[j] * dp[i-1-j]\n\t\t\t}\n\t\t}\n\t}\n\treturn dp[n]\n}", "func Weights(n int, randomness int64) []int {\n\tperm := Permutation(n, randomness)\n\tweights := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tnewIndex := perm[i]\n\t\tweights[i] = newIndex + 1\n\t}\n\treturn weights\n}", "func (uni *Uniform3fv) Set(idx int, v0, v1, v2 float32) {\n\n\tpos := idx * 3\n\tuni.v[pos] = v0\n\tuni.v[pos+1] = v1\n\tuni.v[pos+2] = v2\n}", "func (p *Int64) SetCoeff(n uint64, a int64) {\n\tif n > p.Degree {\n\t\tp.Degree = n\n\t}\n\tp.c[n] = a\n}", "func randDegree() float64 {\n return rand.Float64() * 360.0\n }", "func (self *State)Tanh(a any)any{\n self.IncOperations(self.coeff[\"tanh\"]+self.off[\"tanh\"])\n return wrap1(a,math.Tanh)\n}", "func (StudentsT) NumParameters() int {\n\treturn 3\n}", "func (skeleton *Skeleton) SetTorsoMinimumNumberNodes(value float32) {\n\n\tC.setObjParamFloat((C.gpointer)(skeleton.skeleton), C.CString(\"torso-minimum-number-nodes\"), C.float(value))\n}", "func RandomN(n uint16) uint16 {\n\treturn uint16(rand.Int63n(int64(n)))\n}", "func temp(i int) float64 { return temp0 * math.Exp(-k*float64(i)/n) }", "func (n *TemperatureSensorNtcConf) initialize() {\n\tn.t0 = float64(n.TC0) + kelvinOffset\n\tif n.B <= 0 {\n\t\t//B=[ln(R0)-ln(R1)]/(1/T0-1/T1)\n\t\tT1 := float64(n.TC1) + kelvinOffset\n\t\tn.B = (1/n.t0 - 1/T1)\n\t\tn.B = (math.Log(n.R0) - math.Log(n.R1)) / n.B // 2000K...5000K\n\t}\n\tn.r = n.B / n.t0\n}", "func (ch Channel_v2) tangentIntegrate(n int32, xy Channel_v2, m Channel_f32, dt float32) {\n\tfor i := int32(0); i < n; i++ {\n\t\ttangent := [2]float32{0, 0}\n\t\tp := xy[i]\n\n\t\tif p[0] != 0 || p[1] != 0 {\n\t\t\tnormalize(p[1], p[0], &tangent)\n\t\t}\n\n\t\tch[i][0] += m[i] * tangent[0] * dt\n\t\tch[i][1] += m[i] * tangent[1] * dt\n\t}\n}", "func (s *Simulator) PointN() int {\n\treturn int(s.PointsPerSeries) * s.SeriesN()\n}", "func (r *randomGraph) Generate(n int) ([]*triple.Triple, error) {\n\tmaxEdges := r.nodes * r.nodes\n\tif n > maxEdges {\n\t\treturn nil, fmt.Errorf(\"current configuration only allow a max of %d triples (%d requested)\", maxEdges, n)\n\t}\n\tvar trpls []*triple.Triple\n\tfor _, idx := range rand.Perm(maxEdges)[:n] {\n\t\ti, j := idx/r.nodes, idx%r.nodes\n\t\tt, err := r.newTriple(i, j)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttrpls = append(trpls, t)\n\t}\n\treturn trpls, nil\n}", "func randset(arr []T, n int) {\n\n}", "func NewGoldenTraceN(n int) *GoldenTrace {\n\tg := &GoldenTrace{\n\t\tValues: make([]Digest, n, n),\n\t\tParams_: make(map[string]string),\n\t}\n\tfor i, _ := range g.Values {\n\t\tg.Values[i] = MISSING_DIGEST\n\t}\n\treturn g\n}", "func NewParameters(bitlen int) *Parameters {\n\tm, err := rand.Prime(rand.Reader, bitlen)\n\tif err != nil {\n\t\tpanic(\"Could not generate randon prime\")\n\t}\n\tn := 3\n\treturn &Parameters{\n\t\tn: n,\n\t\tM: m,\n\t\ttriplet: GenerateBeaverTriplet(m),\n\t\tassinc: mr.Intn(n),\n\t}\n}", "func New(n, k int) *Tree {\n\tvar t *Tree\n\tfor _, v := range rand.Perm(n) {\n\t\tt = insert(t, (1+v)*k)\n\t}\n\treturn t\n}", "func (m *MonteCarloSimulation) Simulate(N int, alpha float64) *Estimate {\n\t// We require at least one trial\n\tif N <= 1 {\n\t\tpanic(\"N must be greater than 1\")\n\t}\n\n\t// Run all trials, storing the results in ys and the controls in xs\n\tys := make([]float64, N)\n\txs := make([][]float64, N)\n\tfor i, _ := range ys {\n\t\tys[i], xs[i] = m.F()\n\t}\n\n\td := len(xs[0])\n\t// If there are no control variates, just do standard Monte Carlo\n\tif d == 0 {\n\t\treturn create_estimate(ys, alpha)\n\t}\n\n\t// Otherwise return an estimate based off the control variates\n\treturn control_estimate(ys, xs, alpha)\n}", "func (c *core) N() int {\n\treturn ((c.Curve.Params().P.BitLen()+1)/2 + 7) / 8\n}", "func (ch channel_v2) radialIntegrate(n int32, xy channel_v2, m channel_f32, dt float32) {\n\tfor i := int32(0); i < n; i++ {\n\t\tnormal := [2]float32{0, 0}\n\t\tp := xy[i]\n\n\t\tif p[0] != 0 || p[1] != 0 {\n\t\t\tnormalize(p[0], p[1], &normal)\n\t\t}\n\n\t\tch[i][0] += m[i] * normal[0] * dt\n\t\tch[i][1] += m[i] * normal[1] * dt\n\t}\n}", "func Perm(n int) []int { return globalRand.Perm(n) }", "func Perm(n int) []int { return globalRand.Perm(n) }", "func (e *Exponential) setParameters(p []Parameter) {\n\tif len(p) != e.NumParameters() {\n\t\tpanic(\"exponential: incorrect number of parameters to set\")\n\t}\n\tif p[0].Name != \"Rate\" {\n\t\tpanic(\"exponential: \" + panicNameMismatch)\n\t}\n\te.Rate = p[0].Value\n}", "func Perm(n int) []float64 {\n\tm := make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tj := rand.Intn(i + 1)\n\t\tm[i] = m[j]\n\t\tm[j] = float64(i)\n\t}\n\treturn m\n}", "func (n *Nonce) Set(val int64) {\n\tn.mtx.Lock()\n\tn.n = val\n\tn.mtx.Unlock()\n}", "func random(cluster,n int) []int {\n\treturn rand.Perm(cluster)[:n]\n}", "func (ch channel_v2) tangentIntegrate(n int32, xy channel_v2, m channel_f32, dt float32) {\n\tfor i := int32(0); i < n; i++ {\n\t\ttangent := [2]float32{0, 0}\n\t\tp := xy[i]\n\n\t\tif p[0] != 0 || p[1] != 0 {\n\t\t\tnormalize(p[1], p[0], &tangent)\n\t\t}\n\n\t\tch[i][0] += m[i] * tangent[0] * dt\n\t\tch[i][1] += m[i] * tangent[1] * dt\n\t}\n}", "func (ant *Ant) NextN(steps int) (cell *Cell, err error) {\n\tif steps < 0 {\n\t\tpanic(\"steps must be >= 0\")\n\t}\n\tif steps == 0 {\n\t\treturn ant.Position, nil\n\t}\n\tfor i := 0; i < steps; i++ {\n\t\tcell, err = ant.Next()\n\t\tif err != nil {\n\t\t\treturn cell, err\n\t\t}\n\t}\n\treturn cell, err\n}", "func coef(n int, t, y []Num) ([]Num, []Num) {\r\n\tsize := n + 1\r\n\ta := make([]Num, size)\r\n\th := make([]Num, size)\r\n\r\n\tfor i := 1; i <= n; i++ {\r\n\t\th[i] = t[i] - t[i-1]\r\n\t}\r\n\r\n\th[0] = h[1]\r\n\th[size] = h[n]\r\n\r\n\tdel := Num(-1)\r\n\tgam := 2 * y[0]\r\n\tp := del * gam\r\n\tq := Num(2)\r\n\r\n\tfor i := 0; i < n; i++ {\r\n\t\tr := h[i+1] / h[i]\r\n\t\tdel = Num(-1) * r * del\r\n\t\tgam = Num(-1)*gam + (r+1)*y[i]\r\n\t\tp = p + gam*del\r\n\t\tq = q + del*del\r\n\t}\r\n\r\n\ta[0] = (Num(-1) * p) / q\r\n\r\n\tfor i := 1; i < size; i++ {\r\n\t\ta[i] = ((h[i-1]+h[i])*y[i-1] - h[i]*a[i-1]) / h[i-1]\r\n\r\n\t}\r\n\r\n\treturn a[:], h[:]\r\n}", "func Examen(H []Estudiante) {\n\n for i := 0; i < N; i++ {\n r := H[i].Renta / (Rmin+Ce)\n if r>2 {\n r = 2\n } \n k := 1 + (rand.Float64()-0.5) / 5 * 2 + (r-1) * 0.1\n\t\tH[i].Nota *= k\n// fmt.Println(\"factor nota\",k, H[i].Nota)\t\t\t\n\t\n\t\tif H[i].Nota<0 {\n\t\t H[i].Nota = 0\n\t\t} else if H[i].Nota > 10 {\n\t\t H[i].Nota = 10\n\t\t}\n\t}\n}", "func (vn *VecN) Set(i int, val float64) {\n\tvn.vec[i] = val\n}", "func newNCO(w float64, n int) []complex128 {\n\tnco := make([]complex128, n)\n\tfor i := range nco {\n\t\tnco[i] = complex128(cmplx.Exp(complex(0, 2*math.Pi*w*float64(i))))\n\t}\n\treturn nco\n}", "func (uni *UniformMatrix3f) Set(pos int, v float32) {\n\n\tuni.v[pos] = v\n}", "func Intn(n int) int {\n\treturn globalRand.Intn(n)\n}", "func (r *Registers) setFlagN(bit bool) {\n\tif bit {\n\t\tr.F |= negativeFlag\n\t} else {\n\t\tr.F = r.F &^ negativeFlag\n\t}\n}", "func (l *Libvirt) DomainSetNumaParameters(Dom Domain, Params []TypedParam, Flags uint32) (err error) {\n\tvar buf []byte\n\n\targs := DomainSetNumaParametersArgs {\n\t\tDom: Dom,\n\t\tParams: Params,\n\t\tFlags: Flags,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\n\t_, err = l.requestStream(254, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func setup(f func(int) Grapher, n int) (graph Grapher) {\n\tgraph = f(n)\n\trandom := rand.New(rand.NewSource(time.Now().UnixNano()))\n\tfor count := 0; count < n; {\n\t\ta := random.Intn(n)\n\t\tb := random.Intn(n)\n\t\tif !graph.HasEdge(a, b) {\n\t\t\tgraph.Add(a, b)\n\t\t\tcount++\n\t\t}\n\t}\n\treturn\n}", "func JNG(r operand.Op) { ctx.JNG(r) }", "func (b Bits) Set(n int) Bits {\n\treturn b | (1 << uint64(n))\n}", "func (this *NurbsCurve) insertKnot(u float64, r int) *NurbsCurve {\n\tdegree := this.degree\n\tcontrolPoints := this.controlPoints\n\tknots := this.knots\n\n\t// numPts is num control points for the initial curve\n\t// k is the span on which the knots are inserted\n\t// s is the initial multiplicity of the knot\n\t// r is the number of times to insert the knot\n\t// controlPoints is initial set of control points\n\n\ts := 0 // assume original multiplicity is 0 - TODO add check for multiplicity in knots\n\n\tnumPts := len(controlPoints)\n\tk := knots.Span(degree, u) // the span in which the knot will be inserted\n\tnumPtsPost := numPts + r // a new control pt for every new knot\n\tcontrolPointsTemp := make([]HomoPoint, degree-s) // new Array( degree - s )\n\tknotsPost := make(KnotVec, len(knots)+r) // new Array( knots.length + r ) // r new knots\n\tcontrolPointsPost := make([]HomoPoint, numPtsPost) // new Array( numPtsPost )\n\n\t// new knot vector\n\n\t// insert the k knots that will not be affected\n\tfor i := 1; i <= k; i++ {\n\t\tknotsPost[i] = knots[i]\n\t}\n\n\t// insert the new repeat knots\n\tfor i := 1; i <= r; i++ {\n\t\tknotsPost[k+i] = u\n\t}\n\n\t// insert the rest of the knots\n\tfor i := k + 1; i < len(knots); i++ {\n\t\tknotsPost[i+r] = knots[i]\n\t}\n\n\t// control point generation\n\n\t// copy the original control points before the insertion span\n\tfor i := 0; i <= k-degree; i++ {\n\t\tcontrolPointsPost[i] = controlPoints[i]\n\t}\n\n\t// copy the original controls after the insertion span\n\tfor i := k - s; i < numPts; i++ {\n\t\tcontrolPointsPost[i+r] = controlPoints[i]\n\t}\n\n\t// collect the affected control points in this temporary array\n\tfor i := 0; i <= degree-s; i++ {\n\t\tcontrolPointsTemp[i] = controlPoints[k-degree+i]\n\t}\n\n\tvar L int\n\tvar alpha float64\n\n\t// insert knot r times\n\tfor j := 1; j <= r; j++ {\n\t\tL = k - degree + j\n\n\t\tfor i := 0; i <= degree-j-s; i++ {\n\t\t\talpha = (u - knots[L+i]) / (knots[i+k+1] - knots[L+i])\n\n\t\t\tcontrolPointsTemp[i] = HomoInterpolated(\n\t\t\t\t&controlPointsTemp[i],\n\t\t\t\t&controlPointsTemp[i+1],\n\t\t\t\talpha,\n\t\t\t)\n\t\t}\n\n\t\tcontrolPointsPost[L] = controlPointsTemp[0]\n\t\tcontrolPointsPost[k+r-j-s] = controlPointsTemp[degree-j-s]\n\n\t}\n\n\t// not so confident about this part\n\tfor i := L + 1; i < k-s; i++ {\n\t\tcontrolPointsPost[i] = controlPointsTemp[i-L]\n\t}\n\n\treturn &NurbsCurve{degree, controlPointsPost, knotsPost}\n}", "func CreateNumberSpiral(n int64) [][]int64 {\n\tif n%2 == 0 {\n\t\tn++\n\t}\n\n\t// Create our array in memory\n\tg := make([][]int64, n)\n\tfor i := range g {\n\t\tg[i] = make([]int64, n)\n\t}\n\n\t// Our starting point must be n/2, n/2\n\tr, c := int64(n/2), int64(n/2)\n\tg[r][c] = 1\n\tfor i := int64(1); true; i++ {\n\t\tif i%2 != 0 {\n\t\t\tvct := GetVector(r, c, i+1, \">\")\n\t\t\t// This is a get out for the last line of the spiral\n\t\t\tif !SafeVector(vct, n) {\n\t\t\t\tvct = GetVector(r, c, i, \">\")\n\t\t\t\tnumSpirIncrementVector(&g, vct)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tnumSpirIncrementVector(&g, vct)\n\t\t\tnumSpirSetRowCol(&r, &c, &vct)\n\n\t\t\tvct = GetVector(r, c, i+1, \"v\")\n\t\t\tnumSpirIncrementVector(&g, vct)\n\t\t\tnumSpirSetRowCol(&r, &c, &vct)\n\t\t} else {\n\t\t\tvct := GetVector(r, c, i+1, \"<\")\n\t\t\tnumSpirIncrementVector(&g, vct)\n\t\t\tnumSpirSetRowCol(&r, &c, &vct)\n\n\t\t\tvct = GetVector(r, c, i+1, \"^\")\n\t\t\tnumSpirIncrementVector(&g, vct)\n\t\t\tnumSpirSetRowCol(&r, &c, &vct)\n\t\t}\n\t}\n\n\treturn g\n}", "func stepPerms(n int32) int32 {\n\tif n < 3 {\n\t\treturn n\n\t}\n\n\ta, b, c, current := 1, 2, 4, 0\n\n\tfor i := int32(3); i < n; i++ {\n\t\tcurrent = a + b + c\n\t\ta, b = b, c\n\t\tc = current\n\t}\n\n\treturn int32(c)\n}", "func (cpu *Cpu) taxy(r int) {\n\tswitch r {\n\tcase X:\n\t\tcpu.x = cpu.ac\n\t\tcpu.p.n = cpu.x\n\t\tcpu.p.z = cpu.x\n\n\tcase Y:\n\t\tcpu.y = cpu.ac\n\t\tcpu.p.n = cpu.y\n\t\tcpu.p.z = cpu.y\n\t}\n}", "func (Binomial) NumParameters() int {\n\treturn 2\n}" ]
[ "0.570201", "0.5282836", "0.51394093", "0.5008743", "0.48968518", "0.48002815", "0.46859342", "0.4647159", "0.46215564", "0.45934406", "0.45926017", "0.45582205", "0.45221698", "0.4500831", "0.44778112", "0.44498968", "0.4448061", "0.4424958", "0.44235697", "0.44030243", "0.4386226", "0.43816942", "0.43646747", "0.43564188", "0.43525204", "0.4334907", "0.43320078", "0.43320078", "0.43320078", "0.43305057", "0.43232945", "0.4315278", "0.4292514", "0.42880884", "0.42724064", "0.42591527", "0.42562738", "0.42535836", "0.42507994", "0.42387924", "0.4227876", "0.42274913", "0.42264894", "0.42239094", "0.42077228", "0.42037797", "0.41953427", "0.41933107", "0.41769513", "0.41764215", "0.41676122", "0.41625345", "0.41606385", "0.41540962", "0.41504398", "0.41477045", "0.41438696", "0.4143307", "0.4141011", "0.41387329", "0.41339934", "0.41243115", "0.4123455", "0.41192278", "0.41185516", "0.4097465", "0.40897286", "0.4085297", "0.408377", "0.40760663", "0.40651548", "0.4063584", "0.40625128", "0.40625077", "0.40544727", "0.40514502", "0.4049828", "0.4049828", "0.40435168", "0.40408793", "0.40361285", "0.40242475", "0.4023364", "0.40176797", "0.40135264", "0.40113655", "0.4010219", "0.40060404", "0.39979428", "0.3993146", "0.39880902", "0.39832088", "0.39821628", "0.3979121", "0.39781314", "0.39772192", "0.3968873", "0.39656353", "0.39583835", "0.39471403" ]
0.58603626
0
Get n and theta
func (tpe *TPE) GetConfig() (n int, theta float64) { return tpe.setup.N, tpe.setup.Theta }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func involuteTheta(\n\tr float64, // base radius\n\td float64, // involute radial distance\n) float64 {\n\tx := d / r\n\treturn math.Sqrt(x*x - 1)\n}", "func coef(n int, t, y []Num) ([]Num, []Num) {\r\n\tsize := n + 1\r\n\ta := make([]Num, size)\r\n\th := make([]Num, size)\r\n\r\n\tfor i := 1; i <= n; i++ {\r\n\t\th[i] = t[i] - t[i-1]\r\n\t}\r\n\r\n\th[0] = h[1]\r\n\th[size] = h[n]\r\n\r\n\tdel := Num(-1)\r\n\tgam := 2 * y[0]\r\n\tp := del * gam\r\n\tq := Num(2)\r\n\r\n\tfor i := 0; i < n; i++ {\r\n\t\tr := h[i+1] / h[i]\r\n\t\tdel = Num(-1) * r * del\r\n\t\tgam = Num(-1)*gam + (r+1)*y[i]\r\n\t\tp = p + gam*del\r\n\t\tq = q + del*del\r\n\t}\r\n\r\n\ta[0] = (Num(-1) * p) / q\r\n\r\n\tfor i := 1; i < size; i++ {\r\n\t\ta[i] = ((h[i-1]+h[i])*y[i-1] - h[i]*a[i-1]) / h[i-1]\r\n\r\n\t}\r\n\r\n\treturn a[:], h[:]\r\n}", "func geometricProgression(a, r, n int) int {\n\treturn a*r ^ (n - 1)\n}", "func (ds DataSet) GetTheta() [][][]float64 {\n\tth := make([][][]float64, len(ds.NN.Thetas))\n\tfor i, theta := range ds.NN.Thetas {\n\t\trows, _ := theta.Dims()\n\t\tth[i] = make([][]float64, rows)\n\t\tfor j := 0; j < rows; j++ {\n\t\t\tvar dst []float64\n\t\t\tth[i][j] = theta.Row(dst, j)\n\t\t}\n\t}\n\n\treturn th\n}", "func pi(n int) float64 {\n\tvar x float64\n\tvar a = 1\n\tvar b = 1\n\tfor i := 0; i < n; i++ {\n\t\tx += float64(a) / float64(b)\n\t\ta *= -1\n\t\tb += 2\n\t}\n\treturn x * 4.0\n}", "func GenParams(N int64, Q nt.Integer) *NTTParams {\n\t// setting up initial parameters\n\tvar nttParams = &NTTParams{\n\t\tn: N,\n\t\tnRev: nt.ModInv(nt.FromInt64(int64(N)), &Q).Uint64(),\n\t\tq: Q,\n\t}\n\t// computing Psi terms\n\tg := primitiveRoot(&Q)\n\tfi := nt.Sub(&Q, nt.One)\n\n\t// compute the 2-nth root of unity and its inverse\n\t// psi = g^(fi/2n) mod q\n\t// psiInv = psi^-1 mod q\n\ttwoN := nt.FromInt64(2 * N)\n\texp := nt.Div(fi, twoN)\n\tpsi := nt.ModExp(g, exp, &Q)\n\tpsiInv := nt.ModInv(psi, &Q)\n\t// compute the powers of psi and psiInv\n\tnttParams.PsiRev = make([]*nt.Integer, N)\n\tnttParams.PsiInvRev = make([]*nt.Integer, N)\n\tvar Nbitlen uint32\n\tfor i := 32 - 1; i >= 0; i-- {\n\t\tif N&(1<<uint(i)) != 0 {\n\t\t\tNbitlen = uint32(i)\n\t\t\tbreak\n\t\t}\n\t}\n\tvar idxRev uint32\n\tvar i nt.Integer\n\tvar k int64\n\tfor k = 0; k < N; k++ {\n\t\ti.SetInt64(k)\n\t\tidxRev = bitRev(k, Nbitlen)\n\t\tnttParams.PsiRev[idxRev] = nt.ModExp(psi, &i, &Q)\n\t\tnttParams.PsiInvRev[idxRev] = nt.ModExp(psiInv, &i, &Q)\n\t}\n\n\t// compute the montgomery rep of psi and psiInv\n\tnttParams.PsiRevMont = make([]*big.Int, N)\n\tnttParams.PsiInvRevMont = make([]*big.Int, N)\n\n\tQbitlen := int64(Q.BitLen() + 5)\n\tR := nt.ModExp(nt.FromInt64(2), nt.FromInt64(Qbitlen), &Q)\n\n\tfor k = 0; k < N; k++ {\n\t\tnttParams.PsiRevMont[k] = nt.ModMul(R, nttParams.PsiRev[k], &Q)\n\t\tnttParams.PsiInvRevMont[k] = nt.ModMul(R, nttParams.PsiInvRev[k], &Q)\n\t}\n\tnttParams.bitlength = uint64(Qbitlen)\n\t// computing qInv (montgomery reduction param)\n\tR = R.Lsh(nt.One, uint(Qbitlen))\n\tRInv := nt.ModInv(R, &Q)\n\tnttParams.qInv = nt.Div(nt.Sub(nt.Mul(R, RInv), nt.One), &Q)\n\n\treturn nttParams\n}", "func getX(x, y, theta float64) float64 {\n\ttheta = theta * math.Pi / 180\n\treturn x*math.Cos(theta) - y*math.Sin(theta)\n}", "func pi(n int32) float64 {\n\tf := 0.0\n\tfor k := int32(0); k <= n; k++ {\n\t\tf += term(k)\n\t}\n\treturn f\n}", "func tripleGenerator(k int, x uint16) (int, uint32, uint32) {\n\tl, _, _ := intermediateSymbols(k)\n\tlprime := smallestPrimeGreaterOrEqual(l)\n\tq := uint32(65521) // largest prime < 2^16\n\tjk := uint32(systematicIndextable[k])\n\n\ta := uint32((53591 + (uint64(jk) * 997)) % uint64(q))\n\tb := (10267 * (jk + 1)) % q\n\ty := uint32((uint64(b) + (uint64(x) * uint64(a))) % uint64(q))\n\tv := raptorRand(y, 0, 1048576) // 1048576 == 2^20\n\td := deg(v)\n\ta = 1 + raptorRand(y, 1, uint32(lprime-1))\n\tb = raptorRand(y, 2, uint32(lprime))\n\n\treturn d, a, b\n}", "func (r Ray) Theta() float64 {\n\treturn math.Acos(r.Direction[2])\n}", "func Totient(n int) int {\n\tphi := 1\n\tfor p, k := range Factor(n) {\n\t\tphi *= PowInt(p, k-1) * (p - 1)\n\t}\n\n\treturn phi\n}", "func Nuttal(input VectorComplex) VectorComplex {\n\tvh := input.Copy()\n\ttheta := 2.0 * math.Pi / float64(len(vh)-1)\n\ta0 := complex(0.355768, 0.0)\n\ta1 := complex(0.487396, 0.0)\n\ta2 := complex(0.144232, 0.0)\n\ta3 := complex(0.012604, 0.0)\n\n\tfor i := 0; i < len(vh); i++ {\n\t\tx := complex(theta*float64(i), 0)\n\t\tvh[i] *= a0 - a1*cmplx.Cos(x) + a2*cmplx.Cos(2.0*x) + a3*cmplx.Cos(3.0*x)\n\t}\n\treturn vh\n}", "func zetaStatic(st, n int64, theta, initialSum float64) float64 {\n\tsum := initialSum\n\tfor i := st; i < n; i++ {\n\t\tsum += 1 / math.Pow(float64(i+1), theta)\n\t}\n\treturn sum\n}", "func temp(i int) float64 { return temp0 * math.Exp(-k*float64(i)/n) }", "func (neuralNet *NeuralNet) f(theta []float64) (sum float64) {\n\tneuralNet.setAllWeights(theta)\n\n\tneuralNet.doBackPropagation(neuralNet.getInputs(), neuralNet.guess)\n\n\tfor _, outputNeuron := range neuralNet.outputLayer.neurons {\n\t\t// fmt.Println(\"outputNeuron\", outputNeuron)\n\t\tsum += math.Pow(outputNeuron.delta, 2.0)\n\t}\n\treturn\n}", "func zeta(st, n int64, theta, initialSum float64) (int64, float64) {\n\tcountForzata := n\n\treturn countForzata, zetaStatic(st, n, theta, initialSum)\n}", "func tangent(p0, p1, p2, p3, q0, q1 Point) float64 {\n\tA := cprod(p0, p1, q0, q1)\n\tB := cprod(p1, p2, q0, q1)\n\tC := cprod(p2, p3, q0, q1)\n\n\ta := A - 2*B + C\n\tb := -2*A + 2*B\n\tc := A\n\n\td := b*b - 4*a*c\n\n\tif a == 0 || d < 0 {\n\t\treturn -1 // TODO: replace with error?\n\t}\n\ts := math.Sqrt(d)\n\n\tr1 := (-b + s) / (2 * a)\n\tr2 := (-b - s) / (2 * a)\n\n\tif r1 >= 0 && r1 <= 1 {\n\t\treturn r1\n\t} else if r2 >= 0 && r2 <= 1 {\n\t\treturn r2\n\t} else {\n\t\treturn -1\n\t}\n}", "func geometricProgressionSum(a int, r int, n int) int {\n\tS := int(math.Pow(float64(r), float64(n)))\n\treturn a * (1 - S) / (1 - r)\n}", "func (self *State)Tan(a any)any{\n self.IncOperations(self.coeff[\"tan\"]+self.off[\"tan\"])\n return wrap1(a,math.Tan)\n}", "func calculate(d float64) (float64, float64) {\n\t// hitung luas\n\tvar area = math.Pi * math.Pow(d / 2, 2)\n\t// hitung keliling\n\tvar circumference = math.Pi * d\n\t// kembalikan 2 nilai\n\treturn area, circumference\n}", "func getY(x, y, theta float64) float64 {\n\ttheta = theta * math.Pi / 180\n\treturn x*math.Sin(theta) + y*math.Cos(theta)\n}", "func Hann(x float64, n int) float64 {\n\treturn 0.5 - 0.5*math.Cos(2*x*math.Pi/float64(n))\n}", "func calculate(d float64) (float64, float64) {\n\t// hitung luas\n\tvar area = math.Pi * math.Pow(d/2, 2)\n\t// hitung keliling\n\tvar circumference = math.Pi * d\n\n\t// kembalikan 2 nilai\n\treturn area, circumference\n}", "func nd(n int) int {\n\tif n == 0 {\n\t\treturn 1\n\t}\n\treturn int(math.Log10(float64(n))) + 1\n}", "func Pentagonal(n int) int{\r\n\treturn n*((3*n)-1)/2\r\n}", "func NumTrees(n int) int {\n\t//fmt.Println(\"NumTrees\")\n\tdpt := make([]int, n+1) //dynamic programming table\n\tdpt[0], dpt[1] = 1, 1\n\tfor i := 2; i <= n; i++ {\n\t\tfor j := 1; j <= i; j++ {\n\t\t\tdpt[i] += dpt[j-1] * dpt[i-j]\n\t\t}\n\t}\n\treturn dpt[n]\n}", "func likelihood(pi float64, x int, n int) float64 {\n\treturn math.Pow(pi, float64(x)) * math.Pow(1 - pi, float64(n - x))\n}", "func (this *NurbsCurve) Tangent(u float64) vec3.T {\n\treturn this.Derivatives(u, 1)[1]\n}", "func pi(n int) float64 {\n\tch := make(chan float64)\n\tfor k := 0; k <= n; k++ {\n\t\tgo term(ch, float64(k))\n\t}\n\tf := 0.0\n\tfor k := 0; k <= n; k++ {\n\t\tf += <-ch\n\t}\n\treturn f\n}", "func numTrees(n int) int {\n\tarray := make([]int, n+2)\n\tarray[0] = 1\n\tarray[1] = 1\n\n\tfor i := 2; i <= n; i++ {\n\t\tfor j := 0; j < i; j++ {\n\t\t\tarray[i] += array[j] * array[i-j-1]\n\t\t}\n\t}\n\n\treturn array[n]\n}", "func (self *State)Tanh(a any)any{\n self.IncOperations(self.coeff[\"tanh\"]+self.off[\"tanh\"])\n return wrap1(a,math.Tanh)\n}", "func NilakanthaPiTerms(n int) float64 {\n\n\tpi := 3.\n\tfor i := 1; i <= n; i++ {\n\t\tsignal := 1.\n\t\tif i%2 == 0 {\n\t\t\tsignal = -1.\n\t\t}\n\n\t\t// 2*3*4, 4*5*6, 6*7*8, 8*9*10 ...\n\t\tdivisor := (i * 2) * (i*2 + 1) * (i*2 + 2)\n\n\t\t// 4/(2*3*4), -4/(4*5*6), 4/(6*7*8), -4/(8*9*10) ...\n\t\tterm := 4. / (signal * float64(divisor))\n\n\t\tpi = pi + term\n\t}\n\n\treturn pi\n}", "func t(i int) float64 {\n\treturn t_0 + *deltaT*float64(i)\n}", "func (d Decimal) Tan() Decimal {\n\n\tPI4A := NewFromFloat(7.85398125648498535156e-1) // 0x3fe921fb40000000, Pi/4 split into three parts\n\tPI4B := NewFromFloat(3.77489470793079817668e-8) // 0x3e64442d00000000,\n\tPI4C := NewFromFloat(2.69515142907905952645e-15) // 0x3ce8469898cc5170,\n\tM4PI := NewFromFloat(1.273239544735162542821171882678754627704620361328125) // 4/pi\n\n\tif d.Equal(NewFromFloat(0.0)) {\n\t\treturn d\n\t}\n\n\t// make argument positive but save the sign\n\tsign := false\n\tif d.LessThan(NewFromFloat(0.0)) {\n\t\td = d.Neg()\n\t\tsign = true\n\t}\n\n\tj := d.Mul(M4PI).IntPart() // integer part of x/(Pi/4), as integer for tests on the phase angle\n\ty := NewFromFloat(float64(j)) // integer part of x/(Pi/4), as float\n\n\t// map zeros to origin\n\tif j&1 == 1 {\n\t\tj++\n\t\ty = y.Add(NewFromFloat(1.0))\n\t}\n\n\tz := d.Sub(y.Mul(PI4A)).Sub(y.Mul(PI4B)).Sub(y.Mul(PI4C)) // Extended precision modular arithmetic\n\tzz := z.Mul(z)\n\n\tif zz.GreaterThan(NewFromFloat(1e-14)) {\n\t\tw := zz.Mul(_tanP[0].Mul(zz).Add(_tanP[1]).Mul(zz).Add(_tanP[2]))\n\t\tx := zz.Add(_tanQ[1]).Mul(zz).Add(_tanQ[2]).Mul(zz).Add(_tanQ[3]).Mul(zz).Add(_tanQ[4])\n\t\ty = z.Add(z.Mul(w.Div(x)))\n\t} else {\n\t\ty = z\n\t}\n\tif j&2 == 2 {\n\t\ty = NewFromFloat(-1.0).Div(y)\n\t}\n\tif sign {\n\t\ty = y.Neg()\n\t}\n\treturn y\n}", "func arithmeticProgression(a, n, d int) int {\n\treturn a + (n-1)*d\n}", "func series(n int) (x, y, xh []float64) {\n\tx = make([]float64, n)\n\ty = make([]float64, n)\n\txh = make([]float64, n)\n\tfor i := 0; i < n; i++ {\n\t\tx[i] = math.Sin(float64(i+1) * math.Sqrt2)\n\t\ty[i] = x[i]\n\t\txh[i] = x[i]\n\t}\n\treturn x, y, xh\n}", "func (r *AggloResult) Step(i int) (int, int, float64) {\n\treturn r.perm[i], r.pi[r.perm[i]], r.lambda[r.perm[i]]\n}", "func numTrees(n int) int {\n\tdp := make([]int, n+1)\n\tdp[0], dp[1] = 1, 1\n\tfor i := 2; i <= n; i++ {\n\t\tfor j := 0; j <= (i-1)/2; j++ {\n\t\t\tif j == i-1-j {\n\t\t\t\tdp[i] += dp[j] * dp[j]\n\t\t\t} else {\n\t\t\t\tdp[i] += 2 * dp[j] * dp[i-1-j]\n\t\t\t}\n\t\t}\n\t}\n\treturn dp[n]\n}", "func calProb(N,K float64) float64{\r\n return Factorial(N)/(Factorial(N-K)*math.Pow(N,K))\r\n}", "func (o *Bspline) recursiveN(t float64, i int, p int) float64 {\n\tif math.Abs(t-o.tmax) < 1e-14 {\n\t\tt = o.tmax - 1e-14 // remove noise. e.g. 1.000000000000002\n\t}\n\tif p == 0 {\n\t\tif t < o.T[i] {\n\t\t\treturn 0.0\n\t\t}\n\t\tif t < o.T[i+1] {\n\t\t\treturn 1.0\n\t\t}\n\t\treturn 0.0\n\t}\n\td1 := o.T[i+p] - o.T[i]\n\td2 := o.T[i+p+1] - o.T[i+1]\n\tvar N1, N2 float64\n\tif math.Abs(d1) < 1e-14 {\n\t\tN1, d1 = 0.0, 1.0\n\t} else {\n\t\tN1 = o.recursiveN(t, i, p-1)\n\t}\n\tif math.Abs(d2) < 1e-14 {\n\t\tN2, d2 = 0.0, 1.0\n\t} else {\n\t\tN2 = o.recursiveN(t, i+1, p-1)\n\t}\n\treturn (t-o.T[i])*N1/d1 + (o.T[i+p+1]-t)*N2/d2\n}", "func Tan(scope *Scope, x tf.Output) (y tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Tan\",\n\t\tInput: []tf.Input{\n\t\t\tx,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func involuteXY(\n\tr float64, // base radius\n\ttheta float64, // involute angle\n) v2.Vec {\n\tc := math.Cos(theta)\n\ts := math.Sin(theta)\n\treturn v2.Vec{\n\t\tr * (c + theta*s),\n\t\tr * (s - theta*c),\n\t}\n}", "func JNG(r operand.Op) { ctx.JNG(r) }", "func (ch Channel_v2) tangentIntegrate(n int32, xy Channel_v2, m Channel_f32, dt float32) {\n\tfor i := int32(0); i < n; i++ {\n\t\ttangent := [2]float32{0, 0}\n\t\tp := xy[i]\n\n\t\tif p[0] != 0 || p[1] != 0 {\n\t\t\tnormalize(p[1], p[0], &tangent)\n\t\t}\n\n\t\tch[i][0] += m[i] * tangent[0] * dt\n\t\tch[i][1] += m[i] * tangent[1] * dt\n\t}\n}", "func pythaTriplet(variable int) int{\n\n\tfor i:=1;i<variable;i++{\n\t\tfor j:=1;j<variable;j++{\n\t\t\tfor k:=1; k<variable;k++{\n\t\t\t\tif rightTriplet(variable,i,j,k){\n\t\t\t\t\tfmt.Println(i,j,k)\n\t\t\t\t\treturn i*j*k\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn -1\n}", "func (ant *Ant) getProbability() []float64 {\n\tp := make([]float64, 0)\n\tvar sum float64\n\tfor i, l := range ant.visited[ant.position] {\n\t\tif l != 0 {\n\t\t\td := math.Pow((float64(1)/float64(l)), ant.env.alpha) * math.Pow(ant.env.pheromon[ant.position][i], ant.env.betta)\n\t\t\tp = append(p, d)\n\t\t\tsum += d\n\t\t} else {\n\t\t\tp = append(p, 0)\n\t\t}\n\t}\n\tfor _, l := range p {\n\t\tl = l / sum\n\t}\n\treturn p\n}", "func (tpe *TPE) Setup(n int, theta float64) {\n\ttpe.setup.N = n\n\ttpe.setup.Theta = theta\n}", "func pointslope(pp *privPath, i, j int) (ctr, dir Point) {\n\t// assume i<j\n\n\tn := len(pp.Pt)\n\tsums := pp.Sums\n\tr := 0 // rotations from i to j\n\n\tfor j >= n {\n\t\tj -= n\n\t\tr++\n\t}\n\tfor i >= n {\n\t\ti -= n\n\t\tr--\n\t}\n\tfor j < 0 {\n\t\tj += n\n\t\tr--\n\t}\n\tfor i < 0 {\n\t\ti += n\n\t\tr++\n\t}\n\n\tx := float64(sums[j+1].x - sums[i].x + r*sums[n].x)\n\ty := float64(sums[j+1].y - sums[i].y + r*sums[n].y)\n\tx2 := float64(sums[j+1].x2 - sums[i].x2 + r*sums[n].x2)\n\txy := float64(sums[j+1].xy - sums[i].xy + r*sums[n].xy)\n\ty2 := float64(sums[j+1].y2 - sums[i].y2 + r*sums[n].y2)\n\tk := float64(j + 1 - i + r*n)\n\n\tctr.X = x / k\n\tctr.Y = y / k\n\n\ta := (x2 - x*x/k) / k\n\tb := (xy - x*y/k) / k\n\tc := (y2 - y*y/k) / k\n\n\tlambda2 := (a + c + math.Sqrt((a-c)*(a-c)+4*b*b)) / 2 // larger e.value\n\n\t// now find e.vector for lambda2\n\ta -= lambda2\n\tc -= lambda2\n\n\tvar l float64\n\tif fabs(a) >= fabs(c) {\n\t\tl = math.Sqrt(a*a + b*b)\n\t\tif l != 0 {\n\t\t\tdir.X = -b / l\n\t\t\tdir.Y = a / l\n\t\t}\n\t} else {\n\t\tl = math.Sqrt(c*c + b*b)\n\t\tif l != 0 {\n\t\t\tdir.X = -c / l\n\t\t\tdir.Y = b / l\n\t\t}\n\t}\n\tif l == 0 {\n\t\tdir.X, dir.Y = 0, 0 // sometimes this can happen when k=4: the two eigenvalues coincide\n\t}\n\treturn\n}", "func aritmetic_sereies_sum(a1, n, d int) int {\n // an = a1 + (n - 1)*d\n // Sn = n*(a1 + an)/2\n return n*a1 + n*(n - 1)*d/2\n}", "func (ch channel_v2) tangentIntegrate(n int32, xy channel_v2, m channel_f32, dt float32) {\n\tfor i := int32(0); i < n; i++ {\n\t\ttangent := [2]float32{0, 0}\n\t\tp := xy[i]\n\n\t\tif p[0] != 0 || p[1] != 0 {\n\t\t\tnormalize(p[1], p[0], &tangent)\n\t\t}\n\n\t\tch[i][0] += m[i] * tangent[0] * dt\n\t\tch[i][1] += m[i] * tangent[1] * dt\n\t}\n}", "func XYToD(n, x, y int) (d int) {\n\tfor s:=n/2; s>0; s/=2 {\n\t\tvar rx, ry int\n\t\tif x&s > 0 {\n\t\t\trx = 1\n\t\t}\n\t\tif y&s > 0 {\n\t\t\try = 1\n\t\t}\n\t\td += s * s * ((3 * rx) ^ ry)\n\t\trot(s, rx, ry, &x, &y)\n\t}\n\treturn\n}", "func randDegree() float64 {\n return rand.Float64() * 360.0\n }", "func calculate(r float64) (float64, float64) {\n\tvar area = pi * (r * r)\n\n\tvar circle = 2 * pi * r\n\n\treturn area, circle\n}", "func trapez(f func(float64) float64, a float64, b float64, n int) float64 {\n\tvar h float64\n\tvar sum float64 = 0.0\n\n\tif a > b {\n\t\tfmt.Print(\"ERROR: Lower interval bound a has to be smaller than upper bound b.\")\n\t\treturn 0\n\t}\n\n\t// Step length h\n\th = (b - a) / float64(n)\n\n\t// Calculate integral value with trapezoidal rule\n\tfor k := 1; k <= n-1; k++ {\n\t\tsum = sum + f(a+float64(k)*h)\n\t}\n\n\treturn h * (0.5*f(a) + 0.5*f(b) + sum)\n}", "func Weights(n int, randomness int64) []int {\n\tperm := Permutation(n, randomness)\n\tweights := make([]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tnewIndex := perm[i]\n\t\tweights[i] = newIndex + 1\n\t}\n\treturn weights\n}", "func Tan(tk obj.Token, args []oop.VarDef) oop.Val {\n\tval := args[0].Val\n\tif val.Type != oop.Int && val.Type != oop.Float {\n\t\tval.Data = 0.0\n\t}\n\treturn oop.Val{Data: math.Tan(val.Data.(float64)), Type: oop.Float}\n}", "func (z *Int) Binomial(n, k int64) *Int {}", "func NthTriangleNumber(n int) int {\n\tif n%2 == 0 {\n\t\treturn (n + 1) * n / 2\n\t}\n\treturn (n*n + n + 1) / 2\n}", "func (a Ant) GetVertexesRNValue() []float64 {\n numVertex := len((*(*a.graph).vertexes))\n rnvalues := make([]float64, numVertex)\n //fmt.Printf(\"Num vertexes %d\\n\", numVertex)\n count := 0;\n for count < numVertex {\n indexVertex := (*(*a.graph).vertexes)[count].index\n pheromoneVertex := (*(*a.graph).vertexes)[count].pheromone\n weightVertex := (*a.graph).FullWeightOfVertex(indexVertex)\n rnvalues[indexVertex] = pheromoneVertex*weightVertex\n //fmt.Printf(\"Index: %d Pheromone: %f Weight: %f RN: %f\\n\", indexVertex,pheromoneVertex,weightVertex, rnvalues[indexVertex])\n count = count+1\n }\n return rnvalues\n}", "func (ta *TA) Ln() *TA {\n\treturn ta.Mapf(math.Log, false)\n}", "func Nagon(n int, radius float64) v2.VecSet {\n\tif n < 3 {\n\t\treturn nil\n\t}\n\tm := Rotate(Tau / float64(n))\n\tv := make(v2.VecSet, n)\n\tp := v2.Vec{radius, 0}\n\tfor i := 0; i < n; i++ {\n\t\tv[i] = p\n\t\tp = m.MulPosition(p)\n\t}\n\treturn v\n}", "func HitungNA(clo1, clo2, clo3 float64) float64 {\r\n\r\n\tvar Total float64\r\n\tTotal = (clo1 * 20 / 100) + (clo2 * 35 / 100) + (clo3 * 45 / 100)\r\n\r\n\treturn Total\r\n\r\n}", "func viralAdvertising(n int32) int32 {\n\n\toutput := make([]int32, n)\n\n\toutput[0] = (5 / 2) * 3\n\n\tvar i int32 = 1\n\n\tvar total int32 = 2\n\n\tfor ; i < n; i++ {\n\t\tcurrentTotal := output[i-1] / 2\n\t\toutput[i] = currentTotal * 3\n\t\ttotal += currentTotal\n\t}\n\n\treturn total\n}", "func trapezoidalr(inf float64, sup float64, f F, m int, previous float64) float64 {\n\tif m > 1 {\n\t\tep := int(math.Pow(2, float64(m-2)))\n\t\tc := 0.0\n\n\t\tfor j := 1; j <= ep; j++ {\n\t\t\ty := (float64(2*ep-2*j+1)*inf + float64(2*j-1)*sup) / (2 * float64(ep))\n\t\t\tc += f(y)\n\t\t}\n\t\tc = .5*previous + (sup-inf)*c/(2*float64(ep))\n\t\treturn c\n\t}\n\treturn (sup - inf) / 2.0 * (f(sup) + f(inf))\n}", "func (i *Number) ArcTangent() *Number {\n\treturn NewNumber(math.Atan(i.value))\n}", "func Ones(_, _ int, _ float64) float64 { return 1 }", "func penalty3(pp *privPath, i, j int) float64 {\n\tr := 0 // rotations from i to j\n\tsums, pt := pp.Sums, pp.Pt\n\tn := len(pt)\n\n\tif j >= n {\n\t\tj -= n\n\t\tr = 1\n\t}\n\n\tvar (\n\t\tx, y, x2, xy, y2, k float64\n\t)\n\n\t// critical inner loop: the \"if\" gives a 4.6 percent speedup\n\tif r == 0 {\n\t\tx = float64(sums[j+1].x - sums[i].x)\n\t\ty = float64(sums[j+1].y - sums[i].y)\n\t\tx2 = float64(sums[j+1].x2 - sums[i].x2)\n\t\txy = float64(sums[j+1].xy - sums[i].xy)\n\t\ty2 = float64(sums[j+1].y2 - sums[i].y2)\n\t\tk = float64(j + 1 - i)\n\t} else {\n\t\tx = float64(sums[j+1].x - sums[i].x + sums[n].x)\n\t\ty = float64(sums[j+1].y - sums[i].y + sums[n].y)\n\t\tx2 = float64(sums[j+1].x2 - sums[i].x2 + sums[n].x2)\n\t\txy = float64(sums[j+1].xy - sums[i].xy + sums[n].xy)\n\t\ty2 = float64(sums[j+1].y2 - sums[i].y2 + sums[n].y2)\n\t\tk = float64(j + 1 - i + n)\n\t}\n\n\tpx := float64(pt[i].X+pt[j].X)/2.0 - float64(pt[0].X)\n\tpy := float64(pt[i].Y+pt[j].Y)/2.0 - float64(pt[0].Y)\n\tey := float64(pt[j].X - pt[i].X)\n\tex := -float64(pt[j].Y - pt[i].Y)\n\n\ta := ((x2-2*x*px)/k + px*px)\n\tb := ((xy-x*py-y*px)/k + px*py)\n\tc := ((y2-2*y*py)/k + py*py)\n\n\ts := ex*ex*a + 2*ex*ey*b + ey*ey*c\n\n\treturn math.Sqrt(s)\n}", "func (o *Orbit) Elements() (a, e, i, Ω, ω, ν, λ, tildeω, u float64) {\n\tif o.hashValid() {\n\t\treturn o.ccha, o.cche, o.cchi, o.cchΩ, o.cchω, o.cchν, o.cchλ, o.cchtildeω, o.cchu\n\t}\n\t// Algorithm from Vallado, 4th edition, page 113 (RV2COE).\n\thVec := Cross(o.rVec, o.vVec)\n\tn := Cross([]float64{0, 0, 1}, hVec)\n\tv := Norm(o.vVec)\n\tr := Norm(o.rVec)\n\tξ := (v*v)/2 - o.Origin.μ/r\n\ta = -o.Origin.μ / (2 * ξ)\n\teVec := make([]float64, 3, 3)\n\tfor i := 0; i < 3; i++ {\n\t\teVec[i] = ((v*v-o.Origin.μ/r)*o.rVec[i] - Dot(o.rVec, o.vVec)*o.vVec[i]) / o.Origin.μ\n\t}\n\te = Norm(eVec)\n\t// Prevent nil values for e\n\tif e < eccentricityε {\n\t\te = eccentricityε\n\t}\n\ti = math.Acos(hVec[2] / Norm(hVec))\n\tif i < angleε {\n\t\ti = angleε\n\t}\n\tω = math.Acos(Dot(n, eVec) / (Norm(n) * e))\n\tif math.IsNaN(ω) {\n\t\tω = 0\n\t}\n\tif eVec[2] < 0 {\n\t\tω = 2*math.Pi - ω\n\t}\n\tΩ = math.Acos(n[0] / Norm(n))\n\tif math.IsNaN(Ω) {\n\t\tΩ = angleε\n\t}\n\tif n[1] < 0 {\n\t\tΩ = 2*math.Pi - Ω\n\t}\n\tcosν := Dot(eVec, o.rVec) / (e * r)\n\tif abscosν := math.Abs(cosν); abscosν > 1 && floats.EqualWithinAbs(abscosν, 1, 1e-12) {\n\t\t// Welcome to the edge case which took about 1.5 hours of my time.\n\t\tcosν = Sign(cosν) // GTFO NaN!\n\t}\n\tν = math.Acos(cosν)\n\tif math.IsNaN(ν) {\n\t\tν = 0\n\t}\n\tif Dot(o.rVec, o.vVec) < 0 {\n\t\tν = 2*math.Pi - ν\n\t}\n\t// Fix rounding errors.\n\ti = math.Mod(i, 2*math.Pi)\n\tΩ = math.Mod(Ω, 2*math.Pi)\n\tω = math.Mod(ω, 2*math.Pi)\n\tν = math.Mod(ν, 2*math.Pi)\n\tλ = math.Mod(ω+Ω+ν, 2*math.Pi)\n\ttildeω = math.Mod(ω+Ω, 2*math.Pi)\n\tif e < eccentricityε {\n\t\t// Circular\n\t\tu = math.Acos(Dot(n, o.rVec) / (Norm(n) * r))\n\t} else {\n\t\tu = math.Mod(ν+ω, 2*math.Pi)\n\t}\n\t// Cache values\n\to.ccha = a\n\to.cche = e\n\to.cchi = i\n\to.cchΩ = Ω\n\to.cchω = ω\n\to.cchν = ν\n\to.cchλ = λ\n\to.cchtildeω = tildeω\n\to.cchu = u\n\to.computeHash()\n\treturn\n}", "func nCr(n int, r int) int {\n\tresult := 1\n\tif r > n/2 {\n\t\tr = n - r\n\t}\n\tfor i := 1; i <= r; i++ {\n\t\tresult *= n - r + i\n\t\tresult /= i\n\t}\n\treturn result\n}", "func isPentagonal(n int) bool{\r\n\r\n\tvar temp float64= (1+math.Sqrt(1+24*float64(n)))/6\r\n\tif (temp==float64(int(temp))) {\r\n\t\treturn true\r\n\t}else{\r\n\t\treturn false\r\n\t}\r\n}", "func (r *ConstantRand) Intn(n int) int {\n\tif n <= 0 {\n\t\tpanic(\"invalid argument to Intn\")\n\t}\n\n\tif int(r.seed) > n-1 {\n\t\treturn n\n\t}\n\n\treturn int(r.seed)\n}", "func polyGetNoise(eta int, seed []byte, nonce byte) Poly {\n\toutbuf := make([]byte, eta*n/4)\n\tstate := sha3.NewShake256()\n\tstate.Write(seed[:])\n\tstate.Write([]byte{nonce})\n\tstate.Read(outbuf[:])\n\tvar p Poly\n\tif eta == 3 {\n\t\tp = polyCBD3(outbuf)\n\t}\n\tif eta == 2 {\n\t\tp = polyCBD2(outbuf)\n\t}\n\treturn p\n}", "func (this *NurbsCurve) nonRationalPointGivenN(n int, u float64) HomoPoint {\n\tdegree := this.degree\n\tcontrolPoints := this.controlPoints\n\tknots := this.knots\n\n\tif !areValidRelations(degree, len(controlPoints), len(knots)) {\n\t\tpanic(\"Invalid relations between control points, knot Array, and n\")\n\t}\n\n\tknotSpanIndex := knots.SpanGivenN(n, degree, u)\n\tbasisValues := BasisFunctionsGivenKnotSpanIndex(knotSpanIndex, u, degree, knots)\n\tvar position HomoPoint\n\n\tfor j := 0; j <= degree; j++ {\n\t\tscaled := controlPoints[knotSpanIndex-degree+j]\n\t\tscaled.Scale(basisValues[j])\n\t\tposition.Add(&scaled)\n\t}\n\n\treturn position\n}", "func (c *core) N() int {\n\treturn ((c.Curve.Params().P.BitLen()+1)/2 + 7) / 8\n}", "func NewTransactionN(n int) *Transaction {\n\treturn &Transaction{Deltas: make([]Delta, 0, n), deltas: make(map[Delta]struct{}, n)}\n}", "func (r *Rand) Intn(n int) int {\n\tif x, err := r.cryptoRand.Intn(n); err == nil {\n\t\treturn x\n\t}\n\treturn r.mathRand.Intn(n)\n}", "func (t *Team) GetVar() (sum float64) {\n\tfor _, p := range t.players {\n\t\tsum += p.GetSigma() * p.GetSigma()\n\t}\n\treturn\n}", "func (c CelestialObject) J(n uint8) float64 {\n\tswitch n {\n\tcase 2:\n\t\treturn c.J2\n\tcase 3:\n\t\treturn c.J3\n\tcase 4:\n\t\treturn c.J4\n\tdefault:\n\t\treturn 0.0\n\t}\n}", "func Twin(n int) (int, bool) {\n\tif OptimizedTrialDivision(int64(n)) && OptimizedTrialDivision(int64(n+2)) {\n\t\treturn n + 2, true\n\t}\n\treturn -1, false\n}", "func learnMultiple(x, y int) (sum, prod int) {\n\t// two values returned\n\treturn x + y, x * y\n\n}", "func NthElement(scope *Scope, input tf.Output, n tf.Output, optional ...NthElementAttr) (values tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\tattrs := map[string]interface{}{}\n\tfor _, a := range optional {\n\t\ta(attrs)\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"NthElement\",\n\t\tInput: []tf.Input{\n\t\t\tinput, n,\n\t\t},\n\t\tAttrs: attrs,\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func Tanh(tk obj.Token, args []oop.VarDef) oop.Val {\n\tval := args[0].Val\n\tif val.Type != oop.Int && val.Type != oop.Float {\n\t\tval.Data = 0.0\n\t}\n\treturn oop.Val{Data: math.Tanh(val.Data.(float64)), Type: oop.Float}\n}", "func sizeToParams(n int) (c, d int) {\n\tc = 2\n\tfor ; c < n; c *= 2 {\n\t\td++\n\t}\n\treturn c, d + 1\n}", "func parseNth(t Tokenizer) (int, int, error) {\n\tvar a, b int\n\tvar ok bool\n\n\terr := fmt.Errorf(\"Invalid nth arguments at position %v\", t.Position())\n\n\ttk := skipWhitespace(t)\n\tswitch tk.Type() {\n\tcase Number:\n\t\tn := tk.(*NumberToken)\n\t\tif !n.Integer || !closingParen(t) {\n\t\t\treturn 0, 0, err\n\t\t}\n\n\t\tif b, ok = parseInt(n.Value); ok {\n\t\t\treturn 0, b, nil\n\t\t} else {\n\t\t\treturn 0, 0, err\n\t\t}\n\tcase Dimension:\n\t\td := tk.(*DimensionToken)\n\t\tif !d.Integer {\n\t\t\treturn 0, 0, err\n\t\t}\n\n\t\ta, ok = parseInt(d.Value)\n\t\tif !ok {\n\t\t\treturn 0, 0, err\n\t\t}\n\n\t\tunit := strings.ToLower(d.Unit)\n\t\tif unit == \"n\" {\n\t\t\tb, ok = parseB(t)\n\t\t} else if unit == \"n-\" {\n\t\t\tb, ok = parseSignlessB(t, -1)\n\t\t} else {\n\t\t\tb, ok = parseNDashDigits(unit)\n\t\t\tok = ok && closingParen(t)\n\t\t}\n\n\t\tif !ok {\n\t\t\treturn 0, 0, err\n\t\t}\n\n\t\treturn a, b, nil\n\tcase Ident:\n\t\tident := strings.ToLower(tk.String())\n\t\tswitch ident {\n\t\tcase \"even\":\n\t\t\ta, b = 2, 0\n\t\t\tok = closingParen(t)\n\t\tcase \"odd\":\n\t\t\ta, b = 2, 1\n\t\t\tok = closingParen(t)\n\t\tcase \"n\":\n\t\t\ta = 1\n\t\t\tb, ok = parseB(t)\n\t\tcase \"-n\":\n\t\t\ta = -1\n\t\t\tb, ok = parseB(t)\n\t\tcase \"n-\":\n\t\t\ta = 1\n\t\t\tb, ok = parseSignlessB(t, -1)\n\t\tcase \"-n-\":\n\t\t\ta = -1\n\t\t\tb, ok = parseSignlessB(t, -1)\n\t\tdefault:\n\t\t\tif strings.HasPrefix(ident, \"-\") {\n\t\t\t\ta = -1\n\t\t\t\tb, ok = parseNDashDigits(ident[1:])\n\t\t\t\tok = ok && closingParen(t)\n\t\t\t} else {\n\t\t\t\ta = 1\n\t\t\t\tb, ok = parseNDashDigits(ident)\n\t\t\t\tok = ok && closingParen(t)\n\t\t\t}\n\t\t}\n\n\t\tif !ok {\n\t\t\treturn 0, 0, err\n\t\t}\n\n\t\treturn a, b, nil\n\tcase Delim:\n\t\tif tk.String() != \"+\" {\n\t\t\treturn 0, 0, err\n\t\t}\n\n\t\ttk = t.NextToken()\n\t\tif tk.Type() != Ident {\n\t\t\treturn 0, 0, err\n\t\t}\n\n\t\tident := strings.ToLower(tk.String())\n\t\tswitch ident {\n\t\tcase \"n\":\n\t\t\ta = 1\n\t\t\tb, ok = parseB(t)\n\t\tcase \"n-\":\n\t\t\ta = 1\n\t\t\tb, ok = parseSignlessB(t, -1)\n\t\tdefault:\n\t\t\ta = 1\n\t\t\tb, ok = parseNDashDigits(ident)\n\t\t\tok = ok && closingParen(t)\n\t\t}\n\n\t\tif !ok {\n\t\t\treturn 0, 0, err\n\t\t}\n\n\t\treturn a, b, nil\n\tdefault:\n\t\treturn 0, 0, err\n\t}\n}", "func (s *Simulator) PointN() int {\n\treturn int(s.PointsPerSeries) * s.SeriesN()\n}", "func (p *G1Jac) phi(a *G1Jac) *G1Jac {\n\tp.Set(a)\n\tp.X.Mul(&p.X, &thirdRootOneG1)\n\treturn p\n}", "func TotientPhi(m int) (int, error) {\n\tif m < 1 {\n\t\treturn -1, errors.New(\"The given number is not positive\")\n\t}\n\n\tif m == 1 {\n\t\treturn 1, nil\n\t}\n\tif IsPrime(m) {\n\t\treturn m - 1, nil\n\t}\n\tcoPrimes := 1\n\tfor i := 2; i < int(m/2)+1; i++ {\n\t\tif m%i != 0 {\n\t\t\tif coPrime, _ := IsCoprime(i, m); coPrime.ValueOrZero() {\n\t\t\t\tcoPrimes++\n\t\t\t}\n\t\t}\n\t}\n\tfor i := int(m/2) + 1; i < m; i++ {\n\t\tif coPrime, _ := IsCoprime(i, m); coPrime.ValueOrZero() {\n\t\t\tcoPrimes++\n\t\t}\n\t}\n\treturn coPrimes, nil\n}", "func Tanh(scope *Scope, x tf.Output) (y tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Tanh\",\n\t\tInput: []tf.Input{\n\t\t\tx,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func h(n int) int {\n var a int = n % 2\n if a == 1 {\n return n * 3 + 1\n }\n return n / 2\n}", "func Entropy(n, m int) float64 {\n\treturn float64(n) * math.Log2(float64(m))\n}", "func (n *Normal) Entropy() float64 {\n\treturn float64(n.dim)/2*(1+logTwoPi) + n.logSqrtDet\n}", "func getCoordinatesForIndex(index int) (int, int) {\n\treturn index % 3, index / 3o hello world\n\n}", "func giniCoefficient(nums []int) float64 {\n\tsort.Ints(nums)\n\tn := len(nums)\n\tdenom := 0\n\tfor _, num := range nums {\n\t\tdenom += num\n\t}\n\tdenom *= n\n\tnumer := 0\n\tfor i, num := range nums {\n\t\tnumer += (i + 1) * num\n\t}\n\tnumer *= 2\n\treturn float64(numer)/float64(denom) - float64(n+1)/float64(n)\n}", "func findCoefficients(sphr sphere, direction, origin vector, verbosity bool) (float64, float64, float64) {\n\toffset := origin.sub(sphr.center)\n\ta := (direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z)\n\tb := 2 * (direction.x*(offset.x) + direction.y*(offset.y) + direction.z*(offset.z))\n\tc := (math.Pow((offset.x), 2) + math.Pow((offset.y), 2) + math.Pow((offset.z), 2) - (sphr.radius * sphr.radius))\n\n\tif verbosity {\n\t\tfmt.Printf(\"a:%f,\\nb:%f,\\nc:%f \\n\", a, b, c)\n\t}\n\treturn a, b, c\n}", "func TrainNB1(trainMatrix [][]int, trainCategory []int)([]float64, []float64, float64) {\n numTrainDocs := len(trainMatrix)\n numWords := len(trainMatrix[0])\n sumCategory := calc.SumInt(trainCategory)\n \n pAbusive := float64(sumCategory) / float64(numTrainDocs)\n p0Num := make([]int, numWords)\n p1Num := make([]int, numWords)\n\n p0Denom := float64(2.0)\n p1Denom := float64(2.0)\n\n for i := 0; i < numTrainDocs; i++ {\n if trainCategory[i] == 1 {\n p1Num = calc.AddIntVec(p1Num, trainMatrix[i])\n p1Denom += float64(calc.SumInt(trainMatrix[i]))\n }else{\n p0Num = calc.AddIntVec(p0Num, trainMatrix[i])\n p0Denom += float64(calc.SumInt(trainMatrix[i])) \n }\n }\n \n fmt.Println(\"p0Num: \", p0Num)\n fmt.Println(\"p1Num: \", p1Num)\n p1Vec := calc.DivIntVec(p1Num, p1Denom)\n p0Vec := calc.DivIntVec(p0Num, p0Denom)\n \n p0Vec = LogVec(p0Vec)\n p1Vec = LogVec(p1Vec)\n\n return p0Vec, p1Vec, pAbusive\n}", "func GenerateBeaverTriplet(N *big.Int) [3]*big.Int {\n\tvar triplet [3]*big.Int\n\n\tx, y := getRandom(N), getRandom(N)\n\n\tif mr.Intn(2) > 0 {\n\t\t// u = x, v = y, w = xy mod N\n\t\tw := new(big.Int).Mul(x, y)\n\t\ttriplet[0] = w.Mod(w, N)\n\t\ttriplet[1] = x\n\t\ttriplet[2] = y\n\t} else {\n\t\t// v = x, w = y, u = (xy^-1)^-1 mod N\n\t\tu := new(big.Int).Mul(x, new(big.Int).ModInverse(y, N))\n\t\ttriplet[0] = y\n\t\ttriplet[1] = x\n\t\ttriplet[2] = u.ModInverse(u, N)\n\t}\n\n\treturn triplet\n}", "func Tan(arg float64) float64 {\n\treturn math.Tan(arg)\n}", "func Tangent(normal Dir) (to, from *Mtx) {\n\tangle := math.Acos(normal.Dot(Up))\n\taxis, ok := normal.Cross(Up)\n\tif !ok {\n\t\treturn Identity(), Identity()\n\t}\n\tangleAxis := axis.Scaled(angle)\n\tm := Rotate(angleAxis)\n\treturn m, m.Inverse()\n}", "func stepPerms(n int32) int32 {\n\tif n < 3 {\n\t\treturn n\n\t}\n\n\ta, b, c, current := 1, 2, 4, 0\n\n\tfor i := int32(3); i < n; i++ {\n\t\tcurrent = a + b + c\n\t\ta, b = b, c\n\t\tc = current\n\t}\n\n\treturn int32(c)\n}", "func (x *Rat) Denom() *Int {}" ]
[ "0.56499743", "0.5570517", "0.55274975", "0.5270913", "0.52580523", "0.5210327", "0.5186417", "0.5147195", "0.5046329", "0.5032955", "0.5023559", "0.5020158", "0.49866942", "0.4941833", "0.4909239", "0.49024647", "0.48769343", "0.48618388", "0.48359647", "0.4822305", "0.4815016", "0.47977552", "0.47860244", "0.4747307", "0.4729657", "0.47237203", "0.4708014", "0.4698357", "0.4691062", "0.4663331", "0.46569872", "0.46195942", "0.46020916", "0.45964462", "0.4596159", "0.4570424", "0.45652077", "0.45649576", "0.4556179", "0.45512787", "0.45494002", "0.4533994", "0.45165366", "0.44796592", "0.447906", "0.4467091", "0.44414535", "0.44411317", "0.44396967", "0.44229567", "0.44090295", "0.44045898", "0.44004345", "0.4397166", "0.4396306", "0.43798262", "0.43557668", "0.43498486", "0.43471795", "0.4347073", "0.43432847", "0.43373436", "0.43339476", "0.43326882", "0.43204728", "0.4318123", "0.43043253", "0.43032223", "0.4297916", "0.42853057", "0.42840728", "0.42777285", "0.42728388", "0.4269576", "0.42641103", "0.4262167", "0.42612612", "0.42610654", "0.42557767", "0.4241051", "0.42354745", "0.4229295", "0.42287445", "0.4226218", "0.42177445", "0.42140818", "0.42126185", "0.42108715", "0.41994458", "0.41902497", "0.4187216", "0.41742468", "0.4166603", "0.4164817", "0.41640994", "0.41630682", "0.41613474", "0.41612643", "0.41554427", "0.4154941" ]
0.4970011
13
Export Setup Vars as JSON string
func (tpe *TPE) ExportSetup() string { // Marshal Struct to JSON string configJSON, _ := json.Marshal(tpe.setup) return string(configJSON) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func main() {\n\tprovider := &dummyProvider{\n\t\tsettings: map[string]string{},\n\t}\n\tsettings.SetProvider(provider)\n\toutput := map[string]string{}\n\tfor key, name := range provider.settings {\n\t\tvalue := os.Getenv(key)\n\t\tif value == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\toutput[name] = value\n\t}\n\tdata, _ := json.Marshal(output)\n\tos.Stdout.Write(data)\n}", "func (a *App) SerializeEnvVars() error {\n\tvar buf bytes.Buffer\n\tcmd := \"cat > /home/application/apprc <<END\\n\"\n\tcmd += fmt.Sprintf(\"# generated by tsuru at %s\\n\", time.Now().Format(time.RFC822Z))\n\tfor k, v := range a.Env {\n\t\tcmd += fmt.Sprintf(`export %s=\"%s\"`+\"\\n\", k, v.Value)\n\t}\n\tcmd += \"END\\n\"\n\terr := a.run(cmd, &buf)\n\tif err != nil {\n\t\toutput := buf.Bytes()\n\t\tif output == nil {\n\t\t\terr = fmt.Errorf(\"Failed to write env vars: %s.\", err)\n\t\t} else {\n\t\t\terr = fmt.Errorf(\"Failed to write env vars (%s): %s.\", err, output)\n\t\t}\n\t}\n\treturn err\n}", "func (env *Env) GenerateJSONConfig(rw http.ResponseWriter, req *http.Request) {\n\thostname := mux.Vars(req)[\"hostname\"]\n\t// TODO: Verify that the sessionID matches the host.CurrentSessionIDs.Stage2ID.\n\t// sessionID := mux.Vars(req)[\"sessionID\"]\n\n\t// Use hostname as key to load record from Datastore.\n\thost, err := env.Config.Load(hostname)\n\tif err != nil {\n\t\thttp.Error(rw, err.Error(), http.StatusNotFound)\n\t\treturn\n\t}\n\terr = env.requestIsFromHost(req, host)\n\tif err != nil {\n\t\thttp.Error(rw, err.Error(), http.StatusForbidden)\n\t\treturn\n\t}\n\n\t// TODO(soltesz):\n\t// * Save information sent in PostForm, e.g. ssh host key.\n\tstage := path.Base(req.URL.Path)\n\n\tscript := template.FormatJSONConfig(host, stage)\n\n\t// Complete request as successful.\n\trw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\trw.WriteHeader(http.StatusOK)\n\t_, err = fmt.Fprintf(rw, script)\n\tif err != nil {\n\t\tlog.Printf(\"Failed to write response to %q: %v\", hostname, err)\n\t}\n\treturn\n}", "func createJSPackageJSON(function *Function) {\n\ttempPackageTemplate := `{\n\t\t\"name\": \"{{ .name}}\",\n\t\t\"version\": \"0.0.1\",\n\t\t\"description\": \"r3x Knative Function\",\n\t\t\"main\": \"r3x-func.js\",\n\t\t\"scripts\": {\n\t\t \"start\": \"node r3x-func.js\"\n\t\t},\n\t\t\"keywords\": [\n\t\t \"javascript\",\n\t\t \"knative\",\n\t\t \"kubernetes\",\n\t\t \"serverless\"\n\t\t],\n\t\t\"dependencies\": {\n\t\t \"@rubixfunctions/r3x-js-sdk\": \"0.0.14\"\n\t\t}\n\t }\n\t `\n\n\tdata := make(map[string]interface{})\n\tdata[\"name\"] = function.name\n\n\trootCmdScript, err := executeTemplate(tempPackageTemplate, data)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\terr = writeStringToFile(filepath.Join(function.AbsPath(), \"package.json\"), rootCmdScript)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n}", "func (o SyntheticsGlobalVariableParseTestOptions) MarshalJSON() ([]byte, error) {\n\ttoSerialize := map[string]interface{}{}\n\tif o.UnparsedObject != nil {\n\t\treturn json.Marshal(o.UnparsedObject)\n\t}\n\tif o.Field != nil {\n\t\ttoSerialize[\"field\"] = o.Field\n\t}\n\tif o.LocalVariableName != nil {\n\t\ttoSerialize[\"localVariableName\"] = o.LocalVariableName\n\t}\n\tif o.Parser != nil {\n\t\ttoSerialize[\"parser\"] = o.Parser\n\t}\n\ttoSerialize[\"type\"] = o.Type\n\n\tfor key, value := range o.AdditionalProperties {\n\t\ttoSerialize[key] = value\n\t}\n\treturn json.Marshal(toSerialize)\n}", "func (v varExporter) String() string {\n\tout := map[string]probeInfo{}\n\n\tv.p.mu.Lock()\n\tprobes := make([]*Probe, 0, len(v.p.probes))\n\tfor _, probe := range v.p.probes {\n\t\tprobes = append(probes, probe)\n\t}\n\tv.p.mu.Unlock()\n\n\tfor _, probe := range probes {\n\t\tprobe.mu.Lock()\n\t\tinf := probeInfo{\n\t\t\tLabels: probe.labels,\n\t\t\tStart: probe.start,\n\t\t\tEnd: probe.end,\n\t\t\tResult: probe.result,\n\t\t}\n\t\tif probe.end.After(probe.start) {\n\t\t\tinf.Latency = probe.end.Sub(probe.start).String()\n\t\t}\n\t\tout[probe.name] = inf\n\t\tprobe.mu.Unlock()\n\t}\n\n\tbs, err := json.Marshal(out)\n\tif err != nil {\n\t\treturn fmt.Sprintf(`{\"error\": %q}`, err)\n\t}\n\treturn string(bs)\n}", "func (ps pumaStatusFinalOutput) printAndBuildJSON() error {\n\tb, err := json.Marshal(ps)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Println(string(b))\n\n\treturn nil\n}", "func (g *GenOpts) JSON() ([]byte, error) {\n\treturn json.Marshal(g)\n}", "func setUp() {\n\tdefaultData := map[string]string{\n\t\t\"key1\": \"value1\",\n\t\t\"key2\": \"value2\",\n\t\t\"key3\": \"value3\",\n\t}\n\tjsonData, _ := json.Marshal(defaultData)\n\terr := ioutil.WriteFile(JsonTestPath, jsonData, 0644)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n}", "func VarsHandler(c *Context, w http.ResponseWriter, r *http.Request) (int, error) {\n\tw.WriteHeader(http.StatusOK)\n\tio.WriteString(w, jsonPrettyPrint(c.Config.String()))\n\treturn 200, nil\n}", "func Test(w http.ResponseWriter, r *http.Request) {\n\tres, err := json.Marshal(EnvVariablesModel{Vars: os.Environ(), A: \"b\", C: 123})\n\tif err != nil {\n\t\tcommon.DisplayAppError(\n\t\t\tw,\n\t\t\terr,\n\t\t\t\"An unexpected error has occurred\",\n\t\t\t500,\n\t\t)\n\t\treturn\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Write(res)\n}", "func (gl *GlobalSettings) Encode() []byte {\n\tvar b, err = json.Marshal(gl)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b\n}", "func jsonPrintDetails() {\n\n\tb, err := json.Marshal(alertDetails[name])\n\n\tif err != nil {\n\t\tlog.Printf(\"Unable to convert Detailed JSON Data, error: %v\\n\", err)\n\t\treturn\n\t}\n\n\tfmt.Println(string(b))\n}", "func (j *tfvarsJSON) Generate(module *terraform.Module) error {\n\tcopy := orderedmap.New()\n\tcopy.SetEscapeHTML(false)\n\tfor _, i := range module.Inputs {\n\t\tcopy.Set(i.Name, i.Default)\n\t}\n\n\tbuffer := new(bytes.Buffer)\n\tencoder := jsonsdk.NewEncoder(buffer)\n\tencoder.SetIndent(\"\", \" \")\n\tencoder.SetEscapeHTML(false)\n\n\tif err := encoder.Encode(copy); err != nil {\n\t\treturn err\n\t}\n\n\tj.generator.funcs(withContent(strings.TrimSuffix(buffer.String(), \"\\n\")))\n\n\treturn nil\n}", "func (c *Config) writeSettingsJson() {\n\tenc, _ := json.MarshalIndent(*c, \"\", \" \")\n\n\tif err := ioutil.WriteFile(configFile, enc, 0660); err != nil {\n\t\tpanic(err)\n\t}\n}", "func pluginConfigJsonToString(data map[string]interface{}) string {\n\tmarshalledData := map[string]interface{}{}\n\tfor key, val := range data {\n\t\tif !contains(computedPluginProperties, key) {\n\t\t\tmarshalledData[key] = val\n\t\t}\n\t}\n\t// We know it is valid JSON at this point\n\trawJson, _ := json.Marshal(marshalledData)\n\n\treturn string(rawJson)\n}", "func (a *Arrangements) ToJSONFile(filename string) error {\n\tdata, err := json.MarshalIndent(a, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = ioutil.WriteFile(filename, data, 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (ts *TelemetrySetupRequest) String() (result string) {\n\tspaces3 := \" \"\n\tspaces6 := spaces3 + spaces3\n\tspaces9 := spaces6 + spaces3\n\tspaces12 := spaces9 + spaces3\n\tresult = \"\\n \\\"ietf-dots-telemetry:telemetry-setup\\\":\\n\"\n\tfor key, t := range ts.TelemetrySetup.Telemetry {\n\t\tresult += fmt.Sprintf(\"%s\\\"%s[%d]\\\":\\n\", spaces3, \"telemetry\", key+1)\n\t\tif t.TelemetryConfigurationCurrent != nil {\n\t\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", spaces6, \"current-config\")\n\t\t\ttConfig := t.TelemetryConfigurationCurrent\n\t\t\tif tConfig.MeasurementInterval != nil {\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", spaces9, \"measurement-interval\", *tConfig.MeasurementInterval)\n\t\t\t}\n\t\t\tif tConfig.MeasurementSample != nil {\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", spaces9, \"measurement-sample\", *tConfig.MeasurementSample)\n\t\t\t}\n\t\t\tif tConfig.LowPercentile != nil {\n\t\t\t\tlow, _ := tConfig.LowPercentile.Round(2).Float64()\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %f\\n\", spaces9, \"low-percentile\", low)\n\t\t\t}\n\t\t\tif tConfig.MidPercentile != nil {\n\t\t\t\tmid, _ := tConfig.MidPercentile.Round(2).Float64()\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %f\\n\", spaces9, \"mid-percentile\", mid)\n\t\t\t}\n\t\t\tif tConfig.HighPercentile != nil {\n\t\t\t\thigh, _ := tConfig.HighPercentile.Round(2).Float64()\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %f\\n\", spaces9, \"high-percentile\", high)\n\t\t\t}\n\t\t\tfor k, v := range tConfig.UnitConfigList {\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s[%d]\\\":\\n\", spaces9, \"unit-config\", k+1)\n\t\t\t\tif v.Unit != nil {\n\t\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", spaces12, \"unit\", *v.Unit)\n\t\t\t\t}\n\t\t\t\tif v.UnitStatus != nil {\n\t\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %t\\n\", spaces12, \"unit-status\", *v.UnitStatus)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif tConfig.ServerOriginatedTelemetry != nil {\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %t\\n\", spaces9, \"server-originated-telemetry\", *tConfig.ServerOriginatedTelemetry)\n\t\t\t}\n\t\t\tif tConfig.TelemetryNotifyInterval != nil {\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", spaces9, \"telemetry-notify-interval\", *tConfig.TelemetryNotifyInterval)\n\t\t\t}\n\t\t}\n\t\tfor k, v := range t.TotalPipeCapacity {\n\t\t\tresult += fmt.Sprintf(\"%s\\\"%s[%d]\\\":\\n\", spaces6, \"total-pipe-capacity\", k+1)\n\t\t\tif v.LinkId != nil {\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %s\\n\", spaces9, \"link-id\", *v.LinkId)\n\t\t\t}\n\t\t\tif v.Capacity != nil {\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", spaces9, \"capacity\", *v.Capacity)\n\t\t\t}\n\t\t\tif v.Unit != nil {\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", spaces9, \"unit\", *v.Unit)\n\t\t\t}\n\t\t}\n\t\tfor k, v := range t.Baseline {\n\t\t\tresult += fmt.Sprintf(\"%s\\\"%s[%d]\\\":\\n\", spaces6, \"baseline\", k+1)\n\t\t\tif v.Id != nil {\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", spaces9, \"id\", *v.Id)\n\t\t\t}\n\t\t\tresultTargets := ConvertTargetsRequestToStrings(v.TargetPrefix, v.TargetPortRange, v.TargetProtocol, v.TargetFQDN, v.TargetURI, v.AliasName, spaces9)\n\t\t\tresult += resultTargets\n\t\t\tfor kNormal, vNormal := range v.TotalTrafficNormal {\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s[%d]\\\":\\n\", spaces9, \"total-traffic-normal\", kNormal+1)\n\t\t\t\tresult += vNormal.String(spaces9)\n\t\t\t}\n\t\t\tfor kNormalPerProtocol, vNormalPerProtocol := range v.TotalTrafficNormalPerProtocol {\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s[%d]\\\":\\n\", spaces9, \"total-traffic-normal-per-protocol\", kNormalPerProtocol+1)\n\t\t\t\tresult += vNormalPerProtocol.String(spaces9)\n\t\t\t}\n\t\t\tfor kNormalPerPort, vNormalPerPort := range v.TotalTrafficNormalPerPort {\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s[%d]\\\":\\n\", spaces9, \"total-traffic-normal-per-port\", kNormalPerPort+1)\n\t\t\t\tresult += vNormalPerPort.String(spaces9)\n\t\t\t}\n\t\t\tfor kConnectionCapacity, vConnectionCapacity := range v.TotalConnectionCapacity {\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s[%d]\\\":\\n\", spaces9, \"total-connection-capacity\", kConnectionCapacity+1)\n\t\t\t\tresult += vConnectionCapacity.String(spaces9)\n\t\t\t}\n\t\t\tfor kConnectionCapacityPerPort, vConnectionCapacityPerPort := range v.TotalConnectionCapacityPerPort {\n\t\t\t\tresult += fmt.Sprintf(\"%s\\\"%s[%d]\\\":\\n\", spaces9, \"total-connection-capacity-per-port\", kConnectionCapacityPerPort+1)\n\t\t\t\tresult += vConnectionCapacityPerPort.String(spaces9)\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func (c *Config) JSON() string {\n\tbytes, _ := json.Marshal(c)\n\n\treturn string(bytes)\n\n}", "func (el EnvironmentList) JSON() ([]byte, error) {\n\treturn json.Marshal(el.Environments)\n}", "func (n *AgentNotify) DumpJSON() {\n\tfmt.Println(n.getJSON())\n}", "func Dd(variable interface{}, die bool) {\n\tres, _ := json.MarshalIndent(variable, \"\", \" \")\n\n\tfmt.Println(\"= = = = = = = = = = = =\")\n\tfmt.Println(string(res))\n\tfmt.Println(\"= = = = = = = = = = = =\")\n\tif die {\n\t\tos.Exit(1)\n\t}\n}", "func ListToJSON(complete, remaining MigrationCollection) string {\n var formatted, err = json.MarshalIndent(map[string][]Migration{\n \"Complete\": complete,\n \"Remaining\": remaining,\n }, \"\", \" \")\n if (err != nil) {\n fmt.Printf(\"ERROR: could not marshal JSON of --list\\n%s\\n\\n\", err)\n os.Exit(1)\n }\n return string(formatted)\n}", "func outPut() {\n\ts, _ := json.Marshal(allMap)\n\tfmt.Println(string(s))\n\ts, _ = json.Marshal(errMap)\n\tfmt.Println(string(s))\n}", "func (s *SurfForecast) ExportAsJSON(filename string) error {\n\tjsonData, jsonErr := s.ToJSON()\n\tif jsonErr != nil {\n\t\treturn jsonErr\n\t}\n\n\tfileErr := ioutil.WriteFile(filename, jsonData, 0644)\n\treturn fileErr\n}", "func (w *RandomWorld) PlantsToJSON(fileName string) {\n\tfi, _ := os.Create(fileName)\n\tdefer fi.Close()\n\tfz := NewWriter(fi)\n\te := NewEncoder(fz)\n\n\tif err := e.Encode(w.FoodList); err != nil {\n\t\tpanic(err)\n\t}\n}", "func (uc *UseCase) JSON(indents ...int) []byte {\n\tindent := 0\n\tif 0 < len(indents) {\n\t\tindent = indents[0]\n\t}\n\treturn []byte(oj.JSON(uc, indent))\n}", "func ExportToJSONSchema(schema *rdl.Schema, outdir string, basePath string) error {\n\tsname := string(schema.Name)\n\tjs, err := jsGenerate(schema, basePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tj, err := json.MarshalIndent(js, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\tout, file, _, err := outputWriter(outdir, sname, \".json\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Fprintf(out, \"%s\\n\", string(j))\n\tout.Flush()\n\tif file != nil {\n\t\tfile.Close()\n\t}\n\treturn err\n}", "func (m *Manifest) Dump() {\n\tout := map[string]interface{}{}\n\n\twants := []string{}\n\tfor pn := range m.Wants {\n\t\twants = append(wants, pn)\n\t}\n\tout[\"wants\"] = wants\n\n\tpackages := map[string]interface{}{}\n\tfor pn, p := range m.OutPackages {\n\t\tif wants, ok := p[\"wants\"]; ok {\n\t\t\twants := wants.(map[string]interface{})\n\t\t\tnw := []string{}\n\t\t\tfor dn := range wants {\n\t\t\t\tnw = append(nw, dn)\n\t\t\t}\n\t\t\tp[\"wants\"] = nw\n\t\t}\n\t\tpackages[pn] = p\n\t}\n\tout[\"packages\"] = packages\n\n\tfile, err := os.Create(\"./airbuild.json\")\n\tdefer file.Close()\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\te := json.NewEncoder(file)\n\te.SetIndent(\"\", \" \")\n\terr = e.Encode(out)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\tlog.Info(\"Generated airbuild.json\")\n}", "func (s *varsScope) ToJSONObject() map[string]interface{} {\n\ts.lock.RLock()\n\tdefer s.lock.RUnlock()\n\n\tret := make(map[string]interface{})\n\n\tfor k, v := range s.storage {\n\t\tvar value interface{}\n\n\t\tvalue = fmt.Sprintf(\"ComplexDataStructure: %#v\", v)\n\n\t\tbytes, err := json.Marshal(v)\n\t\tif err != nil {\n\t\t\tbytes, err = json.Marshal(stringutil.ConvertToJSONMarshalableObject(v))\n\n\t\t}\n\t\tif err == nil {\n\t\t\tjson.Unmarshal(bytes, &value)\n\t\t}\n\n\t\tret[k] = value\n\t}\n\n\treturn ret\n}", "func GetNewConfigJsonTemplate(cc CodeConfig) string {\n\treturn `{\n\t\"version\": \"0.1.0\",\n \"gson_api_url\": \"https://api.your-domain-goes-here.com/v1/\",\n\t\"port\": 4000,\n\t\"new_relic_key\": \"\",\n\t\"debug\": false,\n\t\"environment\": \"test\",\n\t\"test\": { {{if .IsMSSQL}}\n\t\t\"mssql\": {\n\t\t \"aws\": {\n\t\t\t\"server\": \"\",\n\t\t\t\"port\": 1433,\n\t\t\t\"dbname\": \"\",\n\t\t\t\"username\": \"\",\n\t\t\t\"password\": \"\",\n\t\t\t\"maxidleconnections\": 10,\n\t\t\t\"maxopenconnections\": 100,\n\t\t\t\"debug\": true\n\t\t }\n\t\t}\n {{else if .IsPostgresql}}\n \"postgresql\": {\n\t\t \"aws\": {\n\t\t\t\"server\": \"\",\n\t\t\t\"port\": 5432,\n\t\t\t\"dbname\": \"\",\n\t\t\t\"username\": \"\",\n\t\t\t\"password\": \"\",\n\t\t\t\"maxidleconnections\": 10,\n\t\t\t\"maxopenconnections\": 100,\n\t\t\t\"debug\": true\n\t\t }\n\t\t}\n {{else if .IsRethinkDB}}\n\t\t\"rethinkdb\": {\n\t\t \"aws\": {\n\t\t \"addresses\":\"\",\n\t\t \"dbname\": \"\",\n\t\t \"authkey\": \"\",\n\t\t \"discoverhosts\": false,\n\t\t \"maxidleconnections\": 10,\n\t\t \"maxopenconnections\": 100,\n\t\t \"debug\": true\n\t\t}\n\t}{{end}}\n }\n}`\n}", "func jsonPrint(w http.ResponseWriter, out []string) {\n\tjsondat := &myJSON{Array: out}\n\tencjson, _ := json.Marshal(jsondat)\n\tfmt.Fprintf(w, \"%q\", string(encjson))\n}", "func SettingEnCodeJSON(configPath string, pa *Setting) error {\n\tfile, err := os.Create(configPath + \"/SsrMicroConfig.json\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tenc := json.NewEncoder(file)\n\tenc.SetIndent(\"\", \" \")\n\tif err := enc.Encode(&pa); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func DumpMakeVars(ctx Context, config Config, goals, vars []string) (map[string]string, error) {\n\tsoongUiVars := map[string]func() string{\n\t\t\"OUT_DIR\": func() string { return config.OutDir() },\n\t\t\"DIST_DIR\": func() string { return config.DistDir() },\n\t\t\"TMPDIR\": func() string { return absPath(ctx, config.TempDir()) },\n\t}\n\n\tmakeVars := make([]string, 0, len(vars))\n\tfor _, v := range vars {\n\t\tif _, ok := soongUiVars[v]; !ok {\n\t\t\tmakeVars = append(makeVars, v)\n\t\t}\n\t}\n\n\tvar ret map[string]string\n\tif len(makeVars) > 0 {\n\t\t// It's not safe to use the same TMPDIR as the build, as that can be removed.\n\t\ttmpDir, err := ioutil.TempDir(\"\", \"dumpvars\")\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer os.RemoveAll(tmpDir)\n\n\t\tSetupLitePath(ctx, config, tmpDir)\n\n\t\tret, err = dumpMakeVars(ctx, config, goals, makeVars, false, tmpDir)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\t} else {\n\t\tret = make(map[string]string)\n\t}\n\n\tfor _, v := range vars {\n\t\tif f, ok := soongUiVars[v]; ok {\n\t\t\tret[v] = f()\n\t\t}\n\t}\n\n\treturn ret, nil\n}", "func (s *BuildahTestSession) OutputToJSON() []map[string]interface{} {\n\tvar i []map[string]interface{}\n\tif err := json.Unmarshal(s.Out.Contents(), &i); err != nil {\n\t\tfmt.Println(err)\n\t\treturn nil\n\t}\n\treturn i\n}", "func (co *CreateOptions) DevfileJSON() error {\n\tenvInfo, err := envinfo.NewEnvSpecificInfo(co.contextFlag)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Ignore the error as we want other information if connection to cluster is not possible\n\tvar c kclient.ClientInterface\n\tclient, _ := kclient.New()\n\tif client != nil {\n\t\tc = client\n\t}\n\tcfd, err := component.NewComponentFullDescriptionFromClientAndLocalConfigProvider(c, envInfo, envInfo.GetName(), envInfo.GetApplication(), co.GetProject(), co.GetComponentContext())\n\tif err != nil {\n\t\treturn err\n\t}\n\tmachineoutput.OutputSuccess(cfd.GetComponent())\n\treturn nil\n}", "func (u configExportMessage) JSON() string {\n\tu.Status = \"success\"\n\tstatusJSONBytes, e := json.MarshalIndent(u, \"\", \" \")\n\tfatalIf(probe.NewError(e), \"Unable to marshal into JSON.\")\n\n\treturn string(statusJSONBytes)\n}", "func ( fq *Fq_req ) To_json( ) ( *string, error ) {\n\tjbytes, err := json.Marshal( fq )\t\t\t// bundle into a json string\n\n\ts := string( jbytes )\n\n\treturn &s, err\n}", "func dumpVarConfig(ctx build.Context, args ...string) build.Config {\n\treturn build.NewConfig(ctx)\n}", "func (component *Component) JSONSpecs() (string, error) {\n\tcomponentObject := component.Export()\n\tcomponentObject.Status.Conditions = commonv1alpha1.ConditionList{}\n\tjsonSpecs, err := json.Marshal(componentObject)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(jsonSpecs), nil\n}", "func (tasks *TaskFile) Export() {\n\tvar pattern string\n\tswitch runtime.GOOS {\n\tcase \"windows\":\n\t\tpattern = \"$env:%s='%s'\"\n\tcase \"darwin\", \"linux\":\n\t\tpattern = \"export %s='%s'\"\n\tdefault:\n\t\tlogger.Fatal(\"export\", fmt.Errorf(\"unsupported platform %s\", runtime.GOOS))\n\t}\n\tfor _, v := range tasks.TemplateVars.List {\n\t\tfmt.Println(fmt.Sprintf(pattern, v.Key, os.Getenv(v.Key)))\n\t}\n}", "func (w *RandomWorld) BeingsToJSON(fileName string) {\n\tfi, _ := os.Create(fileName)\n\tdefer fi.Close()\n\tfz := NewWriter(fi)\n\te := NewEncoder(fz)\n\n\tif err := e.Encode(w.BeingList); err != nil {\n\t\tpanic(err)\n\t}\n}", "func SVar(v interface{}) string {\n\ts, err := json.Marshal(v)\n\t// s, err := json.MarshalIndent ( v, \"\", \"\\t\" )\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"Error:%s\", err)\n\t} else {\n\t\treturn string(s)\n\t}\n}", "func SVar(v interface{}) string {\n\ts, err := json.Marshal(v)\n\t// s, err := json.MarshalIndent ( v, \"\", \"\\t\" )\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"Error:%s\", err)\n\t} else {\n\t\treturn string(s)\n\t}\n}", "func SVar(v interface{}) string {\n\ts, err := json.Marshal(v)\n\t// s, err := json.MarshalIndent ( v, \"\", \"\\t\" )\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"Error:%s\", err)\n\t} else {\n\t\treturn string(s)\n\t}\n}", "func (a *MyAccount) ExportJSON(passw string) ([]byte, error) {\n\tenc, err := a.Keys.GetEncrypted(passw)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn json.Marshal(&struct {\n\t\tName string `json:\"name\"`\n\t\tFields map[string]string `json:\"fields\"`\n\t\tKeys string `json:\"keys\"`\n\t}{\n\t\tName: a.Name,\n\t\tFields: a.Fields,\n\t\tKeys: HexEnc(enc),\n\t})\n}", "func (c Config) ToJSON() string {\n\tdata, _ := json.MarshalIndent(c, \"\", \"\\t\")\n\treturn string(data)\n}", "func (c *Check) toJSON() (string, error) {\n\tprobes, err := getProbeList()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tprobeIDs := []int{}\n\tfor _, probe := range (*c)[\"probes\"].([]interface{}) {\n\t\tprobeName := probe.(string)\n\t\tid := probes.ByName[probeName].ID\n\t\tprobeIDs = append(probeIDs, id)\n\t}\n\t(*c)[\"probes\"] = probeIDs\n\n\tj, err := json.MarshalIndent(c, \"\", \" \")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(j), nil\n}", "func printSecretJSON(secret *v1.Secret, targetData string, filterF filterFunc, flagMetadata bool) {\n\ttype metadata struct {\n\t\tName string\n\t\tType string\n\t\tLength int\n\t\tSize int\n\t}\n\ttype outjson struct {\n\t\tMetadata metadata `json:\"metadata\",omitempty`\n\t\tValues map[string]string `json:\"values\"`\n\t}\n\n\tsecs := outjson{Values: make(map[string]string)}\n\tfor _, sd := range filterF(secret.Data, targetData) {\n\t\tsecs.Values[sd.Key] = sd.Value\n\t}\n\n\tif flagMetadata {\n\t\tsecs.Metadata = metadata{Name: secret.Name, Type: string(secret.Type), Length: len(secret.Data), Size: secret.Size()}\n\t}\n\n\tsecretJSON, err := json.MarshalIndent(secs, \"\", \" \")\n\tif err != nil {\n\t\tprExit(err)\n\t}\n\tfmt.Fprintf(os.Stdout, \"%s\", secretJSON)\n}", "func (cmd Command) GenerateJSON() error {\n\tdbconf := cmd.Config.MysqlConfig\n\tcon, err := mysql.NewConnection(dbconf.Host, dbconf.Port, dbconf.User, dbconf.Password, dbconf.DbName, false)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer con.Close()\n\toutputPath := strings.Replace(cmd.Config.OutputJSONPath, \"{dbname}\", cmd.Config.MysqlConfig.DbName, -1)\n\treturn writeTablesJSON(con, outputPath)\n}", "func (p *AwsProvider) getInstallerVars() Values {\n\treturn Values{\n\t\t\"REGION\": p.region,\n\t}\n}", "func (o CustomDataExporter) JSON(ctx context.Context, w io.Writer, indent string) error {\n\tq := sqlutil.Select(\n\t\t\"cve_id\",\n\t\t\"cve_json\",\n\t).From(\n\t\t\"custom_data\",\n\t).Where(\n\t\to.condition(),\n\t)\n\n\tquery, args := q.String(), q.QueryArgs()\n\n\tif debug.V(1) {\n\t\tflog.Infof(\"running: %q / %#v\", query, args)\n\t}\n\n\trows, err := o.DB.QueryContext(ctx, query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"cannot query vendor data\")\n\t}\n\n\tdefer rows.Close()\n\n\trecord := struct {\n\t\tCVE string\n\t\tJSON []byte\n\t}{}\n\n\tf := &cveFile{}\n\tfor rows.Next() {\n\t\tv := record\n\t\terr = rows.Scan(sqlutil.NewRecordType(&v).Values()...)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"cannot scan vendor data\")\n\t\t}\n\n\t\terr = f.Add(v.CVE, v.JSON)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif indent == \"\" {\n\t\treturn f.EncodeJSON(w)\n\t}\n\n\tconst prefix = \"\"\n\treturn f.EncodeIndentedJSON(w, prefix, indent)\n}", "func (o WebhooksIntegrationCustomVariableResponse) MarshalJSON() ([]byte, error) {\n\ttoSerialize := map[string]interface{}{}\n\tif o.UnparsedObject != nil {\n\t\treturn json.Marshal(o.UnparsedObject)\n\t}\n\ttoSerialize[\"is_secret\"] = o.IsSecret\n\ttoSerialize[\"name\"] = o.Name\n\tif o.Value != nil {\n\t\ttoSerialize[\"value\"] = o.Value\n\t}\n\n\tfor key, value := range o.AdditionalProperties {\n\t\ttoSerialize[key] = value\n\t}\n\treturn json.Marshal(toSerialize)\n}", "func (o *Recordingsettings) String() string {\n \n \n \n\n j, _ := json.Marshal(o)\n str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\\\u`, `\\u`, -1))\n\n return str\n}", "func (so SessionOptions) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\tif so.Tags != nil {\n\t\tobjectMap[\"tags\"] = so.Tags\n\t}\n\tif so.ArtifactID != nil {\n\t\tobjectMap[\"artifactId\"] = so.ArtifactID\n\t}\n\tif so.Name != nil {\n\t\tobjectMap[\"name\"] = so.Name\n\t}\n\tif so.File != nil {\n\t\tobjectMap[\"file\"] = so.File\n\t}\n\tif so.ClassName != nil {\n\t\tobjectMap[\"className\"] = so.ClassName\n\t}\n\tif so.Arguments != nil {\n\t\tobjectMap[\"args\"] = so.Arguments\n\t}\n\tif so.Jars != nil {\n\t\tobjectMap[\"jars\"] = so.Jars\n\t}\n\tif so.PythonFiles != nil {\n\t\tobjectMap[\"pyFiles\"] = so.PythonFiles\n\t}\n\tif so.Files != nil {\n\t\tobjectMap[\"files\"] = so.Files\n\t}\n\tif so.Archives != nil {\n\t\tobjectMap[\"archives\"] = so.Archives\n\t}\n\tif so.Configuration != nil {\n\t\tobjectMap[\"conf\"] = so.Configuration\n\t}\n\tif so.DriverMemory != nil {\n\t\tobjectMap[\"driverMemory\"] = so.DriverMemory\n\t}\n\tif so.DriverCores != nil {\n\t\tobjectMap[\"driverCores\"] = so.DriverCores\n\t}\n\tif so.ExecutorMemory != nil {\n\t\tobjectMap[\"executorMemory\"] = so.ExecutorMemory\n\t}\n\tif so.ExecutorCores != nil {\n\t\tobjectMap[\"executorCores\"] = so.ExecutorCores\n\t}\n\tif so.ExecutorCount != nil {\n\t\tobjectMap[\"numExecutors\"] = so.ExecutorCount\n\t}\n\treturn json.Marshal(objectMap)\n}", "func (s) TestJSONEnvVarSet(t *testing.T) {\n\tconfigJSON := `{\n\t\t\"project_id\": \"fake\"\n\t}`\n\tcleanup, err := createTmpConfigInFileSystem(configJSON)\n\tdefer cleanup()\n\n\tif err != nil {\n\t\tt.Fatalf(\"failed to create config in file system: %v\", err)\n\t}\n\tctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)\n\tdefer cancel()\n\tif err := Start(ctx); err != nil {\n\t\tt.Fatalf(\"error starting observability with valid config through file system: %v\", err)\n\t}\n\tdefer End()\n}", "func ExportConfigVars() {\n\tconf := Get()\n\texportConfigVar(\"addr\", conf.ListenAddr)\n\texportConfigVar(\"db\", conf.DB)\n\texportConfigVar(\"public-url\", conf.PublicURL)\n\texportConfigVar(\"delay\", conf.Delay.String())\n\texportConfigVar(\"timeout\", conf.Timeout.String())\n\texportConfigVar(\"cache-retention\", conf.CacheRetention.String())\n}", "func (a TemplateApply_Secrets) MarshalJSON() ([]byte, error) {\n\tvar err error\n\tobject := make(map[string]json.RawMessage)\n\n\tfor fieldName, field := range a.AdditionalProperties {\n\t\tobject[fieldName], err = json.Marshal(field)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, fmt.Sprintf(\"error marshaling '%s'\", fieldName))\n\t\t}\n\t}\n\treturn json.Marshal(object)\n}", "func export(w http.ResponseWriter, export *ProjectInfo) CustError {\n\thttp.Header.Add(w.Header(), \"content-type\", \"application/json\")\n\n\tvar output = ExportInfo{}\n\n\toutput.Langs = make([]string, 0, len((*export).Langs))\n\n\t// Check vital data\n\terr := checkVitalData(export)\n\tif err.status != 0 {\n\t\treturn CustError{http.StatusPartialContent, \": Some vital values are empty or nonexistent\"}\n\t}\n\n\t// map[string]interface{} to []string convertion\n\tfor k := range (*export).Langs {\n\t\toutput.Langs = append(output.Langs, k)\n\t}\n\n\tsort.Strings(output.Langs)\n\n\toutput.Name = (*export).Name\n\toutput.Owner = (*export).Owner.Login\n\toutput.Contrib = (*export).TopContrib[0].Name\n\toutput.Commits = (*export).TopContrib[0].Commits\n\n\terrEncode := json.NewEncoder(w).Encode(output)\n\n\t// Encoding failed\n\tif errEncode != nil {\n\t\treturn CustError{http.StatusInternalServerError, errorStr[7]}\n\t}\n\n\t// Nothing bad happened\n\treturn CustError{0, errorStr[0]}\n}", "func (pc *BasicECSPodCreator) exportEnvVars(envVars []cocoa.EnvironmentVariable) []*ecs.KeyValuePair {\n\tvar converted []*ecs.KeyValuePair\n\n\tfor _, envVar := range envVars {\n\t\tif envVar.SecretOpts != nil {\n\t\t\tcontinue\n\t\t}\n\t\tvar pair ecs.KeyValuePair\n\t\tpair.SetName(utility.FromStringPtr(envVar.Name)).SetValue(utility.FromStringPtr(envVar.Value))\n\t\tconverted = append(converted, &pair)\n\t}\n\n\treturn converted\n}", "func marshalVestingData(data cli.VestingData) ([]byte, error) {\n\treturn json.MarshalIndent(data, \"\", \" \")\n}", "func WriteJSONConfig(conf *Config) {\n\tfile, err := os.Create(settingsFile)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer file.Close()\n\tstr, err := json.MarshalIndent(conf, \"\", \" \")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfile.Write(str)\n\tfile.WriteString(\"\\n\")\n}", "func (o *ExportDataPartial) Stringify() string {\n\treturn pjson.Stringify(o.ToMap())\n}", "func (o *Launcherbuttonsettings) String() string {\n \n\n j, _ := json.Marshal(o)\n str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\\\u`, `\\u`, -1))\n\n return str\n}", "func (cfg *Config) ToJSON() string {\n\tbyt, _ := json.Marshal(cfg)\n\treturn string(byt)\n}", "func (v EventApplicationVariableAdd) MarshalEasyJSON(w *jwriter.Writer) {\n\teasyjson4c51a5cdEncodeGithubComOvhCdsSdk5(w, v)\n}", "func genConfig() ([]byte, error) {\n\t// Using genflags.getConfig() instead of config.New() because\n\t// it will include any defaults we have on the command line such\n\t// as default plugin selection. We didn't want to wire this into\n\t// the `config` package, but it will be a default value the CLI\n\t// users expect.\n\tc := genflags.resolveConfig()\n\tb, err := json.Marshal(c)\n\treturn b, errors.Wrap(err, \"unable to marshal configuration\")\n}", "func CreateDockerconfigjson(host, username, password string) []byte {\n\tauth := base64.StdEncoding.EncodeToString([]byte(username + \":\" + password))\n\tout := fmt.Sprintf(`{\"auths\":{\"%s\":{\"auth\": \"%s\"}}}`, host, auth)\n\treturn []byte(out)\n}", "func (m VariableMultipliersServerExecutionOptions) MarshalJSON() ([]byte, error) {\n\t_parts := make([][]byte, 0, 1)\n\n\taO0, err := swag.WriteJSON(m.ServerTargetExecutionOptions)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t_parts = append(_parts, aO0)\n\n\t// now for regular properties\n\tvar propsVariableMultipliersServerExecutionOptions struct {\n\t\tContinueOnError bool `json:\"continueOnError,omitempty\"`\n\n\t\tMaxConcurrency int32 `json:\"maxConcurrency,omitempty\"`\n\n\t\tMultipliers []string `json:\"multipliers\"`\n\t}\n\tpropsVariableMultipliersServerExecutionOptions.ContinueOnError = m.ContinueOnError\n\n\tpropsVariableMultipliersServerExecutionOptions.MaxConcurrency = m.MaxConcurrency\n\n\tpropsVariableMultipliersServerExecutionOptions.Multipliers = m.Multipliers\n\n\tjsonDataPropsVariableMultipliersServerExecutionOptions, errVariableMultipliersServerExecutionOptions := swag.WriteJSON(propsVariableMultipliersServerExecutionOptions)\n\tif errVariableMultipliersServerExecutionOptions != nil {\n\t\treturn nil, errVariableMultipliersServerExecutionOptions\n\t}\n\t_parts = append(_parts, jsonDataPropsVariableMultipliersServerExecutionOptions)\n\treturn swag.ConcatJSON(_parts...), nil\n}", "func (o *Webdeployment) String() string {\n \n \n \n o.AllowedDomains = []string{\"\"} \n \n \n \n\n j, _ := json.Marshal(o)\n str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\\\u`, `\\u`, -1))\n\n return str\n}", "func GenerateJSONReport(report analyzer.VulnerabilityReport) {\n\tdata, err := json.MarshalIndent(report, \"\", \" \")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(string(data))\n}", "func (conf Config) JSON() []byte {\n\tb, err := json.Marshal(&conf)\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\treturn b\n}", "func (o *ExportData) Stringify() string {\n\to.Hash()\n\treturn pjson.Stringify(o)\n}", "func (obj *JSONObject) Export() json.RawMessage {\n\tstr, _ := json.Marshal(obj)\n\treturn str\n}", "func writeD3JSON(w io.Writer, pkgs *map[string][]string) error {\n\td3pkgs := pkgsToD3Pkgs(pkgs)\n\tenc := json.NewEncoder(w)\n\n\tw.Write([]byte(\"[\"))\n\tfirst := true\n\tfor _, p := range *d3pkgs {\n\t\tif first {\n\t\t\tfirst = false\n\t\t} else {\n\t\t\tw.Write([]byte(\",\"))\n\t\t}\n\n\t\tif err := enc.Encode(p); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tw.Write([]byte(\"]\"))\n\treturn nil\n}", "func (configVarString ConfigVarString) MarshalJSON() ([]byte, error) {\n\tvar secretKeyRefEmpty, configMapKeyRefEmpty bool\n\tif configVarString.SecretKeyRef.ObjectReference.Namespace == \"\" &&\n\t\tconfigVarString.SecretKeyRef.ObjectReference.Name == \"\" &&\n\t\tconfigVarString.SecretKeyRef.Key == \"\" {\n\t\tsecretKeyRefEmpty = true\n\t}\n\n\tif configVarString.ConfigMapKeyRef.ObjectReference.Namespace == \"\" &&\n\t\tconfigVarString.ConfigMapKeyRef.ObjectReference.Name == \"\" &&\n\t\tconfigVarString.ConfigMapKeyRef.Key == \"\" {\n\t\tconfigMapKeyRefEmpty = true\n\t}\n\n\tif secretKeyRefEmpty && configMapKeyRefEmpty {\n\t\treturn []byte(fmt.Sprintf(`\"%s\"`, configVarString.Value)), nil\n\t}\n\n\tbuffer := bytes.NewBufferString(\"{\")\n\tif !secretKeyRefEmpty {\n\t\tjsonVal, err := json.Marshal(configVarString.SecretKeyRef)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tbuffer.WriteString(fmt.Sprintf(`\"secretKeyRef\":%s`, string(jsonVal)))\n\t}\n\n\tif !configMapKeyRefEmpty {\n\t\tvar leadingComma string\n\t\tif !secretKeyRefEmpty {\n\t\t\tleadingComma = \",\"\n\t\t}\n\t\tjsonVal, err := json.Marshal(configVarString.ConfigMapKeyRef)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tbuffer.WriteString(fmt.Sprintf(`%s\"configMapKeyRef\":%s`, leadingComma, jsonVal))\n\t}\n\n\tif configVarString.Value != \"\" {\n\t\tbuffer.WriteString(fmt.Sprintf(`,\"value\":\"%s\"`, configVarString.Value))\n\t}\n\n\tbuffer.WriteString(\"}\")\n\treturn buffer.Bytes(), nil\n}", "func (environment *Environment) String() string {\n\tmarshaledVal, _ := json.MarshalIndent(*environment, \"\", \" \") // Marshal to JSON\n\n\treturn string(marshaledVal) // Return string value\n}", "func (env *Env) GenerateStage1JSON(rw http.ResponseWriter, req *http.Request) {\n\thostname := mux.Vars(req)[\"hostname\"]\n\n\t// Use hostname as key to load record from Datastore.\n\thost, err := env.Config.Load(hostname)\n\tif err != nil {\n\t\thttp.Error(rw, err.Error(), http.StatusNotFound)\n\t\treturn\n\t}\n\n\terr = env.requestIsFromHost(req, host)\n\tif err != nil {\n\t\thttp.Error(rw, err.Error(), http.StatusForbidden)\n\t\treturn\n\t}\n\n\t// TODO(soltesz):\n\t// * Save information sent in PostForm.\n\n\t// Generate new session IDs.\n\thost.GenerateSessionIDs()\n\n\t// Count all requests for the stage1 target.\n\tmetrics.Stage1Total.WithLabelValues(host.Name).Inc()\n\n\t// Save host record to Datastore to commit session IDs.\n\tif err := env.Config.Save(host); err != nil {\n\t\thttp.Error(rw, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Generate epoxy client JSON action.\n\tscript := template.CreateStage1Action(host, env.ServerAddr)\n\n\t// Complete request as successful.\n\trw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\trw.WriteHeader(http.StatusOK)\n\t_, err = fmt.Fprintf(rw, script)\n\tif err != nil {\n\t\tlog.Printf(\"Failed to write response to %q: %v\", hostname, err)\n\t}\n\treturn\n}", "func WriteFileAsJsonBeauty(path string, v interface{}, coverage bool) error {\n\treturn WriteFileAsJson(path, v, os.FileMode(0666), coverage, true)\n}", "func ToJSON(v interface{}) string {\n\tjsonText, _ := json.MarshalIndent(v, \"\", \"\\t\")\n\treturn string(jsonText)\n}", "func DumpJSON(iamfile string) (content string, err error) {\n\tpd, err := Parse(iamfile)\n\tif err != nil {\n\t\treturn content, err\n\t}\n\tbc, err := json.MarshalIndent(pd, \"\", \" \")\n\tif err != nil {\n\t\treturn content, err\n\t}\n\tcontent = string(bc)\n\treturn content, nil\n}", "func (obj *JSONObjectArray) Export() json.RawMessage {\n\tstr, _ := json.Marshal(obj)\n\treturn str\n}", "func (m *Meta) JSON() string {\n\tj, _ := json.MarshalIndent(m, \"\", \" \")\n\treturn string(j)\n}", "func OptionsToJSON(opts *ExporterOptions) (string, error) {\n\tif opts == nil {\n\t\treturn \"\", nil\n\t}\n\n\tjsonOpts, err := json.Marshal(opts)\n\treturn string(jsonOpts), err\n}", "func (c Capabilities) JSON() (string, error) {\n\tcapabilitiesJSON, err := json.Marshal(c)\n\treturn string(capabilitiesJSON), err\n}", "func (m ApplianceSetupInfo) MarshalJSON() ([]byte, error) {\n\t_parts := make([][]byte, 0, 2)\n\n\taO0, err := swag.WriteJSON(m.MoBaseMo)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t_parts = append(_parts, aO0)\n\n\tvar dataAO1 struct {\n\t\tAccount *IamAccountRef `json:\"Account,omitempty\"`\n\n\t\tBuildType string `json:\"BuildType,omitempty\"`\n\n\t\tCloudURL string `json:\"CloudUrl,omitempty\"`\n\n\t\tEndTime strfmt.DateTime `json:\"EndTime,omitempty\"`\n\n\t\tSetupStates []string `json:\"SetupStates\"`\n\n\t\tStartTime strfmt.DateTime `json:\"StartTime,omitempty\"`\n\t}\n\n\tdataAO1.Account = m.Account\n\n\tdataAO1.BuildType = m.BuildType\n\n\tdataAO1.CloudURL = m.CloudURL\n\n\tdataAO1.EndTime = m.EndTime\n\n\tdataAO1.SetupStates = m.SetupStates\n\n\tdataAO1.StartTime = m.StartTime\n\n\tjsonDataAO1, errAO1 := swag.WriteJSON(dataAO1)\n\tif errAO1 != nil {\n\t\treturn nil, errAO1\n\t}\n\t_parts = append(_parts, jsonDataAO1)\n\n\treturn swag.ConcatJSON(_parts...), nil\n}", "func JsonOutput(data interface{}) {\n\tjson.NewEncoder(os.Stdout).Encode(data)\n}", "func NewTfvarsJSON(config *print.Config) Type {\n\treturn &tfvarsJSON{\n\t\tgenerator: newGenerator(config, false),\n\t\tconfig: config,\n\t}\n}", "func ExportToJSON(jiraFile string, userMaps []UserMap, projectMaps []ProjectMap, token string, exportFile string) error {\r\n\texport, err := GetDataFromXMLFile(jiraFile)\r\n\tif err != nil {\r\n\t\treturn err\r\n\t}\r\n\tdata, err := json.Marshal(export.GetDataForClubhouse(userMaps, projectMaps, token))\r\n\tif err != nil {\r\n\t\treturn err\r\n\t}\r\n\terr = ioutil.WriteFile(exportFile, data, 0644)\r\n\tif err != nil {\r\n\t\treturn err\r\n\t}\r\n\treturn nil\r\n}", "func toJson(v interface{}) string {\n\toutput, _ := json.Marshal(v)\n\treturn string(output)\n}", "func GetCredsAsJSON() (string, error) {\n\tfmt.Println(s.LogPrefix + \"GOT\")\n\treturn \"{}\", nil\n}", "func JSON(data interface{}, args ...interface{}) string {\n\tw := Writer{\n\t\tOptions: ojg.DefaultOptions,\n\t\tWidth: 80,\n\t\tMaxDepth: 3,\n\t\tSEN: false,\n\t}\n\tw.config(args)\n\tb, _ := w.encode(data)\n\n\treturn string(b)\n}", "func (s *Switch) To_json( ) ( jstr string ) {\n\tvar sep = \"\"\n\n\tif s == nil {\n\t\tjstr = `{ id: \"null_switch\" }`\n\t\treturn\n\t}\n\n\tif s.lidx > 0 {\n\t\tjstr = fmt.Sprintf( `{ \"id\": %q, \"links\": [ `, *s.id )\n\n\t\tfor i := 0; i < s.lidx; i++ {\n\t\t\tjstr += fmt.Sprintf( \"%s%s\", sep, s.links[i].To_json() )\n\t\t\tsep = \",\"\n\t\t}\n\t\tjstr += \" ]\"\n\t} else {\n\t\tjstr = fmt.Sprintf( `{ \"id\": %q }`, *s.id )\n\t}\n\n\n\tif len( s.hosts ) > 0 {\n\t\tjstr += fmt.Sprintf( `, \"conn_hosts\": [ ` )\n\t\tsep = \"\"\n\t\tfor k := range s.hosts {\n\t\t\tif s.hosts[k] == true {\n\t\t\t\tvmid := \"unknown\"\n\t\t\t\tif s.hvmid[k] != nil {\n\t\t\t\t\tvmid = *s.hvmid[k]\n\t\t\t\t}\n\t\t\t\tjstr += fmt.Sprintf( `%s { \"host\": %q, \"port\": %d, \"vmid\": %q }`, sep, k, s.hport[k], vmid )\n\t\t\t\tsep = \",\"\n\t\t\t}\n\t\t}\n\t\tjstr += \" ]\"\n\t}\n\n\tjstr += \" }\"\n\treturn\n}", "func SVar(v interface{}) string {\n\ts, err := json.Marshal(v)\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"Error:%s\", err)\n\t}\n\treturn string(s)\n}", "func (o *Crossplatformpolicycreate) String() string {\n \n \n \n \n \n \n \n \n \n \n\n j, _ := json.Marshal(o)\n str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\\\u`, `\\u`, -1))\n\n return str\n}", "func (o *Createperformanceprofile) String() string {\n \n \n \n o.ReportingIntervals = []Reportinginterval{{}} \n \n \n\n j, _ := json.Marshal(o)\n str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\\\u`, `\\u`, -1))\n\n return str\n}", "func GenerateJSON(articles Collections) {\n\tdefer wg.Done()\n\tdatas := make([]map[string]interface{}, 0)\n\tfor i, _ := range articles {\n\t\tarticle := articles[i].(Article)\n\t\tvar data = map[string]interface{}{\n\t\t\t\"title\": article.Title,\n\t\t\t\"content\": article.Markdown,\n\t\t\t\"preview\": string(article.Preview),\n\t\t\t\"link\": article.Link,\n\t\t\t\"cover\": article.Cover,\n\t\t}\n\t\tdatas = append(datas, data)\n\t}\n\tstr, _ := json.Marshal(datas)\n\tioutil.WriteFile(filepath.Join(publicPath, \"index.json\"), []byte(str), 0644)\n}", "func (ed EtcdDump) PrintDataAsJSON(filter []string) (*bytes.Buffer, error) {\n\tbuffer := new(bytes.Buffer)\n\tkeys := ed.getSortedKeys()\n\tvar wasError error\n\n\tvpps, isData := processFilter(keys, filter)\n\tif !isData {\n\t\tfmt.Fprintf(buffer, \"No data to display for VPPS: %s\\n\", vpps)\n\t\treturn buffer, wasError\n\t}\n\n\tfor _, key := range keys {\n\t\tif isNotInFilter(key, vpps) {\n\t\t\tcontinue\n\t\t}\n\n\t\tvd, _ := ed[key]\n\t\t// Obtain raw data\n\t\tifaceConfDataRoot, ifaceConfKeys := getInterfaceConfigData(vd.Interfaces)\n\t\tifaceStateDataRoot, ifaceStateKeys := getInterfaceStateData(vd.Interfaces)\n\t\tl2ConfigDataRoot, l2Keys := getL2ConfigData(vd.BridgeDomains)\n\t\tl2StateDataRoot, l2Keys := getL2StateData(vd.BridgeDomains)\n\t\tl2FibDataRoot, l2FibKeys := getL2FIBData(vd.FibTableEntries)\n\t\tl3FibDataRoot, l3FibKeys := getL3FIBData(vd.StaticRoutes)\n\n\t\t// Interface config data\n\t\tjsConfData, err := json.MarshalIndent(ifaceConfDataRoot, \"\", indent)\n\t\tif err != nil {\n\t\t\twasError = err\n\t\t}\n\t\t// Interface state data\n\t\tjsStateData, err := json.MarshalIndent(ifaceStateDataRoot, \"\", indent)\n\t\tif err != nil {\n\t\t\twasError = err\n\t\t}\n\t\t// L2 config data\n\t\tjsL2ConfigData, err := json.MarshalIndent(l2ConfigDataRoot, \"\", indent)\n\t\tif err != nil {\n\t\t\twasError = err\n\t\t}\n\t\t// L2 state data\n\t\tjsL2StateData, err := json.MarshalIndent(l2StateDataRoot, \"\", indent)\n\t\tif err != nil {\n\t\t\twasError = err\n\t\t}\n\t\t// L2 FIB data\n\t\tjsL2FIBData, err := json.MarshalIndent(l2FibDataRoot, \"\", indent)\n\t\tif err != nil {\n\t\t\twasError = err\n\t\t}\n\t\t// L3 FIB data\n\t\tjsL3FIBData, err := json.MarshalIndent(l3FibDataRoot, \"\", indent)\n\t\tif err != nil {\n\t\t\twasError = err\n\t\t}\n\n\t\t// Add data to buffer\n\t\tif string(jsConfData) != emptyJSON {\n\t\t\tprintLabel(buffer, key+\": - \"+IfConfig+\"\\n\", indent, ifaceConfKeys)\n\t\t\tfmt.Fprintf(buffer, \"%s\\n\", jsConfData)\n\t\t}\n\t\tif string(jsStateData) != emptyJSON {\n\t\t\tprintLabel(buffer, key+\": - \"+IfState+\"\\n\", indent, ifaceStateKeys)\n\t\t\tfmt.Fprintf(buffer, \"%s\\n\", jsStateData)\n\t\t}\n\t\tif string(jsL2ConfigData) != emptyJSON {\n\t\t\tprintLabel(buffer, key+\": - \"+BdConfig+\"\\n\", indent, l2Keys)\n\t\t\tfmt.Fprintf(buffer, \"%s\\n\", jsL2ConfigData)\n\t\t}\n\t\tif string(jsL2ConfigData) != emptyJSON {\n\t\t\tprintLabel(buffer, key+\": - \"+BdState+\"\\n\", indent, l2Keys)\n\t\t\tfmt.Fprintf(buffer, \"%s\\n\", jsL2StateData)\n\t\t}\n\t\tif string(jsL2FIBData) != emptyJSON {\n\t\t\tprintLabel(buffer, key+\": -\"+L2FibConfig+\"\\n\", indent, l2FibKeys)\n\t\t\tfmt.Fprintf(buffer, \"%s\\n\", jsL2FIBData)\n\t\t}\n\t\tif string(jsL3FIBData) != emptyJSON {\n\t\t\tprintLabel(buffer, key+\": - \"+L3FibConfig+\"\\n\", indent, l3FibKeys)\n\t\t\tfmt.Fprintf(buffer, \"%s\\n\", jsL3FIBData)\n\t\t}\n\n\t}\n\n\treturn buffer, wasError\n}", "func GoodJSONConfFile(t *testing.T) string {\n\tt.Helper()\n\n\tgoodJSONConfFile := `[\n\t\t{\n\t\t\t\"TableName\" : \"UserAccounts\",\n\t\t\t\"Filter\" : \"LOG0 = 'UserAccounts'\",\n\t\t\t\"DeleteMarkerField\": \"__DELETE__\",\n\t\t\t\"FieldMappings\" : [\n\t\t\t\t{\"Field\": \"userAddress\" , \"ColumnName\" : \"address\", \"Type\": \"address\", \"Primary\" : true},\n\t\t\t\t{\"Field\": \"userName\", \"ColumnName\" : \"username\", \"Type\": \"string\", \"Primary\" : false},\n\t\t\t\t{\"Field\": \"userId\", \"ColumnName\" : \"userid\", \"Type\": \"uint256\", \"Primary\" : false},\n\t\t\t\t{\"Field\": \"userBool\", \"ColumnName\" : \"userbool\", \"Type\": \"bool\", \"Primary\" : false}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\"TableName\" : \"TEST_TABLE\",\n\t\t\"Filter\" : \"Log1Text = 'EVENT_TEST'\",\n\t\t\"DeleteMarkerField\": \"__DELETE__\",\n\t\t\"FieldMappings\" : [\n\t\t\t{\"Field\": \"key\", \"ColumnName\": \"Index\", \"Type\": \"uint256\", \"Primary\" : true},\n\t\t\t{\"Field\": \"blocknum\", \"ColumnName\": \"Block\", \"Type\": \"uint256\", \"Primary\" : false},\n\t\t\t{\"Field\": \"somestr\", \"ColumnName\": \"String\", \"Type\": \"string\", \"Primary\" : false},\n\t\t\t{\"Field\": \"instance\", \"ColumnName\": \"Instance\", \"Type\": \"uint\", \"Primary\" : false}\n\t\t]\n\t}\n\t]`\n\n\treturn goodJSONConfFile\n}", "func ExportToJSON(jiraFile string, userMaps []userMap, exportFile string) error {\n\texport, err := GetDataFromXMLFile(jiraFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdata, err := json.Marshal(export.GetDataForClubhouse(userMaps))\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = ioutil.WriteFile(exportFile, data, 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}" ]
[ "0.631789", "0.5536032", "0.5465756", "0.5427909", "0.5401986", "0.5396326", "0.53941", "0.52809274", "0.5243702", "0.5160759", "0.5114038", "0.51007146", "0.5063309", "0.5053315", "0.5032404", "0.50227076", "0.50181514", "0.50147146", "0.49809915", "0.49705908", "0.49643305", "0.4943879", "0.4926636", "0.49177802", "0.49139273", "0.49124166", "0.49103403", "0.49052975", "0.48942322", "0.48896962", "0.48774108", "0.48632494", "0.48602974", "0.4857732", "0.48514712", "0.4839665", "0.48381713", "0.48337418", "0.48237562", "0.4821458", "0.48157516", "0.48145944", "0.48111966", "0.48111966", "0.48111966", "0.48061356", "0.48022595", "0.47908452", "0.47858936", "0.47822747", "0.47790614", "0.4778751", "0.4767777", "0.476044", "0.47594187", "0.47440776", "0.47410786", "0.47361434", "0.47295424", "0.4716763", "0.470707", "0.47002873", "0.4694725", "0.46880654", "0.46877056", "0.46828726", "0.46828133", "0.46808267", "0.46728736", "0.4672588", "0.46712622", "0.46706364", "0.4667177", "0.4665318", "0.4664608", "0.46623027", "0.46609366", "0.4657043", "0.46555054", "0.46499804", "0.46404088", "0.46391064", "0.46371663", "0.463494", "0.46338242", "0.46308997", "0.46232715", "0.46166867", "0.4611606", "0.4608811", "0.45984706", "0.4597358", "0.45916778", "0.45829463", "0.45824486", "0.45809102", "0.4580144", "0.45736146", "0.45698977", "0.4567798" ]
0.6818595
0
Import Setup Vars from JSON string
func (tpe *TPE) ImportSetup(JSON string) { // Unmarshal and load Config json.Unmarshal([]byte(JSON), &tpe.setup) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (obj *JSONObject) ImportString(str string) {\n\tobj.ImportRaw(json.RawMessage(str))\n}", "func (obj *JSONObject) ImportRaw(str json.RawMessage) {\n\terr := json.Unmarshal(str, &obj)\n\tif err != nil {\n\t\tdescribe(err)\n\t}\n}", "func (r *Vars) UnmarshalJSON(b []byte) error {\n\trawVars := make(map[string]interface{})\n\tif err := json.Unmarshal(b, &rawVars); err != nil {\n\t\tNewInvalidField(\"var\", err.Error())\n\t\treturn err\n\t}\n\tstringVars := make(Vars)\n\n\tfor key, v := range rawVars {\n\t\tswitch value := v.(type) {\n\t\tcase string, bool, float64:\n\t\t\tstringVars[key] = fmt.Sprintf(\"%v\", value)\n\t\tdefault:\n\t\t\treturn NewInvalidField(\"var\", fmt.Sprintf(\"value of key '%v' must be a string\", key))\n\t\t}\n\t}\n\t*r = stringVars\n\treturn nil\n}", "func (obj *JSONObjectArray) ImportString(str string) {\n\tobj.ImportRaw(json.RawMessage(str))\n}", "func LoadFromEnv(v interface{}, prefix string) (result []MarshalledEnvironmentVar) {\n\tpointerValue := reflect.ValueOf(v)\n\tstructValue := pointerValue.Elem()\n\tstructType := structValue.Type()\n\n\tfor i := 0; i < structValue.NumField(); i++ {\n\t\tstructField := structType.Field(i)\n\t\tfieldValue := structValue.Field(i)\n\n\t\tif fieldValue.CanSet() {\n\t\t\tenvKey := strings.ToUpper(prefix) + gocase.ToUpperSnake(structField.Name)\n\t\t\tenvVal := os.Getenv(envKey)\n\n\t\t\tif envVal != \"\" {\n\t\t\t\t// create a json blob with the env data\n\t\t\t\tjsonStr := \"\"\n\t\t\t\tif fieldValue.Kind() == reflect.String {\n\t\t\t\t\tjsonStr = fmt.Sprintf(`{\"%s\": \"%s\"}`, structField.Name, envVal)\n\t\t\t\t} else {\n\t\t\t\t\tjsonStr = fmt.Sprintf(`{\"%s\": %s}`, structField.Name, envVal)\n\t\t\t\t}\n\n\t\t\t\terr := json.Unmarshal([]byte(jsonStr), v)\n\t\t\t\tresult = append(result, MarshalledEnvironmentVar{envKey, envVal, structField.Name, err})\n\t\t\t}\n\t\t}\n\t}\n\n\treturn\n}", "func NewFromString(jsonString string) (*MinConf, error) {\n\tconst metaKey = \"$\"\n\tjsonString = removeComments(jsonString)\n\n\tvar m map[string]interface{}\n\terr := json.Unmarshal([]byte(jsonString), &m)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif m == nil {\n\t\treturn nil, errors.New(\"invalid configuration\")\n\t}\n\n\t// $ = minconf options\n\tmeta := m[metaKey].(map[string]interface{})\n\tif meta == nil {\n\t\treturn nil, errors.New(metaKey + \" property is required\")\n\t}\n\n\tvar options map[string]interface{}\n\tif meta[\"options\"] == nil {\n\t\toptions = make(map[string]interface{})\n\t} else {\n\t\toptions = meta[\"options\"].(map[string]interface{})\n\t}\n\n\tenvSelector := stringOr(options[\"envSelector\"], \"RUN_ENV\")\n\tdefaultEnv := stringOr(options[\"defaultEnv\"], \"development\")\n\tdotAlias := stringOr(options[\"dotAlias\"], \"__\")\n\n\tenvs := meta[\"envs\"].(map[string]interface{})\n\tif envs == nil {\n\t\treturn nil, errors.New(\"$.envs property is required\")\n\t}\n\n\t// get environment from selector\n\tenv := os.Getenv(envSelector)\n\tif env == \"\" {\n\t\tenv = defaultEnv\n\t}\n\n\tbase := make(map[string]interface{})\n\tfor key, mergeSpec := range envs {\n\t\tif key == env {\n\t\t\tmergeables := strings.Split(mergeSpec.(string), \" \")\n\t\t\tfor _, mergeable := range mergeables {\n\t\t\t\tvar src map[string]interface{}\n\n\t\t\t\tswitch mergeable {\n\t\t\t\tcase \"ARGV\":\n\t\t\t\t\tsrc, err = newArgvMap().Config()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\n\t\t\t\tcase \"ENV\":\n\t\t\t\t\tsrc, err = newEnvMap(dotAlias).Config()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t\t\tsrc = m[mergeable].(map[string]interface{})\n\t\t\t\t}\n\n\t\t\t\tif src != nil {\n\t\t\t\t\tbase, err = Merge(base, src)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t}\n\n\tnj := jo.NewFromMap(base)\n\tinternalMap := nj.Data().(map[string]interface{})\n\n\t// some keys have dots such as ENV keys that had \"__\" replaced with \".\"\n\tfor key, value := range internalMap {\n\t\tif strings.Contains(key, \".\") {\n\t\t\tdelete(internalMap, key)\n\t\t\tnj.Set(key, value)\n\t\t}\n\t}\n\n\tmc := &MinConf{Object: nj, EnvSelector: envSelector, DefaultEnv: defaultEnv, Env: env}\n\treturn mc, nil\n}", "func (us *UserStorage) ImportJSON(data []byte) error {\n\tud := []userData{}\n\tif err := json.Unmarshal(data, &ud); err != nil {\n\t\treturn err\n\t}\n\tfor _, u := range ud {\n\t\tpswd := u.Pswd\n\t\tu.Pswd = \"\"\n\t\tif _, err := us.AddNewUser(&User{userData: u}, pswd); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (us *UserStorage) ImportJSON(data []byte) error {\n\tud := []userData{}\n\tif err := json.Unmarshal(data, &ud); err != nil {\n\t\treturn err\n\t}\n\tfor _, u := range ud {\n\t\tpswd := u.Pswd\n\t\tu.Pswd = \"\"\n\t\t_, err := us.AddNewUser(&User{userData: u}, pswd)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (as *AppStorage) ImportJSON(data []byte) error {\n\tapd := []appData{}\n\tif err := json.Unmarshal(data, &apd); err != nil {\n\t\tlog.Println(\"Error unmarshalling app data:\", err)\n\t\treturn err\n\t}\n\tfor _, a := range apd {\n\t\tif _, err := as.addNewApp(&AppData{appData: a}); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (s) TestJSONEnvVarSet(t *testing.T) {\n\tconfigJSON := `{\n\t\t\"project_id\": \"fake\"\n\t}`\n\tcleanup, err := createTmpConfigInFileSystem(configJSON)\n\tdefer cleanup()\n\n\tif err != nil {\n\t\tt.Fatalf(\"failed to create config in file system: %v\", err)\n\t}\n\tctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)\n\tdefer cancel()\n\tif err := Start(ctx); err != nil {\n\t\tt.Fatalf(\"error starting observability with valid config through file system: %v\", err)\n\t}\n\tdefer End()\n}", "func ImportCloudConfigJson(path string) (*models.CloudConfigInfo, error) {\r\n\tinfoJSON, err := ioutil.ReadFile(path)\r\n\tif err != nil {\r\n\t\tConsoleOutput(fmt.Sprintf(\"failed to read file: %v\", err), stderr)\r\n\t\treturn &models.CloudConfigInfo{}, err\r\n\t}\r\n\r\n\t// Converting json to struct\r\n\tvar info models.CloudConfigInfo\r\n\tjson.Unmarshal(infoJSON, &info)\r\n\treturn &info, nil\r\n}", "func InitializeTestValues(s interface{}) interface{} {\r\n\tfields := reflect.ValueOf(s).Elem()\r\n\t// iterate across all configuration properties\r\n\tfor i := 0; i < fields.NumField(); i++ {\r\n\t\ttypeField := fields.Type().Field(i)\r\n\t\tenvironmentVariablesKey := typeField.Tag.Get(\"env\")\r\n\t\tif fields.Field(i).Kind() == reflect.String {\r\n\t\t\t// check if we want a property inside a complex object\r\n\t\t\tpropertyKey, exists := typeField.Tag.Lookup(\"property\")\r\n\t\t\tif exists {\r\n\t\t\t\t// get object string\r\n\t\t\t\tobjectString := os.Getenv(environmentVariablesKey)\r\n\t\t\t\t// grab property value inside string\r\n\t\t\t\tpropertyValue := getPropertyValueFromString(objectString, propertyKey)\r\n\t\t\t\t// set the value in the correct field\r\n\t\t\t\tfields.Field(i).SetString(propertyValue)\r\n\t\t\t} else {\r\n\t\t\t\tfields.Field(i).SetString(os.Getenv(environmentVariablesKey))\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn s\r\n}", "func (obj *JSONObjectArray) ImportRaw(str json.RawMessage) {\n\to := *obj\n\ttmp := [](map[string]interface{}){}\n\to = JSONObjectArray{}\n\terr := json.Unmarshal(str, &tmp)\n\tif err != nil {\n\t\tdescribe(err)\n\t}\n\tfor i := 0; i < len(tmp); i++ {\n\t\to = append(o, JSONObject(tmp[i]))\n\t}\n\t*obj = o\n}", "func SettingInitJSON(configPath string) error {\n\tpa := &Setting{\n\t\tAutoStartSsr: true,\n\t\tPythonPath: GetPythonPath(),\n\t\tSsrPath: GetPythonPath() + \" \" + configPath + \"/shadowsocksr/shadowsocks/local.py\",\n\t\tLocalAddress: \"127.0.0.1\",\n\t\tLocalPort: \"1080\",\n\t\tBypass: true,\n\t\tHttpProxy: true,\n\t\tHttpProxyAddressAndPort: \"127.0.0.1:8188\",\n\t\tSocks5WithBypassAddressAndPort: \"127.0.0.1:1083\",\n\n\t\tTimeOut: \"1000\",\n\t\tHttpWithBypass: true,\n\t\tBypassFile: configPath + \"/cidrBypass.conf\",\n\t\tBypassDomainFile: configPath + \"/domainBypass.conf\",\n\t\tDirectProxyFile: configPath + \"/domainProxy.conf\",\n\t\tDiscordDomainFile: configPath + \"/discordFile.conf\",\n\t\tSocks5WithBypass: true,\n\t\tDnsServer: \"8.8.8.8:53\",\n\t\tUdpTrans: true,\n\t\tPidFile: configPath + \"/shadowsocksr.pid\",\n\t\tLogFile: \"\",\n\t\tFastOpen: true,\n\t\tWorks: \"8\",\n\t}\n\tif err := SettingEnCodeJSON(configPath, pa); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func LoadFromJSON(r io.Reader) (*Meta, error) {\n\tm := &Meta{}\n\n\tif err := json.NewDecoder(r).Decode(m); err != nil {\n\t\treturn nil, fmt.Errorf(\"while decoding Meta JSON file: %s\", err)\n\t}\n\n\tm.cfg, _ = m.Config()\n\n\treturn m, nil\n}", "func loadSettings(payload []byte) (Settings, error) {\n\tvar settings Settings\n\terr := json.Unmarshal(payload, &settings)\n\tif err != nil {\n\t\treturn Settings{}, err\n\t}\n\treturn settings, nil\n}", "func testReadSettingJson() {\n\tf, _ := filepath.Abs(\"./settings.json\")\n\ts, err := ioutil.ReadFile(f)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tvar c Config\n\n\terr = json.Unmarshal(s, &c)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(c.Deliveries[0].Url)\n\tfmt.Println(c.Deliveries[0].Post)\n\tfmt.Println(c.Deliveries[1].Url)\n\tfmt.Println(c.Deliveries[1].Post)\n\tfmt.Println(c.Feeds[0].Url)\n\tfmt.Println(c.Feeds[0].Timestamp)\n\tfmt.Println(c.Feeds[0].Read)\n\tfmt.Println(c.Feeds[1].Url)\n\tfmt.Println(c.Feeds[1].Timestamp)\n\tfmt.Println(c.Feeds[1].Read)\n\n}", "func (ev Vars) ReadInto(obj interface{}) error {\n\tobjMeta := reflectType(obj)\n\n\tvar field reflect.StructField\n\tvar tag string\n\tvar envValue string\n\tvar defaultValue string\n\tvar err error\n\n\tfor x := 0; x < objMeta.NumField(); x++ {\n\t\tfield = objMeta.Field(x)\n\t\ttag = field.Tag.Get(TagNameEnvironmentVariableName)\n\n\t\tif len(tag) > 0 {\n\t\t\tenvValue = ev.String(tag)\n\t\t\tif len(envValue) > 0 {\n\t\t\t\terr = setValueByName(obj, field.Name, envValue)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdefaultValue = field.Tag.Get(TagNameEnvironmentVariableDefault)\n\t\t\t\tif len(defaultValue) > 0 {\n\t\t\t\t\terr = setValueByName(obj, field.Name, defaultValue)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (o *SyntheticsGlobalVariableParseTestOptions) UnmarshalJSON(bytes []byte) (err error) {\n\tall := struct {\n\t\tField *string `json:\"field,omitempty\"`\n\t\tLocalVariableName *string `json:\"localVariableName,omitempty\"`\n\t\tParser *SyntheticsVariableParser `json:\"parser,omitempty\"`\n\t\tType *SyntheticsGlobalVariableParseTestOptionsType `json:\"type\"`\n\t}{}\n\tif err = json.Unmarshal(bytes, &all); err != nil {\n\t\treturn json.Unmarshal(bytes, &o.UnparsedObject)\n\t}\n\tif all.Type == nil {\n\t\treturn fmt.Errorf(\"required field type missing\")\n\t}\n\tadditionalProperties := make(map[string]interface{})\n\tif err = json.Unmarshal(bytes, &additionalProperties); err == nil {\n\t\tdatadog.DeleteKeys(additionalProperties, &[]string{\"field\", \"localVariableName\", \"parser\", \"type\"})\n\t} else {\n\t\treturn err\n\t}\n\n\thasInvalidField := false\n\to.Field = all.Field\n\to.LocalVariableName = all.LocalVariableName\n\tif all.Parser != nil && all.Parser.UnparsedObject != nil && o.UnparsedObject == nil {\n\t\thasInvalidField = true\n\t}\n\to.Parser = all.Parser\n\tif !all.Type.IsValid() {\n\t\thasInvalidField = true\n\t} else {\n\t\to.Type = *all.Type\n\t}\n\n\tif len(additionalProperties) > 0 {\n\t\to.AdditionalProperties = additionalProperties\n\t}\n\n\tif hasInvalidField {\n\t\treturn json.Unmarshal(bytes, &o.UnparsedObject)\n\t}\n\n\treturn nil\n}", "func (in *Input) LoadFromEnv() {\n\tnum := reflect.ValueOf(in).Elem().NumField()\n\tfor i := 0; i < num; i++ {\n\t\ttField := reflect.TypeOf(in).Elem().Field(i)\n\t\tvField := reflect.ValueOf(in).Elem().Field(i)\n\t\tvalue, ok := os.LookupEnv(envPrefix + tField.Tag.Get(\"env\"))\n\t\tif ok {\n\t\t\tvField.Set(reflect.ValueOf(value))\n\t\t}\n\t}\n}", "func NewFromJSON(jsonEnv map[string]interface{}) (*ChefEnvironment, util.Gerror) {\n\tenv, err := New(jsonEnv[\"name\"].(string))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = env.UpdateFromJSON(jsonEnv)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn env, nil\n}", "func (a *MyAccount) ImportJSON(data []byte, passw string) (*MyAccount, error) {\n\tvar tmp struct {\n\t\tName string `json:\"name\"`\n\t\tFields map[string]string `json:\"fields\"`\n\t\tKeys string `json:\"keys\"`\n\t}\n\n\tif err := json.Unmarshal(data, &tmp); err != nil {\n\t\treturn nil, err\n\t}\n\n\tkeys, err := new(Keypair).SetEncrypted(HexDec(tmp.Keys), passw)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ta.Fields = tmp.Fields\n\ta.Name = tmp.Name\n\ta.Keys = keys\n\treturn a, nil\n}", "func (e *Extras) FromString(str string) (err error) {\n\tattrs := strings.Split(str, \":\")\n\n\tss, err := strconv.Atoi(attrs[0])\n\tif err != nil {\n\t\treturn err\n\t}\n\te.SampleSet = SampleSet(ss)\n\n\tss, err = strconv.Atoi(attrs[1])\n\tif err != nil {\n\t\treturn err\n\t}\n\te.AdditionalSet = SampleSet(ss)\n\n\te.CustomIndex, err = strconv.Atoi(attrs[2])\n\tif err != nil {\n\t\treturn err\n\t}\n\n\te.SampleVolume, err = strconv.Atoi(attrs[3])\n\te.Filename = attrs[4]\n\treturn err\n}", "func fillVariableMap() {\n\tvariableMap = make(map[string]string)\n\t// add regular variables, if any\n\tfor _, v := range *variables {\n\t\ts := strings.SplitN(v, \"=\", 2)\n\t\tvariableMap[s[0]] = s[1]\n\t}\n\t// add JSON variables, if provided\n\tif *jsonPath != \"\" {\n\t\t// JSON parameter provided\n\t\tif jsonFile, err := os.Open(*jsonPath); err != nil {\n\t\t\t// parse JSON file\n\t\t\tif err := json.NewDecoder(jsonFile).Decode(&variableMap); err != nil {\n\t\t\t\tfmt.Printf(\"Error parsing JSON: %v\\n\", err)\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\t\t} else {\n\t\t\t// something went wrong opening the file\n\t\t\tfmt.Printf(\"Could not open the JSON file at %v: %v\\n\", jsonPath, err)\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n\t// add YAML variables, if provided\n\tif *yamlPath != \"\" {\n\t\t// YAML parameter provided\n\t\tif content, err := ioutil.ReadFile(*yamlPath); err == nil {\n\t\t\t// read file\n\t\t\t// parse YAML file\n\t\t\tif err := yaml.Unmarshal(content, &variableMap); err != nil {\n\t\t\t\tfmt.Printf(\"Error parsing YAML: %v\\n\", err)\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\t\t} else {\n\t\t\t// something went wrong opening the file\n\t\t\tfmt.Printf(\"Could not open the YAML file at %v: %v\\n\", yamlPath, err)\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n}", "func loadFromJSON(jString string) ([]Param, error) {\n\tif len(jString) == 0 {\n\t\treturn nil, nil\n\t}\n\tvar data []Param\n\terr := json.Unmarshal([]byte(jString), &data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn data, nil\n}", "func ParsePresetJSON(str string) (res Preset, err error) {\n\tvar c Preset\n\terr = jsonc.Unmarshal([]byte(str), &c)\n\tif err != nil {\n\t\treturn\n\t}\n\tres = c\n\treturn\n}", "func (v *Venom) parseTestCase(ts *TestSuite, tc *TestCase) ([]string, []string, error) {\n\tdvars, err := DumpStringPreserveCase(tc.Vars)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tvars := []string{}\n\textractedVars := []string{}\n\n\t// the value of each var can contains a double-quote -> \"\n\t// if the value is not escaped, it will be used as is, and the json sent to unmarshall will be incorrect.\n\t// This also avoids injections into the json structure of a step\n\tfor i := range dvars {\n\t\tdvars[i] = strings.ReplaceAll(dvars[i], \"\\\"\", \"\\\\\\\"\")\n\t}\n\tfor _, rawStep := range tc.RawTestSteps {\n\t\tcontent, err := interpolate.Do(string(rawStep), dvars)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\n\t\tvar step TestStep\n\t\tif err := yaml.Unmarshal([]byte(content), &step); err != nil {\n\t\t\treturn nil, nil, errors.Wrapf(err, \"unable to unmarshal teststep\")\n\t\t}\n\n\t\t_, exec, err := v.GetExecutorRunner(context.Background(), step, tc.Vars)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\n\t\tdefaultResult := exec.ZeroValueResult()\n\t\tif defaultResult != nil {\n\t\t\tdumpE, err := DumpString(defaultResult)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, err\n\t\t\t}\n\t\t\tfor k := range dumpE {\n\t\t\t\tvar found bool\n\t\t\t\tfor i := 0; i < len(vars); i++ {\n\t\t\t\t\tif vars[i] == k {\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif !found {\n\t\t\t\t\textractedVars = append(extractedVars, k)\n\t\t\t\t}\n\t\t\t\textractedVars = append(extractedVars, tc.Name+\".\"+k)\n\t\t\t\tif strings.HasSuffix(k, \"__type__\") && dumpE[k] == \"Map\" {\n\t\t\t\t\t// go-dump doesnt dump the map name, here is a workaround\n\t\t\t\t\tk = strings.TrimSuffix(k, \"__type__\")\n\t\t\t\t\textractedVars = append(extractedVars, tc.Name+\".\"+k)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tdumpE, err := DumpStringPreserveCase(step)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\n\t\tfor k, v := range dumpE {\n\t\t\tif strings.HasPrefix(k, \"vars.\") {\n\t\t\t\ts := tc.Name + \".\" + strings.Split(k[5:], \".\")[0]\n\t\t\t\textractedVars = append(extractedVars, s)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif strings.HasPrefix(k, \"extracts.\") {\n\t\t\t\ts := tc.Name + \".\" + strings.Split(k[9:], \".\")[0]\n\t\t\t\textractedVars = append(extractedVars, s)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif strings.HasPrefix(k, \"info\") {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif varRegEx.MatchString(v) {\n\t\t\t\tvar found bool\n\t\t\t\tfor i := 0; i < len(vars); i++ {\n\t\t\t\t\tif vars[i] == k {\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ts := varRegEx.FindString(v)\n\t\t\t\tfor i := 0; i < len(extractedVars); i++ {\n\t\t\t\t\tprefix := \"{{.\" + extractedVars[i]\n\t\t\t\t\tif strings.HasPrefix(s, prefix) {\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif !found {\n\t\t\t\t\ts = strings.ReplaceAll(s, \"{{.\", \"\")\n\t\t\t\t\ts = strings.ReplaceAll(s, \"}}\", \"\")\n\t\t\t\t\tvars = append(vars, s)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn vars, extractedVars, nil\n}", "func (flg *Var) Set(s string) error {\n\ts = strings.TrimSpace(s)\n\tif s == \"\" {\n\t\treturn nil\n\t}\n\tvar bs []byte\n\tif strings.HasPrefix(s, \"@\") {\n\t\tvar err error\n\t\tbs, err = ioutil.ReadFile(s[1:])\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tbs = []byte(s)\n\t}\n\tbuf := bytes.NewBuffer(bs)\n\tdecoder := json.NewDecoder(buf)\n\tif flg.UseNumber {\n\t\tdecoder.UseNumber()\n\t}\n\tvar v interface{}\n\tif err := decoder.Decode(&v); err != nil {\n\t\treturn err\n\t}\n\tflg.Value = &v\n\treturn nil\n}", "func convertPlatformVars(slice raw.StringSliceMap, name string) (*starlark.Dict, error) {\n\tbuild := starlark.NewDict(0)\n\tdeployment := starlark.NewDict(0)\n\trepo := starlark.NewDict(0)\n\tuser := starlark.NewDict(0)\n\tsystem := starlark.NewDict(0)\n\tdict := starlark.NewDict(0)\n\n\terr := dict.SetKey(starlark.String(\"build\"), build)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = dict.SetKey(starlark.String(\"deployment\"), deployment)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = dict.SetKey(starlark.String(\"repo\"), repo)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = dict.SetKey(starlark.String(\"user\"), user)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = dict.SetKey(starlark.String(\"system\"), system)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = system.SetKey(starlark.String(\"template_name\"), starlark.String(name))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// iterate through the list of key/value pairs provided\n\tfor key, value := range slice {\n\t\t// lowercase the key\n\t\tkey = strings.ToLower(key)\n\n\t\t// iterate through the list of possible prefixes to look for\n\t\tfor _, prefix := range []string{\"deployment_parameter_\", \"vela_\"} {\n\t\t\t// check if the key has the prefix\n\t\t\tif strings.HasPrefix(key, prefix) {\n\t\t\t\t// trim the prefix from the input key\n\t\t\t\tkey = strings.TrimPrefix(key, prefix)\n\n\t\t\t\t// check if the prefix is from 'vela_*'\n\t\t\t\tif strings.EqualFold(prefix, \"vela_\") {\n\t\t\t\t\tswitch {\n\t\t\t\t\tcase strings.HasPrefix(key, \"build_\"):\n\t\t\t\t\t\terr := build.SetKey(starlark.String(strings.TrimPrefix(key, \"build_\")), starlark.String(value))\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t}\n\t\t\t\t\tcase strings.HasPrefix(key, \"repo_\"):\n\t\t\t\t\t\terr := repo.SetKey(starlark.String(strings.TrimPrefix(key, \"repo_\")), starlark.String(value))\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t}\n\t\t\t\t\tcase strings.HasPrefix(key, \"user_\"):\n\t\t\t\t\t\terr := user.SetKey(starlark.String(strings.TrimPrefix(key, \"user_\")), starlark.String(value))\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\terr := system.SetKey(starlark.String(key), starlark.String(value))\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else { // prefix is from 'deployment_parameter_*'\n\t\t\t\t\terr := deployment.SetKey(starlark.String(key), starlark.String(value))\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn dict, nil\n}", "func LoadSwarmConfigString(swarmConfigJSON string, cwd string) (*SwarmConfig, error) {\n\tvar config *SwarmConfig\n\terr := json.Unmarshal([]byte(swarmConfigJSON), &config)\n\tif err != nil {\n\t\treturn nil, errors.New(\"Invalid JSON in swarm config file: \" + err.Error())\n\t}\n\tconfig.backfillWithDefaults(cwd)\n\tconfig.expandAndNormalisePaths(cwd)\n\treturn config, nil\n}", "func main() {\n\tfile,_ := ioutil.ReadFile(\"input.json\")\n\n\tinput := &PuzzleSetup{}\n\n\tjson.Unmarshal([]byte(string(file)), &input)\n\n\tinput.ParseOps()\n\tinput.Solve()\n}", "func (config *Configuration) VarsFromFile(configFile string) error {\n\tfile, err := ioutil.ReadFile(configFile)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to read config file: %v\", err)\n\t}\n\n\terr = json.Unmarshal(file, &config)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to decode config file: %v\", err)\n\t}\n\n\treturn nil\n}", "func (us *UserStorage) ImportJSON(data []byte) error {\n\treturn nil\n}", "func createSetFromJSON(jsonPath string) map[string]bool {\n\tfile, err := ioutil.ReadFile(jsonPath)\n\tif err != nil {\n\t\tfmt.Printf(\"File error: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\n\t// TODO: handle this error\n\tvar arr []string\n\t_ = json.Unmarshal([]byte(file), &arr)\n\n\tstopwordSet := make(map[string]bool)\n\tfor _, sword := range arr {\n\t\tstopwordSet[sword] = true\n\t}\n\n\treturn stopwordSet\n}", "func (e *ChefEnvironment) UpdateFromJSON(jsonEnv map[string]interface{}) util.Gerror {\n\tif e.Name != jsonEnv[\"name\"].(string) {\n\t\terr := util.Errorf(\"Environment name %s and %s from JSON do not match\", e.Name, jsonEnv[\"name\"].(string))\n\t\treturn err\n\t} else if e.Name == \"_default\" {\n\t\terr := util.Errorf(\"The '_default' environment cannot be modified.\")\n\t\terr.SetStatus(http.StatusMethodNotAllowed)\n\t\treturn err\n\t}\n\n\t/* Validations */\n\tvalidElements := []string{\"name\", \"chef_type\", \"json_class\", \"description\", \"default_attributes\", \"override_attributes\", \"cookbook_versions\"}\nValidElem:\n\tfor k := range jsonEnv {\n\t\tfor _, i := range validElements {\n\t\t\tif k == i {\n\t\t\t\tcontinue ValidElem\n\t\t\t}\n\t\t}\n\t\terr := util.Errorf(\"Invalid key %s in request body\", k)\n\t\treturn err\n\t}\n\n\tvar verr util.Gerror\n\n\tattrs := []string{\"default_attributes\", \"override_attributes\"}\n\tfor _, a := range attrs {\n\t\tjsonEnv[a], verr = util.ValidateAttributes(a, jsonEnv[a])\n\t\tif verr != nil {\n\t\t\treturn verr\n\t\t}\n\t}\n\n\tjsonEnv[\"json_class\"], verr = util.ValidateAsFieldString(jsonEnv[\"json_class\"])\n\tif verr != nil {\n\t\tif verr.Error() == \"Field 'name' nil\" {\n\t\t\tjsonEnv[\"json_class\"] = e.JSONClass\n\t\t} else {\n\t\t\treturn verr\n\t\t}\n\t} else {\n\t\tif jsonEnv[\"json_class\"].(string) != \"Chef::Environment\" {\n\t\t\tverr = util.Errorf(\"Field 'json_class' invalid\")\n\t\t\treturn verr\n\t\t}\n\t}\n\n\tjsonEnv[\"chef_type\"], verr = util.ValidateAsFieldString(jsonEnv[\"chef_type\"])\n\tif verr != nil {\n\t\tif verr.Error() == \"Field 'name' nil\" {\n\t\t\tjsonEnv[\"chef_type\"] = e.ChefType\n\t\t} else {\n\t\t\treturn verr\n\t\t}\n\t} else {\n\t\tif jsonEnv[\"chef_type\"].(string) != \"environment\" {\n\t\t\tverr = util.Errorf(\"Field 'chef_type' invalid\")\n\t\t\treturn verr\n\t\t}\n\t}\n\n\tjsonEnv[\"cookbook_versions\"], verr = util.ValidateAttributes(\"cookbook_versions\", jsonEnv[\"cookbook_versions\"])\n\tif verr != nil {\n\t\treturn verr\n\t}\n\tfor k, v := range jsonEnv[\"cookbook_versions\"].(map[string]interface{}) {\n\t\tif !util.ValidateEnvName(k) || k == \"\" {\n\t\t\tmerr := util.Errorf(\"Cookbook name %s invalid\", k)\n\t\t\tmerr.SetStatus(http.StatusBadRequest)\n\t\t\treturn merr\n\t\t}\n\n\t\tif v == nil {\n\t\t\tverr = util.Errorf(\"Invalid version number\")\n\t\t\treturn verr\n\t\t}\n\t\t_, verr = util.ValidateAsConstraint(v)\n\t\tif verr != nil {\n\t\t\t/* try validating as a version */\n\t\t\tv, verr = util.ValidateAsVersion(v)\n\t\t\tif verr != nil {\n\t\t\t\treturn verr\n\t\t\t}\n\t\t}\n\t}\n\n\tjsonEnv[\"description\"], verr = util.ValidateAsString(jsonEnv[\"description\"])\n\tif verr != nil {\n\t\tif verr.Error() == \"Field 'name' missing\" {\n\t\t\tjsonEnv[\"description\"] = \"\"\n\t\t} else {\n\t\t\treturn verr\n\t\t}\n\t}\n\n\te.ChefType = jsonEnv[\"chef_type\"].(string)\n\te.JSONClass = jsonEnv[\"json_class\"].(string)\n\te.Description = jsonEnv[\"description\"].(string)\n\te.Default = jsonEnv[\"default_attributes\"].(map[string]interface{})\n\te.Override = jsonEnv[\"override_attributes\"].(map[string]interface{})\n\t/* clear out, then loop over the cookbook versions */\n\te.CookbookVersions = make(map[string]string, len(jsonEnv[\"cookbook_versions\"].(map[string]interface{})))\n\tfor c, v := range jsonEnv[\"cookbook_versions\"].(map[string]interface{}) {\n\t\te.CookbookVersions[c] = v.(string)\n\t}\n\n\treturn nil\n}", "func (cfg *Config) UpdateFromEnvs() error {\n\tcc := *cfg\n\n\ttp1, vv1 := reflect.TypeOf(&cc).Elem(), reflect.ValueOf(&cc).Elem()\n\tfor i := 0; i < tp1.NumField(); i++ {\n\t\tjv := tp1.Field(i).Tag.Get(\"json\")\n\t\tif jv == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tjv = strings.Replace(jv, \",omitempty\", \"\", -1)\n\t\tjv = strings.Replace(jv, \"-\", \"_\", -1)\n\t\tjv = strings.ToUpper(strings.Replace(jv, \"-\", \"_\", -1))\n\t\tenv := envPfx + jv\n\t\tif os.Getenv(env) == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tsv := os.Getenv(env)\n\n\t\tfieldName := tp1.Field(i).Name\n\n\t\tswitch vv1.Field(i).Type().Kind() {\n\t\tcase reflect.String:\n\t\t\tvv1.Field(i).SetString(sv)\n\n\t\tcase reflect.Bool:\n\t\t\tbb, err := strconv.ParseBool(sv)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to parse %q (%q, %v)\", sv, env, err)\n\t\t\t}\n\t\t\tvv1.Field(i).SetBool(bb)\n\n\t\tcase reflect.Int, reflect.Int32, reflect.Int64:\n\t\t\tif fieldName == \"WaitBeforeDown\" {\n\t\t\t\tdv, err := time.ParseDuration(sv)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to parse %q (%q, %v)\", sv, env, err)\n\t\t\t\t}\n\t\t\t\tvv1.Field(i).SetInt(int64(dv))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tiv, err := strconv.ParseInt(sv, 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to parse %q (%q, %v)\", sv, env, err)\n\t\t\t}\n\t\t\tvv1.Field(i).SetInt(iv)\n\n\t\tcase reflect.Uint, reflect.Uint32, reflect.Uint64:\n\t\t\tiv, err := strconv.ParseUint(sv, 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to parse %q (%q, %v)\", sv, env, err)\n\t\t\t}\n\t\t\tvv1.Field(i).SetUint(iv)\n\n\t\tcase reflect.Float32, reflect.Float64:\n\t\t\tfv, err := strconv.ParseFloat(sv, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to parse %q (%q, %v)\", sv, env, err)\n\t\t\t}\n\t\t\tvv1.Field(i).SetFloat(fv)\n\n\t\tcase reflect.Slice:\n\t\t\tss := strings.Split(sv, \",\")\n\t\t\tslice := reflect.MakeSlice(reflect.TypeOf([]string{}), len(ss), len(ss))\n\t\t\tfor i := range ss {\n\t\t\t\tslice.Index(i).SetString(ss[i])\n\t\t\t}\n\t\t\tvv1.Field(i).Set(slice)\n\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"%q (%v) is not supported as an env\", env, vv1.Field(i).Type())\n\t\t}\n\t}\n\t*cfg = cc\n\n\tav := *cc.ALBIngressController\n\ttp2, vv2 := reflect.TypeOf(&av).Elem(), reflect.ValueOf(&av).Elem()\n\tfor i := 0; i < tp2.NumField(); i++ {\n\t\tjv := tp2.Field(i).Tag.Get(\"json\")\n\t\tif jv == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tjv = strings.Replace(jv, \",omitempty\", \"\", -1)\n\t\tjv = strings.ToUpper(strings.Replace(jv, \"-\", \"_\", -1))\n\t\tenv := envPfxALB + jv\n\t\tif os.Getenv(env) == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tsv := os.Getenv(env)\n\n\t\tswitch vv2.Field(i).Type().Kind() {\n\t\tcase reflect.String:\n\t\t\tvv2.Field(i).SetString(sv)\n\n\t\tcase reflect.Bool:\n\t\t\tbb, err := strconv.ParseBool(sv)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to parse %q (%q, %v)\", sv, env, err)\n\t\t\t}\n\t\t\tvv2.Field(i).SetBool(bb)\n\n\t\tcase reflect.Int, reflect.Int32, reflect.Int64:\n\t\t\tiv, err := strconv.ParseInt(sv, 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to parse %q (%q, %v)\", sv, env, err)\n\t\t\t}\n\t\t\tvv2.Field(i).SetInt(iv)\n\n\t\tcase reflect.Uint, reflect.Uint32, reflect.Uint64:\n\t\t\tiv, err := strconv.ParseUint(sv, 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to parse %q (%q, %v)\", sv, env, err)\n\t\t\t}\n\t\t\tvv2.Field(i).SetUint(iv)\n\n\t\tcase reflect.Float32, reflect.Float64:\n\t\t\tfv, err := strconv.ParseFloat(sv, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to parse %q (%q, %v)\", sv, env, err)\n\t\t\t}\n\t\t\tvv2.Field(i).SetFloat(fv)\n\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"%q (%v) is not supported as an env\", env, vv2.Field(i).Type())\n\t\t}\n\t}\n\tcfg.ALBIngressController = &av\n\n\treturn nil\n}", "func sourceTablesFromJSON(s string) (st SourceTables, err error) {\n\terr = json.Unmarshal([]byte(s), &st)\n\treturn\n}", "func init() {\n\tconfigFile, err := os.Open(\"settings/config.json\")\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tbyteValue, _ := ioutil.ReadAll(configFile)\n\n\terr = json.Unmarshal(byteValue, &Config)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tdefer configFile.Close()\n}", "func importEnv(e []string) *phpv.ZHashTable {\n\tzt := phpv.NewHashTable()\n\n\tfor _, s := range e {\n\t\tp := strings.IndexByte(s, '=')\n\t\tif p != -1 {\n\t\t\tzt.SetString(phpv.ZString(s[:p]), phpv.ZString(s[p+1:]).ZVal())\n\t\t}\n\t}\n\n\treturn zt\n}", "func (a *Secrets) UnmarshalJSON(b []byte) error {\n\tobject := make(map[string]json.RawMessage)\n\terr := json.Unmarshal(b, &object)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(object) != 0 {\n\t\ta.AdditionalProperties = make(map[string]string)\n\t\tfor fieldName, fieldBuf := range object {\n\t\t\tvar fieldVal string\n\t\t\terr := json.Unmarshal(fieldBuf, &fieldVal)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrap(err, fmt.Sprintf(\"error unmarshaling field %s\", fieldName))\n\t\t\t}\n\t\t\ta.AdditionalProperties[fieldName] = fieldVal\n\t\t}\n\t}\n\treturn nil\n}", "func LoadTestEnv() *core.Engine {\n\tengine := new(core.Engine)\n\n\t_, dir, _, _ := runtime.Caller(0)\n\tconfigJSON := filepath.Join(filepath.Dir(dir), \"../..\", \"env\", \"tdd.json\")\n\n\tjsonFile, err := os.Open(configJSON)\n\n\tif err != nil {\n\t\tlog.Fatalln(err, \"can't open the config file\", dir+\"/regularenvs.json\")\n\t}\n\n\tdefer jsonFile.Close()\n\n\tbyteValue, _ := ioutil.ReadAll(jsonFile)\n\n\terr = json.Unmarshal(byteValue, &engine.Env)\n\tif err != nil {\n\t\tlog.Fatalln(err, \"error in unmarshal JSON\")\n\t}\n\n\tif engine.Env.MachineID, err = machineid.ProtectedID(\"SigmaMono\"); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn engine\n}", "func GoodJSONConfFile(t *testing.T) string {\n\tt.Helper()\n\n\tgoodJSONConfFile := `[\n\t\t{\n\t\t\t\"TableName\" : \"UserAccounts\",\n\t\t\t\"Filter\" : \"LOG0 = 'UserAccounts'\",\n\t\t\t\"DeleteMarkerField\": \"__DELETE__\",\n\t\t\t\"FieldMappings\" : [\n\t\t\t\t{\"Field\": \"userAddress\" , \"ColumnName\" : \"address\", \"Type\": \"address\", \"Primary\" : true},\n\t\t\t\t{\"Field\": \"userName\", \"ColumnName\" : \"username\", \"Type\": \"string\", \"Primary\" : false},\n\t\t\t\t{\"Field\": \"userId\", \"ColumnName\" : \"userid\", \"Type\": \"uint256\", \"Primary\" : false},\n\t\t\t\t{\"Field\": \"userBool\", \"ColumnName\" : \"userbool\", \"Type\": \"bool\", \"Primary\" : false}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\"TableName\" : \"TEST_TABLE\",\n\t\t\"Filter\" : \"Log1Text = 'EVENT_TEST'\",\n\t\t\"DeleteMarkerField\": \"__DELETE__\",\n\t\t\"FieldMappings\" : [\n\t\t\t{\"Field\": \"key\", \"ColumnName\": \"Index\", \"Type\": \"uint256\", \"Primary\" : true},\n\t\t\t{\"Field\": \"blocknum\", \"ColumnName\": \"Block\", \"Type\": \"uint256\", \"Primary\" : false},\n\t\t\t{\"Field\": \"somestr\", \"ColumnName\": \"String\", \"Type\": \"string\", \"Primary\" : false},\n\t\t\t{\"Field\": \"instance\", \"ColumnName\": \"Instance\", \"Type\": \"uint\", \"Primary\" : false}\n\t\t]\n\t}\n\t]`\n\n\treturn goodJSONConfFile\n}", "func initVariables() error {\n\tswitch h, err := os.Hostname(); {\n\tcase err == nil:\n\t\tENVS.Hostname = h\n\tcase os.IsNotExist(err):\n\t\tENVS.Hostname = \"(none)\"\n\tdefault:\n\t\treturn err\n\t}\n\n\tswitch ifs, err := getNetIfaces(); {\n\tcase err == nil:\n\t\tENVS.Network = ifs\n\tdefault:\n\t\treturn err\n\t}\n\n\tswitch out, err := exec.Command(\"./myenvs\").Output(); {\n\tcase err == nil:\n\t\tif err := json.Unmarshal(out, &ENVS.X); err != nil {\n\t\t\treturn err\n\t\t}\n\tcase !os.IsNotExist(err):\n\t\treturn fmt.Errorf(\"%s: %s\", err, out)\n\t}\n\n\treturn nil\n}", "func EnvironmentFromBytes(b []byte) (*Environment, error) {\n\tbuffer := &Environment{} // Initialize buffer\n\n\terr := json.Unmarshal(b, buffer) // Read json into buffer\n\n\tif err != nil { // Check for errors\n\t\treturn &Environment{}, err // Return error\n\t}\n\n\treturn buffer, nil // No error occurred, return read environment\n}", "func AccessTokensFromEnvJSON(env string) []string {\n\taccessTokens := []string{}\n\tif len(env) == 0 {\n\t\treturn accessTokens\n\t}\n\terr := json.Unmarshal([]byte(env), &accessTokens)\n\tif err != nil {\n\t\tlog.Entry().Infof(\"Token json '%v' has wrong format.\", env)\n\t}\n\treturn accessTokens\n}", "func Unmarshal(str string) (Env, error) {\n\treturn strictParse(strings.NewReader(str), false)\n}", "func (s *StartupScript) UnmarshalJSON(data []byte) (err error) {\n\tif s == nil {\n\t\t*s = StartupScript{}\n\t}\n\n\tvar fields map[string]interface{}\n\tif err := json.Unmarshal(data, &fields); err != nil {\n\t\treturn err\n\t}\n\n\ts.ID = fmt.Sprintf(\"%v\", fields[\"SCRIPTID\"])\n\ts.Name = fmt.Sprintf(\"%v\", fields[\"name\"])\n\ts.Type = fmt.Sprintf(\"%v\", fields[\"type\"])\n\ts.Content = fmt.Sprintf(\"%v\", fields[\"script\"])\n\n\treturn\n}", "func init() {\n\tpackr.PackJSONBytes(\"./../../secrets\", \"secrets.yaml.template\", \"\\\"bmF0c1VybDogIiR7TkFUU19VUkx9Igpmcm9udFVybDogIiR7RlJPTlRfVVJMfSIKYXBpVXJsOiAiJHtBUElfVVJMfSIK\\\"\")\n\tpackr.PackJSONBytes(\"./../../secrets\", \"staging.yaml\", \"\\\"bmF0c1VybDogIm5hdHM6Ly9vdHRlcmx5LXNlY3VyZTo0NmFhOWE4YmJiM2M0NzQzMDJiYkAzNS4xOTUuMTQ4LjI0OTo0MjIyIgpmcm9udFVybDogImh0dHBzOi8vYXBwLnNlY3VyZWFwaS5kZXYiCmFwaVVybDogImh0dHBzOi8vYXBpLnNlY3VyZWFwaS5kZXYiCg==\\\"\")\n}", "func NewFromJSON(data []byte) (*Conf, error) {\n\tvar c map[string]string\n\tif err := json.Unmarshal(data, &c); err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Conf{c: c}, nil\n}", "func main() {\n\tprovider := &dummyProvider{\n\t\tsettings: map[string]string{},\n\t}\n\tsettings.SetProvider(provider)\n\toutput := map[string]string{}\n\tfor key, name := range provider.settings {\n\t\tvalue := os.Getenv(key)\n\t\tif value == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\toutput[name] = value\n\t}\n\tdata, _ := json.Marshal(output)\n\tos.Stdout.Write(data)\n}", "func init() {\n\tWorkEnv = os.Getenv(\"WorkEnv\")\n\tjsonFile, err := os.Open(\"./config/config.json\")\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\t// defer the closing of our jsonFile so that we can parse it later on\n\tdefer jsonFile.Close()\n\t// read our opened xmlFile as a byte array.\n\tbyteValue, _ := ioutil.ReadAll(jsonFile)\n\tvar environments Environments\n\tjson.Unmarshal(byteValue, &environments)\n\tvar checkWorkEnv = 0\n\tfor i := 0; i < len(environments.Environments); i++ {\n\t\tif WorkEnv == environments.Environments[i].Env || (WorkEnv == \"\" && environments.Environments[i].Env == \"dev\") {\n\t\t\tAddress = environments.Environments[i].Database.Address\n\t\t\tDbName = environments.Environments[i].Database.DBName\n\t\t\tDbUsername = environments.Environments[i].Database.DBUsername\n\t\t\tDbPassword = environments.Environments[i].Database.DBPassword\n\t\t\tPort = environments.Environments[i].API.Port\n\t\t\tcheckWorkEnv = 1\n\t\t}\n\t}\n\tif checkWorkEnv == 0 {\n\t}\n}", "func ImportJSON(url string, target interface{}, delimiter byte) error {\r\n\t// Get HTTP response from URL\r\n\tresponse, err := httpClient.Get(url)\r\n\tif (err != nil) {\r\n\t\treturn err\r\n\t}\r\n\r\n\tdefer response.Body.Close()\r\n\r\n\t// If the payload is fully JSON convert it to the specific struct and return\r\n\tif (delimiter == 0) {\r\n\t\treturn json.NewDecoder(response.Body).Decode(target)\r\n\t}\r\n\r\n\t/*\r\n\t\tIf payload is a JSON data segments separated by the delimiter\r\n\t\tNeed to assemble an array of structs type given\r\n\t*/\r\n\r\n\treader := bufio.NewReader(response.Body)\r\n\tslice := reflect.ValueOf(target).Elem()\r\n\ttypeOfSlice := slice.Type()\r\n\tslice.Set(reflect.MakeSlice(typeOfSlice, 0, 1))\r\n\tptrToTarget := reflect.New(typeOfSlice.Elem())\r\n\r\n\t// Loop through the payload segments try to convert them to struct and add them to array\r\n\tfor {\r\n\t\tpart, err := reader.ReadBytes(delimiter);\r\n\t\tif (err != nil) {\r\n\t\t\terrMsg := err.Error();\r\n\t\t\tif (errMsg != \"EOF\") {\r\n\t\t\t\tlog.Error(err.Error())\r\n\t\t\t}\r\n\r\n\t\t\treturn nil\r\n\t\t}\r\n\r\n\t\tif (len(part) == 0) {\r\n\t\t\treturn nil\r\n\t\t}\r\n\r\n\t\tif err := json.Unmarshal(part, ptrToTarget.Interface()); (err != nil) {\r\n\t\t\treturn err\r\n\t\t}\r\n\r\n\t\tslice.Set(reflect.Append(slice, ptrToTarget.Elem()))\r\n\t}\r\n\r\n\treturn nil\r\n}", "func (a *TemplateApply_Secrets) UnmarshalJSON(b []byte) error {\n\tobject := make(map[string]json.RawMessage)\n\terr := json.Unmarshal(b, &object)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(object) != 0 {\n\t\ta.AdditionalProperties = make(map[string]string)\n\t\tfor fieldName, fieldBuf := range object {\n\t\t\tvar fieldVal string\n\t\t\terr := json.Unmarshal(fieldBuf, &fieldVal)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrap(err, fmt.Sprintf(\"error unmarshaling field %s\", fieldName))\n\t\t\t}\n\t\t\ta.AdditionalProperties[fieldName] = fieldVal\n\t\t}\n\t}\n\treturn nil\n}", "func main() {\n\twccFlags := cmd.SetupWebClientFlags(\"load-scenario\", \"test-case.json\")\n\n\tflag.Parse()\n\n\tif len(flag.Args()) != 1 {\n\t\tflag.Usage()\n\t\t// Mimick flag.ExitOnError\n\t\tos.Exit(2)\n\t}\n\n\twebclient := wccFlags.ConfiguredClient()\n\n\tform, err := cmd.ReadSectionData(flag.Arg(0))\n\tif err != nil {\n\t\tlog.Fatalln(\"error reading from file:\", err)\n\t}\n\n\twebclient.WithAuth(func() {\n\t\tfor _, v := range api.Catalogue() {\n\t\t\t// If the source data represents a scenario that has been submitted\n\t\t\t// to e-QIP, etc. already, do not re-load that meta-data\n\t\t\tif v.Payload == \"submission.releases\" {\n\t\t\t\tlog.Printf(\"Skipping `%s:%s`\\n\", v.Name, v.Subsection)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tval, ok := form[v.Name].(map[string]interface{})\n\t\t\tif !ok {\n\t\t\t\tlog.Fatalf(\"`%s` is not found\\n\", v.Name)\n\t\t\t}\n\n\t\t\tjs, ok := val[v.Subsection].(map[string]interface{})\n\t\t\tif !ok {\n\t\t\t\tlog.Fatalf(\"`%s:%s` is not found\\n\", v.Name, v.Subsection)\n\t\t\t}\n\n\t\t\tjsonString, err := json.Marshal(js)\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatalf(\"Could not marshal json for `%s:%s`\\n\", v.Name, v.Subsection)\n\t\t\t}\n\t\t\tlog.Printf(\"Saving `%s:%s`\\n\", v.Name, v.Subsection)\n\t\t\twebclient.Save(jsonString)\n\t\t}\n\t})\n}", "func fromJson(v string) interface{} {\n\toutput, _ := mustFromJson(v)\n\treturn output\n}", "func (a *Account) ImportJSON(data []byte) (*Account, error) {\n\tvar tmp struct {\n\t\tPublicKey string `json:\"public_key\"`\n\t\tName string `json:\"name\"`\n\t\tTimestamp uint32 `json:\"timestamp\"`\n\t\tFields map[string]string `json:\"fields\"`\n\t\tSignature string `json:\"signature\"`\n\t}\n\n\tif err := json.Unmarshal(data, &tmp); err != nil {\n\t\treturn nil, err\n\t}\n\n\ta.pub = *(new(PubKey).SetString(tmp.PublicKey))\n\ta.name = tmp.Name\n\ta.fields = tmp.Fields\n\ta.sign = *(new(SigData).SetString(tmp.Signature))\n\ta.timestamp = tmp.Timestamp\n\treturn a, nil\n}", "func loadFrom(r io.Reader) (*Config, error) {\n\tc := &Config{}\n\tdec := json.NewDecoder(r)\n\tif err := dec.Decode(c); err != nil {\n\t\treturn nil, err\n\t}\n\tif err := c.General.validate(); err != nil {\n\t\treturn nil, fmt.Errorf(\"config validation error: %v\", err)\n\t}\n\tif err := c.Service.Parameters.validate(); err != nil {\n\t\treturn nil, fmt.Errorf(\"config validation error: %v\", err)\n\t}\n\tif err := c.Service.Input.validate(); err != nil {\n\t\treturn nil, fmt.Errorf(\"config validation error: %v\", err)\n\t}\n\tif err := c.Service.Output.validate(); err != nil {\n\t\treturn nil, fmt.Errorf(\"config validation error: %v\", err)\n\t}\n\treturn c, nil\n}", "func (e *CheckRun) LoadFromJSON(data []byte) (bool, error) {\n\terr := json.Unmarshal(data, &e)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn true, nil\n}", "func FromDynamicJSON(data, target interface{}) error {\n\tb, err := json.Marshal(data)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\treturn json.Unmarshal(b, target)\n}", "func Setup() {\n\n\t// first merge in defaults\n\tmerge(&Data, defaultData)\n\n\tmode := os.Getenv(\"GO_ENV\")\n\n\t// merge in env specific configs\n\tswitch mode {\n\tcase \"dev\", \"\": // \"\" means default is dev\n\t\tmerge(&Data, devData)\n\tcase \"test\":\n\t\tmerge(&Data, testData)\n\tcase \"prod\":\n\t\tmerge(&Data, prodData)\n\t}\n\n\t// try to overwrite from env variables\n\tfor _, f := range structs.New(&Data).Fields() {\n\t\tnameCamel := toSnakeCase(f.Name())\n\t\tnameUpper := strings.ToUpper(nameCamel)\n\t\tenvVal, ok := os.LookupEnv(nameUpper)\n\t\tif ok { // ok means env variable exists, even if its value is blank\n\t\t\tf.Set(envVal)\n\t\t}\n\t}\n\n}", "func LoadFromJSON(r io.Reader) (*FieldData, error) {\n\tvar fdata FieldData\n\terr := json.NewDecoder(r).Decode(&fdata.values)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &fdata, nil\n}", "func UnmarshalFromEnv(c interface{}) {\n\ttopType := reflect.TypeOf(c).Elem()\n\ttopValue := reflect.ValueOf(c)\n\tfor i := 0; i < topType.NumField(); i++ {\n\t\tfield := topType.Field(i)\n\t\tif field.Tag.Get(\"env\") != \"\" {\n\t\t\tenvVar := os.Getenv(field.Tag.Get(\"env\"))\n\t\t\tif envVar == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tswitch field.Type.Kind() {\n\t\t\tcase reflect.Bool:\n\t\t\t\tb, err := strconv.ParseBool(envVar)\n\t\t\t\tif err != nil {\n\t\t\t\t\tfmt.Println(\"didn't set from \", field.Tag.Get(\"env\"), \" due to \", err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tf := topValue.Elem().Field(i)\n\t\t\t\tf.SetBool(b)\n\t\t\tcase reflect.Int64:\n\t\t\t\tinteger, err := strconv.ParseInt(envVar, 0, 64)\n\t\t\t\tif err != nil {\n\t\t\t\t\tfmt.Println(\"didn't set from \", field.Tag.Get(\"env\"), \" due to \", err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tf := topValue.Elem().Field(i)\n\t\t\t\tf.SetInt(integer)\n\t\t\tcase reflect.String:\n\t\t\t\tf := topValue.Elem().Field(i)\n\t\t\t\tf.SetString(envVar)\n\t\t\tcase reflect.Float64:\n\t\t\t\tfloat, err := strconv.ParseFloat(envVar, 64)\n\t\t\t\tif err != nil {\n\t\t\t\t\tfmt.Println(\"didn't set from \", field.Tag.Get(\"env\"), \" due to \", err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tf := topValue.Elem().Field(i)\n\t\t\t\tf.SetFloat(float)\n\t\t\t}\n\t\t}\n\t}\n}", "func setupEnvironmentVariables(a []string) map[string]string {\n\tr := make(map[string]string)\n\tfor _, s := range a {\n\t\tarr := strings.SplitN(s, \"=\", 2)\n\t\tif len(arr) == 2 {\n\t\t\tr[arr[0]] = arr[1]\n\t\t}\n\t}\n\treturn r\n}", "func loadJSON(t *testing.T, filename string, output interface{}) {\n\tfile := filepath.Join(\"testdata\", filename)\n\tfd, err := os.Open(file)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to read file %s: %v\", file, err)\n\t}\n\tif err = json.NewDecoder(fd).Decode(&output); err != nil {\n\t\tt.Fatalf(\"failed to decode file %s: %v\", file, err)\n\t}\n}", "func loadCCCEnv(file string) *CCCEnv {\n\tvar b []byte\n\tvar err error\n\n\tif b, err = ioutil.ReadFile(file); err != nil {\n\t\tpanic(fmt.Sprintf(\"Cannot read env file %s\\n\", err))\n\n\t}\n\n\tenv := &CCCEnv{}\n\terr = json.Unmarshal(b, &env)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"error unmarshalling cccenv: %s\\n\", err))\n\t}\n\n\treturn env\n}", "func (t Tags) Load(src string) {\n\tss := strings.Split(src, \",\")\n\tfirst := strings.TrimSpace(ss[0])\n\tif len(ss) > 0 {\n\t\tt[\"type\"] = first\n\t\trest := ss[1:]\n\t\tfor _, v := range rest {\n\t\t\tts := strings.Split(v, \"=\")\n\t\t\tif len(ts) < 2 {\n\t\t\t\tt[v] = \"\"\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tt[strings.TrimSpace(ts[0])] = strings.TrimSpace(ts[1])\n\t\t}\n\t}\n\n}", "func Json(data string) ViperBuilder {\n\treturn ReadConfig(\"json\", strings.NewReader(data))\n}", "func (r *CreateInstanceRequest) FromJsonString(s string) error {\n\tf := make(map[string]interface{})\n\tif err := json.Unmarshal([]byte(s), &f); err != nil {\n\t\treturn err\n\t}\n\tdelete(f, \"ProductId\")\n\tdelete(f, \"Software\")\n\tdelete(f, \"SupportHA\")\n\tdelete(f, \"InstanceName\")\n\tdelete(f, \"PayMode\")\n\tdelete(f, \"TimeSpan\")\n\tdelete(f, \"TimeUnit\")\n\tdelete(f, \"LoginSettings\")\n\tdelete(f, \"VPCSettings\")\n\tdelete(f, \"ResourceSpec\")\n\tdelete(f, \"COSSettings\")\n\tdelete(f, \"Placement\")\n\tdelete(f, \"SgId\")\n\tdelete(f, \"PreExecutedFileSettings\")\n\tdelete(f, \"AutoRenew\")\n\tdelete(f, \"ClientToken\")\n\tdelete(f, \"NeedMasterWan\")\n\tdelete(f, \"RemoteLoginAtCreate\")\n\tdelete(f, \"CheckSecurity\")\n\tdelete(f, \"ExtendFsField\")\n\tdelete(f, \"Tags\")\n\tdelete(f, \"DisasterRecoverGroupIds\")\n\tdelete(f, \"CbsEncrypt\")\n\tdelete(f, \"MetaType\")\n\tdelete(f, \"UnifyMetaInstanceId\")\n\tdelete(f, \"MetaDBInfo\")\n\tdelete(f, \"ApplicationRole\")\n\tdelete(f, \"SceneName\")\n\tdelete(f, \"ExternalService\")\n\tdelete(f, \"VersionID\")\n\tdelete(f, \"MultiZone\")\n\tdelete(f, \"MultiZoneSettings\")\n\tif len(f) > 0 {\n\t\treturn tcerr.NewTencentCloudSDKError(\"ClientError.BuildRequestError\", \"CreateInstanceRequest has unknown keys!\", \"\")\n\t}\n\treturn json.Unmarshal([]byte(s), &r)\n}", "func (o *MetadataOptions) LoadFrom(filename string) error {\n\tfile, err := os.Open(filename)\n\tdefer file.Close()\n\tif err != nil {\n\t\treturn err\n\t}\n\tblob, err := ioutil.ReadAll(file)\n\terr = json.Unmarshal(blob, o)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *Client) ImportCookie(domain, jsonStr string) (err error) {\n\tdebug(\"domain:\", domain)\n\n\tvar cookies []*cookie\n\n\terr = json.Unmarshal([]byte(jsonStr), &cookies)\n\tif err != nil {\n\t\tdebug(\"ERR(json.Unmarshal)\", err)\n\t\treturn\n\t}\n\t// debug(cookies)\n\n\thttpCookies := tohttpCookie(cookies)\n\n\terr = c.SetCookies(domain, httpCookies)\n\tif err != nil {\n\t\treturn\n\t}\n\treturn\n}", "func setEnv(d interface{}) {\n\tVCAP := os.Getenv(\"VCAP_SERVICES\")\n\tif VCAP == \"\" {\n\t\treturn // no environment found so use whatever DBURL is set to\n\t}\n\tb := []byte(VCAP)\n\terr := json.Unmarshal(b, d) \n\tif err != nil {\n\t\tfmt.Printf(\"dbhandler:setEnv:ERROR:%s\", err)\n\t}\n}", "func setupVars() {\n\tvar err error\n\n\t// setup logging and other general configurations\n\tlogger, err = util.MakeLogger(\"debug\", \"json\")\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"could not create test logger: %v\\n\", err)\n\t\tos.Exit(10)\n\t}\n\n\t// setup kubernetes related configurations\n\tfakeK8sClient = fake.NewClientBuilder().Build()\n\n\t// setup kong proxy related configurations\n\tfakeKongAdminAPI, err = kongt.NewFakeAdminAPIServer()\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"could not setup Kong Proxy testing environment: %v\\n\", err)\n\t\tos.Exit(10)\n\t}\n\tfakeKongConfig.Client = fakeKongAdminAPI.KongClient\n}", "func (e *Environment) UnmarshalJSON(data []byte) error {\n\tvar fields struct {\n\t\tAllowDynamicInfrastructure bool `json:\"AllowDynamicInfrastructure\"`\n\t\tDescription string `json:\"Description,omitempty\"`\n\t\tName string `json:\"Name\" validate:\"required\"`\n\t\tSlug string `json:\"Slug\"`\n\t\tSortOrder int `json:\"SortOrder\"`\n\t\tSpaceID string `json:\"SpaceId\"`\n\t\tUseGuidedFailure bool `json:\"UseGuidedFailure\"`\n\t\tresources.Resource\n\t}\n\n\tif err := json.Unmarshal(data, &fields); err != nil {\n\t\treturn err\n\t}\n\n\t// validate JSON representation\n\tvalidate := validator.New()\n\tif err := validate.Struct(fields); err != nil {\n\t\treturn err\n\t}\n\n\te.AllowDynamicInfrastructure = fields.AllowDynamicInfrastructure\n\te.Description = fields.Description\n\te.Name = fields.Name\n\te.Slug = fields.Slug\n\te.SortOrder = fields.SortOrder\n\te.SpaceID = fields.SpaceID\n\te.UseGuidedFailure = fields.UseGuidedFailure\n\te.Resource = fields.Resource\n\n\tvar environment map[string]*json.RawMessage\n\tif err := json.Unmarshal(data, &environment); err != nil {\n\t\treturn err\n\t}\n\n\tvar extensionSettings *json.RawMessage\n\tvar extensionSettingsCollection []*json.RawMessage\n\n\tif environment[\"ExtensionSettings\"] != nil {\n\t\textensionSettingsValue := environment[\"ExtensionSettings\"]\n\n\t\tif err := json.Unmarshal(*extensionSettingsValue, &extensionSettings); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := json.Unmarshal(*extensionSettings, &extensionSettingsCollection); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfor _, v := range extensionSettingsCollection {\n\t\t\tvar extensionSettingsItem map[string]*json.RawMessage\n\t\t\tif err := json.Unmarshal(*v, &extensionSettingsItem); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif extensionSettingsItem[\"ExtensionId\"] != nil {\n\t\t\t\tvar extensionID extensions.ExtensionID\n\t\t\t\tjson.Unmarshal(*extensionSettingsItem[\"ExtensionId\"], &extensionID)\n\n\t\t\t\tswitch extensionID {\n\t\t\t\tcase extensions.JiraExtensionID:\n\t\t\t\t\tvar jiraExtensionSettings *JiraExtensionSettings\n\t\t\t\t\tif err := json.Unmarshal(*v, &jiraExtensionSettings); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\te.ExtensionSettings = append(e.ExtensionSettings, jiraExtensionSettings)\n\t\t\t\tcase extensions.JiraServiceManagementExtensionID:\n\t\t\t\t\tvar jiraServiceManagementExtensionSettings *JiraServiceManagementExtensionSettings\n\t\t\t\t\tif err := json.Unmarshal(*v, &jiraServiceManagementExtensionSettings); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\te.ExtensionSettings = append(e.ExtensionSettings, jiraServiceManagementExtensionSettings)\n\t\t\t\tcase extensions.ServiceNowExtensionID:\n\t\t\t\t\tvar serviceNowExtensionSettings *ServiceNowExtensionSettings\n\t\t\t\t\tif err := json.Unmarshal(*v, &serviceNowExtensionSettings); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\te.ExtensionSettings = append(e.ExtensionSettings, serviceNowExtensionSettings)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func FromJsonString(jsonString string) (ResumeData, error) {\n\treturn fromJson([]byte(jsonString))\n}", "func (r *CreateAttackDownloadTaskResponse) FromJsonString(s string) error {\n\treturn json.Unmarshal([]byte(s), &r)\n}", "func (m *ServerConfigImport) UnmarshalJSON(raw []byte) error {\n\t// AO0\n\tvar aO0 MoBaseMo\n\tif err := swag.ReadJSON(raw, &aO0); err != nil {\n\t\treturn err\n\t}\n\tm.MoBaseMo = aO0\n\n\t// AO1\n\tvar dataAO1 struct {\n\t\tDescription string `json:\"Description,omitempty\"`\n\n\t\tOrganization *IamAccountRef `json:\"Organization,omitempty\"`\n\n\t\tPolicyPrefix string `json:\"PolicyPrefix,omitempty\"`\n\n\t\tPolicyTypes []string `json:\"PolicyTypes\"`\n\n\t\tProfileName string `json:\"ProfileName,omitempty\"`\n\n\t\tServer *ComputeRackUnitRef `json:\"Server,omitempty\"`\n\n\t\tServerProfile *ServerProfileRef `json:\"ServerProfile,omitempty\"`\n\t}\n\tif err := swag.ReadJSON(raw, &dataAO1); err != nil {\n\t\treturn err\n\t}\n\n\tm.Description = dataAO1.Description\n\n\tm.Organization = dataAO1.Organization\n\n\tm.PolicyPrefix = dataAO1.PolicyPrefix\n\n\tm.PolicyTypes = dataAO1.PolicyTypes\n\n\tm.ProfileName = dataAO1.ProfileName\n\n\tm.Server = dataAO1.Server\n\n\tm.ServerProfile = dataAO1.ServerProfile\n\n\treturn nil\n}", "func (r *StartLoggingRequest) FromJsonString(s string) error {\n\tf := make(map[string]interface{})\n\tif err := json.Unmarshal([]byte(s), &f); err != nil {\n\t\treturn err\n\t}\n\tdelete(f, \"AuditName\")\n\tif len(f) > 0 {\n\t\treturn tcerr.NewTencentCloudSDKError(\"ClientError.BuildRequestError\", \"StartLoggingRequest has unknown keys!\", \"\")\n\t}\n\treturn json.Unmarshal([]byte(s), &r)\n}", "func (r *CreateAttackDownloadTaskRequest) FromJsonString(s string) error {\n\tf := make(map[string]interface{})\n\tif err := json.Unmarshal([]byte(s), &f); err != nil {\n\t\treturn err\n\t}\n\tdelete(f, \"Domain\")\n\tdelete(f, \"FromTime\")\n\tdelete(f, \"ToTime\")\n\tdelete(f, \"Name\")\n\tdelete(f, \"RiskLevel\")\n\tdelete(f, \"Status\")\n\tdelete(f, \"RuleId\")\n\tdelete(f, \"AttackIp\")\n\tdelete(f, \"AttackType\")\n\tif len(f) > 0 {\n\t\treturn tcerr.NewTencentCloudSDKError(\"ClientError.BuildRequestError\", \"CreateAttackDownloadTaskRequest has unknown keys!\", \"\")\n\t}\n\treturn json.Unmarshal([]byte(s), &r)\n}", "func NewTfvarsJSON(config *print.Config) Type {\n\treturn &tfvarsJSON{\n\t\tgenerator: newGenerator(config, false),\n\t\tconfig: config,\n\t}\n}", "func GrabDictPackage[T interfaces.ISettings](myfilename string, juststrings, recursive, newlines bool, allowWildcard, allowRepo, allowBuildId, allowUse, verifyEapi bool, eapi, eapiDefault string) map[*dep.Atom[T]][]string {\n\tfileList := []string{}\n\tif recursive {\n\t\tfileList = grab.RecursiveFileList(myfilename)\n\t} else {\n\t\tfileList = []string{myfilename}\n\t}\n\tatoms := map[*dep.Atom[T]][]string{}\n\tvar d map[string][]string\n\tfor _, filename := range fileList {\n\t\td = grab.GrabDict(filename, false, true, false, true, newlines)\n\t\tif len(d) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif verifyEapi && eapi == \"\" {\n\t\t\teapi = ReadCorrespondingEapiFile(myfilename, eapiDefault)\n\t\t}\n\t\tfor k, v := range d {\n\t\t\ta, err := dep.NewAtom[T](k, nil, allowWildcard, &allowRepo, nil, eapi, nil, &allowBuildId)\n\t\t\tif err != nil {\n\t\t\t\tmsg.WriteMsg(fmt.Sprintf(\"--- Invalid Atom in %s: %s\\n\", filename, err), -1, nil)\n\t\t\t} else {\n\t\t\t\tif !allowUse && a.Use != nil {\n\t\t\t\t\tmsg.WriteMsg(fmt.Sprintf(\"--- Atom is not allowed to have USE flag(s) in %s: %s\\n\", filename, k), -1, nil)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif atoms[a] == nil {\n\t\t\t\t\tatoms[a] = v\n\t\t\t\t} else {\n\t\t\t\t\tatoms[a] = append(atoms[a], v...)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif juststrings {\n\t\tfor k, v := range atoms {\n\t\t\tatoms[k] = []string{strings.Join(v, \" \")}\n\t\t}\n\t}\n\treturn atoms\n}", "func unmarshalStaticVars() {\n\n}", "func (r *PublishVersionRequest) FromJsonString(s string) error {\n\tf := make(map[string]interface{})\n\tif err := json.Unmarshal([]byte(s), &f); err != nil {\n\t\treturn err\n\t}\n\tdelete(f, \"FunctionName\")\n\tdelete(f, \"Description\")\n\tdelete(f, \"Namespace\")\n\tif len(f) > 0 {\n\t\treturn tcerr.NewTencentCloudSDKError(\"ClientError.BuildRequestError\", \"PublishVersionRequest has unknown keys!\", \"\")\n\t}\n\treturn json.Unmarshal([]byte(s), &r)\n}", "func (s *StartupScript) UnmarshalJSON(data []byte) (err error) {\n\tif s == nil {\n\t\t*s = StartupScript{}\n\t}\n\n\tvar v map[string]interface{}\n\tif err := json.Unmarshal(data, &v); err != nil {\n\t\treturn err\n\t}\n\n\ts.ScriptID = fmt.Sprintf(\"%v\", v[\"SCRIPTID\"])\n\ts.DateCreated = fmt.Sprintf(\"%v\", v[\"date_created\"])\n\ts.DateModified = fmt.Sprintf(\"%v\", v[\"date_modified\"])\n\ts.Name = fmt.Sprintf(\"%v\", v[\"name\"])\n\ts.Type = fmt.Sprintf(\"%v\", v[\"type\"])\n\ts.Script = fmt.Sprintf(\"%v\", v[\"script\"])\n\n\treturn nil\n}", "func applyFlexMeta(cfg *load.Config) {\n\tflexMetaEnv := os.Getenv(\"FLEX_META\")\n\tjsonData := []byte(flexMetaEnv)\n\n\tvar flexMetaJSON map[string]interface{}\n\terr := json.Unmarshal(jsonData, &flexMetaJSON)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif cfg.CustomAttributes == nil {\n\t\tcfg.CustomAttributes = map[string]string{}\n\t}\n\n\tfor key, value := range flexMetaJSON {\n\t\tcfg.CustomAttributes[key] = fmt.Sprintf(\"%v\", value)\n\t}\n}", "func (r *TextTranslateRequest) FromJsonString(s string) error {\n\tf := make(map[string]interface{})\n\tif err := json.Unmarshal([]byte(s), &f); err != nil {\n\t\treturn err\n\t}\n\tdelete(f, \"SourceText\")\n\tdelete(f, \"Source\")\n\tdelete(f, \"Target\")\n\tdelete(f, \"ProjectId\")\n\tdelete(f, \"UntranslatedText\")\n\tif len(f) > 0 {\n\t\treturn tcerr.NewTencentCloudSDKError(\"ClientError.BuildRequestError\", \"TextTranslateRequest has unknown keys!\", \"\")\n\t}\n\treturn json.Unmarshal([]byte(s), &r)\n}", "func ReadVars(envarprefixes ...string) error {\n\tvar (\n\t\ti interface{}\n\t)\n\tif len(envarprefixes) == 0 {\n\t\tfor k := range envFiles {\n\t\t\tenvarprefixes = append(envarprefixes, k)\n\t\t}\n\t}\n\tfmt.Println(\"envarprefixes\", envarprefixes)\n\tfor _, prefix := range envarprefixes {\n\t\tswitch prefix {\n\t\tcase \"go_crawler\":\n\t\t\ti = &crawlerEnvVars\n\t\tcase \"aws\":\n\t\t\ti = &awsEnvVars\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"No existe la configuración %s\", prefix)\n\t\t}\n\t\terr := envconfig.Process(prefix, i)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Error al leer las variables: %v\", err)\n\t\t}\n\t}\n\treturn nil\n}", "func NewCommandFromJSON(configPath, dbName string) (*Command, error) {\n\tb, err := helper.ReadFile(configPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcom := Command{}\n\tif err := com.Config.ParseJSON(b); err != nil {\n\t\treturn nil, err\n\t}\n\tif dbName != \"\" {\n\t\tcom.Config.MysqlConfig.DbName = dbName\n\t}\n\tcom.ReadAt = time.Now()\n\treturn &com, nil\n}", "func setUp() {\n\tdefaultData := map[string]string{\n\t\t\"key1\": \"value1\",\n\t\t\"key2\": \"value2\",\n\t\t\"key3\": \"value3\",\n\t}\n\tjsonData, _ := json.Marshal(defaultData)\n\terr := ioutil.WriteFile(JsonTestPath, jsonData, 0644)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n}", "func (s *ControlService) loadInitData(filePath string) error {\n\ts.SupportedFeatures = make(FeatureMap)\n\tfile, err := ioutil.ReadFile(filePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar features []*pb.Feature\n\tif err := json.Unmarshal(file, &features); err != nil {\n\t\treturn err\n\t}\n\tfor _, f := range features {\n\t\ts.SupportedFeatures[f.Fname.Name] = f\n\t}\n\treturn nil\n}", "func (r *CreateAliasResponse) FromJsonString(s string) error {\n\treturn json.Unmarshal([]byte(s), &r)\n}", "func (r *GetAliasRequest) FromJsonString(s string) error {\n\tf := make(map[string]interface{})\n\tif err := json.Unmarshal([]byte(s), &f); err != nil {\n\t\treturn err\n\t}\n\tdelete(f, \"FunctionName\")\n\tdelete(f, \"Name\")\n\tdelete(f, \"Namespace\")\n\tif len(f) > 0 {\n\t\treturn tcerr.NewTencentCloudSDKError(\"ClientError.BuildRequestError\", \"GetAliasRequest has unknown keys!\", \"\")\n\t}\n\treturn json.Unmarshal([]byte(s), &r)\n}", "func (e *EnvironmentVariablesMapV0) UnmarshalJSON(data []byte) error {\n\tvar plain []string\n\tif err := json.Unmarshal(data, &plain); err == nil {\n\t\te.RawCPU = []string{}\n\t\te.RawGPU = []string{}\n\t\te.RawCPU = append(e.RawCPU, plain...)\n\t\te.RawGPU = append(e.RawGPU, plain...)\n\t\treturn nil\n\t}\n\ttype DefaultParser EnvironmentVariablesMapV0\n\tvar jsonItems DefaultParser\n\tif err := json.Unmarshal(data, &jsonItems); err != nil {\n\t\treturn errors.Wrapf(err, \"failed to parse runtime items\")\n\t}\n\te.RawCPU = []string{}\n\te.RawGPU = []string{}\n\tif jsonItems.RawCPU != nil {\n\t\te.RawCPU = append(e.RawCPU, jsonItems.RawCPU...)\n\t}\n\tif jsonItems.RawGPU != nil {\n\t\te.RawGPU = append(e.RawGPU, jsonItems.RawGPU...)\n\t}\n\treturn nil\n}", "func InitEnv() error {\n\tfile, err := ioutil.ReadFile(envPath)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif errMarsh := codec.DecJson(file, &env); errMarsh != nil {\n\t\treturn fmt.Errorf(\"failed to parse %s. decode error: %v\", string(file), err)\n\t}\n\n\treturn nil\n}", "func (s *Values) Setup() error {\n\treturn nil\n}", "func (r *DescribeFlowTrendRequest) FromJsonString(s string) error {\n\tf := make(map[string]interface{})\n\tif err := json.Unmarshal([]byte(s), &f); err != nil {\n\t\treturn err\n\t}\n\tdelete(f, \"Domain\")\n\tdelete(f, \"StartTs\")\n\tdelete(f, \"EndTs\")\n\tif len(f) > 0 {\n\t\treturn tcerr.NewTencentCloudSDKError(\"ClientError.BuildRequestError\", \"DescribeFlowTrendRequest has unknown keys!\", \"\")\n\t}\n\treturn json.Unmarshal([]byte(s), &r)\n}", "func storeEnvs(origEnvs map[string]string) error {\n\tfor key, val := range origEnvs {\n\t\tkeyParts := strings.Split(key, \"_\")\n\n\t\t// skip error format\n\t\t// env key format must be MODNAME_XXX_YYYY...\n\t\tif len(keyParts) < 2 {\n\t\t\tcontinue\n\t\t}\n\n\t\tenvType := strings.ToLower(keyParts[0])\n\t\tnewKey := strings.Join(keyParts[1:], \"_\")\n\t\tif _, ok := envs[envType]; !ok {\n\t\t\tenvs[envType] = make(map[string]string)\n\t\t}\n\n\t\tmoduleEnv := envs[envType]\n\t\tsetValue := strings.Trim(val, \"\\\"\")\n\t\tmoduleEnv[newKey] = setValue\n\t}\n\n\tenvsStr, _ := json.MarshalIndent(envs, \"\", \" \")\n\tlogger.Info.Printf(\"Load config: %s\\n\", envsStr)\n\treturn nil\n}", "func (r *CreateAliasRequest) FromJsonString(s string) error {\n\tf := make(map[string]interface{})\n\tif err := json.Unmarshal([]byte(s), &f); err != nil {\n\t\treturn err\n\t}\n\tdelete(f, \"Name\")\n\tdelete(f, \"FunctionName\")\n\tdelete(f, \"FunctionVersion\")\n\tdelete(f, \"Namespace\")\n\tdelete(f, \"RoutingConfig\")\n\tdelete(f, \"Description\")\n\tif len(f) > 0 {\n\t\treturn tcerr.NewTencentCloudSDKError(\"ClientError.BuildRequestError\", \"CreateAliasRequest has unknown keys!\", \"\")\n\t}\n\treturn json.Unmarshal([]byte(s), &r)\n}", "func ParsePackageJSON(rawFile []byte) map[string]string {\n\tv, _ := jason.NewObjectFromBytes(rawFile)\n\n\tdevDependecies, _ := v.GetObject(\"devDependencies\")\n\tdeps, _ := v.GetObject(\"dependencies\")\n\n\tversions := map[string]string{}\n\tassignVersionsFromDeps(devDependecies, versions)\n\tassignVersionsFromDeps(deps, versions)\n\n\treturn versions\n}", "func (l *configLoader) FillVariables(preparedConfig map[interface{}]interface{}, vars []*latest.Variable) error {\n\t// Find out what vars are really used\n\tvarsUsed := map[string]bool{}\n\terr := walk.Walk(preparedConfig, varMatchFn, func(path, value string) (interface{}, error) {\n\t\tvarspkg.ParseString(value, func(v string) (interface{}, error) {\n\t\t\tvarsUsed[v] = true\n\t\t\treturn \"\", nil\n\t\t})\n\n\t\treturn value, nil\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Parse cli --var's\n\tvarsParsed, err := ParseVarsFromOptions(l.options)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Fill used defined variables\n\tif len(vars) > 0 {\n\t\tnewVars := []*latest.Variable{}\n\t\tfor _, variable := range vars {\n\t\t\tif varsUsed[strings.TrimSpace(variable.Name)] {\n\t\t\t\tnewVars = append(newVars, variable)\n\t\t\t}\n\t\t}\n\n\t\tif len(newVars) > 0 {\n\t\t\terr = l.askQuestions(newVars, varsParsed)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// Walk over data and fill in variables\n\tl.resolvedVars = map[string]string{}\n\terr = walk.Walk(preparedConfig, varMatchFn, func(path, value string) (interface{}, error) {\n\t\treturn l.VarReplaceFn(path, value, varsParsed)\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func DecodeVars(r io.Reader) (p *PKGBUILD, err error) {\n\tp = New()\n\tsc := scanner.NewVarScanner(r)\n\tif err = p.Scan(sc, true); err != nil {\n\t\tp = nil\n\t}\n\treturn\n}" ]
[ "0.55925316", "0.54728365", "0.54148096", "0.5374281", "0.53484166", "0.52084845", "0.5208345", "0.5178336", "0.51544327", "0.5094269", "0.50767475", "0.5066785", "0.506295", "0.5060029", "0.50245893", "0.49681205", "0.49542847", "0.49385795", "0.49327472", "0.4896272", "0.48926836", "0.48762593", "0.4869893", "0.485055", "0.48477015", "0.4840168", "0.48326918", "0.48263782", "0.48247457", "0.4801045", "0.4799495", "0.47915018", "0.4791405", "0.47901207", "0.47866535", "0.47839054", "0.47807238", "0.47713387", "0.4759391", "0.47412238", "0.4734638", "0.47215107", "0.4707563", "0.4701017", "0.4691445", "0.46896768", "0.4679432", "0.46577328", "0.46485972", "0.4642021", "0.4639705", "0.4639605", "0.46361342", "0.4635254", "0.46343967", "0.46337497", "0.4626351", "0.46206775", "0.4619041", "0.46061853", "0.4601535", "0.45934644", "0.45871356", "0.4582171", "0.4579131", "0.4577741", "0.45738587", "0.45724466", "0.4566355", "0.4565446", "0.45648324", "0.45629722", "0.4562521", "0.45493314", "0.45377755", "0.45325902", "0.45263353", "0.4521806", "0.4521674", "0.45195097", "0.45128378", "0.4510526", "0.45104855", "0.45064056", "0.4504727", "0.45021954", "0.45013094", "0.44997296", "0.44988573", "0.4488819", "0.4485864", "0.44846138", "0.44830808", "0.44754526", "0.44750822", "0.44668308", "0.44627035", "0.44621402", "0.44610187", "0.44561756" ]
0.69953114
0
NewDeviceContext creates a new context given a DeviceConfig. DeviceContext will use that configuration to compute how long requests take.
func newDeviceContext(config *slowfs.DeviceConfig) *deviceContext { var writeBackCache *writeBackCache if config.FsyncStrategy == slowfs.WriteBackCachedFsync { writeBackCache = newWriteBackCache(config) } return &deviceContext{ deviceConfig: config, logger: log.New(os.Stderr, "DeviceContext: ", log.Ldate|log.Ltime|log.Lshortfile), writeBackCache: writeBackCache, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewContext(config *Config) (*Context, error) {\n\tvar context Context\n\tvar ret C.int32_t\n\tif config != nil {\n\t\tret = C.tiledb_ctx_alloc(config.tiledbConfig, &context.tiledbContext)\n\t} else {\n\t\tret = C.tiledb_ctx_alloc(nil, &context.tiledbContext)\n\t}\n\tif ret != C.TILEDB_OK {\n\t\treturn nil, fmt.Errorf(\"error creating tiledb context: %s\", context.LastError())\n\t}\n\n\t// Set finalizer for free C pointer on gc\n\truntime.SetFinalizer(&context, func(context *Context) {\n\t\tcontext.Free()\n\t})\n\n\terr := context.setDefaultTags()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error creating tiledb context: %s\", err.Error())\n\t}\n\n\treturn &context, nil\n}", "func NewContext(dir string, config *opt.Options, dataCount uint64) (*Context, error) {\n\tstorages, err := initStorages(config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif dataCount > math.MaxUint32 {\n\t\treturn nil, errors.ErrContextOverflow\n\t}\n\n\tcontext := &Context{\n\t\tconfig: config,\n\t\tsp: nil,\n\t\tstorages: storages,\n\t\tlock: sync.RWMutex{},\n\t}\n\n\tcontext.SetStoragePointer(uint32(dataCount))\n\tfmt.Println(\"Create YTFS content success, current sp = \", context.sp)\n\treturn context, nil\n}", "func CreateContext(hDc unsafe.Pointer) unsafe.Pointer {\n\tret, _, _ := syscall.Syscall(gpCreateContext, 1, uintptr(hDc), 0, 0)\n\treturn (unsafe.Pointer)(ret)\n}", "func NewContext(ctx context.Context, cfg *Config) context.Context {\n\treturn context.WithValue(ctx, cfgKey, cfg)\n}", "func NewContext(wg *sync.WaitGroup, clockType ClockType, rclArgs *RCLArgs) (ctx *Context, err error) {\n\tctx = &Context{WG: wg}\n\tdefer onErr(&err, ctx.Close)\n\n\tif err = rclInit(rclArgs, ctx); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif wg == nil {\n\t\tctx.WG = &sync.WaitGroup{}\n\t}\n\n\tif clockType != 0 {\n\t\tctx.Clock, err = ctx.NewClock(clockType)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn ctx, nil\n}", "func NewContext(ctx context.Context, cfg config.Config, log log15.Logger) (*Context, error) {\n\tif log == nil {\n\t\treturn nil, errors.New(\"log cannot be nil\")\n\t}\n\tc := &Context{\n\t\tContext: ctx,\n\t\tcfg: cfg,\n\t\tlog: log,\n\t\tapiKeychain: NewKeychain(),\n\t\twebKeychain: NewKeychain(),\n\t}\n\terr := c.registerKeychainFromConfig()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error loading keys from config: %v\", err)\n\t}\n\tif cfg.Database.MaxOpenConns <= 0 {\n\t\treturn nil, fmt.Errorf(\"invalid value for max open db conns %d\", cfg.Database.MaxOpenConns)\n\t}\n\tc.rateLimit = make(chan struct{}, cfg.Database.MaxOpenConns)\n\tfor i := 0; i < cfg.Database.MaxOpenConns; i++ {\n\t\tc.rateLimit <- struct{}{}\n\t}\n\treturn c, nil\n}", "func NewContext(c context.Context, dbg func() bool) Context {\n\treturn &ctx{Context: c, dbg: dbg}\n}", "func NewContext(outputType ContextType, now time.Time, state *ApplicationState) *Context {\n\treturn &Context{\n\t\toutputType: outputType,\n\t\tcurrentTime: now,\n\t\tgasAccountant: NewNopGasAccountant(),\n\t\tstate: state,\n\t}\n}", "func newContext(canv *canvas) Context {\n\treturn &context{\n\t\tcanvas: canv,\n\t}\n}", "func NewContext(networkID string, bridgeName string, params map[string]string, defaultProxyPort int64, dnsPort int64) (*Context, error) {\n\n\tnetworkContext := &Context{\n\t\tID: networkID,\n\t\tBridgeName: bridgeName,\n\t\tTunnelDNSPort: dnsPort,\n\t}\n\terr := parseNetworkConfiguration(networkContext, params, defaultProxyPort)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = preconditions(networkContext)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tredsocksContext, redsocksError := redsocks.NewContext(buildRedsocksConfig(networkContext))\n\n\tif redsocksError != nil {\n\t\treturn nil, err\n\t}\n\n\tnetworkContext.redsocks = redsocksContext\n\n\treturn networkContext, nil\n}", "func NewContext(config, secrets map[string]interface{}) *Context {\n\treturn &Context{\n\t\tresults: starlark.StringDict{},\n\t\tvalues: starlark.StringDict{},\n\t\tconfig: config,\n\t\tsecrets: secrets,\n\t}\n}", "func NewCmdConfigUseContext(out io.Writer, configAccess clientcmd.ConfigAccess) *cobra.Command {\n\toptions := &useContextOptions{configAccess: configAccess}\n\n\tcmd := &cobra.Command{\n\t\tUse: \"use-context CONTEXT_NAME\",\n\t\tDisableFlagsInUseLine: true,\n\t\tShort: i18n.T(\"Set the current-context in a kubeconfig file\"),\n\t\tAliases: []string{\"use\"},\n\t\tLong: `Set the current-context in a kubeconfig file.`,\n\t\tExample: useContextExample,\n\t\tValidArgsFunction: completion.ContextCompletionFunc,\n\t\tRun: func(cmd *cobra.Command, args []string) {\n\t\t\tcmdutil.CheckErr(options.complete(cmd))\n\t\t\tcmdutil.CheckErr(options.run())\n\t\t\tfmt.Fprintf(out, \"Switched to context %q.\\n\", options.contextName)\n\t\t},\n\t}\n\n\treturn cmd\n}", "func NewContext(denyNetworkAccess bool, format string, depth int) *Context {\n\tcontext, _ := NewContextWithCache(denyNetworkAccess, format, depth, MemoryCache)\n\treturn context\n}", "func NewContext(ctx context.Context, config *Config) context.Context {\n\treturn context.WithValue(ctx, configContextKey{}, config)\n}", "func NewCtx(\n\tservice string,\n\tc *config.Config,\n\tl log.Logger,\n\ts stats.Stats,\n\tsd disco.Agent,\n) Ctx {\n\t// Build background registry\n\treg := bg.NewReg(service, l, s)\n\n\tlf := []log.Field{\n\t\tlog.String(\"node\", c.Node),\n\t\tlog.String(\"version\", c.Version),\n\t\tlog.String(\"log_type\", \"A\"),\n\t}\n\n\tctx, cancelFunc := goc.WithCancel(goc.Background())\n\n\treturn &context{\n\t\tservice: service,\n\t\tappConfig: c,\n\t\tbgReg: reg,\n\t\tdisco: sd,\n\t\tc: ctx,\n\t\tcancelFunc: cancelFunc,\n\t\tl: l.AddCalldepth(1),\n\t\tlFields: lf,\n\t\tstats: s,\n\t}\n}", "func NewContext(clock *hlc.Clock, config *TLSConfig) *Context {\n\treturn &Context{\n\t\tlocalClock: clock,\n\t\ttlsConfig: config,\n\t\tRemoteClocks: newRemoteClockMonitor(clock),\n\t}\n}", "func New() *Context {\n\tc := &Context{newNode()}\n\treturn c\n}", "func (code *InterpCode) NewContext(cfg *ContextConfig) (ictx Context, err error) {\n\tdefer func() {\n\t\tierr := recover()\n\t\tif ierr == nil {\n\t\t\treturn\n\t\t}\n\t\tif v, ok := ierr.(error); ok {\n\t\t\terr = v\n\t\t}\n\t\terr = fmt.Errorf(\"%s\", ierr)\n\t}()\n\tdefer CaptureTrap(&err)\n\tvm, err := exec.NewVM(code.module,\n\t\texec.WithLazyCompile(true),\n\t\texec.WithGasMapper(new(GasMapper)),\n\t\texec.WithGasLimit(cfg.GasLimit))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvm.RecoverPanic = true\n\tctx := &wagonContext{\n\t\tmodule: code.module,\n\t\tvm: vm,\n\t\tuserData: make(map[string]interface{}),\n\t}\n\tvm.UserData = ctx\n\tictx = ctx\n\treturn\n}", "func NewContext() *Context {\n\treturn &Context{\n\t\tr: raster.NewRasterizer(0, 0),\n\t\tfontSize: 12,\n\t\tdpi: 72,\n\t\tscale: 12 << 6,\n\t}\n}", "func NewContext(discord *discordgo.Session, guild *discordgo.Guild, textChannel *discordgo.Channel,\n\tuser *discordgo.User, message *discordgo.MessageCreate, cmdHandler *CommandHandler, config Configuration) *Context {\n\tctx := new(Context)\n\tctx.Discord = discord\n\tctx.Guild = guild\n\tctx.TextChannel = textChannel\n\tctx.User = user\n\tctx.Message = message\n\tctx.CmdHandler = cmdHandler\n\tctx.Config = config\n\n\treturn ctx\n}", "func newContext(config *Config) (*Context, error) {\n\tctx := &Context{Env: make(map[string]string)}\n\n\tfor _, envVarName := range config.Envvars {\n\t\tvalue := os.Getenv(envVarName)\n\t\tif value != \"\" {\n\t\t\t//log.Printf(\"Env var %s found with value '%s'\", envVarName, value)\n\t\t\tctx.Env[envVarName] = value\n\t\t} else {\n\t\t\treturn nil, errors.New(fmt.Sprintf(\"Env var %s not defined!\", envVarName))\n\t\t}\n\t}\n\n\treturn ctx, nil\n}", "func NewContext(w http.ResponseWriter, r *http.Request) (*Context, error) {\n var s *Session\n var u *UserSession\n var err error\n\n s, err = GetSession(w, r)\n if err != nil {\n return nil, err\n }\n\n u, err = GetUserSession(w, r)\n if err != nil {\n return nil, err\n }\n\n data := setup(w, r, u, s)\n\n return &Context{\n W: w,\n R: r,\n Session: s,\n UserSession: u,\n Data: data,\n }, nil\n}", "func NewContext(retPc, nlocals int) *Context {\n\treturn &Context{returnPc: retPc, locals: make([]int, nlocals)}\n}", "func NewContext(testID string) *Context {\n\tctx := &Context{\n\t\ttestID: testID,\n\t\tEnv: NewEnv(),\n\t\tAppIDManager: NewAppIDManager(),\n\t\tclient: &http.Client{},\n\t}\n\tmgr := &CRDManager{context: ctx}\n\tctx.CRDManager = mgr\n\treturn ctx\n}", "func NewTestContext(t *testing.T) (*testContext, error) {\n\tfmwkTestContext := framework.NewTestCtx(t)\n\tnamespace, err := fmwkTestContext.GetNamespace()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"test context instantiation failed\")\n\t}\n\t// number of nodes, retry interval and timeout should come from user-input flags\n\treturn &testContext{osdkTestCtx: fmwkTestContext, kubeclient: framework.Global.KubeClient,\n\t\ttimeout: retry.Timeout, retryInterval: retry.Interval, namespace: namespace}, nil\n}", "func NewContext() (Context, error) {\n\tctx := C.sfContext_create()\n\tif ctx == nil {\n\t\treturn Context{nil}, errors.New(\"Couldn't make a new context\")\n\t}\n\treturn Context{ctx}, nil\n}", "func NewContext(r *http.Request, w http.ResponseWriter) Context {\n\treturn &ContextInstance{\n\t\tr: NewRequest(r),\n\t\tw: NewResponseWriter(w),\n\t\tvalues: map[ContextKey]interface{}{},\n\t\tstartTime: time.Now(),\n\t}\n}", "func NewCONTEXT() *CONTEXT {\n\tvar c *CONTEXT\n\tbuf := make([]byte, unsafe.Sizeof(*c)+15)\n\treturn (*CONTEXT)(unsafe.Pointer((uintptr(unsafe.Pointer(&buf[15]))) &^ 15))\n}", "func NewContext() *Context {\n\treturn &Context{\n\t\tAutoShell: true,\n\t\tForeground: true,\n\t\tBlock: true,\n\t\tDry: false,\n\t}\n}", "func NewContext() (c *Context) {\n\tc = new(Context)\n\tc.Ctx, c.Cancel = context.WithCancel(context.Background())\n\t// don't block if DB and NATS terminated with an error together\n\tc.Err = make(chan error, 2)\n\treturn\n}", "func NewCtx(t Tester) *Ctx {\n\tdir, err := ioutil.TempDir(\"\", \"xslate-test-\")\n\tif err != nil {\n\t\tpanic(\"Failed to create temporary directory!\")\n\t}\n\n\treturn &Ctx{t, dir}\n}", "func (n *Neural32) NewContext() *Context32 {\n\tlayers, depth := n.Layers, len(n.Layers)\n\n\tactivations := make([][]float32, depth)\n\tfor i, width := range layers {\n\t\tactivations[i] = vector32(width, 1.0)\n\t}\n\n\treturn &Context32{\n\t\tNeural32: n,\n\t\tActivations: activations,\n\t}\n}", "func CreateLayerContext(hDc unsafe.Pointer, level unsafe.Pointer) unsafe.Pointer {\n\tret, _, _ := syscall.Syscall(gpCreateLayerContext, 2, uintptr(hDc), uintptr(level), 0)\n\treturn (unsafe.Pointer)(ret)\n}", "func NewContext() *Context {\n\tcx := &Context{}\n\tcx.id = uid()\n\tcx.ready = make(chan error, 1)\n\tcx.in = make(chan *cxfn)\n\tcx.objs = make(map[int]*Object)\n\tcx.funcs = make(map[int]*function)\n\tvar err error\n\tjsapi.do(func() {\n\t\tif C.JSAPI_NewContext(C.int(cx.id)) != C.JSAPI_OK {\n\t\t\terr = fmt.Errorf(\"failed to spawn new context\")\n\t\t\treturn\n\t\t}\n\t\tcontexts[cx.id] = cx\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\terr = <-cx.ready\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tcx.Valid = true\n\truntime.SetFinalizer(cx, finalizer)\n\tcx.do(func(ptr *C.JSAPIContext) {\n\t\tcx.ptr = ptr\n\t})\n\treturn cx\n}", "func NewContext() *context {\n\treturn &context{\n\t\tstore: make(map[uint64]trace.Event),\n\t\tmutex: &sync.Mutex{},\n\t\tcounter: counter.NewCounter(0),\n\t}\n}", "func NewContext(block *core.Block, engine db.DB, wb db.WriteBatch) Context {\n\treturn &DefaultContext{\n\t\tqueryEngine: engine,\n\t\twb: wb,\n\t\tblock: block,\n\t\tchannelID: block.Header.ChannelID,\n\t\tevmCtx: &evm.Context{\n\t\t\tBlockHeight: block.GetNumber(),\n\t\t\tBlockTime: block.Header.Time,\n\t\t\tDifficulty: 0,\n\t\t\tGasLimit: 10000000000,\n\t\t\tGasPrice: 0,\n\t\t\tCoinBase: nil,\n\t\t},\n\t\taccounts: make(map[string]*accountInfo),\n\t}\n}", "func NewContext(r *http.Request, w http.ResponseWriter, ps httprouter.Params) Context {\n\treturn newContext(r, w, ps)\n}", "func New() *Context {\n\treturn &Context{}\n}", "func ContextCreate() (*Context, error) {\n\tcontext := newContext()\n\treturn context, nil\n}", "func (c Context) New() Context {\n\treturn Context{\n\t\tLog: c.Log,\n\t\tdata: make(map[string]interface{}),\n\t}\n}", "func NewContext(apiKey string, cloudAddr string) *Context {\n\tctx := &Context{\n\t\tapiKey: apiKey,\n\t\tcloudAddr: cloudAddr,\n\t}\n\treturn ctx\n}", "func NewCmdConfigGetContext(rootSettings *environment.AirshipCTLSettings) *cobra.Command {\n\n\ttheContext := &config.ContextOptions{}\n\tgetcontextcmd := &cobra.Command{\n\t\tUse: \"get-context NAME\",\n\t\tShort: getContextLong,\n\t\tExample: getContextExample,\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif len(args) == 1 {\n\t\t\t\ttheContext.Name = args[0]\n\t\t\t}\n\t\t\treturn runGetContext(theContext, cmd.OutOrStdout(), rootSettings.Config())\n\t\t},\n\t}\n\n\tgctxInitFlags(theContext, getcontextcmd)\n\n\treturn getcontextcmd\n}", "func NewContext(\n\targs []string, in io.Reader, out io.Writer, log io.Writer,\n) (*CommandContext, error) {\n\tctx := &CommandContext{\n\t\tin: in,\n\t\tout: out,\n\t\tLog: log,\n\t}\n\n\tctx.commandName = filepath.Base(args[0])\n\tif len(args) > 1 {\n\t\tctx.directory = args[1]\n\t}\n\n\treturn ctx, nil\n}", "func NewConfigContext(ctx context.Context, v *Config) context.Context {\n\treturn context.WithValue(ctx, configKey{}, v)\n}", "func NewWsContext(deviceId, userId int64, conn *websocket.Conn) *WsContext {\n\treturn &WsContext{\n\t\tDeviceId: deviceId,\n\t\tUserId: userId,\n\t\tConn: conn,\n\t}\n}", "func newCONTEXT() *_CONTEXT {\n\tvar c *_CONTEXT\n\tbuf := make([]byte, unsafe.Sizeof(*c)+15)\n\treturn (*_CONTEXT)(unsafe.Pointer((uintptr(unsafe.Pointer(&buf[15]))) &^ 15))\n}", "func NewProcessContextByCfg(cfg ProcessConfig) *Context {\n\tif cfg.DBFile == \"\" {\n\t\tcfg.DBFile = TmpFile()\n\t}\n\tsm, err := drmaa2os.NewDefaultSessionManager(cfg.DBFile)\n\treturn &Context{\n\t\tSM: sm,\n\t\tDefaultTemplate: cfg.DefaultTemplate,\n\t\tCtxCreationErr: err}\n}", "func createContext(ctx context.Context, t uint64) (context.Context, context.CancelFunc) {\n\ttimeout := time.Duration(t) * time.Millisecond\n\treturn context.WithTimeout(ctx, timeout*time.Millisecond)\n}", "func newContext(wrapped context.Context, identifier int) Context {\n\treturn &contextImpl{wrapped, identifier, false, sync.Mutex{}}\n}", "func newContext(w http.ResponseWriter, r *http.Request) *Context {\n\treturn &Context{\n\t\tw: w,\n\t\tr: r,\n\t\tdata: nil,\n\t}\n}", "func NewContext(res http.ResponseWriter, req *http.Request) *Context {\n\treturn &Context{\n\t\tParams: make(map[string]string),\n\t\tRequest: req,\n\t\tResponse: res,\n\t\tNext: func() {},\n\t\tNextRoute: func() {},\n\t\tData: make(map[string]interface{}),\n\t}\n}", "func NewContext(ctx context.Context, t Trace) context.Context {\n\treturn context.WithValue(ctx, _ctxKey, t)\n}", "func NewCtx(w ResponseWriter, r *http.Request) *Ctx {\n\treturn &Ctx{\n\t\tid: NewCtxID(),\n\t\tresponse: w,\n\t\trequest: r,\n\t\tstate: &SyncState{},\n\t}\n}", "func CreateContext(masterKey, masterSalt []byte, profile string, ssrc uint32) (c *Context, err error) {\n\tif masterKeyLen := len(masterKey); masterKeyLen != keyLen {\n\t\treturn c, errors.Errorf(\"SRTP Master Key must be len %d, got %d\", masterKey, keyLen)\n\t} else if masterSaltLen := len(masterSalt); masterSaltLen != saltLen {\n\t\treturn c, errors.Errorf(\"SRTP Salt must be len %d, got %d\", saltLen, masterSaltLen)\n\t}\n\n\tc = &Context{\n\t\tmasterKey: masterKey,\n\t\tmasterSalt: masterSalt,\n\t\tssrc: ssrc,\n\t}\n\n\tif c.sessionKey, err = c.generateSessionKey(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif c.sessionSalt, err = c.generateSessionSalt(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tc.block, err = aes.NewCipher(c.sessionKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn c, nil\n}", "func NewContext(env map[string]string) *ContextImpl {\n\tcntx := &ContextImpl{\n\t\tenv: env,\n\t\ttest: make(map[string]string),\n\t\ttestNumber: 0,\n\t\tcorrelationId: \"\",\n\t}\n\tif cntx.env == nil {\n\t\tcntx.env = make(map[string]string)\n\t}\n\treturn cntx\n}", "func NewContext(\n\tcfg *config.Config,\n\tbuildVersion string,\n\tresolver hostname.ResolverChangeNotifier,\n\tlookup host.IDLookup,\n\tsampleMatchFn sampler.IncludeSampleMatchFn,\n) *context {\n\tctx, cancel := context2.WithCancel(context2.Background())\n\n\tvar agentKey atomic.Value\n\tagentKey.Store(\"\")\n\treturn &context{\n\t\tcfg: cfg,\n\t\tCtx: ctx,\n\t\tCancelFn: cancel,\n\t\tid: id.NewContext(ctx),\n\t\treconnecting: new(sync.Map),\n\t\tversion: buildVersion,\n\t\tservicePidLock: &sync.RWMutex{},\n\t\tservicePids: make(map[string]map[int]string),\n\t\tresolver: resolver,\n\t\tidLookup: lookup,\n\t\tshouldIncludeEvent: sampleMatchFn,\n\t\tagentKey: agentKey,\n\t}\n}", "func NewContext(options *ContextOptions) (*Context, error) {\n\tstatus := newStatus()\n\tcOpt, err := options.c()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer C.TFE_DeleteContextOptions(cOpt)\n\tcContext := C.TFE_NewContext(cOpt, status.c)\n\tif err := status.Err(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tc := &Context{c: cContext}\n\truntime.SetFinalizer(c, (*Context).finalizer)\n\treturn c, nil\n}", "func NewSetContextCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Command {\n\to := &config.ContextOptions{}\n\tcmd := &cobra.Command{\n\t\tUse: \"set-context NAME\",\n\t\tShort: \"Manage contexts\",\n\t\tLong: setContextLong[1:],\n\t\tExample: setContextExample,\n\t\tArgs: cobra.MaximumNArgs(1),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tnFlags := cmd.Flags().NFlag()\n\t\t\tif len(args) == 1 {\n\t\t\t\t// context name is made optional with --current flag added\n\t\t\t\to.Name = args[0]\n\t\t\t}\n\t\t\tif o.Name != \"\" && nFlags == 0 {\n\t\t\t\tfmt.Fprintf(cmd.OutOrStdout(), \"Context %q not modified. No new options provided.\\n\", o.Name)\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tmodified, err := config.RunSetContext(o, rootSettings.Config, true)\n\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif modified {\n\t\t\t\tfmt.Fprintf(cmd.OutOrStdout(), \"Context %q modified.\\n\", o.Name)\n\t\t\t} else {\n\t\t\t\tfmt.Fprintf(cmd.OutOrStdout(), \"Context %q created.\\n\", o.Name)\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\n\taddSetContextFlags(o, cmd)\n\treturn cmd\n}", "func NewContext(l *LARS) *Ctx {\n\n\tc := &Ctx{\n\t\tparams: make(Params, l.mostParams),\n\t}\n\n\tc.response = newResponse(nil, c)\n\n\treturn c\n}", "func NewTestContext(t *testing.T) *TestContext {\n\t// Provide a way for tests to provide and capture stdin and stdout\n\t// Copy output to the test log simultaneously, use go test -v to see the output\n\terr := &bytes.Buffer{}\n\taggErr := io.MultiWriter(err, test.Logger{T: t})\n\tout := &bytes.Buffer{}\n\taggOut := io.MultiWriter(out, test.Logger{T: t})\n\n\tinnerContext := New()\n\tinnerContext.correlationId = \"0\"\n\tinnerContext.timestampLogs = false\n\tinnerContext.environ = getEnviron()\n\tinnerContext.FileSystem = aferox.NewAferox(\"/\", afero.NewMemMapFs())\n\tinnerContext.In = &bytes.Buffer{}\n\tinnerContext.Out = aggOut\n\tinnerContext.Err = aggErr\n\tinnerContext.ConfigureLogging(context.Background(), LogConfiguration{\n\t\tLogLevel: zapcore.DebugLevel,\n\t\tVerbosity: zapcore.DebugLevel,\n\t})\n\tinnerContext.PlugInDebugContext = &PluginDebugContext{\n\t\tDebuggerPort: \"2735\",\n\t\tRunPlugInInDebugger: \"\",\n\t\tPlugInWorkingDirectory: \"\",\n\t}\n\n\tc := &TestContext{\n\t\tContext: innerContext,\n\t\tcapturedOut: out,\n\t\tcapturedErr: err,\n\t\tT: t,\n\t}\n\n\tc.NewCommand = c.NewTestCommand\n\n\treturn c\n}", "func New(mode string, configurator *configurator.Configurator) (*Contexter) {\n\treturn &Contexter {\n\t\tmode: mode,\n\t\tContext: nil,\n\t\tconfigurator: configurator,\n\t}\n}", "func NewContext(data map[string]interface{}) *Context {\n\treturn &Context{\n\t\tData: data,\n\t}\n}", "func NewContext(r *http.Request, rw http.ResponseWriter) *Context {\n\treturn &Context{\n\t\tRequest: r,\n\t\tResponse: rw,\n\t\tParams: url.Values{},\n\t}\n}", "func newCtx(dir string) (*sdcgContext, error) {\n\tvar err error\n\tif dir == \"\" {\n\t\tdir, err = os.Getwd()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to get working directory: %w\", err)\n\t\t}\n\t}\n\tmodFile, err := findGoModFile(dir)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tmod, err := gomod.Parse(\"go.mod\", modFile)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &sdcgContext{\n\t\tdir: dir,\n\t\tcurrentModule: mod.Name,\n\t}, nil\n}", "func NewContext(parent context.Context, ds Datastore) context.Context {\n\treturn &wrapper{parent, ds}\n}", "func NewContext(ctx context.Context, vos Vos) context.Context {\n\treturn context.WithValue(ctx, fsKey, vos)\n}", "func (p *Platform) newContext(destroy bool) (*terraform.Context, error) {\n\tcfg, err := p.config()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvars, err := p.variables(cfg.Module.Variables)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// providerResolver := providers.ResolverFixed(p.Providers)\n\t// provisioners := p.Provisioners\n\n\t// Create ContextOpts with the current state and variables to apply\n\tctxOpts := terraform.ContextOpts{\n\t\tConfig: cfg,\n\t\tDestroy: destroy,\n\t\tState: p.State,\n\t\tVariables: vars,\n\t\tProviderResolver: providers.ResolverFixed(p.Providers),\n\t\tProvisioners: p.Provisioners,\n\t\tHooks: p.Hooks,\n\t}\n\n\tctx, diags := terraform.NewContext(&ctxOpts)\n\tif diags.HasErrors() {\n\t\treturn nil, diags.Err()\n\t}\n\n\t// Validate the context\n\tif diags = ctx.Validate(); diags.HasErrors() {\n\t\treturn nil, diags.Err()\n\t}\n\n\treturn ctx, nil\n}", "func (ds *ServerImpl) newFlowContext(\n\tctx context.Context,\n\tid execinfrapb.FlowID,\n\tevalCtx *tree.EvalContext,\n\ttraceKV bool,\n\tcollectStats bool,\n\tlocalState LocalState,\n\tisGatewayNode bool,\n) execinfra.FlowCtx {\n\t// TODO(radu): we should sanity check some of these fields.\n\tflowCtx := execinfra.FlowCtx{\n\t\tAmbientContext: ds.AmbientContext,\n\t\tCfg: &ds.ServerConfig,\n\t\tID: id,\n\t\tEvalCtx: evalCtx,\n\t\tNodeID: ds.ServerConfig.NodeID,\n\t\tTraceKV: traceKV,\n\t\tCollectStats: collectStats,\n\t\tLocal: localState.IsLocal,\n\t\tGateway: isGatewayNode,\n\t\t// The flow disk monitor is a child of the server's and is closed on\n\t\t// Cleanup.\n\t\tDiskMonitor: execinfra.NewMonitor(\n\t\t\tctx, ds.ParentDiskMonitor, \"flow-disk-monitor\",\n\t\t),\n\t}\n\n\tif localState.IsLocal && localState.Collection != nil {\n\t\t// If we were passed a descs.Collection to use, then take it. In this case,\n\t\t// the caller will handle releasing the used descriptors, so we don't need\n\t\t// to cleanup the descriptors when cleaning up the flow.\n\t\tflowCtx.TypeResolverFactory = &descs.DistSQLTypeResolverFactory{\n\t\t\tDescriptors: localState.Collection,\n\t\t\tCleanupFunc: func(ctx context.Context) {},\n\t\t}\n\t} else {\n\t\t// If we weren't passed a descs.Collection, then make a new one. We are\n\t\t// responsible for cleaning it up and releasing any accessed descriptors\n\t\t// on flow cleanup.\n\t\tcollection := descs.NewCollection(ds.ServerConfig.Settings, ds.ServerConfig.LeaseManager.(*lease.Manager), ds.ServerConfig.HydratedTables)\n\t\tflowCtx.TypeResolverFactory = &descs.DistSQLTypeResolverFactory{\n\t\t\tDescriptors: collection,\n\t\t\tCleanupFunc: func(ctx context.Context) {\n\t\t\t\tcollection.ReleaseAll(ctx)\n\t\t\t},\n\t\t}\n\t}\n\treturn flowCtx\n}", "func NewContext(\n\tflags ParsedFlags,\n\tdescriptors []ModuleDescriptor,\n) *Context {\n\treturn &Context{\n\t\tflags: flags,\n\t\tdescriptors: descriptors,\n\t\tmoduleInstances: make(map[string]interface{}),\n\t}\n}", "func NewContext(ctx context.Context, txn Transaction) context.Context {\n\treturn context.WithValue(ctx, contextKey, txn)\n}", "func NewContext(w http.ResponseWriter, req *http.Request, s *Server) *Context {\n\tp := mux.Vars(req)\n\tsw := negroni.NewResponseWriter(w)\n\tctx := &Context{sw, req, s, p, req.URL.Query()}\n\treturn ctx\n}", "func NewContext(ctx context.Context, md Metadata) context.Context {\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\treturn context.WithValue(ctx, metadataKey{}, Copy(md))\n}", "func NewContext(r *http.Request) Context {\n\tac := appengine.NewContext(r)\n\tid := requestID(appengine.RequestID(ac))\n\n\tctxs.RLock()\n\tc, ok := ctxs.m[id]\n\tctxs.RUnlock()\n\n\tif ok {\n\t\treturn c\n\t}\n\n\tc = Context{\n\t\tContext: ac,\n\t\tR: r,\n\t\tcounters: map[string]change{},\n\t\treported: false,\n\t}\n\tctxs.Lock()\n\tctxs.m[id] = c\n\tctxs.Unlock()\n\treturn c\n}", "func New(parent context.Context, id, language string) *Context {\n\treturn &Context{\n\t\tID: id,\n\t\tLanguage: language,\n\t\tContext: context.WithValue(parent, ContextIDKey, id),\n\t}\n}", "func NewContext() Context {\n\treturn Context{\n\t\tFilter: Filter(0),\n\t\tSession: nil,\n\t\tMessage: nil,\n\t\tPrefix: \"\",\n\t\tAlias: \"\",\n\t\tArgs: nil,\n\t\tToks: Toks{},\n\t\tErr: nil,\n\t\tFmtFilterErr: defaultFmtFilterErr,\n\t}\n}", "func (message *Message) NewCtx(ctx context.Context) {\n\tmessage.mutex.Lock()\n\tdefer message.mutex.Unlock()\n\tmessage.ctx = ctx\n}", "func NewContext(ctx context.Context, s Stopwatch) context.Context {\n\treturn context.WithValue(ctx, stopwatchContextKey, s)\n}", "func NewContext(ctx context.Context, rights Rights) context.Context {\n\treturn context.WithValue(ctx, rightsKey, rights)\n}", "func NewContext(name string) (ctx *Context, err error) {\n\tif name == \"\" {\n\t\tname = \"1\"\n\t}\n\t// validate the name\n\tif !validNameRE.MatchString(name) {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"'%s' is not a valid cluster name, cluster names must match `%s`\",\n\t\t\tname, validNameRE.String(),\n\t\t)\n\t}\n\treturn &Context{\n\t\tname: name,\n\t}, nil\n}", "func newUSBContext() (*usbContext, error) {\n\tvar ctx *C.struct_libusb_context\n\tif ret := C.libusb_init(&ctx); ret < 0 {\n\t\treturn nil, newLibUSBError(ret)\n\t}\n\tvar c = (*usbContext)(ctx)\n\n\treturn c, nil\n}", "func (a *Authboss) NewContext() *Context {\n\treturn &Context{\n\t\tAuthboss: a,\n\t}\n}", "func NewContext(fns ...SetContextFn) (ctx context.Context) {\n\tctx = context.TODO()\n\tctx = ApplyContext(ctx, fns...)\n\treturn\n}", "func NewContext(top int) *Context {\n\ttotal := totalInfo{}\n\n\tctx := Context{\n\t\ttotal: &total,\n\t\ttop: top,\n\t}\n\treturn &ctx\n}", "func CreateDeferredCtx(zedcloudCtx *ZedCloudContext,\n\tps *pubsub.PubSub, agentName string, ctxName string,\n\twarningTime time.Duration, errorTime time.Duration,\n\tsentHandler *SentHandlerFunction,\n\tpriorityCheckFunctions ...TypePriorityCheckFunction) *DeferredContext {\n\t// Default \"accept all\" priority\n\tpriorityCheckFunctions = append(priorityCheckFunctions,\n\t\tfunc(obj interface{}) bool {\n\t\t\treturn true\n\t\t})\n\n\tctx := &DeferredContext{\n\t\tlock: &sync.Mutex{},\n\t\tTicker: flextimer.NewRangeTicker(longTime1, longTime2),\n\t\tsentHandler: sentHandler,\n\t\tpriorityCheckFunctions: priorityCheckFunctions,\n\t\tzedcloudCtx: zedcloudCtx,\n\t}\n\n\t// Start processing task\n\tgo ctx.processQueueTask(ps, agentName, ctxName,\n\t\twarningTime, errorTime)\n\n\treturn ctx\n}", "func New() *Context {\n\treturn &Context{\n\t\tRequest: newRequest(),\n\t\tClient: &http.Client{Transport: http.DefaultTransport},\n\t}\n}", "func NewContext() *Context {\n\treturn &Context{\n\t\n\t\tcontext: context.Background(),\n\t}\n}", "func NewContext(c ctx.Context, req *http.Request, resp http.ResponseWriter) Context {\n\twc := &webCtx{req: req, resp: resp, now: time.Now()}\n\twc.Context, wc.cancel = ctx.WithCancel(c)\n\twc.remoteIP = remoteIP(req)\n\treturn wc\n}", "func NewContextWithDeviceConnection(ctx context.Context, con *RequestDeviceConnection) context.Context {\n\treturn context.WithValue(ctx, requestDeviceConnectionKey, con)\n}", "func NewContext(ctx context.Context, client client.Client) context.Context {\n\treturn context.WithValue(ctx, statsKey, client)\n}", "func NewContext(ctx context.Context, c *Client) context.Context {\n\treturn context.WithValue(ctx, ctxKey{}, c)\n}", "func NewContext(trigger trigger.Type, bc blockchainer.Blockchainer, d dao.DAO,\n\tgetContract func(dao.DAO, util.Uint160) (*state.Contract, error), natives []Contract,\n\tblock *block.Block, tx *transaction.Transaction, log *zap.Logger) *Context {\n\tbaseExecFee := int64(DefaultBaseExecFee)\n\tdao := d.GetWrapped()\n\n\tif bc != nil && (block == nil || block.Index != 0) {\n\t\tbaseExecFee = bc.GetPolicer().GetBaseExecFee()\n\t}\n\treturn &Context{\n\t\tChain: bc,\n\t\tNetwork: uint32(bc.GetConfig().Magic),\n\t\tNatives: natives,\n\t\tTrigger: trigger,\n\t\tBlock: block,\n\t\tTx: tx,\n\t\tDAO: dao,\n\t\tLog: log,\n\t\tInvocations: make(map[util.Uint160]int),\n\t\tgetContract: getContract,\n\t\tbaseExecFee: baseExecFee,\n\t}\n}", "func NewContext(user, password, address string) Context {\n\tvar ctx Context\n\tctx.User = user\n\tctx.Password = password\n\tctx.Address = address\n\treturn ctx\n}", "func NewContext() Context {\n\treturn Context{Log: log.New(), Db: rootContext.Db}\n}", "func NewContext(stdCtx context.Context, vars *Vars) Context {\n\tctx := &rootContext{\n\t\tvars: vars,\n\t}\n\treturn withStdCancel(ctx, stdCtx)\n}", "func NewSetContextCommand(cfgFactory config.Factory) *cobra.Command {\n\to := &config.ContextOptions{}\n\tcmd := &cobra.Command{\n\t\tUse: \"set-context CONTEXT_NAME\",\n\t\tShort: \"Airshipctl command to create/modify context in airshipctl config file\",\n\t\tLong: setContextLong[1:],\n\t\tExample: setContextExample,\n\t\tArgs: cobra.MaximumNArgs(1),\n\t\tRunE: setContextRunE(cfgFactory, o),\n\t}\n\n\taddSetContextFlags(cmd, o)\n\treturn cmd\n}", "func NewKMSContext(parent context.Context, val *KMSConfig) context.Context {\n\treturn context.WithValue(parent, kmsConfigKey{}, val)\n}", "func NewContext(ctx context.Context, requestID string) Context {\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\treturn Context{context.WithValue(ctx, requestIDKey, requestID)}\n}", "func NewContext(options ...ContextOption) Context {\n\tcfg := &ContextConfig{\n\t\tIDs: newIDs(),\n\t}\n\tfor _, option := range options {\n\t\toption(cfg)\n\t}\n\n\treturn &parseContext{\n\t\tstore: make([]interface{}, ContextKeyMax+1),\n\t\trefs: map[string]Reference{},\n\t\tids: cfg.IDs,\n\t\tblockOffset: -1,\n\t\tblockIndent: -1,\n\t\tdelimiters: nil,\n\t\tlastDelimiter: nil,\n\t\topenedBlocks: []Block{},\n\t}\n}", "func NewContext() *Context {\n\tctx := new(Context)\n\tctx.data = make(map[interface{}]interface{})\n\treturn ctx\n}", "func NewContext(\n\tsession *discordgo.Session,\n\tmessage *discordgo.Message,\n\tchannel *discordgo.Channel,\n\tguild *discordgo.Guild,\n\targs []string,\n) Context {\n\treturn Context{\n\t\tSession: session,\n\t\tState: session.State,\n\t\tMessage: message,\n\t\tAuthor: message.Author,\n\t\tChannel: channel,\n\t\tGuild: guild,\n\t\tArgs: args,\n\t}\n}" ]
[ "0.60010606", "0.58748376", "0.58544135", "0.56649375", "0.55289286", "0.55034286", "0.54515684", "0.54493266", "0.5427652", "0.54165214", "0.5393935", "0.5357877", "0.53502446", "0.5347706", "0.53308403", "0.52864504", "0.52632374", "0.5250634", "0.5219931", "0.5216731", "0.52096593", "0.52055365", "0.5201148", "0.51921654", "0.51678216", "0.5153051", "0.514024", "0.510215", "0.5077524", "0.50620276", "0.5060225", "0.5057356", "0.50298536", "0.50254846", "0.5020223", "0.49661353", "0.49523342", "0.4937767", "0.4931043", "0.4929404", "0.49026006", "0.48893845", "0.48891237", "0.48886043", "0.48871803", "0.4866559", "0.48562044", "0.48548254", "0.4832943", "0.48323137", "0.48214567", "0.48196393", "0.48104113", "0.480719", "0.48033765", "0.4785931", "0.47827134", "0.47765088", "0.4771651", "0.47679162", "0.4766387", "0.47654074", "0.47647983", "0.47597906", "0.47490484", "0.4739783", "0.4730577", "0.47227216", "0.4719435", "0.47189698", "0.4716842", "0.47104692", "0.47101852", "0.4701745", "0.47017163", "0.47005677", "0.46997985", "0.46837562", "0.46809065", "0.4675736", "0.46727675", "0.46699294", "0.46560174", "0.46534008", "0.46523848", "0.46519536", "0.4648556", "0.46312347", "0.46274096", "0.462179", "0.46176457", "0.4608982", "0.45904768", "0.45881045", "0.45826587", "0.45787752", "0.45663232", "0.45653751", "0.45652702", "0.4562184" ]
0.74137986
0
ComputeTime computes how long a request should take given the current state of the device. It does not update the context.
func (dc *deviceContext) computeTime(req *Request) time.Duration { requestDuration := time.Duration(0) switch req.Type { // Handle metadata requests, plus metadata requests that have been factored out because we // need separate handling for them. case MetadataRequest, CloseRequest: requestDuration = dc.deviceConfig.MetadataOpTime case AllocateRequest: requestDuration = dc.computeSeekTime(req) + dc.deviceConfig.AllocateTime(req.Size) case ReadRequest: requestDuration = dc.computeSeekTime(req) + dc.deviceConfig.ReadTime(req.Size) case WriteRequest: switch dc.deviceConfig.WriteStrategy { case slowfs.FastWrite: // Leave at 0 seconds. case slowfs.SimulateWrite: requestDuration = dc.computeSeekTime(req) + dc.deviceConfig.WriteTime(req.Size) } case FsyncRequest: switch dc.deviceConfig.FsyncStrategy { case slowfs.DumbFsync: requestDuration = dc.deviceConfig.SeekTime * 10 case slowfs.WriteBackCachedFsync: requestDuration = dc.deviceConfig.SeekTime + dc.deviceConfig.WriteTime(dc.writeBackCache.getUnwrittenBytes(req.Path)) } default: dc.logger.Printf("unknown request type for %+v\n", req) } return latestTime(dc.busyUntil, req.Timestamp).Add(requestDuration).Sub(req.Timestamp) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getTime(r *http.Request) time.Duration {\n\tif ctx := r.Context().Value(toTime); ctx != nil {\n\t\tvalue, ok := ctx.(time.Time)\n\t\tif ok {\n\t\t\treturn time.Since(value)\n\t\t}\n\t}\n\n\treturn 0\n}", "func computeTime(referenceTime time.Time, referenceUptime, eventUptime time.Duration) time.Time {\n\tdiff := referenceUptime - eventUptime\n\tif diff < 0 {\n\t\treturn referenceTime\n\t}\n\treturn referenceTime.Add(-1 * diff)\n}", "func (c *Context) GetTime() float64 {\n\treturn float64(C.glfwGetTime())\n}", "func (c *Context) GetTime() float64 {\n\treturn float64(C.glfwGetTime())\n}", "func now() time.Duration { return time.Since(startTime) }", "func ProcessStateUserTime(p *os.ProcessState,) time.Duration", "func (id *HashChainLinkIdentity) RequestTime() (uint64, error) {\n\tif id == nil {\n\t\treturn 0, errors.New(errors.KsiInvalidArgumentError)\n\t}\n\treturn id.requestTime, nil\n}", "func calcRuntime(t time.Time, f string) {\n\t//now := time.Now()\n\t//log.Printf(\"%s cost %f millisecond\\n\", f, now.Sub(t).Seconds() * 1000)\n\t//log.Printf()\n}", "func (cont *Container) AllocatedTime() time.Duration {\n\treturn delta(cont.Destroy, cont.Create)\n}", "func ProcessStateSystemTime(p *os.ProcessState,) time.Duration", "func TimeElapsed() int64 {\n\telapsed := time.Since(start)\n\treturn elapsed.Nanoseconds() / 1000\n}", "func (b *ActivationHit) ComputeQueueTime() {\n\tb.QueueTime = int64((time.Now().Sub(b.CreatedAt)).Seconds())\n}", "func computeUptime(activeState string, activeEnterTimestampMicroSec uint64, unitNow int64) int64 {\n\tif activeState != unitActiveState {\n\t\treturn 0\n\t}\n\tuptime := unitNow - int64(activeEnterTimestampMicroSec)/1000000\n\tif uptime < 0 {\n\t\treturn 0\n\t}\n\treturn uptime\n}", "func (s *Stopwatch) elapsedTime() time.Duration {\n\tif s.active() {\n\t\treturn time.Since(s.start)\n\t}\n\treturn s.stop.Sub(s.start)\n}", "func getElapsed(start time.Time) string {\n\treturn fmt.Sprintf(\"(%.3fs)\", time.Since(start).Seconds())\n}", "func (l *Latency) Compute(ts time.Time) {\n\tl.mu.Lock()\n\tdefer l.mu.Unlock()\n\tnowTime := Now()\n\tlat := l.compute(ts, nowTime)\n\tl.totalDiff += lat / l.scaleFactor\n\tl.count++\n\tif lat > l.max {\n\t\tl.max = lat\n\t}\n\tif lat < l.min || l.min == 0 {\n\t\tl.min = lat\n\t}\n\tif l.start.IsZero() {\n\t\tl.start = nowTime\n\t}\n}", "func (c *ContextInstance) GetRunningTime() time.Duration {\n\treturn time.Now().Sub(c.startTime)\n}", "func (t *LastReqTime) Time() time.Time {\n\tt.mu.RLock()\n\tdefer t.mu.RUnlock()\n\treturn t.t\n}", "func ElapsedTime(layer, time int) int {\n\treturn time + PreparationTime(layer)\n}", "func (o *Operator) ElapsedTime() time.Duration {\n\treturn time.Since(o.createTime)\n}", "func (rc *Ctx) Elapsed() time.Duration {\n\tif !rc.requestEnd.IsZero() {\n\t\treturn rc.requestEnd.Sub(rc.requestStart)\n\t}\n\treturn time.Now().UTC().Sub(rc.requestStart)\n}", "func (s *Stats) GetCPUTimes() {\n\n if s.CPUInfo == nil {\n s.CPUInfo = new(CPUInfo)\n }\n\n s.CPUInfo.PrevCPUTimes = s.CPUInfo.PerCPUTimes\n s.CPUInfo.PerCPUTimes, _ = cpu.Times(true)\n\n if len(s.CPUInfo.PrevCPUTimes) == 0 {\n s.CPUInfo.PrevCPUTimes = s.CPUInfo.PerCPUTimes\n }\n}", "func GetTime() {\n\ttp := myTransport()\n\tclient := &http.Client{Transport: tp}\n\n\tresp, err := client.Get(\"https://gitlab.com\")\n\tif err != nil {\n\t\tlog.Fatalf(\"get error: %s: %s\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tlog.Println(\"Response Time:\", tp.Duration())\n\tlog.Println(\"Connection Time:\", tp.ConnDuration())\n\n}", "func GetCurrentSysTime(instructionData reflect.Value, finished chan bool) int {\n\tfmt.Println(\"FIBER INFO: Getting sys time...\")\n\n\tvariable.SetVariable(instructionData.FieldByName(\"Output\").Interface().(string), time.Now())\n\tfinished <- true\n\treturn -1\n}", "func (j *DSGit) CalculateTimeToReset(ctx *Ctx, rateLimit, rateLimitReset int) (seconds int) {\n\tseconds = rateLimitReset\n\treturn\n}", "func (t *Turn) TimeElapsed() time.Duration {\n\treturn time.Now().Sub(t.Start)\n}", "func GetCurrentTime() uint64 {\n\treturn ComposeTSByTime(time.Now(), 0)\n}", "func ElapsedTime(count, time int) int {\n\treturn time + PreparationTime(count)\n}", "func StatRequest(rpc string, errcode string, inTime, outTime time.Time) int64 {\n\treqCounter.With(prometheus.Labels{\n\t\t\"rpc\": rpc,\n\t\t\"errcode\": errcode,\n\t}).Inc()\n\n\tcost := toMSTimestamp(outTime) - toMSTimestamp(inTime)\n\trespTimeSummary.With(prometheus.Labels{\"rpc\": rpc}).Observe(float64(cost))\n\n\treturn cost\n}", "func (b *BaseHit) ComputeQueueTime() {\n\tb.QueueTime = int64((time.Now().Sub(b.CreatedAt)).Milliseconds())\n}", "func elapsedTimeData(ctx context.Context, d *ui.Device) (float64, error) {\n\tview := d.Object(ui.ID(mediaScanPerfPkg + \":id/media_scan_perf\"))\n\ttesting.ContextLogf(ctx, \"Waiting for a view %s matching the selector to appear\", mediaScanPerfPkg)\n\tif err := view.WaitForExists(ctx, 5*time.Minute); err != nil {\n\t\treturn 0.0, errors.Wrapf(err, \"failed to wait for a view %s matching the selector to appear\", mediaScanPerfPkg)\n\t}\n\n\ttesting.ContextLog(ctx, \"Waiting for getting the text content in app ui\")\n\tvar elapsedTime float64\n\tif err := testing.Poll(ctx, func(ctx context.Context) error {\n\t\ttext, err := view.GetText(ctx)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"failed to get the text content in app ui\")\n\t\t}\n\t\telapsedTime, err = strconv.ParseFloat(text, 64)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"failed to parse the text content in app ui to float64\")\n\t\t}\n\t\treturn nil\n\t}, &testing.PollOptions{Timeout: 10 * time.Minute}); err != nil {\n\t\treturn elapsedTime, errors.Wrap(err, \"failed to get data from app ui\")\n\t}\n\treturn elapsedTime, nil\n}", "func (b *backend) Time(ctx context.Context) (time.Time, error) {\n\tresp, err := pb.NewEntroQClient(b.conn).Time(ctx, new(pb.TimeRequest))\n\tif err != nil {\n\t\treturn time.Time{}, fmt.Errorf(\"grpc time: %w\", unpackGRPCError(err))\n\t}\n\treturn fromMS(resp.TimeMs).UTC(), nil\n}", "func (t *Task) TimeSinceStart() time.Duration {\n\tt.mutex.RLock()\n\tdefer t.mutex.RUnlock()\n\treturn time.Since(t.begun)\n}", "func GetNodeTime(n *Node) int64 {\n\tseconds := int64(0)\n\n\tmnts := n.Moments\n\tfor i := 0; i < len(mnts); i++ {\n\t\tseconds += int64(mnts[i].Activeseconds)\n\t}\n\n\tfor i := 0; i < len(n.SubNodes); i++ {\n\t\tseconds += GetNodeTime(&n.SubNodes[i])\n\t}\n\treturn seconds\n}", "func (r *client) Time(ctx context.Context, req *pb.TimeRequest) (time *pb.TimeResponse, err error) {\n\tresp, err := r.AgentClient.Time(ctx, req, r.callOptions...)\n\tif err != nil {\n\t\treturn nil, ConvertGRPCError(err)\n\t}\n\treturn resp, nil\n}", "func (me *Metrics) RecordRequestTime(labels Labels, length time.Duration) {\n\t// Only record times for successful requests, as we don't have labels to screen out bad requests.\n\tif labels.RequestStatus == RequestStatusOK {\n\t\tme.RequestTimer.Update(length)\n\t}\n}", "func (bc ByteCount) CalcTime(rate BitRate) (time.Duration, error) {\n\tif rate == 0 {\n\t\treturn 0, ErrDivZeroBitRate\n\t}\n\tns := float64(bc) * 8 * float64(time.Second) / float64(rate)\n\tif ns < float64(math.MinInt64) || float64(math.MaxInt64) < ns {\n\t\treturn 0, ErrOutOfRange\n\t}\n\treturn time.Duration(ns), nil\n}", "func ElapsedTime(numberOfLayers int, ovenTime int) int {\n\treturn PreparationTime(numberOfLayers) + ovenTime\n}", "func (b *Event) ComputeQueueTime() {\n\tb.QueueTime = int64((time.Now().Sub(b.CreatedAt)).Seconds())\n}", "func main() {\n start := time.Now()\n diffusion() //calls the diffusion method\n end := time.Now()\n fmt.Printf(\"Wall Time: %v\\n\", end.Sub(start))\n }", "func (r *Response) Time() time.Duration {\n\tif r.Request.clientTrace != nil {\n\t\treturn r.Request.TraceInfo().TotalTime\n\t}\n\treturn r.receivedAt.Sub(r.Request.Time)\n}", "func (tj *TensorFlowJob) Duration() time.Duration {\n\tjob := tj.tfjob\n\n\tif job.Status.StartTime == nil ||\n\t\tjob.Status.StartTime.IsZero() {\n\t\treturn 0\n\t}\n\n\tif !job.Status.CompletionTime.IsZero() {\n\t\treturn job.Status.CompletionTime.Time.Sub(job.Status.StartTime.Time)\n\t}\n\n\tif tj.GetStatus() == \"FAILED\" {\n\t\tcond := getPodLatestCondition(tj.chiefPod)\n\t\tif !cond.LastTransitionTime.IsZero() {\n\t\t\treturn cond.LastTransitionTime.Time.Sub(job.Status.StartTime.Time)\n\t\t} else {\n\t\t\tlog.Debugf(\"the latest condition's time is zero of pod %s\", tj.chiefPod.Name)\n\t\t}\n\t}\n\n\treturn metav1.Now().Sub(job.Status.StartTime.Time)\n}", "func DurationCompute(start, end uint8) string {\n\treturn fmt.Sprintf(\"0天%s时\", strconv.Itoa(int(end-start)))\n}", "func (d *RTPTimeDuration) Calc(_now uint32) time.Duration {\n\tnow := uint64(_now)\n\t// NOTICE: there is a bug when a RTP packet come late,\n\t// it is too complicated to detect here, please filter it when receive it.\n\tif (now - d.start) < 0 {\n\t\t// 0 2^32\n\t\t// |<---> now ---------------- start <--->|\n\t\td.accumulate += (RTPTimestampTop - d.start) + (now - 0)\n\t\td.start = now\n\t}\n\n\treturn time.Duration((d.accumulate + (now - d.start)) / d.rate)\n}", "func (m *ntpManager) processTime() error {\n\tif atomic.LoadInt32(&m.started) == 0 {\n\t\treturn fmt.Errorf(\"NTP manager %w\", ErrSubSystemNotStarted)\n\t}\n\tNTPTime, err := m.FetchNTPTime()\n\tif err != nil {\n\t\treturn err\n\t}\n\tcurrentTime := time.Now()\n\tdiff := NTPTime.Sub(currentTime)\n\tconfigNTPTime := m.allowedDifference\n\tnegDiff := m.allowedNegativeDifference\n\tconfigNTPNegativeTime := -negDiff\n\tif diff > configNTPTime || diff < configNTPNegativeTime {\n\t\tlog.Warnf(log.TimeMgr, \"NTP manager: Time out of sync (NTP): %v | (time.Now()): %v | (Difference): %v | (Allowed): +%v / %v\\n\",\n\t\t\tNTPTime,\n\t\t\tcurrentTime,\n\t\t\tdiff,\n\t\t\tconfigNTPTime,\n\t\t\tconfigNTPNegativeTime)\n\t}\n\treturn nil\n}", "func (s *Session) OperationTime() *primitive.Timestamp {\n\tpanic(\"lungo: not implemented\")\n}", "func (r *server) Time(ctx context.Context, req *pb.TimeRequest) (*pb.TimeResponse, error) {\n\treturn &pb.TimeResponse{\n\t\tTimestamp: pb.NewTimeToProto(r.agent.Time().UTC()),\n\t}, nil\n}", "func (o LookupAnalysisResultOutput) RequestTime() pulumi.StringOutput {\n\treturn o.ApplyT(func(v LookupAnalysisResult) string { return v.RequestTime }).(pulumi.StringOutput)\n}", "func (j *DSRocketchat) CalculateTimeToReset(ctx *Ctx, rateLimit, rateLimitReset int) (seconds int) {\n\tseconds = (int(int64(rateLimitReset)-(time.Now().UnixNano()/int64(1000000))) / 1000) + 1\n\tif seconds < 0 {\n\t\tseconds = 0\n\t}\n\tif ctx.Debug > 1 {\n\t\tPrintf(\"CalculateTimeToReset(%d,%d) -> %d\\n\", rateLimit, rateLimitReset, seconds)\n\t}\n\treturn\n}", "func Time(t time.Time) int64 {\n\treturn t.UnixNano() / 1000000\n}", "func (o CertificateOutput) UpdateTime() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Certificate) pulumi.StringOutput { return v.UpdateTime }).(pulumi.StringOutput)\n}", "func (d Display) GetTime() int {\n\treturn int(C.caca_get_display_time(d.Dp))\n}", "func (d *Device) LastElapsed() time.Duration {\n\treturn d.lastElapsed\n}", "func (g getLoadReplay) calcTime(group *chargeGroup) time.Time {\n\tnow := time.Now()\n\tstime := now.Add(g.timeOffset)\n\n\tif stime.Equal(g.firstRecord) || stime.Equal(g.lastRecord) ||\n\t\t(stime.After(g.firstRecord) && stime.Before(g.lastRecord)) {\n\t\treturn stime\n\t}\n\tstime = g.firstRecord\n\tg.timeOffset = g.firstRecord.Sub(now)\n\n\treturn stime\n}", "func (i *iterator) Time() int64 { return i.imin }", "func (manager *Manager) EstimatedTimeCompelete() time.Time {\n\tswitch manager.state {\n\tcase notRunningState:\n\tcase runningState:\n\t\treturn time.Unix(manager.estimatedEndTimeInSec, 0)\n\tdefault:\n\t}\n\n\treturn time.Time{}\n}", "func calcDt(neurone Neurone) float64 {\n\t// Drain off and ignore changes in energy from the dendrites.\n\tselect {\n\tcase <-neurone.deltaE:\n\tcase <-time.After(250 * time.Millisecond):\n\t}\n\n\t// Calculate how many seconds have elapsed since this cooldown state started.\n\treturn float64(time.Now().UnixNano()-neurone.start) / nanoToSeconds\n}", "func taskPendingTime(t *swarming_api.SwarmingRpcsTaskRequestMetadata) (int64, error) {\n\tcreatedTime, err := swarming.Created(t)\n\tif err != nil {\n\t\treturn 0.0, err\n\t}\n\tstartTime, err := swarming.Started(t)\n\tif err != nil {\n\t\treturn 0.0, err\n\t}\n\treturn int64(startTime.Sub(createdTime).Seconds() * float64(1000.0)), nil\n}", "func GetCPUTimeStat(rw http.ResponseWriter) error {\n\tcpus, err := cpu.Times(true)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn share.JSONResponse(cpus, rw)\n}", "func (e Edge) netTime() float64 {\n\tif e.End.State.Time < e.Start.State.Time {\n\t\tPrintError(fmt.Sprintf(\"Found backwards edge: %s to %s\", e.Start.State.String(), e.End.State.String()))\n\t}\n\treturn e.End.State.Time - e.Start.State.Time\n}", "func (r *Report) ConnectionTime() time.Duration {\n\treturn r.ConnectDone.Sub(r.ConnectStart)\n}", "func (j *DSGitHub) CalculateTimeToReset(ctx *Ctx, rateLimit, rateLimitReset int) (seconds int) {\n\tseconds = rateLimitReset\n\treturn\n}", "func calculateIcySleep(streamStart time.Time, servedTime time.Duration) time.Duration {\n\t// time.Since is basically now.Sub\n\n\t// calculate how much time we should have served to the user. This will\n\t// be the time elapsed since the stream started, plus the buffer\n\texpectedServed := nowFn().Sub(streamStart) + streamBuffer\n\n\t// the difference between how much we have served, vs. how much we should serve\n\tservedDelta := servedTime - expectedServed\n\n\tif servedDelta <= 0 {\n\t\t// closest thing to immediate\n\t\treturn 1 * time.Nanosecond\n\t}\n\treturn servedDelta\n}", "func (c *Clock) Since(t time.Time) time.Duration {\n\treturn c.Now().Sub(t)\n}", "func ElapsedTime() {\n\telapsed := time.Since(last)\n\tdefer resetLast()\n\tincr_offset()\n\tdefer decr_offset()\n\tNotice(fmt.Sprintf(formats[\"elapsed\"], elapsed))\n}", "func (s *Stats) GetTotalCPUTimes() {\n\n if s.CPUInfo == nil {\n s.CPUInfo = new(CPUInfo)\n }\n\n s.CPUInfo.PrevTotalTimes = s.CPUInfo.TotalTimes\n s.CPUInfo.TotalTimes, _ = cpu.Times(false)\n\n if len(s.CPUInfo.PrevTotalTimes) == 0 {\n s.CPUInfo.PrevTotalTimes = s.CPUInfo.TotalTimes\n }\n}", "func GetTime() int64 {\n\treturn time.Now().UnixNano() / int64(time.Millisecond)\n}", "func timeSince(a time.Time) string {\n\tb := time.Now()\n\n\ty1, M1, d1 := a.Date()\n\ty2, M2, d2 := b.Date()\n\n\th1, m1, s1 := a.Clock()\n\th2, m2, s2 := b.Clock()\n\n\tyear := int(y2 - y1)\n\tmonth := int(M2 - M1)\n\tday := int(d2 - d1)\n\thour := int(h2 - h1)\n\tmin := int(m2 - m1)\n\tsec := int(s2 - s1)\n\n\tif sec < 0 {\n\t\tsec += 60\n\t\tmin--\n\t}\n\tif min < 0 {\n\t\tmin += 60\n\t\thour--\n\t}\n\tif hour < 0 {\n\t\thour += 24\n\t\tday--\n\t}\n\tif day < 0 {\n\t\tt := time.Date(y1, M1, 32, 0, 0, 0, 0, time.UTC)\n\t\tday += 32 - t.Day()\n\t\tmonth--\n\t}\n\tif month < 0 {\n\t\tmonth += 12\n\t\tyear--\n\t}\n\n\treturn fmt.Sprintf(\"P%dY%dM%dDT%dH%dM%dS\", year, month, day, hour, min, sec)\n}", "func Time(address string) (time.Time, error) {\n\tr, err := Query(address)\n\tif err != nil {\n\t\treturn time.Now(), err\n\t}\n\n\terr = r.Validate()\n\tif err != nil {\n\t\treturn time.Now(), err\n\t}\n\n\t// Use the response's clock offset to calculate an accurate time.\n\treturn time.Now().Add(r.ClockOffset), nil\n}", "func (oiu *onceInUpdater) Time() Time {\n\treturn Time(atomic.LoadUint32((*uint32)(&oiu.t)))\n}", "func (s *SharedMemory) PollTime() uint64 {\n\taddr := unsafe.Pointer(uintptr(unsafe.Pointer(&s.shmem.dwRevision)) + C.sizeof_DWORD)\n\treturn uint64(*(*C.__time64_t)(addr))\n}", "func CalculateTimeDiff(serverTime time.Time, loc *time.Location) (time.Duration, error) {\n\tgetSeconds := func(t time.Time) (float64, error) {\n\t\ttz := t.Format(\"-0700\")\n\t\tdur, err := time.ParseDuration(fmt.Sprintf(\"%sh%sm\",\n\t\t\ttz[1:3], tz[3:5]))\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\n\t\tsec := dur.Seconds()\n\t\tif tz[:1] == \"-\" {\n\t\t\tsec = sec * -1\n\t\t}\n\n\t\treturn sec, nil\n\t}\n\n\tserverSec, err := getSeconds(serverTime)\n\tif err != nil {\n\t\treturn time.Second * 0, err\n\t}\n\n\tlocalSec, err := getSeconds(serverTime.In(loc))\n\tif err != nil {\n\t\treturn time.Second * 0, err\n\t}\n\n\treturn time.ParseDuration(fmt.Sprintf(\"%.0fs\",\n\t\tserverSec-localSec))\n}", "func (cm *CostModel) CanCompute(start, end time.Time) bool {\n\treturn start.Before(time.Now())\n}", "func LastUpdateTime(t time.Time) Precondition { return lastUpdateTime(t) }", "func (c *Client) Time(stat string, rate float64, f func()) error {\n\tts := time.Now()\n\tf()\n\treturn c.Duration(stat, time.Since(ts), rate)\n}", "func (t *TimeTravelCtx) now() time.Time {\n\tt.mutex.RLock()\n\tdefer t.mutex.RUnlock()\n\treturn t.ts\n}", "func (c *webCtx) Now() time.Time {\n\treturn c.now\n}", "func CurrentTime() Time {\n\tif atomic.LoadUint32(&isRunning) != 0 {\n\t\treturn currentTime\n\t}\n\n\treturn Time(time.Now().UnixNano() / 1e6)\n}", "func (c *Default) Calculate(state State) time.Duration {\n\tif t, ok := IsRetryAfter(state.LastError); ok {\n\t\tif t < c.minSleep {\n\t\t\treturn c.minSleep\n\t\t}\n\t\treturn t\n\t}\n\n\tif state.ConsecutiveRetries > 0 {\n\t\tsleepTime := c.maxSleep\n\t\tif c.attackConstant != 0 {\n\t\t\tsleepTime = (state.SleepTime << c.attackConstant) / ((1 << c.attackConstant) - 1)\n\t\t}\n\t\tif sleepTime > c.maxSleep {\n\t\t\tsleepTime = c.maxSleep\n\t\t}\n\t\treturn sleepTime\n\t}\n\tsleepTime := (state.SleepTime<<c.decayConstant - state.SleepTime) >> c.decayConstant\n\tif sleepTime < c.minSleep {\n\t\tsleepTime = c.minSleep\n\t}\n\treturn sleepTime\n}", "func (_this *IntersectionObserverEntry) Time() float64 {\n\tvar ret float64\n\tvalue := _this.Value_JS.Get(\"time\")\n\tret = (value).Float()\n\treturn ret\n}", "func (ct *cpuTracker) UtilizeTime(vdr ids.ShortID, startTime, endTime time.Time) {\n\tct.lock.Lock()\n\tdefer ct.lock.Unlock()\n\n\tmeter := ct.getMeter(vdr)\n\tct.cumulativeMeter.Start(startTime)\n\tct.cumulativeMeter.Stop(endTime)\n\tmeter.Start(startTime)\n\tmeter.Stop(endTime)\n}", "func clockDelta(ctx context.Context) (time.Duration, error) {\n\t// /proc/timer_list contains a line which says \"now at %Ld nsecs\".\n\t// This clock value comes from CLOCK_MONOTONIC (see the kernel's kernel/time/timer_list.c).\n\tparse := func(output string) (int64, error) {\n\t\tfor _, line := range strings.Split(output, \"\\n\") {\n\t\t\ttokens := strings.Split(line, \" \")\n\t\t\tif len(tokens) == 4 && tokens[0] == \"now\" && tokens[1] == \"at\" && tokens[3] == \"nsecs\" {\n\t\t\t\treturn strconv.ParseInt(tokens[2], 10, 64)\n\t\t\t}\n\t\t}\n\t\treturn 0, errors.Errorf(\"unexpected format of /proc/timer_list: %q\", output)\n\t}\n\n\t// Use android-sh to read /proc/timer_list which only root can read.\n\tout, err := arc.BootstrapCommand(ctx, \"/system/bin/cat\", \"/proc/timer_list\").Output(testexec.DumpLogOnError)\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"failed to read guest's /proc/timer_list\")\n\t}\n\tguestClockNS, err := parse(string(out))\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"failed to prase guest's /proc/timer_list\")\n\t}\n\n\tout, err = ioutil.ReadFile(\"/proc/timer_list\")\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"failed to read host's /proc/timer_list\")\n\t}\n\thostClockNS, err := parse(string(out))\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"failed to prase host's /proc/timer_list\")\n\t}\n\n\ttesting.ContextLogf(ctx, \"Host clock: %d ns, Guest clock: %d ns\", hostClockNS, guestClockNS)\n\treturn time.Duration((hostClockNS - guestClockNS) * int64(time.Nanosecond)), nil\n}", "func remainingTime(t *testing.T) time.Duration {\n\tdeadline, hasDeadline := t.Deadline()\n\tif hasDeadline {\n\t\treturn time.Until(deadline) - time.Second // give us 1 second to clean up\n\t}\n\n\treturn DefaultResourceTimeout\n}", "func (rs *requestContext) Now() time.Time {\n\treturn rs.now\n}", "func Time(logger *log.Logger, next http.HandlerFunc) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tstart := time.Now()\n\t\tnext.ServeHTTP(w, r)\n\t\telapsed := time.Since(start)\n\t\tlogger.Println(elapsed)\n\t})\n}", "func Time(logger *log.Logger, next http.HandlerFunc) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tstart := time.Now()\n\t\tnext.ServeHTTP(w, r)\n\t\telapsed := time.Since(start)\n\t\tlogger.Println(elapsed)\n\t})\n}", "func (cli *Application) elapsed() time.Duration {\n\treturn time.Now().Sub(cli.started)\n}", "func (o WorkerPoolOutput) UpdateTime() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *WorkerPool) pulumi.StringOutput { return v.UpdateTime }).(pulumi.StringOutput)\n}", "func (o WorkerPoolOutput) UpdateTime() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *WorkerPool) pulumi.StringOutput { return v.UpdateTime }).(pulumi.StringOutput)\n}", "func getTime() time.Time {\n\treturn time.Now().Add(timeOffset)\n}", "func Since(t time.Time) int {\n\treturn int(time.Since(t) / time.Millisecond)\n}", "func (p *Peer) TimeConnected() time.Time {\n\tp.statsMtx.RLock()\n\ttimeConnected := p.timeConnected\n\tp.statsMtx.RUnlock()\n\n\treturn timeConnected\n}", "func (s *Session) AdvanceOperationTime(*primitive.Timestamp) error {\n\tpanic(\"lungo: not implemented\")\n}", "func (s *State) Time() time.Time {\n\treturn s.time\n}", "func (o *ConditionRequestRateCondition) GetTime() string {\n\tif o == nil || o.Time == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Time\n}", "func calculateDurationUntilNextReload(lastErcotReload string) (time.Duration, error) {\n\n\tmyLocation, loadLocationError := time.LoadLocation(\"America/Chicago\")\n\tif loadLocationError != nil {\n\t\treturn time.Duration(0), loadLocationError\n\t}\n\n\tasOfTimestamp, _ := time.ParseInLocation(ercot.RtLmpLastUpdatedTimestampLayOut, lastErcotReload, myLocation)\n\t//fmt.Printf(\"As-Of time: %v\\n\", asOfTimestamp)\n\ttargetReload := asOfTimestamp.Add(time.Minute * 5).Add(time.Second * 30)\n\t//fmt.Printf(\"Target reload time: %v\\n\", targetReload)\n\n\tnow := time.Now()\n\t//fmt.Println(now)\n\tdifference := targetReload.Sub(now)\n\t//fmt.Printf(\"Wait time: %v\\n\", difference)\n\n\tif difference < 0 {\n\t\t// This means that the ERCOT webpage should have already reloaded by now\n\t\t// We'll give it 10 seconds and check again\n\t\tdifference = time.Duration(10) * time.Second\n\t}\n\n\treturn difference, nil\n}", "func GetPhysical(t time.Time) int64 {\n\treturn t.UnixNano() / int64(time.Millisecond)\n}", "func (t Time) Clock() (hour, min, sec int) {}", "func (cia *chainInfoAPI) BlockTime(ctx context.Context) time.Duration {\n\treturn cia.chain.config.BlockTime()\n}", "func (o EntitlementOutput) UpdateTime() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Entitlement) pulumi.StringOutput { return v.UpdateTime }).(pulumi.StringOutput)\n}" ]
[ "0.6423677", "0.6169987", "0.59779924", "0.59779924", "0.58311296", "0.5684228", "0.56696755", "0.56140286", "0.55195993", "0.55083275", "0.5452939", "0.5432582", "0.5420827", "0.5411604", "0.53523755", "0.5336318", "0.53116274", "0.52941823", "0.52860546", "0.5259746", "0.52594805", "0.5246958", "0.5239525", "0.52185416", "0.51766527", "0.51668847", "0.51594794", "0.5145038", "0.5127597", "0.51204985", "0.51146215", "0.5094874", "0.5085826", "0.50833994", "0.50800186", "0.50761926", "0.50697047", "0.5067642", "0.50645465", "0.5060641", "0.5040495", "0.5024207", "0.50179166", "0.49926883", "0.4988313", "0.49859506", "0.49626485", "0.49584997", "0.49313575", "0.49302945", "0.49285346", "0.4924809", "0.48768032", "0.48739925", "0.48371053", "0.48279184", "0.48194233", "0.4816877", "0.4816625", "0.48085523", "0.48062682", "0.48058933", "0.4804587", "0.47981766", "0.47903457", "0.47854516", "0.4784846", "0.47735408", "0.47725543", "0.4766033", "0.47652885", "0.47612748", "0.47585964", "0.47533646", "0.47532344", "0.47512576", "0.47498205", "0.4748353", "0.47395", "0.47353414", "0.47300708", "0.47296566", "0.4727245", "0.47192103", "0.47167215", "0.47167215", "0.47164884", "0.47062385", "0.47062385", "0.46897435", "0.46885192", "0.4688358", "0.46865916", "0.46821156", "0.46810433", "0.46741083", "0.46732986", "0.46705937", "0.46659636", "0.46642748" ]
0.77658814
0
Execute executes a given request, applying changes to the device context.
func (dc *deviceContext) execute(req *Request) { spareTime := req.Timestamp.Sub(dc.busyUntil) // Devote spare time to writing back cache. if spareTime > 0 && dc.writeBackCache != nil { dc.writeBackCache.writeBack(spareTime) } dc.busyUntil = req.Timestamp.Add(dc.computeTime(req)) switch req.Type { case MetadataRequest, AllocateRequest: // Do nothing. case CloseRequest: if dc.writeBackCache != nil { dc.writeBackCache.close(req.Path) } if dc.lastAccessedFile == req.Path { dc.lastAccessedFile = "" dc.firstUnseenByte = 0 } case ReadRequest: dc.lastAccessedFile = req.Path dc.firstUnseenByte = req.Start + req.Size case WriteRequest: switch dc.deviceConfig.WriteStrategy { case slowfs.FastWrite: // Fast writes don't affect things here. case slowfs.SimulateWrite: dc.lastAccessedFile = req.Path dc.firstUnseenByte = req.Start + req.Size } if dc.writeBackCache != nil { dc.writeBackCache.write(req.Path, req.Size) } case FsyncRequest: if dc.writeBackCache != nil { dc.writeBackCache.writeBackFile(req.Path) } default: dc.logger.Printf("unknown request type for %+v\n", req) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func ExecuteRequest(req *http.Request, result interface{}) error {\n\tclient := http.Client{}\n\tresponse, err := client.Do(req)\n\tif err != nil {\n\t\tlog.Println(\"Error executing request call\")\n\t\tlog.Println(err)\n\t\treturn err\n\t}\n\tdefer response.Body.Close()\n\tout, err := ioutil.ReadAll(response.Body)\n\tif response.StatusCode == http.StatusUnauthorized {\n\t\tlog.Println(\"DOes not have permission to perform that action\")\n\t\treturn types.UnAuthorizedScope\n\t}\n\terr = json.NewDecoder(bytes.NewReader(out)).Decode(result)\n\tif err != nil {\n\t\tlog.Println(\"Error deserializing body in JSON Decoder\")\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *MakeRequestController) Execute() {\n\tmakeRequestData := c.AppCtx.GetMDR()\n\tprefix := \"[\" + strconv.Itoa(rand.Intn(100)) + \"] \"\n\n\t// Get current context to replace all variables\n\t_, currentContext := c.View.GetContext()\n\tcurrentContextValues := c.AppCtx.GetOutput().Context.GetAllKeyValue(currentContext)\n\n\tURL := types.URL(c.View.GetURL()).\n\t\tReplaceContext(makeRequestData.MapRequestHeaderKeyValue).\n\t\tReplaceContext(currentContextValues)\n\n\tmethod := makeRequestData.Method\n\tcontentType := makeRequestData.ContentType\n\tbody := []byte(makeRequestData.Body)\n\thttpHeaderValues := makeRequestData.GetHTTPHeaderValues().ReplaceContext(currentContextValues)\n\n\tHTTPClient, error := httpclient.Call(method, URL, contentType, body, httpHeaderValues, c.Action.DisplayErrorRequest)\n\tif error != nil {\n\t\tc.AppCtx.PrintInfo(prefix + makeRequestData.ToLog(URL))\n\t\tc.AppCtx.PrintError(prefix + fmt.Sprint(error))\n\n\t\tc.Action.DisplayErrorRequest(fmt.Sprint(error), \"error\")\n\t} else {\n\t\tc.AppCtx.PrintInfo(prefix + makeRequestData.ToLog(URL))\n\n\t\tresponse := fmt.Sprintf(\"%+s\", HTTPClient.Body)\n\t\tif logRequestOn {\n\t\t\tc.AppCtx.PrintInfo(prefix + response)\n\t\t}\n\n\t\tc.Action.DisplayResponse(HTTPClient, response)\n\t}\n}", "func (r *Request) Execute() (*Response, error) {\n\treturn r.sendRequest()\n}", "func (dru *DeviceRequestUpdate) Exec(ctx context.Context) error {\n\t_, err := dru.Save(ctx)\n\treturn err\n}", "func (rt *rtuTransport) ExecuteRequest(req *pdu) (res *pdu, err error) {\n\t// set an i/o deadline on the link\n\terr\t= rt.link.SetDeadline(time.Now().Add(rt.timeout))\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// build an RTU ADU out of the request object and\n\t// send the final ADU+CRC on the wire\n\t_, err\t= rt.link.Write(rt.assembleRTUFrame(req))\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// observe inter-frame delays\n\ttime.Sleep(rt.interFrameDelay())\n\n\t// read the response back from the wire\n\tres, err = rt.readRTUFrame()\n\n\treturn\n}", "func (cb *Breaker) Execute(req func() (interface{}, error)) (interface{}, error) {\n\tgeneration, err := cb.beforeRequest()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer func() {\n\t\te := recover()\n\t\tif e != nil {\n\t\t\tcb.afterRequest(generation, false)\n\t\t\tpanic(e)\n\t\t}\n\t}()\n\n\tresult, err := req()\n\tcb.afterRequest(generation, err == nil)\n\treturn result, err\n}", "func (c *Client) ExecuteRequest(req *http.Request, v interface{}, x interface{}) error {\n\tres, err := httpClient.Do(req)\n\tif err != nil {\n\t\treturn errors.New(\"sangu-bca.client.ExecuteRequest.Do: \" + err.Error())\n\t}\n\tdefer res.Body.Close()\n\n\tresBody, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn errors.New(\"sangu-bca.client.ExecuteRequest.Read: \" + err.Error())\n\t}\n\n\tif v != nil && res.StatusCode == 200 {\n\t\tif err = json.Unmarshal(resBody, v); err != nil {\n\t\t\treturn errors.New(\"sangu-bca.client.ExecuteRequest.UnmarshalOK: \" + err.Error())\n\t\t}\n\t}\n\n\tif x != nil && res.StatusCode != 200 {\n\t\tif err = json.Unmarshal(resBody, x); err != nil {\n\t\t\treturn errors.New(\"sangu-bca.client.ExecuteRequest.UnmarshalNotOK: \" + err.Error())\n\t\t}\n\t}\n\n\treturn nil\n}", "func (d *Device) Execute(op string, payload string) (result ExecuteResult, err *dbus.Error) {\n\td.logger.Print(\"Device.Execute() not implemented\")\n\treturn result, err\n}", "func (c *Executor) ExecuteRequest(request *Request) (*http.Response, error) {\n\tfollowRedirects := request.followRedirects\n\treq, err := c.newHTTPRequest(request)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// do the request to the remote API\n\tr, err := c.do(req, followRedirects)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// it's possible the access token expired and the oauth subsystem could not obtain a new one because the\n\t// refresh token is expired or revoked. Attempt to get a new refresh and access token and retry the request.\n\tif r.StatusCode == http.StatusUnauthorized {\n\t\t_ = r.Body.Close()\n\t\terr = c.reAuthenticate()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tr, err = c.do(req, followRedirects)\n\t}\n\n\treturn r, err\n}", "func (a *ApiExecutor) executeRequest(req *Request) (Result, error) {\n\tvar fsm *simple_fsm.Fsm\n\tstr := a.StructureMap[req.MethodName]\n\tfsm = simple_fsm.NewFsm(str)\n\tfsm.SetInput(\"methodName\", req.MethodName)\n\tfsm.SetInput(\"start_date\", time.Now())\n\tfsm.SetInput(\"failed\", false)\n\tfor k, v := range req.Params {\n\t\tfsm.SetInput(k, v)\n\t}\n\texecRes, err := fsm.Run()\n\tprintFsmDump(fsm)\n\n\tif err != nil {\n\t\tlog.Printf(\"Error occured during flow execution: %v\", err)\n\t}\n\tlog.Printf(\"Exec result %v\", execRes)\n\treturn NewResultFrom(execRes), nil\n}", "func (h *Hook) Execute(r *admission.AdmissionRequest) (*Result, error) {\n\tswitch r.Operation {\n\tcase admission.Create:\n\t\treturn wrapperExecution(h.Create, r)\n\tcase admission.Update:\n\t\treturn wrapperExecution(h.Update, r)\n\tcase admission.Delete:\n\t\treturn wrapperExecution(h.Delete, r)\n\tcase admission.Connect:\n\t\treturn wrapperExecution(h.Connect, r)\n\t}\n\n\treturn &Result{Message: fmt.Sprintf(\"Invalid operation: %s\", r.Operation)}, nil\n}", "func (crawl *Crawl) Execute(req *Request) (resp *Response, err error) {\n\t// Make request\n\tresp, err = crawl.Do(req)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// If request.Raw is not true - parse html\n\tif !req.Raw {\n\t\terr = resp.ParseHTML()\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Set request context if empty\n\tif req.Context == nil {\n\t\treq.Context = context.Background()\n\t}\n\n\t// ctx = context.WithValue(ctx, \"crawl\", crawl)\n\t// ctx = context.WithValue(ctx, \"response\", resp)\n\n\t// Run handlers\n\tfor _, cb := range req.Callbacks {\n\t\tif handler := crawl.GetHandler(cb); handler != nil {\n\t\t\terr = handler(req.Context, crawl, resp)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Warningf(\"Handler %v was not found\", cb)\n\t\t}\n\t}\n\n\tlog.V(2).Infof(\"%s %s %s - %v\", req.GetMethod(), resp.GetStatus(), resp.GetURL(), req.Callbacks)\n\n\treturn\n}", "func (c *Client) Execute(r Request, data interface{}) error {\n\tpayload, err := json.Marshal(r)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq, err := http.NewRequest(\"POST\", c.Endpoint, bytes.NewBuffer(payload))\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor k, v := range c.Headers {\n\t\treq.Header.Set(k, v)\n\t}\n\tres, err := c.client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer res.Body.Close()\n\n\tvar response Response\n\terr = json.NewDecoder(res.Body).Decode(&response)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif response.Data != nil {\n\t\terr = json.Unmarshal(*response.Data, data)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif response.Errors != nil {\n\t\tvar errors Errors\n\t\terr = json.Unmarshal(*response.Errors, &errors)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn errors\n\t}\n\n\treturn nil\n}", "func Execute(\n\tctx context.Context,\n\tpayload gapir.Payload,\n\thandlePost builder.PostDataHandler,\n\thandleNotification builder.NotificationHandler,\n\tconnection *gapir.Connection,\n\tmemoryLayout *device.MemoryLayout,\n\tos *device.OS) error {\n\n\tctx = status.Start(ctx, \"Execute\")\n\tdefer status.Finish(ctx)\n\n\t// The memoryLayout is specific to the ABI of the requested capture,\n\t// while the OS is not. Thus a device.Configuration is not applicable here.\n\treturn executor{\n\t\tpayload: payload,\n\t\thandlePost: handlePost,\n\t\thandleNotification: handleNotification,\n\t\tmemoryLayout: memoryLayout,\n\t\tOS: os,\n\t}.execute(ctx, connection)\n}", "func Execute(\n\tctx context.Context,\n\thandler Handler,\n\tabortHandler AbortHandler,\n\trequest interface{}) Awaiter {\n\ttask := &task{\n\t\trequest: request,\n\t\thandler: handler,\n\t\tabortHandler: abortHandler,\n\t\tresultQ: make(chan Response, 1),\n\t\trunning: true,\n\t}\n\tgo task.run(ctx) // run handler asynchronously\n\treturn task\n}", "func (_e *handler_Expecter) Execute(req interface{}, s interface{}) *handler_Execute_Call {\n\treturn &handler_Execute_Call{Call: _e.mock.On(\"Execute\", req, s)}\n}", "func (h *Handler) Apply(req *processor_pb2.TpProcessRequest, ctx *processor.Context) error {\n\tr := new(TPRequest)\n\n\t// 加一個環境變數,來設定是否要進入 debug mode,\n\t// 如果是 debug mode 則取消 recover.\n\tif !h.debug {\n\t\tdefer func(r *TPRequest) {\n\t\t\tif r := recover(); r != nil {\n\t\t\t\tlog.Fatal(r)\n\t\t\t\tfmt.Println(r)\n\t\t\t}\n\t\t}(r)\n\t}\n\n\tif err := proto.Unmarshal(req.Payload, r); err != nil {\n\t\treturn Unmarshal.TxErrore(err)\n\t}\n\n\tlog.Debugf(\"got CMD (%d)\", r.Cmd)\n\thfunc, ok := h.router[r.Cmd]\n\tif !ok || hfunc == nil {\n\t\treturn &processor.InvalidTransactionError{\n\t\t\tMsg: fmt.Sprintf(\"unknow cmd: %d\", r.Cmd),\n\t\t}\n\t}\n\n\tctxw := &Context{\n\t\tref: ctx,\n\t\tsigner: req.Header.SignerPublicKey,\n\t\tcmd: r.Cmd,\n\t}\n\n\tif err := hfunc(ctxw, r); err != nil {\n\t\tlog.Debugf(\"cmd %d handler: %v\", r.Cmd, err)\n\t\tfmt.Println(\"handle\", r.Cmd, err)\n\t\treturn err\n\t}\n\tlog.Debugf(\"CMD (%d) end\", r.Cmd)\n\treturn nil\n}", "func (druo *DeviceRequestUpdateOne) Exec(ctx context.Context) error {\n\t_, err := druo.Save(ctx)\n\treturn err\n}", "func (c *ToyController) Execute(ctx context.Context) error {\n\tc.le.Debug(\"toy controller executed\")\n\t<-ctx.Done()\n\treturn nil\n}", "func ExecuteRequest(testServer *server.HTTPServer, req *http.Request, config *server.Configuration) *httptest.ResponseRecorder {\n\trouter := testServer.Initialize()\n\n\trr := httptest.NewRecorder()\n\trouter.ServeHTTP(rr, req)\n\n\treturn rr\n}", "func (h Handler) Apply(c echo.Context) error {\n\tuser, err := security.JWTDecode(c)\n\tif err == security.ErrUserNotFound {\n\t\th.logger.Printf(\"error finding jwt token in context: %v\\n\", err)\n\t\treturn response.NewErrorResponse(c, http.StatusForbidden, \"authentication token was not found\")\n\t}\n\toper := Operation{}\n\terr = c.Bind(&oper)\n\tif err != nil {\n\t\th.logger.Printf(\"could not bind request data%v\\n\", err)\n\t\treturn response.NewBadRequestResponse(c, \"id, gameId, op, row, col are required\")\n\t}\n\tif err = c.Validate(oper); err != nil {\n\t\th.logger.Printf(\"validation error %v\\n\", err)\n\t\treturn response.NewBadRequestResponse(c, err.Error())\n\t}\n\tctx := c.Request().Context()\n\tapi := apiFactory(h.logger, h.db)\n\tconfirmation, err := api.ApplyOperation(ctx, user, oper)\n\tif err != nil {\n\t\treturn response.NewResponseFromError(c, err)\n\t}\n\treturn response.NewSuccessResponse(c, cResponse{confirmation})\n}", "func (in *Input) Execute(ctx context.Context, req *proIntegrator.ExecuteRequest) (*proIntegrator.ExecuteResponse, error) {\n\tinc := req.Component\n\tinc.ParamsOutput[\"Param1\"] = inc.ParamsInput[\"Param1\"]\n\tinc.ParamsOutput[\"Param2\"] = inc.ParamsInput[\"Param2\"]\n\tcomponent := &proIntegrator.Component{}\n\tmapIn := make(map[string]*proIntegrator.DataType)\n\tmapOut := make(map[string]*proIntegrator.DataType)\n\tfor key, value := range inc.ParamsInput {\n\t\tmapIn[key] = value\n\t}\n\tfor key, value := range inc.ParamsOutput {\n\t\tmapOut[key] = value\n\t}\n\tcomponent.Name = in.Component.Name\n\tcomponent.ParamsInput = mapIn\n\tcomponent.ParamsOutput = mapOut\n\n\tresponse := &proIntegrator.ExecuteResponse{component}\n\treturn response, nil\n}", "func (runtime *Runtime) Execute(document *ast.Document, operationName string, variableValues map[string]interface{}) *Response {\n\trsp := &Response{}\n\n\t// TODO\n\t// err = validateDocument(document)\n\t// if err != nil {\n\t// \trsp.Errors = append(rsp.Errors, err)\n\t// \treturn rsp\n\t// }\n\n\toperation, err := runtime.getOperation(document, operationName)\n\tif err != nil {\n\t\trsp.Errors = append(rsp.Errors, err)\n\t\treturn rsp\n\t}\n\n\tcoercedVarVals, err := runtime.coerceVariableValues(operation, variableValues)\n\tif err != nil {\n\t\trsp.Errors = append(rsp.Errors, err)\n\t\treturn rsp\n\t}\n\treturn runtime.executeRequest(operation, coercedVarVals)\n}", "func (s *service) Run(ctx context.Context, request *task.Action) (task.Response, error) {\n\tswitch req := request.ServiceRequest().(type) {\n\tcase *DeleteRequest:\n\t\treturn nil, s.Delete(ctx, req)\n\tcase *MoveRequest:\n\t\treturn nil, s.Move(ctx, req)\n\t}\n\treturn nil, errors.Errorf(\"unsupported request type:%T\", request)\n}", "func (aru *AuthRequestUpdate) Exec(ctx context.Context) error {\n\t_, err := aru.Save(ctx)\n\treturn err\n}", "func (c *client) Execute(relativeURL string, params map[string]string) (*http.Response, error) {\n\tparams[\"appkey\"] = c.appKey\n\tparams[\"sid\"] = c.sid\n\tparams[\"timestamp\"] = fmt.Sprint(time.Now().Unix())\n\tparams[\"sign\"] = signRequest(params, c.appSecret)\n\n\treturn c.post(c.baseURL+relativeURL, params)\n}", "func (a *ApiExecutor) Execute(request *Request) (Result, error) {\n\tmethod := a.Methods[request.MethodName]\n\tif method.IsEmpty() {\n\t\tmsg := fmt.Sprintf(\"Method '%s' was not recognized by executor\", request.MethodName)\n\t\tlog.Printf(\"[ERROR] \" + msg)\n\t\treturn NewResultMessage(http.StatusBadRequest, msg), errors.New(msg)\n\t}\n\n\tok, err := checkToken(request)\n\tif err != nil {\n\t\treturn NewResultMessage(http.StatusBadRequest, err.Error()), err\n\t}\n\tif !ok {\n\t\treturn NewResultMessage(http.StatusForbidden, \"Provided token is not valid, or expired. Please provide, valid token or authorize with 'auth'\"), nil\n\t}\n\n\tok, err = validateParams(method, request.Params)\n\tif err != nil {\n\t\treturn NewResultMessage(http.StatusBadRequest, err.Error()), err\n\t}\n\tif !ok {\n\t\treturn NewResultMessage(http.StatusBadRequest, \"Provided parameters are not valid\"), nil\n\t}\n\n\tok, err = checkPermissions(request)\n\tif err != nil {\n\t\treturn NewResultMessage(http.StatusBadRequest, err.Error()), err\n\t}\n\tif !ok {\n\t\treturn NewResultMessage(http.StatusForbidden, \"No permissions to perform operation '\" + request.MethodName + \"'\"), nil\n\t}\n\n\tresult, err := a.executeRequest(request)\n\tif err != nil {\n\t\treturn NewResultMessage(http.StatusInternalServerError, err.Error()), err\n\t}\n\treturn result, err\n}", "func Execute(ctx context.Context) error {\n\treturn rootCmd.ExecuteContext(ctx)\n}", "func (dru *DeviceRequestUpdate) ExecX(ctx context.Context) {\n\tif err := dru.Exec(ctx); err != nil {\n\t\tpanic(err)\n\t}\n}", "func (c Command) Execute(ctx context.Context, payload xml.TokenReader, s *xmpp.Session) (Response, xmlstream.TokenReadCloser, error) {\n\treturn c.ExecuteIQ(ctx, stanza.IQ{\n\t\tType: stanza.SetIQ,\n\t\tTo: c.JID,\n\t}, payload, s)\n}", "func execRequest(_ int, p *gop.Context) {\n\tret, ret1 := cgi.Request()\n\tp.Ret(0, ret, ret1)\n}", "func (tmpl *appTemplate) Execute(c *AppConfig, w http.ResponseWriter, r *http.Request, data interface{}) *appError {\n\td := struct {\n\t\tData interface{}\n\t}{\n\t\tData: data,\n\t}\n\n\tif err := tmpl.t.Execute(w, d); err != nil {\n\t\treturn c.appErrorf(r, err, \"could not write template: %v\", err)\n\t}\n\treturn nil\n}", "func (h HTTPAction) Execute(resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vucontext *config.VUContext, vulog *log.Entry, playbook *config.TestDef) bool {\n\tvulog.Data[\"action\"] = h.Title\n\treturn DoHTTPRequest(h, resultsChannel, sessionMap, vucontext, vulog, playbook)\n}", "func (s *mongoRequest) Execute(msession *mgo.Session, r *http.Request) (interface{}, error) {\n\t// FIXME add session to mongoRequest struct?\n\t// TODO test copy/clone/new against consistency modes\n\terr := s.Decode(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsession := msession.Copy()\n\tdefer session.Close()\n\tcoll := session.DB(s.Database).C(s.Collection)\n\tquery := new(mgo.Query)\n\tbakeAction(&query, s, coll)\n\tbakeSubActions(&query, s, coll)\n\tjdata, err := executeQuery(query, s, coll)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn jdata, nil\n}", "func execute(fhandler *flowHandler, request []byte) ([]byte, error) {\n\tvar result []byte\n\tvar err error\n\n\tpipeline := fhandler.getPipeline()\n\n\tcurrentNode, _ := pipeline.GetCurrentNodeDag()\n\n\t// trace node - mark as start of node\n\tfhandler.tracer.startNodeSpan(currentNode.GetUniqueId(), fhandler.id)\n\n\t// Execute all operation\n\tfor _, operation := range currentNode.Operations() {\n\n\t\tswitch {\n\t\t// If function\n\t\tcase operation.Function != \"\":\n\t\t\tfmt.Printf(\"[Request `%s`] Executing function `%s`\\n\",\n\t\t\t\tfhandler.id, operation.Function)\n\t\t\tif result == nil {\n\t\t\t\tresult, err = executeFunction(pipeline, operation, request)\n\t\t\t} else {\n\t\t\t\tresult, err = executeFunction(pipeline, operation, result)\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\terr = fmt.Errorf(\"Node(%s), Function(%s), error: function execution failed, %v\",\n\t\t\t\t\tcurrentNode.GetUniqueId(), operation.Function, err)\n\t\t\t\tif operation.FailureHandler != nil {\n\t\t\t\t\terr = operation.FailureHandler(err)\n\t\t\t\t}\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t}\n\t\t// If callback\n\t\tcase operation.CallbackUrl != \"\":\n\t\t\tfmt.Printf(\"[Request `%s`] Executing callback `%s`\\n\",\n\t\t\t\tfhandler.id, operation.CallbackUrl)\n\t\t\tif result == nil {\n\t\t\t\terr = executeCallback(pipeline, operation, request)\n\t\t\t} else {\n\t\t\t\terr = executeCallback(pipeline, operation, result)\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\terr = fmt.Errorf(\"Node(%s), Callback(%s), error: callback failed, %v\",\n\t\t\t\t\tcurrentNode.GetUniqueId(), operation.CallbackUrl, err)\n\t\t\t\tif operation.FailureHandler != nil {\n\t\t\t\t\terr = operation.FailureHandler(err)\n\t\t\t\t}\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t}\n\n\t\t// If modifier\n\t\tdefault:\n\t\t\tfmt.Printf(\"[Request `%s`] Executing modifier\\n\", fhandler.id)\n\t\t\tif result == nil {\n\t\t\t\tresult, err = operation.Mod(request)\n\t\t\t} else {\n\t\t\t\tresult, err = operation.Mod(result)\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\terr = fmt.Errorf(\"Node(%s), error: Failed at modifier, %v\",\n\t\t\t\t\tcurrentNode.GetUniqueId(), err)\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif result == nil {\n\t\t\t\tresult = []byte(\"\")\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Printf(\"[Request `%s`] Completed execution of Node %s\\n\", fhandler.id, currentNode.GetUniqueId())\n\n\treturn result, nil\n}", "func (g *HTTPGateway) Execute(req *retryablehttp.Request) ([]byte, error) {\n\tif g.Profile.AWS != nil {\n\t\t//sign request\n\t\tif err := signer.SignRequest(req, *g.Profile.AWS, signer.GetV4Signer); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tresponse, err := g.Client.HTTPClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer func() {\n\t\terr := response.Body.Close()\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}()\n\tif err = g.isValidResponse(response); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ioutil.ReadAll(response.Body)\n}", "func (vk VK) Execute(Code string) (response []byte, vkErr Error) {\n\tp := make(map[string]string)\n\tp[\"code\"] = Code\n\tresponse, vkErr = vk.Request(\"execute\", p)\n\n\treturn\n}", "func (s *server) Execute(args ExecuteArgs, resp *string) error {\n\tr, err := s.impl.Execute(args)\n\t*resp = r\n\treturn err\n}", "func (c *Client) Do(ctx context.Context, req *Request, resp *Response) error {\n\tr := graphql.Response{}\n\tif resp != nil {\n\t\tr.Data = resp.Data\n\t\tr.Errors = resp.Errors\n\t\tr.Extensions = resp.Extensions\n\t}\n\treturn c.gql.MakeRequest(ctx, &graphql.Request{\n\t\tQuery: req.Query,\n\t\tVariables: req.Variables,\n\t\tOpName: req.OpName,\n\t}, &r)\n}", "func Execute(ctx context.Context, query string, vars map[string]interface{}) (map[string]*json.RawMessage, error) {\n\tmediaQuery := graphql.NewRequest(query)\n\tfor k, v := range vars {\n\t\tmediaQuery.Var(k, v)\n\t}\n\n\tvar res map[string]*json.RawMessage\n\tif err := client.Run(ctx, mediaQuery, &res); err != nil {\n\t\treturn map[string]*json.RawMessage{}, err\n\t}\n\treturn res, nil\n}", "func (i *Intent) Execute(ctx context.Context, tts *tts.Service) {\n\tfor idx, action := range i.Actions {\n\t\terr := action(ctx, tts)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"error %v while executing the intent %q at action %d\\n\", err, i.Command, idx)\n\t\t\t// TODO Handle errors that will allow the rest of the intent to run\n\t\t\t// TODO Tell users about the errors encountered while running the intent and ask if the intent should continue the execution or retry\n\t\t\tbreak\n\t\t}\n\t}\n}", "func (drc *DeviceRequestCreate) Exec(ctx context.Context) error {\n\t_, err := drc.Save(ctx)\n\treturn err\n}", "func (upd *Update) Execute(vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) {\n\tif upd.QueryTimeout != 0 {\n\t\tcancel := vcursor.SetContextTimeout(time.Duration(upd.QueryTimeout) * time.Millisecond)\n\t\tdefer cancel()\n\t}\n\n\tswitch upd.Opcode {\n\tcase Unsharded:\n\t\treturn upd.execUpdateUnsharded(vcursor, bindVars)\n\tcase Equal:\n\t\treturn upd.execUpdateEqual(vcursor, bindVars)\n\tcase In:\n\t\treturn upd.execUpdateIn(vcursor, bindVars)\n\tcase Scatter:\n\t\treturn upd.execUpdateByDestination(vcursor, bindVars, key.DestinationAllShards{})\n\tcase ByDestination:\n\t\treturn upd.execUpdateByDestination(vcursor, bindVars, upd.TargetDestination)\n\tdefault:\n\t\t// Unreachable.\n\t\treturn nil, fmt.Errorf(\"unsupported opcode: %v\", upd)\n\t}\n}", "func (s *executionServer) Execute(\n\treq *remoteexecution.ExecuteRequest, execServer remoteexecution.Execution_ExecuteServer) error {\n\tlog.Debugf(\"Received Execute request: %s\", req)\n\n\tif !s.IsInitialized() {\n\t\treturn status.Error(codes.Internal, \"Server not initialized\")\n\t}\n\n\tvar err error = nil\n\n\t// Record metrics based on final error condition\n\tdefer func() {\n\t\tif err == nil {\n\t\t\ts.stat.Counter(stats.BzExecSuccessCounter).Inc(1)\n\t\t} else {\n\t\t\ts.stat.Counter(stats.BzExecFailureCounter).Inc(1)\n\t\t}\n\t}()\n\tdefer s.stat.Latency(stats.BzExecLatency_ms).Time().Stop()\n\n\t// Transform ExecuteRequest into Scoot Job, validate and schedule\n\t// If we encounter an error here, assume it was due to an InvalidArgument\n\tjob, err := execReqToScoot(req)\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to convert request to Scoot JobDefinition: %s\", err)\n\t\treturn status.Error(codes.InvalidArgument, fmt.Sprintf(\"Error converting request to internal definition: %s\", err))\n\t}\n\n\terr = domain.ValidateJob(job)\n\tif err != nil {\n\t\tlog.Errorf(\"Scoot Job generated from request invalid: %s\", err)\n\t\treturn status.Error(codes.Internal, fmt.Sprintf(\"Internal job definition invalid: %s\", err))\n\t}\n\n\tid, err := s.scheduler.ScheduleJob(job)\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to schedule Scoot job: %s\", err)\n\t\treturn status.Error(codes.Internal, fmt.Sprintf(\"Failed to schedule Scoot job: %s\", err))\n\t}\n\tlog.WithFields(\n\t\tlog.Fields{\n\t\t\t\"jobID\": id,\n\t\t}).Info(\"Scheduled execute request as Scoot job\")\n\n\teom := &remoteexecution.ExecuteOperationMetadata{\n\t\tStage: remoteexecution.ExecuteOperationMetadata_QUEUED,\n\t\tActionDigest: req.GetActionDigest(),\n\t}\n\n\t// Marshal ExecuteActionMetadata to protobuf.Any format\n\teomAsPBAny, err := marshalAny(eom)\n\tif err != nil {\n\t\treturn status.Error(codes.Internal, err.Error())\n\t}\n\n\t// Include the response message in the longrunning operation message\n\top := &longrunning.Operation{\n\t\tName: id,\n\t\tMetadata: eomAsPBAny,\n\t\tDone: false,\n\t}\n\n\t// Send the initial operation on the exec server stream\n\terr = execServer.Send(op)\n\tif err != nil {\n\t\treturn status.Error(codes.Internal, err.Error())\n\t}\n\n\tlog.Debug(\"ExecuteRequest completed successfully\")\n\treturn nil\n}", "func (du *DeviceUpdate) Exec(ctx context.Context) error {\n\t_, err := du.Save(ctx)\n\treturn err\n}", "func (in *SampleIn) Execute(ctx context.Context, req *proIntegrator.ExecuteRequest) (*proIntegrator.ExecuteResponse, error) {\n\n\tfmt.Println(\"SampleIn::Execute called with \" + req.Component.ParamsInput[\"Param1\"].Str + \" \" +\n\t\treq.Component.ParamsInput[\"Param2\"].Str)\n\n\tin.Component.ParamsOutput[\"Param1\"].Str = req.Component.ParamsInput[\"Param1\"].Str + \" SampleIn\"\n\tin.Component.ParamsOutput[\"Param2\"].Str = req.Component.ParamsInput[\"Param2\"].Str + \" SampleIn\"\n\n\tcomponent := &proIntegrator.Component{}\n\tmapIn := make(map[string]*proIntegrator.DataType)\n\tmapOut := make(map[string]*proIntegrator.DataType)\n\tfor key, value := range in.Component.ParamsInput {\n\t\tmapIn[key] = value\n\t}\n\tfor key, value := range in.Component.ParamsOutput {\n\t\tmapOut[key] = value\n\t}\n\tcomponent.Name = in.Component.Name\n\tcomponent.ParamsInput = mapIn\n\tcomponent.ParamsOutput = mapOut\n\n\tresponse := &proIntegrator.ExecuteResponse{component}\n\n\treturn response, nil\n}", "func (c *Client) Execute(ctx context.Context, req *http.Request, r interface{}) (*http.Response, error) {\n\treq = req.WithContext(ctx)\n\tdebugReq(req)\n\tresp, err := c.client.Do(req)\n\tif err != nil {\n\t\t// If we got an error, and the context has been canceled,\n\t\t// the context's error is probably more useful.\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn nil, ctx.Err()\n\t\tdefault:\n\t\t}\n\n\t\t// If the error type is *url.Error, sanitize its URL before returning.\n\t\tif e, ok := err.(*url.Error); ok {\n\t\t\tif url, err := url.Parse(e.URL); err == nil {\n\t\t\t\te.URL = sanitizeURL(url).String()\n\t\t\t\treturn nil, e\n\t\t\t}\n\t\t}\n\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != 200 && resp.StatusCode != 201 {\n\t\treturn nil, fmt.Errorf(\"Request to %s responded with status %d\", req.URL, resp.StatusCode)\n\t}\n\n\tif r != nil {\n\t\tif w, ok := r.(io.Writer); ok {\n\t\t\tio.Copy(w, resp.Body)\n\t\t} else {\n\t\t\tdecErr := json.NewDecoder(resp.Body).Decode(r)\n\t\t\tif decErr == io.EOF {\n\t\t\t\tdecErr = nil // ignore EOF errors caused by empty response body\n\t\t\t}\n\t\t\tif decErr != nil {\n\t\t\t\terr = decErr\n\t\t\t}\n\t\t}\n\t}\n\n\treturn resp, err\n}", "func (u Update) Invoke(parameters map[string]interface{}) *context.ActivityContext {\n\n\t// getting and assign the values from the MAP to internal variables\n\tsecurityToken := parameters[\"securityToken\"].(string)\n\t/*log := parameters[\"log\"].(string)*/\n\tdomain := parameters[\"namespace\"].(string)\n\tclass := parameters[\"class\"].(string)\n\tJSON_Document := parameters[\"JSON\"].(string)\n\n\t//creating new instance of context.ActivityContext\n\tvar activityContext = new(context.ActivityContext)\n\n\t//creating new instance of context.ActivityError\n\tvar activityError context.ActivityError\n\n\t//setting activityError proprty values\n\tactivityError.Encrypt = false\n\tactivityError.ErrorString = \"No Exception\"\n\tactivityError.Forward = false\n\tactivityError.SeverityLevel = context.Info\n\n\t// preparing the data relevent to make the objectstore API\n\t//url := \"http://\" + Common.GetObjectstoreIP() + \"/\" + domain + \"/\" + class\n\turl := \"http://\" + domain + \"/data/\" + domain + \"/\" + class + \"?securityToken=\" + securityToken\n\n\treq, err := http.NewRequest(\"PUT\", url, bytes.NewBuffer([]byte(JSON_Document)))\n\t/*req.Header.Set(\"securityToken\", securityToken)\n\treq.Header.Set(\"log\", log)*/\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\t// once the request is made according to the response the following is done\n\tif err != nil {\n\t\tactivityError.ErrorString = err.Error()\n\t\tactivityContext.ActivityStatus = false\n\t\tactivityContext.Message = \"Connection to server failed! Check connectivity.\"\n\t\tactivityContext.ErrorState = activityError\n\t} else {\n\t\tactivityContext.ActivityStatus = true\n\t\tactivityContext.Message = \"Data Successfully Updated!\"\n\t\tactivityContext.ErrorState = activityError\n\t}\n\tdefer resp.Body.Close()\n\t// once the functionality of the method completes it returns the processed data\n\treturn activityContext\n}", "func (m *MockFinder) Execute(ctx context.Context, query string, from int64, until int64) error {\n\tm.query = query\n\treturn nil\n}", "func (cmd *command) Execute(ch io.ReadWriter) (err error) {\n\tif cmd.Flags.Source {\n\t\terr = cmd.serveSource(ch)\n\t} else {\n\t\terr = cmd.serveSink(ch)\n\t}\n\tif err != nil {\n\t\treturn trace.Wrap(err)\n\t}\n\treturn nil\n}", "func (m *MockFinder) Execute(ctx context.Context, config *config.Config, query string, from int64, until int64, stat *FinderStat) (err error) {\n\tm.query = query\n\treturn\n}", "func (bq *InMemoryBuildQueue) Execute(in *remoteexecution.ExecuteRequest, out remoteexecution.Execution_ExecuteServer) error {\n\t// Fetch the action corresponding to the execute request.\n\t// Ideally, a scheduler is oblivious of what this message looks\n\t// like, if it weren't for the fact that DoNotCache and Platform\n\t// are used for scheduling decisions.\n\t//\n\t// To prevent loading this messages from the Content Addressable\n\t// Storage (CAS) multiple times, the scheduler holds on to it\n\t// and passes it on to the workers.\n\tctx := out.Context()\n\tinstanceName, err := digest.NewInstanceName(in.InstanceName)\n\tif err != nil {\n\t\treturn util.StatusWrapf(err, \"Invalid instance name %#v\", in.InstanceName)\n\t}\n\n\tif err := auth.AuthorizeSingleInstanceName(ctx, bq.executeAuthorizer, instanceName); err != nil {\n\t\treturn util.StatusWrap(err, \"Authorization\")\n\t}\n\n\tactionDigest, err := instanceName.NewDigestFromProto(in.ActionDigest)\n\tif err != nil {\n\t\treturn util.StatusWrap(err, \"Failed to extract digest for action\")\n\t}\n\tactionMessage, err := bq.contentAddressableStorage.Get(ctx, actionDigest).ToProto(&remoteexecution.Action{}, bq.maximumMessageSizeBytes)\n\tif err != nil {\n\t\treturn util.StatusWrap(err, \"Failed to obtain action\")\n\t}\n\taction := actionMessage.(*remoteexecution.Action)\n\tplatformKey, err := platform.NewKey(instanceName, action.Platform)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Forward the client-provided request metadata, so that the\n\t// worker logs it.\n\trequestMetadata := getRequestMetadata(ctx)\n\ttargetID := requestMetadata.GetTargetId()\n\tvar auxiliaryMetadata []*anypb.Any\n\tif requestMetadata != nil {\n\t\trequestMetadataAny, err := anypb.New(requestMetadata)\n\t\tif err != nil {\n\t\t\treturn util.StatusWrapWithCode(err, codes.InvalidArgument, \"Failed to marshal request metadata\")\n\t\t}\n\t\tauxiliaryMetadata = []*anypb.Any{requestMetadataAny}\n\t}\n\tw3cTraceContext := otel.W3CTraceContextFromContext(ctx)\n\n\t// TODO: Remove this code once all clients support REv2.2.\n\tif action.Platform == nil || targetID == \"\" {\n\t\tcommandDigest, err := instanceName.NewDigestFromProto(action.CommandDigest)\n\t\tif err != nil {\n\t\t\treturn util.StatusWrap(err, \"Failed to extract digest for command\")\n\t\t}\n\t\tcommandMessage, err := bq.contentAddressableStorage.Get(ctx, commandDigest).ToProto(&remoteexecution.Command{}, bq.maximumMessageSizeBytes)\n\t\tif err != nil {\n\t\t\treturn util.StatusWrap(err, \"Failed to obtain command\")\n\t\t}\n\t\tcommand := commandMessage.(*remoteexecution.Command)\n\n\t\t// REv2.1 and older don't provide platform properties as\n\t\t// part of the Action message.\n\t\tif action.Platform == nil {\n\t\t\tplatformKey, err = platform.NewKey(instanceName, command.Platform)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\t// REv2.1 RequestMetadata doesn't include the target_id\n\t\t// field. Provide the argv[0] instead, so that we gain\n\t\t// some insight in what this action does.\n\t\tif targetID == \"\" && len(command.Arguments) > 0 {\n\t\t\ttargetID = command.Arguments[0]\n\t\t}\n\t}\n\n\t// Create an invocation key. Operations are scheduled by\n\t// grouping them by invocation, so that scheduling is fair.\n\tplatformHooks := bq.platformHooks[bq.platformHooksTrie.GetLongestPrefix(platformKey)+1]\n\tinvocationID, err := platformHooks.ExtractInvocationID(ctx, instanceName, action, requestMetadata)\n\tif err != nil {\n\t\treturn util.StatusWrap(err, \"Failed to extract invocation ID from request\")\n\t}\n\tinvocationKey, err := newInvocationKey(invocationID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Analyze the action, so that we can later determine on which\n\t// size class this action needs to run.\n\tinitialSizeClassSelector, err := platformHooks.Analyze(ctx, actionDigest.GetDigestFunction(), action)\n\tif err != nil {\n\t\treturn util.StatusWrap(err, \"Failed to analyze initial size class of action\")\n\t}\n\n\tbq.enter(bq.clock.Now())\n\tdefer bq.leave()\n\n\tif t, ok := bq.inFlightDeduplicationMap[actionDigest]; ok {\n\t\t// A task for the same action digest already exists\n\t\t// against which we may deduplicate. No need to create a\n\t\t// task.\n\t\tinitialSizeClassSelector.Abandoned()\n\t\tscq := t.getSizeClassQueue()\n\t\ti := scq.getOrCreateInvocation(invocationKey)\n\t\tif o, ok := t.operations[i]; ok {\n\t\t\t// Task is already associated with the current\n\t\t\t// invocation. Simply wait on the operation that\n\t\t\t// already exists.\n\t\t\treturn o.waitExecution(bq, out)\n\t\t}\n\n\t\t// Create an additional operation for this task.\n\t\to := t.newOperation(bq, in.ExecutionPolicy.GetPriority(), i, false)\n\t\tswitch t.getStage() {\n\t\tcase remoteexecution.ExecutionStage_QUEUED:\n\t\t\t// The request has been deduplicated against a\n\t\t\t// task that is still queued.\n\t\t\to.enqueue()\n\t\tcase remoteexecution.ExecutionStage_EXECUTING:\n\t\t\t// The request has been deduplicated against a\n\t\t\t// task that is already in the executing stage.\n\t\t\ti.incrementExecutingWorkersCount()\n\t\tdefault:\n\t\t\tpanic(\"Task in unexpected stage\")\n\t\t}\n\t\treturn o.waitExecution(bq, out)\n\t}\n\n\t// We need to create a new task. For that we first need to\n\t// obtain the size class queue in which we're going to place it.\n\tplatformQueueIndex := bq.platformQueuesTrie.GetLongestPrefix(platformKey)\n\tif platformQueueIndex < 0 {\n\t\tcode := codes.FailedPrecondition\n\t\tif bq.now.Before(bq.platformQueueAbsenceHardFailureTime) {\n\t\t\t// The scheduler process started not too long\n\t\t\t// ago. It may be the case that clients ended up\n\t\t\t// connecting to the scheduler before workers\n\t\t\t// got a chance to synchronize.\n\t\t\t//\n\t\t\t// Prevent builds from failing unnecessarily by\n\t\t\t// providing a brief window of time where\n\t\t\t// soft errors are returned to the client,\n\t\t\t// giving workers time to reconnect.\n\t\t\tcode = codes.Unavailable\n\t\t}\n\t\tinitialSizeClassSelector.Abandoned()\n\t\treturn status.Errorf(code, \"No workers exist for instance name prefix %#v platform %s\", platformKey.GetInstanceNamePrefix().String(), platformKey.GetPlatformString())\n\t}\n\tpq := bq.platformQueues[platformQueueIndex]\n\tsizeClassIndex, timeout, initialSizeClassLearner := initialSizeClassSelector.Select(pq.sizeClasses)\n\tscq := pq.sizeClassQueues[sizeClassIndex]\n\n\t// Create the task.\n\tactionWithCustomTimeout := *action\n\tactionWithCustomTimeout.Timeout = durationpb.New(timeout)\n\tt := &task{\n\t\toperations: map[*invocation]*operation{},\n\t\tactionDigest: actionDigest,\n\t\tdesiredState: remoteworker.DesiredState_Executing{\n\t\t\tActionDigest: in.ActionDigest,\n\t\t\tAction: &actionWithCustomTimeout,\n\t\t\tQueuedTimestamp: bq.getCurrentTime(),\n\t\t\tAuxiliaryMetadata: auxiliaryMetadata,\n\t\t\tInstanceNameSuffix: pq.instanceNamePatcher.PatchInstanceName(instanceName).String(),\n\t\t\tW3CTraceContext: w3cTraceContext,\n\t\t},\n\t\ttargetID: targetID,\n\t\tinitialSizeClassLearner: initialSizeClassLearner,\n\t\tstageChangeWakeup: make(chan struct{}),\n\t}\n\tif !action.DoNotCache {\n\t\tbq.inFlightDeduplicationMap[actionDigest] = t\n\t}\n\ti := scq.getOrCreateInvocation(invocationKey)\n\to := t.newOperation(bq, in.ExecutionPolicy.GetPriority(), i, false)\n\tt.schedule(bq)\n\treturn o.waitExecution(bq, out)\n}", "func (ui *UI) exec(ctx context.Context, line string, reqCh chan execReq) int {\n\treq := execReq{\n\t\tctx: ctx,\n\t\tline: line,\n\t\tui: ui,\n\t\trespCh: make(chan int),\n\t}\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn 0\n\tcase reqCh <- req:\n\t}\n\treturn <-req.respCh\n}", "func (this *Query_UServ_UpdateNameToFoo) Execute(x In_UServ_UpdateNameToFoo) *Iter_UServ_UpdateNameToFoo {\n\tvar setupErr error\n\tparams := []interface{}{\n\t\tfunc() (out interface{}) {\n\t\t\tout = x.GetId()\n\t\t\treturn\n\t\t}(),\n\t}\n\tresult := &Iter_UServ_UpdateNameToFoo{\n\t\ttm: this.opts.MAPPINGS,\n\t\tctx: this.ctx,\n\t}\n\tif setupErr != nil {\n\t\tresult.err = setupErr\n\t\treturn result\n\t}\n\tresult.result, result.err = this.db.ExecContext(this.ctx, \"Update users set name = 'foo' WHERE id = $1\", params...)\n\treturn result\n}", "func (a *Activity) Eval(ctx activity.Context) (done bool, err error) {\n\n\tinput := &Input{}\n\n\terr = ctx.GetInputObject(input)\n\tif err != nil {\n\t\treturn true, err\n\t}\n\tfmt.Println(input.Username)\n\n\tfmt.Println(\"requesting...\")\n\tinsertdata(input.Username, input.Connectionstring, input.Password, input.Content)\n\toutput := &Output{Output: \"success\"}\n\n\terr = ctx.SetOutputObject(output)\n\tif err != nil {\n\t\treturn true, err\n\t}\n\treturn true, nil\n}", "func Execute() *fire.Callback {\n\t// prepare matchers\n\tgetFilterMatcher := fire.Except(fire.Create | fire.CollectionAction)\n\tverifyIDMatcher := fire.Except(fire.List | fire.Create | fire.CollectionAction)\n\tverifyModelMatcher := fire.Except(fire.Create | fire.CollectionAction)\n\tverifyCreateMatcher := fire.Only(fire.Create)\n\tverifyUpdateMatcher := fire.Only(fire.Update)\n\tgetFieldsAndPropsMatcher := fire.Except(fire.Delete | fire.CollectionAction | fire.ResourceAction)\n\n\t// prepare access tables\n\tgenericAccess := map[fire.Operation]Access{\n\t\tfire.List: List,\n\t\tfire.Find: Find,\n\t\tfire.Create: Create,\n\t\tfire.Update: Update,\n\t\tfire.Delete: Delete,\n\t\tfire.ResourceAction: Find,\n\t}\n\treadAccess := map[fire.Operation]Access{\n\t\tfire.List: List,\n\t\tfire.Find: Find,\n\t\tfire.Create: Find,\n\t\tfire.Update: Find,\n\t}\n\twriteAccess := map[fire.Operation]Access{\n\t\tfire.Create: Create,\n\t\tfire.Update: Update,\n\t}\n\n\treturn fire.C(\"ash/Execute\", fire.Authorizer, fire.All(), func(ctx *fire.Context) error {\n\t\t// get policy\n\t\tpolicy, _ := ctx.Data[PolicyDataKey].(*Policy)\n\t\tif policy == nil {\n\t\t\treturn fire.ErrAccessDenied.Wrap()\n\t\t}\n\n\t\t// check access\n\t\taccess := genericAccess[ctx.Operation]\n\t\tif policy.Access&access != access {\n\t\t\treturn fire.ErrAccessDenied.Wrap()\n\t\t}\n\n\t\t// apply filter if available\n\t\tif getFilterMatcher(ctx) && policy.GetFilter != nil {\n\t\t\tctx.Filters = append(ctx.Filters, policy.GetFilter(ctx))\n\t\t}\n\n\t\t// verify action access\n\t\tif ctx.Operation.Action() {\n\t\t\t// get action\n\t\t\taction := ctx.JSONAPIRequest.CollectionAction\n\t\t\tif ctx.Operation == fire.ResourceAction {\n\t\t\t\taction = ctx.JSONAPIRequest.ResourceAction\n\t\t\t}\n\n\t\t\t// check action\n\t\t\tif !policy.Actions[action] {\n\t\t\t\treturn fire.ErrAccessDenied.Wrap()\n\t\t\t}\n\t\t}\n\n\t\t// verify ID if available\n\t\tif verifyIDMatcher(ctx) && policy.VerifyID != nil {\n\t\t\t// get access\n\t\t\taccess := policy.VerifyID(ctx, ctx.Selector[\"_id\"].(coal.ID))\n\n\t\t\t// check access\n\t\t\tif access&genericAccess[ctx.Operation] == 0 {\n\t\t\t\treturn fire.ErrAccessDenied.Wrap()\n\t\t\t}\n\t\t}\n\n\t\t// verify model if available\n\t\tif verifyModelMatcher(ctx) && policy.VerifyModel != nil {\n\t\t\tctx.Defer(fire.C(\"ash/Execute-VerifyModel\", fire.Verifier, verifyModelMatcher, func(ctx *fire.Context) error {\n\t\t\t\t// get required access\n\t\t\t\treqAccess := genericAccess[ctx.Operation]\n\n\t\t\t\t// check access\n\t\t\t\tif ctx.Operation == fire.List {\n\t\t\t\t\tfor _, model := range ctx.Models {\n\t\t\t\t\t\tif policy.VerifyModel(ctx, model)&reqAccess == 0 {\n\t\t\t\t\t\t\treturn fire.ErrAccessDenied.Wrap()\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif policy.VerifyModel(ctx, ctx.Model)&reqAccess == 0 {\n\t\t\t\t\t\treturn fire.ErrAccessDenied.Wrap()\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn nil\n\t\t\t}))\n\t\t}\n\n\t\t// verify create if available\n\t\tif verifyCreateMatcher(ctx) && policy.VerifyCreate != nil {\n\t\t\tctx.Defer(fire.C(\"ash/Execute-VerifyCreate\", fire.Validator, verifyCreateMatcher, func(ctx *fire.Context) error {\n\t\t\t\t// check access\n\t\t\t\tif !policy.VerifyCreate(ctx, ctx.Model) {\n\t\t\t\t\treturn fire.ErrAccessDenied.Wrap()\n\t\t\t\t}\n\n\t\t\t\treturn nil\n\t\t\t}))\n\t\t}\n\n\t\t// verify update if available\n\t\tif verifyUpdateMatcher(ctx) && policy.VerifyUpdate != nil {\n\t\t\tctx.Defer(fire.C(\"ash/Execute-VerifyUpdate\", fire.Validator, verifyUpdateMatcher, func(ctx *fire.Context) error {\n\t\t\t\t// check access\n\t\t\t\tif !policy.VerifyUpdate(ctx, ctx.Model) {\n\t\t\t\t\treturn fire.ErrAccessDenied.Wrap()\n\t\t\t\t}\n\n\t\t\t\treturn nil\n\t\t\t}))\n\t\t}\n\n\t\t// collect fields\n\t\treadableFields := policy.Fields.Collect(readAccess[ctx.Operation])\n\t\twritableFields := policy.Fields.Collect(writeAccess[ctx.Operation])\n\n\t\t// set intersections of fields\n\t\tctx.ReadableFields = stick.Intersect(ctx.ReadableFields, readableFields)\n\t\tctx.WritableFields = stick.Intersect(ctx.WritableFields, writableFields)\n\n\t\t// set fields getters if available\n\t\tif getFieldsAndPropsMatcher(ctx) && policy.GetFields != nil {\n\t\t\tctx.GetReadableFields = func(model coal.Model) []string {\n\t\t\t\tif model == nil {\n\t\t\t\t\treturn readableFields\n\t\t\t\t}\n\t\t\t\treturn policy.GetFields(ctx, model).Collect(readAccess[ctx.Operation])\n\t\t\t}\n\t\t\tctx.GetWritableFields = func(model coal.Model) []string {\n\t\t\t\tif ctx.Operation == fire.Create {\n\t\t\t\t\treturn writableFields\n\t\t\t\t}\n\t\t\t\treturn policy.GetFields(ctx, model).Collect(writeAccess[ctx.Operation])\n\t\t\t}\n\t\t}\n\n\t\t// set properties getter if available\n\t\tif getFieldsAndPropsMatcher(ctx) && policy.GetProperties != nil {\n\t\t\tctx.GetReadableProperties = func(model coal.Model) []string {\n\t\t\t\treturn policy.GetProperties(ctx, model).Collect(readAccess[ctx.Operation])\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t})\n}", "func (c *Command) Execute(ctx context.Context) error {\n\n\tpctx := &commandContext{\n\t\tdependencyResolver: pipeline.NewDependencyRecorder[*commandContext](),\n\t\tContext: ctx,\n\t}\n\n\tp := pipeline.NewPipeline[*commandContext]().WithBeforeHooks(pipe.DebugLogger[*commandContext](c.Log), pctx.dependencyResolver.Record)\n\tp.WithSteps(\n\t\tp.NewStep(\"create client\", c.createClient),\n\t\tp.NewStep(\"fetch task\", c.fetchTask),\n\t\tp.NewStep(\"list intermediary files\", c.listIntermediaryFiles),\n\t\tp.NewStep(\"delete intermediary files\", c.deleteFiles),\n\t\tp.NewStep(\"delete source file\", c.deleteSourceFile),\n\t)\n\n\treturn p.RunWithContext(pctx)\n}", "func (tt *TestCase) Execute(t *testing.T, fn echo.HandlerFunc) {\n\treq := tt.Request.Request()\n\trec, err := Do(fn, req, tt.Request.URLParams)\n\tif tt.ExpectedError != \"\" {\n\t\trequire.EqualError(t, err, tt.ExpectedError)\n\t} else {\n\t\trequire.NoError(t, err)\n\t\tEqualResp(t, tt.ExpectedResponse, rec)\n\t}\n}", "func (c *connector) Invoke(ctx radio.Context) error {\n\tif ctx == nil {\n\t\treturn errors.New(\"no context given\")\n\t}\n\n\t// Obtaining exclusive lock on command\n\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\n\t// Sending indicator, that command in progress\n\tctx.CommandInProgress()\n\n\t// Running with os.Std replacements\n\tvar err error\n\tsout, serr := std.BindStrings(func() {\n\t\tc.cmd.SetArgs(ctx.GetArgs())\n\t\terr = c.cmd.Execute()\n\t})\n\n\t// Packing response\n\tif len(serr) > 0 {\n\t\tctx.SendMessage(serr)\n\t}\n\tif len(sout) > 0 {\n\t\tctx.SendMessage(sout)\n\t}\n\tif err != nil {\n\t\tctx.SendMessage(err)\n\t}\n\n\treturn err\n}", "func (e *ldapExecutor) Execute(ctx context.Context, config *ldapconf.Config) error {\n\treturn nil\n}", "func (p *ContextPlugin) Execute(event *types.Event) *types.Event {\n\tif event.Time == 0 {\n\t\tevent.Time = time.Now().UnixMilli()\n\t}\n\n\tif event.InsertID == \"\" {\n\t\tevent.InsertID = uuid.NewString()\n\t}\n\n\tevent.Library = p.contextString\n\n\treturn event\n}", "func (hh *HealthCheckHandler) Execute(w http.ResponseWriter, r *http.Request) {\n\tuuid := utils.ExtractUUID(r.URL.String())\n\tif uuid == \"\" {\n\t\thttp.Error(w, marshalError(\"invalid uuid\"), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tqueryParams := r.URL.Query()\n\ttimeout, err := time.ParseDuration(queryParams[\"timeout\"][0])\n\tif err != nil {\n\t\thttp.Error(w, marshalError(err.Error()), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\thc, err := hh.db.Get(uuid)\n\tif err != nil {\n\t\thttp.Error(w, marshalError(err.Error()), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t// make a copy and run the healthcheck\n\ttry := &models.HealthCheck{\n\t\tID: hc.ID,\n\t\tEndpoint: hc.Endpoint,\n\t}\n\n\ttry = service.Run(try, timeout)\n\n\tb, err := json.Marshal(try)\n\tif err != nil {\n\t\thttp.Error(w, marshalError(err.Error()), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Write(b)\n}", "func (c *carHandler) Execute(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"CarsHandler actived\")\n\tcontentType := r.Header.Get(\"Content-type\")\n\tif contentType != \"application/json\" {\n\t\tlog.Println(fmt.Errorf(\"Content Type is not valid\"))\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tvar input []usecase.CarInput\n\tdefer r.Body.Close()\n\n\tdecoder := json.NewDecoder(r.Body)\n\tif err := decoder.Decode(&input); err != nil {\n\t\tlog.Println(err)\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif err := c.validate(input); err != nil {\n\t\tlog.Println(err)\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif err := c.CarUsecase.PutCars(input); err != nil {\n\t\tlog.Println(err)\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tlog.Println(fmt.Sprintf(\"Car created\"))\n\tw.WriteHeader(http.StatusOK)\n\treturn\n}", "func HandleRequest(ctx context.Context, event StatusUpdatedEvent) error {\n\t// Print the event\n\tlog.Printf(\"%v\\n\", event)\n\t// Validate the event\n\tif err := shared.Validate.Struct(event); err != nil {\n\t\treturn err\n\t}\n\t// Get the device\n\tdevice, err := iot.GetThing(event.DeviceId)\n\tif err != nil {\n\t\tshared.LogErrorAndExit(err)\n\t}\n\t// Get the device shadow\n\tshdw, err := shadowClient.Get(event.DeviceId)\n\tif err != nil {\n\t\treturn err\n\t}\n\taccountID := device.AccountId\n\tlog.Printf(\"Device '%s' associated with account '%s'\", event.DeviceId, accountID)\n\t// Get the account\n\taccount, err := db.GetAccountById(accountID)\n\tif err != nil {\n\t\tshared.LogErrorAndExit(err)\n\t}\n\t// Determine parameters for the email\n\tstateType, transitionType, err := powerStatusToEnums(event.State.Status)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Construct an event to pass to the emailer\n\tupdate := email.ContextData{\n\t\tDeviceName: shdw.Name,\n\t\tTime: time.Unix(event.Updated.Status.Timestamp, 0),\n\t}\n\t// Send 'power status updated' emails\n\tlog.Printf(\"Send emails to: %s\", account.Emails)\n\terr = emailClient.SendUpdate(account.Emails, stateType, transitionType, update)\n\tif err != nil {\n\t\tshared.LogErrorAndExit(err)\n\t}\n\treturn nil\n}", "func (c *Client) Do(schema *RequestSchema) (Response, error) {\n\treq, err := c.lifecycle.Build(schema)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp, err := c.lifecycle.Execute(req, schema.Into)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err = c.lifecycle.Cleanup(resp); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn resp, nil\n}", "func (o *LunOnlineRequest) ExecuteUsing(zr *ZapiRunner) (*LunOnlineResponse, error) {\n\treturn o.executeWithoutIteration(zr)\n}", "func (s *MachineActionExecutor) Execute(vmDTO *TurboActionExecutorInput) (*TurboActionExecutorOutput, error) {\n\tnodeName := vmDTO.ActionItems[0].GetTargetSE().GetDisplayName()\n\tvar actionType ActionType\n\tvar diff int32\n\tswitch vmDTO.ActionItems[0].GetActionType() {\n\tcase proto.ActionItemDTO_PROVISION:\n\t\tactionType = ProvisionAction\n\t\tdiff = 1\n\tcase proto.ActionItemDTO_SUSPEND:\n\t\tactionType = SuspendAction\n\t\tdiff = -1\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported action type %v\", vmDTO.ActionItems[0].GetActionType())\n\t}\n\t// Get on with it.\n\tcontroller, key, err := newController(s.cAPINamespace, nodeName, diff, actionType, s.executor.clusterScraper)\n\tif err != nil {\n\t\treturn nil, err\n\t} else if key == nil {\n\t\treturn nil, fmt.Errorf(\"the target machine deployment has no name\")\n\t}\n\tscaleDirection := \"up\"\n\tscaleAmount := diff\n\tif diff < 0 {\n\t\tscaleDirection = \"down\"\n\t\tscaleAmount = -diff\n\t}\n\tglog.V(2).Infof(\"Starting to scale %s the machineSet %s by %d replica\", scaleDirection, *key, scaleAmount)\n\t// See if we already have this.\n\t_, ok := s.cache.Get(*key)\n\tif ok {\n\t\treturn nil, fmt.Errorf(\"the action against the %s is already running\", *key)\n\t}\n\ts.cache.Add(*key, key)\n\tdefer s.unlock(*key)\n\t// Check other preconditions.\n\terr = controller.checkPreconditions()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = controller.executeAction()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = controller.checkSuccess()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tglog.V(2).Infof(\"Completed scaling %s the machineSet %s by %d replica\", scaleDirection, *key, scaleAmount)\n\treturn &TurboActionExecutorOutput{Succeeded: true}, nil\n}", "func (req *Request) ExecuteRequest(client *http.Client) datastructure.Response {\n\tvar response datastructure.Response\n\tvar start = time.Now()\n\tvar err error\n\n\tif client == nil {\n\t\tclient = http.DefaultClient\n\t}\n\n\tlog.Debug(\"ExecuteRequest | Executing request ...\")\n\t//client := &http.Client{Transport: req.Tr, Timeout: req.Timeout}\n\treq.Tr.DisableKeepAlives = true\n\tclient.Transport = req.Tr\n\tclient.Timeout = req.Timeout\n\tlog.Debugf(\"Request: %+v\\n\", req.Req)\n\tlog.Debugf(\"Client: %+v\\n\", client)\n\n\t// If content length was not specified (only for POST) add an headers with the length of the request\n\tif req.Method == \"POST\" && req.Req.Header.Get(\"Content-Length\") == \"\" {\n\t\tcontentLength := strconv.FormatInt(req.Req.ContentLength, 10)\n\t\treq.Req.Header.Set(\"Content-Length\", contentLength)\n\t\tlog.Debug(\"ExecuteRequest | Setting Content-Length -> \", contentLength)\n\n\t}\n\tresp, err := client.Do(req.Req)\n\n\tif err != nil {\n\t\tlog.Error(\"Error executing request | ERR:\", err)\n\t\terr = errors.New(\"ERROR_SENDING_REQUEST -> \" + err.Error())\n\t\tresponse.Error = err\n\t\treturn response\n\t}\n\n\tdefer resp.Body.Close()\n\tresponse.Headers = make(map[string]string, len(resp.Header))\n\tfor k, v := range resp.Header {\n\t\tresponse.Headers[k] = strings.Join(v, `,`)\n\t}\n\tresponse.Cookie = resp.Cookies()\n\n\t//log.Debug(\"ExecuteRequest | Request executed, reading response ...\")]\n\tbodyResp, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif err = resp.Body.Close(); err != nil {\n\t\tlog.Println(\"Error during connection closing! \", err.Error())\n\t}\n\tif err != nil {\n\t\tlog.Error(\"Unable to read response! | Err: \", err)\n\t\terr = errors.New(\"ERROR_READING_RESPONSE -> \" + err.Error())\n\t\tresponse.Error = err\n\t\treturn response\n\t}\n\n\tresponse.Body = bodyResp\n\tresponse.StatusCode = resp.StatusCode\n\tresponse.Error = nil\n\telapsed := time.Since(start)\n\tresponse.Time = elapsed\n\tresponse.Response = resp\n\tlog.Debug(\"ExecuteRequest | Elapsed -> \", elapsed, \" | STOP!\")\n\treturn response\n}", "func executeRequest(method string, url string, body *bytes.Buffer, asAdmin bool) *http.Response {\n\tconfig, err := loadConfig(testConfigPath)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Unable to load config %s\", err))\n\t}\n\n\th := handler{\n\t\tlogger: log.NewNopLogger(),\n\t\tnewCredentialsProvider: newMockProvider,\n\t\targo: mockWorkflowSvc{},\n\t\tconfig: config,\n\t\tgitClient: newMockGitClient(),\n\t\tnewCredsProviderSvc: mockCredsProvSvc,\n\t\tenv: env.Vars{\n\t\t\tAdminSecret: testPassword,\n\t\t},\n\t\tdbClient: newMockDB(),\n\t}\n\n\tvar router = setupRouter(h)\n\treq, _ := http.NewRequest(method, url, body)\n\tauthorizationHeader := \"vault:user:\" + testPassword\n\tif asAdmin {\n\t\tauthorizationHeader = \"vault:admin:\" + testPassword\n\t}\n\treq.Header.Add(\"Authorization\", authorizationHeader)\n\tw := httptest.NewRecorder()\n\trouter.ServeHTTP(w, req)\n\treturn w.Result()\n}", "func (c *clientRegistry) Execute(frame []byte) error {\n\theaders, err := getHeadersFromFrame(frame)\n\tif err != nil {\n\t\tlog.Warn(\"frugal: invalid protocol frame headers:\", err)\n\t\treturn err\n\t}\n\n\topid, err := strconv.ParseUint(headers[opID], 10, 64)\n\tif err != nil {\n\t\tlog.Warn(\"frugal: invalid protocol frame:\", err)\n\t\treturn err\n\t}\n\n\tc.mu.RLock()\n\thandler, ok := c.handlers[opid]\n\tif !ok {\n\t\tc.mu.RUnlock()\n\t\treturn nil\n\t}\n\tc.mu.RUnlock()\n\n\treturn handler(&thrift.TMemoryBuffer{Buffer: bytes.NewBuffer(frame)})\n}", "func (druo *DeviceRequestUpdateOne) ExecX(ctx context.Context) {\n\tif err := druo.Exec(ctx); err != nil {\n\t\tpanic(err)\n\t}\n}", "func (sc *SkynetClient) executeRequest(config requestOptions) (*http.Response, error) {\n\turl := sc.PortalURL\n\tmethod := config.method\n\treqBody := config.reqBody\n\n\t// Set options, prioritizing options passed to the API calls.\n\topts := sc.Options\n\tif config.EndpointPath != \"\" {\n\t\topts.EndpointPath = config.EndpointPath\n\t}\n\tif config.APIKey != \"\" {\n\t\topts.APIKey = config.APIKey\n\t}\n\tif config.CustomUserAgent != \"\" {\n\t\topts.CustomUserAgent = config.CustomUserAgent\n\t}\n\tif config.customContentType != \"\" {\n\t\topts.customContentType = config.customContentType\n\t}\n\n\t// Make the URL.\n\turl = makeURL(url, opts.EndpointPath, config.extraPath, config.query)\n\n\t// Create the request.\n\treq, err := http.NewRequest(method, url, reqBody)\n\tif err != nil {\n\t\treturn nil, errors.AddContext(err, fmt.Sprintf(\"could not create %v request\", method))\n\t}\n\tif opts.APIKey != \"\" {\n\t\treq.SetBasicAuth(\"\", opts.APIKey)\n\t}\n\tif opts.CustomUserAgent != \"\" {\n\t\treq.Header.Set(\"User-Agent\", opts.CustomUserAgent)\n\t}\n\tif opts.customContentType != \"\" {\n\t\treq.Header.Set(\"Content-Type\", opts.customContentType)\n\t}\n\n\t// Execute the request.\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn nil, errors.AddContext(err, \"could not execute request\")\n\t}\n\tif resp.StatusCode >= 400 {\n\t\treturn nil, errors.AddContext(makeResponseError(resp), \"error code received\")\n\t}\n\n\treturn resp, nil\n}", "func (self *Client) exec(request Request) error {\n\tself.logDebug.Printf(\"Client.exec: cmd=%02x flags=%04x...\", request.Cmd, request.Flags)\n\n\tmsg := self.genlFamily.Request(request.Cmd, request.Flags, nil, request.Attrs.Bytes())\n\n\tif out, err := self.genlHub.Sync(msg); err != nil {\n\t\treturn err\n\t} else {\n\t\tfor _, msg := range out {\n\t\t\tif msg.Header.Type == syscall.NLMSG_ERROR {\n\t\t\t\tif msgErr := nlgo.NlMsgerr(msg.NetlinkMessage); msgErr.Payload().Error != 0 {\n\t\t\t\t\treturn msgErr\n\t\t\t\t} else {\n\t\t\t\t\t// ack\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tself.logWarning.Printf(\"Client.exec: Unexpected response: %+v\", msg)\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t}\n}", "func (c *Client) Run(ctx context.Context, req *Request, resp interface{}) error {\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tdefault:\n\t}\n\n\treturn c.runWithJSON(ctx, req, resp)\n}", "func (s *Service) Process(ctx context.Context, request []byte) ([]byte, error) {\n\tserviceContext := GetServiceContext(ctx)\n\tname, args, err := s.Codec.Decode(request, serviceContext)\n\tif err != nil {\n\t\treturn s.Codec.Encode(err, serviceContext)\n\t}\n\tvar result interface{}\n\tfunc() {\n\t\tdefer func() {\n\t\t\tif p := recover(); p != nil {\n\t\t\t\tresult = NewPanicError(p)\n\t\t\t}\n\t\t}()\n\t\tresults, err := s.invokeManager.Handler().(NextInvokeHandler)(ctx, name, args)\n\t\tif err != nil {\n\t\t\tresult = err\n\t\t\treturn\n\t\t}\n\t\tswitch len(results) {\n\t\tcase 0:\n\t\t\tresult = nil\n\t\tcase 1:\n\t\t\tresult = results[0]\n\t\tdefault:\n\t\t\tresult = results\n\t\t}\n\t}()\n\treturn s.Codec.Encode(result, serviceContext)\n}", "func (aruo *AuthRequestUpdateOne) Exec(ctx context.Context) error {\n\t_, err := aruo.Save(ctx)\n\treturn err\n}", "func (c *Client) ExecuteFunction(request *ExecuteFunctionRequest) (response *ExecuteFunctionResponse, err error) {\n if request == nil {\n request = NewExecuteFunctionRequest()\n }\n response = NewExecuteFunctionResponse()\n err = c.Send(request, response)\n return\n}", "func (h *handlerState) execute(ctx context.Context, tracker attribute.Tracker, attrs *mixerpb.Attributes, method config.APIMethod) *rpc.Status {\n\tab, err := tracker.StartRequest(attrs)\n\tif err != nil {\n\t\tglog.Warningf(\"Unable to process attribute update. error: '%v'\", err)\n\t\treturn newStatus(code.Code_INVALID_ARGUMENT)\n\t}\n\tdefer tracker.EndRequest()\n\n\t// get a new context with the attribute bag attached\n\tctx = attribute.NewContext(ctx, ab)\n\n\tuntypedCfg := h.cfg.Load()\n\tif untypedCfg == nil {\n\t\tconst gerr = \"configuration is not available\"\n\t\t// config has NOT been loaded yet\n\t\tglog.Error(gerr)\n\t\treturn newStatusWithMessage(code.Code_INTERNAL, gerr)\n\t}\n\tcfg := untypedCfg.(config.Resolver)\n\tcfgs, err := cfg.Resolve(ab, h.methodmap[method])\n\tif err != nil {\n\t\treturn newStatusWithMessage(code.Code_INTERNAL, fmt.Sprintf(\"unable to resolve config %s\", err.Error()))\n\t}\n\tif glog.V(2) {\n\t\tglog.Infof(\"Resolved [%d] ==> %v \", len(cfgs), cfgs)\n\t}\n\n\touts, err := h.aspectExecutor.Execute(ctx, cfgs, ab)\n\tif err != nil {\n\t\treturn newStatusWithMessage(code.Code_INTERNAL, err.Error())\n\t}\n\tfor _, out := range outs {\n\t\tif out.Code != code.Code_OK {\n\t\t\treturn newStatus(out.Code)\n\t\t}\n\t}\n\treturn newStatus(code.Code_OK)\n}", "func (c *client) Do(r *http.Request) (io.ReadCloser, error) {\n\tc.rateRequest()\n\tif !c.token.Valid() {\n\t\tvar err error\n\t\tc.cli, c.token, err = build(c.id, c.secret, c.user, c.pass)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn c.exec(r)\n}", "func (c Client) executeRequest(req *http.Request) ([]byte, error) {\n\tresp, err := c.httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\tbuf := new(bytes.Buffer)\n\tbuf.ReadFrom(resp.Body)\n\tbytes := buf.Bytes()\n\tif resp.StatusCode != 200 {\n\t\treturn bytes, fmt.Errorf(\"%s %s failed. Response code was %s\", req.Method, req.URL, resp.Status)\n\t}\n\treturn bytes, nil\n}", "func (r *Carol) Execute(cfg ExecConfig) {\n\tr.Responder.Execute(cfg, r.exec)\n}", "func (b *Backend) Exec(request *frames.ExecRequest) (frames.Frame, error) {\n\tcmd := strings.TrimSpace(strings.ToLower(request.Proto.Command))\n\tswitch cmd {\n\tcase \"infer\", \"infer_schema\":\n\t\treturn nil, b.inferSchema(request)\n\tcase \"update\":\n\t\treturn nil, b.updateItem(request)\n\t}\n\treturn nil, fmt.Errorf(\"NoSQL backend doesn't support execute command '%s'\", cmd)\n}", "func (r *analyticsDeferredResultHandle) executeHandle(req *gocbcore.HttpRequest, valuePtr interface{}) error {\n\tresp, err := r.provider.DoHttpRequest(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tjsonDec := json.NewDecoder(resp.Body)\n\terr = jsonDec.Decode(valuePtr)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = resp.Body.Close()\n\tif err != nil {\n\t\tlogDebugf(\"Failed to close socket (%s)\", err)\n\t}\n\n\treturn nil\n}", "func (cu *CurlJob) Execute(ctx context.Context) {\n\tcu.request = cu.request.WithContext(ctx)\n\tvar err error\n\tcu.Response, err = cu.httpClient.Do(cu.request)\n\n\tif err == nil && cu.Response.StatusCode >= 200 && cu.Response.StatusCode < 400 {\n\t\tcu.JobStatus = OK\n\t} else {\n\t\tcu.JobStatus = FAILURE\n\t}\n}", "func (tx *Hello) Execute(p types.Process, ctw *types.ContextWrapper, index uint16) error {\n\tsp := p.(*HelloWorld)\n\n\treturn sp.vault.WithFee(p, ctw, tx, func() error {\n\t\tif err := sp.AddHelloCount(ctw, tx.To); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}", "func (aru *AuthRequestUpdate) ExecX(ctx context.Context) {\n\tif err := aru.Exec(ctx); err != nil {\n\t\tpanic(err)\n\t}\n}", "func (c *authenticatedConnection) Do(ctx context.Context, req driver.Request) (driver.Response, error) {\n\tif atomic.LoadInt32(&c.prepared) == 0 {\n\t\t// Probably we're not yet prepared\n\t\tif err := c.prepare(ctx); err != nil {\n\t\t\t// Authentication failed\n\t\t\treturn nil, driver.WithStack(err)\n\t\t}\n\t}\n\t// Configure the request for authentication.\n\tif err := c.auth.Configure(req); err != nil {\n\t\t// Failed to configure request for authentication\n\t\treturn nil, driver.WithStack(err)\n\t}\n\t// Do the authenticated request\n\tresp, err := c.conn.Do(ctx, req)\n\tif err != nil {\n\t\treturn nil, driver.WithStack(err)\n\t}\n\treturn resp, nil\n}", "func (exe *HTTPRemote) Execute(param map[string]interface{}) (map[string]interface{}, error) {\n\texeID, _ := util.GetStringParam(param, \"id\")\n\n\tparamJSON, err := json.Marshal(param)\n\tif err != nil {\n\t\texe.Errorf(\"Generate json param error: %s\", err)\n\t\treturn nil, errors.New(\"Generate json param error\")\n\t}\n\n\tsignatureBytes := util.CalculateMAC(paramJSON, []byte(exe.Secret))\n\tsignature := hex.EncodeToString(signatureBytes)\n\n\treq, err := http.NewRequest(\"POST\", exe.Host, bytes.NewBuffer(paramJSON))\n\tif err != nil {\n\t\texe.Errorf(\"Create request failed: %s\", err)\n\t\treturn nil, errors.New(\"Create request failed\")\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"X-Herald-Signature\", signature)\n\n\texe.Infof(\"Start to connect to: %s\", exe.Host)\n\n\tclient := &http.Client{\n\t\tTimeout: exe.Timeout,\n\t}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\texe.Errorf(\"Remote execution request failed: %s\", err)\n\t\treturn nil, errors.New(\"Remote execution request failed\")\n\t}\n\tdefer resp.Body.Close()\n\n\tcontentType := resp.Header.Get(\"Content-Type\")\n\n\texe.Debugf(\"Response status: %s\", resp.Status)\n\texe.Debugf(\"Response content type: %s\", contentType)\n\n\tif resp.StatusCode != http.StatusOK {\n\t\texe.Errorf(\"Http status not OK: %s\", resp.Status)\n\t\tbody, _ := ioutil.ReadAll(resp.Body)\n\t\texe.Errorf(\"Remote error: %s\", string(body))\n\t\treturn nil, fmt.Errorf(`Http status %d: \"%s\"`, resp.StatusCode, string(body))\n\t}\n\n\tmediaType, mtParams, err := mime.ParseMediaType(contentType)\n\tif err != nil {\n\t\texe.Errorf(\"Parse media type error: %s\", err)\n\t\treturn nil, errors.New(\"Parse media type error\")\n\t}\n\n\tresult := make(map[string]interface{})\n\n\texe.Debugf(\"Parsed context type: %s\", mediaType)\n\tresult[\"context_type\"] = mediaType\n\n\tif mediaType == \"application/json\" {\n\t\texe.processJSONPart(result, resp.Body)\n\t} else if strings.HasPrefix(mediaType, \"multipart/\") {\n\t\texe.processMultiPart(result, resp.Body, mtParams[\"boundary\"], exeID)\n\t} else {\n\t\texe.Errorf(\"Unknown media type: %s\", mediaType)\n\t\tbody, _ := ioutil.ReadAll(resp.Body)\n\t\tresult[\"response\"] = string(body)\n\t\treturn result, errors.New(\"Unknown media type\")\n\t}\n\n\texitCodeFloat, err := util.GetFloatParam(result, \"exit_code\")\n\texitCode := int(exitCodeFloat)\n\tif exitCode != 0 {\n\t\treturn result, fmt.Errorf(\"Command failed with code %d\", exitCode)\n\t}\n\n\treturn result, nil\n}", "func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) error {\n\tserviceID, source := c.manifest.ServiceID()\n\tif c.Globals.Verbose() {\n\t\tcmd.DisplayServiceID(serviceID, source, out)\n\t}\n\tif source == manifest.SourceUndefined {\n\t\treturn errors.ErrNoServiceID\n\t}\n\tc.Input.ServiceID = serviceID\n\n\td, err := c.Globals.Client.UpdateDictionaryItem(&c.Input)\n\tif err != nil {\n\t\tc.Globals.ErrLog.Add(err)\n\t\treturn err\n\t}\n\n\ttext.Success(out, \"Updated dictionary item (service %s)\", d.ServiceID)\n\ttext.Break(out)\n\ttext.PrintDictionaryItem(out, \"\", d)\n\treturn nil\n}", "func (e *Engine) Do(ctx context.Context, query string, response interface{}) error {\n\tpayload := GQLRequest{\n\t\tQuery: query,\n\t\tVariables: map[string]interface{}{},\n\t}\n\n\tbody, err := e.Request(ctx, \"POST\", \"/\", &payload)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Request failed: %w\", err)\n\t}\n\n\t// TODO temporary hack, actually parse the response\n\tif str := string(body); strings.Contains(str, \"errors: \\\"[{\\\"error\") {\n\t\treturn fmt.Errorf(\"pql error: %s\", str)\n\t}\n\n\terr = json.Unmarshal(body, response)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"json unmarshal: %w\", err)\n\t}\n\n\treturn nil\n}", "func Handle(ctx context.Context, requestEnv *alexa.RequestEnvelope) (interface{}, error) {\n\treturn a.ProcessRequest(ctx, requestEnv)\n}", "func (client *Client) Execute(command string) {\n\tclient.SendResponse(command)\n}", "func (c *Authorize) Execute(\n\tctx context.Context,\n) error {\n\terr := cli.CheckEnvWarp(ctx)\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\n\tresult, err := cli.RunLocalCommand(ctx, warp.Command{\n\t\tType: warp.CmdTpState,\n\t\tArgs: []string{},\n\t})\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\n\tif result.Disconnected {\n\t\treturn errors.Trace(\n\t\t\terrors.Newf(\n\t\t\t\t\"The warp is currently disconnected. No client has access to \" +\n\t\t\t\t\t\"it and all previously authorized users will be revoked \" +\n\t\t\t\t\t\"upon reconnection.\",\n\t\t\t),\n\t\t)\n\t}\n\n\tusername := \"\"\n\tuser := \"\"\n\targs := []string{}\n\tmatches := 0\n\tfor _, u := range result.SessionState.Users {\n\t\tif !u.Hosting {\n\t\t\tif u.Username == c.usernameOrToken ||\n\t\t\t\tu.Token == c.usernameOrToken {\n\t\t\t\tmatches += 1\n\t\t\t\targs = append(args, u.Token)\n\t\t\t\tusername = u.Username\n\t\t\t\tuser = u.Token\n\t\t\t}\n\t\t}\n\t}\n\n\tif matches == 0 {\n\t\treturn errors.Trace(\n\t\t\terrors.Newf(\n\t\t\t\t\"Username or token not found: %s. Use `warp state` to \"+\n\t\t\t\t\t\"retrieve a list of currently connected warp clients.\",\n\t\t\t\tc.usernameOrToken,\n\t\t\t),\n\t\t)\n\t} else if matches > 1 {\n\t\treturn errors.Trace(\n\t\t\terrors.Newf(\n\t\t\t\t\"Username ambiguous, please provide a user token instead. \" +\n\t\t\t\t\t\"Warp clients user tokens can be retrieved with \" +\n\t\t\t\t\t\"`warp state`.\",\n\t\t\t),\n\t\t)\n\t}\n\n\tout.Normf(\"You are about to authorize the following user to write to \")\n\tout.Valuf(\"%s\\n\", os.Getenv(warp.EnvWarp))\n\tout.Normf(\" ID: \")\n\tout.Boldf(\"%s\", user)\n\tout.Normf(\" Username: \")\n\tout.Valuf(\"%s\\n\", username)\n\tout.Normf(\"Are you sure this is who you think this is? [Y/n]: \")\n\n\treader := bufio.NewReader(os.Stdin)\n\tconfirmation, _ := reader.ReadString('\\n')\n\tconfirmation = strings.TrimSpace(confirmation)\n\n\tif confirmation != \"\" && confirmation != \"Y\" && confirmation != \"y\" {\n\t\treturn errors.Trace(\n\t\t\terrors.Newf(\"Authorizxation aborted by user.\"),\n\t\t)\n\t}\n\tresult, err = cli.RunLocalCommand(ctx, warp.Command{\n\t\tType: warp.CmdTpAuthorize,\n\t\tArgs: args,\n\t})\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\n\tout.Normf(\"\\n\")\n\tout.Normf(\"Done! You can revoke authorizations at any time with \")\n\tout.Boldf(\"warp revoke\\n\")\n\tout.Normf(\"\\n\")\n\n\tPrintSessionState(ctx, result.Disconnected, result.SessionState)\n\n\treturn nil\n}", "func (s *Server) Execution(req *ExecutionRequest, stream Runner_ExecutionServer) error {\n\t// check authorization and get runner hash\n\trunnerHash, err := s.isAuthorized(stream.Context())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// create rpc event stream\n\tctx, cancel := context.WithCancel(stream.Context())\n\tdefer cancel()\n\tsubscriber := xstrings.RandASCIILetters(8)\n\tquery := fmt.Sprintf(\"%s.%s='%s' AND %s.%s='%s'\",\n\t\texecutionmodule.EventType, executionmodule.AttributeKeyExecutor, runnerHash.String(),\n\t\texecutionmodule.EventType, sdk.AttributeKeyAction, executionmodule.AttributeActionCreated,\n\t)\n\teventStream, err := s.rpc.Subscribe(ctx, subscriber, query, 0)\n\tdefer s.rpc.Unsubscribe(context.Background(), subscriber, query)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := acknowledgement.SetStreamReady(stream); err != nil {\n\t\treturn err\n\t}\n\n\t// listen to event stream\n\tfor {\n\t\tselect {\n\t\tcase event := <-eventStream:\n\t\t\t// get the index of the action=created attributes\n\t\t\tattrKeyActionCreated := fmt.Sprintf(\"%s.%s\", executionmodule.EventType, sdk.AttributeKeyAction)\n\t\t\tattrIndexes := make([]int, 0)\n\t\t\tfor index, attr := range event.Events[attrKeyActionCreated] {\n\t\t\t\tif attr == executionmodule.AttributeActionCreated {\n\t\t\t\t\tattrIndexes = append(attrIndexes, index)\n\t\t\t\t}\n\t\t\t}\n\t\t\t// iterate only on the index of attribute hash where action=created\n\t\t\tattrKeyHash := fmt.Sprintf(\"%s.%s\", executionmodule.EventType, executionmodule.AttributeKeyHash)\n\t\t\tfor _, index := range attrIndexes {\n\t\t\t\tattr := event.Events[attrKeyHash][index]\n\t\t\t\thash, err := hash.Decode(attr)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tvar exec *execution.Execution\n\t\t\t\troute := fmt.Sprintf(\"custom/%s/%s/%s\", executionmodule.QuerierRoute, executionmodule.QueryGet, hash)\n\t\t\t\tif err := s.rpc.QueryJSON(route, nil, &exec); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\ts.execInProgress.Store(hash.String(), time.Now().UnixNano())\n\t\t\t\tif err := stream.Send(exec); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\tcase <-ctx.Done():\n\t\t\treturn ctx.Err()\n\t\tcase <-stream.Context().Done():\n\t\t\treturn stream.Context().Err()\n\t\t}\n\t}\n}", "func (r AlternativeReq) Run() error {\n\tr.Handler.handleAlterRequest(r, util.Transport)\n\treturn nil\n}", "func (_Vault *VaultTransactor) Execute(opts *bind.TransactOpts, token common.Address, amount *big.Int, recipientToken common.Address, exchangeAddress common.Address, callData []byte, timestamp []byte, signData []byte) (*types.Transaction, error) {\n\treturn _Vault.contract.Transact(opts, \"execute\", token, amount, recipientToken, exchangeAddress, callData, timestamp, signData)\n}", "func (r *Request) Do(ctx context.Context, h Handler) (ResponseData, error) {\n\tpanic(\"TODO\")\n}", "func (client *Client) ExecuteRequest(destinationNumber string, messageContent string, messageChannel chan Message) (Message, error) {\n\t// Returns you a message Object back\n\n\tvar message Message\n\n\tmessageDataBuffer := client.NewMessage(messageContent, destinationNumber)\n\n\trequest, err := client.NewRequest(messageDataBuffer)\n\tif err != nil {\n\t\terrStr := fmt.Sprintf(\"Error concerning HTTP credentials ... here is the error %v\", err)\n\t\treturn Message{}, &errorString{errStr}\n\t}\n\n\tresponse, err := client.RequestExecutor.Do(request)\n\n\tif err != nil {\n\t\terrStr := fmt.Sprintf(\"Error executing the HTTP request ... here is the error %v\", err)\n\t\treturn Message{}, &errorString{errStr}\n\t}\n\n\tif response.StatusCode >= 300 {\n\t\terrStr := fmt.Sprintf(\"Status Code : %v\", response.StatusCode)\n\t\treturn Message{}, &errorString{errStr}\n\t}\n\n\tdecoder := json.NewDecoder(response.Body)\n\terr = decoder.Decode(&message)\n\n\tif err != nil {\n\t\terrStr := fmt.Sprintf(\"Error decoding data into Message Object ... here is the data %v\", err)\n\t\treturn Message{}, &errorString{errStr}\n\t}\n\n\tmessageChannel <- message\n\treturn message, nil\n}", "func executeRequest(method string, path string, contact c.Contact) *httptest.ResponseRecorder {\n\tresponse := httptest.NewRecorder()\n\tif (c.Contact{})==contact {\n\t\treq, _ := http.NewRequest(method, path, nil)\n\t\tserver.GetRouter().ServeHTTP(response, req)\n\t} else {\n\t\tpayload,_:= json.Marshal(contact)\n\t\treq, _ := http.NewRequest(method, path, bytes.NewBuffer(payload))\n\t\tserver.GetRouter().ServeHTTP(response, req)\n\t}\n\treturn response\n}", "func (duo *DeviceUpdateOne) Exec(ctx context.Context) error {\n\t_, err := duo.Save(ctx)\n\treturn err\n}" ]
[ "0.66719776", "0.63951325", "0.63034904", "0.6293009", "0.61960685", "0.616474", "0.61634", "0.61555916", "0.61194813", "0.6007152", "0.5956136", "0.5890451", "0.5877885", "0.5847017", "0.5831893", "0.57932687", "0.5766032", "0.57413876", "0.5740811", "0.57251626", "0.5697184", "0.5685057", "0.56316596", "0.55493265", "0.5547654", "0.5533726", "0.55168325", "0.5503621", "0.5474259", "0.5467503", "0.5435386", "0.5432086", "0.54139656", "0.5410622", "0.5396733", "0.53880864", "0.5387489", "0.53830177", "0.5376471", "0.5368887", "0.5364507", "0.53636396", "0.53587335", "0.5352045", "0.5342796", "0.5333118", "0.5326944", "0.53263056", "0.53203464", "0.5304652", "0.5292439", "0.5287765", "0.52712494", "0.52691436", "0.52633965", "0.52411854", "0.52399915", "0.52361995", "0.52271247", "0.52251065", "0.521464", "0.52130073", "0.5209739", "0.5204227", "0.5193481", "0.51859236", "0.5185602", "0.51815134", "0.5170487", "0.5168681", "0.51520854", "0.51496667", "0.5148583", "0.5147869", "0.51451963", "0.51419497", "0.51387286", "0.5135299", "0.5127693", "0.5121611", "0.51136804", "0.5110732", "0.5108875", "0.5106125", "0.51032096", "0.51029426", "0.5097182", "0.5095109", "0.50921565", "0.50919837", "0.5085247", "0.5078132", "0.5062384", "0.50608754", "0.50559205", "0.505204", "0.5049689", "0.5044881", "0.50434947", "0.5043055" ]
0.64396346
1
add DeployCmd and it's respective flags parameters: nil returns: nil
func init() { RootCmd.AddCommand(DeployCmd) DeployCmd.Flags().StringP("file", "f", "", "file used to specify the job to deploy (required)") DeployCmd.Flags().StringP("port", "p", "", "connect to a specific port (default: 3939)") DeployCmd.MarkFlagRequired("file") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func init() {\n\tRootCmd.AddCommand(DeployCmd)\n\tDeployCmd.Flags().StringP(\"file\", \"f\", \"\", \"file used to specify the job to deploy (required)\")\n\tDeployCmd.Flags().StringP(\"port\", \"p\", \"\", \"connect to a specific port (default: 3939)\")\n\tDeployCmd.MarkFlagRequired(\"file\")\n}", "func NewDeployCmd(deployment services.Deployment) cli.Command {\n\treturn cli.Command{\n\t\tName: \"deploy\",\n\t\tAliases: []string{\"d\"},\n\t\tUsage: \"Deploys new version of app, takes newest task definition and updates docker image by creating new revision\",\n\t\tFlags: []cli.Flag{\n\t\t\tcli.StringFlag{\n\t\t\t\tName: \"clusterName\",\n\t\t\t\tUsage: \"Name of ECS cluster to which new version should be deployed\",\n\t\t\t},\n\t\t\tcli.StringFlag{\n\t\t\t\tName: \"serviceName\",\n\t\t\t\tUsage: \"existing service in ECS cluster which should be updated\",\n\t\t\t},\n\t\t\tcli.StringFlag{\n\t\t\t\tName: \"image\",\n\t\t\t\tUsage: \"Image with tag which will be used to create new Task Definition\",\n\t\t\t},\n\t\t\tcli.IntFlag{\n\t\t\t\tName: \"imageIndex\",\n\t\t\t\tUsage: \"Index of image in container definitions that should be updated\",\n\t\t\t\tValue: 0,\n\t\t\t},\n\t\t\tcli.StringFlag{\n\t\t\t\tName: \"codedeployApp\",\n\t\t\t\tUsage: \"codedeploy application which is used to trigger deployment\",\n\t\t\t},\n\t\t\tcli.StringFlag{\n\t\t\t\tName: \"codedeployGroup\",\n\t\t\t\tUsage: \"codedeployGroup group which is used to trigger deployment\",\n\t\t\t},\n\t\t},\n\t\tAction: func(c *cli.Context) error {\n\t\t\tif err := validateRequiredFlags(c, requiredDeployFlags); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tclusterName := c.String(\"clusterName\")\n\t\t\tserviceName := c.String(\"serviceName\")\n\t\t\timage := c.String(\"image\")\n\t\t\timageIndex := c.Int(\"imageIndex\")\n\n\t\t\tcodedeployGroup := c.String(\"codedeployGroup\")\n\t\t\tcodedeployApp := c.String(\"codedeployApp\")\n\n\t\t\tif len(codedeployGroup) == 0 {\n\t\t\t\tcodedeployGroup = serviceName\n\t\t\t}\n\n\t\t\tif len(codedeployApp) == 0 {\n\t\t\t\tcodedeployApp = serviceName\n\t\t\t}\n\n\t\t\toutput, err := deployment.Deploy(&clusterName, &serviceName, &image, imageIndex, &codedeployApp, &codedeployGroup)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\treturn printOutput(output)\n\t\t},\n\t}\n}", "func deployCmds(app provision.App, version string) ([]string, error) {\n\tdeployCmd, err := config.GetString(\"docker:deploy-cmd\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tappRepo := repository.ReadOnlyURL(app.GetName())\n\tuser, err := config.GetString(\"docker:ssh:user\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcmds := []string{\"sudo\", \"-u\", user, deployCmd, appRepo, version}\n\treturn cmds, nil\n}", "func DeployCmd() prompter.Command {\n\treturn prompter.Command{\n\t\tName: \"deploy\",\n\t\tDescription: \"deploy borrowed time and generate a config file\",\n\t\tExecutor: deployExecutor,\n\t}\n}", "func deployExecutor(args prompter.CmdArgs) error {\n\tfmt.Println(\"inside deployExecutor\")\n\tfmt.Printf(\"args: %v\\n\", args)\n\n\treturn config.Deploy()\n\t// err := config.Deploy()\n\t// if err != nil {\n\t// \treturn err\n\t// }\n\n\t// // Read config.\n\t// cfg, err = config.Read()\n\t// if err != nil {\n\t// \treturn err\n\t// }\n\n\t// // Enable all commands.\n\t// configCmd.Hidden = false\n\t// templateCmd.Hidden = false\n\t// dataCmd.Hidden = false\n\n\t// return nil\n}", "func (c *DeployCommand) Run(args []string) int {\n\n\tvar err error\n\tvar level, format string\n\n\tconfig := &levant.DeployConfig{\n\t\tClient: &structs.ClientConfig{},\n\t\tDeploy: &structs.DeployConfig{},\n\t\tPlan: &structs.PlanConfig{},\n\t\tTemplate: &structs.TemplateConfig{},\n\t}\n\n\tflags := c.Meta.FlagSet(\"deploy\", FlagSetVars)\n\tflags.Usage = func() { c.UI.Output(c.Help()) }\n\n\tflags.StringVar(&config.Client.Addr, \"address\", \"\", \"\")\n\tflags.BoolVar(&config.Client.AllowStale, \"allow-stale\", false, \"\")\n\tflags.IntVar(&config.Deploy.Canary, \"canary-auto-promote\", 0, \"\")\n\tflags.StringVar(&config.Client.ConsulAddr, \"consul-address\", \"\", \"\")\n\tflags.BoolVar(&config.Deploy.Force, \"force\", false, \"\")\n\tflags.BoolVar(&config.Deploy.ForceBatch, \"force-batch\", false, \"\")\n\tflags.BoolVar(&config.Deploy.ForceCount, \"force-count\", false, \"\")\n\tflags.BoolVar(&config.Plan.IgnoreNoChanges, \"ignore-no-changes\", false, \"\")\n\tflags.StringVar(&level, \"log-level\", \"INFO\", \"\")\n\tflags.StringVar(&format, \"log-format\", \"HUMAN\", \"\")\n\tflags.StringVar(&config.Deploy.VaultToken, \"vault-token\", \"\", \"\")\n\tflags.BoolVar(&config.Deploy.EnvVault, \"vault\", false, \"\")\n\n\tflags.Var((*helper.FlagStringSlice)(&config.Template.VariableFiles), \"var-file\", \"\")\n\n\tif err = flags.Parse(args); err != nil {\n\t\treturn 1\n\t}\n\n\targs = flags.Args()\n\n\tif config.Deploy.EnvVault == true && config.Deploy.VaultToken != \"\" {\n\t\tc.UI.Error(c.Help())\n\t\tc.UI.Error(\"\\nERROR: Can not used -vault and -vault-token flag at the same time\")\n\t\treturn 1\n\t}\n\n\tif err = logging.SetupLogger(level, format); err != nil {\n\t\tc.UI.Error(err.Error())\n\t\treturn 1\n\t}\n\n\tif len(args) == 1 {\n\t\tconfig.Template.TemplateFile = args[0]\n\t} else if len(args) == 0 {\n\t\tif config.Template.TemplateFile = helper.GetDefaultTmplFile(); config.Template.TemplateFile == \"\" {\n\t\t\tc.UI.Error(c.Help())\n\t\t\tc.UI.Error(\"\\nERROR: Template arg missing and no default template found\")\n\t\t\treturn 1\n\t\t}\n\t} else {\n\t\tc.UI.Error(c.Help())\n\t\treturn 1\n\t}\n\n\tconfig.Template.Job, err = template.RenderJob(config.Template.TemplateFile,\n\t\tconfig.Template.VariableFiles, config.Client.ConsulAddr, &c.Meta.flagVars)\n\tif err != nil {\n\t\tc.UI.Error(fmt.Sprintf(\"[ERROR] levant/command: %v\", err))\n\t\treturn 1\n\t}\n\n\tif config.Deploy.Canary > 0 {\n\t\tif err = c.checkCanaryAutoPromote(config.Template.Job, config.Deploy.Canary); err != nil {\n\t\t\tc.UI.Error(fmt.Sprintf(\"[ERROR] levant/command: %v\", err))\n\t\t\treturn 1\n\t\t}\n\t}\n\n\tif config.Deploy.ForceBatch {\n\t\tif err = c.checkForceBatch(config.Template.Job, config.Deploy.ForceBatch); err != nil {\n\t\t\tc.UI.Error(fmt.Sprintf(\"[ERROR] levant/command: %v\", err))\n\t\t\treturn 1\n\t\t}\n\t}\n\n\tif !config.Deploy.Force {\n\t\tp := levant.PlanConfig{\n\t\t\tClient: config.Client,\n\t\t\tPlan: config.Plan,\n\t\t\tTemplate: config.Template,\n\t\t}\n\n\t\tplanSuccess, changes := levant.TriggerPlan(&p)\n\t\tif !planSuccess {\n\t\t\treturn 1\n\t\t} else if !changes && p.Plan.IgnoreNoChanges {\n\t\t\treturn 0\n\t\t}\n\t}\n\n\tsuccess := levant.TriggerDeployment(config, nil)\n\tif !success {\n\t\treturn 1\n\t}\n\n\treturn 0\n}", "func Deploy(ctx context.Context) *cobra.Command {\n\toptions := &Options{}\n\n\tcmd := &cobra.Command{\n\t\tUse: \"deploy\",\n\t\tShort: \"Execute the list of commands specified in the Okteto manifest to deploy the application\",\n\t\tArgs: utils.NoArgsAccepted(\"https://okteto.com/docs/reference/cli/#version\"),\n\t\tHidden: true,\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\t// This is needed because the deploy command needs the original kubeconfig configuration even in the execution within another\n\t\t\t// deploy command. If not, we could be proxying a proxy and we would be applying the incorrect deployed-by label\n\t\t\tos.Setenv(model.OktetoWithinDeployCommandContextEnvVar, \"false\")\n\n\t\t\tif err := contextCMD.LoadManifestV2WithContext(ctx, options.Namespace, options.ManifestPath); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif okteto.IsOkteto() {\n\t\t\t\tcreate, err := utils.ShouldCreateNamespace(ctx, okteto.Context().Namespace)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif create {\n\t\t\t\t\tnsCmd, err := namespace.NewCommand()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tnsCmd.Create(ctx, &namespace.CreateOptions{Namespace: okteto.Context().Namespace})\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcwd, err := os.Getwd()\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to get the current working directory: %w\", err)\n\t\t\t}\n\n\t\t\taddEnvVars(ctx, cwd)\n\t\t\tif options.Name == \"\" {\n\t\t\t\toptions.Name = utils.InferApplicationName(cwd)\n\t\t\t}\n\n\t\t\t// Look for a free local port to start the proxy\n\t\t\tport, err := model.GetAvailablePort(\"localhost\")\n\t\t\tif err != nil {\n\t\t\t\toktetoLog.Infof(\"could not find a free port to start proxy server: %s\", err)\n\t\t\t\treturn err\n\t\t\t}\n\t\t\toktetoLog.Debugf(\"found available port %d\", port)\n\n\t\t\t// TODO for now, using self-signed certificates\n\t\t\tcert, err := tls.X509KeyPair(cert, key)\n\t\t\tif err != nil {\n\t\t\t\toktetoLog.Infof(\"could not read certificate: %s\", err)\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t// Generate a token for the requests done to the proxy\n\t\t\tsessionToken := uuid.NewString()\n\n\t\t\tkubeconfig := newKubeConfig()\n\t\t\tclusterConfig, err := kubeconfig.Read()\n\t\t\tif err != nil {\n\t\t\t\toktetoLog.Infof(\"could not read kubeconfig file: %s\", err)\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\thandler, err := getProxyHandler(options.Name, sessionToken, clusterConfig)\n\t\t\tif err != nil {\n\t\t\t\toktetoLog.Infof(\"could not configure local proxy: %s\", err)\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\ts := &http.Server{\n\t\t\t\tAddr: fmt.Sprintf(\":%d\", port),\n\t\t\t\tHandler: handler,\n\t\t\t\tReadTimeout: 5 * time.Second,\n\t\t\t\tWriteTimeout: 10 * time.Second,\n\t\t\t\tIdleTimeout: 120 * time.Second,\n\t\t\t\tTLSConfig: &tls.Config{\n\t\t\t\t\tCertificates: []tls.Certificate{cert},\n\n\t\t\t\t\t// Recommended security configuration by DeepSource\n\t\t\t\t\tMinVersion: tls.VersionTLS12,\n\t\t\t\t\tMaxVersion: tls.VersionTLS13,\n\t\t\t\t},\n\t\t\t}\n\n\t\t\tc := &deployCommand{\n\t\t\t\tgetManifest: contextCMD.GetManifest,\n\n\t\t\t\tkubeconfig: kubeconfig,\n\t\t\t\texecutor: utils.NewExecutor(oktetoLog.GetOutputFormat()),\n\t\t\t\tproxy: newProxy(proxyConfig{\n\t\t\t\t\tport: port,\n\t\t\t\t\ttoken: sessionToken,\n\t\t\t\t}, s),\n\t\t\t\ttempKubeconfigFile: fmt.Sprintf(tempKubeConfigTemplate, config.GetUserHomeDir(), options.Name),\n\t\t\t\tk8sClientProvider: okteto.NewK8sClientProvider(),\n\t\t\t}\n\t\t\treturn c.runDeploy(ctx, cwd, options)\n\t\t},\n\t}\n\n\tcmd.Flags().StringVar(&options.Name, \"name\", \"\", \"application name\")\n\tcmd.Flags().StringVarP(&options.ManifestPath, \"file\", \"f\", \"\", \"path to the okteto manifest file\")\n\tcmd.Flags().StringVarP(&options.Namespace, \"namespace\", \"n\", \"\", \"overwrites the namespace where the application is deployed\")\n\n\tcmd.Flags().StringArrayVarP(&options.Variables, \"var\", \"v\", []string{}, \"set a variable (can be set more than once)\")\n\tcmd.Flags().BoolVarP(&options.Build, \"build\", \"\", false, \"force build of images when deploying the app\")\n\tcmd.Flags().MarkHidden(\"build\")\n\n\treturn cmd\n}", "func Deploy(ctx context.Context) *cobra.Command {\n\topts := &DeployOptions{}\n\tcmd := &cobra.Command{\n\t\tUse: \"deploy <name>\",\n\t\tShort: \"Deploy a preview environment\",\n\t\tArgs: utils.MaximumNArgsAccepted(1, \"\"),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tcwd, err := os.Getwd()\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to get the current working directory: %w\", err)\n\t\t\t}\n\n\t\t\tif err := optionsSetup(cwd, opts, args); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif err := contextCMD.NewContextCommand().Run(ctx, &contextCMD.ContextOptions{}); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\toktetoLog.Information(\"Using %s @ %s as context\", opts.name, okteto.RemoveSchema(okteto.Context().Name))\n\n\t\t\tif !okteto.IsOkteto() {\n\t\t\t\treturn oktetoErrors.ErrContextIsNotOktetoCluster\n\t\t\t}\n\n\t\t\tpreviewCmd, err := NewCommand()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn previewCmd.ExecuteDeployPreview(ctx, opts)\n\t\t},\n\t}\n\tcmd.Flags().StringVarP(&opts.branch, \"branch\", \"b\", \"\", \"the branch to deploy (defaults to the current branch)\")\n\tcmd.Flags().StringVarP(&opts.repository, \"repository\", \"r\", \"\", \"the repository to deploy (defaults to the current repository)\")\n\tcmd.Flags().StringVarP(&opts.scope, \"scope\", \"s\", \"personal\", \"the scope of preview environment to create. Accepted values are ['personal', 'global']\")\n\tcmd.Flags().StringVarP(&opts.sourceUrl, \"sourceUrl\", \"\", \"\", \"the URL of the original pull/merge request.\")\n\tcmd.Flags().DurationVarP(&opts.timeout, \"timeout\", \"t\", (5 * time.Minute), \"the length of time to wait for completion, zero means never. Any other values should contain a corresponding time unit e.g. 1s, 2m, 3h \")\n\tcmd.Flags().StringArrayVarP(&opts.variables, \"var\", \"v\", []string{}, \"set a preview environment variable (can be set more than once)\")\n\tcmd.Flags().BoolVarP(&opts.wait, \"wait\", \"w\", false, \"wait until the preview environment deployment finishes (defaults to false)\")\n\tcmd.Flags().StringVarP(&opts.file, \"file\", \"f\", \"\", \"relative path within the repository to the okteto manifest (default to okteto.yaml or .okteto/okteto.yaml)\")\n\tcmd.Flags().StringArrayVarP(&opts.labels, \"label\", \"\", []string{}, \"set a preview environment label (can be set more than once)\")\n\n\tcmd.Flags().StringVarP(&opts.deprecatedFilename, \"filename\", \"\", \"\", \"relative path within the repository to the manifest file (default to okteto-pipeline.yaml or .okteto/okteto-pipeline.yaml)\")\n\tif err := cmd.Flags().MarkHidden(\"filename\"); err != nil {\n\t\toktetoLog.Infof(\"failed to hide deprecated flag: %s\", err)\n\t}\n\treturn cmd\n}", "func (sd *SousNewDeploy) AddFlags(fs *flag.FlagSet) {\n\tMustAddFlags(fs, &sd.DeployFilterFlags, NewDeployFilterFlagsHelp)\n\n\tfs.BoolVar(&sd.force, \"force\", false,\n\t\t\"force deploy no matter if GDM already is at the correct version\")\n\tfs.BoolVar(&sd.waitStable, \"wait-stable\", true,\n\t\t\"wait for the deploy to complete before returning (otherwise, use --wait-stable=false)\")\n\tfs.StringVar(&sd.dryrunOption, \"dry-run\", \"none\",\n\t\t\"prevent rectify from actually changing things - \"+\n\t\t\t\"values are none,scheduler,registry,both\")\n}", "func getApp() (app *cli.App) {\n\t// global app variables (name, version, etc)\n\tapp = cli.NewApp()\n\tapp.Name = \"mi-deploy\"\n\tapp.Usage = \"Deploy MI to various public clouds\"\n\tapp.Version = \"0.0.1-dev\"\n\tapp.Author = \"Langston Barrett\"\n\tapp.Email = \"[email protected]\"\n\tlvls := []string{\"debug\", \"info\", \"warn\", \"fatal\", \"panic\"}\n\tlvlsStr := strings.Join(lvls, \" | \")\n\tplatforms := []string{\"aws\", \"digitalocean\", \"gce\", \"openstack\", \"softlayer\", \"vagrant\"}\n\tplatformsStr := strings.Join(platforms, \" | \")\n\n\t// these are command line subcommands like $(git status). They have their\n\t// own flags, but more importantly, actions that are executed when the\n\t// subcommand is used.\n\tapp.Commands = []cli.Command{\n\t\t{\n\t\t\tName: \"deploy\",\n\t\t\tUsage: \"deploy a branch to a platform\",\n\t\t\tFlags: []cli.Flag{\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName: \"platform, p\",\n\t\t\t\t\tValue: \"\",\n\t\t\t\t\tUsage: \"Deploy to this platform. One of:\\n\\t\" + platformsStr,\n\t\t\t\t},\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName: \"branch, b\",\n\t\t\t\t\tValue: \"master\",\n\t\t\t\t\tUsage: \"Deploy this branch (optional, default is master)\",\n\t\t\t\t},\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName: \"url, u\",\n\t\t\t\t\tValue: repoURL,\n\t\t\t\t\tUsage: \"Clone from this remote URL (optional)\",\n\t\t\t\t},\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName: \"verbosity\",\n\t\t\t\t\tValue: \"info\",\n\t\t\t\t\tUsage: lvlsStr,\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t// the logic of deploying a branch\n\t\t\tAction: func(c *cli.Context) {\n\t\t\t\tlog.Debug(\"Running subcommand deploy\")\n\t\t\t\t// set verbosity\n\t\t\t\tsetVerbosity(c.String(\"verbosity\"))\n\t\t\t\trepoURL = c.String(\"url\")\n\t\t\t\tplatform := c.String(\"platform\")\n\t\t\t\tbranch := c.String(\"branch\")\n\t\t\t\t// set global variables\n\t\t\t\tsuffix := RemovePathChars(branch)\n\t\t\t\tsuffix += \"-\" + platform + \"-\" + timestamp + \"/\"\n\t\t\t\tdeploymentDir = path.Join(wd, \"deployments/\", suffix)\n\t\t\t\trepoDir = path.Join(deploymentDir, sh.Basename(repoURL))\n\n\t\t\t\t// deploy\n\t\t\t\tplatforms := []string{\n\t\t\t\t\t\"aws\", \"digitalocean\", \"gce\", \"openstack\", \"softlayer\", \"vagrant\",\n\t\t\t\t}\n\t\t\t\tif platform == \"vagrant\" {\n\t\t\t\t\tdeployToVagrant(branch)\n\t\t\t\t} else if StrIn(platform, platforms) {\n\t\t\t\t\tdeployToCloud(platform, branch)\n\t\t\t\t} else {\n\t\t\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\t\t\"specified\": platform,\n\t\t\t\t\t}).Fatal(\"Invalid platform option passed\")\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"destroy\",\n\t\t\tUsage: \"destroy the resources and files from a deployment\",\n\t\t\tFlags: []cli.Flag{\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName: \"filter, f\",\n\t\t\t\t\tValue: \"\",\n\t\t\t\t\tUsage: \"Only list deployments that match this regex\",\n\t\t\t\t},\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName: \"verbosity\",\n\t\t\t\t\tValue: \"info\",\n\t\t\t\t\tUsage: lvlsStr,\n\t\t\t\t},\n\t\t\t},\n\t\t\tAction: func(c *cli.Context) {\n\t\t\t\tlog.Debug(\"Running subcommand destroy\")\n\t\t\t\t// set verbosity\n\t\t\t\tsetVerbosity(c.String(\"verbosity\"))\n\n\t\t\t\tpromptDestroy(c.String(\"filter\"))\n\t\t\t},\n\t\t},\n\t}\n\treturn app\n}", "func deploymentCommand(_ *cobra.Command, _ []string) error {\n\tnodePort := varIntNodePort\n\thome := varStringHome\n\tremote := varStringRemote\n\tbranch := varStringBranch\n\tif len(remote) > 0 {\n\t\trepo, _ := util.CloneIntoGitHome(remote, branch)\n\t\tif len(repo) > 0 {\n\t\t\thome = repo\n\t\t}\n\t}\n\n\tif len(home) > 0 {\n\t\tpathx.RegisterGoctlHome(home)\n\t}\n\n\t// 0 to disable the nodePort type\n\tif nodePort != 0 && (nodePort < basePort || nodePort > portLimit) {\n\t\treturn errors.New(\"nodePort should be between 30000 and 32767\")\n\t}\n\n\ttext, err := pathx.LoadTemplate(category, deployTemplateFile, deploymentTemplate)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tout, err := pathx.CreateIfNotExist(varStringO)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer out.Close()\n\n\tif varIntTargetPort == 0 {\n\t\tvarIntTargetPort = varIntPort\n\t}\n\n\tt := template.Must(template.New(\"deploymentTemplate\").Parse(text))\n\terr = t.Execute(out, Deployment{\n\t\tName: varStringName,\n\t\tNamespace: varStringNamespace,\n\t\tImage: varStringImage,\n\t\tSecret: varStringSecret,\n\t\tReplicas: varIntReplicas,\n\t\tRevisions: varIntRevisions,\n\t\tPort: varIntPort,\n\t\tTargetPort: varIntTargetPort,\n\t\tNodePort: nodePort,\n\t\tUseNodePort: nodePort > 0,\n\t\tRequestCpu: varIntRequestCpu,\n\t\tRequestMem: varIntRequestMem,\n\t\tLimitCpu: varIntLimitCpu,\n\t\tLimitMem: varIntLimitMem,\n\t\tMinReplicas: varIntMinReplicas,\n\t\tMaxReplicas: varIntMaxReplicas,\n\t\tServiceAccount: varStringServiceAccount,\n\t\tImagePullPolicy: varStringImagePullPolicy,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Println(color.Green.Render(\"Done.\"))\n\treturn nil\n}", "func (p *PublisherMunger) AddFlags(cmd *cobra.Command, config *github.Config) {}", "func (d *DeployManager) Deploy() (operationResult controllerutil.OperationResult, err error) {\n\n\tvar volumes []corev1.Volume\n\tvar volumeMounts []corev1.VolumeMount\n\tvar imagePullSecrets []corev1.LocalObjectReference\n\tvar depStrategy appsv1.DeploymentStrategy\n\tconfigParameter := \"\"\n\tappParameter := \"\"\n\tappsMap := make(map[string]string)\n\n\td.CreateLabels()\n\tcontainerPorts := d.Application.ContainerPorts\n\tif d.Image.Secret != \"\" {\n\t\tsecret := createLocalObjectReference(d.Image.Secret)\n\t\timagePullSecrets = append(imagePullSecrets, secret)\n\t}\n\n\tq := corev1.PersistentVolumeClaimSpec{}\n\tif d.Application.PersistenceEnabled {\n\t\tif !siddhiv1alpha2.EqualsPVCSpec(&d.SiddhiProcess.Spec.PVC, &q) {\n\t\t\tpvcName := d.Application.Name + PVCExtension\n\t\t\terr = d.KubeClient.CreateOrUpdatePVC(\n\t\t\t\tpvcName,\n\t\t\t\td.SiddhiProcess.Namespace,\n\t\t\t\td.SiddhiProcess.Spec.PVC,\n\t\t\t\td.SiddhiProcess,\n\t\t\t)\n\t\t\tif err != nil {\n\t\t\t\treturn operationResult, err\n\t\t\t}\n\t\t\tmountPath, err := populateMountPath(d.SiddhiProcess, d.Image.Home, d.Image.Profile)\n\t\t\tif err != nil {\n\t\t\t\treturn operationResult, err\n\t\t\t}\n\t\t\tvolume, volumeMount := createPVCVolumes(pvcName, mountPath)\n\t\t\tvolumes = append(volumes, volume)\n\t\t\tvolumeMounts = append(volumeMounts, volumeMount)\n\t\t}\n\t\tdeployYAMLCMName := d.Application.Name + DepCMExtension\n\t\tsiddhiConfig := StatePersistenceConf\n\t\tif d.SiddhiProcess.Spec.SiddhiConfig != \"\" {\n\t\t\tsiddhiConfig = d.SiddhiProcess.Spec.SiddhiConfig\n\t\t}\n\t\tdata := map[string]string{\n\t\t\tdeployYAMLCMName: siddhiConfig,\n\t\t}\n\t\terr = d.KubeClient.CreateOrUpdateCM(deployYAMLCMName, d.SiddhiProcess.Namespace, data, d.SiddhiProcess)\n\t\tif err != nil {\n\t\t\treturn operationResult, err\n\t\t}\n\t\tmountPath := d.Image.Home + DepConfMountPath\n\t\tvolume, volumeMount := createCMVolumes(deployYAMLCMName, mountPath)\n\t\tvolumes = append(volumes, volume)\n\t\tvolumeMounts = append(volumeMounts, volumeMount)\n\t\tconfigParameter = DepConfParameter + mountPath + deployYAMLCMName\n\t} else if d.SiddhiProcess.Spec.SiddhiConfig != \"\" {\n\t\tdeployYAMLCMName := d.SiddhiProcess.Name + DepCMExtension\n\t\tdata := map[string]string{\n\t\t\tdeployYAMLCMName: d.SiddhiProcess.Spec.SiddhiConfig,\n\t\t}\n\t\terr = d.KubeClient.CreateOrUpdateCM(deployYAMLCMName, d.SiddhiProcess.Namespace, data, d.SiddhiProcess)\n\t\tif err != nil {\n\t\t\treturn operationResult, err\n\t\t}\n\t\tmountPath := d.Image.Home + DepConfMountPath\n\t\tvolume, volumeMount := createCMVolumes(deployYAMLCMName, mountPath)\n\t\tvolumes = append(volumes, volume)\n\t\tvolumeMounts = append(volumeMounts, volumeMount)\n\t\tconfigParameter = DepConfParameter + mountPath + deployYAMLCMName\n\t}\n\n\tmaxUnavailable := intstr.IntOrString{\n\t\tType: artifact.Int,\n\t\tIntVal: MaxUnavailable,\n\t}\n\tmaxSurge := intstr.IntOrString{\n\t\tType: artifact.Int,\n\t\tIntVal: MaxSurge,\n\t}\n\trollingUpdate := appsv1.RollingUpdateDeployment{\n\t\tMaxUnavailable: &maxUnavailable,\n\t\tMaxSurge: &maxSurge,\n\t}\n\tdepStrategy = appsv1.DeploymentStrategy{\n\t\tType: appsv1.RollingUpdateDeploymentStrategyType,\n\t\tRollingUpdate: &rollingUpdate,\n\t}\n\n\tif len(d.Application.Apps) > 0 {\n\t\tappsCMName := d.Application.Name + strconv.Itoa(int(d.SiddhiProcess.Status.CurrentVersion))\n\t\tfor k, v := range d.Application.Apps {\n\t\t\tkey := k + SiddhiExtension\n\t\t\tappsMap[key] = v\n\t\t}\n\t\terr = d.KubeClient.CreateOrUpdateCM(appsCMName, d.SiddhiProcess.Namespace, appsMap, d.SiddhiProcess)\n\t\tif err != nil {\n\t\t\treturn operationResult, err\n\t\t}\n\t\tappsPath := d.Image.Home + SiddhiFilesDir\n\t\tvolume, volumeMount := createCMVolumes(appsCMName, appsPath)\n\t\tvolumes = append(volumes, volume)\n\t\tvolumeMounts = append(volumeMounts, volumeMount)\n\t\tappParameter = AppConfParameter + appsPath + \" \"\n\t} else {\n\t\tappParameter = ParserParameter\n\t}\n\n\tuserID := int64(802)\n\toperationResult, _ = d.KubeClient.CreateOrUpdateDeployment(\n\t\td.Application.Name,\n\t\td.SiddhiProcess.Namespace,\n\t\td.Application.Replicas,\n\t\td.Labels,\n\t\td.Image.Name,\n\t\tContainerName,\n\t\t[]string{Shell},\n\t\t[]string{\n\t\t\tfilepath.Join(d.Image.Home, SiddhiBin, (d.Image.Profile + \".sh\")),\n\t\t\tappParameter,\n\t\t\tconfigParameter,\n\t\t},\n\t\tcontainerPorts,\n\t\tvolumeMounts,\n\t\td.SiddhiProcess.Spec.Container.Env,\n\t\tcorev1.SecurityContext{RunAsUser: &userID},\n\t\tcorev1.PullAlways,\n\t\timagePullSecrets,\n\t\tvolumes,\n\t\tdepStrategy,\n\t\td.SiddhiProcess,\n\t)\n\treturn operationResult, err\n}", "func AddDeploymentFlag(cmd *cobra.Command) *string {\n\tv := \"\"\n\tcmd.Flags().StringVar(&v, \"deployment\", DefaultIngressDeploymentName, \"The name of the ingress-nginx deployment\")\n\treturn &v\n}", "func (v *VersionCommand) addFlags() {\n\t// TODO: add flags here\n}", "func Deploy(cmd *cobra.Command, args []string) {\n\tappPath := \"\"\n\n\t// This helps break up many of the functions/steps for deployment\n\tdeployer := deploy.NewDeployer(&cfg, getAWSSession())\n\n\t// It is possible to pass a specific zip file from the config instead of building a new one (why would one? who knows, but I liked the pattern of using cfg)\n\tif cfg.Lambda.SourceZip == \"\" {\n\t\t// Build the Go app in the current directory (for AWS architecture).\n\t\tappPath, err := build(&cfg.App.BuildEnvVars)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"There was a problem building the Go app for the Lambda function.\")\n\t\t\tfmt.Println(err.Error())\n\t\t\tos.Exit(-1)\n\t\t}\n\t\t// Ensure it's executable.\n\t\t// err = os.Chmod(appPath, os.FileMode(int(0777)))\n\t\terr = os.Chmod(appPath, os.ModePerm)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"Warning, executable permissions could not be set on Go binary. It may fail to run in AWS.\")\n\t\t\tfmt.Println(err.Error())\n\t\t}\n\n\t\t// Adjust timestamp?\n\t\t// err = os.Chtimes(appPath, time.Now(), time.Now())\n\t\t// if err != nil {\n\t\t// \tfmt.Println(\"Warning, executable permissions could not be set on Go binary. It may fail to run in AWS.\")\n\t\t// \tfmt.Println(err.Error())\n\t\t// }\n\n\t\tcfg.Lambda.SourceZip = compress(cfg.App.BuildFileName)\n\t\t// If something went wrong, exit\n\t\tif cfg.Lambda.SourceZip == \"\" {\n\t\t\tfmt.Println(\"There was a problem building the Lambda function zip file.\")\n\t\t\tos.Exit(-1)\n\t\t}\n\t}\n\n\t// Get the Lambda function zip file's bytes\n\tvar zipBytes []byte\n\tzipBytes, err := ioutil.ReadFile(cfg.Lambda.SourceZip)\n\tif err != nil {\n\t\tfmt.Println(\"Could not read from Lambda function zip file.\")\n\t\tfmt.Println(err)\n\t\tos.Exit(-1)\n\t}\n\n\t// If no role, create an aegis role for executing Lambda functions.\n\t// This will actually be rather permissive. Use a custom role to be more restrictive.\n\t// The aegis framework needs the ability to invoke other Lambdas, work with XRay, S3, and more.\n\t// So it's going to be a few managed policies that make sense. Use a custom role if needed.\n\t// When roles are passed to use, they are not modified.\n\tif cfg.Lambda.Role == \"\" {\n\t\tcfg.Lambda.Role = createOrUpdateAegisRole()\n\n\t\t// Have to delay a few seconds to give AWS some time to set up the role.\n\t\t// Assigning it to the Lambda too soon could result in an error:\n\t\t// InvalidParameterValueException: The role defined for the function cannot be assumed by Lambda.\n\t\t// Apparently it needs a few seconds ¯\\_(ツ)_/¯\n\t\ttime.Sleep(5 * time.Second)\n\t}\n\n\t// Create (or update) the function\n\tlambdaArn := deployer.CreateFunction(zipBytes)\n\n\t// Create the API Gateway API with proxy resource.\n\t// This only needs to be done once as it shouldn't change and additional resources can't be configured.\n\t// So it will check first for the same name before creating. If a match is found, that API ID will be returned.\n\t//\n\t// TODO: Maybe prompt the user to overwrite? Because if the name matches, it will go on to deploy stages on\n\t// that API...Which may be bad. I wish API names had to be unique. That would be a lot better.\n\t// Think on what to do here because it could create a bad experience...It's also nice to have one \"deploy\" command\n\t// that also deploys stages and picks up new stages as the config changes. Could always break out deploy stage\n\t// into a separate command...Again, all comes down to experience and expectations. Warnings might be enough...\n\t// But a prompt on each \"deploy\" command after the first? Maybe too annoying. Could pass an \"--ignore\" flag or force\n\t// to solve those annoyances though.\n\tapiID := deployer.ImportAPI(*lambdaArn)\n\t// TODO: Allow updates...this isn't quite working yet\n\t// The DeployAPI() function will take care of some updates as well (things like stage variables, etc.).\n\t// deployer.UpdateAPI(apiID, *lambdaArn)\n\n\t// fmt.Printf(\"API ID: %s\\n\", apiID)\n\n\t// Ensure the API can access the Lambda\n\tdeployer.AddAPIPermission(apiID, *lambdaArn)\n\n\t// Ensure the API has it's binary media types set (Swagger import apparently does not set them)\n\tdeployer.AddBinaryMediaTypes(apiID)\n\n\t// Deploy for each stage (defaults to just one \"prod\" stage).\n\t// However, this can be changed over time (cache settings, stage variables, etc.) and is relatively harmless to re-deploy\n\t// on each run anyway. Plus, new stages can be added at any time.\n\tfor key := range cfg.API.Stages {\n\t\tinvokeURL := deployer.DeployAPI(apiID, cfg.API.Stages[key])\n\t\t// fmt.Printf(\"%s API Invoke URL: %s\\n\", key, invokeURL)\n\t\tfmt.Printf(\"%v %v %v\\n\", color.GreenString(key), \"API URL:\", color.GreenString(invokeURL))\n\t}\n\n\t// Tasks (CloudWatch event rules to trigger Lambda)\n\tfmt.Printf(\"\\n\")\n\tdeployer.AddTasks()\n\n\t// Bucket notifications (to trigger Lambda)\n\tfmt.Printf(\"\\n\")\n\tdeployer.AddS3BucketNotifications()\n\n\t// SES Recipient Rules (to trigger Lambda)\n\tif cfg.SESRules != nil && len(cfg.SESRules) > 0 {\n\t\tfmt.Printf(\"\\n\")\n\t\tdeployer.AddSESPermission(lambdaArn)\n\t\tdeployer.AddSESRules()\n\t}\n\n\t// Clean up\n\tif !cfg.App.KeepBuildFiles {\n\t\tos.Remove(cfg.Lambda.SourceZip)\n\t\t// Remember the Go app may not be built if the source zip file was passed via configuration/CLI flag.\n\t\t// However, if it is build then it's for AWS architecture and likely isn't needed by the user. Clean it up.\n\t\t// Note: It should be called `aegis_app` to help avoid conflicts.\n\t\tif _, err := os.Stat(appPath); err == nil {\n\t\t\tos.Remove(appPath)\n\t\t}\n\t}\n\n}", "func (c *Context) CreateDeploy(job *work.Job) error {\n // Extract args from job.\n deployUid := job.ArgString(\"deployUid\")\n deployName := job.ArgString(\"name\")\n apiClusterID := uint(job.ArgInt64(\"apiClusterID\"))\n modelVersionID := uint(job.ArgInt64(\"modelVersionID\"))\n sha := job.ArgString(\"sha\")\n envs := job.ArgString(\"envs\")\n logKey := job.ArgString(\"logKey\")\n\n if err := job.ArgError(); err != nil {\n if logKey != \"\" {\n return logBuildableErr(err, logKey, \"Arg error occurred inside create deploy job.\")\n }\n\n app.Log.Errorln(err.Error())\n return err\n }\n\n // Find ApiCluster by ID.\n apiCluster, err := apiclustersvc.FromID(apiClusterID)\n if err != nil {\n return logBuildableErr(err, logKey, \"API cluster not found.\")\n }\n\n // Find ModelVersion by ID.\n modelVersion, err := modelversionsvc.FromID(modelVersionID)\n if err != nil {\n return logBuildableErr(err, logKey, \"Model version not found.\")\n }\n\n // Store ref to project.\n project := &modelVersion.Model.Project\n\n // If sha provided, find Commit by that value. Otherwise, fetch latest commit from repo.\n commit, err := commitsvc.FromShaOrLatest(sha, project)\n if err != nil {\n return logBuildableErr(err, logKey, \"Error finding commit sha to deploy.\")\n }\n\n // Upsert Deploy.\n deploy, isNew, err := deploysvc.Upsert(\n commit.ID,\n modelVersion.ID,\n apiCluster.ID,\n deployUid,\n deployName,\n )\n\n if err != nil {\n return logBuildableErr(err, logKey, \"Failed to upsert deploy.\")\n }\n\n // If Deploy already exists, return an \"Everything up-to-date.\" message.\n if !isNew {\n // TODO: stream back a success message with \"Everything up-to-date.\"\n return nil\n }\n\n // Convert stringified envs into map[string]string representation.\n envsMap, err := envvarsvc.MapFromBytes([]byte(envs))\n if err != nil {\n return failDeploy(deploy.ID, err, logKey, \"Failed to parse deploy environment variables.\")\n }\n\n // Create EnvVars for this Deploy.\n if err := envvarsvc.CreateFromMap(deploy.ID, envsMap); err != nil {\n return failDeploy(deploy.ID, err, logKey, \"Failed to create deploy environment variables.\")\n }\n\n // Define args for the BuildDeploy job.\n jobArgs := work.Q{\n \"resourceID\": deploy.ID,\n \"buildTargetSha\": commit.Sha,\n \"projectID\": project.ID,\n \"targetCluster\": cluster.Api,\n \"logKey\": logKey,\n \"followOnJob\": Names.ApiDeploy,\n \"followOnArgs\": enc.JSON{\n \"deployID\": deploy.ID,\n \"logKey\": logKey,\n },\n }\n\n // Enqueue new job to build this Project for the ApiCluster.\n if _, err := app.JobQueue.Enqueue(Names.BuildDeploy, jobArgs); err != nil {\n return failDeploy(deploy.ID, err, logKey, \"Failed to schedule build deploy job.\")\n }\n\n // Update deploy stage to BuildScheduled.\n if err := deploysvc.UpdateStage(deploy, model.BuildStages.BuildScheduled); err != nil {\n return failDeploy(deploy.ID, err, logKey, \"Failed to update stage of deploy.\")\n }\n\n return nil\n}", "func Deploy(ctx context.Context, k8sRepo config.KubernetesConfigsRepo, texts []string, message, caller string) (messages []string, err error) {\n\tif !DeployWorker.isRunning {\n\t\treturn nil, errors.New(\"deploy worker is not running\")\n\t}\n\n\tif len(texts) < 1 {\n\t\treturn nil, errors.New(\"call help\")\n\t}\n\n\t// Compare and retrieve the repo before we engage the deployment, so we can pass the repo to deploy worker for clearer intention\n\tcodebases := k8sRepo.Configs\n\trepoNameInCMD, texts := pop(texts, 0)\n\tvar codebase *config.Codebase\n\tfor _, c := range codebases {\n\t\tif repoNameInCMD == c.Repo {\n\t\t\tcodebase = &c\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif codebase == nil {\n\t\treturn nil, errors.New(\"invalid repo name\")\n\t}\n\n\t// deploy requires env only and it only supports image-tag only\n\n\ttexts, stage, err := popValue(texts, \"env\", \"=\")\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"getting env for deployment encountered an error\")\n\t} else if stage == \"prod\" {\n\t\treturn nil, errors.New(\"deploy command doesn't support prod env\")\n\t}\n\n\ttexts, image, err := popValue(texts, \"image-tag\", \"=\")\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"getting image-tag for deployment encountered an error\")\n\t}\n\n\tif len(texts) != 0 {\n\t\treturn nil, errors.New(\"Major Tom does not support: \" + strings.Join(texts, \", \"))\n\t}\n\n\ttimeout := 5 * time.Minute\n\tch := make(chan response)\n\tnewCtx := context.WithValue(ctx, mjcontext.ResponseChannel, ch)\n\tnewCtx, cancelFn := context.WithTimeout(newCtx, timeout)\n\tdefer cancelFn()\n\tdeployChannel <- Deployment{\n\t\tctx: newCtx,\n\t\tcodebase: codebase,\n\t\tstage: stage,\n\t\timageTag: image,\n\t\tcaller: caller,\n\t\tmessage: message,\n\t}\n\n\tselect {\n\tcase commandResponse := <-ch:\n\t\treturn commandResponse.Messages, commandResponse.Error\n\tcase <-newCtx.Done():\n\t\treturn nil, errors.Errorf(\"\\\"%s\\\" command has timeouted(%f)\", strings.Join(texts, \" \"), timeout.Minutes())\n\t}\n}", "func (c *DeployCommand) Run(args []string) int {\n\n\tvar variables, addr, log string\n\tvar err error\n\tvar job *nomad.Job\n\tvar canary int\n\tvar forceCount bool\n\n\tflags := c.Meta.FlagSet(\"deploy\", FlagSetVars)\n\tflags.Usage = func() { c.UI.Output(c.Help()) }\n\n\tflags.StringVar(&addr, \"address\", \"\", \"\")\n\tflags.IntVar(&canary, \"canary-auto-promote\", 0, \"\")\n\tflags.StringVar(&log, \"log-level\", \"INFO\", \"\")\n\tflags.StringVar(&variables, \"var-file\", \"\", \"\")\n\tflags.BoolVar(&forceCount, \"force-count\", false, \"\")\n\n\tif err = flags.Parse(args); err != nil {\n\t\treturn 1\n\t}\n\n\targs = flags.Args()\n\n\tif len(args) != 1 {\n\t\tc.UI.Error(c.Help())\n\t\treturn 1\n\t}\n\n\tlogging.SetLevel(log)\n\n\tjob, err = levant.RenderJob(args[0], variables, &c.Meta.flagVars)\n\tif err != nil {\n\t\tc.UI.Error(fmt.Sprintf(\"[ERROR] levant/command: %v\", err))\n\t\treturn 1\n\t}\n\n\tif canary > 0 {\n\t\tif err = c.checkCanaryAutoPromote(job, canary); err != nil {\n\t\t\tc.UI.Error(fmt.Sprintf(\"[ERROR] levant/command: %v\", err))\n\t\t\treturn 1\n\t\t}\n\n\t\tc.UI.Info(fmt.Sprintf(\"[INFO] levant/command: running canary-auto-update of %vs\", canary))\n\t}\n\n\tclient, err := levant.NewNomadClient(addr)\n\tif err != nil {\n\t\tc.UI.Error(fmt.Sprintf(\"[ERROR] levant/command: %v\", err))\n\t\treturn 1\n\t}\n\n\tsuccess := client.Deploy(job, canary, forceCount)\n\tif !success {\n\t\tc.UI.Error(fmt.Sprintf(\"[ERROR] levant/command: deployment of job %s failed\", *job.Name))\n\t\treturn 1\n\t}\n\n\tc.UI.Info(fmt.Sprintf(\"[INFO] levant/command: deployment of job %s successful\", *job.Name))\n\n\treturn 0\n}", "func Command(app *kingpin.Application) {\n\tcmd := new(command)\n\n\tcommand := app.Command(\"deploy\", \"Triggers a deployment\").Action(cmd.run)\n\tcommand.Flag(\"key\", \"Key used to authenticate to the Acquia API\").Envar(\"ACQUIA_KEY\").StringVar(&cmd.Key)\n\tcommand.Flag(\"secret\", \"Secret used to authenticate to the Acquia API\").Envar(\"ACQUIA_SECRET\").StringVar(&cmd.Secret)\n\tcommand.Arg(\"environment\", \"UUID of the environment which we will be triggering a deployment\").Required().StringVar(&cmd.Environment)\n\tcommand.Arg(\"branch\", \"Branch to deploy\").Required().StringVar(&cmd.Branch)\n}", "func genWebServerDeploy(c *cluster.Cluster) *cluster.Deploy {\n d := c.NewDeploy(\"web server\")\n d.AddCommand(\"apt-get update\")\n d.AddCommand(\"apt-get install -y apache2\")\n return d\n\n}", "func GetDeploymentsCommand() cli.Command {\n\tcommand := cli.Command{\n\t\tName: \"deployment\",\n\t\tUsage: \"options for deployment\",\n\t\tSubcommands: []cli.Command{\n\t\t\t{\n\t\t\t\tName: \"list\",\n\t\t\t\tUsage: \"Lists all the deployments\",\n\t\t\t\tArgsUsage: \" \",\n\t\t\t\tDescription: \"[Deprecated] List the current deployment.\",\n\t\t\t\tAction: func(c *cli.Context) {\n\t\t\t\t\terr := listDeployments(c, os.Stdout)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Fatal(\"Error: \", err)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"show\",\n\t\t\t\tUsage: \"Show deployment info\",\n\t\t\t\tArgsUsage: \" \",\n\t\t\t\tDescription: \"Show detailed information about the current deployment.\\n\" +\n\t\t\t\t\t\" Requires system administrator access,\",\n\t\t\t\tAction: func(c *cli.Context) {\n\t\t\t\t\terr := showDeployment(c, os.Stdout)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Fatal(\"Error: \", err)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"list-hosts\",\n\t\t\t\tUsage: \"Lists all ESXi hosts\",\n\t\t\t\tArgsUsage: \" \",\n\t\t\t\tDescription: \"List information about all ESXi hosts used in the deployment.\\n\" +\n\t\t\t\t\t\" For each host, the ID, the current state, the IP, and the type (MGMT and/or CLOUD)\\n\" +\n\t\t\t\t\t\" Requires system administrator access.\",\n\t\t\t\tAction: func(c *cli.Context) {\n\t\t\t\t\terr := listDeploymentHosts(c, os.Stdout)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Fatal(\"Error: \", err)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"list-vms\",\n\t\t\t\tUsage: \"Lists all VMs\",\n\t\t\t\tArgsUsage: \" \",\n\t\t\t\tDescription: \"List all VMs associated with all tenants and projects.\\n\" +\n\t\t\t\t\t\" Requires system administrator access.\",\n\t\t\t\tAction: func(c *cli.Context) {\n\t\t\t\t\terr := listDeploymentVms(c, os.Stdout)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Fatal(\"Error: \", err)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"enable-cluster-type\",\n\t\t\t\tUsage: \"Enable cluster type for deployment\",\n\t\t\t\tArgsUsage: \" \",\n\t\t\t\tDescription: \"Enable a cluster type (e.g. Kubernetes) and specify the image to be used\\n\" +\n\t\t\t\t\t\" when creating the cluster.\\n\" +\n\t\t\t\t\t\" Requires system administrator access.\",\n\t\t\t\tFlags: []cli.Flag{\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName: \"type, k\",\n\t\t\t\t\t\tUsage: \"Cluster type (accepted values are KUBERNETES, MESOS, or SWARM)\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName: \"image-id, i\",\n\t\t\t\t\t\tUsage: \"ID of the cluster image\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tAction: func(c *cli.Context) {\n\t\t\t\t\terr := enableClusterType(c)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Fatal(\"Error: \", err)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"disable-cluster-type\",\n\t\t\t\tUsage: \"Disable cluster type for deployment\",\n\t\t\t\tArgsUsage: \" \",\n\t\t\t\tDescription: \"Disable a cluster type (e.g. Kubernetes). Users will no longer be able\\n\" +\n\t\t\t\t\t\" to deploy clusters of that type, but existing clusters will be unaffected.\\n\" +\n\t\t\t\t\t\" Requires system administrator access.\",\n\t\t\t\tFlags: []cli.Flag{\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName: \"type, k\",\n\t\t\t\t\t\tUsage: \"Cluster type (accepted values are KUBERNETES, MESOS, or SWARM)\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tAction: func(c *cli.Context) {\n\t\t\t\t\terr := disableClusterType(c)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Fatal(\"Error: \", err)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"update-image-datastores\",\n\t\t\t\tUsage: \"Updates the list of image datastores\",\n\t\t\t\tArgsUsage: \" \",\n\t\t\t\tDescription: \"Update the list of allowed image datastores.\\n\" +\n\t\t\t\t\t\" Requires system administrator access.\",\n\t\t\t\tFlags: []cli.Flag{\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName: \"datastores, d\",\n\t\t\t\t\t\tUsage: \"Comma separated name of datastore names\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tAction: func(c *cli.Context) {\n\t\t\t\t\terr := updateImageDatastores(c)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Fatal(\"Error: \", err)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"sync-hosts-config\",\n\t\t\t\tUsage: \"Synchronizes hosts configurations\",\n\t\t\t\tArgsUsage: \" \",\n\t\t\t\tAction: func(c *cli.Context) {\n\t\t\t\t\terr := syncHostsConfig(c)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Fatal(\"Error: \", err)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"pause\",\n\t\t\t\tUsage: \"Pause system under the deployment\",\n\t\t\t\tArgsUsage: \" \",\n\t\t\t\tDescription: \"Pause Photon Controller. All incoming requests that modify the system\\n\" +\n\t\t\t\t\t\" state (other than resume) will be refused. This implies pause-background-states\" +\n\t\t\t\t\t\" Requires system administrator access.\",\n\t\t\t\tAction: func(c *cli.Context) {\n\t\t\t\t\terr := pauseSystem(c)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Fatal(\"Error: \", err)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"pause-background-tasks\",\n\t\t\t\tUsage: \"Pause background tasks\",\n\t\t\t\tArgsUsage: \" \",\n\t\t\t\tDescription: \"Pause all background tasks in Photon Controller, such as image replication.\" +\n\t\t\t\t\t\" Incoming requests from users will continue to work\\n\" +\n\t\t\t\t\t\" Requires system administrator access.\",\n\t\t\t\tAction: func(c *cli.Context) {\n\t\t\t\t\terr := pauseBackgroundTasks(c)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Fatal(\"Error: \", err)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"resume\",\n\t\t\t\tUsage: \"Resume system under the deployment\",\n\t\t\t\tArgsUsage: \" \",\n\t\t\t\tDescription: \"Resume Photon Controller after it has been paused.\\n\" +\n\t\t\t\t\t\" Requires system administrator access.\",\n\t\t\t\tAction: func(c *cli.Context) {\n\t\t\t\t\terr := resumeSystem(c)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Fatal(\"Error: \", err)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"set-security-groups\",\n\t\t\t\tUsage: \"Set security groups for a deployment\",\n\t\t\t\tArgsUsage: \"<security-groups>\",\n\t\t\t\tDescription: \"Provide the list of Lightwave groups that contain the people who are\\n\" +\n\t\t\t\t\t\" allowed to be system administrators. Be careful: providing the wrong group could remove\\n\" +\n\t\t\t\t\t\" your access.\" +\n\t\t\t\t\t\" Requires system administrator access.\",\n\t\t\t\tAction: func(c *cli.Context) {\n\t\t\t\t\terr := setDeploymentSecurityGroups(c)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Fatal(\"Error: \", err)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"migration\",\n\t\t\t\tUsage: \"migrates state and hosts between photon controller deployments\",\n\t\t\t\tSubcommands: []cli.Command{\n\t\t\t\t\t{\n\t\t\t\t\t\tName: \"prepare\",\n\t\t\t\t\t\tUsage: \"initializes the migration\",\n\t\t\t\t\t\tFlags: []cli.Flag{\n\t\t\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\t\t\tName: \"endpoint, e\",\n\t\t\t\t\t\t\t\tUsage: \"API endpoint of the old management plane\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tAction: func(c *cli.Context) {\n\t\t\t\t\t\t\terr := deploymentMigrationPrepare(c)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\tlog.Fatal(\"Error: \", err)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tName: \"finalize\",\n\t\t\t\t\t\tUsage: \"finalizes the migration\",\n\t\t\t\t\t\tFlags: []cli.Flag{\n\t\t\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\t\t\tName: \"endpoint, e\",\n\t\t\t\t\t\t\t\tUsage: \"API endpoint of the old management plane\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tAction: func(c *cli.Context) {\n\t\t\t\t\t\t\terr := deploymentMigrationFinalize(c)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\tlog.Fatal(\"Error: \", err)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tName: \"status\",\n\t\t\t\t\t\tUsage: \"shows the status of the current migration\",\n\t\t\t\t\t\tAction: func(c *cli.Context) {\n\t\t\t\t\t\t\terr := showMigrationStatus(c)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\tlog.Fatal(\"Error: \", err)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\treturn command\n}", "func init() {\n\tRootCmd.AddCommand(deployCmd)\n\n\t// Here you will define your flags and configuration settings.\n\n\t// Cobra supports Persistent Flags which will work for this command\n\t// and all subcommands, e.g.:\n\t// deployCmd.PersistentFlags().String(\"foo\", \"\", \"A help for foo\")\n\n\t// Cobra supports local flags which will only run when this command\n\t// is called directly, e.g.:\n\t// deployCmd.Flags().BoolP(\"toggle\", \"t\", false, \"Help message for toggle\")\n\n}", "func deployJob(cmd *cobra.Command, args []string) {\n port, _:= cmd.Flags().GetString(\"port\")\n if port == \"\" {\n port = DefaultPort\n }\n name, _:= cmd.Flags().GetString(\"file\")\n yaml := unmarsharlYaml(readJobFile(name))\n currentDir, _ := os.Getwd()\n var job NewJob\n job.ID = yaml.Job.ID\n job.UID = fmt.Sprint(syscall.Getuid())\n group, _ := user.LookupGroup(\"odin\")\n gid, _ := strconv.Atoi(group.Gid)\n job.GID = strconv.Itoa(gid)\n job.Name = yaml.Job.Name\n job.Description = yaml.Job.Description\n job.File = currentDir + \"/\" + yaml.Job.File\n if yaml.Job.Language == \"go\" {\n job.Language = yaml.Job.Language\n cmd := exec.Command(job.Language, \"build\", job.File)\n cmd.SysProcAttr = &syscall.SysProcAttr{}\n _, err := cmd.CombinedOutput()\n if err != nil {\n fmt.Println(err)\n os.Exit(2)\n }\n job.File = job.File[:len(job.File)-3]\n } else {\n job.Language = yaml.Job.Language\n }\n job.Schedule = getScheduleString(name, port)\n jobJSON, _ := json.Marshal(job)\n body := makePostRequest(fmt.Sprintf(\"http://localhost%s/jobs\", port), bytes.NewBuffer(jobJSON))\n fmt.Println(body)\n}", "func (p *Platform) deploy(ctx context.Context, ui terminal.UI, artifact *registry.Artifact, src *component.Source, job *component.JobInfo) (*Deployment, error) {\n\tu := ui.Status()\n\tdefer u.Close()\n\tu.Update(\"Validating Lambda inputs\")\n\t// Validation Step\n\tu.Step(terminal.StatusOK, \"Lambda input validation is complete. Creating zip file of the application.\")\n\tzipError := ZipCreationFunction(p)\n\tif zipError != nil {\n\t\tu.Step(terminal.StatusError, \"Creation of binary zipfile failed. Application exiting.\")\n\t\treturn nil, zipError\n\t}\n\n\t//utils.DefaultSubnets(ctx, sess)\n\n\treturn &Deployment{}, nil\n}", "func flagSet(name string, cfg *CmdConfig) *flag.FlagSet {\n\tflags := flag.NewFlagSet(name, flag.ExitOnError)\n\tflags.StringVar(\n\t\t&cfg.ConfigPath,\n\t\t\"config-path\",\n\t\tsetFromEnvStr(\"CONFIG_PATH\", \"/repo\"),\n\t\t\"Configuration root directory. Should include the '.porter' or 'environment' directory. \"+\n\t\t\t\"Kubernetes object yaml files may be in the directory or in a subdirectory named 'k8s'.\",\n\t)\n\tflags.StringVar(&cfg.ConfigType, \"config-type\", setFromEnvStr(\"CONFIG_TYPE\", \"porter\"), \"Configuration type, \"+\n\t\t\"simple or porter.\")\n\tflags.StringVar(&cfg.Environment, \"environment\", setFromEnvStr(\"ENVIRONMENT\", \"\"), \"Environment of deployment.\")\n\tflags.IntVar(&cfg.MaxConfigMaps, \"max-cm\", setFromEnvInt(\"MAX_CM\", 5), \"Maximum number of configmaps and secret \"+\n\t\t\"objects to keep per app.\")\n\tflags.StringVar(&cfg.Namespace, \"namespace\", setFromEnvStr(\"NAMESPACE\", \"default\"), \"Kubernetes namespace.\")\n\tflags.StringVar(&cfg.Regions, \"regions\", setFromEnvStr(\"REGIONS\", \"\"), \"Regions\"+\n\t\t\"of deployment. (Multiple Space delimited regions allowed)\")\n\tflags.StringVar(&cfg.SHA, \"sha\", setFromEnvStr(\"sha\", \"\"), \"Deployment sha.\")\n\tflags.StringVar(&cfg.VaultAddress, \"vault-addr\", setFromEnvStr(\"VAULT_ADDR\", \"https://vault.loc.adobe.net\"),\n\t\t\"Vault server.\")\n\tflags.StringVar(&cfg.VaultBasePath, \"vault-path\", setFromEnvStr(\"VAULT_PATH\", \"/\"), \"Path in Vault.\")\n\tflags.StringVar(&cfg.VaultToken, \"vault-token\", setFromEnvStr(\"VAULT_TOKEN\", \"\"), \"Vault token.\")\n\tflags.StringVar(&cfg.SecretPathWhiteList, \"secret-path-whitelist\", setFromEnvStr(\"SECRET_PATH_WHITELIST\", \"\"), \"\"+\n\t\t\"Multiple Space delimited secret path whitelist allowed\")\n\tflags.BoolVar(&cfg.Verbose, \"v\", setFromEnvBool(\"VERBOSE\"), \"Verbose log output.\")\n\tflags.IntVar(&cfg.Wait, \"wait\", setFromEnvInt(\"WAIT\", 180), \"Extra time to wait for deployment to complete in \"+\n\t\t\"seconds.\")\n\tflags.StringVar(&cfg.LogMode, \"log-mode\", setFromEnvStr(\"LOG_MODE\", \"inline\"), \"Pod log streaming mode. \"+\n\t\t\"One of 'inline' (print to porter2k8s log), 'file' (write to filesystem, see log-dir option), \"+\n\t\t\"'none' (disable log streaming)\")\n\tflags.StringVar(&cfg.LogDir, \"log-dir\", setFromEnvStr(\"LOG_DIR\", \"logs\"),\n\t\t\"Directory to write pod logs into. (must already exist)\")\n\n\treturn flags\n}", "func (i *Install) AttachCmd(cmd *cobra.Command) {\n\ti.OperationGlobal = &OperationGlobal{}\n\ti.OperationGlobal.AttachCmd(cmd)\n\tcmd.Flags().IntVar(&i.EgClientPort, \"mesh-control-plane-client-port\", DefaultMeshClientPort, \"Mesh control plane client port for remote accessing\")\n\tcmd.Flags().IntVar(&i.EgAdminPort, \"mesh-control-plane-admin-port\", DefaultMeshAdminPort, \"Port of mesh control plane admin for management\")\n\tcmd.Flags().IntVar(&i.EgPeerPort, \"mesh-control-plane-peer-port\", DefaultMeshPeerPort, \"Port of mesh control plane for consensus each other\")\n\tcmd.Flags().IntVar(&i.MeshControlPlaneCheckHealthzMaxTime,\n\t\t\"mesh-control-plane-check-healthz-max-time\",\n\t\tDefaultMeshControlPlaneCheckHealthzMaxTime,\n\t\t\"Max timeout in second for checking control panel component whether ready or not\")\n\n\tcmd.Flags().IntVar(&i.EgServicePeerPort, \"mesh-control-plane-service-peer-port\", DefaultMeshPeerPort, \"Port of Easegress cluster peer\")\n\tcmd.Flags().IntVar(&i.EgServiceAdminPort, \"mesh-control-plane-service-admin-port\", DefaultMeshAdminPort, \"Port of Easegress admin address\")\n\n\tcmd.Flags().StringVar(&i.MeshControlPlaneStorageClassName, \"mesh-storage-class-name\", DefaultMeshControlPlaneStorageClassName, \"Mesh storage class name\")\n\tcmd.Flags().StringVar(&i.MeshControlPlanePersistVolumeCapacity, \"mesh-control-plane-pv-capacity\", DefaultMeshControlPlanePersistVolumeCapacity,\n\t\tMeshControlPlanePVNotExistedHelpStr)\n\n\tcmd.Flags().Int32Var(&i.MeshIngressServicePort, \"mesh-ingress-service-port\", DefaultMeshIngressServicePort, \"Port of mesh ingress controller\")\n\n\tcmd.Flags().StringVar(&i.EaseMeshRegistryType, \"registry-type\", DefaultMeshRegistryType, MeshRegistryTypeHelpStr)\n\tcmd.Flags().IntVar(&i.HeartbeatInterval, \"heartbeat-interval\", DefaultHeartbeatInterval, \"Heartbeat interval for mesh service\")\n\n\tcmd.Flags().StringVar(&i.ImageRegistryURL, \"image-registry-url\", DefaultImageRegistryURL, \"Image registry URL\")\n\tcmd.Flags().StringVar(&i.EasegressImage, \"easegress-image\", DefaultEasegressImage, \"Easegress image name\")\n\tcmd.Flags().StringVar(&i.EaseMeshOperatorImage, \"easemesh-operator-image\", DefaultEaseMeshOperatorImage, \"Mesh operator image name\")\n\n\tcmd.Flags().IntVar(&i.EasegressControlPlaneReplicas, \"easemesh-control-plane-replicas\", DefaultMeshControlPlaneReplicas, \"Mesh control plane replicas\")\n\tcmd.Flags().IntVar(&i.MeshIngressReplicas, \"easemesh-ingress-replicas\", DefaultMeshIngressReplicas, \"Mesh ingress controller replicas\")\n\tcmd.Flags().IntVar(&i.EaseMeshOperatorReplicas, \"easemesh-operator-replicas\", DefaultMeshOperatorReplicas, \"Mesh operator controller replicas\")\n\tcmd.Flags().StringVarP(&i.SpecFile, \"file\", \"f\", \"\", \"A yaml file specifying the install params\")\n\tcmd.Flags().BoolVar(&i.CleanWhenFailed, \"clean-when-failed\", true, \"Clean resources when installation failed\")\n}", "func Deploy(args []string) error {\n\t// TODO: check if the main/env.go file has changed based on env.txt:\n\t// If it has changed and the \"change-env\" argument is not set, print\n\t// an error message and return. If it has changed and \"change-env\" is\n\t// set, replace main/env.go.\n\t// If it has not changed, don't do anything to the existing file.\n\treturn nil\n}", "func (*SigMentionHandler) AddFlags(cmd *cobra.Command, config *github.Config) {}", "func (PingCIMunger) AddFlags(cmd *cobra.Command, config *github_util.Config) {}", "func (p *provider) deploy(req handlers.ResourceDeployRequest) (*handlers.ResourceDeployResult, error) {\n\tvar result handlers.ResourceDeployResult\n\n\t// get resource info : tmc + extension info\n\tresourceInfo, err := p.defaultHandler.GetResourceInfo(&req)\n\tdefer func() {\n\t\t// callback to orchestrator\n\t\tif len(req.Callback) == 0 {\n\t\t\treturn\n\t\t}\n\t\tif err != nil {\n\t\t\tp.defaultHandler.Callback(req.Callback, req.Uuid, false, nil, req.Options, err.Error())\n\t\t} else {\n\t\t\tp.defaultHandler.Callback(req.Callback, result.ID, true, result.Config, result.Options, \"\")\n\t\t}\n\t}()\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to defaultHandler.GetResourceInfo for %s:%s/%s\", req.Engine, req.Options[\"version\"], req.Az)\n\t}\n\n\thandler := p.findHandler(resourceInfo.Tmc)\n\tif handler == nil {\n\t\treturn nil, fmt.Errorf(\"could not find deploy handler for %s\", req.Engine)\n\t}\n\n\t// pre-check if it needs to further deploy\n\ttmcInstance, needDeployInstance, err := handler.CheckIfNeedTmcInstance(&req, resourceInfo)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to CheckIfNeedTmcInstance for %s/%s\", req.Engine, req.Az)\n\t}\n\ttenant, needApplyTenant, err := handler.CheckIfNeedTmcInstanceTenant(&req, resourceInfo)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to CheckIfNeedTmcInstanceTenant for %s/%s\", req.Engine, req.Az)\n\t}\n\tp.Log.Infof(\"[%s/%s] check if it needs to deploy tmc instance: %v, needs to apply tenant: %v\\n\",\n\t\treq.Engine, req.Az, needDeployInstance, needApplyTenant)\n\n\tvar subResults []*handlers.ResourceDeployResult\n\t// resolve dependency resources\n\tif needApplyTenant || needDeployInstance {\n\t\t// for some resource like monitor, do not has dice.yml definition\n\t\tif resourceInfo.Dice != nil && resourceInfo.Dice.AddOns != nil {\n\t\t\tdefer func() {\n\t\t\t\t// delete related sub resources if error occur\n\t\t\t\tif err == nil {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tfor _, subResult := range subResults {\n\t\t\t\t\tp.UnDeploy(subResult.ID)\n\t\t\t\t\thandler.DeleteRequestRelation(req.Uuid, subResult.ID)\n\t\t\t\t}\n\t\t\t}()\n\n\t\t\tfor name, addon := range resourceInfo.Dice.AddOns {\n\t\t\t\t// deploy dependency resource recursive\n\t\t\t\tsubReq := handler.BuildSubResourceDeployRequest(name, addon, &req)\n\t\t\t\tif subReq == nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tvar subResult *handlers.ResourceDeployResult\n\t\t\t\tsubResult, err = p.Deploy(*subReq)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, errors.Wrapf(err, \"failed to Deploy sub addon %s:%s/%s\", subReq.Engine, subReq.Options[\"version\"], subReq.Az)\n\t\t\t\t}\n\t\t\t\tsubResults = append(subResults, subResult)\n\t\t\t\thandler.BuildRequestRelation(req.Uuid, subResult.ID)\n\t\t\t}\n\t\t}\n\t}\n\n\t// create tmc_instance record if necessary\n\tvar clusterConfig map[string]string\n\tclusterConfig, err = handler.GetClusterConfig(req.Az)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to GetClusterConfig(%s)\", req.Az)\n\t}\n\tif needDeployInstance {\n\t\t// initialize tmc_instance\n\t\ttmcInstance, err = handler.InitializeTmcInstance(&req, resourceInfo, subResults)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to InitializeTmcInstance\")\n\t\t}\n\t\tdefer func() {\n\t\t\t// delete instance if error occur,\n\t\t\t// if tmcInstance status is RUNNING skip delete even if error\n\t\t\tif err == nil || tmcInstance.Status == handlers.TmcInstanceStatusRunning {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\thandler.DeleteTmcInstance(tmcInstance, handlers.TmcInstanceStatusError)\n\t\t}()\n\n\t\t// if is custom resource, do not real deploy, just update config and simply mark status as RUNNING\n\t\tcustomConfig, hasCustom := handler.CheckIfHasCustomConfig(clusterConfig)\n\t\tif hasCustom {\n\t\t\thandler.UpdateTmcInstanceOnCustom(tmcInstance, customConfig)\n\t\t} else {\n\t\t\t// do pre-deploy job if any\n\t\t\tif err = handler.DoPreDeployJob(resourceInfo, tmcInstance); err != nil {\n\t\t\t\treturn nil, errors.Wrap(err, \"failed to DoPreDeployJob\")\n\t\t\t}\n\n\t\t\t// do deploy and wait for ready\n\t\t\tvar sgDeployResult interface{}\n\t\t\tif resourceInfo.Dice == nil || resourceInfo.Dice.Services == nil || len(resourceInfo.Dice.Services) == 0 {\n\t\t\t\t// some resource do not need real deploy, e.g. configcenter.\n\t\t\t\t// this kind of resource do not have services section defined in dice.yml\n\t\t\t\t// just mock a success response\n\t\t\t\tsgDeployResult = &apistructs.ServiceGroup{\n\t\t\t\t\tStatusDesc: apistructs.StatusDesc{Status: apistructs.StatusReady},\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsgReq := handler.BuildServiceGroupRequest(resourceInfo, tmcInstance, clusterConfig)\n\t\t\t\tsgDeployResult, err = handler.DoDeploy(sgReq, resourceInfo, tmcInstance, clusterConfig)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, errors.Wrap(err, \"failed to DoDeploy\")\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// do post-deploy job if any\n\t\t\tadditionalConfig := map[string]string{}\n\t\t\tadditionalConfig, err = handler.DoPostDeployJob(tmcInstance, sgDeployResult, clusterConfig)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Wrapf(err, \"failed to DoPostDeployJob for tmc_instance %+v\", tmcInstance)\n\t\t\t}\n\n\t\t\t// update tmc_instance config and status\n\t\t\tconfig := handler.BuildTmcInstanceConfig(tmcInstance, sgDeployResult, clusterConfig, additionalConfig)\n\t\t\thandler.UpdateTmcInstanceOnFinish(tmcInstance, config, handlers.TmcInstanceStatusRunning)\n\t\t}\n\t}\n\n\tif needApplyTenant {\n\t\t// create tmc_instance_tenant record\n\t\ttenant, err = handler.InitializeTmcInstanceTenant(&req, tmcInstance, subResults)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to InitializeTmcInstanceTenant\")\n\t\t}\n\t\tdefer func() {\n\t\t\t// delete tenant if error occur\n\t\t\tif err == nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\thandler.DeleteTenant(tenant, tmcInstance, clusterConfig)\n\t\t}()\n\n\t\t// deploy tmc_instance_tenant\n\t\tvar config map[string]string\n\t\tconfig, err = handler.DoApplyTmcInstanceTenant(&req, resourceInfo, tmcInstance, tenant, clusterConfig)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to DoApplyTmcInstanceTenant for %+v\", tmcInstance)\n\t\t}\n\n\t\t// update and persistent applied config\n\t\ttenant, err = handler.UpdateTmcInstanceTenantOnFinish(tenant, config)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to UpdateTmcInstanceTenantOnFinish\")\n\t\t}\n\t}\n\n\tresult = handler.BuildDeployResult(tmcInstance, tenant)\n\n\treturn &result, nil\n}", "func Deploy(opts DeployOptions) error {\n\tvar outBuffer bytes.Buffer\n\tstart := time.Now()\n\tlogWriter := LogWriter{App: opts.App}\n\tlogWriter.Async()\n\tdefer logWriter.Close()\n\twriter := io.MultiWriter(&tsuruIo.NoErrorWriter{Writer: opts.OutputStream}, &outBuffer, &logWriter)\n\timageId, err := deployToProvisioner(&opts, writer)\n\telapsed := time.Since(start)\n\tsaveErr := saveDeployData(&opts, imageId, outBuffer.String(), elapsed, err)\n\tif saveErr != nil {\n\t\tlog.Errorf(\"WARNING: couldn't save deploy data, deploy opts: %#v\", opts)\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = incrementDeploy(opts.App)\n\tif err != nil {\n\t\tlog.Errorf(\"WARNING: couldn't increment deploy count, deploy opts: %#v\", opts)\n\t}\n\tif opts.App.UpdatePlatform == true {\n\t\topts.App.SetUpdatePlatform(false)\n\t}\n\treturn nil\n}", "func templateDeploy(cmd *cobra.Command, args []string) {\n\t//Check deploy template file.\n\tif len(args) <= 0 || utils.IsFileExist(args[0]) == false {\n\t\tfmt.Fprintf(os.Stderr, \"the deploy template file is required, %s\\n\", \"see https://github.com/Huawei/containerops/singular for more detail.\")\n\t\tos.Exit(1)\n\t}\n\n\ttemplate := args[0]\n\td := new(objects.Deployment)\n\n\t//Read template file and parse.\n\tif err := d.ParseFromFile(template, output); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"parse deploy template error: %s\\n\", err.Error())\n\t\tos.Exit(1)\n\t}\n\n\t//Set private key file path.\n\tif privateKey != \"\" {\n\t\td.Tools.SSH.Private, d.Tools.SSH.Public = privateKey, publicKey\n\t}\n\n\t//The integrity checking of deploy template.\n\tif err := d.Check(); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"parse deploy template error: %s\\n\", err.Error())\n\t\tos.Exit(1)\n\t}\n\n\t//Set log and error io.Writer\n\tvar logWriters io.Writer\n\n\t//Generate stdout/stderr io.Writer\n\tstdoutFile, _ := os.Create(path.Join(d.Config, \"deploy.log\"))\n\tdefer stdoutFile.Close()\n\n\t//Using MultiWriter log and error.\n\tif verbose == true {\n\t\tlogWriters = io.MultiWriter(stdoutFile, os.Stdout)\n\t} else {\n\t\tlogWriters = io.MultiWriter(stdoutFile)\n\t}\n\n\t//Deploy cloud native stack\n\tif err := module.DeployInfraStacks(d, db, logWriters, timestamp); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"%s\\n\", err.Error())\n\t\tos.Exit(1)\n\t}\n\n\t//Delete droplets\n\tif del == true {\n\t\tif err := module.DeleteInfraStacks(d, logWriters, timestamp); err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"%s\\n\", err.Error())\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n}", "func NewDeployCmd() *cobra.Command {\n\tcmd := &DeployCmd{}\n\n\tdeployCmd := &cobra.Command{\n\t\tUse: \"deploy\",\n\t\tShort: \"Deploy the project\",\n\t\tLong: `\n#######################################################\n################## devspace deploy ####################\n#######################################################\nDeploys the current project to a Space or namespace:\n\ndevspace deploy\ndevspace deploy --namespace=deploy\ndevspace deploy --namespace=deploy\ndevspace deploy --kube-context=deploy-context\n#######################################################`,\n\t\tArgs: cobra.NoArgs,\n\t\tRun: cmd.Run,\n\t}\n\n\tdeployCmd.Flags().StringVar(&cmd.Namespace, \"namespace\", \"\", \"The namespace to deploy to\")\n\tdeployCmd.Flags().StringVar(&cmd.KubeContext, \"kube-context\", \"\", \"The kubernetes context to use for deployment\")\n\tdeployCmd.Flags().StringVar(&cmd.DockerTarget, \"docker-target\", \"\", \"The docker target to use for building\")\n\n\tdeployCmd.Flags().BoolVar(&cmd.SwitchContext, \"switch-context\", false, \"Switches the kube context to the deploy context\")\n\tdeployCmd.Flags().BoolVarP(&cmd.ForceBuild, \"force-build\", \"b\", false, \"Forces to (re-)build every image\")\n\tdeployCmd.Flags().BoolVarP(&cmd.ForceDeploy, \"force-deploy\", \"d\", false, \"Forces to (re-)deploy every deployment\")\n\n\treturn deployCmd\n}", "func (jj *Juju) Deploy(user, service string) (*simplejson.Json, error) {\n args := []string{\"deploy\", \"--show-log\"}\n id := jj.id(user, service)\n report := JSON(fmt.Sprintf(`{\"time\": \"%s\"}`, time.Now()))\n log.Infof(\"deploy juju service: %s\\n\", id)\n\n // Get charms location\n storePath, storePrefix, err := jj.Charmstore(service)\n if err != nil { return EmptyJSON(), err }\n if storePrefix == \"local\" {\n args = append(args, \"--repository\")\n args = append(args, storePath)\n }\n\n // Add final service syntax to deploy\n args = append(args, fmt.Sprintf(\"%s:%s/%s\", storePrefix, defaultSeries, service))\n args = append(args, id)\n\n // Read and dump user configuration\n confPath, err := jj.fetchConfig(user, service)\n if err != nil { return EmptyJSON(), err }\n if confPath != \"\" {\n args = append(args, \"--config\") \n args = append(args, confPath) \n }\n\n // Charm deployment\n log.Infof(\"enqueue process\")\n client, err := goresque.Dial(redisURL)\n if err != nil { return EmptyJSON(), err }\n client.Enqueue(workerClass, \"fork\", jj.Path, args)\n\n report.Set(\"deployed\", id)\n report.Set(\"provider\", \"juju\")\n report.Set(\"arguments\", args)\n report.Set(\"series\", defaultSeries)\n return report, nil\n}", "func (cmd *DeployCmd) Run(cobraCmd *cobra.Command, args []string) {\n\t// Set config root\n\tconfigExists, err := configutil.SetDevSpaceRoot()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tif !configExists {\n\t\tlog.Fatal(\"Couldn't find a DevSpace configuration. Please run `devspace init`\")\n\t}\n\n\t// Start file logging\n\tlog.StartFileLogging()\n\n\t// Prepare the config\n\tcmd.prepareConfig()\n\n\t// Create kubectl client\n\tclient, err := kubectl.NewClientWithContextSwitch(cmd.SwitchContext)\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to create new kubectl client: %v\", err)\n\t}\n\n\t// Create namespace if necessary\n\terr = kubectl.EnsureDefaultNamespace(client, log.GetInstance())\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to create namespace: %v\", err)\n\t}\n\n\t// Create cluster binding if necessary\n\terr = kubectl.EnsureGoogleCloudClusterRoleBinding(client, log.GetInstance())\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to ensure cluster-admin role binding: %v\", err)\n\t}\n\n\t// Create docker client\n\tdockerClient, err := docker.NewClient(false)\n\n\t// Create pull secrets and private registry if necessary\n\terr = registry.InitRegistries(dockerClient, client, log.GetInstance())\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Load generated config\n\tgeneratedConfig, err := generated.LoadConfig()\n\tif err != nil {\n\t\tlog.Fatalf(\"Error loading generated.yaml: %v\", err)\n\t}\n\n\t// Force image build\n\tmustRedeploy, err := image.BuildAll(client, generatedConfig, false, cmd.ForceBuild, log.GetInstance())\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Save config if an image was built\n\tif mustRedeploy == true {\n\t\terr := generated.SaveConfig(generatedConfig)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Error saving generated config: %v\", err)\n\t\t}\n\t}\n\n\t// Force deployment of all defined deployments\n\terr = deploy.All(client, generatedConfig, false, mustRedeploy || cmd.ForceDeploy, log.GetInstance())\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Save Config\n\terr = generated.SaveConfig(generatedConfig)\n\tif err != nil {\n\t\tlog.Fatalf(\"Error saving generated config: %v\", err)\n\t}\n\n\tif generatedConfig.CloudSpace != nil {\n\t\t// Create ingress if there is none\n\t\terr = cloud.CreateIngress(client)\n\t\tif err != nil {\n\t\t\tlog.Warnf(\"Error creating ingress: %v\", err)\n\t\t}\n\n\t\tlog.Donef(\"Successfully deployed!\")\n\t\tlog.Infof(\"Run: \\n- `%s` to open the app in the browser\\n- `%s` to open a shell into the container\\n- `%s` to show the container logs\\n- `%s` to open the management ui\\n- `%s` to analyze the space for potential issues\", ansi.Color(\"devspace open\", \"white+b\"), ansi.Color(\"devspace enter\", \"white+b\"), ansi.Color(\"devspace logs\", \"white+b\"), ansi.Color(\"devspace ui\", \"white+b\"), ansi.Color(\"devspace analyze\", \"white+b\"))\n\t} else {\n\t\tlog.Donef(\"Successfully deployed!\")\n\t\tlog.Infof(\"Run `%s` to check for potential issues\", ansi.Color(\"devspace analyze\", \"white+b\"))\n\t}\n}", "func main() {\n\n\tvar version string\n\n\t// Derive the commit message from -X main.commit=$YOUR_VALUE_HERE\n\t// if the build does not have the commit variable set externally,\n\t// fall back to unsupported custom build\n\tif commit != \"\" {\n\t\tversion = commit\n\t} else {\n\t\tversion = \"unsupported custom build\"\n\t}\n\n\t// let the user know that we are running within a docker container\n\tcheckRunningWithinDocker()\n\n\t// build the Command Line interface\n\t// https://github.com/urfave/cli/blob/master/docs/v2/manual.md\n\n\t// basic information\n\tapp := &cli.App{\n\t\tName: \"appimagetool\",\n\t\tAuthors: \t\t\t\t[]*cli.Author{{Name: \"AppImage Project\"}},\n\t\tVersion: version,\n\t\tUsage: \t\t\"An automatic tool to create AppImages\",\n\t\tEnableBashCompletion: false,\n\t\tHideHelp: false,\n\t\tHideVersion: false,\n\t\tCompiled: time.Time{},\n\t\tCopyright: \"MIT License\",\n\t\tAction: \t\t\t\tbootstrapAppImageBuild,\n\n\t}\n\n\t// define subcommands, like 'deploy', 'validate', ...\n\tapp.Commands = []*cli.Command{\n\t\t{\n\t\t\tName: \"deploy\",\n\t\t\tUsage: \"Turns PREFIX directory into AppDir by deploying dependencies and AppRun file\",\n\t\t\tAction: bootstrapAppImageDeploy,\n\t\t},\n\t\t{\n\t\t\tName: \"validate\",\n\t\t\tUsage: \"Calculate the sha256 digest and check whether the signature is valid\",\n\t\t\tAction: bootstrapValidateAppImage,\n\t\t},\n\t\t{\n\t\t\tName: \"setupsigning\",\n\t\t\tUsage: \"Prepare a git repository that is used with Travis CI for signing AppImages\",\n\t\t\tAction: bootstrapSetupSigning,\n\t\t},\n\t\t{\n\t\t\tName: \t\"sections\",\n\t\t\tUsage: \t\"\",\n\t\t\tAction:\tbootstrapAppImageSections,\n\t\t},\n\t}\n\n\t// define flags, such as --libapprun_hooks, --standalone here ...\n\tapp.Flags = []cli.Flag{\n\t\t&cli.BoolFlag{\n\t\t\tName: \"libapprun_hooks\",\n\t\t\tAliases: []string{\"l\"},\n\t\t\tUsage: \"Use libapprun_hooks\",\n\t\t},\n\t\t&cli.BoolFlag{\n\t\t\tName: \"overwrite\",\n\t\t\tAliases: []string{\"o\"},\n\t\t\tUsage: \"Overwrite existing files\",\n\t\t},\n\t\t&cli.BoolFlag{\n\t\t\tName: \"standalone\",\n\t\t\tAliases: []string{\"s\"},\n\t\t\tUsage: \"Make standalone self-contained bundle\",\n\t\t},\n\t}\n\n\t// TODO: move travis based Sections to travis.go in future\n\tif os.Getenv(\"TRAVIS_TEST_RESULT\") == \"1\" {\n\t\tlog.Fatal(\"$TRAVIS_TEST_RESULT is 1, exiting...\")\n\t}\n\n\terrRuntime := app.Run(os.Args)\n\tif errRuntime != nil {\n\t\tlog.Fatal(errRuntime)\n\t}\n\n}", "func (c *applicationUsecaseImpl) Deploy(ctx context.Context, app *model.Application, req apisv1.ApplicationDeployRequest) (*apisv1.ApplicationDeployResponse, error) {\n\t// TODO: rollback to handle all the error case\n\t// step1: Render oam application\n\tversion := utils.GenerateVersion(\"\")\n\toamApp, err := c.renderOAMApplication(ctx, app, req.WorkflowName, version)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tconfigByte, _ := yaml.Marshal(oamApp)\n\n\tworkflow, err := c.workflowUsecase.GetWorkflow(ctx, app, oamApp.Annotations[oam.AnnotationWorkflowName])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// step2: check and create deploy event\n\tif !req.Force {\n\t\tvar lastVersion = model.ApplicationRevision{\n\t\t\tAppPrimaryKey: app.PrimaryKey(),\n\t\t\tEnvName: workflow.EnvName,\n\t\t}\n\t\tlist, err := c.ds.List(ctx, &lastVersion, &datastore.ListOptions{\n\t\t\tPageSize: 1, Page: 1, SortBy: []datastore.SortOption{{Key: \"createTime\", Order: datastore.SortOrderDescending}}})\n\t\tif err != nil && !errors.Is(err, datastore.ErrRecordNotExist) {\n\t\t\tlog.Logger.Errorf(\"query app latest revision failure %s\", err.Error())\n\t\t\treturn nil, bcode.ErrDeployConflict\n\t\t}\n\t\tif len(list) > 0 && list[0].(*model.ApplicationRevision).Status != model.RevisionStatusComplete {\n\t\t\tlog.Logger.Warnf(\"last app revision can not complete %s/%s\", list[0].(*model.ApplicationRevision).AppPrimaryKey, list[0].(*model.ApplicationRevision).Version)\n\t\t\treturn nil, bcode.ErrDeployConflict\n\t\t}\n\t}\n\n\tvar appRevision = &model.ApplicationRevision{\n\t\tAppPrimaryKey: app.PrimaryKey(),\n\t\tVersion: version,\n\t\tApplyAppConfig: string(configByte),\n\t\tStatus: model.RevisionStatusInit,\n\t\t// TODO: Get user information from ctx and assign a value.\n\t\tDeployUser: \"\",\n\t\tNote: req.Note,\n\t\tTriggerType: req.TriggerType,\n\t\tWorkflowName: oamApp.Annotations[oam.AnnotationWorkflowName],\n\t\tEnvName: workflow.EnvName,\n\t}\n\n\tif err := c.ds.Add(ctx, appRevision); err != nil {\n\t\treturn nil, err\n\t}\n\t// step3: check and create namespace\n\tvar namespace corev1.Namespace\n\tif err := c.kubeClient.Get(ctx, types.NamespacedName{Name: oamApp.Namespace}, &namespace); apierrors.IsNotFound(err) {\n\t\tnamespace.Name = oamApp.Namespace\n\t\tif err := c.kubeClient.Create(ctx, &namespace); err != nil {\n\t\t\tlog.Logger.Errorf(\"auto create namespace failure %s\", err.Error())\n\t\t\treturn nil, bcode.ErrCreateNamespace\n\t\t}\n\t}\n\t// step4: apply to controller cluster\n\terr = c.apply.Apply(ctx, oamApp)\n\tif err != nil {\n\t\tappRevision.Status = model.RevisionStatusFail\n\t\tappRevision.Reason = err.Error()\n\t\tif err := c.ds.Put(ctx, appRevision); err != nil {\n\t\t\tlog.Logger.Warnf(\"update deploy event failure %s\", err.Error())\n\t\t}\n\n\t\tlog.Logger.Errorf(\"deploy app %s failure %s\", app.PrimaryKey(), err.Error())\n\t\treturn nil, bcode.ErrDeployApplyFail\n\t}\n\n\t// step5: create workflow record\n\tif err := c.workflowUsecase.CreateWorkflowRecord(ctx, app, oamApp, workflow); err != nil {\n\t\tlog.Logger.Warnf(\"create workflow record failure %s\", err.Error())\n\t}\n\n\t// step6: update app revision status\n\tappRevision.Status = model.RevisionStatusRunning\n\tif err := c.ds.Put(ctx, appRevision); err != nil {\n\t\tlog.Logger.Warnf(\"update app revision failure %s\", err.Error())\n\t}\n\n\treturn &apisv1.ApplicationDeployResponse{\n\t\tApplicationRevisionBase: apisv1.ApplicationRevisionBase{\n\t\t\tVersion: appRevision.Version,\n\t\t\tStatus: appRevision.Status,\n\t\t\tReason: appRevision.Reason,\n\t\t\tDeployUser: appRevision.DeployUser,\n\t\t\tNote: appRevision.Note,\n\t\t\tTriggerType: appRevision.TriggerType,\n\t\t},\n\t}, nil\n}", "func (oi *offsetInjector) deploy(ctx context.Context) error {\n\tif err := oi.c.RunE(ctx, oi.c.All(), \"test -x ./bumptime\"); err == nil {\n\t\toi.deployed = true\n\t\treturn nil\n\t}\n\n\tif err := oi.c.Install(ctx, oi.c.l, oi.c.All(), \"ntp\"); err != nil {\n\t\treturn err\n\t}\n\tif err := oi.c.Install(ctx, oi.c.l, oi.c.All(), \"gcc\"); err != nil {\n\t\treturn err\n\t}\n\tif err := oi.c.RunL(ctx, oi.c.l, oi.c.All(), \"sudo\", \"service\", \"ntp\", \"stop\"); err != nil {\n\t\treturn err\n\t}\n\tif err := oi.c.RunL(ctx, oi.c.l,\n\t\toi.c.All(),\n\t\t\"curl\",\n\t\t\"--retry\", \"3\",\n\t\t\"--fail\",\n\t\t\"--show-error\",\n\t\t\"-kO\",\n\t\t\"https://raw.githubusercontent.com/cockroachdb/jepsen/master/cockroachdb/resources/bumptime.c\",\n\t); err != nil {\n\t\treturn err\n\t}\n\tif err := oi.c.RunL(ctx, oi.c.l,\n\t\toi.c.All(), \"gcc\", \"bumptime.c\", \"-o\", \"bumptime\", \"&&\", \"rm bumptime.c\",\n\t); err != nil {\n\t\treturn err\n\t}\n\toi.deployed = true\n\treturn nil\n}", "func (s *deployerService) Deploy(ctx context.Context, db *gorm.DB, opts DeploymentsCreateOpts) (*Release, error) {\n\tvar msg jsonmessage.JSONMessage\n\n\tr, err := s.deploy(ctx, db, opts)\n\tif err != nil {\n\t\tmsg = newJSONMessageError(err)\n\t} else {\n\t\tmsg = jsonmessage.JSONMessage{Status: fmt.Sprintf(\"Status: Created new release v%d for %s\", r.Version, r.App.Name)}\n\t}\n\n\tif err := json.NewEncoder(opts.Output).Encode(&msg); err != nil {\n\t\treturn r, err\n\t}\n\n\treturn r, err\n}", "func DeploySSH(m *parlaytypes.TreasureMap, logFile string, jsonLogging, background bool) error {\n\n\tif len(ssh.Hosts) == 0 {\n\t\tlog.Warnln(\"No hosts credentials have been loaded, only commands with commandLocal = true will work\")\n\t}\n\tif len(m.Deployments) == 0 {\n\t\treturn fmt.Errorf(\"No Deployments in parlay map\")\n\t}\n\n\tfor x := range m.Deployments {\n\t\t// Build new hosts list from imported SSH servers and compare that we have required credentials\n\t\t_, err := ssh.FindHosts(m.Deployments[x].Hosts)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Begin the deployment\n\tif logFile != \"\" {\n\t\t//enable logging\n\t\tlogger.InitLogFile(logFile)\n\t}\n\n\tif jsonLogging {\n\t\tlogger.InitJSON()\n\t}\n\n\tif background {\n\t\tgo startDeployments(m.Deployments)\n\t} else {\n\t\tstartDeployments(m.Deployments)\n\t}\n\n\t// TODO - test original automation\n\n\t// for x := range m.Deployments {\n\t// \t// Build new hosts list from imported SSH servers and compare that we have required credentials\n\t// \thosts, err := ssh.FindHosts(m.Deployments[x].Hosts)\n\t// \tif err != nil {\n\t// \t\treturn err\n\t// \t}\n\n\t// \t// Beggining of deployment work\n\t// \tlog.Infof(\"Beginning Deployment [%s]\\n\", m.Deployments[x].Name)\n\t// \tlogger.WriteLogEntry(\"\", \"\", \"\", fmt.Sprintf(\"Beginning Deployment [%s]\\n\", m.Deployments[x].Name))\n\n\t// \t// Set Restore checkpoint\n\t// \trestore.Deployment = m.Deployments[x].Name\n\t// \trestore.Hosts = m.Deployments[x].Hosts\n\n\t// \tif m.Deployments[x].Parallel == true {\n\t// \t\t// Begin this deployment in parallel across all hosts\n\t// \t\terr = parallelDeployment(m.Deployments[x].Actions, hosts, &logger)\n\t// \t\tif err != nil {\n\t// \t\t\treturn err\n\t// \t\t}\n\t// \t} else {\n\t// \t\t// This work will be sequential, one host after the next\n\t// \t\tfor z := range m.Deployments[x].Hosts {\n\t// \t\t\tvar hostConfig ssh.HostSSHConfig\n\t// \t\t\t// Find the hosts SSH configuration\n\t// \t\t\tfor i := range hosts {\n\t// \t\t\t\tif hosts[i].Host == m.Deployments[x].Hosts[z] {\n\t// \t\t\t\t\thostConfig = hosts[i]\n\t// \t\t\t\t}\n\t// \t\t\t}\n\t// \t\t\t// Set the state of logging actions to in-progress\n\t// \t\t\tlogger.SetLoggingState(hostConfig.Host, \"Running\")\n\t// \t\t\terr = sequentialDeployment(m.Deployments[x].Actions, hostConfig, &logger)\n\t// \t\t\tif err != nil {\n\t// \t\t\t\tlogger.SetLoggingState(hostConfig.Host, \"Failed\")\n\t// \t\t\t\treturn err\n\t// \t\t\t}\n\t// \t\t\t// Set the state of logging actions to completed\n\t// \t\t\tlogger.SetLoggingState(hostConfig.Host, \"Completed\")\n\t// \t\t}\n\t// \t}\n\t// }\n\treturn nil\n}", "func (g *smartContractGW) PostDeploy(msg *messages.TransactionReceipt) error {\n\n\trequestID := msg.Headers.ReqID\n\n\t// We use the ethereum address of the contract, without the 0x prefix, and\n\t// all in lower case, as the name of the file and the path root of the Swagger operations\n\tif msg.ContractAddress == nil {\n\t\treturn ethconnecterrors.Errorf(ethconnecterrors.RESTGatewayPostDeployMissingAddress, requestID)\n\t}\n\taddrHexNo0x := strings.ToLower(msg.ContractAddress.Hex()[2:])\n\n\t// Generate and store the swagger\n\tbasePath := \"/contracts/\"\n\tisRemote := isRemote(msg.Headers.CommonHeaders)\n\tif isRemote {\n\t\tbasePath = \"/instances/\"\n\t}\n\tregisteredName := msg.RegisterAs\n\tif registeredName == \"\" {\n\t\tregisteredName = addrHexNo0x\n\t}\n\n\tif msg.Headers.MsgType == messages.MsgTypeTransactionSuccess {\n\t\tmsg.ContractSwagger = g.conf.BaseURL + basePath + registeredName + \"?openapi\"\n\t\tmsg.ContractUI = g.conf.BaseURL + basePath + registeredName + \"?ui\"\n\n\t\tvar err error\n\t\tif isRemote {\n\t\t\tif msg.RegisterAs != \"\" {\n\t\t\t\terr = g.rr.registerInstance(msg.RegisterAs, \"0x\"+addrHexNo0x)\n\t\t\t}\n\t\t} else {\n\t\t\t_, err = g.storeNewContractInfo(addrHexNo0x, requestID, registeredName, msg.RegisterAs)\n\t\t}\n\t\treturn err\n\t}\n\treturn nil\n}", "func (p *PullCommand) addFlags() {\n\t// TODO: add flags here\n}", "func newDeployment(ctx context.Context, c *vim25.Client, params *types.VMDeployParams, l log.Logger) (*Deployment, error) { //nolint: unparam\n\td := newSimpleDeployment(c, params, l)\n\n\t// step 1. choose Datacenter and folder\n\tif err := d.chooseDatacenter(ctx, params.Datacenter); err != nil {\n\t\terr = errors.Wrap(err, \"Could not choose datacenter\")\n\t\tl.Log(\"err\", err)\n\t\treturn nil, err\n\t}\n\n\tif err := d.chooseFolder(ctx, params.Folder); err != nil {\n\t\terr = errors.Wrap(err, \"Could not choose folder\")\n\t\tl.Log(\"err\", err)\n\t\treturn nil, err\n\t}\n\n\t// step 2. choose computer resource\n\tresType := params.ComputerResources.Type\n\tresPath := params.ComputerResources.Path\n\tif err := d.chooseComputerResource(ctx, resType, resPath); err != nil {\n\t\terr = errors.Wrap(err, \"Could not choose Computer Resource\")\n\t\tl.Log(\"err\", err)\n\t\treturn nil, err\n\t}\n\n\t// step 3. Choose datastore cluster or single datastore\n\tdsType := params.Datastores.Type\n\tdsNames := params.Datastores.Names\n\tif err := d.chooseDatastore(ctx, dsType, dsNames); err != nil {\n\t\terr = errors.Wrap(err, \"Could not choose datastore\")\n\t\tl.Log(\"err\", err)\n\t\treturn nil, err\n\t}\n\n\treturn d, nil\n}", "func deploy(project, name, image, region string, envs []string, options options) (string, error) {\n\tenvVars := parseEnv(envs)\n\n\tclient, err := runClient(region)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to initialize Run API client: %w\", err)\n\t}\n\n\tsvc, err := getService(project, name, region)\n\tif err == nil {\n\t\t// existing service\n\t\tsvc = patchService(svc, envVars, image, options)\n\t\t_, err = client.Namespaces.Services.ReplaceService(\"namespaces/\"+project+\"/services/\"+name, svc).Do()\n\t\tif err != nil {\n\t\t\tif e, ok := err.(*googleapi.Error); ok {\n\t\t\t\treturn \"\", fmt.Errorf(\"failed to deploy existing Service: code=%d message=%s -- %s\", e.Code, e.Message, e.Body)\n\t\t\t}\n\t\t\treturn \"\", fmt.Errorf(\"failed to deploy to existing Service: %w\", err)\n\t\t}\n\t} else {\n\t\t// new service\n\t\tsvc := newService(name, project, image, envVars, options)\n\t\t_, err = client.Namespaces.Services.Create(\"namespaces/\"+project, svc).Do()\n\t\tif err != nil {\n\t\t\tif e, ok := err.(*googleapi.Error); ok {\n\t\t\t\treturn \"\", fmt.Errorf(\"failed to deploy a new Service: code=%d message=%s -- %s\", e.Code, e.Message, e.Body)\n\t\t\t}\n\t\t\treturn \"\", fmt.Errorf(\"failed to deploy a new Service: %w\", err)\n\t\t}\n\t}\n\n\tif options.AllowUnauthenticated == nil || *options.AllowUnauthenticated {\n\t\tif err := allowUnauthenticated(project, name, region); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to allow unauthenticated requests on the service: %w\", err)\n\t\t}\n\t}\n\n\tif err := waitReady(project, name, region); err != nil {\n\t\treturn \"\", err\n\t}\n\n\tout, err := getService(project, name, region)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get service after deploying: %w\", err)\n\t}\n\treturn out.Status.Url, nil\n}", "func Deploy(w http.ResponseWriter, r *http.Request) {\n\t// this will hold our decoded request json\n var requestParams deployStruct\n\t// let's decode request body\n decoder := json.NewDecoder(r.Body)\n err := decoder.Decode(&requestParams)\n\t// is it a bad request?\n if err != nil {\n log.Print(\"ERROR: failed to decode request JSON\")\n\t\thttp.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)\n }\n\n\t// let's forward request to docker hosts\n\tfmt.Fprintln(w, DeployAndRunContainer(&requestParams))\n}", "func (cc *BackupCommand) addFlags() {\n\tflagSet := cc.cmd.Flags()\n\thome, _ := homedir.Dir()\n\tbackPath := filepath.Join(home, \".mysshbackup\")\n\tflagSet.StringVarP(&cc.backupPath, \"path\", \"p\", backPath, \"backup path\")\n\n}", "func Deploy(d *appsv1.Deployment, forceCreate bool, client *kubernetes.Clientset) error {\n\tif forceCreate {\n\t\tif err := create(d, client); err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tif err := update(d, client); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func Deploy(ctx context.Context, cached *dialers.Cached, events chan *agent.Message, options ...Option) {\n\tvar (\n\t\ts = deploying{\n\t\t\tcState: cState{\n\t\t\t\tcached: cached,\n\t\t\t\theartbeat: time.Minute,\n\t\t\t\tconnection: &agent.ConnectionEvent{},\n\t\t\t\tFailureDisplay: FailureDisplayNoop{},\n\t\t\t\tau: aurora.NewAurora(true),\n\t\t\t\tLogger: log.New(os.Stderr, \"[CLIENT] \", 0),\n\t\t\t}.merge(options...),\n\t\t}\n\t)\n\n\ts.run(ctx, events, s)\n}", "func metadataCmd(pr *external.PluginRequest) external.PluginResponse {\n\tpluginResponse := external.PluginResponse{\n\t\tAPIVersion: \"v1alpha1\",\n\t\tCommand: \"flags\",\n\t\tUniverse: pr.Universe,\n\t}\n\n\t// Here is an example of parsing multiple flags from a Kubebuilder external plugin request\n\tflagsToParse := pflag.NewFlagSet(\"flagsFlags\", pflag.ContinueOnError)\n\tflagsToParse.Bool(\"init\", false, \"sets the init flag to true\")\n\tflagsToParse.Bool(\"api\", false, \"sets the api flag to true\")\n\tflagsToParse.Bool(\"webhook\", false, \"sets the webhook flag to true\")\n\n\tflagsToParse.Parse(pr.Args)\n\n\tinitFlag, _ := flagsToParse.GetBool(\"init\")\n\tapiFlag, _ := flagsToParse.GetBool(\"api\")\n\twebhookFlag, _ := flagsToParse.GetBool(\"webhook\")\n\n\t// The Phase 2 Plugins implementation will only ever pass a single boolean flag\n\t// argument in the JSON request `args` field. The flag will be `--init` if it is\n\t// attempting to get the flags for the `init` subcommand, `--api` for `create api`,\n\t// `--webhook` for `create webhook`, and `--edit` for `edit`\n\tif initFlag {\n\t\t// Populate the JSON response `metadata` field with a description\n\t\t// and examples for the `init` subcommand\n\t\tpluginResponse.Metadata = scaffolds.InitMeta\n\t} else if apiFlag {\n\t\tpluginResponse.Metadata = scaffolds.ApiMeta\n\t} else if webhookFlag {\n\t\tpluginResponse.Metadata = scaffolds.WebhookMeta\n\t} else {\n\t\tpluginResponse.Error = true\n\t\tpluginResponse.ErrorMsgs = []string{\n\t\t\t\"unrecognized flag\",\n\t\t}\n\t}\n\n\treturn pluginResponse\n}", "func init() {\n\tappCmd.AddCommand(appInstallCmd)\n\tappInstallCmd.Flags().StringVarP(&appInstallVersion, \"version\", \"v\", \"\", \"Specify the version of the contribution (optional)\")\n\tappInstallCmd.Flags().StringVarP(&appInstallName, \"name\", \"n\", \"\", \"The name of the contribution (required)\")\n\tappInstallCmd.Flags().BoolVarP(&appInstallPalette, \"palette\", \"p\", false, \"Install palette file\")\n\tappInstallCmd.MarkFlagRequired(\"name\")\n}", "func (r *RuntimeServer) GetDeployInfo(ctx context.Context, re *pb.ServiceRequest) (*pb.DeployInfo, error) {\n\tvar deployinfo pb.DeployInfo\n\tappService := r.store.GetAppService(re.ServiceId)\n\tif appService != nil {\n\t\tdeployinfo.Namespace = appService.TenantID\n\t\tif appService.GetStatefulSet() != nil {\n\t\t\tdeployinfo.Statefuleset = appService.GetStatefulSet().Name\n\t\t\tdeployinfo.StartTime = appService.GetStatefulSet().ObjectMeta.CreationTimestamp.Format(time.RFC3339)\n\t\t}\n\t\tif appService.GetDeployment() != nil {\n\t\t\tdeployinfo.Deployment = appService.GetDeployment().Name\n\t\t\tdeployinfo.StartTime = appService.GetDeployment().ObjectMeta.CreationTimestamp.Format(time.RFC3339)\n\t\t}\n\t\tif services := appService.GetServices(false); services != nil {\n\t\t\tservice := make(map[string]string, len(services))\n\t\t\tfor _, s := range services {\n\t\t\t\tservice[s.Name] = s.Name\n\t\t\t}\n\t\t\tdeployinfo.Services = service\n\t\t}\n\t\tif endpoints := appService.GetEndpoints(false); endpoints != nil &&\n\t\t\tappService.AppServiceBase.ServiceKind == model.ServiceKindThirdParty {\n\t\t\teps := make(map[string]string, len(endpoints))\n\t\t\tfor _, s := range endpoints {\n\t\t\t\teps[s.Name] = s.Name\n\t\t\t}\n\t\t\tdeployinfo.Endpoints = eps\n\t\t}\n\t\tif secrets := appService.GetSecrets(false); secrets != nil {\n\t\t\tsecretsinfo := make(map[string]string, len(secrets))\n\t\t\tfor _, s := range secrets {\n\t\t\t\tsecretsinfo[s.Name] = s.Name\n\t\t\t}\n\t\t\tdeployinfo.Secrets = secretsinfo\n\t\t}\n\t\tif ingresses := appService.GetIngress(false); ingresses != nil {\n\t\t\tingress := make(map[string]string, len(ingresses))\n\t\t\tfor _, s := range ingresses {\n\t\t\t\tingress[s.Name] = s.Name\n\t\t\t}\n\t\t\tdeployinfo.Ingresses = ingress\n\t\t}\n\t\tif pods := appService.GetPods(false); pods != nil {\n\t\t\tpodNames := make(map[string]string, len(pods))\n\t\t\tfor _, s := range pods {\n\t\t\t\tpodNames[s.Name] = s.Name\n\t\t\t}\n\t\t\tdeployinfo.Pods = podNames\n\t\t}\n\t\tif rss := appService.GetReplicaSets(); rss != nil {\n\t\t\trsnames := make(map[string]string, len(rss))\n\t\t\tfor _, s := range rss {\n\t\t\t\trsnames[s.Name] = s.Name\n\t\t\t}\n\t\t\tdeployinfo.Replicatset = rsnames\n\t\t}\n\t\tdeployinfo.Status = appService.GetServiceStatus()\n\t}\n\treturn &deployinfo, nil\n}", "func (c *cmdCreate) AddFlags(fs *flag.FlagSet) {\n\tfs.StringVar(&(c.fileName), \"f\", \"\", \"gateway app file\")\n\tfs.StringVar(&(c.pingport), \"pingport\", \"\", \"ping port\")\n}", "func (cmd *AddProjectCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tcc.Flags().StringVar(&cmd.Payload, \"payload\", \"\", \"Request body encoded in JSON\")\n\tcc.Flags().StringVar(&cmd.ContentType, \"content\", \"\", \"Request content type override, e.g. 'application/x-www-form-urlencoded'\")\n}", "func DeployApp(w http.ResponseWriter, r *http.Request) {\n\tparams := mux.Vars(r)\n\tstatus := params[\"status\"]\n\tlog.Printf(\"Params: %s\\n\", params)\n\n\tclientset, err := getConfig()\n\tif err != nil {\n\t\tlog.Fatalln(\"failed to get the config:\", err)\n\t}\n\n\tdeploymentsClient := clientset.AppsV1().Deployments(namespace)\n\n\tdeploymentName := params[\"app\"] + \"-deployment\"\n\n\tlist, err := deploymentsClient.List(metav1.ListOptions{})\n\tif err != nil {\n\t\tlog.Fatalln(\"failed to get deployments:\", err)\n\t}\n\n\tcontainers := []apiv1.Container{createContainer(params[\"app\"], repository+\"/\"+params[\"app\"]+appversion)}\n\n\tif status == \"true\" {\n\t\tfor _, d := range list.Items {\n\t\t\tif d.Name == deploymentName && *d.Spec.Replicas > 0 {\n\t\t\t\tlog.Printf(\"Deployment already running: %s\\n\", deploymentName)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tnodeLabel(params[\"node\"], \"app\", params[\"app\"], \"add\")\n\n\t\tdeployment := &appsv1.Deployment{\n\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\tName: deploymentName,\n\t\t\t},\n\t\t\tSpec: appsv1.DeploymentSpec{\n\t\t\t\tReplicas: int32Ptr(1),\n\t\t\t\tSelector: &metav1.LabelSelector{\n\t\t\t\t\tMatchLabels: map[string]string{\n\t\t\t\t\t\t\"app\": params[\"app\"],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tTemplate: apiv1.PodTemplateSpec{\n\t\t\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\t\t\tLabels: map[string]string{\n\t\t\t\t\t\t\t\"app\": params[\"app\"],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tSpec: apiv1.PodSpec{\n\t\t\t\t\t\tContainers: containers,\n\t\t\t\t\t\tNodeSelector: map[string]string{\n\t\t\t\t\t\t\t\"app\": params[\"app\"],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tVolumes: []apiv1.Volume{\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tName: \"mem\",\n\t\t\t\t\t\t\t\tVolumeSource: apiv1.VolumeSource{\n\t\t\t\t\t\t\t\t\tHostPath: &apiv1.HostPathVolumeSource{\n\t\t\t\t\t\t\t\t\t\tPath: \"/dev/mem\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tName: \"gpiomem\",\n\t\t\t\t\t\t\t\tVolumeSource: apiv1.VolumeSource{\n\t\t\t\t\t\t\t\t\tHostPath: &apiv1.HostPathVolumeSource{\n\t\t\t\t\t\t\t\t\t\tPath: \"/dev/gpiomem\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t\t// Create Deployment\n\t\tfmt.Println(\"Creating deployment...\")\n\t\tresult, err := deploymentsClient.Create(deployment)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tfmt.Printf(\"Created deployment %q.\\n\", result.GetObjectMeta().GetName())\n\n\t} else {\n\n\t\tnodeLabel(params[\"node\"], \"app\", params[\"app\"], \"del\")\n\n\t\tfmt.Println(\"Deleting deployment...\")\n\t\tdeletePolicy := metav1.DeletePropagationForeground\n\t\tif err := deploymentsClient.Delete(deploymentName, &metav1.DeleteOptions{\n\t\t\tPropagationPolicy: &deletePolicy,\n\t\t}); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tfmt.Println(\"Deleted deployment.\")\n\t}\n\n}", "func BuildDeployCmd() *cobra.Command {\n\tdeployCmd := BuildSvcDeployCmd()\n\tdeployCmd.Use = \"deploy\"\n\tdeployCmd.Short = \"Deploy your service.\"\n\tdeployCmd.Long = `Command for deploying services to your environments.`\n\tdeployCmd.Example = `\n\tDeploys a service named \"frontend\" to a \"test\" environment.\n\t/code $ copilot deploy --name frontend --env test`\n\n\tdeployCmd.SetUsageTemplate(template.Usage)\n\n\tdeployCmd.Annotations = map[string]string{\n\t\t\"group\": group.Release,\n\t}\n\treturn deployCmd\n}", "func setupAddCommand(cmd *cobra.Command) {\n\tcmd.Flags().String(\"record\", \"\", \"Record Name\")\n\n\tif err := cmd.MarkFlagRequired(\"record\"); err != nil {\n\t\tlog.Fatalf(\"Lethal damage: %s\\n\\n\", err)\n\t}\n\n\tcmd.Flags().String(\"zone\", \"\", \"Zone Name\")\n\n\tif err := cmd.MarkFlagRequired(\"zone\"); err != nil {\n\t\tlog.Fatalf(\"Lethal damage: %s\\n\\n\", err)\n\t}\n\n\tcmd.Flags().String(\"dns-provider\", \"\", \"DNS Provider\")\n\n\tif err := cmd.MarkFlagRequired(\"dns-provider\"); err != nil {\n\t\tlog.Fatalf(\"Lethal damage: %s\\n\\n\", err)\n\t}\n\n\tcmd.Flags().String(\"ip-provider\", \"google\", \"IP Provider\")\n\tcmd.Flags().Int(\"interval\", 1, \"Interval in Minutes\")\n\tcmd.Flags().Bool(\"daemon\", false, \"Daemon\")\n}", "func deployJob(cmd *cobra.Command, args []string) {\n\tport, _ := cmd.Flags().GetString(\"port\")\n\tif port == \"\" {\n\t\tport = DefaultPort\n\t}\n\tname, _ := cmd.Flags().GetString(\"file\")\n\tyaml := unmarsharlYaml(readJobFile(name))\n if !semanticCheck(yaml) {\n os.Exit(2)\n }\n\tcurrentDir, _ := os.Getwd()\n\tvar job NewJob\n\tjob.ID = yaml.Job.ID\n\tjob.UID = fmt.Sprint(syscall.Getuid())\n\tgroup, _ := user.LookupGroup(\"odin\")\n\tgid, _ := strconv.Atoi(group.Gid)\n\tjob.GID = strconv.Itoa(gid)\n\tjob.Name = yaml.Job.Name\n\tjob.Description = yaml.Job.Description\n\tjob.File = currentDir + \"/\" + yaml.Job.File\n\tif yaml.Job.Language == \"go\" {\n\t\tjob.Language = yaml.Job.Language\n\t\tcmd := exec.Command(job.Language, \"build\", job.File)\n\t\tcmd.SysProcAttr = &syscall.SysProcAttr{}\n\t\t_, err := cmd.CombinedOutput()\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tos.Exit(2)\n\t\t}\n\t\tjob.File = job.File[:len(job.File)-3]\n\t} else {\n\t\tjob.Language = yaml.Job.Language\n\t}\n\tjob.Schedule = getScheduleString(name, port)\n\tjobJSON, _ := json.Marshal(job)\n\tbody := makePostRequest(fmt.Sprintf(\"http://localhost%s/jobs/add\", port), bytes.NewBuffer(jobJSON))\n\tfmt.Println(body)\n}", "func (c *Client) deploy(context context.Context, spec *DeployFunctionSpec, update bool) (int, string) {\n\n\tvar deployOutput string\n\t// Need to alter Gateway to allow nil/empty string as fprocess, to avoid this repetition.\n\tvar fprocessTemplate string\n\tif len(spec.FProcess) > 0 {\n\t\tfprocessTemplate = spec.FProcess\n\t}\n\n\tif spec.Replace {\n\t\tc.DeleteFunction(context, spec.FunctionName, spec.Namespace)\n\t}\n\n\treq := types.FunctionDeployment{\n\t\tEnvProcess: fprocessTemplate,\n\t\tImage: spec.Image,\n\t\tRegistryAuth: spec.RegistryAuth,\n\t\tNetwork: spec.Network,\n\t\tService: spec.FunctionName,\n\t\tEnvVars: spec.EnvVars,\n\t\tConstraints: spec.Constraints,\n\t\tSecrets: spec.Secrets,\n\t\tLabels: &spec.Labels,\n\t\tAnnotations: &spec.Annotations,\n\t\tReadOnlyRootFilesystem: spec.ReadOnlyRootFilesystem,\n\t\tNamespace: spec.Namespace,\n\t}\n\n\thasLimits := false\n\treq.Limits = &types.FunctionResources{}\n\tif spec.FunctionResourceRequest.Limits != nil && len(spec.FunctionResourceRequest.Limits.Memory) > 0 {\n\t\thasLimits = true\n\t\treq.Limits.Memory = spec.FunctionResourceRequest.Limits.Memory\n\t}\n\tif spec.FunctionResourceRequest.Limits != nil && len(spec.FunctionResourceRequest.Limits.CPU) > 0 {\n\t\thasLimits = true\n\t\treq.Limits.CPU = spec.FunctionResourceRequest.Limits.CPU\n\t}\n\tif !hasLimits {\n\t\treq.Limits = nil\n\t}\n\n\thasRequests := false\n\treq.Requests = &types.FunctionResources{}\n\tif spec.FunctionResourceRequest.Requests != nil && len(spec.FunctionResourceRequest.Requests.Memory) > 0 {\n\t\thasRequests = true\n\t\treq.Requests.Memory = spec.FunctionResourceRequest.Requests.Memory\n\t}\n\tif spec.FunctionResourceRequest.Requests != nil && len(spec.FunctionResourceRequest.Requests.CPU) > 0 {\n\t\thasRequests = true\n\t\treq.Requests.CPU = spec.FunctionResourceRequest.Requests.CPU\n\t}\n\n\tif !hasRequests {\n\t\treq.Requests = nil\n\t}\n\n\treqBytes, _ := json.Marshal(&req)\n\treader := bytes.NewReader(reqBytes)\n\tvar request *http.Request\n\n\tmethod := http.MethodPost\n\t// \"application/json\"\n\tif update {\n\t\tmethod = http.MethodPut\n\t}\n\n\tvar err error\n\trequest, err = c.newRequest(method, \"/system/functions\", reader)\n\n\tif err != nil {\n\t\tdeployOutput += fmt.Sprintln(err)\n\t\treturn http.StatusInternalServerError, deployOutput\n\t}\n\n\tres, err := c.doRequest(context, request)\n\n\tif err != nil {\n\t\tdeployOutput += fmt.Sprintln(\"Is OpenFaaS deployed? Do you need to specify the --gateway flag?\")\n\t\tdeployOutput += fmt.Sprintln(err)\n\t\treturn http.StatusInternalServerError, deployOutput\n\t}\n\n\tif res.Body != nil {\n\t\tdefer res.Body.Close()\n\t}\n\n\tswitch res.StatusCode {\n\tcase http.StatusOK, http.StatusCreated, http.StatusAccepted:\n\t\tdeployOutput += fmt.Sprintf(\"Deployed. %s.\\n\", res.Status)\n\n\t\tdeployedURL := fmt.Sprintf(\"URL: %s/function/%s\", c.GatewayURL.String(), generateFuncStr(spec))\n\t\tdeployOutput += fmt.Sprintln(deployedURL)\n\tcase http.StatusUnauthorized:\n\t\tdeployOutput += fmt.Sprintln(\"unauthorized access, run \\\"faas-cli login\\\" to setup authentication for this server\")\n\n\tdefault:\n\t\tbytesOut, err := ioutil.ReadAll(res.Body)\n\t\tif err == nil {\n\t\t\tdeployOutput += fmt.Sprintf(\"Unexpected status: %d, message: %s\\n\", res.StatusCode, string(bytesOut))\n\t\t}\n\t}\n\n\treturn res.StatusCode, deployOutput\n}", "func (client *Client) Deploy(state, creds []byte, detach bool) (newState, newCreds []byte, err error) {\n\tbosh, err := boshenv.New(boshenv.DownloadBOSH())\n\tif err != nil {\n\t\treturn state, creds, err\n\t}\n\n\tstate, creds, err = client.createEnv(bosh, state, creds)\n\tif err != nil {\n\t\treturn state, creds, err\n\t}\n\n\tif err = client.updateCloudConfig(bosh); err != nil {\n\t\treturn state, creds, err\n\t}\n\tif err = client.uploadConcourseStemcell(bosh); err != nil {\n\t\treturn state, creds, err\n\t}\n\tif err = client.createDefaultDatabases(); err != nil {\n\t\treturn state, creds, err\n\t}\n\n\tcreds, err = client.deployConcourse(creds, detach)\n\tif err != nil {\n\t\treturn state, creds, err\n\t}\n\n\treturn state, creds, err\n}", "func (c *DetaClient) Deploy(r *DeployRequest) (*DeployResponse, error) {\n\theaders := make(map[string]string)\n\tc.injectResourceHeader(headers, r.Account, r.Region)\n\n\ti := &requestInput{\n\t\tPath: fmt.Sprintf(\"/%s/\", patcherPath),\n\t\tMethod: \"POST\",\n\t\tHeaders: headers,\n\t\tBody: r,\n\t\tNeedsAuth: true,\n\t}\n\to, err := c.request(i)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif o.Status != 200 {\n\t\tmsg := o.Error.Message\n\t\tif msg == \"\" {\n\t\t\tmsg = o.Error.Errors[0]\n\t\t}\n\t\treturn nil, fmt.Errorf(\"failed to deploy: %v\", msg)\n\t}\n\n\tvar resp DeployResponse\n\terr = json.Unmarshal(o.Body, &resp)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to deploy: %v\", err)\n\t}\n\treturn &resp, nil\n}", "func (cmd *AddFirmwareCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tcc.Flags().StringVar(&cmd.Payload, \"payload\", \"\", \"Request body encoded in JSON\")\n\tcc.Flags().StringVar(&cmd.ContentType, \"content\", \"\", \"Request content type override, e.g. 'application/x-www-form-urlencoded'\")\n}", "func (b *taskBuilder) cmd(c ...string) {\n\tb.Spec.Command = c\n}", "func (c *Canary) Deploy(config schemas.Config) error {\n\tif !c.StepStatus[constants.StepCheckPrevious] {\n\t\treturn nil\n\t}\n\tc.Logger.Infof(\"Deploy Mode is %s\", c.Mode)\n\n\t//Get LocalFileProvider\n\tc.LocalProvider = builder.SetUserdataProvider(c.Stack.Userdata, c.AwsConfig.Userdata)\n\tfor i, region := range c.Stack.Regions {\n\t\t//Region check\n\t\t//If region id is passed from command line, then deployer will deploy in that region only.\n\t\tif config.Region != \"\" && config.Region != region.Region {\n\t\t\tc.Logger.Debugf(\"This region is skipped by user : %s\", region.Region)\n\t\t\tcontinue\n\t\t}\n\n\t\tif err := c.ValidateCanaryDeployment(config, region.Region); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tlatestASG := c.LatestAsg[region.Region]\n\t\ttargetGroups, err := c.GetAsgTargetGroups(latestASG, region.Region)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tcanaryVersion := CheckCanaryVersion(targetGroups, region.Region)\n\t\tc.Logger.Debugf(\"Current canary version: %d\", canaryVersion)\n\n\t\tselectedTargetGroup := c.SelectTargetGroupForCopy(region, canaryVersion)\n\t\tc.Logger.Debugf(\"Selected target group to copy: %s\", selectedTargetGroup)\n\n\t\ttgDetail, err := c.DescribeTargetGroup(selectedTargetGroup, region.Region)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Check canary load balancer\n\t\tlbSg, canaryLoadBalancer, err := c.GetLoadBalancerAndSecurityGroupForCanary(region, tgDetail, config.CompleteCanary)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Create canary security group\n\t\terr = c.GetEC2CanarySecurityGroup(tgDetail, region, lbSg, config.CompleteCanary)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tswitch config.CompleteCanary {\n\t\tcase true:\n\t\t\tif err := c.CompleteCanaryDeployment(config, region, latestASG); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase false:\n\t\t\tchangedRegionConfig, err := c.RunCanaryDeployment(config, region, tgDetail, canaryLoadBalancer, canaryVersion)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tc.Stack.Regions[i] = changedRegionConfig\n\t\t}\n\t}\n\n\tc.StepStatus[constants.StepDeploy] = true\n\treturn nil\n}", "func (d *Deployment) PostDeploy(version string) (string, error) {\n\tif os.Geteuid() == 0 && d.cfg.Insecure {\n\t\treturn \"\", fmt.Errorf(\n\t\t\t\"Refusing to execute post-deploy command from insecure %q configuration as root\",\n\t\t\td.appName)\n\t}\n\tif d.cfg.Scripts[\"postdeploy\"].Cmd != \"\" {\n\t\tartifactPath, _ := makeArtifactPath(d.artifactDir, d.appName, version, d.acfg.Extension)\n\t\tversionDir, _ := makeReleasePath(d.releaseDir, version)\n\t\tcmdlineArgs := substituteVars(d.cfg.Scripts[\"postdeploy\"].Args,\n\t\t\tvarValues{artifactPath: artifactPath, versionDir: versionDir})\n\t\treturn sysCommand(versionDir, d.cfg.Scripts[\"postdeploy\"].Cmd, cmdlineArgs)\n\t}\n\treturn \"\", nil\n}", "func NewDeployEnvCmd(out io.Writer) *cobra.Command {\n\te := &envCmd{out: out}\n\n\tcmd := &cobra.Command{\n\t\tUse: \"env\",\n\t\tAliases: []string{\"environment\"},\n\t\tShort: \"Deploy a list of Helm charts to an environment (Kubernetes namespace)\",\n\t\tLong: ``,\n\t\tArgs: func(cmd *cobra.Command, args []string) error {\n\t\t\tif e.name == \"\" {\n\t\t\t\treturn errors.New(\"name can not be empty\")\n\t\t\t}\n\t\t\tif e.repo == \"\" {\n\t\t\t\treturn errors.New(\"repo can not be empty\")\n\t\t\t}\n\t\t\tif e.tls {\n\t\t\t\tif e.helmTLSStore == \"\" {\n\t\t\t\t\treturn errors.New(\"tls is set to true and helm-tls-store is not defined\")\n\t\t\t\t}\n\t\t\t\tif e.kubeContext == \"\" {\n\t\t\t\t\treturn errors.New(\"kube-context has to be non-empty when tls is set to true\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tif len(e.override) == 0 {\n\t\t\t\tif e.chartsFile == \"\" {\n\t\t\t\t\treturn errors.New(\"either charts-file or override has to be defined\")\n\t\t\t\t}\n\t\t\t\tif e.deployOnlyOverrideIfEnvExists {\n\t\t\t\t\treturn errors.New(\"override has to be defined when using using deploy-only-override-if-env-exists\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tif e.chartsFile != \"\" && utils.CheckCircularDependencies(utils.InitReleasesFromChartsFile(e.chartsFile, e.name)) {\n\t\t\t\treturn errors.New(\"Circular dependency found\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t\tRun: func(cmd *cobra.Command, args []string) {\n\n\t\t\tlog.Println(\"initializing chart repository configuration\")\n\t\t\tif err := utils.AddRepository(utils.AddRepositoryOptions{\n\t\t\t\tRepo: e.repo,\n\t\t\t\tPrint: false,\n\t\t\t}); err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t\tif err := utils.UpdateRepositories(false); err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\n\t\t\tlog.Printf(\"deploying environment \\\"%s\\\"\", e.name)\n\t\t\tnsPreExists, err := utils.NamespaceExists(e.name, e.kubeContext)\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t\tif !nsPreExists {\n\t\t\t\tif err := utils.CreateNamespace(e.name, e.kubeContext, false); err != nil {\n\t\t\t\t\tlog.Fatal(err)\n\t\t\t\t}\n\t\t\t\tlog.Printf(\"created environment \\\"%s\\\"\", e.name)\n\t\t\t}\n\t\t\tif err := lockEnvironment(e.name, e.kubeContext, true); err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\n\t\t\tannotations := map[string]string{}\n\t\t\tfor _, a := range e.annotations {\n\t\t\t\tk, v := utils.SplitInTwo(a, \"=\")\n\t\t\t\tannotations[k] = v\n\t\t\t}\n\t\t\tlabels := map[string]string{}\n\t\t\tfor _, a := range e.labels {\n\t\t\t\tk, v := utils.SplitInTwo(a, \"=\")\n\t\t\t\tlabels[k] = v\n\t\t\t}\n\t\t\tif err := utils.UpdateNamespace(e.name, e.kubeContext, annotations, labels, true); err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\n\t\t\tlog.Print(\"initializing releases to deploy\")\n\t\t\tvar desiredReleases []utils.ReleaseSpec\n\t\t\tif nsPreExists && e.deployOnlyOverrideIfEnvExists {\n\t\t\t\tdesiredReleases = utils.InitReleases(e.name, e.override)\n\t\t\t} else {\n\t\t\t\tif e.chartsFile != \"\" {\n\t\t\t\t\tdesiredReleases = utils.InitReleasesFromChartsFile(e.chartsFile, e.name)\n\t\t\t\t}\n\t\t\t\tdesiredReleases = utils.OverrideReleases(desiredReleases, e.override, e.name)\n\t\t\t}\n\n\t\t\tlog.Print(\"getting currently deployed releases\")\n\t\t\tinstalledReleases, err := utils.GetInstalledReleases(utils.GetInstalledReleasesOptions{\n\t\t\t\tKubeContext: e.kubeContext,\n\t\t\t\tNamespace: e.name,\n\t\t\t\tIncludeFailed: false,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\tunlockEnvironment(e.name, e.kubeContext, true)\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\n\t\t\tlog.Print(\"updating protected charts\")\n\t\t\tprotectedCharts, err := updateProtectedCharts(e.name, e.kubeContext, e.protectedCharts, true)\n\t\t\tif err != nil {\n\t\t\t\tunlockEnvironment(e.name, e.kubeContext, true)\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\n\t\t\tfor _, ir := range installedReleases {\n\t\t\t\tfor _, pc := range protectedCharts {\n\t\t\t\t\tif pc != ir.ChartName {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tdesiredReleases = utils.OverrideReleases(desiredReleases, []string{ir.ChartName + \"=\" + ir.ChartVersion}, e.name)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlog.Print(\"calculating delta between desired releases and currently deployed releases\")\n\t\t\treleasesToInstall := utils.GetReleasesDelta(desiredReleases, installedReleases)\n\n\t\t\tlog.Print(\"deploying releases\")\n\t\t\tif err := utils.DeployChartsFromRepository(utils.DeployChartsFromRepositoryOptions{\n\t\t\t\tReleasesToInstall: releasesToInstall,\n\t\t\t\tKubeContext: e.kubeContext,\n\t\t\t\tNamespace: e.name,\n\t\t\t\tRepo: e.repo,\n\t\t\t\tTLS: e.tls,\n\t\t\t\tHelmTLSStore: e.helmTLSStore,\n\t\t\t\tPackedValues: e.packedValues,\n\t\t\t\tSetValues: e.set,\n\t\t\t\tInject: e.inject,\n\t\t\t\tParallel: e.parallel,\n\t\t\t\tTimeout: e.timeout,\n\t\t\t}); err != nil {\n\t\t\t\tmarkEnvironmentAsFailed(e.name, e.kubeContext, true)\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\n\t\t\tif !e.deployOnlyOverrideIfEnvExists {\n\t\t\t\tlog.Print(\"getting currently deployed releases\")\n\t\t\t\tinstalledReleases, err := utils.GetInstalledReleases(utils.GetInstalledReleasesOptions{\n\t\t\t\t\tKubeContext: e.kubeContext,\n\t\t\t\t\tNamespace: e.name,\n\t\t\t\t\tIncludeFailed: false,\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\tmarkEnvironmentAsUnknown(e.name, e.kubeContext, true)\n\t\t\t\t\tlog.Fatal(err)\n\t\t\t\t}\n\t\t\t\tlog.Print(\"calculating delta between desired releases and currently deployed releases\")\n\t\t\t\treleasesToDelete := utils.GetReleasesDelta(installedReleases, desiredReleases)\n\t\t\t\tlog.Print(\"deleting undesired releases\")\n\t\t\t\tif err := utils.DeleteReleases(utils.DeleteReleasesOptions{\n\t\t\t\t\tReleasesToDelete: releasesToDelete,\n\t\t\t\t\tKubeContext: e.kubeContext,\n\t\t\t\t\tTLS: e.tls,\n\t\t\t\t\tHelmTLSStore: e.helmTLSStore,\n\t\t\t\t\tParallel: e.parallel,\n\t\t\t\t\tTimeout: e.timeout,\n\t\t\t\t}); err != nil {\n\t\t\t\t\tmarkEnvironmentAsFailed(e.name, e.kubeContext, true)\n\t\t\t\t\tlog.Fatal(err)\n\t\t\t\t}\n\t\t\t}\n\t\t\tlog.Printf(\"deployed environment \\\"%s\\\"\", e.name)\n\n\t\t\tvar envValid bool\n\t\t\tif e.validate {\n\t\t\t\tenvValid, err = utils.IsEnvValidWithLoopBackOff(e.name, e.kubeContext)\n\t\t\t}\n\n\t\t\tunlockEnvironment(e.name, e.kubeContext, true)\n\n\t\t\tif !e.validate {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t\tif !envValid {\n\t\t\t\tmarkEnvironmentAsFailed(e.name, e.kubeContext, true)\n\t\t\t\tlog.Fatalf(\"environment \\\"%s\\\" validation failed!\", e.name)\n\t\t\t}\n\t\t\t// If we have made it so far, the environment is validated\n\t\t\tlog.Printf(\"environment \\\"%s\\\" validated!\", e.name)\n\t\t},\n\t}\n\n\tf := cmd.Flags()\n\n\tf.StringVarP(&e.chartsFile, \"charts-file\", \"c\", os.Getenv(\"ORCA_CHARTS_FILE\"), \"path to file with list of Helm charts to install. Overrides $ORCA_CHARTS_FILE\")\n\tf.StringSliceVar(&e.override, \"override\", []string{}, \"chart to override with different version (can specify multiple): chart=version\")\n\tf.StringVarP(&e.name, \"name\", \"n\", os.Getenv(\"ORCA_NAME\"), \"name of environment (namespace) to deploy to. Overrides $ORCA_NAME\")\n\tf.StringVar(&e.repo, \"repo\", os.Getenv(\"ORCA_REPO\"), \"chart repository (name=url). Overrides $ORCA_REPO\")\n\tf.StringVar(&e.kubeContext, \"kube-context\", os.Getenv(\"ORCA_KUBE_CONTEXT\"), \"name of the kubeconfig context to use. Overrides $ORCA_KUBE_CONTEXT\")\n\tf.StringSliceVarP(&e.packedValues, \"values\", \"f\", []string{}, \"values file to use (packaged within the chart)\")\n\tf.StringSliceVarP(&e.set, \"set\", \"s\", []string{}, \"set additional parameters\")\n\tf.BoolVar(&e.tls, \"tls\", utils.GetBoolEnvVar(\"ORCA_TLS\", false), \"enable TLS for request. Overrides $ORCA_TLS\")\n\tf.StringVar(&e.helmTLSStore, \"helm-tls-store\", os.Getenv(\"HELM_TLS_STORE\"), \"path to TLS certs and keys. Overrides $HELM_TLS_STORE\")\n\tf.BoolVar(&e.inject, \"inject\", utils.GetBoolEnvVar(\"ORCA_INJECT\", false), \"enable injection during helm upgrade. Overrides $ORCA_INJECT (requires helm inject plugin: https://github.com/maorfr/helm-inject)\")\n\tf.IntVarP(&e.parallel, \"parallel\", \"p\", utils.GetIntEnvVar(\"ORCA_PARALLEL\", 1), \"number of releases to act on in parallel. set this flag to 0 for full parallelism. Overrides $ORCA_PARALLEL\")\n\tf.IntVar(&e.timeout, \"timeout\", utils.GetIntEnvVar(\"ORCA_TIMEOUT\", 300), \"time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks). Overrides $ORCA_TIMEOUT\")\n\tf.StringSliceVar(&e.annotations, \"annotations\", []string{}, \"additional environment (namespace) annotations (can specify multiple): annotation=value\")\n\tf.StringSliceVar(&e.labels, \"labels\", []string{}, \"environment (namespace) labels (can specify multiple): label=value\")\n\tf.BoolVar(&e.validate, \"validate\", utils.GetBoolEnvVar(\"ORCA_VALIDATE\", false), \"perform environment validation after deployment. Overrides $ORCA_VALIDATE\")\n\tf.BoolVarP(&e.deployOnlyOverrideIfEnvExists, \"deploy-only-override-if-env-exists\", \"x\", utils.GetBoolEnvVar(\"ORCA_DEPLOY_ONLY_OVERRIDE_IF_ENV_EXISTS\", false), \"if environment exists - deploy only override(s) (avoid environment update). Overrides $ORCA_DEPLOY_ONLY_OVERRIDE_IF_ENV_EXISTS\")\n\tf.StringSliceVar(&e.protectedCharts, \"protected-chart\", []string{}, \"chart name to protect from being overridden (can specify multiple)\")\n\n\tf.BoolVar(&e.refresh, \"refresh\", utils.GetBoolEnvVar(\"ORCA_REFRESH\", false), \"refresh the environment based on reference environment. Overrides $ORCA_REFRESH\")\n\tf.MarkDeprecated(\"refresh\", \"this is now the default behavior. use -x to deploy only overrides\")\n\treturn cmd\n}", "func Execute(name string, args []string) {\n\topttar := false\n\topttgz := false\n\toptvhdx := false\n\toptvhdxgz := false\n\toptreg := false\n\tswitch len(args) {\n\tcase 0:\n\t\t_, _, flags, _ := wsllib.WslGetDistributionConfiguration(name)\n\t\tif flags&wsllib.FlagEnableWsl2 == wsllib.FlagEnableWsl2 {\n\t\t\toptvhdxgz = true\n\t\t\toptreg = true\n\t\t} else {\n\t\t\topttgz = true\n\t\t\toptreg = true\n\t\t}\n\n\tcase 1:\n\t\tswitch args[0] {\n\t\tcase \"--tar\":\n\t\t\topttar = true\n\t\tcase \"--tgz\":\n\t\t\topttgz = true\n\t\tcase \"--vhdx\":\n\t\t\toptvhdx = true\n\t\tcase \"--vhdxgz\":\n\t\t\toptvhdxgz = true\n\t\tcase \"--reg\":\n\t\t\toptreg = true\n\t\t}\n\n\tdefault:\n\t\tutils.ErrorExit(os.ErrInvalid, true, true, false)\n\t}\n\n\tif optreg {\n\t\terr := backupReg(name, \"backup.reg\")\n\t\tif err != nil {\n\t\t\tutils.ErrorExit(err, true, true, false)\n\t\t}\n\t}\n\tif opttar {\n\t\terr := backupTar(name, \"backup.tar\")\n\t\tif err != nil {\n\t\t\tutils.ErrorExit(err, true, true, false)\n\t\t}\n\n\t}\n\tif opttgz {\n\t\terr := backupTar(name, \"backup.tar.gz\")\n\t\tif err != nil {\n\t\t\tutils.ErrorExit(err, true, true, false)\n\t\t}\n\t}\n\tif optvhdx {\n\t\terr := backupExt4Vhdx(name, \"backup.ext4.vhdx\")\n\t\tif err != nil {\n\t\t\tutils.ErrorExit(err, true, true, false)\n\t\t}\n\t}\n\tif optvhdxgz {\n\t\terr := backupExt4Vhdx(name, \"backup.ext4.vhdx.gz\")\n\t\tif err != nil {\n\t\t\tutils.ErrorExit(err, true, true, false)\n\t\t}\n\t}\n}", "func (c *BlueGreenDeployCommand) GetPluginCommand() plugin.Command {\n\treturn plugin.Command{\n\t\tName: \"bg-deploy\",\n\t\tHelpText: \"Deploy a multi-target app using blue-green deployment\",\n\t\tUsageDetails: plugin.Usage{\n\t\t\tUsage: `Deploy a multi-target app using blue-green deployment\n cf bg-deploy MTA [-e EXT_DESCRIPTOR[,...]] [-t TIMEOUT] [--version-rule VERSION_RULE] [-u URL] [-f] [--no-start] [--use-namespaces] [--no-namespaces-for-services] [--delete-services] [--delete-service-keys] [--delete-service-brokers] [--keep-files] [--no-restart-subscribed-apps] [--no-confirm] [--do-not-fail-on-missing-permissions] [--abort-on-error]\n\n Perform action on an active deploy operation\n cf deploy -i OPERATION_ID -a ACTION [-u URL]`,\n\t\t\tOptions: map[string]string{\n\t\t\t\textDescriptorsOpt: \"Extension descriptors\",\n\t\t\t\tdeployServiceURLOpt: \"Deploy service URL, by default 'deploy-service.<system-domain>'\",\n\t\t\t\ttimeoutOpt: \"Start timeout in seconds\",\n\t\t\t\tversionRuleOpt: \"Version rule (HIGHER, SAME_HIGHER, ALL)\",\n\t\t\t\toperationIDOpt: \"Active deploy operation id\",\n\t\t\t\tactionOpt: \"Action to perform on active deploy operation (abort, retry, monitor)\",\n\t\t\t\tforceOpt: \"Force deploy without confirmation for aborting conflicting processes\",\n\t\t\t\tutil.GetShortOption(noStartOpt): \"Do not start apps\",\n\t\t\t\tutil.GetShortOption(useNamespacesOpt): \"Use namespaces in app and service names\",\n\t\t\t\tutil.GetShortOption(noNamespacesForServicesOpt): \"Do not use namespaces in service names\",\n\t\t\t\tutil.GetShortOption(deleteServicesOpt): \"Recreate changed services / delete discontinued services\",\n\t\t\t\tutil.GetShortOption(deleteServiceKeysOpt): \"Delete existing service keys and apply the new ones\",\n\t\t\t\tutil.GetShortOption(deleteServiceBrokersOpt): \"Delete discontinued service brokers\",\n\t\t\t\tutil.GetShortOption(keepFilesOpt): \"Keep files used for deployment\",\n\t\t\t\tutil.GetShortOption(noRestartSubscribedAppsOpt): \"Do not restart subscribed apps, updated during the deployment\",\n\t\t\t\tutil.GetShortOption(noConfirmOpt): \"Do not require confirmation for deleting the previously deployed MTA apps\",\n\t\t\t\tutil.GetShortOption(noFailOnMissingPermissionsOpt): \"Do not fail on missing permissions for admin operations\",\n\t\t\t\tutil.GetShortOption(abortOnErrorOpt): \"Auto-abort the process on any errors\",\n\t\t\t},\n\t\t},\n\t}\n}", "func registerDeployAPIs(ws *restful.WebService) {\n\tws.Route(ws.POST(\"/{user_id}/deploys\").\n\t\tTo(createDeploy).\n\t\tDoc(\"create a deploy for given user of a specific service\").\n\t\tParam(ws.PathParameter(\"user_id\", \"identifier of the user\").DataType(\"string\")).\n\t\tReads(api.Deploy{}).\n\t\tWrites(api.DeployCreationResponse{}))\n\n\t// Filter the unauthorized operation.\n\tws.Route(ws.GET(\"/{user_id}/deploys/{deploy_id}\").\n\t\tTo(getDeploy).\n\t\tDoc(\"find a deploy by id for given user\").\n\t\tParam(ws.PathParameter(\"user_id\", \"identifier of the user\").DataType(\"string\")).\n\t\tParam(ws.PathParameter(\"deploy_id\", \"identifier of the deploy\").DataType(\"string\")).\n\t\tWrites(api.DeployGetResponse{}))\n\n\t// Filter the unauthorized operation.\n\tws.Route(ws.GET(\"/{user_id}/deploys\").\n\t\tTo(listDeploy).\n\t\tDoc(\"find deploys by id for given user\").\n\t\tParam(ws.PathParameter(\"user_id\", \"identifier of the user\").DataType(\"string\")).\n\t\tWrites(api.DeployListResponse{}))\n\n\t// Filter the unauthorized operation.\n\tws.Route(ws.PUT(\"/{user_id}/deploys/{deploy_id}\").\n\t\tTo(setDeploy).\n\t\tDoc(\"set a deploy by id for given user\").\n\t\tParam(ws.PathParameter(\"user_id\", \"identifier of the user\").DataType(\"string\")).\n\t\tParam(ws.PathParameter(\"deploy_id\", \"identifier of the deploy\").DataType(\"string\")).\n\t\tWrites(api.DeploySetResponse{}))\n\n\t// Filter the unauthorized operation.\n\tws.Route(ws.DELETE(\"/{user_id}/deploys/{deploy_id}\").\n\t\tTo(delDeploy).\n\t\tDoc(\"delete a deploy by id for given user\").\n\t\tParam(ws.PathParameter(\"user_id\", \"identifier of the user\").DataType(\"string\")).\n\t\tParam(ws.PathParameter(\"deploy_id\", \"identifier of the deploy\").DataType(\"string\")).\n\t\tWrites(api.DeployDelResponse{}))\n}", "func NewAddManifestDeployItemCommand(ctx context.Context) *cobra.Command {\n\topts := &addManifestDeployItemOptions{}\n\tcmd := &cobra.Command{\n\t\tUse: addManifestDeployItemUse,\n\t\tExample: addManifestDeployItemExample,\n\t\tShort: addManifestDeployItemShort,\n\t\tArgs: cobra.ExactArgs(1),\n\n\t\tRun: func(cmd *cobra.Command, args []string) {\n\t\t\tif err := opts.Complete(args); err != nil {\n\t\t\t\tfmt.Println(err.Error())\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\n\t\t\tif err := opts.run(ctx, logger.Log); err != nil {\n\t\t\t\tfmt.Println(err.Error())\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\n\t\t\tfmt.Printf(\"Deploy item added\")\n\t\t\tfmt.Printf(\" \\n- deploy item definition in blueprint folder in file %s created\", util.ExecutionFileName(opts.deployItemName))\n\t\t\tfmt.Printf(\" \\n- file reference to deploy item definition added to blueprint\")\n\t\t\tfmt.Printf(\" \\n- import definitions added to blueprint\")\n\t\t},\n\t}\n\n\topts.AddFlags(cmd.Flags())\n\n\treturn cmd\n}", "func (*bzlLibraryLang) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config) {}", "func Setup(c *exec.Cmd) {}", "func (s *deployerService) deploy(ctx context.Context, db *gorm.DB, opts DeploymentsCreateOpts) (*Release, error) {\n\tapp, img := opts.App, opts.Image\n\n\t// If no app is specified, attempt to find the app that relates to this\n\t// images repository, or create it if not found.\n\tif app == nil {\n\t\tvar err error\n\t\tapp, err = appsFindOrCreateByRepo(db, img.Repository)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\t// If the app doesn't already have a repo attached to it, we'll attach\n\t\t// this image's repo.\n\t\tif err := appsEnsureRepo(db, app, img.Repository); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Grab the latest config.\n\tconfig, err := s.configs.Config(db, app)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create a new slug for the docker image.\n\tslug, err := s.slugs.Create(ctx, db, img, opts.Output)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create a new release for the Config\n\t// and Slug.\n\tdesc := fmt.Sprintf(\"Deploy %s\", img.String())\n\n\tr, err := s.releases.Create(ctx, db, &Release{\n\t\tApp: app,\n\t\tConfig: config,\n\t\tSlug: slug,\n\t\tDescription: desc,\n\t})\n\n\treturn r, err\n}", "func (client *WebAppsClient) createMSDeployOperationCreateRequest(ctx context.Context, resourceGroupName string, name string, msDeploy MSDeploy, options *WebAppsBeginCreateMSDeployOperationOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/extensions/MSDeploy\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-02-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, msDeploy)\n}", "func (mgr *manager) DeploySvc(svcCfg anysched.SvcCfg) (anysched.Operation, error) {\n\tcount := uint64(svcCfg.Count)\n\tservice := swarm.ServiceSpec{\n\t\tAnnotations: swarm.Annotations{\n\t\t\tName: svcCfg.ID,\n\t\t},\n\t\tMode: swarm.ServiceMode{\n\t\t\tReplicated: &swarm.ReplicatedService{\n\t\t\t\tReplicas: &count,\n\t\t\t},\n\t\t},\n\t\tTaskTemplate: swarm.TaskSpec{\n\t\t\tContainerSpec: swarm.ContainerSpec{\n\t\t\t\tImage: svcCfg.Image,\n\t\t\t},\n\t\t},\n\t}\n\toptions := types.ServiceCreateOptions{}\n\tserviceCreateResponse, err := mgr.client.ServiceCreate(ctx, service, options)\n\tfmt.Printf(\"*** serviceCreateResponse = %+v; err = %+v\\n\", serviceCreateResponse, err)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"dockerswarm.manager.DeploySvc: mgr.client.ServiceCreate failed\")\n\t}\n\treturn nil, nil\n}", "func CreateDeploy(w http.ResponseWriter, r *http.Request) {\n\tdeploy := models.Deploy{}\n\terr := json.NewDecoder(r.Body).Decode(&deploy)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Todo validate requirement id\n\n\terr = models.InsertDeploy(deploy)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tw.WriteHeader(200)\n\terr = json.NewEncoder(w).Encode(deploy)\n\tif err != nil {\n\t\tpanic(error(err))\n\t}\n}", "func folderDeploy(cmd *cobra.Command, args []string) {\n\t//Check deploy template file.\n\tif len(args) <= 0 || utils.IsFileExist(args[0]) == false {\n\t\tfmt.Fprintf(os.Stderr, \"the template files path is required, %s\\n\", \"see https://github.com/Huawei/containerops/singular for more detail.\")\n\t\tos.Exit(1)\n\t}\n\n\tif utils.IsDirExist(args[0]) == false {\n\t\tfmt.Fprintf(os.Stderr, \"the %s folder is not exist\\n\", args[0])\n\t\tos.Exit(1)\n\t}\n\n\tif files, err := utils.WalkDir(args[0], \"yml\"); err != nil {\n\t\tfmt.Fprintf(os.Stderr, err.Error())\n\t\tos.Exit(1)\n\t} else {\n\t\tfor _, file := range files {\n\t\t\tif utils.IsFileExist(file) == false {\n\t\t\t\tfmt.Fprintf(os.Stderr, \"the %s file is not exist\\n\", file)\n\t\t\t}\n\n\t\t\td := new(objects.Deployment)\n\n\t\t\t//Read template file and parse.\n\t\t\tif err := d.ParseFromFile(file, output); err != nil {\n\t\t\t\tfmt.Fprintf(os.Stderr, \"parse deploy template error: %s\\n\", err.Error())\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\n\t\t\t//Set private key file path.\n\t\t\tif privateKey != \"\" {\n\t\t\t\td.Tools.SSH.Private, d.Tools.SSH.Public = privateKey, publicKey\n\t\t\t}\n\n\t\t\t//The integrity checking of deploy template.\n\t\t\tif err := d.Check(); err != nil {\n\t\t\t\tfmt.Fprintf(os.Stderr, \"parse deploy template error: %s\\n\", err.Error())\n\t\t\t}\n\n\t\t\t//Set log and error io.Writer\n\t\t\tvar logWriters io.Writer\n\n\t\t\t//Generate stdout/stderr io.Writer\n\t\t\tstdoutFile, _ := os.Create(path.Join(d.Config, \"deploy.log\"))\n\t\t\tdefer stdoutFile.Close()\n\n\t\t\t//Using MultiWriter log and error.\n\t\t\tif verbose == true {\n\t\t\t\tlogWriters = io.MultiWriter(stdoutFile, os.Stdout)\n\t\t\t} else {\n\t\t\t\tlogWriters = io.MultiWriter(stdoutFile)\n\t\t\t}\n\n\t\t\t//Deploy cloud native stack\n\t\t\tif err := module.DeployInfraStacks(d, db, logWriters, timestamp); err != nil {\n\t\t\t\tfmt.Fprintf(os.Stderr, \"%s\\n\", err.Error())\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\n\t\t\t//Delete droplets\n\t\t\tif del == true {\n\t\t\t\tif err := module.DeleteInfraStacks(d, logWriters, timestamp); err != nil {\n\t\t\t\t\tfmt.Fprintf(os.Stderr, \"%s\\n\", err.Error())\n\t\t\t\t\tos.Exit(1)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func (cmd *CreateCompanyHyCompanyCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tcc.Flags().StringVar(&cmd.Payload, \"payload\", \"\", \"Request body encoded in JSON\")\n\tcc.Flags().StringVar(&cmd.ContentType, \"content\", \"\", \"Request content type override, e.g. 'application/x-www-form-urlencoded'\")\n}", "func (f *FakeController) Deploy(options *deploy.Options, log log.Logger) error {\n\treturn nil\n}", "func (n *NodeClient) Deploy(dl *gridtypes.Deployment, update bool) error {\n\tdl.TwinID = n.client.id\n\tvar buf bytes.Buffer\n\n\tif err := json.NewEncoder(&buf).Encode(dl); err != nil {\n\t\treturn errors.Wrap(err, \"failed to serialize workload\")\n\t}\n\n\turl := n.url(\"deployment\")\n\tm := http.MethodPost\n\tif update {\n\t\tm = http.MethodPut\n\t}\n\n\trequest, err := http.NewRequest(m, url, &buf)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to build request\")\n\t}\n\n\tif err := n.client.authorize(request); err != nil {\n\t\treturn errors.Wrap(err, \"failed to sign request\")\n\t}\n\n\tresponse, err := http.DefaultClient.Do(request)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := n.response(response, nil, http.StatusAccepted); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (r Runner) Deploy(deploymentName string, manifestFilename string) error {\n\treturn r.DeployWithFlags(deploymentName, manifestFilename)\n}", "func HandleDeploy(w http.ResponseWriter, r *http.Request) {\r\n\r\n\tif r.Method == \"POST\" {\r\n\r\n\t\tvar err error\r\n\r\n\t\turlPart := strings.Split(r.URL.Path, \"/\")\r\n\r\n\t\tname := urlPart[2]\r\n\r\n\t\tif name != \"\" {\r\n\r\n\t\t\t//basis is optionally passed as qs param\r\n\t\t\tbasis := r.URL.Query().Get(\"basis\")\r\n\r\n\t\t\tdefer r.Body.Close()\r\n\r\n\t\t\tbody, _ := ioutil.ReadAll(r.Body)\r\n\r\n\t\t\tbodyString := string(body)\r\n\r\n\t\t\tvm := otto.New()\r\n\r\n\t\t\t//check it compiles\r\n\t\t\tif script, err := vm.Compile(name, bodyString); err == nil {\r\n\r\n\t\t\t\tif hash, err := storage.Set(name, script, basis); err == nil {\r\n\t\t\t\t\tfmt.Printf(\"Deployed Script %s (%s)\\n\", name, hash)\r\n\t\t\t\t\tw.Write([]byte(hash))\r\n\t\t\t\t\treturn\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tw.Write([]byte(err.Error()))\r\n\t\t\thttp.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)\r\n\r\n\t\t\treturn\r\n\t\t}\r\n\t}\r\n\r\n\thttp.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)\r\n\r\n}", "func AddFlags(cmd *cobra.Command) {\n\tcmd.Flags().String(\"log-level\", \"info\", \"The log-level for the operator. Possible values: trace, debug, info, warning, error, fatal, panic\")\n\tcmd.Flags().String(\"jaeger-version\", version.DefaultJaeger(), \"Deprecated: the Jaeger version is now managed entirely by the operator. This option is currently no-op.\")\n\tcmd.Flags().String(\"jaeger-agent-image\", \"jaegertracing/jaeger-agent\", \"The Docker image for the Jaeger Agent\")\n\tcmd.Flags().String(\"jaeger-query-image\", \"jaegertracing/jaeger-query\", \"The Docker image for the Jaeger Query\")\n\tcmd.Flags().String(\"jaeger-collector-image\", \"jaegertracing/jaeger-collector\", \"The Docker image for the Jaeger Collector\")\n\tcmd.Flags().String(\"jaeger-ingester-image\", \"jaegertracing/jaeger-ingester\", \"The Docker image for the Jaeger Ingester\")\n\tcmd.Flags().String(\"jaeger-all-in-one-image\", \"jaegertracing/all-in-one\", \"The Docker image for the Jaeger all-in-one\")\n\tcmd.Flags().String(\"jaeger-cassandra-schema-image\", \"jaegertracing/jaeger-cassandra-schema\", \"The Docker image for the Jaeger Cassandra Schema\")\n\tcmd.Flags().String(\"jaeger-spark-dependencies-image\", \"ghcr.io/jaegertracing/spark-dependencies/spark-dependencies\", \"The Docker image for the Spark Dependencies Job\")\n\tcmd.Flags().String(\"jaeger-es-index-cleaner-image\", \"jaegertracing/jaeger-es-index-cleaner\", \"The Docker image for the Jaeger Elasticsearch Index Cleaner\")\n\tcmd.Flags().String(\"jaeger-es-rollover-image\", \"jaegertracing/jaeger-es-rollover\", \"The Docker image for the Jaeger Elasticsearch Rollover\")\n\tcmd.Flags().String(\"openshift-oauth-proxy-image\", \"quay.io/openshift/origin-oauth-proxy:4.12\", \"The Docker image location definition for the OpenShift OAuth Proxy\")\n\tcmd.Flags().String(\"openshift-oauth-proxy-imagestream-ns\", \"\", \"The namespace for the OpenShift OAuth Proxy imagestream\")\n\tcmd.Flags().String(\"openshift-oauth-proxy-imagestream-name\", \"\", \"The name for the OpenShift OAuth Proxy imagestream\")\n\tcmd.Flags().String(\"platform\", v1.FlagPlatformAutoDetect, \"The target platform the operator will run. Possible values: 'kubernetes', 'openshift', 'auto-detect'\")\n\tcmd.Flags().String(\"es-provision\", v1.FlagProvisionElasticsearchAuto, \"Whether to auto-provision an Elasticsearch cluster for suitable Jaeger instances. Possible values: 'yes', 'no', 'auto'. When set to 'auto' and the API name 'logging.openshift.io' is available, auto-provisioning is enabled.\")\n\tcmd.Flags().String(\"kafka-provision\", \"auto\", \"Whether to auto-provision a Kafka cluster for suitable Jaeger instances. Possible values: 'yes', 'no', 'auto'. When set to 'auto' and the API name 'kafka.strimzi.io' is available, auto-provisioning is enabled.\")\n\tcmd.Flags().Bool(\"kafka-provisioning-minimal\", false, \"(unsupported) Whether to provision Kafka clusters with minimal requirements, suitable for demos and tests.\")\n\tcmd.Flags().String(\"secure-listen-address\", \"\", \"\")\n\tcmd.Flags().String(\"health-probe-bind-address\", \":8081\", \"The address the probe endpoint binds to.\")\n\tcmd.Flags().Int(\"webhook-bind-port\", 9443, \"The address webhooks expose.\")\n\tcmd.Flags().String(\"tls-min-version\", \"VersionTLS12\", \"Minimum TLS version supported. Value must match version names from https://golang.org/pkg/crypto/tls/#pkg-constants.\")\n\tcmd.Flags().StringSlice(\"tls-cipher-suites\", nil, \"Comma-separated list of cipher suites for the server. Values are from tls package constants (https://golang.org/pkg/crypto/tls/#pkg-constants). If omitted, the default Go cipher suites will be used\")\n\tcmd.Flags().Bool(\"leader-elect\", false, \"Enable leader election for controller manager. \"+\n\t\t\"Enabling this will ensure there is only one active controller manager.\")\n\n\tdocURL := fmt.Sprintf(\"https://www.jaegertracing.io/docs/%s\", version.DefaultJaegerMajorMinor())\n\tcmd.Flags().String(\"documentation-url\", docURL, \"The URL for the 'Documentation' menu item\")\n}", "func (t *Task) Deploy(clientset *client.ConfigSet) error {\n\ttask := tekton.Task{\n\t\tTypeMeta: metav1.TypeMeta{\n\t\t\tKind: \"Task\",\n\t\t\tAPIVersion: \"tekton.dev/v1alpha1\",\n\t\t},\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: t.Name,\n\t\t\tNamespace: t.Namespace,\n\t\t},\n\t\tSpec: tekton.TaskSpec{\n\t\t\tInputs: &tekton.Inputs{\n\t\t\t\tResources: []tekton.TaskResource{\n\t\t\t\t\t{\n\t\t\t\t\t\tName: \"sources\",\n\t\t\t\t\t\tType: tekton.PipelineResourceType(\"git\"),\n\t\t\t\t\t\tTargetPath: \"/workspace\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tParams: []tekton.TaskParam{\n\t\t\t\t\t{\n\t\t\t\t\t\tName: \"registry\",\n\t\t\t\t\t\tDefault: \"\",\n\t\t\t\t\t\tDescription: \"Where to store resulting image\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tSteps: t.kaniko(),\n\t\t},\n\t}\n\treturn t.createOrUpdate(task, clientset)\n}", "func (cmd *CreateTechHyTechCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tcc.Flags().StringVar(&cmd.Payload, \"payload\", \"\", \"Request body encoded in JSON\")\n\tcc.Flags().StringVar(&cmd.ContentType, \"content\", \"\", \"Request content type override, e.g. 'application/x-www-form-urlencoded'\")\n}", "func HandleDeployRequests(r api.RequestData) []byte {\n\tif r.Method == \"POST\" {\n\t\tif username, present := r.Query[\"user\"]; present {\n\t\t\tif moduleId, present := r.Query[\"module\"]; present {\n\t\t\t\tif command, present := r.Query[\"command\"]; present {\n\t\t\t\t\tif user := users.GetUser(username); user != nil {\n\t\t\t\t\t\tif module := user.GetModule(moduleId); module != nil {\n\t\t\t\t\t\t\tmodule.Update(r.Body)\n\t\t\t\t\t\t\treturn module.GetCommand().Launch(command)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if r.Method == \"GET\" {\n\t\tif username, present := r.Query[\"user\"]; present {\n\t\t\tif moduleId, present := r.Query[\"module\"]; present {\n\t\t\t\tif user := users.GetUser(username); user != nil {\n\t\t\t\t\tif module := user.GetModule(moduleId); module != nil {\n\t\t\t\t\t\treturn module.GetCommand().GetStatusJSON()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn []byte(\"{\\\"status:\\\": \\\"Invalid request\\\"}\")\n}", "func CmdInstall() *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: \"install\",\n\t\tShort: \"Install noobaa-operator\",\n\t\tRun: RunInstall,\n\t\tArgs: cobra.NoArgs,\n\t}\n\tcmd.Flags().Bool(\"no-deploy\", false, \"Install only the needed resources but do not create the operator deployment\")\n\treturn cmd\n}", "func init() {\n\n\t// set flags of meta command\n\tmetaCmd.Flags().StringVarP(&metaCmdSrc, \"source\", \"s\", \"\",\n\t\t\"The path to the MTA project; the current path is set as default\")\n\tmetaCmd.Flags().StringVarP(&metaCmdTrg, \"target\", \"t\", \"\",\n\t\t\"The path to the folder in which a temporary folder with generated metadata is created; the current path is set as default\")\n\tmetaCmd.Flags().StringVarP(&metaCmdDesc, \"desc\", \"d\", \"\",\n\t\t`The MTA descriptor; supported values: \"dev\" (development descriptor, default value) and \"dep\" (deployment descriptor)`)\n\tmetaCmd.Flags().StringSliceVarP(&metaCmdExtensions, \"extensions\", \"e\", nil,\n\t\t\"The MTA extension descriptors\")\n\tmetaCmd.Flags().StringVarP(&metaCmdPlatform, \"platform\", \"p\", \"cf\",\n\t\t`The deployment platform; supported platforms: \"cf\", \"xsa\", \"neo\"`)\n\tmetaCmd.Flags().BoolP(\"help\", \"h\", false, `Displays detailed information about the \"meta\" command`)\n\n\t// set flags of mtar command\n\tmtarCmd.Flags().StringVarP(&mtarCmdSrc, \"source\", \"s\", \"\",\n\t\t\"The path to the MTA project; the current path is set as default\")\n\tmtarCmd.Flags().StringVarP(&mtarCmdTrg, \"target\", \"t\", \"\",\n\t\t`The path to the folder in which the MTAR file is created; the path to the \"mta_archives\" subfolder of the current folder is set as default`)\n\tmtarCmd.Flags().StringVarP(&mtarCmdDesc, \"desc\", \"d\", \"\",\n\t\t`The MTA descriptor; supported values: \"dev\" (development descriptor, default value) and \"dep\" (deployment descriptor)`)\n\tmtarCmd.Flags().StringSliceVarP(&mtarCmdExtensions, \"extensions\", \"e\", nil,\n\t\t\"The MTA extension descriptors\")\n\tmtarCmd.Flags().StringVarP(&mtarCmdMtarName, \"mtar\", \"m\", \"*\",\n\t\t\"The archive name\")\n\tmtarCmd.Flags().StringVarP(&mtarCmdTrgProvided, \"target_provided\", \"\", \"\",\n\t\t\"The MTA target provided indicator; supported values: true, false\")\n\t_ = mtarCmd.Flags().MarkHidden(\"target_provided\")\n\tmtarCmd.Flags().BoolP(\"help\", \"h\", false, `Displays detailed information about the \"mtar\" command`)\n\n}", "func init() {\n\tRootCmd.AddCommand(AdminCmd)\n\tAdminCmd.AddCommand(UnsubscribeCmd, HealthCheckDb, HealthCheckStore, HealthCheckStats, SetVasCmd, SetConfig, DeleteConfig)\n\tSetVasCmd.Flags().String(FlagUserID, \"\", \"\")\n\tSetVasCmd.Flags().Bool(FlagEnabled, false, \"\")\n\tSetConfig.Flags().String(FlagKey, \"\", \"\")\n\tSetConfig.Flags().String(FlagValue, \"\", \"\")\n\tDeleteConfig.Flags().String(FlagKey, \"\", \"\")\n}", "func Execute() {\n\tlog.Entry().Infof(\"Version %s\", GitCommit)\n\n\trootCmd.AddCommand(ArtifactPrepareVersionCommand())\n\trootCmd.AddCommand(ConfigCommand())\n\trootCmd.AddCommand(DefaultsCommand())\n\trootCmd.AddCommand(ContainerSaveImageCommand())\n\trootCmd.AddCommand(CommandLineCompletionCommand())\n\trootCmd.AddCommand(VersionCommand())\n\trootCmd.AddCommand(DetectExecuteScanCommand())\n\trootCmd.AddCommand(HadolintExecuteCommand())\n\trootCmd.AddCommand(KarmaExecuteTestsCommand())\n\trootCmd.AddCommand(UiVeri5ExecuteTestsCommand())\n\trootCmd.AddCommand(SonarExecuteScanCommand())\n\trootCmd.AddCommand(KubernetesDeployCommand())\n\trootCmd.AddCommand(HelmExecuteCommand())\n\trootCmd.AddCommand(XsDeployCommand())\n\trootCmd.AddCommand(GithubCheckBranchProtectionCommand())\n\trootCmd.AddCommand(GithubCommentIssueCommand())\n\trootCmd.AddCommand(GithubCreateIssueCommand())\n\trootCmd.AddCommand(GithubCreatePullRequestCommand())\n\trootCmd.AddCommand(GithubPublishReleaseCommand())\n\trootCmd.AddCommand(GithubSetCommitStatusCommand())\n\trootCmd.AddCommand(GitopsUpdateDeploymentCommand())\n\trootCmd.AddCommand(CloudFoundryDeleteServiceCommand())\n\trootCmd.AddCommand(AbapEnvironmentPullGitRepoCommand())\n\trootCmd.AddCommand(AbapEnvironmentCloneGitRepoCommand())\n\trootCmd.AddCommand(AbapEnvironmentCheckoutBranchCommand())\n\trootCmd.AddCommand(AbapEnvironmentCreateTagCommand())\n\trootCmd.AddCommand(AbapEnvironmentCreateSystemCommand())\n\trootCmd.AddCommand(CheckmarxExecuteScanCommand())\n\trootCmd.AddCommand(CheckmarxOneExecuteScanCommand())\n\trootCmd.AddCommand(FortifyExecuteScanCommand())\n\trootCmd.AddCommand(CodeqlExecuteScanCommand())\n\trootCmd.AddCommand(CredentialdiggerScanCommand())\n\trootCmd.AddCommand(MtaBuildCommand())\n\trootCmd.AddCommand(ProtecodeExecuteScanCommand())\n\trootCmd.AddCommand(MavenExecuteCommand())\n\trootCmd.AddCommand(CloudFoundryCreateServiceKeyCommand())\n\trootCmd.AddCommand(MavenBuildCommand())\n\trootCmd.AddCommand(MavenExecuteIntegrationCommand())\n\trootCmd.AddCommand(MavenExecuteStaticCodeChecksCommand())\n\trootCmd.AddCommand(NexusUploadCommand())\n\trootCmd.AddCommand(AbapEnvironmentPushATCSystemConfigCommand())\n\trootCmd.AddCommand(AbapEnvironmentRunATCCheckCommand())\n\trootCmd.AddCommand(NpmExecuteScriptsCommand())\n\trootCmd.AddCommand(NpmExecuteLintCommand())\n\trootCmd.AddCommand(GctsCreateRepositoryCommand())\n\trootCmd.AddCommand(GctsExecuteABAPQualityChecksCommand())\n\trootCmd.AddCommand(GctsExecuteABAPUnitTestsCommand())\n\trootCmd.AddCommand(GctsDeployCommand())\n\trootCmd.AddCommand(MalwareExecuteScanCommand())\n\trootCmd.AddCommand(CloudFoundryCreateServiceCommand())\n\trootCmd.AddCommand(CloudFoundryDeployCommand())\n\trootCmd.AddCommand(GctsRollbackCommand())\n\trootCmd.AddCommand(WhitesourceExecuteScanCommand())\n\trootCmd.AddCommand(GctsCloneRepositoryCommand())\n\trootCmd.AddCommand(JsonApplyPatchCommand())\n\trootCmd.AddCommand(KanikoExecuteCommand())\n\trootCmd.AddCommand(CnbBuildCommand())\n\trootCmd.AddCommand(AbapEnvironmentBuildCommand())\n\trootCmd.AddCommand(AbapEnvironmentAssemblePackagesCommand())\n\trootCmd.AddCommand(AbapAddonAssemblyKitCheckCVsCommand())\n\trootCmd.AddCommand(AbapAddonAssemblyKitCheckPVCommand())\n\trootCmd.AddCommand(AbapAddonAssemblyKitCreateTargetVectorCommand())\n\trootCmd.AddCommand(AbapAddonAssemblyKitPublishTargetVectorCommand())\n\trootCmd.AddCommand(AbapAddonAssemblyKitRegisterPackagesCommand())\n\trootCmd.AddCommand(AbapAddonAssemblyKitReleasePackagesCommand())\n\trootCmd.AddCommand(AbapAddonAssemblyKitReserveNextPackagesCommand())\n\trootCmd.AddCommand(CloudFoundryCreateSpaceCommand())\n\trootCmd.AddCommand(CloudFoundryDeleteSpaceCommand())\n\trootCmd.AddCommand(VaultRotateSecretIdCommand())\n\trootCmd.AddCommand(IsChangeInDevelopmentCommand())\n\trootCmd.AddCommand(TransportRequestUploadCTSCommand())\n\trootCmd.AddCommand(TransportRequestUploadRFCCommand())\n\trootCmd.AddCommand(NewmanExecuteCommand())\n\trootCmd.AddCommand(IntegrationArtifactDeployCommand())\n\trootCmd.AddCommand(TransportRequestUploadSOLMANCommand())\n\trootCmd.AddCommand(IntegrationArtifactUpdateConfigurationCommand())\n\trootCmd.AddCommand(IntegrationArtifactGetMplStatusCommand())\n\trootCmd.AddCommand(IntegrationArtifactGetServiceEndpointCommand())\n\trootCmd.AddCommand(IntegrationArtifactDownloadCommand())\n\trootCmd.AddCommand(AbapEnvironmentAssembleConfirmCommand())\n\trootCmd.AddCommand(IntegrationArtifactUploadCommand())\n\trootCmd.AddCommand(IntegrationArtifactTriggerIntegrationTestCommand())\n\trootCmd.AddCommand(IntegrationArtifactUnDeployCommand())\n\trootCmd.AddCommand(IntegrationArtifactResourceCommand())\n\trootCmd.AddCommand(TerraformExecuteCommand())\n\trootCmd.AddCommand(ContainerExecuteStructureTestsCommand())\n\trootCmd.AddCommand(GaugeExecuteTestsCommand())\n\trootCmd.AddCommand(BatsExecuteTestsCommand())\n\trootCmd.AddCommand(PipelineCreateScanSummaryCommand())\n\trootCmd.AddCommand(TransportRequestDocIDFromGitCommand())\n\trootCmd.AddCommand(TransportRequestReqIDFromGitCommand())\n\trootCmd.AddCommand(WritePipelineEnv())\n\trootCmd.AddCommand(ReadPipelineEnv())\n\trootCmd.AddCommand(InfluxWriteDataCommand())\n\trootCmd.AddCommand(AbapEnvironmentRunAUnitTestCommand())\n\trootCmd.AddCommand(CheckStepActiveCommand())\n\trootCmd.AddCommand(GolangBuildCommand())\n\trootCmd.AddCommand(ShellExecuteCommand())\n\trootCmd.AddCommand(ApiProxyDownloadCommand())\n\trootCmd.AddCommand(ApiKeyValueMapDownloadCommand())\n\trootCmd.AddCommand(ApiProviderDownloadCommand())\n\trootCmd.AddCommand(ApiProxyUploadCommand())\n\trootCmd.AddCommand(GradleExecuteBuildCommand())\n\trootCmd.AddCommand(ApiKeyValueMapUploadCommand())\n\trootCmd.AddCommand(PythonBuildCommand())\n\trootCmd.AddCommand(AzureBlobUploadCommand())\n\trootCmd.AddCommand(AwsS3UploadCommand())\n\trootCmd.AddCommand(ApiProxyListCommand())\n\trootCmd.AddCommand(AnsSendEventCommand())\n\trootCmd.AddCommand(ApiProviderListCommand())\n\trootCmd.AddCommand(TmsUploadCommand())\n\trootCmd.AddCommand(TmsExportCommand())\n\trootCmd.AddCommand(IntegrationArtifactTransportCommand())\n\trootCmd.AddCommand(AscAppUploadCommand())\n\n\taddRootFlags(rootCmd)\n\n\tif err := rootCmd.Execute(); err != nil {\n\t\tlog.SetErrorCategory(log.ErrorConfiguration)\n\t\tlog.Entry().WithError(err).Fatal(\"configuration error\")\n\t}\n}", "func ParseArgs(args []string) (*ParserArguments, error) {\n\tflags := flag.NewFlagSet(\"zero-downtime-push\", flag.ContinueOnError)\n\n\tvar envs stringSlice\n\n\tpta := &ParserArguments{}\n\tflags.StringVar(&pta.ManifestPath, \"f\", \"\", \"path to an application manifest\")\n\tflags.StringVar(&pta.AppPath, \"p\", \"\", \"path to application files\")\n\tflags.StringVar(&pta.StackName, \"s\", \"\", \"name of the stack to use\")\n\tflags.StringVar(&pta.HealthCheckType, \"health-check-type\", \"port\", \"type of health check to perform\")\n\tflags.StringVar(&pta.HealthCheckHTTPEndpoint, \"health-check-http-endpoint\", \"\", \"endpoint for the 'http' health check type\")\n\tflags.IntVar(&pta.Timeout, \"t\", 0, \"push timeout in seconds (default 60 seconds)\")\n\tflags.IntVar(&pta.InvocationTimeout, \"invocation-timeout\", -1, \"health check invocation timeout in seconds\")\n\tflags.StringVar(&pta.Process, \"process\", \"\", \"use health check type process\")\n\tflags.BoolVar(&pta.ShowCrashLogs, \"show-crash-log\", false, \"Show recent logs when applications crashes while the deployment\")\n\tflags.StringVar(&pta.VenerableAction, \"venerable-action\", \"delete\", \"option to delete,stop,none application action on venerable app default is delete\")\n\tflags.Var(&envs, \"env\", \"Variable key value pair for adding dynamic environment variables; can specify multiple times\")\n\tflags.BoolVar(&pta.LegacyPush, \"legacy-push\", false, \"use legacy push instead of new v3 api\")\n\tflags.BoolVar(&pta.NoRoute, \"no-route\", false, \"deploy new application without adding routes\")\n\tflags.BoolVar(&pta.AddRoutes, \"route-only\", false, \"only add routes from manifest to the application\")\n\tflags.BoolVar(&pta.NoStart, \"no-start\", false, \"don't start application after deployment; venerable action is none\")\n\tflags.StringVar(&pta.VarsFile, \"vars-file\", \"\", \"path to a variable substitution file for manifest\")\n\tflags.StringVar(&pta.DockerImage, \"docker-image\", \"\", \"docker image url\")\n\tflags.StringVar(&pta.DockerUserName, \"docker-username\", \"\", \"docker repository username; used with password from env CF_DOCKER_PASSWORD\")\n\tdockerPass := os.Getenv(\"CF_DOCKER_PASSWORD\")\n\n\t//first check if argument was passed\n\tif len(args) < 2 {\n\t\treturn pta, ErrNoArgument\n\t}\n\n\t//default start index of parameters is 2 because 1 is the appName\n\targumentStartIndex := 2\n\t//if first argument is not the appName we have to read the appName out of the manifest\n\tnoAppNameProvided, _ := regexp.MatchString(\"^-[a-z]{0,3}\", args[1])\n\n\tif noAppNameProvided {\n\t\targumentStartIndex = 1\n\t}\n\n\terr := flags.Parse(args[argumentStartIndex:])\n\tif err != nil {\n\t\treturn pta, err\n\t}\n\n\tif pta.ManifestPath == \"\" {\n\t\treturn pta, ErrNoManifest\n\t}\n\n\t//parse manifest\n\tparsedManifest, noRouteManifestPath, err := manifest.ParseApplicationManifest(pta.ManifestPath, pta.VarsFile)\n\tif err != nil {\n\t\treturn pta, err //ErrManifest\n\t}\n\n\tif strings.ContainsAny(parsedManifest.ApplicationManifests[0].Path, \"*\") && pta.LegacyPush == false {\n\t\treturn pta, ErrNoWildcardSupport\n\t}\n\n\tpta.Manifest = parsedManifest\n\tpta.NoRouteManifestPath = noRouteManifestPath\n\n\t//check if a docker image shouldbe pushed and verify passed args combination\n\tif len(pta.DockerUserName) > 0 && (len(dockerPass) == 0 || len(pta.DockerImage) == 0) {\n\t\treturn nil, ErrWrongPrivateDockerRepoCombination\n\t}\n\n\t//set timeout\n\tmanifestTimeout, _ := strconv.Atoi(parsedManifest.ApplicationManifests[0].Timeout)\n\tif manifestTimeout > 0 && pta.Timeout <= 0 {\n\t\tpta.Timeout = manifestTimeout\n\t} else if manifestTimeout <= 0 && pta.Timeout <= 0 {\n\t\tpta.Timeout = 60\n\t}\n\n\t//parse first argument as appName\n\tpta.AppName = args[1]\n\tif noAppNameProvided {\n\t\tpta.AppName = parsedManifest.ApplicationManifests[0].Name\n\t}\n\n\t//check that health check works without legacy push only\n\tif pta.LegacyPush && ((argPassed(flags, \"health-check-type\") && pta.HealthCheckType != \"\") || (argPassed(flags, \"health-check-http-endpoint\") && pta.HealthCheckHTTPEndpoint != \"\")) {\n\t\treturn nil, ErrWrongCombination\n\t}\n\n\t// get health check settings from manifest if nothing else was specified in the command line\n\tif argPassed(flags, \"health-check-type\") == false {\n\t\tif parsedManifest.ApplicationManifests[0].HealthCheckType == \"\" {\n\t\t\tpta.HealthCheckType = \"port\"\n\t\t} else {\n\t\t\tpta.HealthCheckType = parsedManifest.ApplicationManifests[0].HealthCheckType\n\t\t}\n\n\t}\n\tif pta.HealthCheckHTTPEndpoint == \"\" {\n\t\tpta.HealthCheckHTTPEndpoint = parsedManifest.ApplicationManifests[0].HealthCheckHTTPEndpoint\n\t}\n\n\t//validate envs format\n\tif len(envs) > 0 {\n\t\tfor _, envPair := range envs {\n\t\t\tif strings.Contains(envPair, \"=\") == false {\n\t\t\t\treturn pta, ErrWrongEnvFormat\n\t\t\t}\n\t\t}\n\t\t//convert variables to use them later in set-ent\n\t\tpta.Envs = env.Convert(envs)\n\t}\n\n\t//no-route set venerable-action to delete as default - but can be overwritten\n\tif (pta.NoRoute || pta.NoStart) && argPassed(flags, \"venerable-action\") == false {\n\t\tpta.VenerableAction = \"none\"\n\t}\n\n\treturn pta, nil\n}", "func (c *ReleaseController) Pack() {\n\tlogs.Info(\"Pack() begin\")\n\tvar ob ms.ServFlt\n\tjson.Unmarshal(c.Ctx.Input.RequestBody, &ob)\n\tlogs.Info(\"解析json参数: serv.ServName[%v], serv.Env[%v]\", ob.ServName, ob.Env)\n\tdb, _ := ms.InitDb()\n\n\t//更新spec版本号\n\tvar serv ms.Serv\n\tdb.Debug().Preload(\"ServEnvs\").Where(\"serv_name = ?\", ob.ServName).First(&serv).GetErrors()\n\tif ob.Env == \"local\" {\n\t\tc.ModifyLocalPath(&serv)\n\t\tlogs.Info(\"local环境,修改localPath为用户当前配置的路径。[%v]\", serv.LocalPath)\n\t} else {\n\t\tif serv.ServType == 1 {\n\t\t\tserv.LocalPath = CgiPath\n\t\t} else if serv.ServType == 2 {\n\t\t\tserv.LocalPath = AppPath\n\t\t} else if serv.ServType == 3 {\n\t\t\tserv.LocalPath = GoPath\n\t\t}\n\t\tlogs.Info(\"其他环境,localPath.[%v], servType.[%v]\", serv.LocalPath, serv.ServType)\n\t}\n\n\tvar _servenv ms.ServEnv\n\tfor _, servenv := range serv.ServEnvs {\n\t\tif servenv.ServName == ob.ServName &&\n\t\t\tstrings.ToLower(servenv.Env) == strings.ToLower(ob.Env) {\n\t\t\t_servenv = servenv\n\t\t}\n\t}\n\n\tlogs.Info(\"%#v\", _servenv)\n\tmodels.GenSpec(&serv, _servenv)\n\n\t//打包\n\tvar stderr, stdout bytes.Buffer\n\ts := \"cd /root/rpmbuild;rpmbuild -bb SPECS/\" + ob.ServName + \".spec\"\n\tlogs.Info(s)\n\tcmd := exec.Command(\"/bin/sh\", \"-c\", s)\n\tcmd.Stdout = &stdout\n\tcmd.Stderr = &stderr\n\n\terr := cmd.Run()\n\tif nil != err {\n\t\tc.setError(1, fmt.Sprintf(\"local exec[%s] failed. \", s))\n\t\tlogs.Error(\"exec[%s] failed. Error:[%s]\", s, stderr.String())\n\t\tgoto end\n\t}\n\n\tlogs.Info(ob.ServName + \" package passed\")\n\nend:\n\tc.Data[\"json\"] = c.GenRetJSON()\n\tc.ServeJSON()\n}", "func Deploy(name string, dir string, port string) {\n\tctx := context.Background()\n\tcli, err := client.NewEnvClient()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\timageName := name\n\tcontainerConfig := &container.Config{\n\t\tImage: imageName,\n\t\tExposedPorts: nat.PortSet{\n\t\t\t\"3000/tcp\": struct{}{},\n\t\t},\n\t}\n\thostConfig := &container.HostConfig{\n\t\tPortBindings: nat.PortMap{\n\t\t\t\"3000/tcp\": []nat.PortBinding{\n\t\t\t\t{\n\t\t\t\t\tHostIP: \"0.0.0.0\",\n\t\t\t\t\tHostPort: port,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tresp, err := cli.ContainerCreate(ctx, containerConfig, hostConfig, nil, \"\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif err := cli.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{}); err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(resp.ID)\n}", "func publishCmd() *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: \"publish\",\n\t\tAliases: []string{\"pb\"},\n\t\tShort: \"Publish release\",\n\t\tLong: \"Publish release to make the configuration effective\",\n\t\tExample: `\n\tbk-bscp-client publish --id <releaseid>\n\t\t`,\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\toperator := service.NewOperator(option.GlobalOptions)\n\t\t\tif err := operator.Init(option.GlobalOptions.ConfigFile); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tID, _ := cmd.Flags().GetString(\"id\")\n\t\t\terr := operator.ConfirmMultiRelease(context.TODO(), ID)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tcmd.Printf(\"Publish successfully: %s\\n\", ID)\n\t\t\tcmd.Println()\n\t\t\tcmd.Printf(\"\\tuse \\\"bk-bscp-client get release --id <releaseid>\\\" to get release detail\\n\\n\")\n\t\t\treturn nil\n\t\t},\n\t}\n\t// --Id is required\n\tcmd.Flags().StringP(\"id\", \"i\", \"\", \"the id of release\")\n\tcmd.MarkFlagRequired(\"id\")\n\treturn cmd\n}", "func (this *Deployment) deploy() error {\n\tif len(this.Application.Processes) == 0 {\n\t\treturn fmt.Errorf(\"No processes scaled up, adjust with `ps:scale procType=#` before deploying\")\n\t}\n\n\ttitleLogger := NewFormatter(this.Logger, GREEN)\n\tdimLogger := NewFormatter(this.Logger, DIM)\n\n\te := Executor{dimLogger}\n\n\tthis.autoDetectRevision()\n\n\terr := writeDeployScripts()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tremoveDynos, allocatingNewDynos, err := this.calculateDynosToDestroy()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif allocatingNewDynos {\n\t\tavailableNodes, err := this.syncNodes()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Now we've successfully sync'd and we have a list of nodes available to deploy to.\n\t\taddDynos, err := this.startDynos(availableNodes, titleLogger)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfmt.Fprintf(titleLogger, \"Arbitrary sleeping for 30s to allow dynos to warm up before syncing load balancers\\n\")\n\t\ttime.Sleep(30 * time.Second)\n\n\t\terr = this.Server.SyncLoadBalancers(&e, addDynos, removeDynos)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif !this.ScalingOnly {\n\t\t// Update releases.\n\t\treleases, err := getReleases(this.Application.Name)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// Prepend the release (releases are in descending order)\n\t\treleases = append([]Release{{\n\t\t\tVersion: this.Version,\n\t\t\tRevision: this.Revision,\n\t\t\tDate: time.Now(),\n\t\t\tConfig: this.Application.Environment,\n\t\t}}, releases...)\n\t\t// Only keep around the latest 15 (older ones are still in S3)\n\t\tif len(releases) > 15 {\n\t\t\treleases = releases[:15]\n\t\t}\n\t\terr = setReleases(this.Application.Name, releases)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\t// Trigger old dynos to shutdown.\n\t\tfor _, removeDyno := range removeDynos {\n\t\t\tfmt.Fprintf(titleLogger, \"Shutting down dyno: %v\\n\", removeDyno.Container)\n\t\t\tgo func(rd Dyno) {\n\t\t\t\trd.Shutdown(&Executor{os.Stdout})\n\t\t\t}(removeDyno)\n\t\t}\n\t}\n\n\treturn nil\n}", "func NewTopLevelDeployCommand(dockerCli *command.DockerCli) *cobra.Command {\n\treturn &cobra.Command{}\n}", "func NewDeploymentCmd(cli *client.Cli) *cobra.Command {\n\n\tvar DeploymentCmd = &cobra.Command{\n\t\tUse: \"deployment COMMAND\",\n\t\tShort: \"Manage deployments\",\n\t}\n\n\tDeploymentCmd.AddCommand(newGetCommand(cli))\n\tDeploymentCmd.AddCommand(newCreateCommand(cli))\n\tDeploymentCmd.AddCommand(newPromoteCommand(cli))\n\n\treturn DeploymentCmd\n}", "func (n *NetworkCreateCommand) addFlags() {\n\tflagSet := n.cmd.Flags()\n\n\tflagSet.StringVarP(&n.name, \"name\", \"n\", \"\", \"the name of network\")\n\tflagSet.StringVarP(&n.driver, \"driver\", \"d\", \"bridge\", \"the driver of network\")\n\tflagSet.StringVar(&n.gateway, \"gateway\", \"\", \"the gateway of network\")\n\tflagSet.StringVar(&n.ipRange, \"ip-range\", \"\", \"the range of network's ip\")\n\tflagSet.StringVar(&n.subnet, \"subnet\", \"\", \"the subnet of network\")\n\tflagSet.StringVar(&n.ipamDriver, \"ipam-driver\", \"default\", \"the ipam driver of network\")\n\tflagSet.BoolVar(&n.enableIPv6, \"enable-ipv6\", false, \"enable ipv6 network\")\n\tflagSet.StringSliceVarP(&n.options, \"option\", \"o\", nil, \"create network with options\")\n\tflagSet.StringSliceVarP(&n.labels, \"label\", \"l\", nil, \"create network with labels\")\n}", "func Deploy(s *model.Service, e *model.Environment, log *logger.Logger) error {\n\tlog.Printf(\"Deploying the service '%s'...\", s.Name)\n\n\tif len(s.GetIngressRules(false)) > 0 && !e.Provider.IsIngress() {\n\t\treturn fmt.Errorf(\"Support for ingress ports requires ingress configuration in your project\")\n\t}\n\tif err := deploy(s, e, log); err != nil {\n\t\treturn err\n\t}\n\tlog.Printf(\"Service '%s' successfully deployed.\", s.Name)\n\treturn nil\n}", "func (cmd *ListProjectCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}" ]
[ "0.67180616", "0.6289662", "0.61988926", "0.61870503", "0.6114755", "0.61016816", "0.6063185", "0.5987771", "0.5962346", "0.5956628", "0.5893648", "0.5819978", "0.5727794", "0.56987953", "0.56575954", "0.5643189", "0.563208", "0.5610448", "0.5586293", "0.5584757", "0.5575489", "0.5555131", "0.5491848", "0.54786223", "0.5472197", "0.5470347", "0.54557633", "0.54353863", "0.5430154", "0.53652596", "0.53326285", "0.5326003", "0.5302358", "0.52949524", "0.52873343", "0.5279539", "0.52773446", "0.5238637", "0.5234612", "0.5230905", "0.52090114", "0.5208051", "0.52036375", "0.52017844", "0.51984465", "0.5195028", "0.519219", "0.519058", "0.51855385", "0.51836383", "0.5173531", "0.516741", "0.5161076", "0.5156891", "0.51537067", "0.51500154", "0.5145843", "0.51415676", "0.5136865", "0.51298696", "0.51241755", "0.5123188", "0.511785", "0.51099175", "0.5097923", "0.5092206", "0.5067803", "0.5065415", "0.50568956", "0.50550145", "0.5053228", "0.5050472", "0.5048762", "0.5022127", "0.50135356", "0.50111103", "0.50107116", "0.5000998", "0.4990264", "0.49825662", "0.49806795", "0.4976683", "0.49658337", "0.49655443", "0.49652573", "0.49542978", "0.49509028", "0.49498284", "0.49453235", "0.49426702", "0.49374", "0.49356633", "0.4932979", "0.49311367", "0.49223614", "0.49217245", "0.49169126", "0.49099776", "0.4905879", "0.48940217" ]
0.7252531
0
this function is called as the run operation for the DeployCmd parameters: cmd (the definition of cmd.Command), args (an array of strings passed to the command) returns: nil
func deployJob(cmd *cobra.Command, args []string) { port, _:= cmd.Flags().GetString("port") if port == "" { port = DefaultPort } name, _:= cmd.Flags().GetString("file") yaml := unmarsharlYaml(readJobFile(name)) currentDir, _ := os.Getwd() var job NewJob job.ID = yaml.Job.ID job.UID = fmt.Sprint(syscall.Getuid()) group, _ := user.LookupGroup("odin") gid, _ := strconv.Atoi(group.Gid) job.GID = strconv.Itoa(gid) job.Name = yaml.Job.Name job.Description = yaml.Job.Description job.File = currentDir + "/" + yaml.Job.File if yaml.Job.Language == "go" { job.Language = yaml.Job.Language cmd := exec.Command(job.Language, "build", job.File) cmd.SysProcAttr = &syscall.SysProcAttr{} _, err := cmd.CombinedOutput() if err != nil { fmt.Println(err) os.Exit(2) } job.File = job.File[:len(job.File)-3] } else { job.Language = yaml.Job.Language } job.Schedule = getScheduleString(name, port) jobJSON, _ := json.Marshal(job) body := makePostRequest(fmt.Sprintf("http://localhost%s/jobs", port), bytes.NewBuffer(jobJSON)) fmt.Println(body) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *DeployCommand) Run(args []string) int {\n\n\tvar err error\n\tvar level, format string\n\n\tconfig := &levant.DeployConfig{\n\t\tClient: &structs.ClientConfig{},\n\t\tDeploy: &structs.DeployConfig{},\n\t\tPlan: &structs.PlanConfig{},\n\t\tTemplate: &structs.TemplateConfig{},\n\t}\n\n\tflags := c.Meta.FlagSet(\"deploy\", FlagSetVars)\n\tflags.Usage = func() { c.UI.Output(c.Help()) }\n\n\tflags.StringVar(&config.Client.Addr, \"address\", \"\", \"\")\n\tflags.BoolVar(&config.Client.AllowStale, \"allow-stale\", false, \"\")\n\tflags.IntVar(&config.Deploy.Canary, \"canary-auto-promote\", 0, \"\")\n\tflags.StringVar(&config.Client.ConsulAddr, \"consul-address\", \"\", \"\")\n\tflags.BoolVar(&config.Deploy.Force, \"force\", false, \"\")\n\tflags.BoolVar(&config.Deploy.ForceBatch, \"force-batch\", false, \"\")\n\tflags.BoolVar(&config.Deploy.ForceCount, \"force-count\", false, \"\")\n\tflags.BoolVar(&config.Plan.IgnoreNoChanges, \"ignore-no-changes\", false, \"\")\n\tflags.StringVar(&level, \"log-level\", \"INFO\", \"\")\n\tflags.StringVar(&format, \"log-format\", \"HUMAN\", \"\")\n\tflags.StringVar(&config.Deploy.VaultToken, \"vault-token\", \"\", \"\")\n\tflags.BoolVar(&config.Deploy.EnvVault, \"vault\", false, \"\")\n\n\tflags.Var((*helper.FlagStringSlice)(&config.Template.VariableFiles), \"var-file\", \"\")\n\n\tif err = flags.Parse(args); err != nil {\n\t\treturn 1\n\t}\n\n\targs = flags.Args()\n\n\tif config.Deploy.EnvVault == true && config.Deploy.VaultToken != \"\" {\n\t\tc.UI.Error(c.Help())\n\t\tc.UI.Error(\"\\nERROR: Can not used -vault and -vault-token flag at the same time\")\n\t\treturn 1\n\t}\n\n\tif err = logging.SetupLogger(level, format); err != nil {\n\t\tc.UI.Error(err.Error())\n\t\treturn 1\n\t}\n\n\tif len(args) == 1 {\n\t\tconfig.Template.TemplateFile = args[0]\n\t} else if len(args) == 0 {\n\t\tif config.Template.TemplateFile = helper.GetDefaultTmplFile(); config.Template.TemplateFile == \"\" {\n\t\t\tc.UI.Error(c.Help())\n\t\t\tc.UI.Error(\"\\nERROR: Template arg missing and no default template found\")\n\t\t\treturn 1\n\t\t}\n\t} else {\n\t\tc.UI.Error(c.Help())\n\t\treturn 1\n\t}\n\n\tconfig.Template.Job, err = template.RenderJob(config.Template.TemplateFile,\n\t\tconfig.Template.VariableFiles, config.Client.ConsulAddr, &c.Meta.flagVars)\n\tif err != nil {\n\t\tc.UI.Error(fmt.Sprintf(\"[ERROR] levant/command: %v\", err))\n\t\treturn 1\n\t}\n\n\tif config.Deploy.Canary > 0 {\n\t\tif err = c.checkCanaryAutoPromote(config.Template.Job, config.Deploy.Canary); err != nil {\n\t\t\tc.UI.Error(fmt.Sprintf(\"[ERROR] levant/command: %v\", err))\n\t\t\treturn 1\n\t\t}\n\t}\n\n\tif config.Deploy.ForceBatch {\n\t\tif err = c.checkForceBatch(config.Template.Job, config.Deploy.ForceBatch); err != nil {\n\t\t\tc.UI.Error(fmt.Sprintf(\"[ERROR] levant/command: %v\", err))\n\t\t\treturn 1\n\t\t}\n\t}\n\n\tif !config.Deploy.Force {\n\t\tp := levant.PlanConfig{\n\t\t\tClient: config.Client,\n\t\t\tPlan: config.Plan,\n\t\t\tTemplate: config.Template,\n\t\t}\n\n\t\tplanSuccess, changes := levant.TriggerPlan(&p)\n\t\tif !planSuccess {\n\t\t\treturn 1\n\t\t} else if !changes && p.Plan.IgnoreNoChanges {\n\t\t\treturn 0\n\t\t}\n\t}\n\n\tsuccess := levant.TriggerDeployment(config, nil)\n\tif !success {\n\t\treturn 1\n\t}\n\n\treturn 0\n}", "func (c *DeployCommand) Run(args []string) int {\n\n\tvar variables, addr, log string\n\tvar err error\n\tvar job *nomad.Job\n\tvar canary int\n\tvar forceCount bool\n\n\tflags := c.Meta.FlagSet(\"deploy\", FlagSetVars)\n\tflags.Usage = func() { c.UI.Output(c.Help()) }\n\n\tflags.StringVar(&addr, \"address\", \"\", \"\")\n\tflags.IntVar(&canary, \"canary-auto-promote\", 0, \"\")\n\tflags.StringVar(&log, \"log-level\", \"INFO\", \"\")\n\tflags.StringVar(&variables, \"var-file\", \"\", \"\")\n\tflags.BoolVar(&forceCount, \"force-count\", false, \"\")\n\n\tif err = flags.Parse(args); err != nil {\n\t\treturn 1\n\t}\n\n\targs = flags.Args()\n\n\tif len(args) != 1 {\n\t\tc.UI.Error(c.Help())\n\t\treturn 1\n\t}\n\n\tlogging.SetLevel(log)\n\n\tjob, err = levant.RenderJob(args[0], variables, &c.Meta.flagVars)\n\tif err != nil {\n\t\tc.UI.Error(fmt.Sprintf(\"[ERROR] levant/command: %v\", err))\n\t\treturn 1\n\t}\n\n\tif canary > 0 {\n\t\tif err = c.checkCanaryAutoPromote(job, canary); err != nil {\n\t\t\tc.UI.Error(fmt.Sprintf(\"[ERROR] levant/command: %v\", err))\n\t\t\treturn 1\n\t\t}\n\n\t\tc.UI.Info(fmt.Sprintf(\"[INFO] levant/command: running canary-auto-update of %vs\", canary))\n\t}\n\n\tclient, err := levant.NewNomadClient(addr)\n\tif err != nil {\n\t\tc.UI.Error(fmt.Sprintf(\"[ERROR] levant/command: %v\", err))\n\t\treturn 1\n\t}\n\n\tsuccess := client.Deploy(job, canary, forceCount)\n\tif !success {\n\t\tc.UI.Error(fmt.Sprintf(\"[ERROR] levant/command: deployment of job %s failed\", *job.Name))\n\t\treturn 1\n\t}\n\n\tc.UI.Info(fmt.Sprintf(\"[INFO] levant/command: deployment of job %s successful\", *job.Name))\n\n\treturn 0\n}", "func (cmd *DeployCmd) Run(cobraCmd *cobra.Command, args []string) {\n\t// Set config root\n\tconfigExists, err := configutil.SetDevSpaceRoot()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tif !configExists {\n\t\tlog.Fatal(\"Couldn't find a DevSpace configuration. Please run `devspace init`\")\n\t}\n\n\t// Start file logging\n\tlog.StartFileLogging()\n\n\t// Prepare the config\n\tcmd.prepareConfig()\n\n\t// Create kubectl client\n\tclient, err := kubectl.NewClientWithContextSwitch(cmd.SwitchContext)\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to create new kubectl client: %v\", err)\n\t}\n\n\t// Create namespace if necessary\n\terr = kubectl.EnsureDefaultNamespace(client, log.GetInstance())\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to create namespace: %v\", err)\n\t}\n\n\t// Create cluster binding if necessary\n\terr = kubectl.EnsureGoogleCloudClusterRoleBinding(client, log.GetInstance())\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to ensure cluster-admin role binding: %v\", err)\n\t}\n\n\t// Create docker client\n\tdockerClient, err := docker.NewClient(false)\n\n\t// Create pull secrets and private registry if necessary\n\terr = registry.InitRegistries(dockerClient, client, log.GetInstance())\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Load generated config\n\tgeneratedConfig, err := generated.LoadConfig()\n\tif err != nil {\n\t\tlog.Fatalf(\"Error loading generated.yaml: %v\", err)\n\t}\n\n\t// Force image build\n\tmustRedeploy, err := image.BuildAll(client, generatedConfig, false, cmd.ForceBuild, log.GetInstance())\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Save config if an image was built\n\tif mustRedeploy == true {\n\t\terr := generated.SaveConfig(generatedConfig)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Error saving generated config: %v\", err)\n\t\t}\n\t}\n\n\t// Force deployment of all defined deployments\n\terr = deploy.All(client, generatedConfig, false, mustRedeploy || cmd.ForceDeploy, log.GetInstance())\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Save Config\n\terr = generated.SaveConfig(generatedConfig)\n\tif err != nil {\n\t\tlog.Fatalf(\"Error saving generated config: %v\", err)\n\t}\n\n\tif generatedConfig.CloudSpace != nil {\n\t\t// Create ingress if there is none\n\t\terr = cloud.CreateIngress(client)\n\t\tif err != nil {\n\t\t\tlog.Warnf(\"Error creating ingress: %v\", err)\n\t\t}\n\n\t\tlog.Donef(\"Successfully deployed!\")\n\t\tlog.Infof(\"Run: \\n- `%s` to open the app in the browser\\n- `%s` to open a shell into the container\\n- `%s` to show the container logs\\n- `%s` to open the management ui\\n- `%s` to analyze the space for potential issues\", ansi.Color(\"devspace open\", \"white+b\"), ansi.Color(\"devspace enter\", \"white+b\"), ansi.Color(\"devspace logs\", \"white+b\"), ansi.Color(\"devspace ui\", \"white+b\"), ansi.Color(\"devspace analyze\", \"white+b\"))\n\t} else {\n\t\tlog.Donef(\"Successfully deployed!\")\n\t\tlog.Infof(\"Run `%s` to check for potential issues\", ansi.Color(\"devspace analyze\", \"white+b\"))\n\t}\n}", "func init() {\n RootCmd.AddCommand(DeployCmd)\n DeployCmd.Flags().StringP(\"file\", \"f\", \"\", \"file used to specify the job to deploy (required)\")\n DeployCmd.Flags().StringP(\"port\", \"p\", \"\", \"connect to a specific port (default: 3939)\")\n DeployCmd.MarkFlagRequired(\"file\")\n}", "func deployExecutor(args prompter.CmdArgs) error {\n\tfmt.Println(\"inside deployExecutor\")\n\tfmt.Printf(\"args: %v\\n\", args)\n\n\treturn config.Deploy()\n\t// err := config.Deploy()\n\t// if err != nil {\n\t// \treturn err\n\t// }\n\n\t// // Read config.\n\t// cfg, err = config.Read()\n\t// if err != nil {\n\t// \treturn err\n\t// }\n\n\t// // Enable all commands.\n\t// configCmd.Hidden = false\n\t// templateCmd.Hidden = false\n\t// dataCmd.Hidden = false\n\n\t// return nil\n}", "func Deploy(ctx context.Context, k8sRepo config.KubernetesConfigsRepo, texts []string, message, caller string) (messages []string, err error) {\n\tif !DeployWorker.isRunning {\n\t\treturn nil, errors.New(\"deploy worker is not running\")\n\t}\n\n\tif len(texts) < 1 {\n\t\treturn nil, errors.New(\"call help\")\n\t}\n\n\t// Compare and retrieve the repo before we engage the deployment, so we can pass the repo to deploy worker for clearer intention\n\tcodebases := k8sRepo.Configs\n\trepoNameInCMD, texts := pop(texts, 0)\n\tvar codebase *config.Codebase\n\tfor _, c := range codebases {\n\t\tif repoNameInCMD == c.Repo {\n\t\t\tcodebase = &c\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif codebase == nil {\n\t\treturn nil, errors.New(\"invalid repo name\")\n\t}\n\n\t// deploy requires env only and it only supports image-tag only\n\n\ttexts, stage, err := popValue(texts, \"env\", \"=\")\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"getting env for deployment encountered an error\")\n\t} else if stage == \"prod\" {\n\t\treturn nil, errors.New(\"deploy command doesn't support prod env\")\n\t}\n\n\ttexts, image, err := popValue(texts, \"image-tag\", \"=\")\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"getting image-tag for deployment encountered an error\")\n\t}\n\n\tif len(texts) != 0 {\n\t\treturn nil, errors.New(\"Major Tom does not support: \" + strings.Join(texts, \", \"))\n\t}\n\n\ttimeout := 5 * time.Minute\n\tch := make(chan response)\n\tnewCtx := context.WithValue(ctx, mjcontext.ResponseChannel, ch)\n\tnewCtx, cancelFn := context.WithTimeout(newCtx, timeout)\n\tdefer cancelFn()\n\tdeployChannel <- Deployment{\n\t\tctx: newCtx,\n\t\tcodebase: codebase,\n\t\tstage: stage,\n\t\timageTag: image,\n\t\tcaller: caller,\n\t\tmessage: message,\n\t}\n\n\tselect {\n\tcase commandResponse := <-ch:\n\t\treturn commandResponse.Messages, commandResponse.Error\n\tcase <-newCtx.Done():\n\t\treturn nil, errors.Errorf(\"\\\"%s\\\" command has timeouted(%f)\", strings.Join(texts, \" \"), timeout.Minutes())\n\t}\n}", "func Deploy(ctx context.Context) *cobra.Command {\n\toptions := &Options{}\n\n\tcmd := &cobra.Command{\n\t\tUse: \"deploy\",\n\t\tShort: \"Execute the list of commands specified in the Okteto manifest to deploy the application\",\n\t\tArgs: utils.NoArgsAccepted(\"https://okteto.com/docs/reference/cli/#version\"),\n\t\tHidden: true,\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\t// This is needed because the deploy command needs the original kubeconfig configuration even in the execution within another\n\t\t\t// deploy command. If not, we could be proxying a proxy and we would be applying the incorrect deployed-by label\n\t\t\tos.Setenv(model.OktetoWithinDeployCommandContextEnvVar, \"false\")\n\n\t\t\tif err := contextCMD.LoadManifestV2WithContext(ctx, options.Namespace, options.ManifestPath); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif okteto.IsOkteto() {\n\t\t\t\tcreate, err := utils.ShouldCreateNamespace(ctx, okteto.Context().Namespace)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif create {\n\t\t\t\t\tnsCmd, err := namespace.NewCommand()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tnsCmd.Create(ctx, &namespace.CreateOptions{Namespace: okteto.Context().Namespace})\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcwd, err := os.Getwd()\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to get the current working directory: %w\", err)\n\t\t\t}\n\n\t\t\taddEnvVars(ctx, cwd)\n\t\t\tif options.Name == \"\" {\n\t\t\t\toptions.Name = utils.InferApplicationName(cwd)\n\t\t\t}\n\n\t\t\t// Look for a free local port to start the proxy\n\t\t\tport, err := model.GetAvailablePort(\"localhost\")\n\t\t\tif err != nil {\n\t\t\t\toktetoLog.Infof(\"could not find a free port to start proxy server: %s\", err)\n\t\t\t\treturn err\n\t\t\t}\n\t\t\toktetoLog.Debugf(\"found available port %d\", port)\n\n\t\t\t// TODO for now, using self-signed certificates\n\t\t\tcert, err := tls.X509KeyPair(cert, key)\n\t\t\tif err != nil {\n\t\t\t\toktetoLog.Infof(\"could not read certificate: %s\", err)\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t// Generate a token for the requests done to the proxy\n\t\t\tsessionToken := uuid.NewString()\n\n\t\t\tkubeconfig := newKubeConfig()\n\t\t\tclusterConfig, err := kubeconfig.Read()\n\t\t\tif err != nil {\n\t\t\t\toktetoLog.Infof(\"could not read kubeconfig file: %s\", err)\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\thandler, err := getProxyHandler(options.Name, sessionToken, clusterConfig)\n\t\t\tif err != nil {\n\t\t\t\toktetoLog.Infof(\"could not configure local proxy: %s\", err)\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\ts := &http.Server{\n\t\t\t\tAddr: fmt.Sprintf(\":%d\", port),\n\t\t\t\tHandler: handler,\n\t\t\t\tReadTimeout: 5 * time.Second,\n\t\t\t\tWriteTimeout: 10 * time.Second,\n\t\t\t\tIdleTimeout: 120 * time.Second,\n\t\t\t\tTLSConfig: &tls.Config{\n\t\t\t\t\tCertificates: []tls.Certificate{cert},\n\n\t\t\t\t\t// Recommended security configuration by DeepSource\n\t\t\t\t\tMinVersion: tls.VersionTLS12,\n\t\t\t\t\tMaxVersion: tls.VersionTLS13,\n\t\t\t\t},\n\t\t\t}\n\n\t\t\tc := &deployCommand{\n\t\t\t\tgetManifest: contextCMD.GetManifest,\n\n\t\t\t\tkubeconfig: kubeconfig,\n\t\t\t\texecutor: utils.NewExecutor(oktetoLog.GetOutputFormat()),\n\t\t\t\tproxy: newProxy(proxyConfig{\n\t\t\t\t\tport: port,\n\t\t\t\t\ttoken: sessionToken,\n\t\t\t\t}, s),\n\t\t\t\ttempKubeconfigFile: fmt.Sprintf(tempKubeConfigTemplate, config.GetUserHomeDir(), options.Name),\n\t\t\t\tk8sClientProvider: okteto.NewK8sClientProvider(),\n\t\t\t}\n\t\t\treturn c.runDeploy(ctx, cwd, options)\n\t\t},\n\t}\n\n\tcmd.Flags().StringVar(&options.Name, \"name\", \"\", \"application name\")\n\tcmd.Flags().StringVarP(&options.ManifestPath, \"file\", \"f\", \"\", \"path to the okteto manifest file\")\n\tcmd.Flags().StringVarP(&options.Namespace, \"namespace\", \"n\", \"\", \"overwrites the namespace where the application is deployed\")\n\n\tcmd.Flags().StringArrayVarP(&options.Variables, \"var\", \"v\", []string{}, \"set a variable (can be set more than once)\")\n\tcmd.Flags().BoolVarP(&options.Build, \"build\", \"\", false, \"force build of images when deploying the app\")\n\tcmd.Flags().MarkHidden(\"build\")\n\n\treturn cmd\n}", "func Deploy(ctx context.Context) *cobra.Command {\n\topts := &DeployOptions{}\n\tcmd := &cobra.Command{\n\t\tUse: \"deploy <name>\",\n\t\tShort: \"Deploy a preview environment\",\n\t\tArgs: utils.MaximumNArgsAccepted(1, \"\"),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tcwd, err := os.Getwd()\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to get the current working directory: %w\", err)\n\t\t\t}\n\n\t\t\tif err := optionsSetup(cwd, opts, args); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif err := contextCMD.NewContextCommand().Run(ctx, &contextCMD.ContextOptions{}); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\toktetoLog.Information(\"Using %s @ %s as context\", opts.name, okteto.RemoveSchema(okteto.Context().Name))\n\n\t\t\tif !okteto.IsOkteto() {\n\t\t\t\treturn oktetoErrors.ErrContextIsNotOktetoCluster\n\t\t\t}\n\n\t\t\tpreviewCmd, err := NewCommand()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn previewCmd.ExecuteDeployPreview(ctx, opts)\n\t\t},\n\t}\n\tcmd.Flags().StringVarP(&opts.branch, \"branch\", \"b\", \"\", \"the branch to deploy (defaults to the current branch)\")\n\tcmd.Flags().StringVarP(&opts.repository, \"repository\", \"r\", \"\", \"the repository to deploy (defaults to the current repository)\")\n\tcmd.Flags().StringVarP(&opts.scope, \"scope\", \"s\", \"personal\", \"the scope of preview environment to create. Accepted values are ['personal', 'global']\")\n\tcmd.Flags().StringVarP(&opts.sourceUrl, \"sourceUrl\", \"\", \"\", \"the URL of the original pull/merge request.\")\n\tcmd.Flags().DurationVarP(&opts.timeout, \"timeout\", \"t\", (5 * time.Minute), \"the length of time to wait for completion, zero means never. Any other values should contain a corresponding time unit e.g. 1s, 2m, 3h \")\n\tcmd.Flags().StringArrayVarP(&opts.variables, \"var\", \"v\", []string{}, \"set a preview environment variable (can be set more than once)\")\n\tcmd.Flags().BoolVarP(&opts.wait, \"wait\", \"w\", false, \"wait until the preview environment deployment finishes (defaults to false)\")\n\tcmd.Flags().StringVarP(&opts.file, \"file\", \"f\", \"\", \"relative path within the repository to the okteto manifest (default to okteto.yaml or .okteto/okteto.yaml)\")\n\tcmd.Flags().StringArrayVarP(&opts.labels, \"label\", \"\", []string{}, \"set a preview environment label (can be set more than once)\")\n\n\tcmd.Flags().StringVarP(&opts.deprecatedFilename, \"filename\", \"\", \"\", \"relative path within the repository to the manifest file (default to okteto-pipeline.yaml or .okteto/okteto-pipeline.yaml)\")\n\tif err := cmd.Flags().MarkHidden(\"filename\"); err != nil {\n\t\toktetoLog.Infof(\"failed to hide deprecated flag: %s\", err)\n\t}\n\treturn cmd\n}", "func DeployCmd() prompter.Command {\n\treturn prompter.Command{\n\t\tName: \"deploy\",\n\t\tDescription: \"deploy borrowed time and generate a config file\",\n\t\tExecutor: deployExecutor,\n\t}\n}", "func NewDeployCmd(deployment services.Deployment) cli.Command {\n\treturn cli.Command{\n\t\tName: \"deploy\",\n\t\tAliases: []string{\"d\"},\n\t\tUsage: \"Deploys new version of app, takes newest task definition and updates docker image by creating new revision\",\n\t\tFlags: []cli.Flag{\n\t\t\tcli.StringFlag{\n\t\t\t\tName: \"clusterName\",\n\t\t\t\tUsage: \"Name of ECS cluster to which new version should be deployed\",\n\t\t\t},\n\t\t\tcli.StringFlag{\n\t\t\t\tName: \"serviceName\",\n\t\t\t\tUsage: \"existing service in ECS cluster which should be updated\",\n\t\t\t},\n\t\t\tcli.StringFlag{\n\t\t\t\tName: \"image\",\n\t\t\t\tUsage: \"Image with tag which will be used to create new Task Definition\",\n\t\t\t},\n\t\t\tcli.IntFlag{\n\t\t\t\tName: \"imageIndex\",\n\t\t\t\tUsage: \"Index of image in container definitions that should be updated\",\n\t\t\t\tValue: 0,\n\t\t\t},\n\t\t\tcli.StringFlag{\n\t\t\t\tName: \"codedeployApp\",\n\t\t\t\tUsage: \"codedeploy application which is used to trigger deployment\",\n\t\t\t},\n\t\t\tcli.StringFlag{\n\t\t\t\tName: \"codedeployGroup\",\n\t\t\t\tUsage: \"codedeployGroup group which is used to trigger deployment\",\n\t\t\t},\n\t\t},\n\t\tAction: func(c *cli.Context) error {\n\t\t\tif err := validateRequiredFlags(c, requiredDeployFlags); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tclusterName := c.String(\"clusterName\")\n\t\t\tserviceName := c.String(\"serviceName\")\n\t\t\timage := c.String(\"image\")\n\t\t\timageIndex := c.Int(\"imageIndex\")\n\n\t\t\tcodedeployGroup := c.String(\"codedeployGroup\")\n\t\t\tcodedeployApp := c.String(\"codedeployApp\")\n\n\t\t\tif len(codedeployGroup) == 0 {\n\t\t\t\tcodedeployGroup = serviceName\n\t\t\t}\n\n\t\t\tif len(codedeployApp) == 0 {\n\t\t\t\tcodedeployApp = serviceName\n\t\t\t}\n\n\t\t\toutput, err := deployment.Deploy(&clusterName, &serviceName, &image, imageIndex, &codedeployApp, &codedeployGroup)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\treturn printOutput(output)\n\t\t},\n\t}\n}", "func init() {\n\tRootCmd.AddCommand(DeployCmd)\n\tDeployCmd.Flags().StringP(\"file\", \"f\", \"\", \"file used to specify the job to deploy (required)\")\n\tDeployCmd.Flags().StringP(\"port\", \"p\", \"\", \"connect to a specific port (default: 3939)\")\n\tDeployCmd.MarkFlagRequired(\"file\")\n}", "func deploymentCommand(_ *cobra.Command, _ []string) error {\n\tnodePort := varIntNodePort\n\thome := varStringHome\n\tremote := varStringRemote\n\tbranch := varStringBranch\n\tif len(remote) > 0 {\n\t\trepo, _ := util.CloneIntoGitHome(remote, branch)\n\t\tif len(repo) > 0 {\n\t\t\thome = repo\n\t\t}\n\t}\n\n\tif len(home) > 0 {\n\t\tpathx.RegisterGoctlHome(home)\n\t}\n\n\t// 0 to disable the nodePort type\n\tif nodePort != 0 && (nodePort < basePort || nodePort > portLimit) {\n\t\treturn errors.New(\"nodePort should be between 30000 and 32767\")\n\t}\n\n\ttext, err := pathx.LoadTemplate(category, deployTemplateFile, deploymentTemplate)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tout, err := pathx.CreateIfNotExist(varStringO)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer out.Close()\n\n\tif varIntTargetPort == 0 {\n\t\tvarIntTargetPort = varIntPort\n\t}\n\n\tt := template.Must(template.New(\"deploymentTemplate\").Parse(text))\n\terr = t.Execute(out, Deployment{\n\t\tName: varStringName,\n\t\tNamespace: varStringNamespace,\n\t\tImage: varStringImage,\n\t\tSecret: varStringSecret,\n\t\tReplicas: varIntReplicas,\n\t\tRevisions: varIntRevisions,\n\t\tPort: varIntPort,\n\t\tTargetPort: varIntTargetPort,\n\t\tNodePort: nodePort,\n\t\tUseNodePort: nodePort > 0,\n\t\tRequestCpu: varIntRequestCpu,\n\t\tRequestMem: varIntRequestMem,\n\t\tLimitCpu: varIntLimitCpu,\n\t\tLimitMem: varIntLimitMem,\n\t\tMinReplicas: varIntMinReplicas,\n\t\tMaxReplicas: varIntMaxReplicas,\n\t\tServiceAccount: varStringServiceAccount,\n\t\tImagePullPolicy: varStringImagePullPolicy,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Println(color.Green.Render(\"Done.\"))\n\treturn nil\n}", "func (c *Context) CreateDeploy(job *work.Job) error {\n // Extract args from job.\n deployUid := job.ArgString(\"deployUid\")\n deployName := job.ArgString(\"name\")\n apiClusterID := uint(job.ArgInt64(\"apiClusterID\"))\n modelVersionID := uint(job.ArgInt64(\"modelVersionID\"))\n sha := job.ArgString(\"sha\")\n envs := job.ArgString(\"envs\")\n logKey := job.ArgString(\"logKey\")\n\n if err := job.ArgError(); err != nil {\n if logKey != \"\" {\n return logBuildableErr(err, logKey, \"Arg error occurred inside create deploy job.\")\n }\n\n app.Log.Errorln(err.Error())\n return err\n }\n\n // Find ApiCluster by ID.\n apiCluster, err := apiclustersvc.FromID(apiClusterID)\n if err != nil {\n return logBuildableErr(err, logKey, \"API cluster not found.\")\n }\n\n // Find ModelVersion by ID.\n modelVersion, err := modelversionsvc.FromID(modelVersionID)\n if err != nil {\n return logBuildableErr(err, logKey, \"Model version not found.\")\n }\n\n // Store ref to project.\n project := &modelVersion.Model.Project\n\n // If sha provided, find Commit by that value. Otherwise, fetch latest commit from repo.\n commit, err := commitsvc.FromShaOrLatest(sha, project)\n if err != nil {\n return logBuildableErr(err, logKey, \"Error finding commit sha to deploy.\")\n }\n\n // Upsert Deploy.\n deploy, isNew, err := deploysvc.Upsert(\n commit.ID,\n modelVersion.ID,\n apiCluster.ID,\n deployUid,\n deployName,\n )\n\n if err != nil {\n return logBuildableErr(err, logKey, \"Failed to upsert deploy.\")\n }\n\n // If Deploy already exists, return an \"Everything up-to-date.\" message.\n if !isNew {\n // TODO: stream back a success message with \"Everything up-to-date.\"\n return nil\n }\n\n // Convert stringified envs into map[string]string representation.\n envsMap, err := envvarsvc.MapFromBytes([]byte(envs))\n if err != nil {\n return failDeploy(deploy.ID, err, logKey, \"Failed to parse deploy environment variables.\")\n }\n\n // Create EnvVars for this Deploy.\n if err := envvarsvc.CreateFromMap(deploy.ID, envsMap); err != nil {\n return failDeploy(deploy.ID, err, logKey, \"Failed to create deploy environment variables.\")\n }\n\n // Define args for the BuildDeploy job.\n jobArgs := work.Q{\n \"resourceID\": deploy.ID,\n \"buildTargetSha\": commit.Sha,\n \"projectID\": project.ID,\n \"targetCluster\": cluster.Api,\n \"logKey\": logKey,\n \"followOnJob\": Names.ApiDeploy,\n \"followOnArgs\": enc.JSON{\n \"deployID\": deploy.ID,\n \"logKey\": logKey,\n },\n }\n\n // Enqueue new job to build this Project for the ApiCluster.\n if _, err := app.JobQueue.Enqueue(Names.BuildDeploy, jobArgs); err != nil {\n return failDeploy(deploy.ID, err, logKey, \"Failed to schedule build deploy job.\")\n }\n\n // Update deploy stage to BuildScheduled.\n if err := deploysvc.UpdateStage(deploy, model.BuildStages.BuildScheduled); err != nil {\n return failDeploy(deploy.ID, err, logKey, \"Failed to update stage of deploy.\")\n }\n\n return nil\n}", "func Run(argv []string) (err error) {\n\tenvFlag := cli.StringFlag{\n\t\tName: \"env\",\n\t\tValue: \"dev\",\n\t\tUsage: \"Specify Space environment\",\n\t}\n\n\tdownloadCommand := cli.Command{\n\t\tName: \"pull\",\n\t\tAliases: []string{\"download\"},\n\t\tUsage: \"Download file from Space\",\n\t\tArgsUsage: \"Space object's name\",\n\t\tFlags: []cli.Flag{\n\t\t\t&envFlag,\n\t\t\t&cli.StringFlag{\n\t\t\t\tName: \"output\",\n\t\t\t\tAliases: []string{\"o\"},\n\t\t\t\tUsage: \"Output file, otherwise use object's name\",\n\t\t\t\tValue: \"\",\n\t\t\t},\n\t\t},\n\t\tAction: downloadAction,\n\t}\n\n\tlistInternalCommand := cli.Command{\n\t\tName: \"list-internal\",\n\t\tUsage: \"List available buckets or objects in Space. Not a good idea for production bucket.\",\n\t\tArgsUsage: \"If given, list all objects in {bucket}/{prefix}, otherwise list all buckets\",\n\t\tHideHelp: true,\n\t\tHidden: true,\n\t\tFlags: []cli.Flag{\n\t\t\t&envFlag,\n\t\t},\n\t\tAction: listInternalAction,\n\t}\n\n\tlistCommand := cli.Command{\n\t\tName: \"list\",\n\t\tUsage: \"List available objects in Space.\",\n\t\tArgsUsage: \"Prefix\",\n\t\tFlags: []cli.Flag{\n\t\t\t&envFlag,\n\t\t},\n\t\tAction: listAction,\n\t}\n\n\tpushCommand := cli.Command{\n\t\tName: \"push\",\n\t\tAliases: []string{\"upload\"},\n\t\tUsage: \"Upload file/folder to Space\",\n\t\tArgsUsage: \"File or folder path to upload\",\n\t\tFlags: []cli.Flag{\n\t\t\t&envFlag,\n\t\t\t&cli.BoolFlag{\n\t\t\t\tName: \"recursive\",\n\t\t\t\tAliases: []string{\"r\"},\n\t\t\t\tUsage: \"Upload a folder recursively\",\n\t\t\t\tValue: false,\n\t\t\t},\n\t\t\t&cli.StringFlag{\n\t\t\t\tName: \"prefix\",\n\t\t\t\tAliases: []string{\"p\"},\n\t\t\t\tUsage: \"Object name's prefix.\",\n\t\t\t\tValue: \"\",\n\t\t\t},\n\t\t\t&cli.StringFlag{\n\t\t\t\tName: \"tags\",\n\t\t\t\tAliases: []string{\"t\"},\n\t\t\t\tUsage: \"Add tags, e.g. \\\"version: 0.0, type: app\\\"\",\n\t\t\t\tValue: \"\",\n\t\t\t},\n\t\t},\n\t\tAction: pushAction,\n\t}\n\n\tremoveCommand := cli.Command{\n\t\tName: \"remove\",\n\t\tAliases: []string{\"rm\"},\n\t\tUsage: \"Remove file(s) in Space\",\n\t\tArgsUsage: \"Files to be removed\",\n\t\tFlags: []cli.Flag{\n\t\t\t&envFlag,\n\t\t},\n\t\tAction: removeAction,\n\t}\n\n\tapp := &cli.App{\n\t\tName: \"space\",\n\t\tUsage: \"Work with Space and assets\",\n\t\tCommands: []*cli.Command{\n\t\t\t&downloadCommand,\n\t\t\t&listInternalCommand,\n\t\t\t&listCommand,\n\t\t\t&pushCommand,\n\t\t\t&removeCommand,\n\t\t},\n\t}\n\n\terr = app.Run(argv)\n\treturn err\n}", "func Deploy(w http.ResponseWriter, r *http.Request) {\n\t// this will hold our decoded request json\n var requestParams deployStruct\n\t// let's decode request body\n decoder := json.NewDecoder(r.Body)\n err := decoder.Decode(&requestParams)\n\t// is it a bad request?\n if err != nil {\n log.Print(\"ERROR: failed to decode request JSON\")\n\t\thttp.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)\n }\n\n\t// let's forward request to docker hosts\n\tfmt.Fprintln(w, DeployAndRunContainer(&requestParams))\n}", "func (n *NodeClient) Deploy(dl *gridtypes.Deployment, update bool) error {\n\tdl.TwinID = n.client.id\n\tvar buf bytes.Buffer\n\n\tif err := json.NewEncoder(&buf).Encode(dl); err != nil {\n\t\treturn errors.Wrap(err, \"failed to serialize workload\")\n\t}\n\n\turl := n.url(\"deployment\")\n\tm := http.MethodPost\n\tif update {\n\t\tm = http.MethodPut\n\t}\n\n\trequest, err := http.NewRequest(m, url, &buf)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to build request\")\n\t}\n\n\tif err := n.client.authorize(request); err != nil {\n\t\treturn errors.Wrap(err, \"failed to sign request\")\n\t}\n\n\tresponse, err := http.DefaultClient.Do(request)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := n.response(response, nil, http.StatusAccepted); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (c InstallCmd) Run(out io.Writer) error {\n\tvar err error\n\tlog.Info(\"Installing platform \", c.Platform)\n\tctx := context.TODO()\n\n\tif err := c.ReadPlatformConfig(c.PlatformConfig); err != nil {\n\t\treturn err\n\t}\n\tif err := c.PlatformConfig.Generate(ctx); err != nil {\n\t\treturn err\n\t}\n\tif err := c.WritePlatformConfig(c.PlatformConfig); err != nil {\n\t\treturn err\n\t}\n\n\tmanifestURL, err := c.ManifestBase.Parse(fmt.Sprintf(\"platforms/%s.jsonnet\", c.Platform))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to construct manifest URL: %v\", err)\n\t}\n\n\tlog.Infof(\"Using manifests from %s\", manifestURL)\n\tif err := prodruntime.WriteRootManifest(manifestURL); err != nil {\n\t\treturn err\n\t}\n\n\tif c.OnlyGenerate {\n\t\tfmt.Println(\"Skipping deployment because --only-generate was provided.\")\n\t} else {\n\t\tlog.Info(\"Deploying Bitnami Kubernetes Production Runtime for platform \", c.Platform)\n\t\tif err := c.Update(out); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func Run(ctx context.Context /*clusterConfigs config.K8S,*/, k8sRepoConfig config.KubernetesConfigsRepo, slashcmd, txt, caller string) (messages []string, err error) {\n\tcommand.DeployWorker.Set(k8sRepoConfig.Git)\n\tif slashcmd != ACCEPTED_SLASHCMD {\n\t\treturn []string{\"call help\"}, errors.Errorf(\"%s is not a supported slash command\", slashcmd)\n\t}\n\ttxtParts := strings.Split(txt, \" \")\n\tif len(txtParts) == 0 {\n\t\t// TODO send help\n\t\treturn []string{\"call help\"}, nil\n\t}\n\n\tcmd := txtParts[0]\n\tswitch cmd {\n\t// case \"list\":\n\t// \tmessages, err = command.List(ctx, clusterConfigs, txtParts[1:])\n\t// case \"info\":\n\t// \tmessages, err = command.Info(ctx, clusterConfigs, txtParts[1:])\n\tcase \"deploy\":\n\t\tmessages, err = command.Deploy(ctx, k8sRepoConfig, txtParts[1:], txt, \"+\"+caller)\n\tcase \"release\":\n\t\tmessages, err = command.Release(ctx, k8sRepoConfig, txtParts[1:], txt, \"+\"+caller)\n\tdefault:\n\t\tif isBowie(txtParts) {\n\t\t\tmessages = command.Bowie()\n\t\t} else {\n\t\t\tmessages = []string{\"call help\"}\n\t\t\terr = errors.Errorf(\"command(%s) is not supported\", cmd)\n\t\t}\n\t}\n\treturn messages, err\n}", "func (c *DetaClient) Deploy(r *DeployRequest) (*DeployResponse, error) {\n\theaders := make(map[string]string)\n\tc.injectResourceHeader(headers, r.Account, r.Region)\n\n\ti := &requestInput{\n\t\tPath: fmt.Sprintf(\"/%s/\", patcherPath),\n\t\tMethod: \"POST\",\n\t\tHeaders: headers,\n\t\tBody: r,\n\t\tNeedsAuth: true,\n\t}\n\to, err := c.request(i)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif o.Status != 200 {\n\t\tmsg := o.Error.Message\n\t\tif msg == \"\" {\n\t\t\tmsg = o.Error.Errors[0]\n\t\t}\n\t\treturn nil, fmt.Errorf(\"failed to deploy: %v\", msg)\n\t}\n\n\tvar resp DeployResponse\n\terr = json.Unmarshal(o.Body, &resp)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to deploy: %v\", err)\n\t}\n\treturn &resp, nil\n}", "func folderDeploy(cmd *cobra.Command, args []string) {\n\t//Check deploy template file.\n\tif len(args) <= 0 || utils.IsFileExist(args[0]) == false {\n\t\tfmt.Fprintf(os.Stderr, \"the template files path is required, %s\\n\", \"see https://github.com/Huawei/containerops/singular for more detail.\")\n\t\tos.Exit(1)\n\t}\n\n\tif utils.IsDirExist(args[0]) == false {\n\t\tfmt.Fprintf(os.Stderr, \"the %s folder is not exist\\n\", args[0])\n\t\tos.Exit(1)\n\t}\n\n\tif files, err := utils.WalkDir(args[0], \"yml\"); err != nil {\n\t\tfmt.Fprintf(os.Stderr, err.Error())\n\t\tos.Exit(1)\n\t} else {\n\t\tfor _, file := range files {\n\t\t\tif utils.IsFileExist(file) == false {\n\t\t\t\tfmt.Fprintf(os.Stderr, \"the %s file is not exist\\n\", file)\n\t\t\t}\n\n\t\t\td := new(objects.Deployment)\n\n\t\t\t//Read template file and parse.\n\t\t\tif err := d.ParseFromFile(file, output); err != nil {\n\t\t\t\tfmt.Fprintf(os.Stderr, \"parse deploy template error: %s\\n\", err.Error())\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\n\t\t\t//Set private key file path.\n\t\t\tif privateKey != \"\" {\n\t\t\t\td.Tools.SSH.Private, d.Tools.SSH.Public = privateKey, publicKey\n\t\t\t}\n\n\t\t\t//The integrity checking of deploy template.\n\t\t\tif err := d.Check(); err != nil {\n\t\t\t\tfmt.Fprintf(os.Stderr, \"parse deploy template error: %s\\n\", err.Error())\n\t\t\t}\n\n\t\t\t//Set log and error io.Writer\n\t\t\tvar logWriters io.Writer\n\n\t\t\t//Generate stdout/stderr io.Writer\n\t\t\tstdoutFile, _ := os.Create(path.Join(d.Config, \"deploy.log\"))\n\t\t\tdefer stdoutFile.Close()\n\n\t\t\t//Using MultiWriter log and error.\n\t\t\tif verbose == true {\n\t\t\t\tlogWriters = io.MultiWriter(stdoutFile, os.Stdout)\n\t\t\t} else {\n\t\t\t\tlogWriters = io.MultiWriter(stdoutFile)\n\t\t\t}\n\n\t\t\t//Deploy cloud native stack\n\t\t\tif err := module.DeployInfraStacks(d, db, logWriters, timestamp); err != nil {\n\t\t\t\tfmt.Fprintf(os.Stderr, \"%s\\n\", err.Error())\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\n\t\t\t//Delete droplets\n\t\t\tif del == true {\n\t\t\t\tif err := module.DeleteInfraStacks(d, logWriters, timestamp); err != nil {\n\t\t\t\t\tfmt.Fprintf(os.Stderr, \"%s\\n\", err.Error())\n\t\t\t\t\tos.Exit(1)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func Deploy(cmd *cobra.Command, args []string) {\n\tappPath := \"\"\n\n\t// This helps break up many of the functions/steps for deployment\n\tdeployer := deploy.NewDeployer(&cfg, getAWSSession())\n\n\t// It is possible to pass a specific zip file from the config instead of building a new one (why would one? who knows, but I liked the pattern of using cfg)\n\tif cfg.Lambda.SourceZip == \"\" {\n\t\t// Build the Go app in the current directory (for AWS architecture).\n\t\tappPath, err := build(&cfg.App.BuildEnvVars)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"There was a problem building the Go app for the Lambda function.\")\n\t\t\tfmt.Println(err.Error())\n\t\t\tos.Exit(-1)\n\t\t}\n\t\t// Ensure it's executable.\n\t\t// err = os.Chmod(appPath, os.FileMode(int(0777)))\n\t\terr = os.Chmod(appPath, os.ModePerm)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"Warning, executable permissions could not be set on Go binary. It may fail to run in AWS.\")\n\t\t\tfmt.Println(err.Error())\n\t\t}\n\n\t\t// Adjust timestamp?\n\t\t// err = os.Chtimes(appPath, time.Now(), time.Now())\n\t\t// if err != nil {\n\t\t// \tfmt.Println(\"Warning, executable permissions could not be set on Go binary. It may fail to run in AWS.\")\n\t\t// \tfmt.Println(err.Error())\n\t\t// }\n\n\t\tcfg.Lambda.SourceZip = compress(cfg.App.BuildFileName)\n\t\t// If something went wrong, exit\n\t\tif cfg.Lambda.SourceZip == \"\" {\n\t\t\tfmt.Println(\"There was a problem building the Lambda function zip file.\")\n\t\t\tos.Exit(-1)\n\t\t}\n\t}\n\n\t// Get the Lambda function zip file's bytes\n\tvar zipBytes []byte\n\tzipBytes, err := ioutil.ReadFile(cfg.Lambda.SourceZip)\n\tif err != nil {\n\t\tfmt.Println(\"Could not read from Lambda function zip file.\")\n\t\tfmt.Println(err)\n\t\tos.Exit(-1)\n\t}\n\n\t// If no role, create an aegis role for executing Lambda functions.\n\t// This will actually be rather permissive. Use a custom role to be more restrictive.\n\t// The aegis framework needs the ability to invoke other Lambdas, work with XRay, S3, and more.\n\t// So it's going to be a few managed policies that make sense. Use a custom role if needed.\n\t// When roles are passed to use, they are not modified.\n\tif cfg.Lambda.Role == \"\" {\n\t\tcfg.Lambda.Role = createOrUpdateAegisRole()\n\n\t\t// Have to delay a few seconds to give AWS some time to set up the role.\n\t\t// Assigning it to the Lambda too soon could result in an error:\n\t\t// InvalidParameterValueException: The role defined for the function cannot be assumed by Lambda.\n\t\t// Apparently it needs a few seconds ¯\\_(ツ)_/¯\n\t\ttime.Sleep(5 * time.Second)\n\t}\n\n\t// Create (or update) the function\n\tlambdaArn := deployer.CreateFunction(zipBytes)\n\n\t// Create the API Gateway API with proxy resource.\n\t// This only needs to be done once as it shouldn't change and additional resources can't be configured.\n\t// So it will check first for the same name before creating. If a match is found, that API ID will be returned.\n\t//\n\t// TODO: Maybe prompt the user to overwrite? Because if the name matches, it will go on to deploy stages on\n\t// that API...Which may be bad. I wish API names had to be unique. That would be a lot better.\n\t// Think on what to do here because it could create a bad experience...It's also nice to have one \"deploy\" command\n\t// that also deploys stages and picks up new stages as the config changes. Could always break out deploy stage\n\t// into a separate command...Again, all comes down to experience and expectations. Warnings might be enough...\n\t// But a prompt on each \"deploy\" command after the first? Maybe too annoying. Could pass an \"--ignore\" flag or force\n\t// to solve those annoyances though.\n\tapiID := deployer.ImportAPI(*lambdaArn)\n\t// TODO: Allow updates...this isn't quite working yet\n\t// The DeployAPI() function will take care of some updates as well (things like stage variables, etc.).\n\t// deployer.UpdateAPI(apiID, *lambdaArn)\n\n\t// fmt.Printf(\"API ID: %s\\n\", apiID)\n\n\t// Ensure the API can access the Lambda\n\tdeployer.AddAPIPermission(apiID, *lambdaArn)\n\n\t// Ensure the API has it's binary media types set (Swagger import apparently does not set them)\n\tdeployer.AddBinaryMediaTypes(apiID)\n\n\t// Deploy for each stage (defaults to just one \"prod\" stage).\n\t// However, this can be changed over time (cache settings, stage variables, etc.) and is relatively harmless to re-deploy\n\t// on each run anyway. Plus, new stages can be added at any time.\n\tfor key := range cfg.API.Stages {\n\t\tinvokeURL := deployer.DeployAPI(apiID, cfg.API.Stages[key])\n\t\t// fmt.Printf(\"%s API Invoke URL: %s\\n\", key, invokeURL)\n\t\tfmt.Printf(\"%v %v %v\\n\", color.GreenString(key), \"API URL:\", color.GreenString(invokeURL))\n\t}\n\n\t// Tasks (CloudWatch event rules to trigger Lambda)\n\tfmt.Printf(\"\\n\")\n\tdeployer.AddTasks()\n\n\t// Bucket notifications (to trigger Lambda)\n\tfmt.Printf(\"\\n\")\n\tdeployer.AddS3BucketNotifications()\n\n\t// SES Recipient Rules (to trigger Lambda)\n\tif cfg.SESRules != nil && len(cfg.SESRules) > 0 {\n\t\tfmt.Printf(\"\\n\")\n\t\tdeployer.AddSESPermission(lambdaArn)\n\t\tdeployer.AddSESRules()\n\t}\n\n\t// Clean up\n\tif !cfg.App.KeepBuildFiles {\n\t\tos.Remove(cfg.Lambda.SourceZip)\n\t\t// Remember the Go app may not be built if the source zip file was passed via configuration/CLI flag.\n\t\t// However, if it is build then it's for AWS architecture and likely isn't needed by the user. Clean it up.\n\t\t// Note: It should be called `aegis_app` to help avoid conflicts.\n\t\tif _, err := os.Stat(appPath); err == nil {\n\t\t\tos.Remove(appPath)\n\t\t}\n\t}\n\n}", "func Deploy(args []string) error {\n\t// TODO: check if the main/env.go file has changed based on env.txt:\n\t// If it has changed and the \"change-env\" argument is not set, print\n\t// an error message and return. If it has changed and \"change-env\" is\n\t// set, replace main/env.go.\n\t// If it has not changed, don't do anything to the existing file.\n\treturn nil\n}", "func Command(app *kingpin.Application) {\n\tcmd := new(command)\n\n\tcommand := app.Command(\"deploy\", \"Triggers a deployment\").Action(cmd.run)\n\tcommand.Flag(\"key\", \"Key used to authenticate to the Acquia API\").Envar(\"ACQUIA_KEY\").StringVar(&cmd.Key)\n\tcommand.Flag(\"secret\", \"Secret used to authenticate to the Acquia API\").Envar(\"ACQUIA_SECRET\").StringVar(&cmd.Secret)\n\tcommand.Arg(\"environment\", \"UUID of the environment which we will be triggering a deployment\").Required().StringVar(&cmd.Environment)\n\tcommand.Arg(\"branch\", \"Branch to deploy\").Required().StringVar(&cmd.Branch)\n}", "func (s *deployerService) Deploy(ctx context.Context, db *gorm.DB, opts DeploymentsCreateOpts) (*Release, error) {\n\tvar msg jsonmessage.JSONMessage\n\n\tr, err := s.deploy(ctx, db, opts)\n\tif err != nil {\n\t\tmsg = newJSONMessageError(err)\n\t} else {\n\t\tmsg = jsonmessage.JSONMessage{Status: fmt.Sprintf(\"Status: Created new release v%d for %s\", r.Version, r.App.Name)}\n\t}\n\n\tif err := json.NewEncoder(opts.Output).Encode(&msg); err != nil {\n\t\treturn r, err\n\t}\n\n\treturn r, err\n}", "func deployCmds(app provision.App, version string) ([]string, error) {\n\tdeployCmd, err := config.GetString(\"docker:deploy-cmd\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tappRepo := repository.ReadOnlyURL(app.GetName())\n\tuser, err := config.GetString(\"docker:ssh:user\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcmds := []string{\"sudo\", \"-u\", user, deployCmd, appRepo, version}\n\treturn cmds, nil\n}", "func templateDeploy(cmd *cobra.Command, args []string) {\n\t//Check deploy template file.\n\tif len(args) <= 0 || utils.IsFileExist(args[0]) == false {\n\t\tfmt.Fprintf(os.Stderr, \"the deploy template file is required, %s\\n\", \"see https://github.com/Huawei/containerops/singular for more detail.\")\n\t\tos.Exit(1)\n\t}\n\n\ttemplate := args[0]\n\td := new(objects.Deployment)\n\n\t//Read template file and parse.\n\tif err := d.ParseFromFile(template, output); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"parse deploy template error: %s\\n\", err.Error())\n\t\tos.Exit(1)\n\t}\n\n\t//Set private key file path.\n\tif privateKey != \"\" {\n\t\td.Tools.SSH.Private, d.Tools.SSH.Public = privateKey, publicKey\n\t}\n\n\t//The integrity checking of deploy template.\n\tif err := d.Check(); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"parse deploy template error: %s\\n\", err.Error())\n\t\tos.Exit(1)\n\t}\n\n\t//Set log and error io.Writer\n\tvar logWriters io.Writer\n\n\t//Generate stdout/stderr io.Writer\n\tstdoutFile, _ := os.Create(path.Join(d.Config, \"deploy.log\"))\n\tdefer stdoutFile.Close()\n\n\t//Using MultiWriter log and error.\n\tif verbose == true {\n\t\tlogWriters = io.MultiWriter(stdoutFile, os.Stdout)\n\t} else {\n\t\tlogWriters = io.MultiWriter(stdoutFile)\n\t}\n\n\t//Deploy cloud native stack\n\tif err := module.DeployInfraStacks(d, db, logWriters, timestamp); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"%s\\n\", err.Error())\n\t\tos.Exit(1)\n\t}\n\n\t//Delete droplets\n\tif del == true {\n\t\tif err := module.DeleteInfraStacks(d, logWriters, timestamp); err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"%s\\n\", err.Error())\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n}", "func Deploy(opts DeployOptions) error {\n\tvar outBuffer bytes.Buffer\n\tstart := time.Now()\n\tlogWriter := LogWriter{App: opts.App}\n\tlogWriter.Async()\n\tdefer logWriter.Close()\n\twriter := io.MultiWriter(&tsuruIo.NoErrorWriter{Writer: opts.OutputStream}, &outBuffer, &logWriter)\n\timageId, err := deployToProvisioner(&opts, writer)\n\telapsed := time.Since(start)\n\tsaveErr := saveDeployData(&opts, imageId, outBuffer.String(), elapsed, err)\n\tif saveErr != nil {\n\t\tlog.Errorf(\"WARNING: couldn't save deploy data, deploy opts: %#v\", opts)\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = incrementDeploy(opts.App)\n\tif err != nil {\n\t\tlog.Errorf(\"WARNING: couldn't increment deploy count, deploy opts: %#v\", opts)\n\t}\n\tif opts.App.UpdatePlatform == true {\n\t\topts.App.SetUpdatePlatform(false)\n\t}\n\treturn nil\n}", "func (r Runner) Deploy(deploymentName string, manifestFilename string) error {\n\treturn r.DeployWithFlags(deploymentName, manifestFilename)\n}", "func (o *CreateDeploymentOptions) Run() error {\n\tdeploy := o.createDeployment()\n\n\tif err := util.CreateOrUpdateAnnotation(o.CreateAnnotation, deploy, scheme.DefaultJSONEncoder()); err != nil {\n\t\treturn err\n\t}\n\n\tif o.DryRunStrategy != cmdutil.DryRunClient {\n\t\tcreateOptions := metav1.CreateOptions{}\n\t\tif o.FieldManager != \"\" {\n\t\t\tcreateOptions.FieldManager = o.FieldManager\n\t\t}\n\t\tcreateOptions.FieldValidation = o.ValidationDirective\n\t\tif o.DryRunStrategy == cmdutil.DryRunServer {\n\t\t\tcreateOptions.DryRun = []string{metav1.DryRunAll}\n\t\t}\n\t\tvar err error\n\t\tdeploy, err = o.Client.Deployments(o.Namespace).Create(context.TODO(), deploy, createOptions)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create deployment: %v\", err)\n\t\t}\n\t}\n\n\treturn o.PrintObj(deploy)\n}", "func Execute() {\n\t// redirect stderr to stdout (to capture panics)\n\tsyscall.Dup2(int(os.Stdout.Fd()), int(os.Stderr.Fd()))\n\n\t// we're speaking to the local server only ever\n\tserverAddr := fmt.Sprintf(\"localhost:%d\", *port)\n\tcreds := client.GetClientCreds()\n\tfmt.Printf(\"Connecting to local autodeploy server:%s...\\n\", serverAddr)\n\tconn, err := grpc.Dial(serverAddr, grpc.WithTransportCredentials(creds))\n\tif err != nil {\n\t\tfmt.Println(\"fail to dial: %v\", err)\n\t\treturn\n\t}\n\tdefer conn.Close()\n\tfmt.Println(\"Creating client...\")\n\tcl := pb.NewAutoDeployerClient(conn)\n\tctx := client.SetAuthToken()\n\n\t// the the server we're starting to deploy and get the parameters for deployment\n\tsr := pb.StartupRequest{Msgid: *msgid}\n\tsrp, err := cl.InternalStartup(ctx, &sr)\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to startup: %s\\n\", err)\n\t\tos.Exit(10)\n\t}\n\tif srp.URL == \"\" {\n\t\tfmt.Printf(\"no download url in startup response\\n\")\n\t\tos.Exit(10)\n\t}\n\n\t// change to my working directory\n\terr = os.Chdir(srp.WorkingDir)\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to Chdir() to %s: %s\\n\", srp.WorkingDir, err)\n\t}\n\tfmt.Printf(\"Chdir() to %s\\n\", srp.WorkingDir)\n\t// download the binary and/or archive\n\tbinary := \"executable\"\n\tif srp.Binary != \"\" {\n\t\tbinary = srp.Binary\n\t}\n\tfmt.Printf(\"Downloading binary from %s\\n\", srp.URL)\n\terr = DownloadBinary(srp.URL, binary, srp.DownloadUser, srp.DownloadPassword)\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to download from %s: %s\\n\", srp.URL, err)\n\t\tos.Exit(10)\n\t}\n\n\t// execute the binary\n\tports := countPortCommands(srp.Args)\n\n\tfmt.Printf(\"Getting resources\\n\")\n\tresources, err := cl.AllocResources(ctx, &pb.ResourceRequest{Msgid: *msgid, Ports: int32(ports)})\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to alloc resources: %s\\n\", err)\n\t\tos.Exit(10)\n\t}\n\tfmt.Printf(\"Start commandline: %s %v (%d ports)\\n\", binary, srp.Args, ports)\n\trArgs := replacePorts(srp.Args, resources.Ports)\n\tfmt.Printf(\"Starting binary \\\"%s\\\" with %d args:\\n\", binary, len(srp.Args))\n\n\tfor _, s := range rArgs {\n\t\tfmt.Printf(\"Arg: \\\"%s\\\"\\n\", s)\n\t}\n\tpath := \"./\"\n\tfullb := fmt.Sprintf(\"%s/%s\", path, binary)\n\terr = os.Chmod(fullb, 0500)\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to chmod %s: %s\\n\", fullb, err)\n\t\tos.Exit(10)\n\t}\n\n\tfmt.Printf(\"Starting user application..\\n\")\n\tcmd := exec.Command(fullb, rArgs...)\n\tcmd.Stdout = os.Stdout\n\tcmd.Stderr = os.Stderr\n\terr = cmd.Start()\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to start(): %s\\n\", err)\n\t\tos.Exit(10)\n\t}\n\t_, err = cl.Started(ctx, &pb.StartedRequest{Msgid: *msgid})\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to inform daemon about pending startup. aborting. (%s)\\n\", err)\n\t\tos.Exit(10)\n\t}\n\terr = cmd.Wait()\n\tif err == nil {\n\t\tfmt.Printf(\"Command completed with no error\\n\")\n\t} else {\n\t\tfmt.Printf(\"Command completed: %s\\n\", err)\n\t}\n\tfailed := err != nil\n\tcl.Terminated(ctx, &pb.TerminationRequest{Msgid: *msgid, Failed: failed})\n\tos.Exit(0)\n}", "func (d *DeployManager) Deploy() (operationResult controllerutil.OperationResult, err error) {\n\n\tvar volumes []corev1.Volume\n\tvar volumeMounts []corev1.VolumeMount\n\tvar imagePullSecrets []corev1.LocalObjectReference\n\tvar depStrategy appsv1.DeploymentStrategy\n\tconfigParameter := \"\"\n\tappParameter := \"\"\n\tappsMap := make(map[string]string)\n\n\td.CreateLabels()\n\tcontainerPorts := d.Application.ContainerPorts\n\tif d.Image.Secret != \"\" {\n\t\tsecret := createLocalObjectReference(d.Image.Secret)\n\t\timagePullSecrets = append(imagePullSecrets, secret)\n\t}\n\n\tq := corev1.PersistentVolumeClaimSpec{}\n\tif d.Application.PersistenceEnabled {\n\t\tif !siddhiv1alpha2.EqualsPVCSpec(&d.SiddhiProcess.Spec.PVC, &q) {\n\t\t\tpvcName := d.Application.Name + PVCExtension\n\t\t\terr = d.KubeClient.CreateOrUpdatePVC(\n\t\t\t\tpvcName,\n\t\t\t\td.SiddhiProcess.Namespace,\n\t\t\t\td.SiddhiProcess.Spec.PVC,\n\t\t\t\td.SiddhiProcess,\n\t\t\t)\n\t\t\tif err != nil {\n\t\t\t\treturn operationResult, err\n\t\t\t}\n\t\t\tmountPath, err := populateMountPath(d.SiddhiProcess, d.Image.Home, d.Image.Profile)\n\t\t\tif err != nil {\n\t\t\t\treturn operationResult, err\n\t\t\t}\n\t\t\tvolume, volumeMount := createPVCVolumes(pvcName, mountPath)\n\t\t\tvolumes = append(volumes, volume)\n\t\t\tvolumeMounts = append(volumeMounts, volumeMount)\n\t\t}\n\t\tdeployYAMLCMName := d.Application.Name + DepCMExtension\n\t\tsiddhiConfig := StatePersistenceConf\n\t\tif d.SiddhiProcess.Spec.SiddhiConfig != \"\" {\n\t\t\tsiddhiConfig = d.SiddhiProcess.Spec.SiddhiConfig\n\t\t}\n\t\tdata := map[string]string{\n\t\t\tdeployYAMLCMName: siddhiConfig,\n\t\t}\n\t\terr = d.KubeClient.CreateOrUpdateCM(deployYAMLCMName, d.SiddhiProcess.Namespace, data, d.SiddhiProcess)\n\t\tif err != nil {\n\t\t\treturn operationResult, err\n\t\t}\n\t\tmountPath := d.Image.Home + DepConfMountPath\n\t\tvolume, volumeMount := createCMVolumes(deployYAMLCMName, mountPath)\n\t\tvolumes = append(volumes, volume)\n\t\tvolumeMounts = append(volumeMounts, volumeMount)\n\t\tconfigParameter = DepConfParameter + mountPath + deployYAMLCMName\n\t} else if d.SiddhiProcess.Spec.SiddhiConfig != \"\" {\n\t\tdeployYAMLCMName := d.SiddhiProcess.Name + DepCMExtension\n\t\tdata := map[string]string{\n\t\t\tdeployYAMLCMName: d.SiddhiProcess.Spec.SiddhiConfig,\n\t\t}\n\t\terr = d.KubeClient.CreateOrUpdateCM(deployYAMLCMName, d.SiddhiProcess.Namespace, data, d.SiddhiProcess)\n\t\tif err != nil {\n\t\t\treturn operationResult, err\n\t\t}\n\t\tmountPath := d.Image.Home + DepConfMountPath\n\t\tvolume, volumeMount := createCMVolumes(deployYAMLCMName, mountPath)\n\t\tvolumes = append(volumes, volume)\n\t\tvolumeMounts = append(volumeMounts, volumeMount)\n\t\tconfigParameter = DepConfParameter + mountPath + deployYAMLCMName\n\t}\n\n\tmaxUnavailable := intstr.IntOrString{\n\t\tType: artifact.Int,\n\t\tIntVal: MaxUnavailable,\n\t}\n\tmaxSurge := intstr.IntOrString{\n\t\tType: artifact.Int,\n\t\tIntVal: MaxSurge,\n\t}\n\trollingUpdate := appsv1.RollingUpdateDeployment{\n\t\tMaxUnavailable: &maxUnavailable,\n\t\tMaxSurge: &maxSurge,\n\t}\n\tdepStrategy = appsv1.DeploymentStrategy{\n\t\tType: appsv1.RollingUpdateDeploymentStrategyType,\n\t\tRollingUpdate: &rollingUpdate,\n\t}\n\n\tif len(d.Application.Apps) > 0 {\n\t\tappsCMName := d.Application.Name + strconv.Itoa(int(d.SiddhiProcess.Status.CurrentVersion))\n\t\tfor k, v := range d.Application.Apps {\n\t\t\tkey := k + SiddhiExtension\n\t\t\tappsMap[key] = v\n\t\t}\n\t\terr = d.KubeClient.CreateOrUpdateCM(appsCMName, d.SiddhiProcess.Namespace, appsMap, d.SiddhiProcess)\n\t\tif err != nil {\n\t\t\treturn operationResult, err\n\t\t}\n\t\tappsPath := d.Image.Home + SiddhiFilesDir\n\t\tvolume, volumeMount := createCMVolumes(appsCMName, appsPath)\n\t\tvolumes = append(volumes, volume)\n\t\tvolumeMounts = append(volumeMounts, volumeMount)\n\t\tappParameter = AppConfParameter + appsPath + \" \"\n\t} else {\n\t\tappParameter = ParserParameter\n\t}\n\n\tuserID := int64(802)\n\toperationResult, _ = d.KubeClient.CreateOrUpdateDeployment(\n\t\td.Application.Name,\n\t\td.SiddhiProcess.Namespace,\n\t\td.Application.Replicas,\n\t\td.Labels,\n\t\td.Image.Name,\n\t\tContainerName,\n\t\t[]string{Shell},\n\t\t[]string{\n\t\t\tfilepath.Join(d.Image.Home, SiddhiBin, (d.Image.Profile + \".sh\")),\n\t\t\tappParameter,\n\t\t\tconfigParameter,\n\t\t},\n\t\tcontainerPorts,\n\t\tvolumeMounts,\n\t\td.SiddhiProcess.Spec.Container.Env,\n\t\tcorev1.SecurityContext{RunAsUser: &userID},\n\t\tcorev1.PullAlways,\n\t\timagePullSecrets,\n\t\tvolumes,\n\t\tdepStrategy,\n\t\td.SiddhiProcess,\n\t)\n\treturn operationResult, err\n}", "func (p *Platform) deploy(ctx context.Context, ui terminal.UI, artifact *registry.Artifact, src *component.Source, job *component.JobInfo) (*Deployment, error) {\n\tu := ui.Status()\n\tdefer u.Close()\n\tu.Update(\"Validating Lambda inputs\")\n\t// Validation Step\n\tu.Step(terminal.StatusOK, \"Lambda input validation is complete. Creating zip file of the application.\")\n\tzipError := ZipCreationFunction(p)\n\tif zipError != nil {\n\t\tu.Step(terminal.StatusError, \"Creation of binary zipfile failed. Application exiting.\")\n\t\treturn nil, zipError\n\t}\n\n\t//utils.DefaultSubnets(ctx, sess)\n\n\treturn &Deployment{}, nil\n}", "func (t *Task) Deploy(clientset *client.ConfigSet) error {\n\ttask := tekton.Task{\n\t\tTypeMeta: metav1.TypeMeta{\n\t\t\tKind: \"Task\",\n\t\t\tAPIVersion: \"tekton.dev/v1alpha1\",\n\t\t},\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: t.Name,\n\t\t\tNamespace: t.Namespace,\n\t\t},\n\t\tSpec: tekton.TaskSpec{\n\t\t\tInputs: &tekton.Inputs{\n\t\t\t\tResources: []tekton.TaskResource{\n\t\t\t\t\t{\n\t\t\t\t\t\tName: \"sources\",\n\t\t\t\t\t\tType: tekton.PipelineResourceType(\"git\"),\n\t\t\t\t\t\tTargetPath: \"/workspace\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tParams: []tekton.TaskParam{\n\t\t\t\t\t{\n\t\t\t\t\t\tName: \"registry\",\n\t\t\t\t\t\tDefault: \"\",\n\t\t\t\t\t\tDescription: \"Where to store resulting image\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tSteps: t.kaniko(),\n\t\t},\n\t}\n\treturn t.createOrUpdate(task, clientset)\n}", "func (c *PushCommand) Run(args []string) int {\n\n\treturn 0\n}", "func (o *DeploymentOpts) Run() error {\n\tone := int32(1)\n\tlabels := map[string]string{\"app\": o.Name}\n\tselector := metav1.LabelSelector{MatchLabels: labels}\n\tnamespace := \"\"\n\tif o.EnforceNamespace {\n\t\tnamespace = o.Namespace\n\t}\n\n\tdeploy := &appsv1.Deployment{\n\t\tTypeMeta: metav1.TypeMeta{APIVersion: appsv1.SchemeGroupVersion.String(), Kind: \"Deployment\"},\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: o.Name,\n\t\t\tLabels: labels,\n\t\t\tNamespace: namespace,\n\t\t},\n\t\tSpec: appsv1.DeploymentSpec{\n\t\t\tReplicas: &one,\n\t\t\tSelector: &selector,\n\t\t\tTemplate: v1.PodTemplateSpec{\n\t\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\t\tLabels: labels,\n\t\t\t\t},\n\t\t\t\tSpec: o.buildPodSpec(),\n\t\t\t},\n\t\t},\n\t}\n\n\tif o.DryRunStrategy != cmdutil.DryRunClient {\n\t\tcreateOptions := metav1.CreateOptions{}\n\t\tif o.FieldManager != \"\" {\n\t\t\tcreateOptions.FieldManager = o.FieldManager\n\t\t}\n\t\tif o.DryRunStrategy == cmdutil.DryRunServer {\n\t\t\tif err := o.DryRunVerifier.HasSupport(deploy.GroupVersionKind()); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tcreateOptions.DryRun = []string{metav1.DryRunAll}\n\t\t}\n\t\tvar err error\n\t\tdeploy, err = o.Client.Deployments(o.Namespace).Create(context.TODO(), deploy, createOptions)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create deployment: %v\", err)\n\t\t}\n\t}\n\n\treturn o.PrintObj(deploy)\n}", "func HandleDeploy(w http.ResponseWriter, r *http.Request) {\r\n\r\n\tif r.Method == \"POST\" {\r\n\r\n\t\tvar err error\r\n\r\n\t\turlPart := strings.Split(r.URL.Path, \"/\")\r\n\r\n\t\tname := urlPart[2]\r\n\r\n\t\tif name != \"\" {\r\n\r\n\t\t\t//basis is optionally passed as qs param\r\n\t\t\tbasis := r.URL.Query().Get(\"basis\")\r\n\r\n\t\t\tdefer r.Body.Close()\r\n\r\n\t\t\tbody, _ := ioutil.ReadAll(r.Body)\r\n\r\n\t\t\tbodyString := string(body)\r\n\r\n\t\t\tvm := otto.New()\r\n\r\n\t\t\t//check it compiles\r\n\t\t\tif script, err := vm.Compile(name, bodyString); err == nil {\r\n\r\n\t\t\t\tif hash, err := storage.Set(name, script, basis); err == nil {\r\n\t\t\t\t\tfmt.Printf(\"Deployed Script %s (%s)\\n\", name, hash)\r\n\t\t\t\t\tw.Write([]byte(hash))\r\n\t\t\t\t\treturn\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tw.Write([]byte(err.Error()))\r\n\t\t\thttp.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)\r\n\r\n\t\t\treturn\r\n\t\t}\r\n\t}\r\n\r\n\thttp.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)\r\n\r\n}", "func (eng *Engine) Run(opts Options) error {\n\tctx := ContextForOptions(opts)\n\n\t// Run the deploy and return if everything works.\n\tfinalErr := eng.runDeploy(ctx)\n\tif finalErr == nil {\n\t\treturn nil\n\t}\n\n\tfmt.Println(strings.Repeat(\"*\", 80))\n\tfmt.Println(\"An error was encountered while deploying the application\")\n\tfmt.Printf(\"The error message was: %v\\n\", finalErr)\n\tfmt.Println(strings.Repeat(\"*\", 80))\n\n\tif err := eng.runRollback(ctx); err != nil {\n\t\treturn nil\n\t}\n\n\treturn finalErr\n}", "func getApp() (app *cli.App) {\n\t// global app variables (name, version, etc)\n\tapp = cli.NewApp()\n\tapp.Name = \"mi-deploy\"\n\tapp.Usage = \"Deploy MI to various public clouds\"\n\tapp.Version = \"0.0.1-dev\"\n\tapp.Author = \"Langston Barrett\"\n\tapp.Email = \"[email protected]\"\n\tlvls := []string{\"debug\", \"info\", \"warn\", \"fatal\", \"panic\"}\n\tlvlsStr := strings.Join(lvls, \" | \")\n\tplatforms := []string{\"aws\", \"digitalocean\", \"gce\", \"openstack\", \"softlayer\", \"vagrant\"}\n\tplatformsStr := strings.Join(platforms, \" | \")\n\n\t// these are command line subcommands like $(git status). They have their\n\t// own flags, but more importantly, actions that are executed when the\n\t// subcommand is used.\n\tapp.Commands = []cli.Command{\n\t\t{\n\t\t\tName: \"deploy\",\n\t\t\tUsage: \"deploy a branch to a platform\",\n\t\t\tFlags: []cli.Flag{\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName: \"platform, p\",\n\t\t\t\t\tValue: \"\",\n\t\t\t\t\tUsage: \"Deploy to this platform. One of:\\n\\t\" + platformsStr,\n\t\t\t\t},\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName: \"branch, b\",\n\t\t\t\t\tValue: \"master\",\n\t\t\t\t\tUsage: \"Deploy this branch (optional, default is master)\",\n\t\t\t\t},\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName: \"url, u\",\n\t\t\t\t\tValue: repoURL,\n\t\t\t\t\tUsage: \"Clone from this remote URL (optional)\",\n\t\t\t\t},\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName: \"verbosity\",\n\t\t\t\t\tValue: \"info\",\n\t\t\t\t\tUsage: lvlsStr,\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t// the logic of deploying a branch\n\t\t\tAction: func(c *cli.Context) {\n\t\t\t\tlog.Debug(\"Running subcommand deploy\")\n\t\t\t\t// set verbosity\n\t\t\t\tsetVerbosity(c.String(\"verbosity\"))\n\t\t\t\trepoURL = c.String(\"url\")\n\t\t\t\tplatform := c.String(\"platform\")\n\t\t\t\tbranch := c.String(\"branch\")\n\t\t\t\t// set global variables\n\t\t\t\tsuffix := RemovePathChars(branch)\n\t\t\t\tsuffix += \"-\" + platform + \"-\" + timestamp + \"/\"\n\t\t\t\tdeploymentDir = path.Join(wd, \"deployments/\", suffix)\n\t\t\t\trepoDir = path.Join(deploymentDir, sh.Basename(repoURL))\n\n\t\t\t\t// deploy\n\t\t\t\tplatforms := []string{\n\t\t\t\t\t\"aws\", \"digitalocean\", \"gce\", \"openstack\", \"softlayer\", \"vagrant\",\n\t\t\t\t}\n\t\t\t\tif platform == \"vagrant\" {\n\t\t\t\t\tdeployToVagrant(branch)\n\t\t\t\t} else if StrIn(platform, platforms) {\n\t\t\t\t\tdeployToCloud(platform, branch)\n\t\t\t\t} else {\n\t\t\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\t\t\"specified\": platform,\n\t\t\t\t\t}).Fatal(\"Invalid platform option passed\")\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"destroy\",\n\t\t\tUsage: \"destroy the resources and files from a deployment\",\n\t\t\tFlags: []cli.Flag{\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName: \"filter, f\",\n\t\t\t\t\tValue: \"\",\n\t\t\t\t\tUsage: \"Only list deployments that match this regex\",\n\t\t\t\t},\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName: \"verbosity\",\n\t\t\t\t\tValue: \"info\",\n\t\t\t\t\tUsage: lvlsStr,\n\t\t\t\t},\n\t\t\t},\n\t\t\tAction: func(c *cli.Context) {\n\t\t\t\tlog.Debug(\"Running subcommand destroy\")\n\t\t\t\t// set verbosity\n\t\t\t\tsetVerbosity(c.String(\"verbosity\"))\n\n\t\t\t\tpromptDestroy(c.String(\"filter\"))\n\t\t\t},\n\t\t},\n\t}\n\treturn app\n}", "func DeploySSH(m *parlaytypes.TreasureMap, logFile string, jsonLogging, background bool) error {\n\n\tif len(ssh.Hosts) == 0 {\n\t\tlog.Warnln(\"No hosts credentials have been loaded, only commands with commandLocal = true will work\")\n\t}\n\tif len(m.Deployments) == 0 {\n\t\treturn fmt.Errorf(\"No Deployments in parlay map\")\n\t}\n\n\tfor x := range m.Deployments {\n\t\t// Build new hosts list from imported SSH servers and compare that we have required credentials\n\t\t_, err := ssh.FindHosts(m.Deployments[x].Hosts)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Begin the deployment\n\tif logFile != \"\" {\n\t\t//enable logging\n\t\tlogger.InitLogFile(logFile)\n\t}\n\n\tif jsonLogging {\n\t\tlogger.InitJSON()\n\t}\n\n\tif background {\n\t\tgo startDeployments(m.Deployments)\n\t} else {\n\t\tstartDeployments(m.Deployments)\n\t}\n\n\t// TODO - test original automation\n\n\t// for x := range m.Deployments {\n\t// \t// Build new hosts list from imported SSH servers and compare that we have required credentials\n\t// \thosts, err := ssh.FindHosts(m.Deployments[x].Hosts)\n\t// \tif err != nil {\n\t// \t\treturn err\n\t// \t}\n\n\t// \t// Beggining of deployment work\n\t// \tlog.Infof(\"Beginning Deployment [%s]\\n\", m.Deployments[x].Name)\n\t// \tlogger.WriteLogEntry(\"\", \"\", \"\", fmt.Sprintf(\"Beginning Deployment [%s]\\n\", m.Deployments[x].Name))\n\n\t// \t// Set Restore checkpoint\n\t// \trestore.Deployment = m.Deployments[x].Name\n\t// \trestore.Hosts = m.Deployments[x].Hosts\n\n\t// \tif m.Deployments[x].Parallel == true {\n\t// \t\t// Begin this deployment in parallel across all hosts\n\t// \t\terr = parallelDeployment(m.Deployments[x].Actions, hosts, &logger)\n\t// \t\tif err != nil {\n\t// \t\t\treturn err\n\t// \t\t}\n\t// \t} else {\n\t// \t\t// This work will be sequential, one host after the next\n\t// \t\tfor z := range m.Deployments[x].Hosts {\n\t// \t\t\tvar hostConfig ssh.HostSSHConfig\n\t// \t\t\t// Find the hosts SSH configuration\n\t// \t\t\tfor i := range hosts {\n\t// \t\t\t\tif hosts[i].Host == m.Deployments[x].Hosts[z] {\n\t// \t\t\t\t\thostConfig = hosts[i]\n\t// \t\t\t\t}\n\t// \t\t\t}\n\t// \t\t\t// Set the state of logging actions to in-progress\n\t// \t\t\tlogger.SetLoggingState(hostConfig.Host, \"Running\")\n\t// \t\t\terr = sequentialDeployment(m.Deployments[x].Actions, hostConfig, &logger)\n\t// \t\t\tif err != nil {\n\t// \t\t\t\tlogger.SetLoggingState(hostConfig.Host, \"Failed\")\n\t// \t\t\t\treturn err\n\t// \t\t\t}\n\t// \t\t\t// Set the state of logging actions to completed\n\t// \t\t\tlogger.SetLoggingState(hostConfig.Host, \"Completed\")\n\t// \t\t}\n\t// \t}\n\t// }\n\treturn nil\n}", "func deployJob(cmd *cobra.Command, args []string) {\n\tport, _ := cmd.Flags().GetString(\"port\")\n\tif port == \"\" {\n\t\tport = DefaultPort\n\t}\n\tname, _ := cmd.Flags().GetString(\"file\")\n\tyaml := unmarsharlYaml(readJobFile(name))\n if !semanticCheck(yaml) {\n os.Exit(2)\n }\n\tcurrentDir, _ := os.Getwd()\n\tvar job NewJob\n\tjob.ID = yaml.Job.ID\n\tjob.UID = fmt.Sprint(syscall.Getuid())\n\tgroup, _ := user.LookupGroup(\"odin\")\n\tgid, _ := strconv.Atoi(group.Gid)\n\tjob.GID = strconv.Itoa(gid)\n\tjob.Name = yaml.Job.Name\n\tjob.Description = yaml.Job.Description\n\tjob.File = currentDir + \"/\" + yaml.Job.File\n\tif yaml.Job.Language == \"go\" {\n\t\tjob.Language = yaml.Job.Language\n\t\tcmd := exec.Command(job.Language, \"build\", job.File)\n\t\tcmd.SysProcAttr = &syscall.SysProcAttr{}\n\t\t_, err := cmd.CombinedOutput()\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tos.Exit(2)\n\t\t}\n\t\tjob.File = job.File[:len(job.File)-3]\n\t} else {\n\t\tjob.Language = yaml.Job.Language\n\t}\n\tjob.Schedule = getScheduleString(name, port)\n\tjobJSON, _ := json.Marshal(job)\n\tbody := makePostRequest(fmt.Sprintf(\"http://localhost%s/jobs/add\", port), bytes.NewBuffer(jobJSON))\n\tfmt.Println(body)\n}", "func (f *FakeController) Deploy(options *deploy.Options, log log.Logger) error {\n\treturn nil\n}", "func (deployer *KubernetesDeployer) Deploy(endpoint *portainer.Endpoint, data string, composeFormat bool, namespace string) ([]byte, error) {\n\tif composeFormat {\n\t\tconvertedData, err := deployer.convertComposeData(data)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdata = string(convertedData)\n\t}\n\n\ttoken, err := ioutil.ReadFile(\"/var/run/secrets/kubernetes.io/serviceaccount/token\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcommand := path.Join(deployer.binaryPath, \"kubectl\")\n\tif runtime.GOOS == \"windows\" {\n\t\tcommand = path.Join(deployer.binaryPath, \"kubectl.exe\")\n\t}\n\n\targs := make([]string, 0)\n\targs = append(args, \"--server\", endpoint.URL)\n\targs = append(args, \"--insecure-skip-tls-verify\")\n\targs = append(args, \"--token\", string(token))\n\targs = append(args, \"--namespace\", namespace)\n\targs = append(args, \"apply\", \"-f\", \"-\")\n\n\tvar stderr bytes.Buffer\n\tcmd := exec.Command(command, args...)\n\tcmd.Stderr = &stderr\n\tcmd.Stdin = strings.NewReader(data)\n\n\toutput, err := cmd.Output()\n\tif err != nil {\n\t\treturn nil, errors.New(stderr.String())\n\t}\n\n\treturn output, nil\n}", "func Deploy(ctx context.Context, cached *dialers.Cached, events chan *agent.Message, options ...Option) {\n\tvar (\n\t\ts = deploying{\n\t\t\tcState: cState{\n\t\t\t\tcached: cached,\n\t\t\t\theartbeat: time.Minute,\n\t\t\t\tconnection: &agent.ConnectionEvent{},\n\t\t\t\tFailureDisplay: FailureDisplayNoop{},\n\t\t\t\tau: aurora.NewAurora(true),\n\t\t\t\tLogger: log.New(os.Stderr, \"[CLIENT] \", 0),\n\t\t\t}.merge(options...),\n\t\t}\n\t)\n\n\ts.run(ctx, events, s)\n}", "func main() {\n\tLogo(Version, true)\n\n\tif len(os.Args) > 1 {\n\t\tif err := ProcessArgument(os.Args[1:]...); err != nil {\n\t\t\tif err.Error() != \"deploy\" {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t} else {\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\n\tLog(\"Checking contents...\")\n\n\tif config, err := CheckCurrentProjectFolder(); err != nil {\n\t\tlog.Fatal(err)\n\t} else {\n\t\tNew(config)\n\n\t\tSetProjectName(config.Name)\n\n\t\tl := RunService()\n\t\tdefer l.Close()\n\n\t\te := RunEndpointService()\n\t\tdefer e.Close()\n\n\t\tStartAuthorizer(config)\n\n\t\tStartEndpoints(config)\n\t\tDeploy(config)\n\t}\n}", "func (eng *Engine) runDeploy(baseCtx context.Context) (err error) {\n\tctx, cancel := context.WithCancel(baseCtx)\n\tdefer cancel()\n\n\tdeployCh := eng.fanIn(func(shipper Shipper) chan error {\n\t\treturn shipper.ShipIt(ctx)\n\t})\n\n\tfor err = range deployCh {\n\t\tfmt.Fprintf(os.Stderr, \"ERROR: %v\\n\", err)\n\t}\n\n\treturn\n}", "func (t *Transport) runCmd(cmd []string) error {\n\tvar err error\n\terr = nil\n\tif !t.dryRun {\n\t\tfmt.Fprintf(t.outLog, \"*** Starting netbackup: %s ***\\n\", time.Now())\n\t\tfmt.Fprintf(t.outLog, \"*** Command: %s ***\\n\", strings.Join(cmd, \" \"))\n\n\t\t// Run\n\t\tt.execute.SetStdout(func(buf string) error { _, err := fmt.Fprintln(t.outLog, buf); return err })\n\t\tt.execute.SetStderr(func(buf string) error { _, err := fmt.Fprintln(t.outLog, buf); return err })\n\t\terr = t.execute.Exec(cmd)\n\t\tfmt.Fprintf(t.outLog, \"*** Command returned: %v ***\\n\", err)\n\t}\n\treturn err\n}", "func NewDeployCmd() *cobra.Command {\n\tcmd := &DeployCmd{}\n\n\tdeployCmd := &cobra.Command{\n\t\tUse: \"deploy\",\n\t\tShort: \"Deploy the project\",\n\t\tLong: `\n#######################################################\n################## devspace deploy ####################\n#######################################################\nDeploys the current project to a Space or namespace:\n\ndevspace deploy\ndevspace deploy --namespace=deploy\ndevspace deploy --namespace=deploy\ndevspace deploy --kube-context=deploy-context\n#######################################################`,\n\t\tArgs: cobra.NoArgs,\n\t\tRun: cmd.Run,\n\t}\n\n\tdeployCmd.Flags().StringVar(&cmd.Namespace, \"namespace\", \"\", \"The namespace to deploy to\")\n\tdeployCmd.Flags().StringVar(&cmd.KubeContext, \"kube-context\", \"\", \"The kubernetes context to use for deployment\")\n\tdeployCmd.Flags().StringVar(&cmd.DockerTarget, \"docker-target\", \"\", \"The docker target to use for building\")\n\n\tdeployCmd.Flags().BoolVar(&cmd.SwitchContext, \"switch-context\", false, \"Switches the kube context to the deploy context\")\n\tdeployCmd.Flags().BoolVarP(&cmd.ForceBuild, \"force-build\", \"b\", false, \"Forces to (re-)build every image\")\n\tdeployCmd.Flags().BoolVarP(&cmd.ForceDeploy, \"force-deploy\", \"d\", false, \"Forces to (re-)deploy every deployment\")\n\n\treturn deployCmd\n}", "func (c *Canary) Deploy(config schemas.Config) error {\n\tif !c.StepStatus[constants.StepCheckPrevious] {\n\t\treturn nil\n\t}\n\tc.Logger.Infof(\"Deploy Mode is %s\", c.Mode)\n\n\t//Get LocalFileProvider\n\tc.LocalProvider = builder.SetUserdataProvider(c.Stack.Userdata, c.AwsConfig.Userdata)\n\tfor i, region := range c.Stack.Regions {\n\t\t//Region check\n\t\t//If region id is passed from command line, then deployer will deploy in that region only.\n\t\tif config.Region != \"\" && config.Region != region.Region {\n\t\t\tc.Logger.Debugf(\"This region is skipped by user : %s\", region.Region)\n\t\t\tcontinue\n\t\t}\n\n\t\tif err := c.ValidateCanaryDeployment(config, region.Region); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tlatestASG := c.LatestAsg[region.Region]\n\t\ttargetGroups, err := c.GetAsgTargetGroups(latestASG, region.Region)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tcanaryVersion := CheckCanaryVersion(targetGroups, region.Region)\n\t\tc.Logger.Debugf(\"Current canary version: %d\", canaryVersion)\n\n\t\tselectedTargetGroup := c.SelectTargetGroupForCopy(region, canaryVersion)\n\t\tc.Logger.Debugf(\"Selected target group to copy: %s\", selectedTargetGroup)\n\n\t\ttgDetail, err := c.DescribeTargetGroup(selectedTargetGroup, region.Region)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Check canary load balancer\n\t\tlbSg, canaryLoadBalancer, err := c.GetLoadBalancerAndSecurityGroupForCanary(region, tgDetail, config.CompleteCanary)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Create canary security group\n\t\terr = c.GetEC2CanarySecurityGroup(tgDetail, region, lbSg, config.CompleteCanary)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tswitch config.CompleteCanary {\n\t\tcase true:\n\t\t\tif err := c.CompleteCanaryDeployment(config, region, latestASG); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase false:\n\t\t\tchangedRegionConfig, err := c.RunCanaryDeployment(config, region, tgDetail, canaryLoadBalancer, canaryVersion)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tc.Stack.Regions[i] = changedRegionConfig\n\t\t}\n\t}\n\n\tc.StepStatus[constants.StepDeploy] = true\n\treturn nil\n}", "func Execute() {\n\tlog.Entry().Infof(\"Version %s\", GitCommit)\n\n\trootCmd.AddCommand(ArtifactPrepareVersionCommand())\n\trootCmd.AddCommand(ConfigCommand())\n\trootCmd.AddCommand(DefaultsCommand())\n\trootCmd.AddCommand(ContainerSaveImageCommand())\n\trootCmd.AddCommand(CommandLineCompletionCommand())\n\trootCmd.AddCommand(VersionCommand())\n\trootCmd.AddCommand(DetectExecuteScanCommand())\n\trootCmd.AddCommand(HadolintExecuteCommand())\n\trootCmd.AddCommand(KarmaExecuteTestsCommand())\n\trootCmd.AddCommand(UiVeri5ExecuteTestsCommand())\n\trootCmd.AddCommand(SonarExecuteScanCommand())\n\trootCmd.AddCommand(KubernetesDeployCommand())\n\trootCmd.AddCommand(HelmExecuteCommand())\n\trootCmd.AddCommand(XsDeployCommand())\n\trootCmd.AddCommand(GithubCheckBranchProtectionCommand())\n\trootCmd.AddCommand(GithubCommentIssueCommand())\n\trootCmd.AddCommand(GithubCreateIssueCommand())\n\trootCmd.AddCommand(GithubCreatePullRequestCommand())\n\trootCmd.AddCommand(GithubPublishReleaseCommand())\n\trootCmd.AddCommand(GithubSetCommitStatusCommand())\n\trootCmd.AddCommand(GitopsUpdateDeploymentCommand())\n\trootCmd.AddCommand(CloudFoundryDeleteServiceCommand())\n\trootCmd.AddCommand(AbapEnvironmentPullGitRepoCommand())\n\trootCmd.AddCommand(AbapEnvironmentCloneGitRepoCommand())\n\trootCmd.AddCommand(AbapEnvironmentCheckoutBranchCommand())\n\trootCmd.AddCommand(AbapEnvironmentCreateTagCommand())\n\trootCmd.AddCommand(AbapEnvironmentCreateSystemCommand())\n\trootCmd.AddCommand(CheckmarxExecuteScanCommand())\n\trootCmd.AddCommand(CheckmarxOneExecuteScanCommand())\n\trootCmd.AddCommand(FortifyExecuteScanCommand())\n\trootCmd.AddCommand(CodeqlExecuteScanCommand())\n\trootCmd.AddCommand(CredentialdiggerScanCommand())\n\trootCmd.AddCommand(MtaBuildCommand())\n\trootCmd.AddCommand(ProtecodeExecuteScanCommand())\n\trootCmd.AddCommand(MavenExecuteCommand())\n\trootCmd.AddCommand(CloudFoundryCreateServiceKeyCommand())\n\trootCmd.AddCommand(MavenBuildCommand())\n\trootCmd.AddCommand(MavenExecuteIntegrationCommand())\n\trootCmd.AddCommand(MavenExecuteStaticCodeChecksCommand())\n\trootCmd.AddCommand(NexusUploadCommand())\n\trootCmd.AddCommand(AbapEnvironmentPushATCSystemConfigCommand())\n\trootCmd.AddCommand(AbapEnvironmentRunATCCheckCommand())\n\trootCmd.AddCommand(NpmExecuteScriptsCommand())\n\trootCmd.AddCommand(NpmExecuteLintCommand())\n\trootCmd.AddCommand(GctsCreateRepositoryCommand())\n\trootCmd.AddCommand(GctsExecuteABAPQualityChecksCommand())\n\trootCmd.AddCommand(GctsExecuteABAPUnitTestsCommand())\n\trootCmd.AddCommand(GctsDeployCommand())\n\trootCmd.AddCommand(MalwareExecuteScanCommand())\n\trootCmd.AddCommand(CloudFoundryCreateServiceCommand())\n\trootCmd.AddCommand(CloudFoundryDeployCommand())\n\trootCmd.AddCommand(GctsRollbackCommand())\n\trootCmd.AddCommand(WhitesourceExecuteScanCommand())\n\trootCmd.AddCommand(GctsCloneRepositoryCommand())\n\trootCmd.AddCommand(JsonApplyPatchCommand())\n\trootCmd.AddCommand(KanikoExecuteCommand())\n\trootCmd.AddCommand(CnbBuildCommand())\n\trootCmd.AddCommand(AbapEnvironmentBuildCommand())\n\trootCmd.AddCommand(AbapEnvironmentAssemblePackagesCommand())\n\trootCmd.AddCommand(AbapAddonAssemblyKitCheckCVsCommand())\n\trootCmd.AddCommand(AbapAddonAssemblyKitCheckPVCommand())\n\trootCmd.AddCommand(AbapAddonAssemblyKitCreateTargetVectorCommand())\n\trootCmd.AddCommand(AbapAddonAssemblyKitPublishTargetVectorCommand())\n\trootCmd.AddCommand(AbapAddonAssemblyKitRegisterPackagesCommand())\n\trootCmd.AddCommand(AbapAddonAssemblyKitReleasePackagesCommand())\n\trootCmd.AddCommand(AbapAddonAssemblyKitReserveNextPackagesCommand())\n\trootCmd.AddCommand(CloudFoundryCreateSpaceCommand())\n\trootCmd.AddCommand(CloudFoundryDeleteSpaceCommand())\n\trootCmd.AddCommand(VaultRotateSecretIdCommand())\n\trootCmd.AddCommand(IsChangeInDevelopmentCommand())\n\trootCmd.AddCommand(TransportRequestUploadCTSCommand())\n\trootCmd.AddCommand(TransportRequestUploadRFCCommand())\n\trootCmd.AddCommand(NewmanExecuteCommand())\n\trootCmd.AddCommand(IntegrationArtifactDeployCommand())\n\trootCmd.AddCommand(TransportRequestUploadSOLMANCommand())\n\trootCmd.AddCommand(IntegrationArtifactUpdateConfigurationCommand())\n\trootCmd.AddCommand(IntegrationArtifactGetMplStatusCommand())\n\trootCmd.AddCommand(IntegrationArtifactGetServiceEndpointCommand())\n\trootCmd.AddCommand(IntegrationArtifactDownloadCommand())\n\trootCmd.AddCommand(AbapEnvironmentAssembleConfirmCommand())\n\trootCmd.AddCommand(IntegrationArtifactUploadCommand())\n\trootCmd.AddCommand(IntegrationArtifactTriggerIntegrationTestCommand())\n\trootCmd.AddCommand(IntegrationArtifactUnDeployCommand())\n\trootCmd.AddCommand(IntegrationArtifactResourceCommand())\n\trootCmd.AddCommand(TerraformExecuteCommand())\n\trootCmd.AddCommand(ContainerExecuteStructureTestsCommand())\n\trootCmd.AddCommand(GaugeExecuteTestsCommand())\n\trootCmd.AddCommand(BatsExecuteTestsCommand())\n\trootCmd.AddCommand(PipelineCreateScanSummaryCommand())\n\trootCmd.AddCommand(TransportRequestDocIDFromGitCommand())\n\trootCmd.AddCommand(TransportRequestReqIDFromGitCommand())\n\trootCmd.AddCommand(WritePipelineEnv())\n\trootCmd.AddCommand(ReadPipelineEnv())\n\trootCmd.AddCommand(InfluxWriteDataCommand())\n\trootCmd.AddCommand(AbapEnvironmentRunAUnitTestCommand())\n\trootCmd.AddCommand(CheckStepActiveCommand())\n\trootCmd.AddCommand(GolangBuildCommand())\n\trootCmd.AddCommand(ShellExecuteCommand())\n\trootCmd.AddCommand(ApiProxyDownloadCommand())\n\trootCmd.AddCommand(ApiKeyValueMapDownloadCommand())\n\trootCmd.AddCommand(ApiProviderDownloadCommand())\n\trootCmd.AddCommand(ApiProxyUploadCommand())\n\trootCmd.AddCommand(GradleExecuteBuildCommand())\n\trootCmd.AddCommand(ApiKeyValueMapUploadCommand())\n\trootCmd.AddCommand(PythonBuildCommand())\n\trootCmd.AddCommand(AzureBlobUploadCommand())\n\trootCmd.AddCommand(AwsS3UploadCommand())\n\trootCmd.AddCommand(ApiProxyListCommand())\n\trootCmd.AddCommand(AnsSendEventCommand())\n\trootCmd.AddCommand(ApiProviderListCommand())\n\trootCmd.AddCommand(TmsUploadCommand())\n\trootCmd.AddCommand(TmsExportCommand())\n\trootCmd.AddCommand(IntegrationArtifactTransportCommand())\n\trootCmd.AddCommand(AscAppUploadCommand())\n\n\taddRootFlags(rootCmd)\n\n\tif err := rootCmd.Execute(); err != nil {\n\t\tlog.SetErrorCategory(log.ErrorConfiguration)\n\t\tlog.Entry().WithError(err).Fatal(\"configuration error\")\n\t}\n}", "func Deploy(d *appsv1.Deployment, forceCreate bool, client *kubernetes.Clientset) error {\n\tif forceCreate {\n\t\tif err := create(d, client); err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tif err := update(d, client); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (c *applicationUsecaseImpl) Deploy(ctx context.Context, app *model.Application, req apisv1.ApplicationDeployRequest) (*apisv1.ApplicationDeployResponse, error) {\n\t// TODO: rollback to handle all the error case\n\t// step1: Render oam application\n\tversion := utils.GenerateVersion(\"\")\n\toamApp, err := c.renderOAMApplication(ctx, app, req.WorkflowName, version)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tconfigByte, _ := yaml.Marshal(oamApp)\n\n\tworkflow, err := c.workflowUsecase.GetWorkflow(ctx, app, oamApp.Annotations[oam.AnnotationWorkflowName])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// step2: check and create deploy event\n\tif !req.Force {\n\t\tvar lastVersion = model.ApplicationRevision{\n\t\t\tAppPrimaryKey: app.PrimaryKey(),\n\t\t\tEnvName: workflow.EnvName,\n\t\t}\n\t\tlist, err := c.ds.List(ctx, &lastVersion, &datastore.ListOptions{\n\t\t\tPageSize: 1, Page: 1, SortBy: []datastore.SortOption{{Key: \"createTime\", Order: datastore.SortOrderDescending}}})\n\t\tif err != nil && !errors.Is(err, datastore.ErrRecordNotExist) {\n\t\t\tlog.Logger.Errorf(\"query app latest revision failure %s\", err.Error())\n\t\t\treturn nil, bcode.ErrDeployConflict\n\t\t}\n\t\tif len(list) > 0 && list[0].(*model.ApplicationRevision).Status != model.RevisionStatusComplete {\n\t\t\tlog.Logger.Warnf(\"last app revision can not complete %s/%s\", list[0].(*model.ApplicationRevision).AppPrimaryKey, list[0].(*model.ApplicationRevision).Version)\n\t\t\treturn nil, bcode.ErrDeployConflict\n\t\t}\n\t}\n\n\tvar appRevision = &model.ApplicationRevision{\n\t\tAppPrimaryKey: app.PrimaryKey(),\n\t\tVersion: version,\n\t\tApplyAppConfig: string(configByte),\n\t\tStatus: model.RevisionStatusInit,\n\t\t// TODO: Get user information from ctx and assign a value.\n\t\tDeployUser: \"\",\n\t\tNote: req.Note,\n\t\tTriggerType: req.TriggerType,\n\t\tWorkflowName: oamApp.Annotations[oam.AnnotationWorkflowName],\n\t\tEnvName: workflow.EnvName,\n\t}\n\n\tif err := c.ds.Add(ctx, appRevision); err != nil {\n\t\treturn nil, err\n\t}\n\t// step3: check and create namespace\n\tvar namespace corev1.Namespace\n\tif err := c.kubeClient.Get(ctx, types.NamespacedName{Name: oamApp.Namespace}, &namespace); apierrors.IsNotFound(err) {\n\t\tnamespace.Name = oamApp.Namespace\n\t\tif err := c.kubeClient.Create(ctx, &namespace); err != nil {\n\t\t\tlog.Logger.Errorf(\"auto create namespace failure %s\", err.Error())\n\t\t\treturn nil, bcode.ErrCreateNamespace\n\t\t}\n\t}\n\t// step4: apply to controller cluster\n\terr = c.apply.Apply(ctx, oamApp)\n\tif err != nil {\n\t\tappRevision.Status = model.RevisionStatusFail\n\t\tappRevision.Reason = err.Error()\n\t\tif err := c.ds.Put(ctx, appRevision); err != nil {\n\t\t\tlog.Logger.Warnf(\"update deploy event failure %s\", err.Error())\n\t\t}\n\n\t\tlog.Logger.Errorf(\"deploy app %s failure %s\", app.PrimaryKey(), err.Error())\n\t\treturn nil, bcode.ErrDeployApplyFail\n\t}\n\n\t// step5: create workflow record\n\tif err := c.workflowUsecase.CreateWorkflowRecord(ctx, app, oamApp, workflow); err != nil {\n\t\tlog.Logger.Warnf(\"create workflow record failure %s\", err.Error())\n\t}\n\n\t// step6: update app revision status\n\tappRevision.Status = model.RevisionStatusRunning\n\tif err := c.ds.Put(ctx, appRevision); err != nil {\n\t\tlog.Logger.Warnf(\"update app revision failure %s\", err.Error())\n\t}\n\n\treturn &apisv1.ApplicationDeployResponse{\n\t\tApplicationRevisionBase: apisv1.ApplicationRevisionBase{\n\t\t\tVersion: appRevision.Version,\n\t\t\tStatus: appRevision.Status,\n\t\t\tReason: appRevision.Reason,\n\t\t\tDeployUser: appRevision.DeployUser,\n\t\t\tNote: appRevision.Note,\n\t\t\tTriggerType: appRevision.TriggerType,\n\t\t},\n\t}, nil\n}", "func (jj *Juju) Deploy(user, service string) (*simplejson.Json, error) {\n args := []string{\"deploy\", \"--show-log\"}\n id := jj.id(user, service)\n report := JSON(fmt.Sprintf(`{\"time\": \"%s\"}`, time.Now()))\n log.Infof(\"deploy juju service: %s\\n\", id)\n\n // Get charms location\n storePath, storePrefix, err := jj.Charmstore(service)\n if err != nil { return EmptyJSON(), err }\n if storePrefix == \"local\" {\n args = append(args, \"--repository\")\n args = append(args, storePath)\n }\n\n // Add final service syntax to deploy\n args = append(args, fmt.Sprintf(\"%s:%s/%s\", storePrefix, defaultSeries, service))\n args = append(args, id)\n\n // Read and dump user configuration\n confPath, err := jj.fetchConfig(user, service)\n if err != nil { return EmptyJSON(), err }\n if confPath != \"\" {\n args = append(args, \"--config\") \n args = append(args, confPath) \n }\n\n // Charm deployment\n log.Infof(\"enqueue process\")\n client, err := goresque.Dial(redisURL)\n if err != nil { return EmptyJSON(), err }\n client.Enqueue(workerClass, \"fork\", jj.Path, args)\n\n report.Set(\"deployed\", id)\n report.Set(\"provider\", \"juju\")\n report.Set(\"arguments\", args)\n report.Set(\"series\", defaultSeries)\n return report, nil\n}", "func main() {\n\tif err := cmd.Cmd.Execute(); err != nil {\n\t\tos.Exit(1)\n\t}\n}", "func Deploy(host, remotePath, localDir string) error {\n\tc, e := connect(host)\n\tif e != nil {\n\t\treturn e\n\t}\n\tdefer c.Close()\n\n\te = c.Call(\"Prism.Deploy\", &Program{remotePath, localDir}, nil)\n\tif e != nil {\n\t\treturn fmt.Errorf(\"Prism.Deploy failed: %v\", e)\n\t}\n\treturn nil\n}", "func (p *Publisher) Run() error {\n\tspecResponse, err := p.sdAPI.PostCommand(p.commandSpec)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Post failed: %v\", err)\n\t}\n\n\terr = p.tagCommand(specResponse)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Tag failed: %v\", err)\n\t}\n\n\t// Published successfully\n\t// Show version number of command published by sd-cmd\n\tfmt.Println(specResponse.Version)\n\n\treturn nil\n}", "func (config *ReleaseCommandConfig) Run() error {\n\n\tgit, err := gitpkg.GetGit()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = release(git)\n\n\treturn err\n}", "func (s *SailTrim) Deploy(ctx context.Context) error {\n\tsv, err := s.conf.loadService()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to load service config\")\n\t}\n\tif _, err = s.svc.GetContainerServicesWithContext(ctx, &lightsail.GetContainerServicesInput{\n\t\tServiceName: sv.ContainerServiceName,\n\t}); err != nil {\n\t\treturn s.create(ctx, *sv.ContainerServiceName)\n\t}\n\n\tdp, err := s.conf.loadDeployment()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to load deployment config\")\n\t}\n\tif out, err := s.svc.CreateContainerServiceDeploymentWithContext(ctx, &lightsail.CreateContainerServiceDeploymentInput{\n\t\tServiceName: sv.ContainerServiceName,\n\t\tContainers: dp.Containers,\n\t\tPublicEndpoint: &lightsail.EndpointRequest{\n\t\t\tContainerName: dp.PublicEndpoint.ContainerName,\n\t\t\tContainerPort: dp.PublicEndpoint.ContainerPort,\n\t\t\tHealthCheck: dp.PublicEndpoint.HealthCheck,\n\t\t},\n\t}); err != nil {\n\t\treturn errors.Wrap(err, \"failed to create deployment\")\n\t} else {\n\t\tlog.Printf(\"[info] new deployment is created\")\n\t\tlog.Printf(\"[debug] %s\", MarshalJSONString(out))\n\t}\n\treturn nil\n}", "func (cmd *PurgeCmd) Run(cobraCmd *cobra.Command, args []string) {\n\t// Set config root\n\tconfigExists, err := configutil.SetDevSpaceRoot()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tif !configExists {\n\t\tlog.Fatal(\"Couldn't find any devspace configuration. Please run `devspace init`\")\n\t}\n\n\tlog.StartFileLogging()\n\n\tkubectl, err := kubectl.NewClient()\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to create new kubectl client: %s\", err.Error())\n\t}\n\n\tdeployments := []string{}\n\tif cmd.Deployments != \"\" {\n\t\tdeployments = strings.Split(cmd.Deployments, \",\")\n\t\tfor index := range deployments {\n\t\t\tdeployments[index] = strings.TrimSpace(deployments[index])\n\t\t}\n\t}\n\n\tdeploy.PurgeDeployments(kubectl, deployments)\n}", "func (cmd *UpCmd) Run(cobraCmd *cobra.Command, args []string) {\n\tif configutil.ConfigPath != cmd.flags.config {\n\t\tconfigutil.ConfigPath = cmd.flags.config\n\n\t\t// Don't use overwrite config if we use a different config\n\t\tconfigutil.OverwriteConfigPath = \"\"\n\t}\n\n\tlog.StartFileLogging()\n\tvar err error\n\n\tconfigExists, _ := configutil.ConfigExists()\n\tif !configExists {\n\t\tinitCmd := &InitCmd{\n\t\t\tflags: InitCmdFlagsDefault,\n\t\t}\n\n\t\tinitCmd.Run(nil, []string{})\n\n\t\t// Ensure that config is initialized correctly\n\t\tconfigutil.SetDefaultsOnce()\n\t}\n\n\t// Create kubectl client\n\tcmd.kubectl, err = kubectl.NewClientWithContextSwitch(cmd.flags.switchContext)\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to create new kubectl client: %v\", err)\n\t}\n\n\t// Create namespace if necessary\n\terr = kubectl.EnsureDefaultNamespace(cmd.kubectl, log.GetInstance())\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to create namespace: %v\", err)\n\t}\n\n\t// Create cluster role binding if necessary\n\terr = kubectl.EnsureGoogleCloudClusterRoleBinding(cmd.kubectl, log.GetInstance())\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to create ClusterRoleBinding: %v\", err)\n\t}\n\n\t// Init image registries\n\tif cmd.flags.initRegistries {\n\t\terr = registry.InitRegistries(cmd.kubectl, log.GetInstance())\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t}\n\n\t// Build and deploy images\n\tcmd.buildAndDeploy()\n\n\tif cmd.flags.exitAfterDeploy == false {\n\t\t// Start services\n\t\tcmd.startServices(args)\n\t}\n}", "func (this *Deployment) deploy() error {\n\tif len(this.Application.Processes) == 0 {\n\t\treturn fmt.Errorf(\"No processes scaled up, adjust with `ps:scale procType=#` before deploying\")\n\t}\n\n\ttitleLogger := NewFormatter(this.Logger, GREEN)\n\tdimLogger := NewFormatter(this.Logger, DIM)\n\n\te := Executor{dimLogger}\n\n\tthis.autoDetectRevision()\n\n\terr := writeDeployScripts()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tremoveDynos, allocatingNewDynos, err := this.calculateDynosToDestroy()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif allocatingNewDynos {\n\t\tavailableNodes, err := this.syncNodes()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Now we've successfully sync'd and we have a list of nodes available to deploy to.\n\t\taddDynos, err := this.startDynos(availableNodes, titleLogger)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfmt.Fprintf(titleLogger, \"Arbitrary sleeping for 30s to allow dynos to warm up before syncing load balancers\\n\")\n\t\ttime.Sleep(30 * time.Second)\n\n\t\terr = this.Server.SyncLoadBalancers(&e, addDynos, removeDynos)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif !this.ScalingOnly {\n\t\t// Update releases.\n\t\treleases, err := getReleases(this.Application.Name)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// Prepend the release (releases are in descending order)\n\t\treleases = append([]Release{{\n\t\t\tVersion: this.Version,\n\t\t\tRevision: this.Revision,\n\t\t\tDate: time.Now(),\n\t\t\tConfig: this.Application.Environment,\n\t\t}}, releases...)\n\t\t// Only keep around the latest 15 (older ones are still in S3)\n\t\tif len(releases) > 15 {\n\t\t\treleases = releases[:15]\n\t\t}\n\t\terr = setReleases(this.Application.Name, releases)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\t// Trigger old dynos to shutdown.\n\t\tfor _, removeDyno := range removeDynos {\n\t\t\tfmt.Fprintf(titleLogger, \"Shutting down dyno: %v\\n\", removeDyno.Container)\n\t\t\tgo func(rd Dyno) {\n\t\t\t\trd.Shutdown(&Executor{os.Stdout})\n\t\t\t}(removeDyno)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (d *Deployment) PostDeploy(version string) (string, error) {\n\tif os.Geteuid() == 0 && d.cfg.Insecure {\n\t\treturn \"\", fmt.Errorf(\n\t\t\t\"Refusing to execute post-deploy command from insecure %q configuration as root\",\n\t\t\td.appName)\n\t}\n\tif d.cfg.Scripts[\"postdeploy\"].Cmd != \"\" {\n\t\tartifactPath, _ := makeArtifactPath(d.artifactDir, d.appName, version, d.acfg.Extension)\n\t\tversionDir, _ := makeReleasePath(d.releaseDir, version)\n\t\tcmdlineArgs := substituteVars(d.cfg.Scripts[\"postdeploy\"].Args,\n\t\t\tvarValues{artifactPath: artifactPath, versionDir: versionDir})\n\t\treturn sysCommand(versionDir, d.cfg.Scripts[\"postdeploy\"].Cmd, cmdlineArgs)\n\t}\n\treturn \"\", nil\n}", "func (r *Runner) Deploy(\n\tctx context.Context,\n\tuserName string,\n\tstacks []string,\n) error {\n\tif has, _ := r.hasOutdatedDiffLabel(ctx); has {\n\t\tif err := r.platform.CreateComment(ctx, \"Differences are outdated. Run /diff instead.\"); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn r.Diff(ctx)\n\t}\n\treturn r.updateStatus(ctx, func() (*resultState, error) {\n\t\tcdkPath, cfg, target, pr, err := r.setup(ctx, true)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif target == nil {\n\t\t\treturn newResultState(constant.StateMergeReady, \"No targets are matched\"), nil\n\t\t}\n\t\tif !cfg.IsUserAllowedDeploy(userName) {\n\t\t\treturn newResultState(constant.StateNotMergeReady, fmt.Sprintf(\"user %s is not allowed to deploy\", userName)), nil\n\t\t}\n\t\topenPRs, err := r.platform.GetOpenPullRequests(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif number, exists := existsOtherDeployedSameBasePRs(openPRs, pr); exists {\n\t\t\treturn newResultState(\n\t\t\t\tconstant.StateNotMergeReady,\n\t\t\t\tfmt.Sprintf(\"deployed PR #%d is still opened. First /deploy and merge it, or /rollback.\", number),\n\t\t\t), nil\n\t\t}\n\t\tif len(stacks) == 0 {\n\t\t\tstacks, err = r.cdk.List(cdkPath, target.Contexts)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\tvar (\n\t\t\terrMessage string\n\t\t\thasDiff bool\n\t\t)\n\t\tresult, deployErr := r.cdk.Deploy(cdkPath, stacks, target.Contexts)\n\t\tif deployErr != nil {\n\t\t\terrMessage = deployErr.Error()\n\t\t} else {\n\t\t\t_, hasDiff, err = r.cdk.Diff(cdkPath, nil, target.Contexts)\n\t\t\tif err != nil {\n\t\t\t\terrMessage = err.Error()\n\t\t\t}\n\t\t}\n\t\tif err := r.platform.AddLabel(ctx, constant.LabelDeployed); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif err := r.platform.CreateComment(\n\t\t\tctx,\n\t\t\tfmt.Sprintf(\"### cdk deploy\\n```\\n%s\\n%s\\n```\", result, errMessage),\n\t\t); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif errMessage != \"\" {\n\t\t\treturn newResultState(constant.StateNotMergeReady, \"Fix codes\"), nil\n\t\t}\n\t\tif !hasDiff {\n\t\t\tif err := r.platform.MergePullRequest(ctx, \"automatically merged by cdkbot\"); err != nil {\n\t\t\t\tif err := r.platform.CreateComment(\n\t\t\t\t\tctx,\n\t\t\t\t\tfmt.Sprintf(\"cdkbot tried to merge but failed: %s\", err.Error()),\n\t\t\t\t); err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor _, openPR := range openPRs {\n\t\t\t\t\tif openPR.Number == pr.Number || openPR.BaseBranch != pr.BaseBranch {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tif err := r.platform.AddLabelToOtherPR(ctx, constant.LabelOutdatedDiff, openPR.Number); err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn newResultState(constant.StateMergeReady, \"No diffs. Let's merge!\"), nil\n\t\t}\n\t\treturn newResultState(constant.StateNotMergeReady, \"Go ahead with deploy.\"), nil\n\t})\n}", "func Execute(name string, args []string) {\n\topttar := false\n\topttgz := false\n\toptvhdx := false\n\toptvhdxgz := false\n\toptreg := false\n\tswitch len(args) {\n\tcase 0:\n\t\t_, _, flags, _ := wsllib.WslGetDistributionConfiguration(name)\n\t\tif flags&wsllib.FlagEnableWsl2 == wsllib.FlagEnableWsl2 {\n\t\t\toptvhdxgz = true\n\t\t\toptreg = true\n\t\t} else {\n\t\t\topttgz = true\n\t\t\toptreg = true\n\t\t}\n\n\tcase 1:\n\t\tswitch args[0] {\n\t\tcase \"--tar\":\n\t\t\topttar = true\n\t\tcase \"--tgz\":\n\t\t\topttgz = true\n\t\tcase \"--vhdx\":\n\t\t\toptvhdx = true\n\t\tcase \"--vhdxgz\":\n\t\t\toptvhdxgz = true\n\t\tcase \"--reg\":\n\t\t\toptreg = true\n\t\t}\n\n\tdefault:\n\t\tutils.ErrorExit(os.ErrInvalid, true, true, false)\n\t}\n\n\tif optreg {\n\t\terr := backupReg(name, \"backup.reg\")\n\t\tif err != nil {\n\t\t\tutils.ErrorExit(err, true, true, false)\n\t\t}\n\t}\n\tif opttar {\n\t\terr := backupTar(name, \"backup.tar\")\n\t\tif err != nil {\n\t\t\tutils.ErrorExit(err, true, true, false)\n\t\t}\n\n\t}\n\tif opttgz {\n\t\terr := backupTar(name, \"backup.tar.gz\")\n\t\tif err != nil {\n\t\t\tutils.ErrorExit(err, true, true, false)\n\t\t}\n\t}\n\tif optvhdx {\n\t\terr := backupExt4Vhdx(name, \"backup.ext4.vhdx\")\n\t\tif err != nil {\n\t\t\tutils.ErrorExit(err, true, true, false)\n\t\t}\n\t}\n\tif optvhdxgz {\n\t\terr := backupExt4Vhdx(name, \"backup.ext4.vhdx.gz\")\n\t\tif err != nil {\n\t\t\tutils.ErrorExit(err, true, true, false)\n\t\t}\n\t}\n}", "func (d Driver) Run(name, confTarget, hostVolume string, args []string) error {\n\td.containerID = fmt.Sprintf(\"maestro-%s\", name)\n\td.confTarget = confTarget\n\td.hostVolume = hostVolume\n\td.cmd = args\n\tneedToPull, checkErr := d.needToPull(context.Background())\n\tif checkErr != nil {\n\t\treturn checkErr\n\t}\n\tif needToPull {\n\t\tpullErr := d.pull(context.Background())\n\t\tif pullErr != nil {\n\t\t\treturn pullErr\n\t\t}\n\t}\n\tneedToRemoveOld, removalID, checkRemoveErr := d.needToRemove(context.Background())\n\tif checkRemoveErr != nil {\n\t\treturn checkRemoveErr\n\t}\n\tif needToRemoveOld {\n\t\tremoveErr := d.remove(context.Background(), removalID)\n\t\tif removeErr != nil {\n\t\t\treturn removeErr\n\t\t}\n\t}\n\tcreateErr := d.create(context.Background())\n\tif createErr != nil {\n\t\treturn createErr\n\t}\n\treturn d.start(context.Background())\n}", "func Cmd(logger *zap.Logger, config *lib.Config, args []string) error {\n\treturn nil\n}", "func (c *Command) Run(args []string) {\n\tservice := servd.New()\n\tc.loadAndValidateConfig()\n\n\tswitch args[0] {\n\tcase inquiry:\n\t\tservice.Inquiry()\n\tcase payment:\n\t\tservice.Payment()\n\tcase checkStatus:\n\t\tservice.CheckStatus()\n\tdefault:\n\t\tlog.Println(\"please specify the available command (inquiry, payment, checkstatus)\")\n\t}\n}", "func main() {\n\tcmd.Execute(version, gitCommit, buildDate)\n}", "func (p *provider) deploy(req handlers.ResourceDeployRequest) (*handlers.ResourceDeployResult, error) {\n\tvar result handlers.ResourceDeployResult\n\n\t// get resource info : tmc + extension info\n\tresourceInfo, err := p.defaultHandler.GetResourceInfo(&req)\n\tdefer func() {\n\t\t// callback to orchestrator\n\t\tif len(req.Callback) == 0 {\n\t\t\treturn\n\t\t}\n\t\tif err != nil {\n\t\t\tp.defaultHandler.Callback(req.Callback, req.Uuid, false, nil, req.Options, err.Error())\n\t\t} else {\n\t\t\tp.defaultHandler.Callback(req.Callback, result.ID, true, result.Config, result.Options, \"\")\n\t\t}\n\t}()\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to defaultHandler.GetResourceInfo for %s:%s/%s\", req.Engine, req.Options[\"version\"], req.Az)\n\t}\n\n\thandler := p.findHandler(resourceInfo.Tmc)\n\tif handler == nil {\n\t\treturn nil, fmt.Errorf(\"could not find deploy handler for %s\", req.Engine)\n\t}\n\n\t// pre-check if it needs to further deploy\n\ttmcInstance, needDeployInstance, err := handler.CheckIfNeedTmcInstance(&req, resourceInfo)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to CheckIfNeedTmcInstance for %s/%s\", req.Engine, req.Az)\n\t}\n\ttenant, needApplyTenant, err := handler.CheckIfNeedTmcInstanceTenant(&req, resourceInfo)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to CheckIfNeedTmcInstanceTenant for %s/%s\", req.Engine, req.Az)\n\t}\n\tp.Log.Infof(\"[%s/%s] check if it needs to deploy tmc instance: %v, needs to apply tenant: %v\\n\",\n\t\treq.Engine, req.Az, needDeployInstance, needApplyTenant)\n\n\tvar subResults []*handlers.ResourceDeployResult\n\t// resolve dependency resources\n\tif needApplyTenant || needDeployInstance {\n\t\t// for some resource like monitor, do not has dice.yml definition\n\t\tif resourceInfo.Dice != nil && resourceInfo.Dice.AddOns != nil {\n\t\t\tdefer func() {\n\t\t\t\t// delete related sub resources if error occur\n\t\t\t\tif err == nil {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tfor _, subResult := range subResults {\n\t\t\t\t\tp.UnDeploy(subResult.ID)\n\t\t\t\t\thandler.DeleteRequestRelation(req.Uuid, subResult.ID)\n\t\t\t\t}\n\t\t\t}()\n\n\t\t\tfor name, addon := range resourceInfo.Dice.AddOns {\n\t\t\t\t// deploy dependency resource recursive\n\t\t\t\tsubReq := handler.BuildSubResourceDeployRequest(name, addon, &req)\n\t\t\t\tif subReq == nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tvar subResult *handlers.ResourceDeployResult\n\t\t\t\tsubResult, err = p.Deploy(*subReq)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, errors.Wrapf(err, \"failed to Deploy sub addon %s:%s/%s\", subReq.Engine, subReq.Options[\"version\"], subReq.Az)\n\t\t\t\t}\n\t\t\t\tsubResults = append(subResults, subResult)\n\t\t\t\thandler.BuildRequestRelation(req.Uuid, subResult.ID)\n\t\t\t}\n\t\t}\n\t}\n\n\t// create tmc_instance record if necessary\n\tvar clusterConfig map[string]string\n\tclusterConfig, err = handler.GetClusterConfig(req.Az)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to GetClusterConfig(%s)\", req.Az)\n\t}\n\tif needDeployInstance {\n\t\t// initialize tmc_instance\n\t\ttmcInstance, err = handler.InitializeTmcInstance(&req, resourceInfo, subResults)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to InitializeTmcInstance\")\n\t\t}\n\t\tdefer func() {\n\t\t\t// delete instance if error occur,\n\t\t\t// if tmcInstance status is RUNNING skip delete even if error\n\t\t\tif err == nil || tmcInstance.Status == handlers.TmcInstanceStatusRunning {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\thandler.DeleteTmcInstance(tmcInstance, handlers.TmcInstanceStatusError)\n\t\t}()\n\n\t\t// if is custom resource, do not real deploy, just update config and simply mark status as RUNNING\n\t\tcustomConfig, hasCustom := handler.CheckIfHasCustomConfig(clusterConfig)\n\t\tif hasCustom {\n\t\t\thandler.UpdateTmcInstanceOnCustom(tmcInstance, customConfig)\n\t\t} else {\n\t\t\t// do pre-deploy job if any\n\t\t\tif err = handler.DoPreDeployJob(resourceInfo, tmcInstance); err != nil {\n\t\t\t\treturn nil, errors.Wrap(err, \"failed to DoPreDeployJob\")\n\t\t\t}\n\n\t\t\t// do deploy and wait for ready\n\t\t\tvar sgDeployResult interface{}\n\t\t\tif resourceInfo.Dice == nil || resourceInfo.Dice.Services == nil || len(resourceInfo.Dice.Services) == 0 {\n\t\t\t\t// some resource do not need real deploy, e.g. configcenter.\n\t\t\t\t// this kind of resource do not have services section defined in dice.yml\n\t\t\t\t// just mock a success response\n\t\t\t\tsgDeployResult = &apistructs.ServiceGroup{\n\t\t\t\t\tStatusDesc: apistructs.StatusDesc{Status: apistructs.StatusReady},\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsgReq := handler.BuildServiceGroupRequest(resourceInfo, tmcInstance, clusterConfig)\n\t\t\t\tsgDeployResult, err = handler.DoDeploy(sgReq, resourceInfo, tmcInstance, clusterConfig)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, errors.Wrap(err, \"failed to DoDeploy\")\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// do post-deploy job if any\n\t\t\tadditionalConfig := map[string]string{}\n\t\t\tadditionalConfig, err = handler.DoPostDeployJob(tmcInstance, sgDeployResult, clusterConfig)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Wrapf(err, \"failed to DoPostDeployJob for tmc_instance %+v\", tmcInstance)\n\t\t\t}\n\n\t\t\t// update tmc_instance config and status\n\t\t\tconfig := handler.BuildTmcInstanceConfig(tmcInstance, sgDeployResult, clusterConfig, additionalConfig)\n\t\t\thandler.UpdateTmcInstanceOnFinish(tmcInstance, config, handlers.TmcInstanceStatusRunning)\n\t\t}\n\t}\n\n\tif needApplyTenant {\n\t\t// create tmc_instance_tenant record\n\t\ttenant, err = handler.InitializeTmcInstanceTenant(&req, tmcInstance, subResults)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to InitializeTmcInstanceTenant\")\n\t\t}\n\t\tdefer func() {\n\t\t\t// delete tenant if error occur\n\t\t\tif err == nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\thandler.DeleteTenant(tenant, tmcInstance, clusterConfig)\n\t\t}()\n\n\t\t// deploy tmc_instance_tenant\n\t\tvar config map[string]string\n\t\tconfig, err = handler.DoApplyTmcInstanceTenant(&req, resourceInfo, tmcInstance, tenant, clusterConfig)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to DoApplyTmcInstanceTenant for %+v\", tmcInstance)\n\t\t}\n\n\t\t// update and persistent applied config\n\t\ttenant, err = handler.UpdateTmcInstanceTenantOnFinish(tenant, config)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to UpdateTmcInstanceTenantOnFinish\")\n\t\t}\n\t}\n\n\tresult = handler.BuildDeployResult(tmcInstance, tenant)\n\n\treturn &result, nil\n}", "func (sd *SousNewDeploy) Execute(args []string) cmdr.Result {\n\treturn cmdr.UsageErrorf(\"sous newdeploy has been deprecated, please use `sous deploy` instead.\")\n}", "func publishCmd() *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: \"publish\",\n\t\tAliases: []string{\"pb\"},\n\t\tShort: \"Publish release\",\n\t\tLong: \"Publish release to make the configuration effective\",\n\t\tExample: `\n\tbk-bscp-client publish --id <releaseid>\n\t\t`,\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\toperator := service.NewOperator(option.GlobalOptions)\n\t\t\tif err := operator.Init(option.GlobalOptions.ConfigFile); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tID, _ := cmd.Flags().GetString(\"id\")\n\t\t\terr := operator.ConfirmMultiRelease(context.TODO(), ID)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tcmd.Printf(\"Publish successfully: %s\\n\", ID)\n\t\t\tcmd.Println()\n\t\t\tcmd.Printf(\"\\tuse \\\"bk-bscp-client get release --id <releaseid>\\\" to get release detail\\n\\n\")\n\t\t\treturn nil\n\t\t},\n\t}\n\t// --Id is required\n\tcmd.Flags().StringP(\"id\", \"i\", \"\", \"the id of release\")\n\tcmd.MarkFlagRequired(\"id\")\n\treturn cmd\n}", "func Cmd(logger *zap.Logger, config *lib.Config, args []string) error {\n\n\treturn nil\n\t// var e error\n\n\t// if _, e = os.Stat(\"./dvc.toml\"); os.IsNotExist(e) {\n\n\t// \treader := bufio.NewReader(os.Stdin)\n\n\t// \t// https://tutorialedge.net/golang/reading-console-input-golang/\n\t// \t// BasePackage\n\t// \tfmt.Print(\"> Base Package:\")\n\t// \tbasePackage, _ := reader.ReadString('\\n')\n\t// \tbasePackage = strings.Replace(basePackage, \"\\n\", \"\", -1)\n\n\t// \tfmt.Print(\"> Base directory (leave blank for current):\")\n\t// \tbaseDir, _ := reader.ReadString('\\n')\n\t// \tbaseDir = strings.Replace(baseDir, \"\\n\", \"\", -1)\n\n\t// \t// Host\n\t// \tfmt.Print(\"> Database Host:\")\n\t// \thost, _ := reader.ReadString('\\n')\n\t// \thost = strings.Replace(host, \"\\n\", \"\", -1)\n\n\t// \t// databaseName\n\t// \tfmt.Print(\"> Database Name:\")\n\t// \tdatabaseName, _ := reader.ReadString('\\n')\n\t// \tdatabaseName = strings.Replace(databaseName, \"\\n\", \"\", -1)\n\n\t// \t// databaseUser\n\t// \tfmt.Print(\"> Database User:\")\n\t// \tdatabaseUser, _ := reader.ReadString('\\n')\n\t// \tdatabaseUser = strings.Replace(databaseUser, \"\\n\", \"\", -1)\n\n\t// \t// databasePass\n\t// \tfmt.Print(\"> Database Password:\")\n\t// \tdatabasePass, _ := reader.ReadString('\\n')\n\t// \tdatabasePass = strings.Replace(databasePass, \"\\n\", \"\", -1)\n\n\t// \tcontent := \"databaseType = \\\"mysql\\\"\\nbasePackage = \\\"\" + basePackage + \"\\\"\\n\\nenums = []\\n\\n\"\n\t// \tcontent += \"[connection]\\nhost = \\\"\" + host + \"\\\"\\ndatabaseName = \\\"\" + databaseName + \"\\\"\\nusername = \\\"\" + databaseUser + \"\\\"\\npassword = \\\"\" + databasePass + \"\\\"\\n\\n\"\n\n\t// \tpackages := []string{\n\t// \t\t\"repos\",\n\t// \t\t\"models\",\n\t// \t\t\"typescript\",\n\t// \t\t\"services\",\n\t// \t\t\"dal\",\n\t// \t\t\"definitions\",\n\t// \t}\n\n\t// \tcontent += \"[packages]\\n\"\n\t// \tfor _, p := range packages {\n\t// \t\tif p == \"typescript\" {\n\t// \t\t\tcontinue\n\t// \t\t}\n\n\t// \t\tcontent += fmt.Sprintf(\"%s = \\\"%s\\\"\\n\", p, path.Join(basePackage, p))\n\t// \t}\n\n\t// \t// content += \"[packages]\\ncache = \\\"myPackage/cache\\\"\\nmodels = \\\"myPackage/models\\\"\\nschema = \\\"myPackage/schema\\\"\\nrepos = \\\"myPackage/repos\\\"\\n\\n\"\n\n\t// \tcontent += \"[dirs]\\n\"\n\n\t// \tfor _, p := range packages {\n\n\t// \t\tif baseDir != \"\" {\n\t// \t\t\tcontent += fmt.Sprintf(\"%s = \\\"%s\\\"\\n\", p, path.Join(baseDir, p))\n\t// \t\t} else {\n\t// \t\t\tcontent += fmt.Sprintf(\"%s = \\\"%s\\\"\\n\", p, p)\n\t// \t\t}\n\t// \t}\n\n\t// \t// content += \"[dirs]\\nrepos = \\\"repos\\\"\\ncache = \\\"cache\\\"\\nmodels = \\\"models\\\"\\nschema = \\\"schema\\\"\\ntypescript = \\\"ts\\\"\"\n\n\t// \tioutil.WriteFile(\"./dvc.toml\", []byte(content), 0644)\n\n\t// } else {\n\t// \tfmt.Println(\"dvc.toml already exists in this directory\")\n\t// }\n}", "func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *models.Deploy) (*models.Deploy, error) {\n\tf, err := os.Stat(options.Dir)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !f.IsDir() {\n\t\treturn nil, fmt.Errorf(\"%s is not a directory\", options.Dir)\n\t}\n\n\tif options.Observer != nil {\n\t\tif err := options.Observer.OnSetupWalk(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tlargeMediaEnabled := options.LargeMediaEnabled\n\tif !largeMediaEnabled && deploy != nil {\n\t\tlargeMediaEnabled = deploy.SiteCapabilities.LargeMediaEnabled\n\t}\n\n\tignoreInstallDirs := options.Dir == options.BuildDir\n\n\tcontext.GetLogger(ctx).Infof(\"Getting files info with large media flag: %v\", largeMediaEnabled)\n\tfiles, err := walk(options.Dir, options.Observer, largeMediaEnabled, ignoreInstallDirs)\n\tif err != nil {\n\t\tif options.Observer != nil {\n\t\t\toptions.Observer.OnFailedWalk()\n\t\t}\n\t\treturn nil, err\n\t}\n\tfor name := range files.Files {\n\t\tif strings.ContainsAny(name, \"#?\") {\n\t\t\treturn nil, fmt.Errorf(\"Invalid filename '%s'. Deployed filenames cannot contain # or ? characters\", name)\n\t\t}\n\t}\n\n\tif options.EdgeFunctionsDir != \"\" {\n\t\terr = addInternalFilesToDeploy(options.EdgeFunctionsDir, edgeFunctionsInternalPath, files, options.Observer)\n\t\tif err != nil {\n\t\t\tif options.Observer != nil {\n\t\t\t\toptions.Observer.OnFailedWalk()\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif options.EdgeRedirectsDir != \"\" {\n\t\terr = addInternalFilesToDeploy(options.EdgeRedirectsDir, edgeRedirectsInternalPath, files, options.Observer)\n\t\tif err != nil {\n\t\t\tif options.Observer != nil {\n\t\t\t\toptions.Observer.OnFailedWalk()\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\toptions.files = files\n\n\tfunctions, schedules, functionsConfig, err := bundle(ctx, options.FunctionsDir, options.Observer)\n\tif err != nil {\n\t\tif options.Observer != nil {\n\t\t\toptions.Observer.OnFailedWalk()\n\t\t}\n\t\treturn nil, err\n\t}\n\toptions.functions = functions\n\toptions.functionSchedules = schedules\n\toptions.functionsConfig = functionsConfig\n\n\tdeployFiles := &models.DeployFiles{\n\t\tFiles: options.files.Sums,\n\t\tDraft: options.IsDraft,\n\t\tAsync: n.overCommitted(options.files),\n\t\tFramework: options.Framework,\n\t}\n\tif options.functions != nil {\n\t\tdeployFiles.Functions = options.functions.Sums\n\t}\n\n\tif options.Observer != nil {\n\t\tif err := options.Observer.OnSuccessfulWalk(deployFiles); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif len(schedules) > 0 {\n\t\tdeployFiles.FunctionSchedules = schedules\n\t}\n\n\tif options.functionsConfig != nil {\n\t\tdeployFiles.FunctionsConfig = options.functionsConfig\n\t}\n\n\tl := context.GetLogger(ctx)\n\tl.WithFields(logrus.Fields{\n\t\t\"site_id\": options.SiteID,\n\t\t\"deploy_files\": len(options.files.Sums),\n\t\t\"scheduled_functions\": len(schedules),\n\t}).Debug(\"Starting to deploy files\")\n\tauthInfo := context.GetAuthInfo(ctx)\n\n\tif options.Observer != nil {\n\t\tif err := options.Observer.OnSetupDelta(deployFiles); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif deploy == nil {\n\t\tparams := operations.NewCreateSiteDeployParams().WithSiteID(options.SiteID).WithDeploy(deployFiles)\n\t\tif options.Title != \"\" {\n\t\t\tparams = params.WithTitle(&options.Title)\n\t\t}\n\t\tresp, err := n.Operations.CreateSiteDeploy(params, authInfo)\n\t\tif err != nil {\n\t\t\tif options.Observer != nil {\n\t\t\t\toptions.Observer.OnFailedDelta(deployFiles)\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t\tdeploy = resp.Payload\n\t} else {\n\t\tparams := operations.NewUpdateSiteDeployParams().WithSiteID(options.SiteID).WithDeployID(deploy.ID).WithDeploy(deployFiles)\n\t\tresp, err := n.Operations.UpdateSiteDeploy(params, authInfo)\n\t\tif err != nil {\n\t\t\tif options.Observer != nil {\n\t\t\t\toptions.Observer.OnFailedDelta(deployFiles)\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t\tdeploy = resp.Payload\n\t}\n\n\tif n.overCommitted(options.files) {\n\t\tvar err error\n\n\t\ttimeout := options.PreProcessTimeout\n\t\tif timeout <= 0 {\n\t\t\ttimeout = preProcessingTimeout\n\t\t}\n\t\tdeployReadyCtx, _ := gocontext.WithTimeout(ctx, timeout)\n\t\tdeploy, err = n.WaitUntilDeployReady(deployReadyCtx, deploy)\n\t\tif err != nil {\n\t\t\tif options.Observer != nil {\n\t\t\t\toptions.Observer.OnFailedDelta(deployFiles)\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif options.Observer != nil {\n\t\tif err := options.Observer.OnSuccessfulDelta(deployFiles, deploy); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif len(deploy.Required) == 0 && len(deploy.RequiredFunctions) == 0 {\n\t\treturn deploy, nil\n\t}\n\n\tif err := n.uploadFiles(ctx, deploy, options.files, options.Observer, fileUpload, options.UploadTimeout); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif options.functions != nil {\n\t\tif err := n.uploadFiles(ctx, deploy, options.functions, options.Observer, functionUpload, options.UploadTimeout); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn deploy, nil\n}", "func (cmd *CreateCompanyBranchHyCompanybranchCommand) Run(c *client.Client, args []string) error {\n\tvar path string\n\tif len(args) > 0 {\n\t\tpath = args[0]\n\t} else {\n\t\tpath = fmt.Sprintf(\"/api/company/branch/%v\", cmd.ID)\n\t}\n\tvar payload client.CreateCompanyBranchHyCompanybranchPayload\n\tif cmd.Payload != \"\" {\n\t\terr := json.Unmarshal([]byte(cmd.Payload), &payload)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to deserialize payload: %s\", err)\n\t\t}\n\t}\n\tlogger := goa.NewLogger(log.New(os.Stderr, \"\", log.LstdFlags))\n\tctx := goa.WithLogger(context.Background(), logger)\n\tresp, err := c.CreateCompanyBranchHyCompanybranch(ctx, path, &payload, cmd.ContentType)\n\tif err != nil {\n\t\tgoa.LogError(ctx, \"failed\", \"err\", err)\n\t\treturn err\n\t}\n\n\tgoaclient.HandleResponse(c.Client, resp, cmd.PrettyPrint)\n\treturn nil\n}", "func (d *Deployer) Deploy(ctx context.Context) error {\n\tif d.logger == nil {\n\t\td.logger = loggers.NewDefault()\n\t}\n\n\tbucket, err := d.openBucket(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif d.cfg.Workers <= 0 {\n\t\td.cfg.Workers = 10\n\t}\n\n\t// Load local files from the source directory.\n\tvar include, exclude glob.Glob\n\tif d.target != nil {\n\t\tinclude, exclude = d.target.includeGlob, d.target.excludeGlob\n\t}\n\tlocal, err := d.walkLocal(d.localFs, d.cfg.Matchers, include, exclude, d.mediaTypes)\n\tif err != nil {\n\t\treturn err\n\t}\n\td.logger.Infof(\"Found %d local files.\\n\", len(local))\n\td.summary.NumLocal = len(local)\n\n\t// Load remote files from the target.\n\tremote, err := d.walkRemote(ctx, bucket, include, exclude)\n\tif err != nil {\n\t\treturn err\n\t}\n\td.logger.Infof(\"Found %d remote files.\\n\", len(remote))\n\td.summary.NumRemote = len(remote)\n\n\t// Diff local vs remote to see what changes need to be applied.\n\tuploads, deletes := d.findDiffs(local, remote, d.cfg.Force)\n\td.summary.NumUploads = len(uploads)\n\td.summary.NumDeletes = len(deletes)\n\tif len(uploads)+len(deletes) == 0 {\n\t\tif !d.quiet {\n\t\t\td.logger.Println(\"No changes required.\")\n\t\t}\n\t\treturn nil\n\t}\n\tif !d.quiet {\n\t\td.logger.Println(summarizeChanges(uploads, deletes))\n\t}\n\n\t// Ask for confirmation before proceeding.\n\tif d.cfg.Confirm && !d.cfg.DryRun {\n\t\tfmt.Printf(\"Continue? (Y/n) \")\n\t\tvar confirm string\n\t\tif _, err := fmt.Scanln(&confirm); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif confirm != \"\" && confirm[0] != 'y' && confirm[0] != 'Y' {\n\t\t\treturn errors.New(\"aborted\")\n\t\t}\n\t}\n\n\t// Order the uploads. They are organized in groups; all uploads in a group\n\t// must be complete before moving on to the next group.\n\tuploadGroups := applyOrdering(d.cfg.ordering, uploads)\n\n\tnParallel := d.cfg.Workers\n\tvar errs []error\n\tvar errMu sync.Mutex // protects errs\n\n\tfor _, uploads := range uploadGroups {\n\t\t// Short-circuit for an empty group.\n\t\tif len(uploads) == 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Within the group, apply uploads in parallel.\n\t\tsem := make(chan struct{}, nParallel)\n\t\tfor _, upload := range uploads {\n\t\t\tif d.cfg.DryRun {\n\t\t\t\tif !d.quiet {\n\t\t\t\t\td.logger.Printf(\"[DRY RUN] Would upload: %v\\n\", upload)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tsem <- struct{}{}\n\t\t\tgo func(upload *fileToUpload) {\n\t\t\t\tif err := d.doSingleUpload(ctx, bucket, upload); err != nil {\n\t\t\t\t\terrMu.Lock()\n\t\t\t\t\tdefer errMu.Unlock()\n\t\t\t\t\terrs = append(errs, err)\n\t\t\t\t}\n\t\t\t\t<-sem\n\t\t\t}(upload)\n\t\t}\n\t\t// Wait for all uploads in the group to finish.\n\t\tfor n := nParallel; n > 0; n-- {\n\t\t\tsem <- struct{}{}\n\t\t}\n\t}\n\n\tif d.cfg.MaxDeletes != -1 && len(deletes) > d.cfg.MaxDeletes {\n\t\td.logger.Warnf(\"Skipping %d deletes because it is more than --maxDeletes (%d). If this is expected, set --maxDeletes to a larger number, or -1 to disable this check.\\n\", len(deletes), d.cfg.MaxDeletes)\n\t\td.summary.NumDeletes = 0\n\t} else {\n\t\t// Apply deletes in parallel.\n\t\tsort.Slice(deletes, func(i, j int) bool { return deletes[i] < deletes[j] })\n\t\tsem := make(chan struct{}, nParallel)\n\t\tfor _, del := range deletes {\n\t\t\tif d.cfg.DryRun {\n\t\t\t\tif !d.quiet {\n\t\t\t\t\td.logger.Printf(\"[DRY RUN] Would delete %s\\n\", del)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tsem <- struct{}{}\n\t\t\tgo func(del string) {\n\t\t\t\td.logger.Infof(\"Deleting %s...\\n\", del)\n\t\t\t\tif err := bucket.Delete(ctx, del); err != nil {\n\t\t\t\t\tif gcerrors.Code(err) == gcerrors.NotFound {\n\t\t\t\t\t\td.logger.Warnf(\"Failed to delete %q because it wasn't found: %v\", del, err)\n\t\t\t\t\t} else {\n\t\t\t\t\t\terrMu.Lock()\n\t\t\t\t\t\tdefer errMu.Unlock()\n\t\t\t\t\t\terrs = append(errs, err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t<-sem\n\t\t\t}(del)\n\t\t}\n\t\t// Wait for all deletes to finish.\n\t\tfor n := nParallel; n > 0; n-- {\n\t\t\tsem <- struct{}{}\n\t\t}\n\t}\n\n\tif len(errs) > 0 {\n\t\tif !d.quiet {\n\t\t\td.logger.Printf(\"Encountered %d errors.\\n\", len(errs))\n\t\t}\n\t\treturn errs[0]\n\t}\n\tif !d.quiet {\n\t\td.logger.Println(\"Success!\")\n\t}\n\n\tif d.cfg.InvalidateCDN {\n\t\tif d.target.CloudFrontDistributionID != \"\" {\n\t\t\tif d.cfg.DryRun {\n\t\t\t\tif !d.quiet {\n\t\t\t\t\td.logger.Printf(\"[DRY RUN] Would invalidate CloudFront CDN with ID %s\\n\", d.target.CloudFrontDistributionID)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\td.logger.Println(\"Invalidating CloudFront CDN...\")\n\t\t\t\tif err := InvalidateCloudFront(ctx, d.target.CloudFrontDistributionID); err != nil {\n\t\t\t\t\td.logger.Printf(\"Failed to invalidate CloudFront CDN: %v\\n\", err)\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif d.target.GoogleCloudCDNOrigin != \"\" {\n\t\t\tif d.cfg.DryRun {\n\t\t\t\tif !d.quiet {\n\t\t\t\t\td.logger.Printf(\"[DRY RUN] Would invalidate Google Cloud CDN with origin %s\\n\", d.target.GoogleCloudCDNOrigin)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\td.logger.Println(\"Invalidating Google Cloud CDN...\")\n\t\t\t\tif err := InvalidateGoogleCloudCDN(ctx, d.target.GoogleCloudCDNOrigin); err != nil {\n\t\t\t\t\td.logger.Printf(\"Failed to invalidate Google Cloud CDN: %v\\n\", err)\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\td.logger.Println(\"Success!\")\n\t}\n\treturn nil\n}", "func (m *Material) Deploy() error {\n\tif BuildImage != \"\" {\n\t\tif EcrID != \"\" {\n\t\t\tif err := m.EcrLogin(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tc, err := GitGetCommitHash()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tCommitHash = c\n\n\t\t// TODO: Implementation\n\t\tif Lifecycle {\n\t\t\tif err := ImageLifecycle(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tif err := DockerImageUpload(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif err := m.ECSServiceUpdate(); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (d *downloadCommand) Run(args []string) int {\n\tif len(args) < 2 {\n\t\tfmt.Println(\"The download command expects exactly two arguments.\")\n\t\tfmt.Printf(\"%s\\n\", d.Help())\n\t\treturn 1\n\t}\n\tproduct := args[0]\n\tversion := args[1]\n\n\tproductURL, err := url.Parse(hcrelease.ReleasesURL)\n\tif err != nil {\n\t\treturn 1\n\t}\n\tproductURL.Path = \"index.json\"\n\n\tproducts, err := hcrelease.GetProducts(productURL.String())\n\tif err != nil {\n\t\tfmt.Printf(\"failed to retrieve product details: %v\", err)\n\t\treturn 1\n\t}\n\n\trelease, err := products.GetRelease(product)\n\tif err != nil {\n\t\tfmt.Printf(\"failed to retrieve release details: %v\", err)\n\t\treturn 1\n\t}\n\n\tver, err := release.GetVersion(version)\n\tif err != nil {\n\t\tfmt.Printf(\"failed to retrieve version details: %v\", err)\n\t\treturn 1\n\t}\n\n\tbuild, err := ver.GetBuild(runtime.GOOS, runtime.GOARCH)\n\tif err != nil {\n\t\tfmt.Printf(\"failed to retrieve build details: %v\", err)\n\t\treturn 1\n\t}\n\n\toutFile, err := os.Create(build.Filename)\n\tif err != nil {\n\t\treturn 1\n\t}\n\tdefer outFile.Close()\n\n\terr = build.Download(outFile)\n\tif err != nil {\n\t\tfmt.Printf(\"failed to download build: %v\", err)\n\t\treturn 1\n\t}\n\n\treturn 0\n}", "func (s *deployerService) deploy(ctx context.Context, db *gorm.DB, opts DeploymentsCreateOpts) (*Release, error) {\n\tapp, img := opts.App, opts.Image\n\n\t// If no app is specified, attempt to find the app that relates to this\n\t// images repository, or create it if not found.\n\tif app == nil {\n\t\tvar err error\n\t\tapp, err = appsFindOrCreateByRepo(db, img.Repository)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\t// If the app doesn't already have a repo attached to it, we'll attach\n\t\t// this image's repo.\n\t\tif err := appsEnsureRepo(db, app, img.Repository); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Grab the latest config.\n\tconfig, err := s.configs.Config(db, app)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create a new slug for the docker image.\n\tslug, err := s.slugs.Create(ctx, db, img, opts.Output)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create a new release for the Config\n\t// and Slug.\n\tdesc := fmt.Sprintf(\"Deploy %s\", img.String())\n\n\tr, err := s.releases.Create(ctx, db, &Release{\n\t\tApp: app,\n\t\tConfig: config,\n\t\tSlug: slug,\n\t\tDescription: desc,\n\t})\n\n\treturn r, err\n}", "func NewDeployEnvCmd(out io.Writer) *cobra.Command {\n\te := &envCmd{out: out}\n\n\tcmd := &cobra.Command{\n\t\tUse: \"env\",\n\t\tAliases: []string{\"environment\"},\n\t\tShort: \"Deploy a list of Helm charts to an environment (Kubernetes namespace)\",\n\t\tLong: ``,\n\t\tArgs: func(cmd *cobra.Command, args []string) error {\n\t\t\tif e.name == \"\" {\n\t\t\t\treturn errors.New(\"name can not be empty\")\n\t\t\t}\n\t\t\tif e.repo == \"\" {\n\t\t\t\treturn errors.New(\"repo can not be empty\")\n\t\t\t}\n\t\t\tif e.tls {\n\t\t\t\tif e.helmTLSStore == \"\" {\n\t\t\t\t\treturn errors.New(\"tls is set to true and helm-tls-store is not defined\")\n\t\t\t\t}\n\t\t\t\tif e.kubeContext == \"\" {\n\t\t\t\t\treturn errors.New(\"kube-context has to be non-empty when tls is set to true\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tif len(e.override) == 0 {\n\t\t\t\tif e.chartsFile == \"\" {\n\t\t\t\t\treturn errors.New(\"either charts-file or override has to be defined\")\n\t\t\t\t}\n\t\t\t\tif e.deployOnlyOverrideIfEnvExists {\n\t\t\t\t\treturn errors.New(\"override has to be defined when using using deploy-only-override-if-env-exists\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tif e.chartsFile != \"\" && utils.CheckCircularDependencies(utils.InitReleasesFromChartsFile(e.chartsFile, e.name)) {\n\t\t\t\treturn errors.New(\"Circular dependency found\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t\tRun: func(cmd *cobra.Command, args []string) {\n\n\t\t\tlog.Println(\"initializing chart repository configuration\")\n\t\t\tif err := utils.AddRepository(utils.AddRepositoryOptions{\n\t\t\t\tRepo: e.repo,\n\t\t\t\tPrint: false,\n\t\t\t}); err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t\tif err := utils.UpdateRepositories(false); err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\n\t\t\tlog.Printf(\"deploying environment \\\"%s\\\"\", e.name)\n\t\t\tnsPreExists, err := utils.NamespaceExists(e.name, e.kubeContext)\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t\tif !nsPreExists {\n\t\t\t\tif err := utils.CreateNamespace(e.name, e.kubeContext, false); err != nil {\n\t\t\t\t\tlog.Fatal(err)\n\t\t\t\t}\n\t\t\t\tlog.Printf(\"created environment \\\"%s\\\"\", e.name)\n\t\t\t}\n\t\t\tif err := lockEnvironment(e.name, e.kubeContext, true); err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\n\t\t\tannotations := map[string]string{}\n\t\t\tfor _, a := range e.annotations {\n\t\t\t\tk, v := utils.SplitInTwo(a, \"=\")\n\t\t\t\tannotations[k] = v\n\t\t\t}\n\t\t\tlabels := map[string]string{}\n\t\t\tfor _, a := range e.labels {\n\t\t\t\tk, v := utils.SplitInTwo(a, \"=\")\n\t\t\t\tlabels[k] = v\n\t\t\t}\n\t\t\tif err := utils.UpdateNamespace(e.name, e.kubeContext, annotations, labels, true); err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\n\t\t\tlog.Print(\"initializing releases to deploy\")\n\t\t\tvar desiredReleases []utils.ReleaseSpec\n\t\t\tif nsPreExists && e.deployOnlyOverrideIfEnvExists {\n\t\t\t\tdesiredReleases = utils.InitReleases(e.name, e.override)\n\t\t\t} else {\n\t\t\t\tif e.chartsFile != \"\" {\n\t\t\t\t\tdesiredReleases = utils.InitReleasesFromChartsFile(e.chartsFile, e.name)\n\t\t\t\t}\n\t\t\t\tdesiredReleases = utils.OverrideReleases(desiredReleases, e.override, e.name)\n\t\t\t}\n\n\t\t\tlog.Print(\"getting currently deployed releases\")\n\t\t\tinstalledReleases, err := utils.GetInstalledReleases(utils.GetInstalledReleasesOptions{\n\t\t\t\tKubeContext: e.kubeContext,\n\t\t\t\tNamespace: e.name,\n\t\t\t\tIncludeFailed: false,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\tunlockEnvironment(e.name, e.kubeContext, true)\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\n\t\t\tlog.Print(\"updating protected charts\")\n\t\t\tprotectedCharts, err := updateProtectedCharts(e.name, e.kubeContext, e.protectedCharts, true)\n\t\t\tif err != nil {\n\t\t\t\tunlockEnvironment(e.name, e.kubeContext, true)\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\n\t\t\tfor _, ir := range installedReleases {\n\t\t\t\tfor _, pc := range protectedCharts {\n\t\t\t\t\tif pc != ir.ChartName {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tdesiredReleases = utils.OverrideReleases(desiredReleases, []string{ir.ChartName + \"=\" + ir.ChartVersion}, e.name)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlog.Print(\"calculating delta between desired releases and currently deployed releases\")\n\t\t\treleasesToInstall := utils.GetReleasesDelta(desiredReleases, installedReleases)\n\n\t\t\tlog.Print(\"deploying releases\")\n\t\t\tif err := utils.DeployChartsFromRepository(utils.DeployChartsFromRepositoryOptions{\n\t\t\t\tReleasesToInstall: releasesToInstall,\n\t\t\t\tKubeContext: e.kubeContext,\n\t\t\t\tNamespace: e.name,\n\t\t\t\tRepo: e.repo,\n\t\t\t\tTLS: e.tls,\n\t\t\t\tHelmTLSStore: e.helmTLSStore,\n\t\t\t\tPackedValues: e.packedValues,\n\t\t\t\tSetValues: e.set,\n\t\t\t\tInject: e.inject,\n\t\t\t\tParallel: e.parallel,\n\t\t\t\tTimeout: e.timeout,\n\t\t\t}); err != nil {\n\t\t\t\tmarkEnvironmentAsFailed(e.name, e.kubeContext, true)\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\n\t\t\tif !e.deployOnlyOverrideIfEnvExists {\n\t\t\t\tlog.Print(\"getting currently deployed releases\")\n\t\t\t\tinstalledReleases, err := utils.GetInstalledReleases(utils.GetInstalledReleasesOptions{\n\t\t\t\t\tKubeContext: e.kubeContext,\n\t\t\t\t\tNamespace: e.name,\n\t\t\t\t\tIncludeFailed: false,\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\tmarkEnvironmentAsUnknown(e.name, e.kubeContext, true)\n\t\t\t\t\tlog.Fatal(err)\n\t\t\t\t}\n\t\t\t\tlog.Print(\"calculating delta between desired releases and currently deployed releases\")\n\t\t\t\treleasesToDelete := utils.GetReleasesDelta(installedReleases, desiredReleases)\n\t\t\t\tlog.Print(\"deleting undesired releases\")\n\t\t\t\tif err := utils.DeleteReleases(utils.DeleteReleasesOptions{\n\t\t\t\t\tReleasesToDelete: releasesToDelete,\n\t\t\t\t\tKubeContext: e.kubeContext,\n\t\t\t\t\tTLS: e.tls,\n\t\t\t\t\tHelmTLSStore: e.helmTLSStore,\n\t\t\t\t\tParallel: e.parallel,\n\t\t\t\t\tTimeout: e.timeout,\n\t\t\t\t}); err != nil {\n\t\t\t\t\tmarkEnvironmentAsFailed(e.name, e.kubeContext, true)\n\t\t\t\t\tlog.Fatal(err)\n\t\t\t\t}\n\t\t\t}\n\t\t\tlog.Printf(\"deployed environment \\\"%s\\\"\", e.name)\n\n\t\t\tvar envValid bool\n\t\t\tif e.validate {\n\t\t\t\tenvValid, err = utils.IsEnvValidWithLoopBackOff(e.name, e.kubeContext)\n\t\t\t}\n\n\t\t\tunlockEnvironment(e.name, e.kubeContext, true)\n\n\t\t\tif !e.validate {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t\tif !envValid {\n\t\t\t\tmarkEnvironmentAsFailed(e.name, e.kubeContext, true)\n\t\t\t\tlog.Fatalf(\"environment \\\"%s\\\" validation failed!\", e.name)\n\t\t\t}\n\t\t\t// If we have made it so far, the environment is validated\n\t\t\tlog.Printf(\"environment \\\"%s\\\" validated!\", e.name)\n\t\t},\n\t}\n\n\tf := cmd.Flags()\n\n\tf.StringVarP(&e.chartsFile, \"charts-file\", \"c\", os.Getenv(\"ORCA_CHARTS_FILE\"), \"path to file with list of Helm charts to install. Overrides $ORCA_CHARTS_FILE\")\n\tf.StringSliceVar(&e.override, \"override\", []string{}, \"chart to override with different version (can specify multiple): chart=version\")\n\tf.StringVarP(&e.name, \"name\", \"n\", os.Getenv(\"ORCA_NAME\"), \"name of environment (namespace) to deploy to. Overrides $ORCA_NAME\")\n\tf.StringVar(&e.repo, \"repo\", os.Getenv(\"ORCA_REPO\"), \"chart repository (name=url). Overrides $ORCA_REPO\")\n\tf.StringVar(&e.kubeContext, \"kube-context\", os.Getenv(\"ORCA_KUBE_CONTEXT\"), \"name of the kubeconfig context to use. Overrides $ORCA_KUBE_CONTEXT\")\n\tf.StringSliceVarP(&e.packedValues, \"values\", \"f\", []string{}, \"values file to use (packaged within the chart)\")\n\tf.StringSliceVarP(&e.set, \"set\", \"s\", []string{}, \"set additional parameters\")\n\tf.BoolVar(&e.tls, \"tls\", utils.GetBoolEnvVar(\"ORCA_TLS\", false), \"enable TLS for request. Overrides $ORCA_TLS\")\n\tf.StringVar(&e.helmTLSStore, \"helm-tls-store\", os.Getenv(\"HELM_TLS_STORE\"), \"path to TLS certs and keys. Overrides $HELM_TLS_STORE\")\n\tf.BoolVar(&e.inject, \"inject\", utils.GetBoolEnvVar(\"ORCA_INJECT\", false), \"enable injection during helm upgrade. Overrides $ORCA_INJECT (requires helm inject plugin: https://github.com/maorfr/helm-inject)\")\n\tf.IntVarP(&e.parallel, \"parallel\", \"p\", utils.GetIntEnvVar(\"ORCA_PARALLEL\", 1), \"number of releases to act on in parallel. set this flag to 0 for full parallelism. Overrides $ORCA_PARALLEL\")\n\tf.IntVar(&e.timeout, \"timeout\", utils.GetIntEnvVar(\"ORCA_TIMEOUT\", 300), \"time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks). Overrides $ORCA_TIMEOUT\")\n\tf.StringSliceVar(&e.annotations, \"annotations\", []string{}, \"additional environment (namespace) annotations (can specify multiple): annotation=value\")\n\tf.StringSliceVar(&e.labels, \"labels\", []string{}, \"environment (namespace) labels (can specify multiple): label=value\")\n\tf.BoolVar(&e.validate, \"validate\", utils.GetBoolEnvVar(\"ORCA_VALIDATE\", false), \"perform environment validation after deployment. Overrides $ORCA_VALIDATE\")\n\tf.BoolVarP(&e.deployOnlyOverrideIfEnvExists, \"deploy-only-override-if-env-exists\", \"x\", utils.GetBoolEnvVar(\"ORCA_DEPLOY_ONLY_OVERRIDE_IF_ENV_EXISTS\", false), \"if environment exists - deploy only override(s) (avoid environment update). Overrides $ORCA_DEPLOY_ONLY_OVERRIDE_IF_ENV_EXISTS\")\n\tf.StringSliceVar(&e.protectedCharts, \"protected-chart\", []string{}, \"chart name to protect from being overridden (can specify multiple)\")\n\n\tf.BoolVar(&e.refresh, \"refresh\", utils.GetBoolEnvVar(\"ORCA_REFRESH\", false), \"refresh the environment based on reference environment. Overrides $ORCA_REFRESH\")\n\tf.MarkDeprecated(\"refresh\", \"this is now the default behavior. use -x to deploy only overrides\")\n\treturn cmd\n}", "func Cmd(rootArgs *shared.RootArgs, printf shared.FormatFn) *cobra.Command {\n\tp := &provision{RootArgs: rootArgs}\n\n\tc := &cobra.Command{\n\t\tUse: \"provision\",\n\t\tShort: \"Provision your Apigee environment for remote services\",\n\t\tLong: `The provision command will set up your Apigee environment for remote services. This includes creating\nand installing a remote-service kvm with certificates, creating credentials, and deploying a remote-service proxy\nto your organization and environment.`,\n\t\tArgs: cobra.NoArgs,\n\t\tPersistentPreRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif err := rootArgs.Resolve(false, true); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif !p.IsGCPManaged && p.rotate > 0 {\n\t\t\t\treturn fmt.Errorf(`--rotate only valid for hybrid, use 'token rotate-cert' for others`)\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\n\t\tRunE: func(cmd *cobra.Command, _ []string) error {\n\t\t\tif p.IsGCPManaged {\n\t\t\t\terr := p.retrieveRuntimeType()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrapf(err, \"getting runtime type\")\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn p.run(printf)\n\t\t},\n\t}\n\n\tc.Flags().StringVarP(&rootArgs.ManagementBase, \"management\", \"m\",\n\t\tshared.DefaultManagementBase, \"Apigee management base URL\")\n\tc.Flags().BoolVarP(&rootArgs.IsLegacySaaS, \"legacy\", \"\", false,\n\t\t\"Apigee SaaS (sets management and runtime URL)\")\n\tc.Flags().BoolVarP(&rootArgs.IsOPDK, \"opdk\", \"\", false,\n\t\t\"Apigee opdk\")\n\n\tc.Flags().StringVarP(&rootArgs.Token, \"token\", \"t\", \"\",\n\t\t\"Apigee OAuth or SAML token (overrides any other given credentials)\")\n\tc.Flags().StringVarP(&rootArgs.Username, \"username\", \"u\", \"\",\n\t\t\"Apigee username (legacy or opdk only)\")\n\tc.Flags().StringVarP(&rootArgs.Password, \"password\", \"p\", \"\",\n\t\t\"Apigee password (legacy or opdk only)\")\n\tc.Flags().StringVarP(&rootArgs.MFAToken, \"mfa\", \"\", \"\",\n\t\t\"Apigee multi-factor authorization token (legacy only)\")\n\n\tc.Flags().StringVarP(&p.analyticsServiceAccount, \"analytics-sa\", \"\", \"\",\n\t\t\"path to the service account json file (for GCP-managed analytics only)\")\n\n\tc.Flags().BoolVarP(&p.forceProxyInstall, \"force-proxy-install\", \"f\", false,\n\t\t\"force new proxy install (upgrades proxy)\")\n\tc.Flags().StringVarP(&p.virtualHosts, \"virtual-hosts\", \"\", \"default,secure\",\n\t\t\"override proxy virtualHosts\")\n\tc.Flags().StringVarP(&p.Namespace, \"namespace\", \"n\", \"apigee\",\n\t\t\"emit configuration in the specified namespace\")\n\n\tc.Flags().IntVarP(&p.rotate, \"rotate\", \"\", 0, \"if n > 0, generate new private key and keep n public keys (hybrid only)\")\n\n\treturn c\n}", "func (p *Plugin) Exec() error {\n\tif p.Config.URL == \"\" {\n\t\treturn fmt.Errorf(\"Error: base URL of the flux controller must be added\")\n\t}\n\n\tif len(p.Config.Controller) == 0 {\n\t\treturn fmt.Errorf(\"Error: list of controllers to release at least one\")\n\t}\n\n\tif p.Config.User == \"\" {\n\t\tp.Config.User = p.Build.Author\n\t}\n\n\tif p.Config.Message == \"\" {\n\t\tp.Config.Message = p.Build.Message\n\t}\n\n\targs := []string{\"release --url=\" + p.Config.URL}\n\tif p.Config.Token != \"\" {\n\t\targs = append(args, \"--token=\"+p.Config.Token)\n\t}\n\n\tif p.Config.Namespace != \"\" {\n\t\targs = append(args, \"--namespace=\"+p.Config.Namespace)\n\t}\n\n\targs = append(args, \"--controller=\"+strings.Join(p.Config.Controller, \",\"))\n\n\tif len(p.Config.Exclude) > 0 {\n\t\targs = append(args, \"--exclude=\"+strings.Join(p.Config.Exclude, \",\"))\n\t}\n\n\tif p.Config.UpdateImage != \"\" {\n\t\targs = append(args, \"--update-image=\"+p.Config.UpdateImage)\n\t}\n\n\tif p.Config.User != \"\" {\n\t\targs = append(args, \"--user=\"+p.Config.User)\n\t}\n\tif p.Config.Message != \"\" {\n\t\targs = append(args, \"--message=\"+p.Config.Message)\n\t}\n\n\tcmd := exec.Command(\"fluxctl\", strings.Join(args, \" \"))\n\tcmd.Stdout = os.Stdout\n\tcmd.Stderr = os.Stderr\n\tif err := cmd.Run(); err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Println(\"================================================\")\n\tfmt.Println(\"Successfully deploy new images for kubernetes cluster.\")\n\tfmt.Println(\"================================================\")\n\n\treturn nil\n}", "func Deploy(clusterName string) (error) {\n\tk8Definition, err := getDeployment(clusterName)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn k8client.Apply(k8Definition)\n}", "func (opts *DeployEnvironmentOpts) Execute() error {\n\tif opts.DryRun {\n\t\treturn opts.dryRunEnvironment()\n\t} else {\n\t\treturn opts.deployEnvironment()\n\t}\n}", "func (cmd *CmdUploadPackage) Execute(args []string) error {\n\n\t// Validate incoming flags\n\terr := cmd.validateFlags()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Open our package file\n\tfile, err := os.Open(cmd.PackagePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\n\t// Setup our multipart writer and create the request body using the file supplied\n\tbody := &bytes.Buffer{}\n\twriter := multipart.NewWriter(body)\n\tpart, err := writer.CreateFormFile(\"file\", filepath.Base(cmd.PackagePath))\n\tif err != nil {\n\t\treturn err\n\t}\n\tfileSize, err := io.Copy(part, file)\n\terr = writer.Close()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar endpoint string\n\n\tif cmd.Config.GetEndpointType() == config.EndpointTypeHosted {\n\t\tendpoint = cmd.APIEndpoint + \"/\" + cmd.Config.GetAccountLogicalName() + \"/\" + cmd.Config.GetServiceLogicalName() + upEndPointURI\n\t} else if cmd.Config.GetEndpointType() == config.EndpointTypeOnPremise {\n\t\tendpoint = cmd.APIEndpoint + upEndPointURI\n\t} else {\n\t\treturn errors.New(\"Invalid Endpoint Type in cached config. Reauthenticate to reset\")\n\t}\n\n\tclient := http.Client{}\n\treq, err := http.NewRequest(\"POST\", endpoint, body)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Add our required request headers\n\treq.Header.Add(\"X-UIPATH-TenantName\", cmd.Config.GetServiceLogicalName())\n\treq.Header.Add(\"Authorization\", \"Bearer \"+cmd.Config.GetAccessToken())\n\treq.Header.Add(\"Content-Type\", writer.FormDataContentType())\n\n\t// Use the HTTPHelper to make our API call\n\trespBody, err := util.HTTPHelper(client, req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tapiResp := uploadRespWrapper{}\n\tjsonErr := json.Unmarshal(respBody, &apiResp)\n\tif jsonErr != nil {\n\t\treturn jsonErr\n\t}\n\n\tfmt.Println(\"Package uploaded successfully\")\n\tfmt.Println(\"\")\n\tfmt.Println(\" Package File: \", apiResp.UploadResp[0].Key)\n\tfmt.Println(\" File Size: \", fileSize)\n\tfmt.Println(\" Status: \", apiResp.UploadResp[0].Status)\n\tfmt.Println(\"\")\n\n\treturn nil\n\n}", "func (d *Deployer) Deploy(namespace, rcName string) error {\n\t// Look up the new deployment.\n\tto, err := d.getDeployment(namespace, rcName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"couldn't get deployment %s: %v\", rcName, err)\n\t}\n\n\t// Decode the config from the deployment.\n\t// TODO: Remove this once we are sure there are no internal versions of configs serialized in DC\n\tconfig, err := appsserialization.DecodeDeploymentConfig(to)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"couldn't decode deployment config from deployment %s: %v\", to.Name, err)\n\t}\n\n\t// Get a strategy for the deployment.\n\ts, err := d.strategyFor(config)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// New deployments must have a desired replica count.\n\tdesiredReplicas, hasDesired := deploymentDesiredReplicas(to)\n\tif !hasDesired {\n\t\treturn fmt.Errorf(\"deployment %s has already run to completion\", to.Name)\n\t}\n\n\t// Find all deployments for the config.\n\tunsortedDeployments, err := d.getDeployments(namespace, config.Name)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"couldn't get controllers in namespace %s: %v\", namespace, err)\n\t}\n\tdeployments := make([]*corev1.ReplicationController, 0, len(unsortedDeployments.Items))\n\tfor i := range unsortedDeployments.Items {\n\t\tdeployments = append(deployments, &unsortedDeployments.Items[i])\n\t}\n\n\t// Sort all the deployments by version.\n\tsort.Sort(appsutil.ByLatestVersionDesc(deployments))\n\n\t// Find any last completed deployment.\n\tvar from *corev1.ReplicationController\n\tfor _, candidate := range deployments {\n\t\tif candidate.Name == to.Name {\n\t\t\tcontinue\n\t\t}\n\t\tif appsutil.IsCompleteDeployment(candidate) {\n\t\t\tfrom = candidate\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif appsutil.DeploymentVersionFor(to) < appsutil.DeploymentVersionFor(from) {\n\t\treturn fmt.Errorf(\"deployment %s is older than %s\", to.Name, from.Name)\n\t}\n\n\t// Scale down any deployments which aren't the new or last deployment.\n\tfor _, candidate := range deployments {\n\t\t// Skip the from/to deployments.\n\t\tif candidate.Name == to.Name {\n\t\t\tcontinue\n\t\t}\n\t\tif from != nil && candidate.Name == from.Name {\n\t\t\tcontinue\n\t\t}\n\t\t// Skip the deployment if it's already scaled down.\n\t\tif candidate.Spec.Replicas == nil || *candidate.Spec.Replicas == 0 {\n\t\t\tcontinue\n\t\t}\n\t\t// Scale the deployment down to zero.\n\t\tretryWaitParams := kscale.NewRetryParams(1*time.Second, 120*time.Second)\n\t\tif err := d.scaler.Scale(candidate.Namespace, candidate.Name, uint(0), &kscale.ScalePrecondition{Size: -1, ResourceVersion: \"\"}, retryWaitParams, retryWaitParams, corev1.SchemeGroupVersion.WithResource(\"replicationcontrollers\"), false); err != nil {\n\t\t\tfmt.Fprintf(d.errOut, \"error: Couldn't scale down prior deployment %s: %v\\n\", appsutil.LabelForDeployment(candidate), err)\n\t\t} else {\n\t\t\tfmt.Fprintf(d.out, \"--> Scaled older deployment %s down\\n\", candidate.Name)\n\t\t}\n\t}\n\n\tif d.until == \"start\" {\n\t\treturn strategy.NewConditionReachedErr(\"Ready to start deployment\")\n\t}\n\n\t// Perform the deployment.\n\tif err := s.Deploy(from, to, int(desiredReplicas)); err != nil {\n\t\treturn err\n\t}\n\tfmt.Fprintln(d.out, \"--> Success\")\n\treturn nil\n}", "func (builder *Builder) Run(ctx context.Context) error {\n\tif builder.hasCustomVMIMageRef() {\n\t\tbuilder.Log.Debugf(\"using %s image in %s resource group\", builder.Image, builder.ImageResourceGroup)\n\t} else {\n\t\tbuilder.Log.Debugf(\"using: redhat osa image (SKU: %s; Version: %s)\", builder.ImageSku, builder.ImageVersion)\n\t}\n\n\ttemplate, err := builder.generateTemplate()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer func() {\n\t\tif !builder.PreserveBuildResourceGroup {\n\t\t\tbuilder.Log.Infof(\"PreserveBuildResourceGroup not set, deleting build resource group\")\n\t\t\tbuilder.Groups.Delete(ctx, builder.BuildResourceGroup)\n\t\t}\n\t}()\n\n\tbuilder.Log.Infof(\"creating resource group %s\", builder.BuildResourceGroup)\n\t_, err = builder.Groups.CreateOrUpdate(ctx, builder.BuildResourceGroup, azresources.Group{\n\t\tLocation: to.StringPtr(builder.Location),\n\t\tTags: map[string]*string{\n\t\t\t\"now\": to.StringPtr(fmt.Sprintf(\"%d\", time.Now().Unix())),\n\t\t\t\"ttl\": to.StringPtr(\"6h\"),\n\t\t},\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tbuilder.Log.Infof(\"deploying template, ssh to VM if needed via:\")\n\tbuilder.Log.Infof(\" ssh -i id_rsa cloud-user@%s.%s.cloudapp.azure.com\", builder.DomainNameLabel, builder.Location)\n\tfuture, err := builder.Deployments.CreateOrUpdate(ctx, builder.BuildResourceGroup, \"azuredeploy\", azresources.Deployment{\n\t\tProperties: &azresources.DeploymentProperties{\n\t\t\tTemplate: template,\n\t\t\tMode: azresources.Incremental,\n\t\t},\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tgo builder.ssh()\n\n\tcli := builder.Deployments.Client()\n\tcli.PollingDuration = time.Minute * 90\n\n\tbuilder.Log.Infof(\"waiting for deployment\")\n\terr = future.WaitForCompletionRef(ctx, cli)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif builder.Validate {\n\t\tbuilder.Log.Infof(\"copy file from VM\")\n\t\terr := builder.scp([]string{\n\t\t\t\"/tmp/yum_updateinfo\",\n\t\t\t\"/tmp/yum_updateinfo_list_security\",\n\t\t\t\"/tmp/yum_check_update\",\n\t\t\t\"/tmp/scap_report.html\",\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func DeployApp(w http.ResponseWriter, r *http.Request) {\n\tparams := mux.Vars(r)\n\tstatus := params[\"status\"]\n\tlog.Printf(\"Params: %s\\n\", params)\n\n\tclientset, err := getConfig()\n\tif err != nil {\n\t\tlog.Fatalln(\"failed to get the config:\", err)\n\t}\n\n\tdeploymentsClient := clientset.AppsV1().Deployments(namespace)\n\n\tdeploymentName := params[\"app\"] + \"-deployment\"\n\n\tlist, err := deploymentsClient.List(metav1.ListOptions{})\n\tif err != nil {\n\t\tlog.Fatalln(\"failed to get deployments:\", err)\n\t}\n\n\tcontainers := []apiv1.Container{createContainer(params[\"app\"], repository+\"/\"+params[\"app\"]+appversion)}\n\n\tif status == \"true\" {\n\t\tfor _, d := range list.Items {\n\t\t\tif d.Name == deploymentName && *d.Spec.Replicas > 0 {\n\t\t\t\tlog.Printf(\"Deployment already running: %s\\n\", deploymentName)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tnodeLabel(params[\"node\"], \"app\", params[\"app\"], \"add\")\n\n\t\tdeployment := &appsv1.Deployment{\n\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\tName: deploymentName,\n\t\t\t},\n\t\t\tSpec: appsv1.DeploymentSpec{\n\t\t\t\tReplicas: int32Ptr(1),\n\t\t\t\tSelector: &metav1.LabelSelector{\n\t\t\t\t\tMatchLabels: map[string]string{\n\t\t\t\t\t\t\"app\": params[\"app\"],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tTemplate: apiv1.PodTemplateSpec{\n\t\t\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\t\t\tLabels: map[string]string{\n\t\t\t\t\t\t\t\"app\": params[\"app\"],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tSpec: apiv1.PodSpec{\n\t\t\t\t\t\tContainers: containers,\n\t\t\t\t\t\tNodeSelector: map[string]string{\n\t\t\t\t\t\t\t\"app\": params[\"app\"],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tVolumes: []apiv1.Volume{\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tName: \"mem\",\n\t\t\t\t\t\t\t\tVolumeSource: apiv1.VolumeSource{\n\t\t\t\t\t\t\t\t\tHostPath: &apiv1.HostPathVolumeSource{\n\t\t\t\t\t\t\t\t\t\tPath: \"/dev/mem\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tName: \"gpiomem\",\n\t\t\t\t\t\t\t\tVolumeSource: apiv1.VolumeSource{\n\t\t\t\t\t\t\t\t\tHostPath: &apiv1.HostPathVolumeSource{\n\t\t\t\t\t\t\t\t\t\tPath: \"/dev/gpiomem\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t\t// Create Deployment\n\t\tfmt.Println(\"Creating deployment...\")\n\t\tresult, err := deploymentsClient.Create(deployment)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tfmt.Printf(\"Created deployment %q.\\n\", result.GetObjectMeta().GetName())\n\n\t} else {\n\n\t\tnodeLabel(params[\"node\"], \"app\", params[\"app\"], \"del\")\n\n\t\tfmt.Println(\"Deleting deployment...\")\n\t\tdeletePolicy := metav1.DeletePropagationForeground\n\t\tif err := deploymentsClient.Delete(deploymentName, &metav1.DeleteOptions{\n\t\t\tPropagationPolicy: &deletePolicy,\n\t\t}); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tfmt.Println(\"Deleted deployment.\")\n\t}\n\n}", "func (d *Deployer) Deploy(obj *unstructured.Unstructured) error {\n\tfound := &unstructured.Unstructured{}\n\tfound.SetGroupVersionKind(obj.GroupVersionKind())\n\terr := d.client.Get(context.TODO(), types.NamespacedName{Name: obj.GetName(), Namespace: obj.GetNamespace()}, found)\n\tif err != nil {\n\t\tif errors.IsNotFound(err) {\n\t\t\tlog.Info(\"Create\", \"Kind:\", obj.GroupVersionKind(), \"Name:\", obj.GetName())\n\t\t\treturn d.client.Create(context.TODO(), obj)\n\t\t}\n\t\treturn err\n\t}\n\n\t// if resource has annotation skip-creation-if-exist: true, don't update it to keep customized changes from users\n\tmetadata, ok := obj.Object[\"metadata\"].(map[string]interface{})\n\tif ok {\n\t\tannotations, ok := metadata[\"annotations\"].(map[string]interface{})\n\t\tif ok && annotations != nil && annotations[config.AnnotationSkipCreation] != nil {\n\t\t\tif strings.ToLower(annotations[config.AnnotationSkipCreation].(string)) == \"true\" {\n\t\t\t\tlog.Info(\"Skip creation\", \"Kind:\", obj.GroupVersionKind(), \"Name:\", obj.GetName())\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}\n\n\tdeployerFn, ok := d.deployerFns[found.GetKind()]\n\tif ok {\n\t\treturn deployerFn(obj, found)\n\t}\n\treturn nil\n}", "func runServeCmd(cmd *cobra.Command, args []string) {\n\tchartstreams.SetLogLevel(viper.GetString(\"log-level\"))\n\n\tcfg := &chartstreams.Config{\n\t\tRepoURL: viper.GetString(\"repo-url\"),\n\t\tCloneDepth: viper.GetInt(\"clone-depth\"),\n\t\tListenAddr: viper.GetString(\"listen-addr\"),\n\t\tRelativeDir: viper.GetString(\"relative-dir\"),\n\t\tForceClone: viper.GetBool(\"force-clone\"),\n\t\tGitHubWebhookSecret: viper.GetString(\"github-webhook-secret\"),\n\t}\n\n\tlog.Printf(\"Starting server with config: '%#v'\", cfg)\n\n\tp := chartstreams.NewGitChartProvider(cfg, viper.GetString(\"working-dir\"))\n\tif err := p.Initialize(); err != nil {\n\t\tlog.Fatalf(\"Error during chart provider initialization: '%q'\", err)\n\t}\n\n\ts := chartstreams.NewServer(cfg, p)\n\tif err := s.Start(); err != nil {\n\t\tlog.Fatalf(\"Error during server start: '%q'\", err)\n\t}\n}", "func runReleaseCmd(cmd *cobra.Command, args []string) {\n\tconfigFile, _ := cmd.Flags().GetString(\"config\")\n\tconfig := &config.Config{}\n\terr := config.Load(configFile)\n\tif err != nil {\n\t\tfmt.Printf(\"could not load config file: %v\\n\", err)\n\t\tos.Exit(1)\n\t\treturn\n\t}\n\n\tspinner, err := initSpinner(fmt.Sprintf(\"Releasing v%s of %s\", args[0], config.Repository))\n\tif err != nil {\n\t\tfmt.Println(\"could not init spinner\")\n\t\tos.Exit(1)\n\t\treturn\n\t}\n\tspinner.Start()\n\n\tnewRelease, err := github.NewRelease(config, args, spinner)\n\tif err != nil {\n\t\tspinner.StopFailMessage(fmt.Sprintf(\"%v\", err))\n\t\tspinner.StopFail()\n\t\tos.Exit(1)\n\t\treturn\n\t}\n\n\tcl, err := changelog.HandleChangelog(newRelease.ProjectName, newRelease.Version, newRelease.Date, spinner)\n\tif err != nil {\n\t\tspinner.StopFailMessage(fmt.Sprintf(\"%v\", err))\n\t\tspinner.StopFail()\n\t\tos.Exit(1)\n\t\treturn\n\t}\n\n\tnewRelease.Changelog = cl\n\n\tvar binaryPath string\n\tskipBinary, _ := cmd.Flags().GetBool(\"skipBinary\")\n\tif !skipBinary {\n\t\t// set project build path so we have a predictable location\n\t\tbinaryPath = fmt.Sprintf(binaryPathFmt, newRelease.ProjectName, newRelease.Version)\n\t\trunBuildCmd(cmd, []string{newRelease.Version, binaryPath})\n\t}\n\n\ttokenFile, _ := cmd.Flags().GetString(\"tokenFile\")\n\terr = newRelease.CreateGithubRelease(tokenFile, binaryPath, spinner)\n\tif err != nil {\n\t\tspinner.StopFailMessage(fmt.Sprintf(\"%v\", err))\n\t\tspinner.StopFail()\n\t\tos.Exit(1)\n\t\treturn\n\t}\n\n\tspinner.Suffix(\" Finished release\")\n\tspinner.Stop()\n}", "func Executor(s string) {\n\ts = strings.TrimSpace(s)\n\tcmdStrings := strings.Split(s, \" \")\n\tif s == \"\" {\n\t\treturn\n\t} else if s == \"quit\" || s == \"exit\" {\n\t\tfmt.Println(\"Bye!\")\n\t\tos.Exit(0)\n\t\treturn\n\t}\n\tswitch cmdStrings[0] {\n\tcase \"install-px\":\n\t\tinstallPX()\n\tcase \"deploy\":\n\t\tif len(cmdStrings) < 2 {\n\t\t\tfmt.Println(\"deploy requires an application name\")\n\t\t\treturn\n\t\t}\n\t\tdeploy(\"default\", cmdStrings[1])\n\tcase \"benchmark\":\n\t\tswitch cmdStrings[1] {\n\t\tcase \"postgres\":\n\t\t\tpodExec(\"default\", \"app=postgres\", \"/usr/bin/psql -c 'create database pxdemo;'\")\n\t\t\tpodExec(\"default\", \"app=postgres\", \"/usr/bin/pgbench -n -i -s 50 pxdemo;\")\n\t\t\tpodExec(\"default\", \"app=postgres\", \"/usr/bin/psql pxdemo -c 'select count(*) from pgbench_accounts;'\")\n\t\tdefault:\n\t\t\tfmt.Printf(\"%s benchmark not supported\\n\", cmdStrings[1])\n\t\t}\n\tcase \"px\":\n\t\tif len(cmdStrings) < 2 {\n\t\t\tfmt.Println(\"deploy requires an application name\")\n\t\t\treturn\n\t\t}\n\t\tswitch cmdStrings[1] {\n\t\tcase \"connect\":\n\t\t\tpxInit()\n\t\tcase \"snap\":\n\t\t\tif len(cmdStrings) < 3 {\n\t\t\t\tfmt.Println(\"px snap requires an application name\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tpxSnap(cmdStrings[2])\n\t\tcase \"backup\":\n\t\t\tif len(cmdStrings) < 3 {\n\t\t\t\tfmt.Println(\"px backup requires an PVC name\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tpxBackup(cmdStrings[2])\n\t\tcase \"backup-status\":\n\t\t\tif len(cmdStrings) < 3 {\n\t\t\t\tfmt.Println(\"px backup-status requires a PVC name\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tpxBackupStatus(cmdStrings[2])\n\t\tdefault:\n\t\t\tfmt.Printf(\"px %s is not a valid command\\n\", cmdStrings[1])\n\t\t}\n\tcase \"pre-flight-check\":\n\t\tpreflight()\n\tdefault:\n\t\tfmt.Printf(\"%s is not a supported option\", s)\n\t}\n\treturn\n}", "func (drc *DummyRectificationClient) Deploy(d Deployable, reqID string) error {\n\tdrc.logf(\"Deploying instance %#v\", d)\n\tdrc.Deployed = append(drc.Deployed, d)\n\treturn nil\n}", "func (WebApp) Deploy() error {\n\treturn sh.Run(\"gcloud\", \"app\", \"deploy\",\n\t\tfmt.Sprintf(\"--project=%s\", gcpProject),\n\t\t\"--promote\",\n\t\t\"--quiet\",\n\t\t\"--verbosity=info\")\n}", "func (c *ReleaseController) Post() {\n\tvar ob ms.ServFlt\n\tjson.Unmarshal(c.Ctx.Input.RequestBody, &ob)\n\tlogs.Info(ob)\n\n\tdb, _ := ms.InitDb()\n\n\tvar env ms.Env\n\tvar serv ms.Serv\n\tdb.Preload(\"Hosts\").Where(\"name = ?\", ob.Env).First(&env).GetErrors()\n\tdb.Where(\"serv_name = ?\", ob.ServName).First(&serv).GetErrors()\n\n\tvar installRpm string\n\tvar stderr, stdout bytes.Buffer\n\ts := fmt.Sprintf(\"ls -lt /root/rpmbuild/RPMS/x86_64/ |grep -w %s |grep -w %s | awk -F' ' '{print $9}' |head -n 1\", ob.Env, ob.ServName)\n\tlogs.Info(s)\n\tcmd := exec.Command(\"/bin/sh\", \"-c\", s)\n\tcmd.Stdout = &stdout\n\tcmd.Stderr = &stderr\n\n\terr := cmd.Run()\n\tif err != nil {\n\t\tc.setError(1, fmt.Sprintf(\"local exec[%s] failed. \", s))\n\t\tlogs.Error(\"exec[%s] failed. Error:[%s]\", s, stderr.String())\n\t\tgoto end\n\t}\n\n\t//包名\n\tinstallRpm = \"/data/upgrade/\" + strings.Trim(stdout.String(), \"\\r\\n\")\n\tlogs.Info(\"Install RPM :\", installRpm)\n\n\tfor _, host := range env.Hosts {\n\t\tservType1 := serv.ServType\n\t\tservType2 := host.ServType\n\t\tif (1<<uint8(servType1))&servType2 > 0 {\n\t\t\ts = fmt.Sprintf(\"rpm -U --force %s\", installRpm)\n\t\t\tlogs.Info(host.Name, s)\n\t\t\tcmd = exec.Command(\"ssh\", host.Name, s)\n\t\t\tcmd.Stdout = &stdout\n\t\t\tcmd.Stderr = &stderr\n\t\t\terr = cmd.Run()\n\t\t\tif err != nil {\n\t\t\t\tc.setError(1, fmt.Sprintf(\"install [%s] [%s] failed. \", installRpm, host.Name))\n\t\t\t\tlogs.Error(\"install [%s] [%s] failed. Error:[%s]\", installRpm, host.Name, stderr.String())\n\t\t\t\tgoto end\n\t\t\t}\n\t\t}\n\t}\n\n\tlogs.Info(ob.ServName + \" install passed\")\n\nend:\n\tc.Data[\"json\"] = c.GenRetJSON()\n\tc.ServeJSON()\n}", "func Deploy(name string, dir string, port string) {\n\tctx := context.Background()\n\tcli, err := client.NewEnvClient()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\timageName := name\n\tcontainerConfig := &container.Config{\n\t\tImage: imageName,\n\t\tExposedPorts: nat.PortSet{\n\t\t\t\"3000/tcp\": struct{}{},\n\t\t},\n\t}\n\thostConfig := &container.HostConfig{\n\t\tPortBindings: nat.PortMap{\n\t\t\t\"3000/tcp\": []nat.PortBinding{\n\t\t\t\t{\n\t\t\t\t\tHostIP: \"0.0.0.0\",\n\t\t\t\t\tHostPort: port,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tresp, err := cli.ContainerCreate(ctx, containerConfig, hostConfig, nil, \"\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif err := cli.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{}); err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(resp.ID)\n}", "func (p *Project) Deploy(env string, user string) (io.Reader, error) {\n\tscript := workdir.ProjectDir(p.Name) + \"/.deploy/bin/deploy\"\n\tcmd := unbuffered.Command(script)\n\tcmd.Dir = workdir.ProjectDir(p.Name)\n\tcmd.Env = os.Environ()\n\tcmd.Env = append(cmd.Env, \"DEPLOY_ENV=\"+env)\n\tcmd.Env = append(cmd.Env, \"DEPLOY_USER=\"+user)\n\n\terr := workdir.RotateLogs(p.Name)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to rotate log files\")\n\t}\n\n\t// write to log file\n\tf, err := os.OpenFile(workdir.LogFile(p.Name, 0), os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to open log file\")\n\t}\n\tcallback := func() {\n\t\tf.Close()\n\t\tdatadog.Deployed(p.Name, user, env)\n\t\thook.Deployed(p.Name, user, env)\n\t}\n\tr, err := stdoutStderrReader(cmd, callback)\n\tif err != nil {\n\t\tf.Close()\n\t\treturn nil, err\n\t}\n\n\tr2 := io.TeeReader(r, f)\n\treturn r2, nil\n}", "func (app *application) publishCmd(p *project, cmd *publishApiCommand) (*response, error) {\n\n\tresp := newResponse(\"publish\")\n\n\tchannel := cmd.Channel\n\tdata := cmd.Data\n\tif channel == \"\" || len(data) == 0 {\n\t\tlogger.ERROR.Println(\"channel and data required\")\n\t\treturn nil, ErrInvalidApiMessage\n\t}\n\n\tchOpts, err := app.channelOpts(p.Name, channel)\n\tif err != nil {\n\t\tresp.Err(err)\n\t\treturn resp, nil\n\t}\n\n\terr = app.pubClient(p, channel, chOpts, data, nil)\n\tif err != nil {\n\t\tlogger.ERROR.Println(err)\n\t\tresp.Err(ErrInternalServerError)\n\t}\n\n\treturn resp, nil\n}", "func (a *ContrailAnsibleDeployer) Deploy() error {\n\tswitch a.action {\n\tcase CreateAction:\n\t\treturn a.handleCreate()\n\tcase UpdateAction:\n\t\treturn a.handleUpdate()\n\tcase DeleteAction:\n\t\treturn a.handleDelete()\n\t}\n\treturn nil\n}", "func RunCmd(stdinBytes []byte, commandString string, args ...string) ([]byte, []byte) {\n\n\t// get message printer\n\tmsgPrinter := i18n.GetMessagePrinter()\n\n\t// For debug, build the full cmd string\n\tcmdStr := commandString\n\tfor _, a := range args {\n\t\tcmdStr += \" \" + a\n\t}\n\tif stdinBytes != nil {\n\t\tcmdStr += \" < stdin\"\n\t}\n\tVerbose(msgPrinter.Sprintf(\"running: %v\", cmdStr))\n\n\t// Create the command object with its args\n\tcmd := exec.Command(commandString, args...)\n\tif cmd == nil {\n\t\tFatal(EXEC_CMD_ERROR, msgPrinter.Sprintf(\"did not get a command object\"))\n\t}\n\n\tvar stdin io.WriteCloser\n\t//var jInbytes []byte\n\tvar err error\n\tif stdinBytes != nil {\n\t\t// Create the std in pipe\n\t\tstdin, err = cmd.StdinPipe()\n\t\tif err != nil {\n\t\t\tFatal(EXEC_CMD_ERROR, msgPrinter.Sprintf(\"Could not get Stdin pipe, error: %v\", err))\n\t\t}\n\t\t// Read the input file\n\t\t//jInbytes, err = ioutil.ReadFile(stdinFilename)\n\t\t//if err != nil { Fatal(EXEC_CMD_ERROR,\"Unable to read \" + stdinFilename + \" file, error: %v\", err) }\n\t}\n\t// Create the stdout pipe to hold the output from the command\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\tFatal(EXEC_CMD_ERROR, msgPrinter.Sprintf(\"could not retrieve output from command, error: %v\", err))\n\t}\n\t// Create the stderr pipe to hold the errors from the command\n\tstderr, err := cmd.StderrPipe()\n\tif err != nil {\n\t\tFatal(EXEC_CMD_ERROR, msgPrinter.Sprintf(\"could not retrieve stderr from command, error: %v\", err))\n\t}\n\n\t// Start the command, which will block for input from stdin if the cmd reads from it\n\terr = cmd.Start()\n\tif err != nil {\n\t\tFatal(EXEC_CMD_ERROR, msgPrinter.Sprintf(\"Unable to start command, error: %v\", err))\n\t}\n\n\tif stdinBytes != nil {\n\t\t// Send in the std in bytes\n\t\t_, err = stdin.Write(stdinBytes)\n\t\tif err != nil {\n\t\t\tFatal(EXEC_CMD_ERROR, msgPrinter.Sprintf(\"Unable to write to stdin of command, error: %v\", err))\n\t\t}\n\t\t// Close std in so that the command will begin to execute\n\t\terr = stdin.Close()\n\t\tif err != nil {\n\t\t\tFatal(EXEC_CMD_ERROR, msgPrinter.Sprintf(\"Unable to close stdin, error: %v\", err))\n\t\t}\n\t}\n\n\terr = error(nil)\n\t// Read the output from stdout and stderr into byte arrays\n\t// stdoutBytes, err := readPipe(stdout)\n\tstdoutBytes, err := ioutil.ReadAll(stdout)\n\tif err != nil {\n\t\tFatal(EXEC_CMD_ERROR, msgPrinter.Sprintf(\"could not read stdout, error: %v\", err))\n\t}\n\t// stderrBytes, err := readPipe(stderr)\n\tstderrBytes, err := ioutil.ReadAll(stderr)\n\tif err != nil {\n\t\tFatal(EXEC_CMD_ERROR, msgPrinter.Sprintf(\"could not read stderr, error: %v\", err))\n\t}\n\n\t// Now block waiting for the command to complete\n\terr = cmd.Wait()\n\tif err != nil {\n\t\tFatal(EXEC_CMD_ERROR, msgPrinter.Sprintf(\"command failed: %v, stderr: %s\", err, string(stderrBytes)))\n\t}\n\n\treturn stdoutBytes, stderrBytes\n}", "func (cmd *UpdateCompanyBranchHyCompanybranchCommand) Run(c *client.Client, args []string) error {\n\tvar path string\n\tif len(args) > 0 {\n\t\tpath = args[0]\n\t} else {\n\t\tpath = fmt.Sprintf(\"/api/company/branch/%v\", cmd.ID)\n\t}\n\tvar payload client.UpdateCompanyBranchHyCompanybranchPayload\n\tif cmd.Payload != \"\" {\n\t\terr := json.Unmarshal([]byte(cmd.Payload), &payload)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to deserialize payload: %s\", err)\n\t\t}\n\t}\n\tlogger := goa.NewLogger(log.New(os.Stderr, \"\", log.LstdFlags))\n\tctx := goa.WithLogger(context.Background(), logger)\n\tresp, err := c.UpdateCompanyBranchHyCompanybranch(ctx, path, &payload, cmd.ContentType)\n\tif err != nil {\n\t\tgoa.LogError(ctx, \"failed\", \"err\", err)\n\t\treturn err\n\t}\n\n\tgoaclient.HandleResponse(c.Client, resp, cmd.PrettyPrint)\n\treturn nil\n}", "func (d *Deployment) Execute(ctx context.Context, opts Options, preview bool) (*Plan, result.Result) {\n\tdeploymentExec := &deploymentExecutor{deployment: d}\n\treturn deploymentExec.Execute(ctx, opts, preview)\n}" ]
[ "0.6999749", "0.6883601", "0.66720974", "0.647015", "0.6439493", "0.6367923", "0.62261665", "0.6170908", "0.6144135", "0.6070954", "0.60189515", "0.60038346", "0.59228235", "0.583011", "0.5787182", "0.57143575", "0.57111585", "0.5704478", "0.57001704", "0.5697601", "0.5682563", "0.5663093", "0.56467146", "0.56346357", "0.5630198", "0.5616313", "0.5607725", "0.5523903", "0.5496127", "0.54808545", "0.5463205", "0.54600763", "0.54431736", "0.5434717", "0.54328823", "0.542633", "0.5408512", "0.54078615", "0.53970206", "0.5364314", "0.53617996", "0.53614527", "0.5358899", "0.53554374", "0.5343512", "0.53235495", "0.5317671", "0.5316754", "0.5310867", "0.5306025", "0.5303401", "0.5282262", "0.5275862", "0.52659434", "0.5262514", "0.5250146", "0.5231749", "0.52308756", "0.52243155", "0.51997423", "0.51838666", "0.5180295", "0.51579833", "0.51569486", "0.51558083", "0.5150969", "0.51467526", "0.5143551", "0.5138049", "0.5135865", "0.51297116", "0.51148885", "0.51137584", "0.5112746", "0.5111113", "0.5103755", "0.51017606", "0.5100898", "0.50926346", "0.50874466", "0.5066679", "0.50658566", "0.5064631", "0.506414", "0.5054825", "0.50533354", "0.5041696", "0.503582", "0.5034785", "0.50290304", "0.5023287", "0.50172764", "0.5016355", "0.50160736", "0.5002713", "0.5000862", "0.4991674", "0.49902242", "0.49900937", "0.49899662" ]
0.59596425
12
this function is used to read a file parameters: name (a string containing the path to a file) returns: []byte (an array of bytes containing the contents of the file)
func readJobFile(name string) []byte { file, err := os.Open(name) if err != nil { log.Fatal(err) } bytes, err := ioutil.ReadAll(file) defer file.Close() return bytes }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func readJobFile(name string) []byte {\n\tfile, err := os.Open(name)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tbytes, _ := ioutil.ReadAll(file)\n\tdefer file.Close()\n\treturn bytes\n}", "func ReadFromFile(name string) []byte {\n\tdata, err := ioutil.ReadFile(name)\n\tif err !=nil{\n\t\tpanic(0)\n\t}\n\treturn data\n}", "func (realFS) ReadFile(name string) ([]byte, error) { return ioutil.ReadFile(name) }", "func FileToBytes(path, name string) ([]byte, error) {\n\tfilename := filepath.Join(path, name)\n\tfile, err := os.Open(filename)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer file.Close()\n\n\tstats, err := file.Stat()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdata := make([]byte, stats.Size())\n\n\t_, err = file.Read(data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn data, nil\n}", "func ReadFile(fsys FS, name string) ([]byte, error) {\n\tif fsys, ok := fsys.(ReadFileFS); ok {\n\t\treturn fsys.ReadFile(name)\n\t}\n\n\tfile, err := fsys.Open(name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer file.Close()\n\n\tvar size int\n\tif info, err := file.Stat(); err == nil {\n\t\tsize64 := info.Size()\n\t\tif int64(int(size64)) == size64 {\n\t\t\tsize = int(size64)\n\t\t}\n\t}\n\n\tdata := make([]byte, 0, size+1)\n\tfor {\n\t\tif len(data) >= cap(data) {\n\t\t\td := append(data[:cap(data)], 0)\n\t\t\tdata = d[:len(data)]\n\t\t}\n\t\tn, err := file.Read(data[len(data):cap(data)])\n\t\tdata = data[:len(data)+n]\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\terr = nil\n\t\t\t}\n\t\t\treturn data, err\n\t\t}\n\t}\n}", "func readFileToByteArray(p string) []byte {\n\tb, err := ioutil.ReadFile(p)\n\tif err != nil {\n\t\tlog.Fatalf(\"Error reading file: #%v \", err)\n\t}\n\treturn b\n}", "func readFileToByteArray(p string) []byte {\n\tb, err := ioutil.ReadFile(p)\n\tif err != nil {\n\t\tlog.Fatalf(\"Error reading file: #%v \", err)\n\t}\n\treturn b\n}", "func BytesFromFile(fileName string) ([]byte, error) {\n\t//Opens file\n\topenedFile, err := os.Open(fileName)\n\tif err != nil {\n\t\treturn make([]byte, 0), err\n\t}\n\n\tfi, err := openedFile.Stat()\n\n\tif err != nil {\n\t\treturn make([]byte, 0), err\n\t}\n\n\t//Reads from file\n\tbytesData := make([]byte, fi.Size())\n\topenedFile.Read(bytesData)\n\topenedFile.Close()\n\n\treturn bytesData, nil\n}", "func readFile(fileName string) []byte {\n\tfileByte, err := assembly.Asset(fileName)\n\tcheckErr(err, funcName(), \"Error reading the file\", fileName)\n\treturn fileByte\n}", "func ReadFile(hfs http.FileSystem, name string) ([]byte, error) {\n\tfh, err := hfs.Open(name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar buf bytes.Buffer\n\t_, err = io.Copy(&buf, fh)\n\tfh.Close()\n\treturn buf.Bytes(), err\n}", "func ReadFileAsByte(path string) ([]byte, error) {\n\texists, err := PathExists(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !exists {\n\t\treturn nil, fmt.Errorf(\"path not exist %v\", path)\n\t}\n\tdata, err := os.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"path: %s read err: %v\", path, err)\n\t}\n\n\treturn data, nil\n}", "func loadFileBytes(filename string) ([]byte, error) {\n\tfile := filepath.Join(\"testdata\", filename)\n\tfd, err := os.Open(file)\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\tfileStat, err := fd.Stat()\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\tfileContents := make([]byte, fileStat.Size())\n\t_, err = fd.Read(fileContents)\n\n\treturn fileContents, err\n}", "func readToByteArray() []byte{\n content, err := ioutil.ReadFile(\"testdata.txt\")\n if err != nil {\n log.Fatal(err)\n }\n return content\n}", "func ReadFile(name string) []byte {\n\tbuf, err := ioutil.ReadFile(name)\n\tAbortIf(err)\n\treturn buf\n}", "func readFile(filepath string) ([]byte, string, int64, error){\n var(\n bytes []byte\n err error\n fileType string = \"\"\n size int64\n )\n\n file, err = os.Open(filepath)\n if err != nil {\n return bytes, size, fileType, err\n }\n defer file.Close()\n\n fileInfo, _ := file.Stat()\n size = fileInfo.Size()\n buffer := make([]byte, size)\n file.Read(buffer)\n bytes := bytes.NewReader(buffer)\n fileType = http.DetectContentType(buffer)\n return bytes, size, fileType, err\n}", "func getContentOfFile(fileName string) []byte {\n\tcontent, err := ioutil.ReadFile(fileName)\n\tif err != nil {\n\t\treturn []byte{}\n\t}\n\n\treturn content\n}", "func ReadFileAsByte(path string) ([]byte, error) {\n\tbyteArr, err := ioutil.ReadFile(path)\n\treturn byteArr, err\n}", "func ReadConfigBytes(filename string) (string, []byte, error) {\n\t// default\n\tif filename == \"\" {\n\t\tpathname, b, err := ReadDefaultConfigBytes(\".sshw\", \".sshw.yml\", \".sshw.yaml\")\n\t\tif err != nil {\n\t\t\treturn \"\", nil, err\n\t\t}\n\t\treturn pathname, b, nil\n\t}\n\t// as url, if filename is /absolute/filename, err is nil, so need check Host\n\tif uri, err := url.ParseRequestURI(filename); err == nil && uri.Host != \"\" {\n\t\tif response, err := http.Get(filename); err != nil {\n\t\t\treturn \"\", nil, err\n\t\t} else {\n\t\t\tdefer func() {\n\t\t\t\t_ = response.Body.Close()\n\t\t\t}()\n\t\t\tif b, err := ioutil.ReadAll(response.Body); err != nil {\n\t\t\t\treturn \"\", nil, err\n\t\t\t} else {\n\t\t\t\treturn filename, b, nil\n\t\t\t}\n\t\t}\n\t}\n\t// specify path\n\tpathname := AbsPath(filename)\n\tb, err := ioutil.ReadFile(pathname)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\treturn pathname, b, nil\n}", "func readBytesFromFile(reader io.Reader) ([]byte, error) {\n\tconfigBytes, err := ioutil.ReadAll(reader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn configBytes, nil\n}", "func (m MockFS) ReadFile(name string) ([]byte, error) {\n\tfile, ok := m.Files[name]\n\tif !ok {\n\t\treturn []byte{}, errors.New(\"file not found\")\n\t}\n\n\treturn file.Content(), nil\n}", "func FiletoBytes(fileName string) ([]byte, error) {\n\tjsonFile, err := os.Open(fileName)\n\tdefer jsonFile.Close()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error opening file: %v\", err)\t\n\t}\n\t//fmt.Printf(\"Successfully Opened %s\\n\", fileName)\t// TODO Replace with log later\n\tbyteData, err := ioutil.ReadAll(jsonFile)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading from file %s: %v\", fileName, err)\n\t}\n\treturn byteData, nil\n}", "func (file *File) read() ([]byte, error) {\n\treturn os.ReadFile(file.Path())\n}", "func SlurpAsBytes(filename string) ([]byte, error) {\n\t// #nosec G304\n\tb, err := os.ReadFile(filename)\n\tif err != nil {\n\t\treturn globals.EmptyBytes, errors.Wrapf(err, \"error reading from file %s\", filename)\n\t}\n\treturn b, nil\n}", "func readfile(filename string) (data string, err error) {\n\tvar abspath string\n\tabspath, err = filepath.Abs(filename)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar bytes []byte\n\tbytes, err = ioutil.ReadFile(abspath)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tdata = string(bytes)\n\treturn\n}", "func loadFileData(path string) ([]byte, error) {\n\n\t//Open File\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn nil, err\n\t}\n\tdefer file.Close()\n\n\tfileInfo, err := file.Stat()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn nil, err\n\t}\n\n\tbyteSlice := make([]byte, fileInfo.Size())\n\tbytesRead, err := file.Read(byteSlice)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn nil, err\n\t}\n\n\tlog.Printf(\"Number of bytes read: %d\\n\", bytesRead)\n\tlog.Printf(\"Data read: %s\\n\", byteSlice)\n\n\treturn byteSlice, nil\n}", "func FileRead(f *os.File, b []byte) (int, error)", "func FileToBytes(path string) []byte {\n\tdata, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"path\": path,\n\t\t}).Fatal(err.Error())\n\t}\n\treturn data\n}", "func ReadFile(path string, doGzip bool) (string, error){\n body, err := ReadFileByte(path, doGzip)\n return string(body), err\n}", "func ReadFile(path string) []byte {\n\tfile, err := physfs.Open(path)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tlength, err := file.Length()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tbuffer := make([]byte, length)\n\tfile.Read(buffer)\n\n\treturn buffer\n}", "func getFileContent(fileArg string) (targetName string, b []byte, err error) {\n\tvar localFile string\n\tfiles := strings.Split(fileArg, \":\")\n\tswitch {\n\tcase len(files) < 1:\n\t\treturn \"\", nil, errors.New(\"empty `-files` parameter\")\n\tcase len(files) == 1:\n\t\tlocalFile = files[0]\n\t\ttargetName = files[0]\n\tdefault:\n\t\tlocalFile = files[0]\n\t\ttargetName = files[1]\n\t}\n\n\tb, err = ioutil.ReadFile(localFile)\n\treturn targetName, b, err\n}", "func readFile(path string) []byte {\n\tvar fileBytes []byte\n\tvar err error\n\n\tlogger := log.WithField(\"path\", path)\n\tlogger.Infof(\"Reading file bytes\")\n\n\tif !FileExists(path) {\n\t\tlogger.Fatal(\"Can't find file\")\n\t}\n\tif fileBytes, err = ioutil.ReadFile(path); err != nil {\n\t\tlogger.Fatalf(\"Error on read file: '%s'\", err)\n\t}\n\treturn fileBytes\n}", "func (gcs *gcsPhotos) read(filename string) (buf []byte, outFilename string, err error) {\n src, err := os.Open(filename)\n if err != nil {\n return\n }\n defer src.Close()\n size, err := src.Stat()\n if err != nil {\n return\n }\n buf = make([]byte, size.Size())\n _, err = src.Read(buf)\n if err != nil {\n return\n }\n outFilename = getSha(buf)\n return\n}", "func ReadFile(ctx context.Context, repo gitserver.Repo, commit api.CommitID, name string, maxBytes int64) ([]byte, error) {\n\tif Mocks.ReadFile != nil {\n\t\treturn Mocks.ReadFile(commit, name)\n\t}\n\n\tspan, ctx := opentracing.StartSpanFromContext(ctx, \"Git: ReadFile\")\n\tspan.SetTag(\"Name\", name)\n\tdefer span.Finish()\n\n\tif err := checkSpecArgSafety(string(commit)); err != nil {\n\t\treturn nil, err\n\t}\n\n\tname = util.Rel(name)\n\tb, err := readFileBytes(ctx, repo, commit, name, maxBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn b, nil\n}", "func Read(filename string) []byte {\n\tbuf, err := ioutil.ReadFile(filename)\n\tif err != nil {\n\t\tFatalf(\"must read: %s: %s\", filename, err)\n\t}\n\treturn buf\n}", "func (c *Client) ReadFile(ctx context.Context, name string) ([]byte, error) {\n\tres, err := c.fs.ReadFile(ctx, &baserpc.ReadFileRequest{Name: name})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif res.Error != nil {\n\t\treturn nil, decodeErr(res.Error)\n\t}\n\treturn res.Content, nil\n}", "func readFile(fileName string) ([]string, error) {\n\tvar err error\n\tif fileExists(fileName) {\n\t\tcontent, err := ioutil.ReadFile(fileName)\n\t\tCheckerr(err)\n\t\tdata := strings.Split(toUtf8(content), \"\\r\\n\")\n\t\treturn data, err\n\n\t} else {\n\t\treturn nil, err\n\t}\n}", "func (fs *Fs) ReadFile(name string) ([]byte, error) {\n\treturn os.ReadFile(filepath.Clean(name))\n}", "func readFile(path string) ([]byte, error) {\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer file.Close()\n\treturn ioutil.ReadAll(file)\n}", "func readFile(path string) ([]byte, error) {\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer file.Close()\n\treturn ioutil.ReadAll(file)\n}", "func (f FileManager) Read(path string) ([]byte, error) {\n\tb, err := ioutil.ReadFile(path)\n\tif err != nil && !os.IsNotExist(err) {\n\t\treturn nil, err\n\t}\n\n\treturn b, err\n}", "func (f *attachEmbedFS) ReadFile(name string) ([]byte, error) {\n\treturn f.EmbedFS.ReadFile(f.path(name))\n}", "func ReadAsset(name string) ([]byte, error) {\n\n\t// Get asset from map and verify\n\tasset, ok := assets[name]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"asset does not exist: %s\", name)\n\t}\n\n\t// Decode base64\n\tdecoded, err := base64.StdEncoding.DecodeString(asset.Data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Decompress if required\n\tif asset.Compressed {\n\t\treader, err := gzip.NewReader(bytes.NewReader(decoded))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn ioutil.ReadAll(reader)\n\t}\n\treturn decoded, nil\n}", "func ReadBytes(path string) ([]byte, error) {\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer f.Close()\n\treturn ioutil.ReadAll(f)\n}", "func readFile(name string) *os.File {\n\tfile, err := os.Open(name)\n\tif err != nil {\n\t\tlog.Fatalln(\"Couldn't open the csv file\", err)\n\t}\n\treturn file\n}", "func loadFile(path string) ([]byte, error) {\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer f.Close()\n\n\tfi, err := f.Stat()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tb := make([]byte, fi.Size())\n\tf.Read(b)\n\treturn b, nil\n}", "func slurpFile(path string) ([]byte, error) {\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer f.Close()\n\tcontent, err := ioutil.ReadAll(f)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn content, err\n}", "func ReadFile(file string) ([]byte, error) {\n if _, err := os.Stat(file); err == nil {\n return ioutil.ReadFile(file)\n } else {\n return ReadURL(file)\n }\n}", "func (fsOnDisk) ReadFile(name string) ([]byte, error) {\n\tcontent, err := os.ReadFile(name)\n\treturn content, errors.Wrap(err)\n}", "func ReadBytes(ctx context.Context, filename string) ([]byte, error) {\n\tif strings.HasPrefix(filename, \"gs://\") {\n\t\treturn readGCSObject(ctx, filename)\n\t}\n\treturn ioutil.ReadFile(filename)\n}", "func readFile(fileName string) (string, error) {\n\tfile, err := os.Open(fileName)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer file.Close()\n\tb, err := ioutil.ReadAll(file)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(b), nil\n}", "func getContent(name string) ([]byte, error) {\n\treturn ioutil.ReadFile(\"content/\" + name)\n}", "func (self *FCSFile) readBytes(f *os.File, byteSize int64, offset int64) string {\n\n\treadBytes := make([]byte, byteSize)\n\tf.ReadAt(readBytes, offset)\n\tbyteValue := strings.TrimSpace(string(readBytes)) //Bytes into string conversion\n\n\treturn byteValue\n\n}", "func getSequence(fileName string) ([]byte, error) {\n\treturn ioutil.ReadFile(fileName)\n}", "func readFile (path string) string {\n\tbytesStrFile, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\tfmt.Print(err)\n\t}\n\treturn string(bytesStrFile)\n}", "func getFileDataFromRarArchive(fileName string) ([]byte, error) {\n\tvar fileData []byte\n\tarchivePassword := virtualFileSystemPassword\n\tif virtualFileSystemEncryptionKey != \"\" {\n\t\tarchivePassword = getUnscrambledPassword(archivePassword, virtualFileSystemEncryptionKey)\n\t}\n\tarchiveReadCloser, err := rardecode.OpenReader(virtualFileSystemArchive, archivePassword)\n\tif err != nil {\n\t\terr = errors.New(fmt.Sprintf(\"Could not open '%s': %s\", virtualFileSystemArchive, err.Error()))\n\t\treturn fileData, err\n\t}\n\tdefer archiveReadCloser.Close()\n\tfor {\n\t\tfileHeader, err := archiveReadCloser.Next()\n\t\tif err == io.EOF {\n\t\t\t// If EOF then we are done reading the archive.\n\t\t\tif fileData == nil {\n\t\t\t\terr = errors.New(fmt.Sprintf(\"Could not find file '%s' in archive '%s': %s\", fileName, virtualFileSystemArchive, err.Error()))\n\t\t\t}\n\t\t\treturn fileData, err\n\t\t}\n\t\tif err != nil {\n\t\t\terr = errors.New(fmt.Sprintf(\"Failed while scanning archive '%s': %s\", virtualFileSystemArchive, err.Error()))\n\t\t\treturn fileData, err\n\t\t}\n\t\tif fileHeader.Name == fileName {\n\t\t\tfileData, err = ioutil.ReadAll(archiveReadCloser)\n\t\t\tif err != nil {\n\t\t\t\terr = errors.New(fmt.Sprintf(\"Could not read data from the file '%s': %s\", fileName, err.Error()))\n\t\t\t\treturn fileData, err\n\t\t\t}\n\t\t\treturn fileData, err\n\t\t}\n\t}\n\treturn fileData, err\n}", "func readFile(file string) ([]byte, error) {\n\tb, err := ioutil.ReadFile(file)\n\tif err != nil {\n\t\treturn []byte{}, fmt.Errorf(\"Cannot read file %v, %v\", file, err)\n\t}\n\treturn b, nil\n}", "func readFile(fs http.FileSystem, path string) ([]byte, error) {\n\tf, err := fs.Open(path)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"opening file %s\", path)\n\t}\n\tdefer f.Close()\n\tb, err := ioutil.ReadAll(f)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"reading file content %s\", path)\n\t}\n\treturn b, nil\n}", "func readFile(path string) ([]byte, error) {\n\tp, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn p, nil\n}", "func getFile(fileName string) (bytes []byte, filetype string) {\n\tfile, _ := os.Open(fileName)\n\tdefer file.Close()\n\n\tfileInfo, _ := file.Stat()\n\tsize := fileInfo.Size()\n\tbytes = make([]byte, size)\n\n\tbuffer := bufio.NewReader(file)\n\tbuffer.Read(bytes)\n\n\tfiletype = http.DetectContentType(bytes)\n\treturn\n}", "func (f FileUtilImpl) Read(filename string) ([]byte, error) {\n\treturn ioutil.ReadFile(filename)\n}", "func fileReader(f *string) []byte {\n\tdata, err := ioutil.ReadFile(*f)\n\terrMsgHandler(fmt.Sprintf(\"Failed to read file: %s\\n\", *f), err)\n\treturn data\n}", "func readConfFile(filename []string ) (data string, err error) {\n var buffer bytes.Buffer\n for _, cfile := range filename {\n data, err := ioutil.ReadFile(cfile); if err != nil {\n return \"\", err\n }\n buffer.Write(data)\n }\n return buffer.String(), nil\n}", "func readFile(f string) []byte {\n\tfile, err := ioutil.ReadFile(f)\n\tif err != nil {\n\t\thandleError(err)\n\t}\n\treturn file\n}", "func readFromFileFile(fileName string) (string, error) {\n\n\t// try opening the file\n\tf, err := os.OpenFile(fileName, os.O_RDONLY, os.ModePerm)\n\tif err != nil {\n\t\tlog.Printf(\"Error by opening %s: %v\", fileName, err)\n\t\treturn \"\", err\n\t}\n\tdefer f.Close()\n\n\t// read from file\n\tbuf := make([]byte, maxReadSize)\n\t_, err = f.Read(buf)\n\tif err != nil {\n\t\tlog.Printf(\"Error by reading from %s: %v\", fileName, err)\n\t\treturn \"\", err\n\t}\n\n\treturn strings.TrimSpace(fmt.Sprintf(\"%s\", buf)), nil\n}", "func FileReadAll(path string) ([]byte, error) {\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer f.Close()\n\tc, err := ioutil.ReadAll(f)\n\tif err != nil && err != io.EOF {\n\t\treturn nil, err\n\t}\n\treturn c, nil\n}", "func (fs *FileSend) readFile() ([]byte, error) {\n\n\t// Open our xmlFile\n\tfilePath := filepath.Join(fs.workingDir, filepath.Clean(fs.file))\n\txmlFile, err := os.Open(filePath)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"Could not open file \"+filePath)\n\t}\n\n\tlevel.Debug(fs.logger).Log(\"msg\", \"Successfully Opened \"+fs.file)\n\tdefer xmlFile.Close()\n\n\t// read our opened xmlFile as a byte array.\n\tbyteValue, err := ioutil.ReadAll(xmlFile)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"Could not read file \"+filePath)\n\t}\n\treturn byteValue, nil\n}", "func ReadBytes(filePath string) (data []byte, err error) {\n\tdata, err = ioutil.ReadFile(filePath)\n\treturn\n}", "func processFile(filepath string) []byte {\n\t// read file\n\tjsonFile, err := os.Open(filepath)\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tbyteVal, _ := ioutil.ReadAll(jsonFile)\n\n\tdefer jsonFile.Close()\n\n\treturn byteVal\n}", "func ReadFile(path string) ([]byte, error) {\n\tf, err := FS.OpenFile(CTX, path, os.O_RDONLY, 0644)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbuf := bytes.NewBuffer(make([]byte, 0, bytes.MinRead))\n\n\t// If the buffer overflows, we will get bytes.ErrTooLarge.\n\t// Return that as an error. Any other panic remains.\n\tdefer func() {\n\t\te := recover()\n\t\tif e == nil {\n\t\t\treturn\n\t\t}\n\t\tif panicErr, ok := e.(error); ok && panicErr == bytes.ErrTooLarge {\n\t\t\terr = panicErr\n\t\t} else {\n\t\t\tpanic(e)\n\t\t}\n\t}()\n\t_, err = buf.ReadFrom(f)\n\treturn buf.Bytes(), err\n}", "func ReadFile(path string) ([]byte, error) {\n\tf, err := FS.OpenFile(CTX, path, os.O_RDONLY, 0644)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbuf := bytes.NewBuffer(make([]byte, 0, bytes.MinRead))\n\n\t// If the buffer overflows, we will get bytes.ErrTooLarge.\n\t// Return that as an error. Any other panic remains.\n\tdefer func() {\n\t\te := recover()\n\t\tif e == nil {\n\t\t\treturn\n\t\t}\n\t\tif panicErr, ok := e.(error); ok && panicErr == bytes.ErrTooLarge {\n\t\t\terr = panicErr\n\t\t} else {\n\t\t\tpanic(e)\n\t\t}\n\t}()\n\t_, err = buf.ReadFrom(f)\n\treturn buf.Bytes(), err\n}", "func ReadFile(path string) ([]byte, error) {\n\tf, err := FS.OpenFile(CTX, path, os.O_RDONLY, 0644)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbuf := bytes.NewBuffer(make([]byte, 0, bytes.MinRead))\n\n\t// If the buffer overflows, we will get bytes.ErrTooLarge.\n\t// Return that as an error. Any other panic remains.\n\tdefer func() {\n\t\te := recover()\n\t\tif e == nil {\n\t\t\treturn\n\t\t}\n\t\tif panicErr, ok := e.(error); ok && panicErr == bytes.ErrTooLarge {\n\t\t\terr = panicErr\n\t\t} else {\n\t\t\tpanic(e)\n\t\t}\n\t}()\n\t_, err = buf.ReadFrom(f)\n\treturn buf.Bytes(), err\n}", "func ReadFile(path string) ([]byte, error) {\n\tf, err := FS.OpenFile(CTX, path, os.O_RDONLY, 0644)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbuf := bytes.NewBuffer(make([]byte, 0, bytes.MinRead))\n\n\t// If the buffer overflows, we will get bytes.ErrTooLarge.\n\t// Return that as an error. Any other panic remains.\n\tdefer func() {\n\t\te := recover()\n\t\tif e == nil {\n\t\t\treturn\n\t\t}\n\t\tif panicErr, ok := e.(error); ok && panicErr == bytes.ErrTooLarge {\n\t\t\terr = panicErr\n\t\t} else {\n\t\t\tpanic(e)\n\t\t}\n\t}()\n\t_, err = buf.ReadFrom(f)\n\treturn buf.Bytes(), err\n}", "func ReadFile(path string) ([]byte, error) {\n\tf, err := FS.OpenFile(CTX, path, os.O_RDONLY, 0644)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbuf := bytes.NewBuffer(make([]byte, 0, bytes.MinRead))\n\n\t// If the buffer overflows, we will get bytes.ErrTooLarge.\n\t// Return that as an error. Any other panic remains.\n\tdefer func() {\n\t\te := recover()\n\t\tif e == nil {\n\t\t\treturn\n\t\t}\n\t\tif panicErr, ok := e.(error); ok && panicErr == bytes.ErrTooLarge {\n\t\t\terr = panicErr\n\t\t} else {\n\t\t\tpanic(e)\n\t\t}\n\t}()\n\t_, err = buf.ReadFrom(f)\n\treturn buf.Bytes(), err\n}", "func ReadFileByte(path string, doGzip bool) ([]byte, error){\n\tassetsCache.ml.RLock()\n\tif data, ok := assetsCache.cache[path]; ok {\n\t\tassetsCache.ml.RUnlock()\n\t\treturn []byte(data), nil\n\t}\n\tassetsCache.ml.RUnlock()\n\n reader, err := FindFile(path, doGzip)\n if err != nil {\n return nil, err\n }\n\n if closer, ok := reader.(io.Closer); ok {\n defer closer.Close()\n }\n\n var bu bytes.Buffer\n\n _, err = io.Copy(&bu, reader); \n if err != nil && err != io.EOF {\n return nil, fmt.Errorf(\"File %q failed to be read: %+q\", path, err)\n }\n\n\tassetsCache.ml.Lock()\n\tassetsCache.cache[path] = string(bu.Bytes())\n\tassetsCache.ml.Unlock()\n\n return bu.Bytes(), nil\n}", "func readInputFile(inputFile string) ([]byte, error) {\n\t// ensure the file exists on the filesystem\n\tif _, err := os.Stat(inputFile); os.IsNotExist(err) {\n\t\treturn nil, err\n\t}\n\n\treturn ioutil.ReadFile(inputFile)\n}", "func helperLoadBytes(name string) ([]byte, error) {\n\tpath := filepath.Join(\"testdata\", name) // relative path\n\tbytes, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bytes, nil\n}", "func readFile(file *zip.File) ([]byte, error) {\n\trc, err := file.Open()\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\tdefer rc.Close()\n\n\tbuff := bytes.NewBuffer(nil)\n\t_, err = io.Copy(buff, rc)\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\treturn buff.Bytes(), nil\n}", "func readFile(filename string) string {\n\tfile, err := os.Open(filename)\n\tif err != nil {\n\t\tfmt.Printf(\"\\nError opening file: %v\", filename)\n\t\tos.Exit(0)\n\t}\n\n\tfileBytes, err := ioutil.ReadAll(file)\n\tif err != nil {\n\t\tfmt.Printf(\"\\nError reading file: %v\", filename)\n\t\tos.Exit(0)\n\t}\n\n\treturn string(fileBytes)\n}", "func ReadBinaryFromFile(file string) []byte {\n\tkey, err := ioutil.ReadFile(file)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Failed to load %q from folder: %v\", file, err))\n\t}\n\treturn key\n}", "func (f File) Bytes() []byte {\n\tb, err := ioutil.ReadFile(f.Path)\n\tmust(f.Case.T, err)\n\treturn b\n}", "func fetchFile(path string) ([]byte, error) {\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer file.Close()\n\n\tbytes, err := ioutil.ReadAll(file)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn bytes, nil\n}", "func readFile(t *testing.T, filename string) []byte {\n\tif b, e := ioutil.ReadFile(filename); e == nil {\n\t\treturn b\n\t} else {\n\t\tt.Fatalf(\"Failed to read file %q: %v\", filename, e)\n\t\treturn []byte(\"\")\n\t}\n}", "func (fs *Filesystem) ReadFile(filename string) ([]byte, error) {\n\tf, err := fs.Open(filename)\n\tif err != nil {\n\t\treturn []byte(\"\"), err\n\t}\n\tff := f.(*File)\n\tff.RLock()\n\tdefer ff.RUnlock()\n\tc := make([]byte, len(ff.content))\n\tcopy(c, ff.content)\n\treturn c, nil\n}", "func (s *AzureBlobStorage) ReadFile(ctx context.Context, name string) ([]byte, error) {\n\tclient := s.containerClient.NewBlockBlobClient(s.withPrefix(name))\n\tresp, err := client.DownloadStream(ctx, &blob.DownloadStreamOptions{\n\t\tCPKInfo: s.cpkInfo,\n\t})\n\tif err != nil {\n\t\treturn nil, errors.Annotatef(err, \"Failed to download azure blob file, file info: bucket(container)='%s', key='%s'\", s.options.Bucket, s.withPrefix(name))\n\t}\n\tbody := resp.NewRetryReader(ctx, &blob.RetryReaderOptions{\n\t\tMaxRetries: azblobRetryTimes,\n\t})\n\tdata, err := io.ReadAll(body)\n\tif err != nil {\n\t\treturn nil, errors.Annotatef(err, \"Failed to read azure blob file, file info: bucket(container)='%s', key='%s'\", s.options.Bucket, s.withPrefix(name))\n\t}\n\treturn data, body.Close()\n}", "func (fs *VolatileFileSystem) ReadFile(name string) ([]byte, error) {\n\tfile, rc := fs.vfs.FileByName(name)\n\tif rc != C.SQLITE_OK {\n\t\treturn nil, Error{\n\t\t\tCode: ErrIoErr,\n\t\t\tExtendedCode: ErrIoErrRead,\n\t\t}\n\t}\n\n\treturn file.data[:], nil\n}", "func (m *Model) ReadFile(name string) ([]byte, error) {\n\tfileData, err := os.Open(fmt.Sprintf(\"%s.%s\", name, m.FileType.Extension))\n\tdefer fileData.Close()\n\tdata, err := ioutil.ReadAll(fileData)\n\treturn data, err\n}", "func (a *Archive) ReadAll(name string) ([]byte, error) {\n\te, err := a.GetFileInfo(name)\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\trawContents := make([]byte, e.CompressedSize)\n\tif n, err := a.reader.ReadAt(rawContents, e.Offset); err != nil {\n\t\treturn []byte{}, err\n\t} else if int64(n) < e.CompressedSize {\n\t\treturn []byte{}, ErrIOMisc\n\t}\n\n\tfileContents := make([]byte, 0, e.Size)\n\tbuf := make([]byte, 10*1024)\n\treader := lz4.NewReader(bytes.NewReader(rawContents))\n\tfor n, err := reader.Read(buf); err != io.EOF; n, err = reader.Read(buf) {\n\t\tfileContents = append(fileContents, buf[:n]...)\n\t}\n\n\treturn fileContents, nil\n}", "func ReadFile(fileName string) string{\r\n\tcontent, err := ioutil.ReadFile(fileName)\r\n\r\n\t\tif err != nil {\r\n\t\t\tlog.Fatal(err)\r\n\t\t}\r\n\r\n\t\treturn string(content)\r\n}", "func getInputFileContent(path string) ([]byte, error) {\n\tdata, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn data, nil\n}", "func getFileDataFromFileSystem(fileName string) ([]byte, error) {\n\tvar fileData []byte\n\tvar err error\n\tif virtualFileSystemArchiveType == constants.VirtualFileSystemZip {\n\t\tfileData, err = getFileDataFromZipArchive(fileName)\n\t\treturn fileData, err\n\t} else if virtualFileSystemArchiveType == constants.VirtualFileSystemRar {\n\t\tfileData, err = getFileDataFromRarArchive(fileName)\n\t\treturn fileData, err\n\t}\n\tfileData, err = getFileDataFromLocalFileSystem(fileName)\n\tif err != nil {\n\t\terr = errors.New(fmt.Sprintf(\"Could not open the file '%s': %s\", fileName, err.Error()))\n\t}\n\treturn fileData, err\n}", "func Read(path string) ([]byte, error) {\n\tr, err := os.OpenFile(path, os.O_RDONLY, 0644)\n\tdefer r.Close()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ioutil.ReadAll(r)\n}", "func readSecretFile(fileName string) ([]byte, error) {\n\n\terr := fileExists(fileName)\n\tif err != nil {\n\t\tlog.Errorf(\"Error looking for %s\", fileName)\n\t\treturn nil, err\n\t}\n\n\t//The secrets are base64 encoded\n\tkeyEnc, err := ioutil.ReadFile(fileName)\n\tif err != nil {\n\t\tlog.Errorf(\"Could not read file %s: %s\", fileName, err)\n\t\treturn nil, err\n\t}\n\n\tkeyDecoded, err := b64.StdEncoding.DecodeString(string(keyEnc))\n\treturn keyDecoded, err\n}", "func (w WatWorkspace) Read(name string) ([]byte, error) {\n\tpath := filepath.Join(w.root, kWatDirName, name)\n\tcontents, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"ioutil.ReadFile: %v (while reading file '%s')\", err, name)\n\t}\n\treturn contents, nil\n}", "func LoadBytes(path string) []byte {\n\t// open input file\n\tfi, err := os.Open(path)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t// close fi on exit and check for its returned error\n\tdefer func() {\n\t\tif err := fi.Close(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\tdata, err := ioutil.ReadAll(fi)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn data\n}", "func GetFileContents(path, fileName string) string {\n\tpath, err := filepath.Abs(createFullPath(path, fileName))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdata, err := ioutil.ReadFile(path)\n\treturn string(data)\n}", "func ReadFileByte(filename string) ([]byte, error) {\r\n\tf, err := os.Open(filename)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\tdefer f.Close()\r\n\r\n\treturn ioutil.ReadAll(f)\r\n}", "func ReadFileAsBinary(filePath string) ([]byte, error) {\n\tfilePath = strings.Replace(filePath, \"~\", HomeDir(), 1)\n\n\tif exists, err := RegularFileExists(filePath); err != nil || exists == false {\n\t\treturn []byte{}, errors.New(\"File \" + filePath + \" does NOT exist\")\n\t}\n\n\tbyteArray, err := ioutil.ReadFile(filePath)\n\tif err != nil {\n\t\treturn []byte{}, errors.New(\"Can't read file \" + filePath + \": \" + err.Error())\n\t}\n\treturn byteArray, nil\n}", "func main() {\n file, err := os.Open(os.Args[1])\n\n fi, err := file.Stat();\n\n //each split file size\n size := fi.Size()\n b := make([]byte, size);\n _, err = file.Read(b);\n file.Close()\n\n fmt.Println(string(b))\n}", "func (c *Client) ReadBytes(ctx context.Context, name string) ([]byte, error) {\n\tbuf := &bytes.Buffer{}\n\t_, err := c.readStreamed(ctx, name, 0, 0, buf)\n\treturn buf.Bytes(), err\n}", "func ReadFile(file string) []byte {\n\tcontent, err := ioutil.ReadFile(file)\n\tcheck(err)\n\n\treturn content\n}" ]
[ "0.69813824", "0.6925253", "0.6889243", "0.6857324", "0.679577", "0.6663792", "0.6663792", "0.6564147", "0.6492016", "0.6458569", "0.6413158", "0.6352887", "0.6337797", "0.63189846", "0.6313896", "0.6284289", "0.6278029", "0.6267357", "0.62547106", "0.62303627", "0.6223603", "0.620568", "0.62010586", "0.61587936", "0.61467534", "0.6141168", "0.61162263", "0.6115247", "0.6108096", "0.6098277", "0.6086043", "0.60726166", "0.6052915", "0.6050839", "0.60448694", "0.6013617", "0.5993501", "0.5991843", "0.5991843", "0.5985265", "0.5981939", "0.5977338", "0.5972208", "0.59386295", "0.59276783", "0.59269345", "0.59169936", "0.59134555", "0.5908441", "0.5905166", "0.5900289", "0.5895913", "0.58939904", "0.5877355", "0.5872928", "0.5868769", "0.5865472", "0.5854213", "0.5845399", "0.5839012", "0.5829225", "0.5821475", "0.5802516", "0.5791734", "0.57794684", "0.57600814", "0.5752825", "0.5738104", "0.57259846", "0.57259846", "0.57259846", "0.57259846", "0.57259846", "0.57201475", "0.57192457", "0.57131726", "0.57098097", "0.56882274", "0.56860197", "0.56819314", "0.5665791", "0.5660267", "0.5657135", "0.56518996", "0.5649658", "0.5649361", "0.5639285", "0.5634018", "0.56268775", "0.5602233", "0.55993325", "0.55970263", "0.5588609", "0.5584383", "0.5580542", "0.55779195", "0.55778205", "0.5576697", "0.55555105", "0.55497444" ]
0.7253405
0
this function is used to unmarshal YAML parameters: byteArray (an array of bytes representing the contents of a file) returns: Config (a struct form of the YAML)
func unmarsharlYaml(byteArray []byte) Config { var cfg Config err := yaml.Unmarshal([]byte(byteArray), &cfg) if err != nil { log.Fatalf("error: %v", err) } return cfg }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func ReadConfigFromByteArray(configYaml []byte) *Config {\n\tc := &Config{}\n\n\terr := yaml.Unmarshal(configYaml, c)\n\tif err != nil {\n\t\tlog.Fatalf(\"Invalid configuration: %v\", err)\n\t\treturn nil\n\t}\n\n\tc.Vars.init()\n\treturn c\n}", "func unmarsharlYaml(byteArray []byte) Config {\n\tvar cfg Config\n\terr := yaml.Unmarshal([]byte(byteArray), &cfg)\n\tif err != nil {\n\t\tlog.Fatalf(\"error: %v\", err)\n\t}\n\treturn cfg\n}", "func ParseBytes(b []byte) (*Config, error) {\n\tout := new(Config)\n\terr := yaml.Unmarshal(b, out)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn out, nil\n}", "func FromBytes(byteData []byte) (Data, error) {\n\tvar data Data\n\tif err := yaml.Unmarshal(byteData, &data); err != nil {\n\t\treturn data, fmt.Errorf(\"could not unmarshal config data: %w\", err)\n\t}\n\treturn data, nil\n}", "func ParseBytes(data []byte) (Config, error) {\n\tc, err := parseConfig(data)\n\tif err != nil {\n\t\treturn Config{}, err\n\t}\n\treturn c, nil\n}", "func (c *Config) LoadConfigBytes(content []byte, v interface{}) error {\n // get config map\n resMap, err := c.LoadBytes(content)\n if err != nil {\n return err\n }\n // parse map to struct\n err = c.parseMap(resMap, v)\n if err != nil {\n return err\n }\n return nil\n}", "func (p *Parser) LoadFromBytes(buffer []byte, filetype string) error {\n\tp.Viper.SetConfigType(filetype)\n\tp.defaults()\n\tif err := p.Viper.ReadConfig(bytes.NewBuffer(buffer)); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func parseConfig(conf []byte) (Config, error) {\n\tconfig := Config{}\n\tif err := yaml.Unmarshal(conf, &config); err != nil {\n\t\treturn Config{}, err\n\t}\n\n\treturn config, nil\n}", "func NewConfigFromBytes(b []byte) (*Config, error) {\n\tresult := Config{}\n\terr := json.Unmarshal(b, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = result.validateConfig()\n\n\treturn &result, err\n}", "func ReadBytes(data []byte) (Config, error) {\n\tc := Config{}\n\te := toml.Unmarshal(data, &c)\n\tif e == nil {\n\t\treturn c, nil\n\t}\n\terr := errors.Wrap(errUnmarshalConfigContent, e)\n\tif e := json.Unmarshal(data, &c); e != nil {\n\t\treturn c, errors.Wrap(err, e)\n\t}\n\treturn c, nil\n}", "func NewConfigFromBytes(yamlBytes []byte) (*ScheduledFeedConfig, error) {\n\tconfig := Default()\n\n\terr := unmarshalStrict(yamlBytes, config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tconfig.applyEnvVars()\n\n\treturn config, nil\n}", "func (c *CloudConfig) LoadFromBytes(content []byte) *CloudConfig {\n\terr := yaml.Unmarshal(content, c)\n\tif err != nil {\n\t\tlog.Fatalf(\"%s\", err)\n\t}\n\treturn c\n}", "func LoadFromYamlBytes(raw []byte, cfg conf.Config) (types.ProjectionMapping, error) {\n\t/**\n\t\tvar aux struct {\n\t\t\tName string `yaml:\"name\"`\n\t\t\tNamespace string `yaml:\"namespace\"`\n\t\t\tData []struct {\n\t\t\t\tName string `yaml:\"name\"`\n\t\t\t\tSource struct {\n\t\t\t\t\tJSON string `yaml:\"json\"`\n\t\t\t\t\tYAML string `yaml:\"yaml\"`\n\t\t\t\t\tRaw string `yaml:\"raw\"`\n\t\t\t\t\tJSONPath string `yaml:\"jsonpath\"`\n\t\t\t\t} `yaml:\"source\"`\n\t\t\t} `yaml:\"data\"`\n\t\t}\n\t **/\n\tvar m ProjectionMapping\n\tm.c = cfg\n\terr := yaml.UnmarshalStrict(raw, &m)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// setup the crypter. if no module requested, skip setting this up (we will bail if any items asked to be\n\t// encrypted but didnt specify the module)\n\tif m.Encryption.Module != \"\" {\n\t\tif m.Encryption.CredsKeysFilePath == \"\" {\n\t\t\t// override with the value from cfg\n\t\t\tm.Encryption.CredsKeysFilePath = cfg.CredsEncryptionKeyFile()\n\t\t}\n\t\tif m.Encryption.KeysDecrypterFilePath == \"\" {\n\t\t\t// override with the value from cfg\n\t\t\tm.Encryption.KeysDecrypterFilePath = cfg.CredsKeyDecryptionKeyFile()\n\t\t}\n\t\tc, err := encryption.NewModuleFromEncryptionConfig(m.Encryption)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tm.crypter = c\n\t}\n\treturn &m, nil\n}", "func LoadBytes(bytes []byte) (Config, error) {\n\tcfg := DefaultConfig\n\tjson := jsoniter.ConfigFastest // TODO make configurable?\n\terr := json.Unmarshal(bytes, &cfg)\n\treturn cfg, err\n}", "func LoadFromYAMLBytes(raw []byte, cfg conf.Config) (ConfigProjectionManifest, error) {\n\tvar m ConfigProjectionManifest\n\terr := yaml.UnmarshalStrict(raw, &m)\n\tif err != nil {\n\t\treturn m, err\n\t}\n\tm.SetDefaults()\n\tm.c = cfg\n\terr = m.Validate()\n\tif err != nil {\n\t\treturn m, err\n\t}\n\treturn m, nil\n}", "func DeserializeConfig(fileName string) (Config, error) {\n\tb, _ := ioutil.ReadFile(fileName)\n\tvar config Config\n\tbuffer := bytes.NewBuffer(b)\n\tdec := gob.NewDecoder(buffer)\n\terr := dec.Decode(&config)\n\tif len(b) < 107 {\n\t\treturn config, errors.New(\"Invalid file\")\n\t}\n\tkey := xor.XorKey{Key: XorKeyBA}\n\tconfig.Header = string(key.Decrypt([]byte(config.Header)))\n\tif config.Header != \"CookieUSB\" {\n\t\treturn config, errors.New(\"Invalid file\")\n\t}\n\tkey = xor.XorKey{Key: ReverseByteArray(XorKeyBA)}\n\tconfig.Password = string(key.Decrypt([]byte(config.Password)))\n\t// Decrypt the PublicKey with AES { Key : sha256(rawPassword), IV : config.IV }\n\t// Decrypt the PrivateKey with AES { Key : sha256(rawPassword), IV : config.IV }\n\treturn config, err\n}", "func ReadDockerConfigFileFromBytes(contents []byte) (cfg DockerConfig, err error) {\n\tif err = json.Unmarshal(contents, &cfg); err != nil {\n\t\treturn nil, errors.New(\"error occurred while trying to unmarshal json\")\n\t}\n\treturn\n}", "func LoadConfig(data []byte) *Config {\r\n\tvar config = new(Config)\r\n\terr := yaml.Unmarshal(data, &config)\r\n\tif err != nil {\r\n\t\tpanic(err.Error())\r\n\t}\r\n\treturn config\r\n}", "func LoadConfig(file string) *nebletpb.Config {\n\tvar content string\n\tb, err := ioutil.ReadFile(file)\n\tif err != nil {\n\t\tlogging.CLog().WithFields(logrus.Fields{\n\t\t\t\"err\": err,\n\t\t}).Fatal(\"Failed to read the config file: %s.\", file)\n\t}\n\tcontent = string(b)\n\n\tpb := new(nebletpb.Config)\n\tif err := proto.UnmarshalText(content, pb); err != nil {\n\t\tlogging.CLog().WithFields(logrus.Fields{\n\t\t\t\"err\": err,\n\t\t}).Fatal(\"Failed to parse the config file: %s.\", file)\n\t}\n\treturn pb\n}", "func LoadConfigFromBytes(bytes []byte) (*Config, error) {\n\tvar config Config\n\tconfAst, err := hcl.ParseBytes(bytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\troot := confAst.Node.(*ast.ObjectList)\n\n\t// cache configuration\n\tif cacheConfig := root.Filter(\"cache\"); len(cacheConfig.Items) == 1 {\n\t\thcl.DecodeObject(&config.Cache, cacheConfig.Items[0])\n\t} else {\n\t\tif len(cacheConfig.Items) > 1 {\n\t\t\treturn nil, fmt.Errorf(\"duplicate cache configuration\")\n\t\t}\n\t}\n\n\t// fetch the server config\n\tif serverConfig := root.Filter(\"server\"); len(serverConfig.Items) == 1 {\n\t\thcl.DecodeObject(&config.Server, serverConfig.Items[0])\n\t} else {\n\t\tif len(serverConfig.Items) > 1 {\n\t\t\treturn nil, fmt.Errorf(\"duplicate server configuration\")\n\t\t}\n\n\t\treturn nil, fmt.Errorf(\"missing server configuration\")\n\t}\n\n\t// take care of providers\n\tif providerConfig := root.Filter(\"provider\"); len(providerConfig.Items) > 0 {\n\t\tfor _, providerNode := range providerConfig.Items {\n\t\t\terr = LoadProvider(providerNode)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t} else {\n\t\treturn nil, fmt.Errorf(\"no provider configured\")\n\t}\n\n\t// finally configure mirrors\n\tconfig.Mirrors = make(map[string]MirrorConfig)\n\tif mirrorConfig := root.Filter(\"mirror\"); len(mirrorConfig.Items) > 0 {\n\t\tfor _, mirrorNode := range mirrorConfig.Items {\n\t\t\terr = LoadMirror(&config, mirrorNode)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t} else {\n\t\treturn nil, fmt.Errorf(\"no provider configured\")\n\t}\n\n\treturn &config, err\n}", "func readConfig(yamlStr []byte) Conf {\n\n\t// First unmarshall into generic structure\n\tvar data map[string]interface{}\n\terr := yaml.Unmarshal(yamlStr, &data)\n\tif err != nil {\n\t\tlog.Fatalf(\"Unmarshal: %v\\n\", err)\n\t}\n\n\t// A config can hold multiple keyed sections\n\tc := Conf{}\n\n\t// Load generation settings\n\tif item, ok := data[\"generate\"]; ok {\n\t\tc.Rendering = loadRendering(item)\n\t}\n\treturn c\n}", "func (f *configFile) load(bytes []byte) error {\n\terr := yaml.Unmarshal(bytes, f)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Could not unmarshal config file: %s\", err)\n\t}\n\treturn nil\n}", "func (h *Handler) CreateFromBytes(data []byte) (*corev1.ConfigMap, error) {\n\tcmJson, err := yaml.ToJSON(data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcm := &corev1.ConfigMap{}\n\tif err = json.Unmarshal(cmJson, cm); err != nil {\n\t\treturn nil, err\n\t}\n\treturn h.createConfigmap(cm)\n}", "func parseConfig(path string) (Config, error) {\n\tvar err error\n\tvar yamlBlob []byte\n\tvar conf Config\n\n\tyamlBlob, err = ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn Config{}, err\n\t}\n\terr = yaml.Unmarshal(yamlBlob, &conf)\n\tif err != nil {\n\t\treturn Config{}, err\n\t}\n\treturn conf, nil\n}", "func FromYaml(in []byte, expandEnv bool) (*Config, error) {\n\tconfig := &Config{}\n\n\tif err := config.FromYaml(in, expandEnv); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn config, nil\n}", "func loadConf(filepath string, confobj interface{}) error {\n\tfp, err := os.Open(filepath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer fp.Close()\n\tyamlDec := yaml.NewDecoder(fp)\n\tyamlDec.SetStrict(true)\n\tif err := yamlDec.Decode(confobj); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *Config) FromYaml(data []byte) error {\n\treturn yaml.Unmarshal(data, c)\n}", "func New(yamlBytes []byte) (*Conf, error) {\n\tvar c Conf\n\tif err := yaml.Unmarshal(yamlBytes, &c); err != nil {\n\t\treturn nil, fmt.Errorf(\"Cannot parse the configuration: %s\", err)\n\t}\n\n\tfor _, p := range c.Out {\n\t\tif err := p.Configure(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tfor _, p := range c.In {\n\t\tif err := p.Configure(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn &c, nil\n}", "func Load(configFileByte []byte, configFile string, p Parser) {\n\tlog.Println(\"Parse the config\")\n\terr := p.ParseJSON(configFileByte)\n\tif err != nil {\n\t\tlog.Println(configFileByte)\n\t\tlog.Fatalln(\"Could not parse %q: %v\", configFile, err)\n\t} else {\n\t\tlog.Println(\"Configuration loaded\")\n\t}\n}", "func parsePlaybookYaml(playbookBytes []byte, variables map[string]string) (*Playbook, error) {\n\t// Define and initialize the Playbook struct\n\tvar playbook Playbook = NewPlaybook()\n\n\t// Clean up the YAML\n\tcleaned := cleanYaml(playbookBytes)\n\n\t// Run the yaml through the template engine\n\tstr, err := fillPlaybookTemplate(string(cleaned[:]), variables)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error filling playbook template\")\n\t}\n\n\t// Unmarshal the yaml into the playbook\n\tif err = yaml.Unmarshal([]byte(str), &playbook); err != nil {\n\t\treturn nil, fmt.Errorf(\"error unmarshalling playbook yaml\")\n\t}\n\n\treturn &playbook, nil\n}", "func Yaml(data string) ViperBuilder {\n\treturn ReadConfig(\"yaml\", strings.NewReader(data))\n}", "func decodeTomlConfig2BrokerStruct(filepath string) (instance *Broker, err error) {\n\tinstance = NewBroker()\n\t//err = configor.New(&configor.Config{Debug: true}).Load(instance, filepath)\n\terr = configor.Load(instance, filepath)\n\n\treturn\n}", "func LoadBytes(fileBytes []byte) (*EndpointConfig, error) {\n\tvar (\n\t\tjsonObject *gabs.Container\n\t\terr error\n\t\tepConfig *EndpointConfig\n\t)\n\n\tjsonObject, err = gabs.ParseJSON(fileBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !validate(jsonObject) {\n\t\treturn nil, errors.New(\"Invalid endpoint configuration\")\n\t}\n\tmethod, _ := jsonObject.Path(\"method\").Data().(string)\n\turl, _ := jsonObject.Path(\"url\").Data().(string)\n\n\theaderMap := make(map[string][]string)\n\tchildren, _ := jsonObject.S(\"headers\").ChildrenMap()\n\tfor key, child := range children {\n\t\theaderMap[key] = []string{config.ExpandString(child.Data().(string))}\n\t}\n\n\tpromptsJson, _ := jsonObject.S(\"prompts\").ChildrenMap()\n\tprompts := []*Prompt{}\n\tfor key, child := range promptsJson {\n\t\tvar defaultValue = \"\"\n\t\tif child.Exists(\"defaultValue\") {\n\t\t\tdefaultValue = child.Path(\"defaultValue\").Data().(string)\n\t\t}\n\t\tprompt := &Prompt{Name: key, DefaultValue: defaultValue}\n\t\tprompts = append(prompts, prompt)\n\t}\n\n\tepConfig = &EndpointConfig{\n\t\tjson: jsonObject,\n\t\tMethod: method,\n\t\tUrl: url,\n\t\tOnComplete: []string{},\n\t\tTransform: []string{},\n\t\tHeaders: headerMap,\n\t\tPrompts: prompts,\n\t}\n\n\ttransformNodes, _ := jsonObject.S(\"transform\").Children()\n\tfor _, node := range transformNodes {\n\t\tepConfig.Transform = append(epConfig.Transform, node.Data().(string))\n\t}\n\n\tonCompleteNodes, _ := jsonObject.S(\"onComplete\").Children()\n\tfor _, node := range onCompleteNodes {\n\t\tepConfig.OnComplete = append(epConfig.OnComplete, node.Data().(string))\n\t}\n\n\treturn epConfig, nil\n}", "func NewConfigFromYaml(b []byte) (*Config, error) {\n\tc, err := NewConfig()\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = yaml.Unmarshal(b, c)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot parse config: %q\", err)\n\t}\n\n\treturn c, nil\n}", "func (b *ByteCount) UnmarshalYAML(unmarshal func(interface{}) error) error {\n\tvar strVal string\n\terr := unmarshal(&strVal)\n\tif err != nil {\n\t\treturn err\n\t}\n\tparsed, err := Parse(strVal)\n\tif err != nil {\n\t\treturn err\n\t}\n\t*b = parsed\n\treturn nil\n}", "func loadConfig(filename string) ConfigFile {\n\t// Deliberately don't catch errors, want script to crash on config file load error\n\tconfigFile, _ := ioutil.ReadFile(filename)\n\tvar config ConfigFile\n\tyaml.Unmarshal(configFile, &config)\n\n\t// Return the struct\n\treturn (config)\n}", "func (h *Handler) UpdateFromBytes(data []byte) (*corev1.ConfigMap, error) {\n\tcmJson, err := yaml.ToJSON(data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcm := &corev1.ConfigMap{}\n\tif err = json.Unmarshal(cmJson, cm); err != nil {\n\t\treturn nil, err\n\t}\n\treturn h.updateConfigmap(cm)\n}", "func parseYaml(yml []byte) T {\n\tt := T{}\n\terr := yaml.Unmarshal([]byte(yml), &t)\n\tif err != nil {\n\t\tfmt.Printf(\"error: %v\", err)\n\t}\n\treturn t\n}", "func loadConfig(configFile string) *utils.Config {\n\tconf := &utils.Config{}\n\tif _, err := toml.DecodeFile(configFile, &conf); err != nil {\n\t\tfmt.Println(err)\n\t}\n\treturn conf\n}", "func parseDatabaseConfig(filename string) Configs {\n\tvar parsed Configs\n\tbody, err := ioutil.ReadFile(filename)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\twithoutERB := parseERB(body)\n\terr = yaml.Unmarshal(withoutERB, &parsed)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\treturn parsed\n}", "func ParseObj(data []byte) (*models.TaskConfig, error) {\n\trun := models.TaskConfig{}\n\tlog.Println(string(data))\n\terr := yaml.Unmarshal(data, &run)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &run, nil\n}", "func FromYAML(r io.Reader) (*Config, error) {\n\tc := &Config{}\n\terr := yaml.NewDecoder(r).Decode(c)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode YAML: %w\", err)\n\t}\n\n\treturn c, nil\n}", "func parseYaml(file string) (*v1alpha1.EnvoyConfig, error) {\n\tvar config v1alpha1.EnvoyConfig\n\n\tyamlFile, err := ioutil.ReadFile(file)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error reading YAML file: %s\\n\", err)\n\t}\n\n\terr = yaml.Unmarshal(yamlFile, &config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &config, nil\n}", "func Parse(data []byte) (*Config, error) {\n\tvar err error\n\tc := &Config{}\n\tif err = yaml.Unmarshal(data, c); err != nil {\n\t\treturn c, err\n\t}\n\terr = c.validate()\n\treturn c, err\n}", "func parseConfig(file *os.File) (Config, error) {\n\tbuilderConfig := Config{}\n\ttomlMetadata, err := toml.NewDecoder(file).Decode(&builderConfig)\n\tif err != nil {\n\t\treturn Config{}, errors.Wrap(err, \"decoding toml contents\")\n\t}\n\n\tundecodedKeys := tomlMetadata.Undecoded()\n\tif len(undecodedKeys) > 0 {\n\t\tunknownElementsMsg := config.FormatUndecodedKeys(undecodedKeys)\n\n\t\treturn Config{}, errors.Errorf(\"%s in %s\",\n\t\t\tunknownElementsMsg,\n\t\t\tstyle.Symbol(file.Name()),\n\t\t)\n\t}\n\n\treturn builderConfig, nil\n}", "func (f *Factory) NewFromYAML(filePath string) (string, uint8, FilteredServer) {\n\tlog := f.log.WithField(\"file\", filepath.Base(filePath))\n\n\tcontent, err := os.ReadFile(filePath)\n\tif err != nil {\n\t\tlog.Fatalf(\"Cannot read file: %v\", err)\n\t}\n\n\tvar c Config\n\n\terr = yaml.Unmarshal(content, &c)\n\tif err != nil {\n\t\tlog.Fatalf(\"Cannot decode YAML: %v\", err)\n\t}\n\n\treturn f.newFromConfig(log, c)\n}", "func NewConfigFromYaml(in []byte) Config {\n\tvar cfg Config\n\n\tyaml.Unmarshal(in, &cfg)\n\n\treturn cfg\n}", "func (c *Config) LoadYaml(configFile string) {\n\tdataString, err := ioutil.ReadFile(configFile)\n\t// log.Printf(\"dataString = \\n%s\", dataString)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\terr2 := yaml.Unmarshal(dataString, &c)\n\tif err2 != nil {\n\t\tlog.Fatal(err2)\n\t}\n\n\tc.FillDefaults(&c.Apstra)\n\n\t// log.Printf(\"c = %+v\", c)\n}", "func LoadYaml(data []byte) ([]runtime.Object, error) {\n\tparts := bytes.Split(data, []byte(\"---\"))\n\tvar r []runtime.Object\n\tfor _, part := range parts {\n\t\tpart = bytes.TrimSpace(part)\n\t\tif len(part) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tobj, _, err := scheme.Codecs.UniversalDeserializer().Decode([]byte(part), nil, nil)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tr = append(r, obj)\n\t}\n\treturn r, nil\n}", "func readAliasFromBytes(data []byte, alias *Alias) error {\n\taliasMap := &map[string]string{}\n\n\tif err := yaml.Unmarshal(data, aliasMap); err != nil {\n\t\treturn err\n\t}\n\n\tfor key, value := range *aliasMap {\n\t\tif _, ok := alias.AliasMap[key]; !ok {\n\t\t\talias.AliasMap[key] = value\n\t\t}\n\t}\n\n\treturn nil\n}", "func Load(data []byte) (*clientcmdapi.Config, error) {\n\tconfig := clientcmdapi.NewConfig()\n\t// if there's no data in a file, return the default object instead of failing (DecodeInto reject empty input)\n\tif len(data) == 0 {\n\t\treturn config, nil\n\t}\n\tdecoded, _, err := clientcmdlatest.Codec.Decode(data, &schema.GroupVersionKind{Version: clientcmdlatest.Version, Kind: \"Config\"}, config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn decoded.(*clientcmdapi.Config), nil\n}", "func LoadConfig(data []byte) (Configs, error) {\n\tcfg := Configs{}\n\terr := json.Unmarshal(data, &cfg)\n\n\t// TODO(mattfarina): wrap the error into something more useful if one exists\n\treturn cfg, err\n}", "func (pc *StateFiles) specFromYAML(file string) error {\n\trawYamlFile, err := ioutil.ReadFile(file)\n\tif err != nil {\n\t\tlog.Errorf(\"specFromYaml %v %v\", file, err)\n\t\treturn err\n\t}\n\n\tyamlFile := string(rawYamlFile)\n\n\treturn yaml.Unmarshal([]byte(yamlFile), pc)\n}", "func LoadConfig(configPtr *string) Config {\n\tbytes, err := ioutil.ReadFile(*configPtr)\n\tif err != nil {\n\t\tfmt.Println(\"Specified config file or default config file is not existing or not readable\")\n\t\tos.Exit(2)\n\t}\n\n\tconfig := Config{}\n\terr = yaml.Unmarshal(bytes, &config)\n\tif err != nil {\n\t\tfmt.Println(\"Config file is not valid\")\n\t\tos.Exit(3)\n\t}\n\n\treturn config\n}", "func parse(yml []byte) *Conf {\n\tc := new(Conf)\n\te := yaml.Unmarshal(yml, c)\n\tutil.LogPanic(e)\n\treturn c\n}", "func (conf IniConfig) getConfFromYaml(fileName string) (result IniConfig, err error) {\n\tyamlFile, err := ioutil.ReadFile(fileName)\n\tif err != nil {\n\t\tlog.Printf(\"yamlFile.Get err #%v \", err)\n\t\treturn conf, err\n\t}\n\terr = yaml.Unmarshal(yamlFile, &conf)\n\tif err != nil {\n\t\tlog.Printf(\"Unmarshal: %v\", err)\n\t\treturn conf, err\n\t}\n\treturn conf, nil\n}", "func ParserConfig(_struct interface{}) error {\n\tpath := \"/var/arposter/config.json\"\n\tfile, err := os.OpenFile(path, os.O_RDONLY, 0666)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\n\tdecoder := json.NewDecoder(file)\n\tif err := decoder.Decode(&_struct); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *Config) LoadBytes(content []byte) (map[string]map[string]string, error) {\n // read bytes into buffer\n reader := strings.NewReader(string(content))\n buffer := bufio.NewReader(reader)\n resMap, err := c.splitContent(buffer)\n if err != nil {\n return nil, err\n }\n return resMap, nil\n}", "func ReadFrom(pathToYamlFile string) (*FileConfiguration, error) {\n\tyamlConfiguration := new(yamlConfigurationFormat)\n\n\tvar err error\n\tvar yamlContent []byte\n\tyamlContent, err = ioutil.ReadFile(pathToYamlFile)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = yaml.Unmarshal(yamlContent, &yamlConfiguration)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresult := &FileConfiguration{parsedYaml: yamlConfiguration}\n\n\treturn result, nil\n}", "func NewFromYaml(cnfPath string, keepReloading bool) (*Config, error) {\n\tcnf, err := fromFile(cnfPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlog.INFO.Printf(\"Successfully loaded config from file %s\", cnfPath)\n\n\tif keepReloading {\n\t\t// Open a goroutine to watch remote changes forever\n\t\tgo func() {\n\t\t\tfor {\n\t\t\t\t// Delay after each request\n\t\t\t\ttime.Sleep(reloadDelay)\n\n\t\t\t\t// Attempt to reload the config\n\t\t\t\tnewCnf, newErr := fromFile(cnfPath)\n\t\t\t\tif newErr != nil {\n\t\t\t\t\tlog.WARNING.Printf(\"Failed to reload config from file %s: %v\", cnfPath, newErr)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\t*cnf = *newCnf\n\t\t\t\t// log.INFO.Printf(\"Successfully reloaded config from file %s\", cnfPath)\n\t\t\t}\n\t\t}()\n\t}\n\n\treturn cnf, nil\n}", "func InitConfigFactory(f string) {\n content, err := ioutil.ReadFile(f)\n checkErr(err)\n\n NssfConfig = Config{}\n\n err = yaml.Unmarshal([]byte(content), &NssfConfig)\n checkErr(err)\n\n err = NssfConfig.CheckIntegrity()\n checkErr(err)\n\n // d, err := yaml.Marshal(NssfConfig)\n // checkErr(err)\n // fmt.Printf(string(d))\n}", "func LoadYAMLConfig(data string, outData interface{}) (err error) {\n\terr = marshal.FromYAMLString(data, outData)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func YAMLIntoStruct(filePath string, s interface{}) error {\n\tdata, err := ioutil.ReadFile(filePath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error reading config: %s\", err)\n\t}\n\n\tif err = yaml.Unmarshal(data, s); err != nil {\n\t\treturn fmt.Errorf(\"error parsing %s: %s\", filePath, err)\n\t}\n\treturn nil\n}", "func deserializeByteSequenceConfig(config SequenceConfig) ([]*SequenceModel, []*SequenceModel) {\n\tadds := make([]*SequenceModel, len(config.AddSequences))\n\trems := make([]*SequenceModel, len(config.RemoveSequences))\n\n\tfor x, seq := range config.AddSequences {\n\t\tadds[x] = deserializeByteSequenceModel(seq)\n\t}\n\n\tfor x, seq := range config.RemoveSequences {\n\t\trems[x] = deserializeByteSequenceModel(seq)\n\t}\n\n\treturn adds, rems\n}", "func (c *Config) readConfig() error {\n\tf, err := os.Open(c.file)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\tinputBytes, err := ioutil.ReadAll(f)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := yaml.Unmarshal(inputBytes, &c); err != nil {\n\t\treturn err\n\t}\n\tc.loaded = true\n\treturn nil\n}", "func Load(file string) (v1alpha1.Config, error) {\n\tvar configFile []byte\n\tvar err error\n\tif configFile, err = os.ReadFile(file); err != nil {\n\t\treturn v1alpha1.Config{}, fmt.Errorf(\"unable to read configuration file %s: %s\", file, err.Error())\n\t}\n\n\tvar config v1alpha1.Config\n\tif err = yaml.Unmarshal(configFile, &config); err != nil {\n\t\treturn v1alpha1.Config{}, fmt.Errorf(\"unable to unmarshal file %s: %s\", file, err.Error())\n\t}\n\n\treturn config, nil\n}", "func LoadConfig(fname string) (m *Config) {\n\tm = &Config{}\n\tif err := LoadYaml(m, fname); err != nil {\n\t\tif isV {\n\t\t\tfmt.Println(\" File can not unmarshal.:\", fname)\n\t\t}\n\t\treturn nil\n\t}\n\treturn\n}", "func readConfig(r io.Reader) (letterboxConfig, error) {\n\tvar config letterboxConfig\n\tif _, err := toml.DecodeReader(r, &config); err != nil {\n\t\treturn config, err\n\t}\n\treturn config, nil\n}", "func FromYAML(reader io.Reader, configuration interface{}) error {\n\tcontent, err := ioutil.ReadAll(reader)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn yaml.Unmarshal(content, configuration)\n}", "func LoadConfig(file string) (*Config, error) {\n\tb, err := ioutil.ReadFile(file)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif ext := path.Ext(file); ext == \".yaml\" || ext == \".yml\" {\n\t\tb, err = yaml.YAMLToJSON(b)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tconfig := &Config{}\n\tif err = json.Unmarshal(b, config); err != nil {\n\t\treturn nil, err\n\t}\n\n\tfixMbeanNames(config)\n\treturn config, nil\n}", "func (c *Conf) InitFromBytes(content []byte) error {\n\tc.mutex.Lock()\n\tdefer c.mutex.Unlock()\n\tc.content = content\n\txmlDecoder := xml.NewDecoder(bytes.NewReader(c.content))\n\tvar nodeStack []*elem\n\tnodeStack = append(nodeStack, c.root)\n\tfor {\n\t\tcurrNode := nodeStack[len(nodeStack)-1]\n\t\ttoken, _ := xmlDecoder.Token()\n\t\tif token == nil {\n\t\t\tbreak\n\t\t}\n\t\tswitch t := token.(type) {\n\t\tcase xml.CharData:\n\t\t\tlineDecoder := bufio.NewScanner(bytes.NewReader(t))\n\t\t\tlineDecoder.Split(bufio.ScanLines)\n\t\t\tfor lineDecoder.Scan() {\n\t\t\t\tline := strings.Trim(lineDecoder.Text(), whiteSpaceChars)\n\t\t\t\tif (len(line) > 0 && line[0] == '#') || line == \"\" {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\t// add Line data\n\t\t\t\tcurrNode.addLine(line)\n\t\t\t\tkv := strings.SplitN(line, \"=\", 2)\n\t\t\t\tk, v := strings.Trim(kv[0], whiteSpaceChars), \"\"\n\t\t\t\tif k == \"\" {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif len(kv) == 2 {\n\t\t\t\t\tv = strings.Trim(kv[1], whiteSpaceChars)\n\t\t\t\t}\n\t\t\t\tleaf := newElem(Leaf, k)\n\t\t\t\tleaf.setValue(v)\n\t\t\t\tcurrNode.addChild(k, leaf)\n\t\t\t}\n\t\tcase xml.StartElement:\n\t\t\tnodeName := t.Name.Local\n\t\t\tnode, ok := currNode.findChild(nodeName)\n\t\t\tif !ok {\n\t\t\t\tnode = newElem(Node, nodeName)\n\t\t\t\tcurrNode.addChild(nodeName, node)\n\t\t\t}\n\t\t\tnodeStack = append(nodeStack, node)\n\t\tcase xml.EndElement:\n\t\t\tnodeName := t.Name.Local\n\t\t\tif currNode.name != nodeName {\n\t\t\t\treturn fmt.Errorf(\"xml end not match :%s\", nodeName)\n\t\t\t}\n\t\t\tnodeStack = nodeStack[:len(nodeStack)-1]\n\t\t}\n\t}\n\treturn nil\n}", "func (l *Loader) LoadBytes(in []byte) (*config.Values, error) {\n\treturn l.LoadReader(bytes.NewReader(in))\n}", "func FromYAML(r io.Reader) (Config, error) {\n\td := yaml.NewDecoder(r)\n\tm := make(map[string]interface{})\n\terr := d.Decode(&m)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn FromTieredMap(m), nil\n}", "func FromYAML(rawYAML []byte) ConfigMap {\n\tmapsi := make(map[string]interface{})\n\terr := yaml.Unmarshal(rawYAML, &mapsi)\n\tif err != nil {\n\t\tlog.Printf(\"error unmarshaling YAML: %s\", err)\n\t}\n\treturn New(mapsi)\n}", "func loadConfig(path string) (Config, error) {\n\tcfg := Config{}\n\tfilename, err := filepath.Abs(path)\n\tif err != nil {\n\t\treturn cfg, err\n\t}\n\tcontent, err := ioutil.ReadFile(filename)\n\tif err != nil {\n\t\treturn cfg, err\n\t}\n\n\terr = yaml.Unmarshal(content, &cfg)\n\tif err != nil {\n\t\treturn cfg, err\n\t}\n\n\treturn cfg, err\n}", "func Load(path string, maxSize int64) (*Config, error) {\n\tb, readErr := store.FileRead(path, maxSize)\n\tif readErr != nil {\n\t\treturn nil, readErr\n\t}\n\tc := New()\n\tif err := yaml.Unmarshal(b, c); err != nil {\n\t\treturn nil, err\n\t}\n\treturn c, nil\n}", "func readConfig(fileName string) (*gabs.Container, error) {\n\t// Read file\n\tfileBytes, readErr := ioutil.ReadFile(fileName)\n\n\tif readErr != nil {\n\t\treturn nil, readErr\n\t}\n\n\t// Convert to usable map\n\tparsedJson, parsedJsonErr := gabs.ParseJSON(fileBytes)\n\n\tif parsedJsonErr != nil {\n\t\treturn nil, parsedJsonErr\n\t}\n\n\treturn parsedJson, nil\n}", "func (p *TOMLParser) FromBytes(byteData []byte) (interface{}, error) {\n\tvar data interface{}\n\tif err := toml.Unmarshal(byteData, &data); err != nil {\n\t\treturn data, fmt.Errorf(\"could not unmarshal data: %w\", err)\n\t}\n\treturn &BasicSingleDocument{\n\t\tValue: data,\n\t}, nil\n}", "func (m DiskManifestLoader[T]) decodeYaml(b []byte) ([]T, []error) {\n\tlist := make([]T, 0)\n\terrors := []error{}\n\tscanner := bufio.NewScanner(bytes.NewReader(b))\n\tscanner.Split(splitYamlDoc)\n\n\tfor {\n\t\tif !scanner.Scan() {\n\t\t\terr := scanner.Err()\n\t\t\tif err != nil {\n\t\t\t\terrors = append(errors, err)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tbreak\n\t\t}\n\n\t\tscannerBytes := scanner.Bytes()\n\t\tvar ti typeInfo\n\t\tif err := yaml.Unmarshal(scannerBytes, &ti); err != nil {\n\t\t\terrors = append(errors, err)\n\t\t\tcontinue\n\t\t}\n\n\t\tif ti.Kind != m.kind {\n\t\t\tcontinue\n\t\t}\n\n\t\tif errs := path.IsValidPathSegmentName(ti.Name); len(errs) > 0 {\n\t\t\terrors = append(errors, fmt.Errorf(\"invalid name %q for %q: %s\", ti.Name, m.kind, strings.Join(errs, \"; \")))\n\t\t\tcontinue\n\t\t}\n\n\t\tvar manifest T\n\t\tif m.zvFn != nil {\n\t\t\tmanifest = m.zvFn()\n\t\t}\n\t\tif err := yaml.Unmarshal(scannerBytes, &manifest); err != nil {\n\t\t\terrors = append(errors, err)\n\t\t\tcontinue\n\t\t}\n\t\tlist = append(list, manifest)\n\t}\n\n\treturn list, errors\n}", "func DockstoreComposeFromBytes(yamlBytes []byte) (model *ComposeFull, err error) {\n\tmodel = &ComposeFull{}\n\terr = yaml.Unmarshal(yamlBytes, model)\n\tif nil != err {\n\t\treturn nil, err\n\t}\n\treturn model, model.Sanitize()\n}", "func loadConfig(filename string) (configuration, error) {\n\tconf := configuration{Exclusions: []string{}}\n\tdata, err := ioutil.ReadFile(filename)\n\tif err != nil {\n\t\tif !os.IsNotExist(err) {\n\t\t\treturn conf, err\n\t\t}\n\t} else {\n\t\tif err := yaml.Unmarshal(data, &conf); err != nil {\n\t\t\treturn configuration{}, err\n\t\t}\n\t}\n\treturn conf, nil\n}", "func FileConfig(cfgPath string) *Config {\n\tconfig := new(Config)\n\tcfgFile, err := ioutil.ReadFile(cfgPath)\n\tif err != nil {\n\t\tconfig.err = err\n\t} else {\n\t\tconfig.err = yaml.Unmarshal(cfgFile, config)\n\t}\n\treturn config\n}", "func LoadConfig(configPath string) Config {\n\tb, err := ioutil.ReadFile(configPath)\n\tif err != nil {\n\t\tlog.Fatalf(\"error: %v\", err)\n\t}\n\n\tm := Config{}\n\terr = yaml.Unmarshal(b, &m)\n\n\tif err != nil {\n\t\tlog.Fatalf(\"error: %v\", err)\n\t}\n\n\treturn m\n}", "func LoadConfigFromContent(content []byte) (*Config, error) {\n\tc, err := NewDefault()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = yaml.Unmarshal(content, c)\n\tif err != nil {\n\t\tlogger.Error(\"Config parse error: \" + err.Error())\n\t\treturn nil, err\n\t}\n\n\treturn c, nil\n}", "func ParseRemoteSecretBytes(secretBytes []byte) (*RemoteSecret, error) {\n\tsecret := &RemoteSecret{}\n\terr := yaml.Unmarshal(secretBytes, &secret)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn secret, nil\n}", "func LoadYaml(v interface{}, fname string) (err error) {\n\tbuf, err := ioutil.ReadFile(fname)\n\tif err == nil {\n\t\terr = yaml.Unmarshal([]byte(buf), v)\n\t}\n\treturn\n}", "func Load(dataDirPath string) (config *Config, err error) {\n // load the config json into memory\n byteArr, err := ioutil.ReadFile(filepath.Join(dataDirPath, configFileName))\n if err != nil {\n return nil, fmt.Errorf(\"failed to read configuration file: %v\", err)\n }\n cfgJSON := &configJSON{}\n if err = json.Unmarshal(byteArr, cfgJSON); err != nil {\n return nil, fmt.Errorf(\"failed to parse configuration json: %v\", err)\n }\n\n // decode the private and public pem files\n pubPem, _ := pem.Decode([]byte(cfgJSON.PubPem))\n if pubPem == nil {\n return nil, fmt.Errorf(\"invalid public key data\")\n }\n privPem, _ := pem.Decode([]byte(cfgJSON.PrivPem))\n if privPem == nil {\n return nil, fmt.Errorf(\"invalid private key data\")\n }\n return &Config{privPem, pubPem, dataDirPath}, nil\n}", "func LoadConfig(confPath string) (Config, error){\n var conf Config\n _, err := toml.DecodeFile(confPath, &conf)\n return conf, err\n}", "func recupStructWithConfigFile(file string, debugFile string, debugLog bool) (config Config) {\n\n\t// check if file exists\n\te, err := os.Stat(file)\n\tif err != nil {\n\t\tfmt.Println(\"config file not found\")\n\t\tutils.StopApp()\n\t}\n\tDebugPrint(debugFile, debugLog, \"DEBUG: \", \"File opened : \"+e.Name())\n\n\t// open the file\n\tf, _ := os.Open(file)\n\tdefer f.Close()\n\n\t// read the file contents\n\tbyteValue, _ := ioutil.ReadAll(f)\n\n\t// unmarshal the file's content and save to config variable\n\tjson.Unmarshal(byteValue, &config)\n\n\treturn\n}", "func Load(r io.Reader) (*Config, error) {\n\tb, err := io.ReadAll(r)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not read config: %s\", err)\n\t}\n\n\tc := &Config{}\n\terr = yaml.Unmarshal(b, c)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not parse config: %s\", err)\n\t}\n\n\treturn c, nil\n}", "func LoadConfigFromData(yamlData string) (Config, error) {\n\tc := Config{}\n\n\terr := yaml.Unmarshal([]byte(yamlData), &c)\n\tif err != nil {\n\t\treturn c, err\n\t}\n\n\treturn c, nil\n}", "func NewFromBytes(dataBytes []byte, encoder Encoder) (*Config, error) {\n\tvar data map[string]interface{}\n\n\terr := encoder(dataBytes, &data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn NewFromRaw(data), nil\n}", "func TestLoadconfiguration(t *testing.T) {\n\tvar tx *BFTXEncryptionConfig\n\n\t_gopath := os.Getenv(\"GOPATH\")\n\t_bftxpath := \"/src/github.com/blockfreight/go-bftx\"\n\t// txpath := \"/examples/bftx.json\"\n\ttxpath := \"/examples/config.yaml\"\n\tb, err := ioutil.ReadFile(txpath)\n\terr = yaml.UnmarshalStrict(b, &tx)\n\tif err != nil {\n\t\tt.Errorf(\"%s\", b)\n\t\tt.Errorf(\"================\\n\")\n\t\tt.Errorf(\"yaml file %s cannot be unmarshaled.\\n %v\", _gopath+_bftxpath+txpath, err)\n\t}\n}", "func parseRawConfig(filename string) rawConfig {\n\t// I read the file content...\n\tyamlFile, err := ioutil.ReadFile(filename)\n\tif err != nil {\n\t\tlog.Fatalf(\"Cannot read config file: %v\", err)\n\t}\n\t// ... and I unmarshal the YAML into the raw structure\n\trawconfig := rawConfig{}\n\terr = yaml.Unmarshal(yamlFile, &rawconfig)\n\tif err != nil {\n\t\tlog.Fatalf(\"Cannot parse config file: %v\", err)\n\t}\n\t// Finally, I return the raw structure\n\treturn rawconfig\n}", "func Load(filepath string, config interface{}) error {\n\tmagazine := make(map[string]interface{})\n\tfileBytes, err := ioutil.ReadFile(filepath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := yaml.Unmarshal(fileBytes, &magazine); err != nil {\n\t\treturn err\n\t}\n\n\tmagazine = flatten(magazine)\n\tif err := applyEnv(magazine); err != nil {\n\t\treturn err\n\t}\n\n\tmagBytes, err := yaml.Marshal(bellows.Expand(magazine))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn yaml.Unmarshal(magBytes, config)\n}", "func ParseUpgradeFileFromBytes(upgradeNotes []byte) (*UpgradeFile, error) {\n\t// parse bytes into object\n\tres := &UpgradeFile{}\n\n\terr := yaml.Unmarshal(upgradeNotes, res)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn res, err\n}", "func parseConfig(path string) (*structs.Config, error) {\n\tyamlFile, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to open config file: %v\", err)\n\t}\n\tvar c *structs.Config\n\terr = yaml.Unmarshal(yamlFile, &c)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to parse config file: %v\", err)\n\t}\n\n\treturn c, nil\n}", "func Load(r io.Reader) (*Config, error) {\n\tb, err := io.ReadAll(r)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read bytes from reader: %w\", err)\n\t}\n\n\tvar cfg Config\n\tif err = yaml.Unmarshal(b, &cfg); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to unmarshal bytes to config: %w\", err)\n\t}\n\n\treturn &cfg, nil\n}", "func Parse(configBytes []byte) (*Cfg, error) {\n\tvar gc Cfg\n\n\terr := json.Unmarshal(configBytes, &gc)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = gc.checkErrors()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &gc, err\n}", "func (config *Config) FromYaml(in []byte, expandEnv bool) error {\n\tif expandEnv {\n\t\tparsed, err := envsubst.Bytes(in)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tin = parsed\n\t}\n\n\tif err := yaml.UnmarshalStrict(in, config); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}" ]
[ "0.7526334", "0.74325585", "0.71376395", "0.6780493", "0.6310663", "0.62009126", "0.61722964", "0.6167369", "0.6165938", "0.6147107", "0.6135909", "0.6120184", "0.60807824", "0.5971607", "0.5964108", "0.595612", "0.59326005", "0.5868942", "0.581166", "0.57967645", "0.5746139", "0.5715097", "0.5661324", "0.5625839", "0.5615277", "0.55766135", "0.55581754", "0.5551373", "0.5550396", "0.55383515", "0.55145514", "0.5493929", "0.54783607", "0.5475416", "0.54634285", "0.54514074", "0.54382396", "0.54184324", "0.5408646", "0.54078513", "0.5401729", "0.54016626", "0.5390089", "0.53837866", "0.53809875", "0.5377934", "0.5376728", "0.5365416", "0.53505546", "0.53423154", "0.53405315", "0.53339005", "0.5330156", "0.5319227", "0.53095675", "0.5307782", "0.53068995", "0.5300146", "0.5287042", "0.5281529", "0.5273686", "0.52723557", "0.5270674", "0.5262717", "0.5261107", "0.5260432", "0.52412766", "0.5228102", "0.52279186", "0.52221966", "0.5204955", "0.5195463", "0.51951534", "0.51947", "0.5191839", "0.51894754", "0.5188277", "0.5187023", "0.51839733", "0.51783127", "0.5176558", "0.5166472", "0.5165832", "0.51625365", "0.51583695", "0.5156196", "0.5155794", "0.5154142", "0.5152726", "0.5146792", "0.5146685", "0.5144432", "0.51429254", "0.5139324", "0.51373523", "0.51309216", "0.5128945", "0.51273626", "0.51126593", "0.5112529" ]
0.8160983
0
this function is used to check if a directory exists parameters: dir (a string containing the path to the checked directory) returns: boolean (true is no error in checking the existence of the directory, false if otherwise)
func ensureDirectory(dir string) bool { if _, err := os.Stat(dir); os.IsNotExist(err) { return false } return true }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *Fs) _dirExists(ctx context.Context, dirPath string) (exists bool) {\n\topts := rest.Opts{\n\t\tMethod: \"PROPFIND\",\n\t\tPath: dirPath,\n\t\tExtraHeaders: map[string]string{\n\t\t\t\"Depth\": \"0\",\n\t\t},\n\t}\n\tvar result api.Multistatus\n\tvar resp *http.Response\n\tvar err error\n\terr = f.pacer.Call(func() (bool, error) {\n\t\tresp, err = f.srv.CallXML(ctx, &opts, nil, &result)\n\t\treturn f.shouldRetry(ctx, resp, err)\n\t})\n\treturn err == nil\n}", "func DirExists(dir string) bool {\n\td, e := os.Stat(dir)\n\tswitch {\n\tcase e != nil:\n\t\treturn false\n\tcase !d.IsDir():\n\t\treturn false\n\t}\n\n\treturn true\n}", "func dirExists(path string) bool {\n\tfound, err := os.Stat(path)\n\tif err == nil && found.IsDir() {\n\t\treturn true\n\t}\n\treturn false\n}", "func ExistDir(dir string) bool {\n\t_, err := os.Stat(dir)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\tfmt.Println(err)\n\treturn false\n}", "func CheckDirExist(dir string) bool {\n\tif _, err := os.Stat(dir); os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func DirectoryExists(dir string) bool {\n\tif _, err := os.Stat(dir); os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func folderExists(dir string) bool {\n\tif _, err := os.Stat(dir); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func DirExists(dirname string) bool {\n\t_, err := os.Stat(dirname)\n\treturn err == nil\n}", "func Exists(dir string) bool {\n\tif _, err := os.Stat(dir); os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func DirExists(path string) bool {\n\tif _, err := os.Stat(path); !os.IsNotExist(err) {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func DirExists(path string) (bool, os.FileInfo) {\n exists, fileInfo := FileExists(path)\n if !exists {\n return false, nil\n }\n\n if !fileInfo.IsDir() {\n return false, nil\n }\n\n return true, fileInfo\n}", "func Exists(filename string,isDirectory bool) bool {\n info, err := os.Stat(filename)\n if os.IsNotExist(err) {\n return false\n }\n\n\tif isDirectory{\n\t\treturn info.IsDir()\n\n\t}\n return !info.IsDir()\n\n}", "func DirectoryExists(dir string) bool {\n\tstat, err := os.Stat(dir)\n\treturn !os.IsNotExist(err) && stat.IsDir()\n}", "func (g *GlobalContext) DirExists() bool {\n\t_, err := os.Stat(g.Dir())\n\treturn (err == nil)\n}", "func DirExists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\treturn false, err\n}", "func DirExists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn true, err\n}", "func DirExists(fs Fs, path string) (bool, error) {\n\tfi, err := fs.Stat(path)\n\tif err == nil && fi.IsDir() {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func check_dir() {\n\tnames := []string{\n\t\t\"conf.json\",\n\t\t\"templates/index.html\",\n\t\t\"templates/cat-index.html\",\n\t\t\"templates/category-index.html\",\n\t\t\"templates/post.html\",\n\t\t\"templates/base.html\",\n\t\t\"templates/archive.html\",\n\t\t\"templates/page.html\",\n\t\t\"templates/year.html\"}\n\tfor i := range names {\n\t\tif !exists(names[i]) {\n\t\t\tfmt.Println(names[i], \"is missing from current directory.\")\n\t\t\tos.Exit(-10)\n\t\t}\n\t}\n\n}", "func ensureDirectory(dir string) bool {\n\tif _, err := os.Stat(dir); os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func DirExists(name string) bool {\n\tif fi, err := os.Stat(name); err == nil {\n\t\tif fi.Mode().IsDir() {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func ExistDir(path string) bool {\n\tstat, err := os.Stat(path)\n\treturn err == nil && stat.IsDir()\n}", "func ifDirExists(path string) bool {\n\ts, err := os.Stat(path)\n\tif err != nil {\n\t\tif os.IsExist(err) {\n\t\t\treturn s.IsDir()\n\t\t}\n\t\treturn false\n\t}\n\treturn s.IsDir()\n}", "func DirExists(path string) bool {\n\tret, isDir := FileOrDirExists(path)\n\treturn ret && isDir\n}", "func DirExist(path string) bool {\n\tstat, err := os.Stat(path)\n\treturn !os.IsNotExist(err) && stat.IsDir()\n}", "func doesFileOrDirExists(path string) (bool, error) {\n\tDebugf(\"Checking if the directory %s exists\", path)\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn true, err\n}", "func DirExists(path string) bool {\n\tif fi, err := os.Stat(path); err == nil {\n\t\tif fi.Mode().IsDir() {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func DirExists(dirname string) bool {\n\tinfo, err := os.Stat(dirname)\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn info.IsDir()\n}", "func DirExists(path string) bool {\n\tstat, err := os.Stat(path)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\tif stat.IsDir() {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func exists(path string) (bool, bool, error) {\n\tinfo, err := os.Stat(path)\n\tif err != nil {\n\t\treturn false, false, err\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, false, nil\n\t}\n\tif info.IsDir() {\n\t\treturn true, true, nil\n\t}\n\treturn true, false, err\n}", "func (sshConfig *SSHConfig) DirectoryExists(path string) (result bool, err error) {\n\n\t// stat returns \"No such file or directory\" if the file/dir doesn't exist\n\t// otherwise, it returns some file system related information about the file/dir\n\tcmd := fmt.Sprintf(\"stat %s\", path)\n\tcmdResult, err := sshConfig.Run(cmd)\n\tif err == nil {\n\t\tresult = !strings.Contains(cmdResult, \"No such file or directory\") // DO NOT LOCALIZE\n\t}\n\treturn\n}", "func DirExists(filename string) bool {\n\tinfo, err := os.Stat(filename)\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn info.IsDir()\n}", "func DirExists(fs fsa.FileSystem, path string) bool {\n\tf, err := fs.Stat(path)\n\tif err != nil {\n\t\treturn false\n\t}\n\treturn f.IsDir()\n}", "func DirExists(path string) bool {\n\t// check if the source dir exist\n\tsrc, err := os.Stat(path)\n\tif err != nil {\n\t\tfmt.Println(\"❎ \\\"\", path, \"\\\" does not exist.\")\n\t\treturn false\n\t}\n\n\t// check if the source is indeed a directory or not\n\tif !src.IsDir() {\n\t\tfmt.Println(\"❎ \\\"\", path, \"\\\" is not a directory.\")\n\t\treturn false\n\t}\n\n\treturn true\n}", "func DirExists(path string) bool {\n\tif IsEmptyStr(path) {\n\t\treturn false\n\t}\n\n\tf, err := os.Stat(path)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\treturn f.IsDir()\n}", "func IsDirExist(path string) bool {\n\tfi, err := os.Stat(path)\n\treturn err == nil && fi.IsDir() || os.IsExist(err)\n}", "func ExistDir(file string) bool {\n\ts, err := os.Stat(file)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\treturn s.IsDir()\n}", "func DirExists(filename string) bool {\n\tf, err := os.Stat(filename)\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\tfilemode := f.Mode()\n\treturn filemode.IsDir()\n}", "func DirExists(path string) (bool, error) {\n\tpi, err := pathExists(path)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tif pi.Exists && !pi.IsDir {\n\t\treturn false, ex.New(\"Path exists but is not a directory\", ex.OptMessagef(\"Path: %q\", path))\n\t}\n\n\treturn pi.Exists, nil\n}", "func DirExists(path string) (bool, error) {\n\ts, err := os.Stat(path)\n\tif err == nil {\n\t\tif s.IsDir() {\n\t\t\treturn true, nil\n\t\t}\n\t}\n\treturn false, err\n}", "func checkDir(syncDir string) error {\n\n\tinfo, err := os.Stat(syncDir)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !info.IsDir() {\n\t\treturn errors.New(syncDir + \" is not a directory\")\n\t}\n\n\treturn nil\n}", "func ValidDir(dir string) (valid bool) {\n\n\tif _, err := os.Stat(dir); os.IsNotExist(err) {\n\t\tlog.Println(\"directory does not exist\")\n\t\treturn\n\t}\n\n\tnew := filepath.Join(dir, \"tempDir\")\n\n\tif err := os.Mkdir(new, 0755); err != nil {\n\t\tlog.Println(\"unable to create directory\")\n\t\treturn\n\t}\n\n\tif err := os.Remove(new); err != nil {\n\t\tlog.Println(\"unable to remove directory\")\n\t\treturn\n\t}\n\n\treturn true\n\n}", "func isDirectoryEmpty(dir string) (bool, error) {\n\tf, err := os.Open(dir)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tdefer f.Close()\n\n\t_, err = f.Readdir(1)\n\n\tif err == io.EOF {\n\t\treturn true, nil\n\t}\n\n\treturn false, err\n}", "func checkDir(dir string) error {\n\tif _, err := os.Stat(dir); os.IsNotExist(err) {\n\t\treturn os.Mkdir(dir, os.ModePerm)\n\t}\n\n\treturn nil\n}", "func CheckDir(dir string) error {\n\tif dir == \"\" {\n\t\treturn fmt.Errorf(\"no directory specified\")\n\t}\n\tif _, err := os.Stat(dir); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn fmt.Errorf(\"directory does not exist: %v\", dir)\n\t\t}\n\t\treturn fmt.Errorf(\"can't access adirectory (check permissions): %v\", dir)\n\t}\n\treturn nil\n}", "func checkFileExists(name string) (bool, error) {\n\ts, err := os.Stat(name)\n\tif nil != err {\n\t\treturn false, err\n\t}\n\treturn s.IsDir(), nil\n}", "func exists(filename string) bool {\n\tinfo, err := os.Stat(filename)\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn !info.IsDir()\n}", "func Exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn false, errors.Wrapf(errDirNotExist, \"can't access %s\", path)\n\t\t}\n\t}\n\n\t// Directory exists but can't be accessed\n\treturn true, errors.Wrapf(errDirNoAccess, \"can't access %s\", path)\n}", "func isDir(dir string) bool {\n\tfi, err := os.Stat(dir)\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\tif fi.Mode().IsDir() {\n\t\treturn true\n\t}\n\treturn false\n}", "func Dircheck(path string) (bool, error) {\n\t// check if the path exist\n\tsrc, err := os.Stat(path)\n\tif err != nil {\n\t\tfmt.Println(\"Path does not exist\")\n\t\treturn false, err\n\t}\n\n\t// check if the path is a directory\n\tif !src.IsDir() {\n\t\tfmt.Println(\"Path is not a directory\")\n\t\treturn false, errors.New(\"Path \" + path + \" is not a directory\")\n\t}\n\n\treturn true, nil\n}", "func checkExist(fs afero.Fs, directory string) error {\n\tLineSeparator()\n\t_, err := fs.Stat(directory)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func Exists(path string) bool {\n _, err := os.Stat(path)\n if err == nil { return true }\n if os.IsNotExist(err) { return false }\n return false\n}", "func IsDirExists(name string) bool {\n\tf, err := os.Stat(name)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tif !f.IsDir() {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func DirExists(path string) bool {\n\tfi, err := os.Lstat(path)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\treturn fi.Mode().IsDir()\n}", "func Exists(path string) bool {\n\tinfo, err := os.Stat(path)\n\n\treturn err == nil && info.IsDir()\n}", "func isDirectory(dir string) (b bool, err error) {\n\tfi, err := os.Stat(dir)\n\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn false, err\n\t\t}\n\t}\n\n\tif !fi.IsDir() {\n\t\treturn false, fmt.Errorf(`not a directory: %v`, dir)\n\t}\n\n\treturn true, nil\n}", "func Exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn false, ErrDirectoryAccess\n\t\t}\n\t}\n\n\t// Directory exists but can't be accessed\n\treturn true, ErrDirectoryAccess\n}", "func DirExists(path string) (bool, error) {\n\tfi, err := os.Stat(path)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn false, nil\n\t\t}\n\t\treturn false, err\n\t}\n\treturn fi.IsDir(), nil\n}", "func exists(path string) (bool, error) {\n\tif path == \"\" {\n\t\treturn false, nil\n\t}\n\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif !os.IsNotExist(err) {\n\t\treturn false, err\n\t}\n\n\treturn false, nil\n}", "func isDir(path string) (bool, error) {\n\tsrc, err := os.Stat(path)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tif src.Mode().IsRegular() {\n\t\tfmt.Println(path + \" already exist as a file!\")\n\t\treturn false, nil\n\t}\n\treturn true, nil\n}", "func IsEmptyDir(dir string) (bool, error) {\n\t// Stat follows symlinks\n\tstat, err := os.Stat(dir)\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tif stat.IsDir() {\n\t\tdentries, err := ioutil.ReadDir(dir)\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\n\t\tif len(dentries) == 0 {\n\t\t\treturn true, nil\n\t\t}\n\t}\n\n\treturn false, nil\n}", "func (d *Directory) checkPathExists(p string) (*Directory, error) {\n\tpathParams := strings.Split(p, \"/\")\n\tdir := d\nL:\n\tfor i := 1; i < len(pathParams)-1; i++ {\n\t\tif len(dir.INodes) == 0 {\n\t\t\treturn nil, errors.New(\"Path doesn't exists: \" + strings.Join(pathParams[:i+1], \"/\") + \"/\")\n\t\t}\n\t\tfor j := 0; j < len(dir.INodes); j++ {\n\t\t\tswitch dir.INodes[j].(type) {\n\t\t\tcase *Directory:\n\t\t\t\tif dir.INodes[j].GetName() == pathParams[i] {\n\t\t\t\t\tdir = dir.INodes[j].(*Directory)\n\t\t\t\t\tcontinue L\n\t\t\t\t}\n\t\t\t}\n\t\t\tif j == len(dir.INodes)-1 {\n\t\t\t\treturn nil, errors.New(\"Path doesn't exists: \" + strings.Join(pathParams[:i+1], \"/\") + \"/\")\n\t\t\t}\n\t\t}\n\t}\n\treturn dir, nil\n}", "func ensureDirectory(mounter mount.Interface, dir string) (bool, error) {\n\tif _, err := os.Stat(dir); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn true, nil\n\t\t}\n\t\treturn false, status.Errorf(codes.Internal, \"Failed to check existence of directory %q: %s\", dir, err.Error())\n\t}\n\n\tif err := os.MkdirAll(dir, os.FileMode(0755)); err != nil && !os.IsExist(err) {\n\t\treturn false, status.Errorf(codes.Internal, \"Could not create dir %q: %v\", dir, err)\n\t}\n\n\treturn false, nil\n}", "func isDir(dir string) bool {\n\tf, e := os.Stat(dir)\n\tif e != nil {\n\t\treturn false\n\t}\n\treturn f.IsDir()\n}", "func (fs *FileSystem) DirExists(path string) bool {\n\tif fi, err := os.Stat(path); err == nil {\n\t\tif fi.Mode().IsDir() {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func FileExists(dir string) bool {\n\tinfo, err := os.Stat(dir)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\treturn !info.IsDir()\n}", "func (d *Dir) Exists(newDir string) bool {\n\tfor _, dir := range d.Blacklist {\n\t\tif dir == newDir {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func exists(path string) (bool) {\n\t_, err := os.Stat(path)\n\tif err == nil { return true }\n\tif os.IsNotExist(err) {return false}\n\treturn true\n}", "func exists(path string) (bool) {\n\t_, err := os.Stat(path)\n\tif err == nil { return true }\n\tif os.IsNotExist(err) {return false}\n\treturn true\n}", "func exists(path string) (bool) {\n\t_, err := os.Stat(path)\n\tif err == nil { return true }\n\tif os.IsNotExist(err) {return false}\n\treturn true\n}", "func Exists(p string) (exists bool, isDir bool, err error) {\n\tfi, err := os.Stat(p)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn false, false, nil\n\t\t}\n\t\treturn false, false, err\n\t}\n\treturn true, fi.IsDir(), nil\n}", "func CheckFileOrDirectoryExists(path string) bool {\n\tif _, err := os.Stat(path); os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func FileOrDirExist(p string) bool {\n\t_, err := os.Stat(p)\n\treturn err == nil\n}", "func PassDirExists() (bool, error) {\n\td, err := GetPassDir()\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tdirInfo, err := os.Stat(d)\n\tif err == nil {\n\t\tif !dirInfo.IsDir() {\n\t\t\treturn true, nil\n\t\t}\n\t} else {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn false, nil\n\t\t}\n\t}\n\treturn false, err\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\treturn !os.IsNotExist(err)\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\treturn !os.IsNotExist(err)\n}", "func Exists(name string) bool {\n if _, err := os.Stat(name); err != nil {\n if os.IsNotExist(err) {\n return false\n }\n }\n return true\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil { return true, nil }\n\tif os.IsNotExist(err) { return false, nil }\n\treturn true, err\n}", "func CheckDir(d string) CheckFn {\n\treturn func(logger LogFn) error {\n\t\tif fi, err := os.Stat(d); err == nil {\n\t\t\tif fi.Mode().IsDir() {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\treturn errors.ErrFileNotDir\n\t}\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\treturn err == nil || os.IsExist(err)\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn false\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn false\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn true, err\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn true, err\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn true, err\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn true, err\n}", "func IsDirEmpty(name string) bool {\n\n\texist := false\n\n\tf, err := os.Open(name)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer f.Close()\n\n\t_, err = f.Readdirnames(1) // Or f.Readdir(1)\n\tif err == io.EOF {\n\t\texist = true\n\t}\n\treturn exist // Either not empty or error, suits both cases\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func checkDir(dataDir string) {\n\tif !fsutil.IsDir(dataDir) {\n\t\tprintError(\"Target %s is not a directory\", dataDir)\n\t\tos.Exit(1)\n\t}\n\n\tif !fsutil.IsExist(dataDir) {\n\t\tprintError(\"Directory %s is not exist\", dataDir)\n\t\tos.Exit(1)\n\t}\n\n\tif !fsutil.IsReadable(dataDir) {\n\t\tprintError(\"Directory %s is not readable\", dataDir)\n\t\tos.Exit(1)\n\t}\n\n\tif !fsutil.IsExecutable(dataDir) {\n\t\tprintError(\"Directory %s is not exectable\", dataDir)\n\t\tos.Exit(1)\n\t}\n\n\tif arg.GetS(ARG_OUTPUT) == \"\" && !fsutil.IsWritable(dataDir) {\n\t\tprintError(\"Directory %s is not writable\", dataDir)\n\t\tos.Exit(1)\n\t}\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err != nil {\n\t\tif os.IsExist(err) {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\treturn true\n}", "func FileExistsAndDir(path string) bool {\n\tf, err := os.Stat(path)\n\tif os.IsNotExist(err) {\n return false\n\t}\n\treturn f.IsDir()\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\tpanic(err)\n}", "func fileExists(path string) bool {\n _, err := os.Stat(path)\n return err == nil\n}", "func Exists(fname string) bool {\n if _, err := os.Stat(fname); os.IsNotExist(err) {\n return false\n }\n return true\n}", "func exists(name string) bool {\n if _, err := os.Stat(name); err != nil {\n if os.IsNotExist(err) {\n return false\n }\n }\n return true\n}" ]
[ "0.8022152", "0.7980696", "0.7967961", "0.79369617", "0.79153675", "0.7788843", "0.775478", "0.7736916", "0.771233", "0.7554062", "0.74997157", "0.74757224", "0.7441968", "0.74419415", "0.7429944", "0.7408777", "0.7405653", "0.7399855", "0.73931146", "0.738378", "0.73702705", "0.73509467", "0.7278587", "0.72699887", "0.7267767", "0.7225283", "0.72132534", "0.72083265", "0.7189487", "0.7186952", "0.7175301", "0.7175088", "0.71746504", "0.71422434", "0.71357465", "0.71132386", "0.7096954", "0.70958066", "0.7081585", "0.7069137", "0.70679224", "0.70642513", "0.70639706", "0.7054632", "0.70349336", "0.70282215", "0.7007915", "0.7000677", "0.69881", "0.69739264", "0.6973322", "0.6940277", "0.6939262", "0.6937821", "0.69376993", "0.69283056", "0.6923711", "0.6862343", "0.68606824", "0.6848571", "0.6845532", "0.6834958", "0.68324", "0.6824448", "0.68218166", "0.682013", "0.68020135", "0.68020135", "0.68020135", "0.6786597", "0.67643964", "0.67586863", "0.67524934", "0.6752103", "0.6752103", "0.674646", "0.67428505", "0.6742728", "0.67397636", "0.67375356", "0.67375356", "0.6736773", "0.6736773", "0.6736773", "0.6736773", "0.6736773", "0.6732725", "0.6732725", "0.6732725", "0.6732725", "0.67308956", "0.6721724", "0.6721724", "0.67209476", "0.6716147", "0.66976744", "0.66956156", "0.668037", "0.66782564", "0.6677565" ]
0.78437215
5
this function is used to get the schedule string using the path to the file parameters: name (a string containing the path to a file), port (a string of the port to be used) returns: ss (the generated schedule string)
func getScheduleString(name string, port string) string { dir, _ := os.Getwd() absPath := []byte(dir + "/" + name) ss := makePostRequest(fmt.Sprintf("http://localhost%s/schedule", port), bytes.NewBuffer(absPath)) return ss }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getScheduleString(name string, port string) string {\n\tdir, _ := os.Getwd()\n\tabsPath := []byte(dir + \"/\" + name)\n\tss := makePostRequest(fmt.Sprintf(\"http://localhost%s/schedule\", port), bytes.NewBuffer(absPath))\n\treturn ss\n}", "func (client ScheduleClient) RequestSchedule(date string) ([]byte, error) {\n\trequestURL := client.Config.BaseURL + date + \".xml\"\n\trequest, _ := http.NewRequest(\"GET\", requestURL, nil)\n\trequest.Header.Add(\"authorization\", encodeAsBasicAuth(client.Config.User, client.Config.Password))\n\tlog.Println(\"executing request to \" + requestURL)\n\tresp, respErr := client.Client.Do(request)\n\tif respErr != nil {\n\t\tlog.Println(respErr.Error())\n\t\treturn nil, errors.New(\"HTTP Error: \" + respErr.Error())\n\t}\n\tdata, parseBodyErr := ioutil.ReadAll(resp.Body)\n\tif parseBodyErr == nil {\n\t\treturn data, nil\n\t} \n\treturn nil, errors.New(\"Parse Response Body Error: \" + parseBodyErr.Error())\n}", "func (*Schedule) Descriptor() ([]byte, []int) {\n\treturn file_proto_common_proto_rawDescGZIP(), []int{3}\n}", "func CreateSchedulePath() string {\n\treturn \"/schedule\"\n}", "func (o *SnapmirrorCreateRequest) Schedule() string {\n\tvar r string\n\tif o.SchedulePtr == nil {\n\t\treturn r\n\t}\n\tr = *o.SchedulePtr\n\treturn r\n}", "func getMessageFromSchedule() (string, error) {\n\tmsg := \"\"\n\tbyteValue, err := ioutil.ReadFile(\"./schedule.json\")\n\tif err != nil {\n\t\treturn msg, err\n\t}\n\n\ttype Schedule []struct {\n\t\tDay int `json:\"day\"`\n\t\tMessage string `json:\"message\"`\n\t}\n\n\tvar schedule Schedule\n\terr = json.Unmarshal(byteValue, &schedule)\n\tif err != nil {\n\t\treturn msg, err\n\t}\n\ttoday := int(time.Now().Weekday())\n\n\t// My week starts from monday\n\tif today == 0 {\n\t\ttoday = 7\n\t}\n\n\tfor _, day := range schedule {\n\t\tif day.Day == today {\n\t\t\treturn day.Message, nil\n\t\t}\n\t}\n\n\treturn msg, nil\n}", "func (o ArgoCDExportSpecOutput) Schedule() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ArgoCDExportSpec) *string { return v.Schedule }).(pulumi.StringPtrOutput)\n}", "func (*Schedules) Descriptor() ([]byte, []int) {\n\treturn file_src_nap_nap_proto_rawDescGZIP(), []int{10}\n}", "func genFileName(t *time.Time) string {\r\n\tfilename := \"2A-\" + t.Format(layout)\r\n\treturn filename + \".txt\"\r\n}", "func (*CronSchedule) Descriptor() ([]byte, []int) {\n\treturn file_toit_model_job_proto_rawDescGZIP(), []int{19}\n}", "func FileName(createTime time.Time) string {\n\t// Copied from https://github.com/dyweb/dy-bot/blob/2fedb230d6ba21f0ebb9f1091f27d8482c331772/pkg/util/weeklyutil/weekly.go#L11\n\tsecondsEastOfUTC := int((8 * time.Hour).Seconds())\n\tbeijing := time.FixedZone(\"Beijing Time\", secondsEastOfUTC)\n\n\tcfg := now.Config{\n\t\tWeekStartDay: time.Monday,\n\t\tTimeLocation: beijing,\n\t}\n\tdate := cfg.With(createTime).BeginningOfWeek()\n\treturn fmt.Sprintf(\"%d/%d-%.2d-%.2d-weekly.md\", date.Year(), date.Year(), int(date.Month()), date.Day())\n}", "func (*Schedule) Descriptor() ([]byte, []int) {\n\treturn file_src_grpc_pipeline_proto_rawDescGZIP(), []int{2}\n}", "func ListSchedulePath() string {\n\treturn \"/schedule\"\n}", "func (a BuildBlock) openScFile() *string {\n\tvar err error\n\tvar f []byte\n\tf, err = ioutil.ReadFile(a.runpath + a.Filename + a.Extension)\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"Cannot open script file: %s\\n\", err)\n\t\treturn nil\n\t}\n\tfile := string(f)\n\treturn &file\n}", "func restGetScheduleByName(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tn, err := url.QueryUnescape(vars[NAME])\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusServiceUnavailable)\n\t\tLoggingClient.Error(err.Error(), \"\")\n\t\treturn\n\t}\n\n\tvar res models.Schedule\n\terr = dbClient.GetScheduleByName(&res, n)\n\tif err != nil {\n\t\tif err == db.ErrNotFound {\n\t\t\thttp.Error(w, \"Schedule not found\", http.StatusNotFound)\n\t\t\tLoggingClient.Error(\"Schedule not found: \"+err.Error(), \"\")\n\t\t} else {\n\t\t\thttp.Error(w, err.Error(), http.StatusServiceUnavailable)\n\t\t\tLoggingClient.Error(\"Problem getting schedule: \"+err.Error(), \"\")\n\t\t}\n\n\t\treturn\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(res)\n}", "func (schedule *HumanReadableSchedule) String() string{\n format := \"3:04 PM\"\n var scheduleString string\n for dayNum, dailyOpenHours := range schedule {\n scheduleString += dayStrings[dayNum] + \": \"\n for _,openHours := range dailyOpenHours {\n scheduleString += openHours.StartTime.Format(format) + \" - \" + openHours.EndTime.Format(format)\n }\n scheduleString += \"\\n\"\n\n }\n \n return scheduleString\n}", "func (o ArgoCDExportSpecPtrOutput) Schedule() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ArgoCDExportSpec) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Schedule\n\t}).(pulumi.StringPtrOutput)\n}", "func (o DataSourceOutput) Schedule() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *DataSource) pulumi.StringPtrOutput { return v.Schedule }).(pulumi.StringPtrOutput)\n}", "func getSrc(params *input.Params) string {\n\treturn fmt.Sprintf(SRC_PATH, params.ProjectName)\n}", "func getFilename(now *time.Time) string {\n\thour, _, _ := now.Clock()\n\tvar buf [2]byte\n\tbuf[1] = digits[hour%10]\n\thour /= 10\n\tbuf[0] = digits[hour]\n\treturn string(buf[:]) + \".log\"\n}", "func (l *RemoteProvider) GetSchedule(req *http.Request, scheduleID string) ([]byte, error) {\n\tif !l.Capabilities.IsSupported(PersistSchedules) {\n\t\tlogrus.Error(\"operation not available\")\n\t\treturn nil, ErrInvalidCapability(\"PersistSchedules\", l.ProviderName)\n\t}\n\n\tep, _ := l.Capabilities.GetEndpointForFeature(PersistSchedules)\n\n\tlogrus.Infof(\"attempting to fetch schedule from cloud for id: %s\", scheduleID)\n\n\tremoteProviderURL, _ := url.Parse(fmt.Sprintf(\"%s%s/%s\", l.RemoteProviderURL, ep, scheduleID))\n\tlogrus.Debugf(\"constructed schedule url: %s\", remoteProviderURL.String())\n\tcReq, _ := http.NewRequest(http.MethodGet, remoteProviderURL.String(), nil)\n\n\ttokenString, err := l.GetToken(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresp, err := l.DoRequest(cReq, tokenString)\n\tif err != nil {\n\t\treturn nil, ErrFetch(err, \"Perf Schedule :\"+scheduleID, resp.StatusCode)\n\t}\n\tdefer func() {\n\t\t_ = resp.Body.Close()\n\t}()\n\tbdr, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, ErrDataRead(err, \"Perf Schedule :\"+scheduleID)\n\t}\n\n\tif resp.StatusCode == http.StatusOK {\n\t\tlogrus.Infof(\"schedule successfully retrieved from remote provider\")\n\t\treturn bdr, nil\n\t}\n\treturn nil, ErrFetch(err, fmt.Sprint(bdr), resp.StatusCode)\n}", "func Schedule(date string) time.Time {\n\ts, err := time.Parse(\"1/2/2006 15:04:05\", date)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn s\n}", "func (r *ScheduledAction) Schedule() pulumi.StringOutput {\n\treturn (pulumi.StringOutput)(r.s.State[\"schedule\"])\n}", "func (*CrawlScheduleConfig) Descriptor() ([]byte, []int) {\n\treturn file_config_v1_resources_proto_rawDescGZIP(), []int{10}\n}", "func (o *Job) GetSchedule() string {\n\tif o == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\n\treturn o.Schedule\n}", "func Schedule(date string) time.Time {\n\tlayout := \"1/2/2006 15:04:05\"\n\treturn ConvertToTime(layout, date)\n}", "func (e *CronJob) effectiveSchedule() string {\n\tif e.Paused {\n\t\treturn \"manual\"\n\t}\n\treturn e.Schedule\n}", "func statsAPIScheduleURL(time time.Time) string {\n\thost := \"https://statsapi.mlb.com\"\n\tpath := \"/api/v1/schedule\"\n\tquery := \"?language=en&sportId=1&hydrate=game(content(summary,media(epg))),linescore(runners),flags,team,review&date=\"\n\tmonth := time.Format(\"01\")\n\tday := time.Format(\"02\")\n\tyear := time.Format(\"2006\")\n\treturn host + path + query + month + \"/\" + day + \"/\" + year\n}", "func (*ScheduleServer) Descriptor() ([]byte, []int) {\n\treturn file_msgType_proto_rawDescGZIP(), []int{23}\n}", "func executeSchedule(resp http.ResponseWriter, request *http.Request) {\n\tcors := handleCors(resp, request)\n\tif cors {\n\t\treturn\n\t}\n\n\tlocation := strings.Split(request.URL.String(), \"/\")\n\tvar workflowId string\n\n\tif location[1] == \"api\" {\n\t\tif len(location) <= 4 {\n\t\t\tresp.WriteHeader(401)\n\t\t\tresp.Write([]byte(`{\"success\": false}`))\n\t\t\treturn\n\t\t}\n\n\t\tworkflowId = location[4]\n\t}\n\n\tif len(workflowId) != 32 {\n\t\tresp.WriteHeader(401)\n\t\tresp.Write([]byte(`{\"success\": false, \"message\": \"ID not valid\"}`))\n\t\treturn\n\t}\n\n\tctx := context.Background()\n\tlog.Printf(\"EXECUTING %s!\", workflowId)\n\tidConfig, err := getSchedule(ctx, workflowId)\n\tif err != nil {\n\t\tlog.Printf(\"Error getting schedule: %s\", err)\n\t\tresp.WriteHeader(401)\n\t\tresp.Write([]byte(fmt.Sprintf(`{\"success\": false, \"reason\": \"%s\"}`, err)))\n\t\treturn\n\t}\n\n\t// Basically the src app\n\tinputStrings := map[string]string{}\n\tfor _, item := range idConfig.Translator {\n\t\tif item.Dst.Required == \"false\" {\n\t\t\tlog.Println(\"Skipping not required\")\n\t\t\tcontinue\n\t\t}\n\n\t\tif item.Src.Name == \"\" {\n\t\t\terrorMsg := fmt.Sprintf(\"Required field %s has no source\", item.Dst.Name)\n\t\t\tlog.Println(errorMsg)\n\t\t\tresp.WriteHeader(401)\n\t\t\tresp.Write([]byte(fmt.Sprintf(`{\"success\": false, \"reason\": \"%s\"}`, errorMsg)))\n\t\t\treturn\n\t\t}\n\n\t\tinputStrings[item.Dst.Name] = item.Src.Name\n\t}\n\n\tconfigmap := map[string]string{}\n\tfor _, config := range idConfig.AppInfo.SourceApp.Config {\n\t\tconfigmap[config.Key] = config.Value\n\t}\n\n\t// FIXME - this wont work for everything lmao\n\tfunctionName := strings.ToLower(idConfig.AppInfo.SourceApp.Action)\n\tfunctionName = strings.Replace(functionName, \" \", \"_\", 10)\n\n\tcmdArgs := []string{\n\t\tfmt.Sprintf(\"%s/%s/app.py\", baseAppPath, \"thehive\"),\n\t\tfmt.Sprintf(\"--referenceid=%s\", workflowId),\n\t\tfmt.Sprintf(\"--function=%s\", functionName),\n\t}\n\n\tfor key, value := range configmap {\n\t\tcmdArgs = append(cmdArgs, fmt.Sprintf(\"--%s=%s\", key, value))\n\t}\n\n\t// FIXME - processname\n\tbaseProcess := \"python3\"\n\tlog.Printf(\"Executing: %s %s\", baseProcess, strings.Join(cmdArgs, \" \"))\n\texecSubprocess(baseProcess, cmdArgs)\n\n\tresp.WriteHeader(200)\n\tresp.Write([]byte(`{\"success\": true}`))\n}", "func scheduleFutureMessage(filename string, t time.Time) (err error) {\n\t//TODO actually implement this\n\tuniq := uniqueFromFilename(filename)\n\tlog.Print(uniq)\n\n\treturn nil\n}", "func getSeasonName ( slotFile string ) ( string, string ) {\n\n//\tAirport Code and Season Name precede the Season Dates\n\t\n\tbeforeDates := strings.Split ( slotFile, \"(\" )\n\t\n\tfirst := \"\"\n\tfor _, part := range beforeDates { \n\t\n\t\tfirst = part\t\t// Converts slice to string\n\t\tbreak\n\t}\n\t\n\tairportCode := first[0:3]\n\n\tseasonName := first[3:]\n\tseasonName = strings.TrimSpace( seasonName )\n\t\n\treturn airportCode, seasonName\n}", "func (c *DetaClient) GetSchedule(req *GetScheduleRequest) (*GetScheduleResponse, error) {\n\ti := &requestInput{\n\t\tPath: fmt.Sprintf(\"/schedules/%s\", req.ProgramID),\n\t\tMethod: \"GET\",\n\t\tNeedsAuth: true,\n\t}\n\n\to, err := c.request(i)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif o.Status == 404 {\n\t\treturn nil, nil\n\t}\n\n\tif o.Status != 200 {\n\t\tmsg := o.Error.Message\n\t\tif msg == \"\" {\n\t\t\tmsg = o.Error.Errors[0]\n\t\t}\n\t\treturn nil, fmt.Errorf(\"failed to get schedule: %v\", msg)\n\t}\n\n\tvar resp GetScheduleResponse\n\terr = json.Unmarshal(o.Body, &resp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resp, nil\n}", "func LogSchInit() *os.File {\n\n\tfile, err := os.OpenFile(\"../log_schedular.txt\", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)\n\tif err != nil {\n\t\tfmt.Println(\"Error opening log.txt file\", err)\n\t\tos.Exit(1)\n\t}\n\treturn file\n}", "func GenerateSchedule(w http.ResponseWriter, r *http.Request) {\n\tdata := &ScheduleRequest{}\n\tif err := render.Bind(r, data); err != nil {\n\t\trender.Render(w, r, ErrInvalidRequest(err))\n\t\treturn\n\t}\n\tstart, wksPSeason, nSeason, participants := data.Start, data.SeasonUnits, data.Years, data.Participants\n\ts, err := jdscheduler.NewSchedule(start, nSeason, wksPSeason, participants)\n\tif err != nil {\n\t\trender.Render(w, r, ErrInvalidRequest(err))\n\t\treturn\n\t}\n\trender.Status(r, http.StatusOK)\n\trender.Render(w, r, NewScheduleResponse(*s))\n}", "func (c Calendars) configPath() (string, error) {\n\tconfDir, err := configDirectory()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn filepath.Join(confDir, \"calendars.txt\"), nil\n}", "func (e *CronJob) parseSchedule() (*schedule.Schedule, error) {\n\tif e.cachedSchedule == nil && e.cachedScheduleErr == nil {\n\t\thash := fnv.New64()\n\t\thash.Write([]byte(e.JobID))\n\t\tseed := hash.Sum64()\n\t\te.cachedSchedule, e.cachedScheduleErr = schedule.Parse(e.effectiveSchedule(), seed)\n\t\tif e.cachedSchedule == nil && e.cachedScheduleErr == nil {\n\t\t\tpanic(\"no schedule and no error\")\n\t\t}\n\t}\n\treturn e.cachedSchedule, e.cachedScheduleErr\n}", "func generateModularDailyCronSchedule(input []byte) string {\n\ta := big.NewInt(0).SetBytes(input)\n\tvar hi, mi big.Int\n\tm := mi.Mod(a, big.NewInt(60))\n\th := hi.Mod(a, big.NewInt(24))\n\treturn fmt.Sprintf(\"%d %d * * *\", m.Int64(), h.Int64())\n}", "func getUTCFile(address, folderPath string) (string, error) {\n\t// Compile the regex expresion\n\tlibRegEx, err := regexp.Compile(\"(?i).*\" + address)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Get all the files of the folder\n\tfiles, err := ioutil.ReadDir(folderPath)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Get the name of the file that matches the expression\n\tfor _, f := range files {\n\t\tif libRegEx.MatchString(f.Name()) {\n\t\t\treturn folderPath + f.Name(), nil\n\t\t}\n\t}\n\n\treturn \"\", errors.New(\"UTC File not found\")\n}", "func resolveSchedule(cal *v1alpha1.CalendarEventSource) (cronlib.Schedule, error) {\n\tif cal.Schedule != \"\" {\n\t\t// standard cron expression\n\t\tspecParser := cronlib.NewParser(cronlib.Minute | cronlib.Hour | cronlib.Dom | cronlib.Month | cronlib.Dow)\n\t\tschedule, err := specParser.Parse(cal.Schedule)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Errorf(\"failed to parse schedule %s from calendar event. Cause: %+v\", cal.Schedule, err.Error())\n\t\t}\n\t\treturn schedule, nil\n\t}\n\tif cal.Interval != \"\" {\n\t\tintervalDuration, err := time.ParseDuration(cal.Interval)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Errorf(\"failed to parse interval %s from calendar event. Cause: %+v\", cal.Interval, err.Error())\n\t\t}\n\t\tschedule := cronlib.ConstantDelaySchedule{Delay: intervalDuration}\n\t\treturn schedule, nil\n\t}\n\treturn nil, errors.New(\"calendar event must contain either a schedule or interval\")\n}", "func CreateRequest(sFileName string) []string {\n\tvar sAFileNames []string\n\tsFileNameNameOnly := filepath.Base(sFileName)[:len(filepath.Base(sFileName))-len(filepath.Ext(sFileName))]\n\n\tvar tmEvntRqsts Request\n\tvar tmEvnts []TimeEvent\n\tintNumberOfFiles := 1\n\tintNumberOfLines := 0\n\tintChunkLines := 0\n\n\tf, error := os.Open(sFileName)\n\tif error != nil {\n\t\tlog.Fatal(error)\n\t}\n\tdefer f.Close()\n\tr := csv.NewReader(bufio.NewReader(f))\n\thdrData, error := r.Read()\n\tif error != nil {\n\t\tlog.Fatal(error)\n\t}\n\tmetaHdrTmEnvt := getMetaTimeEvent(sFileName, hdrData)\n\tcurTime := time.Now().Format(\"20060102150405\")\n\tfor {\n\t\tfileData, error := r.Read()\n\t\tif error == io.EOF {\n\t\t\tbreak\n\t\t} else if error != nil {\n\t\t\tlog.Fatal(error)\n\t\t}\n\t\ttmEvnts = append(tmEvnts, populateTimeEvent(fileData, metaHdrTmEnvt))\n\t\tstrRequestNumber := curTime + \"_\" + strconv.Itoa(intNumberOfFiles)\n\t\t// retrieve all the values from line and populate the structure\n\t\ttmEvntRqsts = Request{\n\t\t\tRequestNumber: strRequestNumber,\n\t\t\tSourceID: fileData[metaHdrTmEnvt.SOURCEID],\n\t\t\tRequestTimeStamp: fileData[metaHdrTmEnvt.REQUESTTIMESTAMP],\n\t\t\tTimeEvents: tmEvnts,\n\t\t}\n\t\tintNumberOfLines++\n\t\tintChunkLines++\n\t\tif intChunkLines == Context.Config.ChunkSize {\n\t\t\tsFileName = filepath.Join(Context.Config.Folders.Wrkg, Context.Config.UUID, \"requests\", \"timeEvents\", sFileNameNameOnly+\"_\"+strconv.Itoa(intNumberOfFiles)+\".json\")\n\t\t\tsAFileNames = append(sAFileNames, sFileName)\n\t\t\tfmt.Println(intNumberOfFiles, \"->\", filepath.Base(writeTimeEventsToFile(tmEvntRqsts, sFileName)), \"->\", intChunkLines)\n\t\t\tintNumberOfFiles++\n\t\t\tintChunkLines = 0\n\t\t\ttmEvnts = make([]TimeEvent, 0)\n\t\t}\n\t}\n\tif intChunkLines < Context.Config.ChunkSize && intChunkLines != 0 {\n\t\tsFileName = filepath.Join(Context.Config.Folders.Wrkg, Context.Config.UUID, \"requests\", \"timeEvents\", sFileNameNameOnly+\"_\"+strconv.Itoa(intNumberOfFiles)+\".json\")\n\t\tsAFileNames = append(sAFileNames, sFileName)\n\t\tfmt.Println(intNumberOfFiles, \"->\", filepath.Base(writeTimeEventsToFile(tmEvntRqsts, sFileName)), \"->\", intChunkLines)\n\t}\n\treturn sAFileNames\n}", "func schedule(k string, t TaskRecord, q Queue, c Cache) (string, error) {\n t.SetScheduled()\n str, _ := t.ToString()\n _, cErr := c.Set(k, str)\n if cErr != nil {\n return k, fmt.Errorf(\"set cache returned error: %v\", cErr)\n }\n _, qErr := q.Push(str)\n if qErr != nil {\n return k, fmt.Errorf(\"push queue returned error: %v\", qErr)\n }\n\n return k, nil\n}", "func (o CrawlerOutput) Schedule() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *Crawler) pulumi.StringPtrOutput { return v.Schedule }).(pulumi.StringPtrOutput)\n}", "func getFilePath() string {\n\t_, filename, _, _ := runtime.Caller(1)\n\treturn path.Join(path.Dir(filename), \"/ratelimiter.lua\")\n}", "func Schedule(runtime string, imageNum int, app string, version string, all bool) []byte {\n\tvar (\n\t\toutput []byte\n\t\tactTimeLog *TimeLog\n\t\tisDeployed bool\n\t)\n\ttransferTimes := GetTransferTime(imageNum)\n\n\t// Redefine the selected runtime every selection\n\tselectedRuntimes := []string{}\n\tselectedRuntime, predTimeLog := SelectRunTime(imageNum, app, version, runtime)\n\tfmt.Printf(\"The task is scheduled at %s \\n\", selectedRuntime)\n\tfmt.Printf(\"The bandwidth is %f megabits \\n\", GetBandWidth())\n\tfmt.Printf(\"The batch of %d images needs %f seconds to transfer to runtime %s\\n\",\n\t\timageNum, transferTimes[selectedRuntime], selectedRuntime)\n\n\tif all {\n\t\tfor runtime, isAvail := range runtimes {\n\t\t\tif isAvail {\n\t\t\t\tselectedRuntimes = append(selectedRuntimes, runtime)\n\t\t\t}\n\t\t}\n\t}\n\tselectedRuntimes = append(selectedRuntimes, selectedRuntime)\n\n\tfor _, runtime := range selectedRuntimes {\n\t\t_, predTimeLog = SelectRunTime(imageNum, app, version, runtime)\n\n\t\tretryErr := retrygo.Do(\n\t\t\tfunc() error {\n\t\t\t\toutput, isDeployed, actTimeLog = Request(runtime, imageNum, app, version, transferTimes[runtime])\n\t\t\t\truntimes[runtime] = isDeployed\n\t\t\t\tif !isDeployed {\n\t\t\t\t\treturn errors.New(\"request was not deployed\")\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t},\n\t\t)\n\t\tif retryErr != nil {\n\t\t\tfmt.Printf(\"Request failed: %v ...\", retryErr.Error())\n\t\t}\n\t\tif actTimeLog != nil {\n\t\t\tactTimeLog.Transfer = transferTimes[runtime]\n\t\t}\n\t\tif actTimeLog != nil && actTimeLog.Processing != 0.0 {\n\t\t\tAppendRecordProcessing(dbName, runtime, imageNum, actTimeLog.Processing, app, version)\n\t\t\t//For setup regressions, the prediction is based on preset coef & intercept\n\t\t\tLogTimes(imageNum, app, version, runtime, predTimeLog, actTimeLog)\n\t\t}\n\t}\n\n\treturn output\n}", "func (*LegoPort) Path() string { return filepath.Join(prefix, LegoPortPath) }", "func rewrite_randomSched(origpath,newpath string, criticalPoints []*ConcurrencyUsage) []string{\n // Variables\n var astfiles []*ast.File\n var ret []string\n\tvar conf loader.Config\n\tvar concfiles []string\n\n // extract aux data\n conclines := make(map[string]int) // extract concurrency lines\n _concfiles := make(map[string]int) // extract concurrency files\n\n for _,c := range(criticalPoints){\n\t\tif c.Type == NBCASE{ // we do not want to inject delay before NB_Select cases\n\t\t\tcontinue\n\t\t}\n conclines[c.Location.String()]=1\n _concfiles[c.Location.FileName] = 1\n }\n for k,_ := range(_concfiles){\n concfiles = append(concfiles,k)\n }\n\n // load program files\n\tpaths,err := filepath.Glob(origpath+\"/*.go\")\n\tcheck(err)\n\tif _, err := conf.FromArgs(paths, false); err != nil {\n\t\tpanic(err)\n\t}\n prog, err := conf.Load()\n\tcheck(err)\n for _,crt := range(prog.Created){\n for _,ast := range(crt.Files){\n astfiles = append(astfiles,ast)\n }\n }\n\n // for all ast files in the package\n // add import github.com/staheri/goat/goat\n // inject goat.Sched_Handler to concurrency lines (astutil.Apply)\n // inject goat.Sched_Handler to range (astutil.Inspect)\n // for main/test:\n // add (at the beginning) GOAT_done := goat.Start()\n\t// add (at the beginning) go goat.Finish(GOAT_done,10)\n\n for _,astFile := range(astfiles){\n\n // check if this file has concurrency usage\n if contains(concfiles,prog.Fset.Position(astFile.Package).Filename){ // add import\n astutil.AddImport(prog.Fset, astFile, \"github.com/staheri/goat/goat\")\n }\n // add schedcalls wherever concusage\n astutil.Apply(astFile, func(cr *astutil.Cursor) bool{\n n := cr.Node()\n if n != nil{\n curloc := prog.Fset.Position(n.Pos()).Filename+\":\"+strconv.Itoa(prog.Fset.Position(n.Pos()).Line)\n if _,ok := conclines[curloc];ok{\n if conclines[curloc] != 1{\n return true\n }\n conclines[curloc] = 2\n // point of injection\n switch x:= n.(type){\n case *ast.DeferStmt:\n ds := n.(*ast.DeferStmt)\n cr.Replace(astNode_convertDefer(ds))\n _ = x\n return true\n }\n cr.InsertBefore(astNode_sched())\n return true\n }\n }\n return true\n },nil)\n\n // for range statement, all concusage\n ast.Inspect(astFile, func(n ast.Node) bool {\n switch x := n.(type){\n case *ast.RangeStmt:\n newCall := astNode_sched()\n x.Body.List = append(x.Body.List,newCall)\n return true\n }\n return true\n })\n\n // add other injections only to main/test file\n if mainIn(astFile) || testIn(astFile){\n\n // add gomaxprocs and trace start/stop code\n \tast.Inspect(astFile, func(n ast.Node) bool {\n \t\tswitch x := n.(type) {\n \t\tcase *ast.FuncDecl:\n \t\t\t// find 'main' function\n \t\t\tif x.Name.Name == \"main\" && x.Recv == nil {\n toAdd := astNode_goatMain()\n stmts := []ast.Stmt{toAdd[0]}\n stmts = append(stmts,toAdd[1])\n stmts = append(stmts,toAdd[2])\n\t\t\t\t\t\tstmts = append(stmts,x.Body.List...)\n x.Body.List = stmts\n \t\t\t\treturn true\n \t\t\t}else if strings.HasPrefix(x.Name.Name,\"Test\") && x.Recv == nil{\n toAdd := astNode_goatMain()\n stmts := []ast.Stmt{toAdd[0]}\n stmts = append(stmts,toAdd[1])\n stmts = append(stmts,toAdd[2])\n\t\t\t\t\t\tstmts = append(stmts,x.Body.List...)\n x.Body.List = stmts\n \t\t\t\treturn true\n }\n \t\t}\n \t\treturn true\n \t})\n } // end for main\n\n // write files\n var buf bytes.Buffer\n \terr := printer.Fprint(&buf, prog.Fset, astFile)\n \tcheck(err)\n filename := filepath.Join(newpath, strings.Split(filepath.Base(prog.Fset.Position(astFile.Pos()).Filename),\".\")[0]+\".go\")\n err = ioutil.WriteFile(filename, buf.Bytes(), 0666)\n check(err)\n ret = append(ret,filename)\n }\n return ret\n}", "func (m *TeamItemRequestBuilder) Schedule()(*ifd53534f50d40567e607c2213e794582e29aa46a0c07e2d406db231a42a0140a.ScheduleRequestBuilder) {\n return ifd53534f50d40567e607c2213e794582e29aa46a0c07e2d406db231a42a0140a.NewScheduleRequestBuilderInternal(m.pathParameters, m.requestAdapter);\n}", "func (o AppProjectSpecSyncWindowsOutput) Schedule() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v AppProjectSpecSyncWindows) *string { return v.Schedule }).(pulumi.StringPtrOutput)\n}", "func (s *Schedule) Load() {\r\n\tb, _ := ioutil.ReadFile(s.fileName)\r\n\tjson.Unmarshal(b, &s.ScheduleMap)\r\n}", "func getProcName(path string) string {\n\tnamepath := filepath.Join(path, \"stat\")\n\tstatp, err := ioutil.ReadFile(namepath)\n\tif err != nil {\n\t\t// fmt.Printf(\"error reading stat [%v]\\n\", err)\n\t\treturn \"\"\n\t}\n\tmatch := namergx.FindStringSubmatch(string(statp))\n\tif len(match) < 2 {\n\t\treturn \"\"\n\t}\n\treturn match[1]\n}", "func renameFile(pmConfig config.PMConfig) (string, error) {\n\toffset := \"0000\"\n\tcurrentTime := time.Now().UTC()\n\t//calculating 15 minutes time frame\n\tdiff := currentTime.Minute() - (currentTime.Minute() / 15 * 15)\n\tbegTime := currentTime.Add(time.Duration(-1*diff) * time.Minute)\n\tendTime := begTime.Add(time.Duration(15) * time.Minute)\n\n\tfileName := pmConfig.DestinationDir + \"/\"\n\tfileName += filePrefix + begTime.Format(dateFormat) + \".\" + begTime.Format(timeFormat) + \"-\" + offset\n\tfileName += \"-\" + endTime.Format(timeFormat) + \"-\" + offset\n\tfileName += \"_\" + pmConfig.ForeignID\n\tcounter := 1\n\tname := fileName\n\tfor fileExists(name) {\n\t\tname = fileName + \"_\" + strconv.Itoa(counter)\n\t\tcounter++\n\t}\n\tfileName = name\n\treturn fileName, nil\n}", "func (s Scheduler) Schedule(t TaskRecord) (string, error) {\n key := buildTaskKey(t)\n old, _ := s.Cache.Get(key)\n sched := false\n var oldTsk TaskRecord\n var err error\n\n if old == \"\" {\n sched = true\n } else {\n oldTsk, _ = ParseTask(old)\n if oldTsk.CanReschedule() {\n sched = true\n } else {\n err = errors.New(\"A Task with the submitted ID and UID [\" + oldTsk.ID + \", \" + oldTsk.UID + \"] is being processed\")\n }\n }\n\n if sched {\n return schedule(key, t, s.Queue, s.Cache)\n } else {\n return key, err\n }\n}", "func generateFilePath(currentAccount *int, fileName string) (string, error) {\n\tutcNow := time.Now().UTC()\n\tdatetimeValue := utcNow.Format(\"2006_01_02__15_04_05 \")\n\tbuff := make([]byte, 32)\n\t_, err := rand.Read(buff)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\thexString := fmt.Sprintf(\"%x\", buff)\n\tfileExtension := fileName[strings.LastIndex(fileName, \".\")+1 : len(fileName)]\n\treturn fmt.Sprintf(\"./file/image/%s__%d__%s.%s\", datetimeValue, currentAccount, hexString, fileExtension), nil\n}", "func getTask(r io.Reader, args ...string) (string, error) {\r\n\tif len(args) > 0 {\r\n\t\treturn strings.Join(args, \" \"), nil\r\n\t}\r\n\r\n\ts := bufio.NewScanner(r)\r\n\ts.Scan()\r\n\tif err := s.Err(); err != nil {\r\n\t\treturn \"\", err\r\n\t}\r\n\tif len(s.Text()) == 0 {\r\n\t\treturn \"\", fmt.Errorf(\"Task cannot be blank\")\r\n\t}\r\n\r\n\treturn s.Text(), nil\r\n}", "func (*ScheduledProgram) Descriptor() ([]byte, []int) {\n\treturn file_proto_common_proto_rawDescGZIP(), []int{4}\n}", "func Schedule(names ...string) ([]window.Schedule, error) {\n\tvar r window.Reader\n\tm, err := window.Windows(auklib.ConfDir, r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(names) == 0 {\n\t\tnames = m.Keys()\n\t}\n\tdeck.Infof(\"Aggregating schedule for label(s): %s\", strings.Join(names, \", \"))\n\tvar out []window.Schedule\n\tfor i := range names {\n\t\tschedules := m.AggregateSchedules(names[i])\n\t\tvar success int64 = 1\n\t\tif len(schedules) == 0 {\n\t\t\tdeck.Errorf(\"no schedule found for label %q\", names[i])\n\t\t\tsuccess = 0\n\t\t\tcontinue\n\t\t}\n\n\t\tmetricName := fmt.Sprintf(\"%s/%s\", auklib.MetricRoot, \"schedule_retrieved\")\n\t\tmetric, err := metrics.NewInt(metricName, auklib.MetricSvc)\n\t\tif err != nil {\n\t\t\tdeck.Warningf(\"could not create metric: %v\", err)\n\t\t}\n\t\tmetric.Data.AddStringField(\"request\", names[i])\n\t\tmetric.Set(success)\n\n\t\tout = append(out, findNearest(schedules))\n\t}\n\treturn out, nil\n}", "func (o *ModelsBackupSchedule) GetSchedule() string {\n\tif o == nil || o.Schedule == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Schedule\n}", "func (s *Server) ScheduleCall(w http.ResponseWriter, r *http.Request) {\n\tvar rooms []*model.Room\n\tif err := s.decode(w, r, &rooms); err != nil {\n\t\ts.error(w, r, err, http.StatusBadRequest)\n\t\treturn\n\t}\n\tif len(rooms) == 0 {\n\t\ts.error(w, r, errors.New(\"No rooms provided\"), http.StatusBadRequest)\n\t\treturn\n\t}\n\t// Validate room details provided\n\tfor _, room := range rooms {\n\t\tif room.RoomNumber == 0 {\n\t\t\ts.error(w, r, fmt.Errorf(\"No room number specified for guest %s %s\", room.Firstname, room.Lastname), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\tif room.Firstname == \"\" {\n\t\t\ts.error(w, r, fmt.Errorf(\"No first name provided for room number %d\", room.RoomNumber), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\tif room.Lastname == \"\" {\n\t\t\ts.error(w, r, fmt.Errorf(\"No last name specified for room number %d\", room.RoomNumber), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\tif room.CallTime == \"\" {\n\t\t\ts.error(w, r, fmt.Errorf(\"No call time specified for room number %d\", room.RoomNumber), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\tif err := validateCallTime(room.CallTime); err != nil {\n\t\t\ts.error(w, r, fmt.Errorf(\"Call time (%s) has incorrect format (must be xx:yy) for room number %d\", room.CallTime, room.RoomNumber), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t}\n\t// Save metadata to Postgres\n\tif err := s.db.AddRooms(rooms); err != nil {\n\t\ts.error(w, r, err, http.StatusInternalServerError)\n\t\treturn\n\t}\n\t// Schedule cron job\n\tif err := s.scheduleJob(rooms); err != nil {\n\t\ts.error(w, r, err, http.StatusInternalServerError)\n\t\treturn\n\t}\n\ts.respond(w, r, rooms, http.StatusOK)\n}", "func (o RefreshScheduleMapOutput) ScheduleId() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v RefreshScheduleMap) *string { return v.ScheduleId }).(pulumi.StringPtrOutput)\n}", "func (ss *StringSchedule) String() string {\n\tfields := []string{\n\t\tcsvOfInts(ss.Seconds, \"*\"),\n\t\tcsvOfInts(ss.Minutes, \"*\"),\n\t\tcsvOfInts(ss.Hours, \"*\"),\n\t\tcsvOfInts(ss.DaysOfMonth, \"*\"),\n\t\tcsvOfInts(ss.Months, \"*\"),\n\t\tcsvOfInts(ss.DaysOfWeek, \"*\"),\n\t\tcsvOfInts(ss.Years, \"*\"),\n\t}\n\treturn strings.Join(fields, \" \")\n}", "func fileSource(filename string, i int) string {\n\treturn fmt.Sprintf(\"%s:%d\", filename, i)\n}", "func createFileName(address string) string {\n\tts := time.Now().UTC()\n\treturn fmt.Sprintf(\"UTC--%s--%s.json\", toISO8601(ts), address)\n}", "func (o *ModelsBackupSchedule) GetScheduleOk() (*string, bool) {\n\tif o == nil || o.Schedule == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Schedule, true\n}", "func GetPath(now time.Time, hostname string, interval uint64) string {\n\t// The directory path where the archive should be written.\n\tdirs := fmt.Sprintf(\"%v/%v\", now.Format(\"2006/01/02\"), hostname)\n\n\t// Calculate the start time, which will be Now() - interval, and then format\n\t// the archive file name based on the calculated values.\n\tstartTime := now.Add(time.Duration(interval) * -time.Second)\n\tstartTimeStr := startTime.Format(\"2006-01-02T15:04:05\")\n\tendTimeStr := now.Format(\"2006-01-02T15:04:05\")\n\tarchiveName := fmt.Sprintf(\"%v-to-%v-switch.json\", startTimeStr, endTimeStr)\n\tarchivePath := fmt.Sprintf(\"%v/%v\", dirs, archiveName)\n\n\treturn archivePath\n}", "func (s *SCIONBoxController) topologyFile(slas *models.SCIONLabAS) string {\n\treturn filepath.Join(TempPath, slas.UserEmail+\"SCIONBox_topology.json\")\n}", "func (o RegistryTaskTimerTriggerOutput) Schedule() pulumi.StringOutput {\n\treturn o.ApplyT(func(v RegistryTaskTimerTrigger) string { return v.Schedule }).(pulumi.StringOutput)\n}", "func schedule(jobName string, mapFiles []string, nReduce int, phase jobPhase, registerChan chan string) {\n\tvar ntasks int\n\tvar n_other int // number of inputs (for reduce) or outputs (for map)\n\tswitch phase {\n\tcase mapPhase:\n\t\tntasks = len(mapFiles)\n\t\tn_other = nReduce\n\n\tcase reducePhase:\n\t\tntasks = nReduce\n\t\tn_other = len(mapFiles)\n\t}\n\n\tfmt.Printf(\"Schedule: %v %v tasks (%d I/Os)\\n\", ntasks, phase, n_other)\n\n\t// All ntasks tasks have to be scheduled on workers. Once all tasks\n\t// have completed successfully, schedule() should return.\n\t//\n\t// Your code here (Part III, Part IV).\n\t//\n\tvar wg sync.WaitGroup\n\t//wg.Add(ntasks)\n\t//for i := 0; i < ntasks; i++ {\n\t//\tworker_addr := <- registerChan\n\t//\tfunc_arg := DoTaskArgs{jobName, mapFiles[i], phase, i, n_other}\n\t//\n\t//\tgo func(worker_addr string, func_arg DoTaskArgs) {\n\t//\t\tdefer wg.Done()\n\t//\t\tfor {\n\t//\t\t\tret := call(worker_addr, \"Worker.DoTask\", func_arg, nil)\n\t//\t\t\tif ret { // 成功返回,否则一直运行到成功为止\n\t//\t\t\t\tgo func(registerChan chan string, worker_addr string) { // 这里要使用goroutine\n\t//\t\t\t\t\tregisterChan <- worker_addr // worker变为可用状态\n\t//\t\t\t\t}(registerChan, worker_addr)\n\t//\t\t\t\tbreak\n\t//\t\t\t}\n\t//\t\t}\n\t//\n\t//\t}(worker_addr, func_arg)\n\t//}\n\n\twg.Add(ntasks)\n\ttaskChan := make(chan int, ntasks)\n\t// 把任务放入任务队列\n\tfor i:=0;i<ntasks;i++ {\n\t\ttaskChan <- i\n\t}\n\n\t// 从worker队列中获取可用的worker,并在一个gorountine中一直占用这个worker\n\t// worker会监测是否有任务需要完成,每取到一个task,就会去执行一次,成功告知WaitGroup,\n\t// 失败将任务返回任务队列\n\tgo func() {\n\t\tfor {\n\t\t\tworker_addr := <- registerChan\n\t\t\tgo func(worker_addr string) {\n\t\t\t\tfor {\n\t\t\t\t\ti := <- taskChan\n\t\t\t\t\tif call(worker_addr,\"Worker.DoTask\", &DoTaskArgs{jobName,\n\t\t\t\t\t\tmapFiles[i],phase,i,n_other},nil){\n\t\t\t\t\t\twg.Done()\n\t\t\t\t\t} else{\n\t\t\t\t\t\ttaskChan <- i\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}(worker_addr)\n\t\t}\n\t}()\n\n\twg.Wait()\n\tfmt.Printf(\"Schedule: %v done\\n\", phase)\n}", "func schedule(jobName string, mapFiles []string, nReduce int, phase jobPhase, registerChan chan string) {\n\tvar ntasks int\n\tvar n_other int // number of inputs (for reduce) or outputs (for map)\n\tswitch phase {\n\tcase mapPhase:\n\t\tntasks = len(mapFiles)\n\t\tn_other = nReduce\n\tcase reducePhase:\n\t\tntasks = nReduce\n\t\tn_other = len(mapFiles)\n\t}\n\n\tfmt.Printf(\"Schedule: %v %v tasks (%d I/Os)\\n\", ntasks, phase, n_other)\n\n\t// All ntasks tasks have to be scheduled on workers. Once all tasks\n\t// have completed successfully, schedule() should return.\n\t//\n\t// Your code here (Part III, Part IV).\n\t//\n\tvar wg sync.WaitGroup\n\tfor i := 0; i < ntasks; i++ {\n\t\twg.Add(1)\n\t\tgo func(taskIndex int) {\n\t\t\tdefer wg.Done()\n\t\t\t// 1. Build DoTaskArgs entity.\n\t\t\tvar args DoTaskArgs\n\t\t\targs.Phase = phase\n\t\t\targs.JobName = jobName\n\t\t\targs.TaskNumber = taskIndex\n\t\t\targs.NumOtherPhase = n_other\n\t\t\tif phase == mapPhase {\n\t\t\t\targs.File = mapFiles[taskIndex]\n\t\t\t}\n\t\t\t// 2. Send DoTaskJob rpc.\n\t\t\tfor { // Note Loop call util success if there exists worker failure.\n\t\t\t\t// 3. Fetch worker from registerChan.\n\t\t\t\t// Note if one worker goes down, it won't be fetched from registerChan.\n\t\t\t\twork := <-registerChan\n\t\t\t\tok := call(work, \"Worker.DoTask\", &args, new(struct{}))\n\t\t\t\tif ok == false {\n\t\t\t\t\tfmt.Printf(\"Master: RPC %s schedule error for %s task %d.\\n\", work, phase, taskIndex)\n\t\t\t\t\tfmt.Printf(\"Master: Redo - RPC schedule error for %s task %d.\\n\", phase, taskIndex)\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Printf(\"Master: RPC %s schedule success for %s task %d.\\n\", work, phase, taskIndex)\n\t\t\t\t\t// 4. Register worker (ready) in parallel to avoid block.\n\t\t\t\t\tgo func() {\n\t\t\t\t\t\tregisterChan <- work\n\t\t\t\t\t}()\n\t\t\t\t\tfmt.Printf(\"Master: %d tasks over!\\n\", taskIndex)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}(i)\n\t}\n\twg.Wait() // Wait for all (ntasks) task to compelete.\n\tfmt.Printf(\"Schedule: %v done\\n\", phase)\n}", "func getPattern(pattern string) []byte {\n\tpatternFileName := pattern + \".json\"\n\tif _, ok := patternMap[patternFileName]; ok {\n\t\treturn patternMap[patternFileName]\n\t}\n\treturn nil\n}", "func (*SDConfig) Name() string { return \"file\" }", "func (m *DetectionRule) GetSchedule()(RuleScheduleable) {\n val, err := m.GetBackingStore().Get(\"schedule\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(RuleScheduleable)\n }\n return nil\n}", "func (o LookupPipelineResultOutput) ScheduleInfo() GoogleCloudDatapipelinesV1ScheduleSpecResponseOutput {\n\treturn o.ApplyT(func(v LookupPipelineResult) GoogleCloudDatapipelinesV1ScheduleSpecResponse { return v.ScheduleInfo }).(GoogleCloudDatapipelinesV1ScheduleSpecResponseOutput)\n}", "func main() {\n\t//flag.Parse()\n\t//帮助信息\n\t//if *h == true {\n\t//\tlib.Usage(\"scanPort version: scanPort/1.10.0\\n Usage: scanPort [-h] [-ip ip地址] [-n 进程数] [-p 端口号范围] [-t 超时时长] [-path 日志保存路径]\\n\\nOptions:\\n\")\n\t//\treturn\n\t//}\n\tfi, _ := os.Open(\"log/host.txt\")\n\tdefer fi.Close()\n\tbr := bufio.NewReader(fi)\n\tfor {\n\t\ta, _, c := br.ReadLine()\n\t\tif c == io.EOF {\n\t\t\tbreak\n\t\t}\n\t\t//fmt.Println(string(a))\n\t\tip = string(a)\n\t\tfmt.Printf(\"========== Start %v ip:%v,port:%v ==================== \\n\", time.Now().Format(\"2006-01-02 15:04:05\"), ip, port)\n\n\t\t//创建目录\n\t\tlib.Mkdir(path)\n\n\t\t//初始化\n\t\tscanIP := scan.ScanIp{\n\t\t\tDebug: true,\n\t\t\tTimeout: timeout,\n\t\t\tProcess: process,\n\t\t}\n\t\t//扫所有的ip\n\t\tfileName := path + \"/\" + ip + \"_port.txt\"\n\t\t//for i := 0; i < len(ips); i++ {\n\t\tports := scanIP.GetIpOpenPort(ip, port)\n\t\tlib.Contrast(ports, fileName, ip)\n\t\tif len(ports) > 0 {\n\t\t\tf, err := os.OpenFile(fileName, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(err)\n\t\t\t}\n\t\t\tvar str = fmt.Sprintf(\"%v \\n\", ports)\n\t\t\tif _, err := f.WriteString(str); err != nil {\n\t\t\t\tif err != nil {\n\t\t\t\t\tfmt.Println(err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//}\n\t\tfmt.Printf(\"========== End %v 总执行时长:%.2fs ================ \\n\", time.Now().Format(\"2006-01-02 15:04:05\"), time.Since(startTime).Seconds())\n\n\t}\n\n}", "func ProjectNameFromPlanfile(workspace string, filename string) (string, error) {\n\tr, err := regexp.Compile(fmt.Sprintf(`(.*?)-%s\\.tfplan`, workspace))\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"compiling project name regex, this is a bug\")\n\t}\n\tprojMatch := r.FindAllStringSubmatch(filename, 1)\n\tif projMatch == nil {\n\t\treturn \"\", nil\n\t}\n\trawProjName := projMatch[0][1]\n\treturn strings.Replace(rawProjName, planfileSlashReplace, \"/\", -1), nil\n}", "func (o *StorageNetAppSnapshotPolicySchedule) GetScheduleNameOk() (*string, bool) {\n\tif o == nil || o.ScheduleName == nil {\n\t\treturn nil, false\n\t}\n\treturn o.ScheduleName, true\n}", "func (s *scpSession) getFile(localFile string) error {\n\t//var err error\n\tvar msg string\n\tvar fields []string\n\n\treader := bufio.NewReader(s.out)\n\n\tbuffer, n, err := s.readMessage(reader)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmsgType := string(buffer[0])\n\n\tif msgType == msgCopyFile {\n\t\tmsg = string(buffer[1 : n-1])\n\t\tfields = strings.Split(msg, \" \")\n\n\t\treturn s.readFileData(reader, localFile, os.FileMode(cast.ToUint32(fields[0])), cast.ToInt(fields[1]))\n\t} else if buffer[0] == msgErr || buffer[0] == msgFatalErr {\n\t\treturn fmt.Errorf(\"%s\", string(buffer[1:n]))\n\t}\n\n\treturn fmt.Errorf(\"expected message type '%s', received '%s'\", msgCopyFile, msgType)\n}", "func processFile(file string) (subj *Participant, err error) {\n\t// Open file\n\tdata, err := os.Open(file)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer data.Close()\n\n\t// Read lines\n\tscanner := bufio.NewScanner(data)\n\tif err := scanner.Err(); err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"reading inputfile:\", err)\n\t}\n\n\t// Initiate pointer to a new participant and (first) trial\n\tthissubject := &Participant{}\n\tthistrial := &Trial{}\n\n\t// For line in file\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tif strings.Contains(line, \"Subject:\") && thissubject.id == \"\" {\n\t\t\t_, thissubject.id = ExtractKeyValue(line)\n\t\t}\n\t\tif strings.Contains(line, \"SessionDate:\") && thissubject.sessiondate == \"\" {\n\t\t\t_, thissubject.sessiondate = ExtractKeyValue(line)\n\t\t}\n\n\t\tif strings.Contains(line, logframestart) {\n\t\t\tthistrial = &Trial{}\n\t\t}\n\n\t\tif isMeasureVariable(line) {\n\t\t\tprocessMeasure(line, thistrial)\n\t\t}\n\n\t\tif strings.Contains(line, logframeend) {\n\t\t\tthissubject.trials = append(thissubject.trials, thistrial)\n\t\t}\n\n\t}\n\n\treturn thissubject, nil\n}", "func srcFile(path string) string {\n\treturn \"file://\" + file(path)\n}", "func rewrite_randomSchedOnly(origpath,newpath string, criticalPoints []*ConcurrencyUsage) []string{\n // Variables\n var astfiles []*ast.File\n var ret []string\n\tvar conf loader.Config\n\tvar concfiles []string\n\n // extract aux data\n conclines := make(map[string]int) // extract concurrency lines\n _concfiles := make(map[string]int) // extract concurrency files\n\n for _,c := range(criticalPoints){\n conclines[c.Location.String()]=1\n _concfiles[c.Location.FileName] = 1\n }\n for k,_ := range(_concfiles){\n concfiles = append(concfiles,k)\n }\n\n // load program files\n\tpaths,err := filepath.Glob(origpath+\"/*.go\")\n\tcheck(err)\n\tif _, err := conf.FromArgs(paths, false); err != nil {\n\t\tpanic(err)\n\t}\n prog, err := conf.Load()\n\tcheck(err)\n for _,crt := range(prog.Created){\n for _,ast := range(crt.Files){\n astfiles = append(astfiles,ast)\n }\n }\n\n // for all ast files in the package\n // add import github.com/staheri/goat/goat\n // inject goat.Sched_Handler to concurrency lines (astutil.Apply)\n for _,astFile := range(astfiles){\n\n // check if this file has concurrency usage\n if contains(concfiles,prog.Fset.Position(astFile.Package).Filename){ // add import\n astutil.AddImport(prog.Fset, astFile, \"github.com/staheri/goat/goat\")\n }\n\n // add schedcalls wherever concusage\n astutil.Apply(astFile, func(cr *astutil.Cursor) bool{\n n := cr.Node()\n if n != nil{\n curloc := prog.Fset.Position(n.Pos()).Filename+\":\"+strconv.Itoa(prog.Fset.Position(n.Pos()).Line)\n if _,ok := conclines[curloc];ok{\n if conclines[curloc] != 1{\n return true\n }\n conclines[curloc] = 2\n // point of injection\n switch x:= n.(type){\n case *ast.DeferStmt:\n ds := n.(*ast.DeferStmt)\n cr.Replace(astNode_convertDefer(ds))\n _ = x\n return true\n }\n cr.InsertBefore(astNode_sched())\n return true\n }\n }\n return true\n },nil)\n\n // for range statement, all concusage\n ast.Inspect(astFile, func(n ast.Node) bool {\n switch x := n.(type){\n case *ast.RangeStmt:\n newCall := astNode_sched()\n x.Body.List = append(x.Body.List,newCall)\n return true\n }\n return true\n })\n\n\t\t// add other injections only to main/test file\n if mainIn(astFile) || testIn(astFile){\n\n // add gomaxprocs and trace start/stop code\n \tast.Inspect(astFile, func(n ast.Node) bool {\n \t\tswitch x := n.(type) {\n \t\tcase *ast.FuncDecl:\n \t\t\t// find 'main' function\n \t\t\tif x.Name.Name == \"main\" && x.Recv == nil {\n toAdd := astNode_goatRaceMain()\n stmts := []ast.Stmt{toAdd[0]}\n //stmts = append(stmts,toAdd[1])\n //stmts = append(stmts,toAdd[2])\n\t\t\t\t\t\tstmts = append(stmts,x.Body.List...)\n x.Body.List = stmts\n \t\t\t\treturn true\n \t\t\t}else if strings.HasPrefix(x.Name.Name,\"Test\") && x.Recv == nil{\n\t\t\t\t\t\ttoAdd := astNode_goatRaceMain()\n stmts := []ast.Stmt{toAdd[0]}\n\t\t\t\t\t\tstmts = append(stmts,x.Body.List...)\n x.Body.List = stmts\n \t\t\t\treturn true\n }\n \t\t}\n \t\treturn true\n \t})\n } // end for main\n\n\n // write files\n var buf bytes.Buffer\n \terr := printer.Fprint(&buf, prog.Fset, astFile)\n \tcheck(err)\n filename := filepath.Join(newpath, strings.Split(filepath.Base(prog.Fset.Position(astFile.Pos()).Filename),\".\")[0]+\".go\")\n err = ioutil.WriteFile(filename, buf.Bytes(), 0666)\n check(err)\n ret = append(ret,filename)\n }\n return ret\n}", "func generateFromString(fullpath, src string) {\n\tfullpath = filepath.FromSlash(fullpath)\n\tfile, err := os.Create(fullpath)\n\tif err != nil {\n\t\tlog.Fatalf(\"Error: cannot generate file from string %s.\\n\"+\n\t\t\t\"The error is: %v\", fullpath, err)\n\t}\n\n\t_, err = file.WriteString(src)\n\tif err != nil {\n\t\tlog.Fatalf(\"Error: cannot write from string %s.\\n\"+\n\t\t\t\"The error is: %v\", fullpath, err)\n\t}\n\n\tlog.Successf(\"Created %v\\n\", fullpath)\n}", "func (o *Job) GetScheduleOk() (*string, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn &o.Schedule, true\n}", "func readJobFile(name string) []byte {\n file, err := os.Open(name)\n if err != nil {\n log.Fatal(err)\n }\n bytes, err := ioutil.ReadAll(file)\n defer file.Close()\n return bytes\n}", "func NowFileString() string {\n\tnow := time.Now()\n\treturn now.Format(\"2006-01-02_15-04-05-000Z\")\n}", "func GetSchedule(connection *common.Connection, id string) (*Schedule, *common.ErrorHUE, error) {\n\tschedule := &Schedule{}\n\tpath := fmt.Sprintf(\"/api/\" + connection.Username + \"/schedules/\" + id)\n\tbodyResponse, errHUE, err := internal.Request(connection, \"GET\", http.StatusOK, path, nil)\n\tif errHUE != nil {\n\t\tlog.Errorf(\"HUE Error: %s\", errHUE.Error.Description)\n\t\treturn schedule, errHUE, err\n\t}\n\tif err != nil {\n\t\tlog.Errorf(\"Error: %s\", err.Error())\n\t\treturn schedule, errHUE, err\n\t}\n\terr = json.Unmarshal(bodyResponse, &schedule)\n\tif err != nil {\n\t\tlog.Errorf(\"Error with unmarshalling GetSchedule: %s\", err.Error())\n\t\treturn schedule, nil, err\n\t}\n\treturn schedule, nil, nil\n}", "func (*Timer) Descriptor() ([]byte, []int) {\n\treturn file_schnutibox_proto_rawDescGZIP(), []int{2}\n}", "func (*CronSpec) Descriptor() ([]byte, []int) {\n\treturn file_toit_model_job_proto_rawDescGZIP(), []int{18}\n}", "func (p *Plan) SourceFile() string {\n\treturn join(filepath.Base(p.Expand().Url))\n}", "func getSequence(fileName string) ([]byte, error) {\n\treturn ioutil.ReadFile(fileName)\n}", "func DecodeFile(path string) (*Pattern, error) {\n\tdefer func() {\n\t\tif e := recover(); e != nil {\n\t\t\tfmt.Println(\"Recover panic : \", e)\n\t\t\treturn\n\t\t}\n\t}()\n\tp := &Pattern{}\n\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer file.Close()\n\n\tsize, _ := os.Stat(path)\n\tb := make([]byte, size.Size())\n\n\t// full read\n\terr = binary.Read(file, binary.LittleEndian, &b)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// splice - version - tempo - track\n\tif bytes.Compare([]byte(\"SPLICE\"), b[0:6]) != 0 {\n\t\treturn nil, errors.New(\"SPLICE Not Found\")\n\t}\n\n\t//fmt.Println(hex.Dump(b))\n\tvar tid uint8\n\tvar tname string\n\n\tvar idpos uint32 // starting position for first id\n\tvar length uint32 // name length\n\tvar lengthpos uint32 // starting position for name length\n\tvar stepPos uint32 // starting position for step\n\tvar stepSize uint32 // track step size = 16\n\tvar nextidPos uint32 // starting position for next id\n\tvar bsize uint32 // binary size\n\tvar isize uint32 // byte size\n\n\tstepSize = 16 // 16 bytes step size\n\tidpos = 50\n\tlengthpos = 51\n\tisize = uint32(len(b))\n\n\tfor true {\n\t\t// read the id\n\t\tbuf := bytes.NewReader(b[idpos : idpos+1])\n\t\tbinary.Read(buf, binary.LittleEndian, &tid)\n\n\t\t// handle binary size ?\n\t\tbuf = bytes.NewReader(b[10:14])\n\t\tbinary.Read(buf, binary.BigEndian, &bsize)\n\n\t\t// Why ?\n\t\tbuf = bytes.NewReader(b[lengthpos : lengthpos+4])\n\t\tbinary.Read(buf, binary.BigEndian, &length)\n\n\t\tif length > bsize || length > isize {\n\t\t\t//fmt.Println(length, lengthpos, stepPos)\n\t\t\tbreak\n\t\t}\n\t\tstepPos = lengthpos + 4 + length\n\t\tnextidPos = stepPos + stepSize\n\n\t\t// name\n\t\ttname = string(b[lengthpos+4 : stepPos])\n\n\t\tp.version = string(bytes.Trim(b[14:45], string(0x00)))\n\t\tp.tempo = float32frombytes(b[46:50])\n\t\tp.track = append(p.track, track{id: tid, name: tname, step: b[stepPos:nextidPos]})\n\n\t\tidpos = nextidPos\n\t\tlengthpos = idpos + 1\n\t\tif idpos >= isize || idpos > bsize {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn p, nil\n}", "func Run1(file string) {\n\tdata, err := readInputData(file)\n\thandleErr(err)\n\tfmt.Printf(\"Day 04 t1: '%v'\\n\", sleepEstimatorTask1(data))\n}", "func configFile(name string) string {\n\tfmtString := \"\"\n\tswitch initSystem {\n\tcase \"systemd\":\n\t\tfmtString = \"/etc/systemd/system/%s.service\"\n\tcase \"upstart\":\n\t\tfmtString = \"/etc/init/%s.conf\"\n\tdefault:\n\t\treturn \"\"\n\t}\n\treturn fmt.Sprintf(fmtString, name)\n}", "func Create(name bool) string {\n\tvar n string\n\t//here we see flag to set name is active to to choose a specifc name if not a random one is general one is given\n\tif name {\n\t\tfmt.Println(len(os.Args))\n\t\t//these condition statement are to handle the erros if they put the flag but dont put a name\n\t\tif len(os.Args) >= 4 {\n\n\t\t\tn = time.Now().Format(os.Args[3]+\"/jan-02-2006\") + \" \" + time.Now().Format(\"03:04:05 PM\") + \": \" + os.Args[2]\n\t\t\t//fmt.Println(n, 3)\n\t\t\tos.MkdirAll(os.Args[3], 0777)\n\t\t} else if len(os.Args) == 3 {\n\n\t\t\tn = time.Now().Format(\"jan-02-2006\") + \" \" + time.Now().Format(\"03:04:05 PM\") + \": \" + os.Args[2]\n\t\t\t//fmt.Println(n, 2)\n\t\t} else {\n\t\t\tn = time.Now().Format(\"jan-02-2006\") + \" \" + time.Now().Format(\"03:04:05 PM\") + \": \" + \"quicknotes\"\n\t\t\t//fmt.Println(n, 0)\n\t\t}\n\n\t} else {\n\t\tn = time.Now().Format(\"jan-02-2006\") + \" \" + time.Now().Format(\"03:04:05 PM\") + \": \" + \"quicknotes\"\n\t\t//fmt.Println(n, 0)\n\t}\n\t//return n\n\n\t//fmt.Println(n)\n\t// n the name the file will have\n\treturn n\n}", "func schedule(jobName string, mapFiles []string, nReduce int, phase jobPhase, registerChan chan string) {\n\tvar ntasks int\n\tvar n_other int // number of inputs (for reduce) or outputs (for map)\n\tswitch phase {\n\tcase mapPhase:\n\t\tntasks = len(mapFiles)\n\t\tn_other = nReduce\n\tcase reducePhase:\n\t\tntasks = nReduce\n\t\tn_other = len(mapFiles)\n\t}\n\n\tfmt.Printf(\"Schedule: %v %v tasks (%d I/Os)\\n\", ntasks, phase, n_other)\n\n\t// All ntasks tasks have to be scheduled on workers, and only once all of\n\t// them have been completed successfully should the function return.\n\t// Remember that workers may fail, and that any given worker may finish\n\t// multiple tasks.\n\t//\n\n\tvar wg sync.WaitGroup\n\twg.Add(ntasks)\n\tfor i := 0; i < ntasks; i++ {\n\t\ttask := DoTaskArgs{\n\t\t\tJobName:jobName,\n\t\t\tFile:mapFiles[i],\n\t\t\tPhase:phase,\n\t\t\tTaskNumber:i,\n\t\t\tNumOtherPhase:n_other,\n\t\t}\n\t\tworker := <- registerChan\n\t\tgo fire(worker, \"Worker.DoTask\", task, nil, &wg, registerChan)\n\t}\n\twg.Wait()\n}", "func AddSchedule(nbmaster string, httpClient *http.Client, jwt string) {\r\n fmt.Printf(\"\\nSending a PUT request to add schedule %s to policy %s...\\n\", testScheduleName, testPolicyName)\r\n\r\n schedule := map[string]interface{}{\r\n \"data\": map[string]interface{}{\r\n \"type\": \"schedule\",\r\n \"id\": testScheduleName,\r\n \"attributes\": map[string]interface{}{\r\n \"acceleratorForcedRescan\": false,\r\n \"backupCopies\": map[string]interface{}{\r\n \"priority\": 9999,\r\n \"copies\": []map[string]interface{}{{\r\n \"mediaOwner\": \"owner1\",\r\n \"storage\": nil,\r\n \"retentionPeriod\": map[string]interface{}{\r\n \"value\": 9,\r\n \"unit\": \"WEEKS\"},\r\n \"volumePool\": \"NetBackup\",\r\n \"failStrategy\": \"Continue\"}}},\r\n \"backupType\": \"Full Backup\",\r\n \"excludeDates\": map[string]interface{}{\r\n \"lastDayOfMonth\": true,\r\n \"recurringDaysOfWeek\": []string{\"4:6\", \"2:5\"},\r\n \"recurringDaysOfMonth\": []int{10},\r\n \"specificDates\": []string{\"2000-1-1\", \"2016-2-30\"}},\r\n \"frequencySeconds\": 4800,\r\n \"includeDates\": map[string]interface{}{\r\n \"lastDayOfMonth\": true,\r\n \"recurringDaysOfWeek\": []string{\"2:3\", \"3:4\"},\r\n \"recurringDaysOfMonth\": []int{10,13},\r\n \"specificDates\": []string{\"2016-12-31\"}},\r\n \"mediaMultiplexing\": 2,\r\n \"retriesAllowedAfterRunDay\": true,\r\n \"scheduleType\": \"Calendar\",\r\n \"snapshotOnly\": false,\r\n \"startWindow\": []map[string]interface{}{{\r\n \"dayOfWeek\": 1,\r\n \"startSeconds\": 14600,\r\n \"durationSeconds\": 24600},\r\n {\"dayOfWeek\": 2,\r\n \"startSeconds\": 14600,\r\n \"durationSeconds\": 24600},\r\n {\"dayOfWeek\": 3,\r\n \"startSeconds\": 14600,\r\n \"durationSeconds\": 24600},\r\n {\"dayOfWeek\": 4,\r\n \"startSeconds\": 14600,\r\n \"durationSeconds\": 24600},\r\n {\"dayOfWeek\": 5,\r\n \"startSeconds\": 14600,\r\n \"durationSeconds\": 24600},\r\n {\"dayOfWeek\": 6,\r\n \"startSeconds\": 14600,\r\n \"durationSeconds\": 24600},\r\n {\"dayOfWeek\": 7,\r\n \"startSeconds\": 14600,\r\n \"durationSeconds\": 24600}},\r\n \"syntheticBackup\": false,\r\n \"storageIsSLP\": false}}}\r\n\r\n scheduleRequest, _ := json.Marshal(schedule)\r\n\r\n uri := \"https://\" + nbmaster + \":\" + port + \"/netbackup/\" + policiesUri + testPolicyName + \"/schedules/\" + testScheduleName\r\n\r\n request, _ := http.NewRequest(http.MethodPut, uri, bytes.NewBuffer(scheduleRequest))\r\n request.Header.Add(\"Content-Type\", contentTypeV2);\r\n request.Header.Add(\"Authorization\", jwt);\r\n\r\n response, err := httpClient.Do(request)\r\n\r\n if err != nil {\r\n fmt.Printf(\"The HTTP request failed with error: %s\\n\", err)\r\n panic(\"Unable to add schedule to policy.\\n\")\r\n } else {\r\n if response.StatusCode != 201 {\r\n printErrorResponse(response)\r\n } else {\r\n fmt.Printf(\"%s added to %s successfully.\\n\", testScheduleName, testPolicyName);\r\n }\r\n }\r\n}", "func (a Put) Schedule() *destination.Schedule {\n\treturn nil\n}", "func schedule(jobName string, mapFiles []string, nReduce int, phase jobPhase, registerChan chan string) {\n\tvar ntasks int\n\tvar n_other int // number of inputs (for reduce) or outputs (for map)\n\tvar inputArgs chan string\n\tswitch phase {\n\tcase mapPhase:\n\t\tntasks = len(mapFiles)\n\t\tn_other = nReduce\n\t\tinputArgs = make(chan string, ntasks)\n\t\tfor idx, mf := range (mapFiles) {\n\t\t\targ := strconv.Itoa(idx) + \" \" + mf\n\t\t\tinputArgs <- arg\n\t\t}\n\tcase reducePhase:\n\t\tntasks = nReduce\n\t\tn_other = len(mapFiles)\n\t\tinputArgs = make(chan string, ntasks)\n\t\tfor idx := 0; idx < ntasks; idx++ {\n\t\t\targ := strconv.Itoa(idx)\n\t\t\tinputArgs <- arg\n\t\t}\n\t}\n\n\tfmt.Printf(\"Schedule: %v %v tasks (%d I/Os)\\n\", ntasks, phase, n_other)\n\n\tvar wg sync.WaitGroup\n\twg.Add(ntasks)\n\n\tgo func() {\n\t\tfor {\n\n\t\t\twk := <-registerChan\n\n\t\t\tgo func() {\n\t\t\t\tinput_arg := <-inputArgs\n\t\t\t\targs := strings.Fields(input_arg)\n\t\t\t\ttaskNum, err := strconv.Atoi(args[0])\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Fatalf(\"Number(%s) parse error: %s\\n\", args[0], err)\n\t\t\t\t}\n\n\t\t\t\ttaskArg := &DoTaskArgs{\n\t\t\t\t\tJobName: jobName,\n\t\t\t\t\tPhase: phase,\n\t\t\t\t\tTaskNumber: taskNum,\n\t\t\t\t\tNumOtherPhase: n_other,\n\t\t\t\t}\n\n\t\t\t\tif phase == mapPhase {\n\t\t\t\t\ttaskArg.File = args[1]\n\t\t\t\t}\n\n\t\t\t\tok := call(wk, \"Worker.DoTask\", &taskArg, new(struct{}))\n\n\t\t\t\tdefer func() {\n\t\t\t\t\tregisterChan <- wk\n\t\t\t\t}()\n\n\t\t\t\tif !ok {\n\t\t\t\t\tinputArgs <- input_arg\n\t\t\t\t} else {\n\t\t\t\t\twg.Done()\n\t\t\t\t}\n\n\t\t\t}()\n\t\t}\n\t}()\n\n\twg.Wait()\n\n\t// All ntasks tasks have to be scheduled on workers, and only once all of\n\t// them have been completed successfully should the function return.\n\t// Remember that workers may fail, and that any given worker may finish\n\t// multiple tasks.\n\t//\n\tfmt.Printf(\"Schedule: %v phase done\\n\", phase)\n}", "func schedule(jobName string, mapFiles []string, nReduce int, phase jobPhase, registerChan chan string) {\n\tvar totaljobs, iolength int\n\twg := new(sync.WaitGroup)\n\tif phase == mapPhase {\n\t\ttotaljobs = len(mapFiles)\n\t\tiolength = nReduce\n\t}\n\tif phase == reducePhase {\n\t\ttotaljobs = nReduce\n\t\tiolength = len(mapFiles)\n\t}\n\tfor temp := 0; temp < totaljobs; temp++ {\n\t\twg.Add(1)\n\t\tvar dotaskargs DoTaskArgs\n\t\tif phase == mapPhase {\n\t\t\tdotaskargs = DoTaskArgs{jobName, mapFiles[temp], phase, temp, iolength}\n\t\t}\n\t\tif phase == reducePhase {\n\t\t\tdotaskargs = DoTaskArgs{jobName, \"\", phase, temp, iolength}\n\t\t}\n\t\tgo func() {\n\t\t\tfor {\n\t\t\t\twrkinf := <-registerChan\n\t\t\t\tstatus := call(wrkinf, \"Worker.DoTask\", &dotaskargs, new(struct{}))\n\t\t\t\tif status == true {\n\t\t\t\t\tgo func() {\n\t\t\t\t\t\tregisterChan <- wrkinf\n\t\t\t\t\t}()\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\twg.Done()\n\t\t}()\n\t}\n\twg.Wait()\n}", "func (c *Config) File(stream string) (string, error) {\n\tkey, err := keyName(stream, \"file\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tt, err := template.New(\"filename\").Parse(c.v.GetString(key))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvar tpl bytes.Buffer\n\tif err := t.Execute(&tpl, c); err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn tpl.String(), nil\n}", "func ScheduleHandler(w http.ResponseWriter, r *http.Request) {\n\tclient := context.Get(r, \"redis.Client\").(*redis.Client)\n\tu := url.Values{}\n\tv := mux.Vars(r)\n\n\tu.Set(\"a\", \"sf-muni\")\n\tu.Set(\"r\", v[\"route_tag\"])\n\n\tbody, err := getFromCache(client, r.URL.String())\n\tif err == nil {\n\t\tfmt.Fprintf(w, \"%s\", body)\n\t\treturn\n\t}\n\n\tbody, err = fetch(\"schedule\", u)\n\tif err != nil {\n\t\thttp.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\twriteToCache(client, r.URL.String(), body)\n\n\tfmt.Fprintf(w, \"%s\", body)\n}" ]
[ "0.73062176", "0.5404668", "0.5138776", "0.5093022", "0.5044953", "0.50393766", "0.49811786", "0.49227092", "0.49220976", "0.49137813", "0.48866478", "0.48760164", "0.48616835", "0.47537345", "0.4747598", "0.47460353", "0.47455624", "0.4702152", "0.46913794", "0.46859178", "0.4662792", "0.46625367", "0.4627827", "0.46107602", "0.46102425", "0.45855945", "0.4555229", "0.45508406", "0.45496926", "0.45343956", "0.45204344", "0.45187926", "0.4491018", "0.4488285", "0.44708622", "0.44677052", "0.44588596", "0.4447236", "0.44415945", "0.44405705", "0.4436525", "0.442365", "0.441699", "0.441132", "0.4405478", "0.43973967", "0.4384988", "0.4379549", "0.43775454", "0.43640712", "0.4312295", "0.43026042", "0.42986295", "0.42967921", "0.42963496", "0.42963362", "0.42897984", "0.4288044", "0.42852265", "0.4279946", "0.4277931", "0.4267139", "0.42589423", "0.42508343", "0.4246766", "0.42371365", "0.42367452", "0.42363146", "0.42323095", "0.42238533", "0.42180678", "0.42162305", "0.421472", "0.42067134", "0.41959977", "0.41930026", "0.41836998", "0.4173784", "0.41704556", "0.4166549", "0.4163938", "0.41635877", "0.41628617", "0.4160055", "0.41577265", "0.41562238", "0.4155268", "0.41544673", "0.41480204", "0.41472575", "0.41465145", "0.4146087", "0.4145992", "0.41396365", "0.41363177", "0.41339117", "0.4131289", "0.41282913", "0.41279316", "0.412405" ]
0.74915403
0
Read implements the Conn Read method.
func (c *Conn) Read(b []byte) (int, error) { if !c.ok() { return 0, syscall.EINVAL } if len(c.recvRest) > 0 { l := copy(b, c.recvRest) c.recvRest = c.recvRest[l:] return l, nil } p, err := c.recvBuf.Pop() if err != nil { return 0, err } l := copy(b, p) c.recvRest = p[l:] return l, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *conn) Read(p []byte) (int, error) {\n\treturn c.reader.Read(p)\n}", "func (clientConn *Conn) Read(p []byte) (n int, err error) {\n\treturn clientConn.dataReader.Read(p)\n}", "func (c *WrappedConn) Read(b []byte) (n int, err error) {\n\t//c.Conn is certainly not nil\n\tn, err = c.Conn.Read(b)\n\tif err != nil {\n\t\tc.unusable = true\n\t} else {\n\t\tc.lastAccess = time.Now()\n\t}\n\n\treturn\n}", "func ConnRead(c *tls.Conn, b []byte) (int, error)", "func (dc *DebugConn) Read(p []byte) (int, error) {\n\tif dc.isClosed() {\n\t\treturn 0, ErrClosed\n\t}\n\n\tn, err := dc.Conn.Read(p)\n\n\tif dc.readDebug != nil {\n\t\tdc.readDebug(dc.logger, true, dc.isClient, dc.id, p, n, err)\n\t}\n\n\treturn n, err\n}", "func (c *Conn) Read(b []byte) (int, error) {\n\terr := c.Conn.SetReadDeadline(time.Now().Add(c.ReadTimeout))\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn c.Conn.Read(b)\n}", "func (connection *Connection) Read(delimiter byte) ([]byte, error) {\n\t//TODO\n}", "func (s *session) Read(p []byte) (int, error) {\n\treturn 0, errors.New(\"not implemented\")\n}", "func (s *session) Read() (pdu.Body, error) {\n\treturn s.conn.Read()\n}", "func (c *Conn) Read(b []byte) (int, error) {\n\tif c.readTimeout > 0 {\n\t\tif err := c.Conn.SetReadDeadline(time.Now().Add(c.readTimeout)); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\tn, err := c.Conn.Read(b)\n\tif err == nil && c.Stats != nil {\n\t\tc.Stats.ReadTotal.Add(uint64(n))\n\t}\n\tc.incBytesIn(n)\n\treturn n, err\n}", "func (wsConn *WSConn) Read(p []byte) (n int, err error) {\n\treturn wsConn.conn.Read(p)\n}", "func (conn *Conn) Read(b []byte) (n int, err error) {\n\tn, err = conn.pr.Read(b)\n\n\t// if err == io.EOF {\n\t// \topcode, reader, err = conn.Handler.NextReader()\n\n\t// \tif err != nil {\n\t// \t\treturn n, err\n\t// \t}\n\n\t// \tconn.pr = reader\n\n\t// \tm, err := conn.Read(b[n:])\n\n\t// \treturn m + n, err\n\t// }\n\n\treturn n, err\n}", "func (d *Driver) Read(path string) ([]byte, error) {\n\tdata, _, err := d.conn.Get(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn data, nil\n}", "func (i *Client) Read() error {\n\treturn i.read()\n}", "func (r *RPCIngressGateway) Read(req *ReadReq, resp *ReadResp) error {\n\tconn, err := r.getConn(req.ConnID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tbuf := make([]byte, req.BufLen)\n\n\tresp.N, err = conn.Read(buf)\n\tif resp.N != 0 {\n\t\tresp.B = make([]byte, resp.N)\n\t\tcopy(resp.B, buf[:resp.N])\n\t}\n\tif err != nil {\n\t\tif err.Error() != io.EOF.Error() {\n\t\t\t// we don't print warning if the conn is already closed\n\t\t\t_, ok := r.cm.Get(req.ConnID)\n\t\t\tif ok {\n\t\t\t\tr.log.WithError(err).Warn(\"Received unexpected error when reading from server.\")\n\t\t\t}\n\t\t}\n\t}\n\n\tif wrappedConn, ok := conn.(*appnet.WrappedConn); ok {\n\t\tif skywireConn, ok := wrappedConn.Conn.(*appnet.SkywireConn); ok {\n\t\t\tif ngErr := skywireConn.GetError(); ngErr != nil {\n\t\t\t\terr = ngErr\n\t\t\t}\n\t\t}\n\t}\n\n\tresp.Err = ioErrToRPCIOErr(err)\n\n\t// avoid error in RPC pipeline, error is included in response body\n\treturn nil\n}", "func (c *Conn) Read(p []byte) (n int, err error) {\n\treturn c.bufr.Read(p)\n}", "func (p *conn) Read(b []byte) (int, error) {\n\tvar err error\n\tp.once.Do(func() { err = p.checkPrefix() })\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn p.bufReader.Read(b)\n}", "func (c connection) Read() mynet.Load {\n\tp := packet{}\n\terr := c.decoder.Decode(&p)\n\tif err != nil && err != io.EOF {\n\t\tpanic(err)\n\t}\n\n\treturn p.Load\n}", "func (e errorConnection) Read(b []byte) (n int, err error) {\n\treturn 0, e.err\n}", "func (p *Conn) Read(b []byte) (int, error) {\n\tvar err error\n\tp.once.Do(func() { err = p.checkPrefix() })\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn p.bufReader.Read(b)\n}", "func (t *cliTransHandler) Read(ctx context.Context, conn net.Conn, recvMsg remote.Message) (err error) {\n\tvar bufReader remote.ByteBuffer\n\tstats2.Record(ctx, recvMsg.RPCInfo(), stats.ReadStart, nil)\n\tdefer func() {\n\t\tt.ext.ReleaseBuffer(bufReader, err)\n\t\tstats2.Record(ctx, recvMsg.RPCInfo(), stats.ReadFinish, err)\n\t}()\n\n\tt.ext.SetReadTimeout(ctx, conn, recvMsg.RPCInfo().Config(), recvMsg.RPCRole())\n\tbufReader = t.ext.NewReadByteBuffer(ctx, conn, recvMsg)\n\trecvMsg.SetPayloadCodec(t.opt.PayloadCodec)\n\terr = t.codec.Decode(ctx, recvMsg, bufReader)\n\tif err != nil {\n\t\tif t.ext.IsTimeoutErr(err) {\n\t\t\treturn kerrors.ErrRPCTimeout.WithCause(err)\n\t\t}\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (c *Conn) Read(b []byte) (n int, err error) {\n\treturn syscall.Read(c.fd, b)\n}", "func (c *Conn) Read(p []byte) (n int, err error) {\n\t// handles handshake and error\n\terr = c.Handshake()\n\tif err != nil {\n\t\treturn\n\t}\n\n\treader := NewSecureReader(c.rawConn, c.priv, c.peerPublicKey)\n\treturn reader.Read(p)\n}", "func (c *conn) Read(b []byte) (n int, err error) {\n\tvar data []byte\n\n\tif c.rdata != nil {\n\t\tdata = c.rdata\n\t} else {\n\t\tdata = <-c.readCh\n\t}\n\n\tif data == nil {\n\t\treturn 0, io.EOF\n\t}\n\n\tif len(data) > len(b) {\n\t\tcopy(b, data[:len(b)])\n\t\tc.rdata = data[len(b):]\n\t\treturn len(b), nil\n\t}\n\n\tc.rdata = nil\n\tcopy(b, data)\n\n\treturn len(data), nil\n}", "func (l *lazyConn) Read(p []byte) (n int, err error) {\n\tl.m.Lock()\n\tdefer l.m.Unlock()\n\n\tif l.conn == nil {\n\t\tif err := l.connect(); err != nil {\n\t\t\treturn 0, io.ErrUnexpectedEOF\n\t\t}\n\t}\n\n\tn, err = l.withTimeout().Read(p)\n\tswitch {\n\tcase err == io.EOF:\n\t\tfallthrough\n\tcase err == io.ErrUnexpectedEOF:\n\t\tl.conn = nil\n\t}\n\treturn n, err\n}", "func Read(conn net.Conn) (string, string, error) {\r\n\t//read from connection\r\n\tresult, err := ioutil.ReadAll(conn)\r\n\t// fmt.Printf(\"result %v\\n\",string(result))\r\n\tif err != nil {\r\n\t\treturn \"\", \"\", err\r\n\t}\r\n\tstatus := strings.Split(string(result), \"\\r\\n\\r\\n\")\r\n\treturn status[0], status[1], nil\r\n}", "func (c *noiseConn) Read(p []byte) (n int, err error) {\n\tc.readHeaderOnce.Do(c.readHeader)\n\treturn c.reader.Read(p)\n}", "func (r *response) Read(buf []byte) (int, error) {\n\treturn r.conn.Read(buf)\n}", "func (mCn mockConn) Read(b []byte) (n int, err error) {\n\tfmt.Printf(\"reading: %d of %d.\\n\", *mCn.readCount, len(mockConnOutpBytes))\n\tif *mCn.readCount < len(mockConnOutpBytes) {\n\t\tcopy(b, mockConnOutpBytes[*mCn.readCount])\n\t\t*mCn.readCount = *mCn.readCount + 1\n\t}\n\treturn len(b), nil\n}", "func (d *Device) Read(buf []byte) (n int, err error) {\n\treturn d.conn.Read(buf)\n}", "func (c *Conn) Read(buf []byte) (int, error) {\n\tn, err := c.r.Read(buf)\n\tif err != nil {\n\t\treturn n, err\n\t}\n\tc.WriteToHash(buf[:n])\n\treturn n, nil\n}", "func (cr *ConnectRequest) Read(connReader *bufio.Reader) error {\n\tvar err error\n\t// check version\n\tcr.Ver, err = connReader.ReadByte()\n\tif err != nil {\n\t\treturn errors.New(\"read version error, \" + err.Error())\n\t}\n\tif cr.Ver != consts.VERSION5 {\n\t\treturn errors.New(fmt.Sprintf(\"version %d is not accepted\", cr.Ver))\n\t}\n\n\tcr.Methods.Len, err = connReader.ReadByte()\n\tif err != nil {\n\t\treturn errors.New(\"read nMethods error, \" + err.Error())\n\t}\n\t// 读取指定长度字节好像不对\n\tmethods := make([]byte, int(cr.Methods.Len))\n\t_, err = io.ReadFull(connReader, methods)\n\tif err != nil {\n\t\treturn errors.New(\"read methods error, \" + err.Error())\n\t}\n\tcr.Methods.Bytes = methods\n\n\treturn nil\n}", "func (dc DeadlineConn) Read(data []byte) (int, error) {\n\tcount := 0\n\terr := dc.Conn.SetReadDeadline(time.Now().Add(dc.timeout))\n\tif err != nil {\n\t\treturn count, err\n\t}\n\t// don't bother with resetting the deadline since it will be set\n\t// again next time we call Read()\n\treturn dc.Conn.Read(data)\n}", "func (c *digisparkI2cConnection) Read(b []byte) (countRead int, err error) {\n\tc.mtx.Lock()\n\tdefer c.mtx.Unlock()\n\n\treturn c.readInternal(b)\n}", "func (session *UDPMakeSession) Read(p []byte) (n int, err error) {\n\twc := cache{p, 0, make(chan int)}\n\tselect {\n\tcase session.recvChan <- wc:\n\t\tselect {\n\t\tcase n = <-wc.c:\n\t\tcase <-session.quitChan:\n\t\t\tn = -1\n\t\t}\n\tcase <-session.quitChan:\n\t\tn = -1\n\t}\n\t//log.Println(\"real recv\", l, string(b[:l]))\n\tif n == -1 {\n\t\treturn 0, errors.New(\"force quit for read error\")\n\t} else {\n\t\treturn n, nil\n\t}\n}", "func (session *UDPMakeSession) Read(p []byte) (n int, err error) {\n\twc := cache{p, 0, make(chan int)}\n\tselect {\n\tcase session.recvChan <- wc:\n\t\tselect {\n\t\tcase n = <-wc.c:\n\t\tcase <-session.quitChan:\n\t\t\tn = -1\n\t\t}\n\tcase <-session.quitChan:\n\t\tn = -1\n\t}\n\t//log.Println(\"real recv\", l, string(b[:l]))\n\tif n == -1 {\n\t\treturn 0, errors.New(\"force quit for read error\")\n\t} else {\n\t\treturn n, nil\n\t}\n}", "func (ctn *Connection) Read(buf []byte, length int) (total int, aerr Error) {\n\tvar err error\n\n\t// if all bytes are not read, retry until successful\n\t// Don't worry about the loop; we've already set the timeout elsewhere\n\tfor total < length {\n\t\tvar r int\n\t\tif err = ctn.updateDeadline(); err != nil {\n\t\t\tbreak\n\t\t}\n\n\t\tif !ctn.compressed {\n\t\t\tr, err = ctn.conn.Read(buf[total:length])\n\t\t} else {\n\t\t\tr, err = ctn.inflater.Read(buf[total:length])\n\t\t\tif err == io.EOF && total+r == length {\n\t\t\t\tctn.compressed = false\n\t\t\t\terr = ctn.inflater.Close()\n\t\t\t}\n\t\t}\n\t\ttotal += r\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif total == length {\n\t\t// If all required bytes are read, ignore any potential error.\n\t\t// The error will bubble up on the next network io if it matters.\n\t\treturn total, nil\n\t}\n\n\taerr = chainErrors(errToAerospikeErr(ctn, err), aerr)\n\n\tif ctn.node != nil {\n\t\tctn.node.incrErrorCount()\n\t\tatomic.AddInt64(&ctn.node.stats.ConnectionsFailed, 1)\n\t}\n\n\tctn.Close()\n\n\treturn total, aerr\n}", "func (p *Conn) Read(b []byte) (int, error) {\n\tp.checkProxyHeaderOnce()\n\tif p.headerErr != nil {\n\t\treturn 0, p.headerErr\n\t}\n\treturn p.bufReader.Read(b)\n}", "func (r *pgwireReader) Read(p []byte) (int, error) {\n\tn, err := r.conn.rd.Read(p)\n\treturn n, err\n}", "func (ctn *Connection) Read(buf []byte, length int) (total int, err error) {\n\t// if all bytes are not read, retry until successful\n\t// Don't worry about the loop; we've already set the timeout elsewhere\n\tfor total < length {\n\t\tvar r int\n\t\tif err = ctn.updateDeadline(); err != nil {\n\t\t\tbreak\n\t\t}\n\n\t\tif !ctn.compressed {\n\t\t\tr, err = ctn.conn.Read(buf[total:length])\n\t\t} else {\n\t\t\tr, err = ctn.inflater.Read(buf[total:length])\n\t\t\tif err == io.EOF && total+r == length {\n\t\t\t\tctn.compressed = false\n\t\t\t\terr = ctn.inflater.Close()\n\t\t\t}\n\t\t}\n\t\ttotal += r\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif total == length {\n\t\t// If all required bytes are read, ignore any potential error.\n\t\t// The error will bubble up on the next network io if it matters.\n\t\treturn total, nil\n\t}\n\n\tif ctn.node != nil {\n\t\tctn.node.incrErrorCount()\n\t\tatomic.AddInt64(&ctn.node.stats.ConnectionsFailed, 1)\n\t}\n\n\t// the line should happen before .Close()\n\terr = errToTimeoutErr(ctn, err)\n\tctn.Close()\n\n\treturn total, err\n}", "func (c *conn) Read(b []byte) (int, error) {\n\tc.ronce.Do(c.sleepLatency)\n\n\tn, err := c.rb.FillThrottle(func(remaining int64) (int64, error) {\n\t\tmax := remaining\n\t\tif l := int64(len(b)); max > l {\n\t\t\tmax = l\n\t\t}\n\n\t\tn, err := c.Conn.Read(b[:max])\n\t\treturn int64(n), err\n\t})\n\tif err != nil && err != io.EOF {\n\t\tlog.Errorf(\"trafficshape: error on throttled read: %v\", err)\n\t}\n\n\treturn int(n), err\n}", "func (c *client3E) Read(deviceName string, offset, numPoints int64) ([]byte, error) {\n\trequestStr := c.stn.BuildReadRequest(deviceName, offset, numPoints)\n\n\t// TODO binary protocol\n\tpayload, err := hex.DecodeString(requestStr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tconn, err := net.DialTCP(\"tcp\", nil, c.tcpAddr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer conn.Close()\n\n\t// Send message\n\tif _, err = conn.Write(payload); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Receive message\n\treadBuff := make([]byte, 22+2*numPoints) // 22 is response header size. [sub header + network num + unit i/o num + unit station num + response length + response code]\n\treadLen, err := conn.Read(readBuff)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn readBuff[:readLen], nil\n}", "func (rc *RpcConn) Read(size int) (bytes []byte, err error) {\n\tbytes, err = func() ([]byte, error) {\n\t\tif rc.GetState() != ConnStateReady {\n\t\t\treturn nil, ErrConnectionNotReady\n\t\t}\n\n\t\ttcpConn, ok := rc.conn.(*net.TCPConn)\n\t\tif ok {\n\t\t\ttcpConn.SetReadDeadline(time.Now().Add(rc.readTimeout))\n\t\t}\n\n\t\tbytes, err = rc.rstream.Next(size)\n\t\treturn bytes, err\n\t}()\n\n\tif err != nil && !IsNetworkTimeoutErr(err) {\n\t\trc.setState(ConnStateTransientFailure)\n\t}\n\treturn bytes, err\n}", "func (bc BufConn) Read(b []byte) (int, error) {\n\tif bc.IgnoreRead {\n\t\treturn len(b), nil\n\t}\n\tif bc.OnRead != nil {\n\t\treadBytes := bc.OnRead()\n\t\tcopy(b, readBytes)\n\t\treturn len(b), nil\n\t}\n\treturn bc.Buf.Read(b)\n}", "func (t *DbService) Read(request *ReadRequest) (*ReadResponse, error) {\n\trsp := &ReadResponse{}\n\treturn rsp, t.client.Call(\"db\", \"Read\", request, rsp)\n}", "func Read(L *lua.LState) int {\n\tn := checkLuaNetClient(L, 1)\n\tsize := L.CheckInt(2)\n\n\tbuf := make([]byte, size)\n\tif (n.readTimeout) > 0 {\n\t\tn.SetReadDeadline(time.Now().Add(n.readTimeout))\n\t}\n\tcount, err := n.Read(buf)\n\tif err != nil {\n\t\tL.Push(lua.LNil)\n\t\tL.Push(lua.LString(err.Error()))\n\t\treturn 2\n\t}\n\n\tL.Push(lua.LString(string(buf[0:count])))\n\treturn 1\n}", "func (v *vsockConn) Read(buf []byte) (int, error) {\n\treturn v.vsock.Read(buf)\n}", "func (c *Conn) Read(b []byte) (n int, err error) {\n\terr = func() error {\n\t\tc.mu.Lock()\n\t\tdefer c.mu.Unlock()\n\n\t\tif c.state != StateAspActive {\n\t\t\treturn ErrNotEstablished\n\t\t}\n\t\treturn nil\n\t}()\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tpd, ok := <-c.dataChan\n\tif !ok {\n\t\treturn 0, ErrNotEstablished\n\t}\n\n\tcopy(b, pd.Data)\n\treturn len(pd.Data), nil\n\n}", "func (p *Postgres) Read() Ext {\n\treturn p.Connection()\n}", "func read(addr string) error {\n\tconn, err := net.Dial(\"tcp\", addr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer conn.Close()\n\tif _, err = conn.Read(make([]byte, 1)); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func Read(con *net.Conn) (reader chan string) {\n\treader=make(chan string)\n//\tvar buf = make ([]byte,4048);\n\tnetworkReader:=bufio.NewReader(*con)\n\tgo func() {\n\t\tfor {\n\t\t\tstr, err := networkReader.ReadString('\\n');\n\t\t\tif err!=nil {\n/*\t\t\t\tif !closed(reader) {\n\t\t\t\t\treader<-errorString(\"netConn Read : \",err)\n\t\t\t\t}*/\n\t\t\t\tif err==os.EOF { close(reader) }\n\t\t\t} else {\n\t\t\t\treader<-str\n\t}}} ()\n\treturn reader\n}", "func (c *Client) read(conn *net.TCPConn) (res []byte, err error) {\n\tres = make([]byte, 10240)\n\tres, err = ioutil.ReadAll(conn)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"Error while receiving the data: %s\", err.Error())\n\t\treturn\n\t}\n\n\treturn\n}", "func (fpc *FakePacketConn) Read(b []byte) (int, error) {\n\tn, _, err := fpc.ReadFrom(b)\n\treturn n, err\n}", "func (x *pwConn) Read(buf []byte) (int, error) {\n\tif err := x.handshake(); err != nil {\n\t\treturn 0, err\n\t}\n\treturn x.Conn.Read(buf)\n}", "func (p *TBufferedReadTransport) Read(buf []byte) (int, error) {\n\tin, err := p.readBuf.Read(buf)\n\treturn in, thrift.NewTTransportExceptionFromError(err)\n}", "func (conn *Conn) read(n int) ([]byte, error) {\n\tresult, err := conn.brw.Peek(n)\n\n\tif err != nil {\n\t\tfmt.Println(\"Error while peeking read buffer\", err)\n\t\treturn result, err\n\t}\n\n\t_, err = conn.brw.Discard(n)\n\n\tif err != nil {\n\t\tfmt.Println(\"Error while discarding read buffer\", err)\n\t}\n\n\treturn result, err\n}", "func (c *LimitedConnection) Read(b []byte) (read int, err error) {\n\treturn c.rateLimitLoop(&c.readNotBefore, &c.readDeadline, c.inner.Read, b)\n}", "func (nc noClose) Read(p []byte) (n int, err error) {\n\treturn nc.in.Read(p)\n}", "func (c *Conn) Read(b []byte) (int, error) {\n\tvar err error\n\tc.once.Do(func() { err = c.scanProxyData() })\n\tif err != nil {\n\t\treturn 0, err // return if an error occured while reading prefix\n\t}\n\n\treturn c.Reader.Read(b)\n}", "func (c *Conn) CloseRead() error {\n\tif closer, ok := c.Conn.(interface {\n\t\tCloseRead() error\n\t}); ok {\n\t\treturn closer.CloseRead()\n\t}\n\treturn nil\n}", "func (s *Session) Read(buf []byte) (int, error) {\n\t_, r, err := s.ws.NextReader()\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tn, err := r.Read(buf)\n\tif err != nil {\n\t\treturn n, err\n\t}\n\n\tatomic.StoreInt32(&s.timeout, 0)\n\n\treturn n, err\n}", "func (r *Reader) Read(bs []byte) (int, error) {\n\treturn r.R(0).Read(bs)\n}", "func (c *udpListenerConn) Read(byt []byte) (int, error) {\n\tvar buf []byte\n\tvar ok bool\n\n\tif !c.readDeadline.IsZero() {\n\t\treadTimer := time.NewTimer(c.readDeadline.Sub(time.Now()))\n\t\tdefer readTimer.Stop()\n\n\t\tselect {\n\t\tcase <-readTimer.C:\n\t\t\treturn 0, udpErrorTimeout\n\t\tcase buf, ok = <-c.read:\n\t\t}\n\t} else {\n\t\tbuf, ok = <-c.read\n\t}\n\n\tif ok == false {\n\t\treturn 0, udpErrorTerminated\n\t}\n\n\tcopy(byt, buf)\n\tc.listener.readDone <- struct{}{}\n\treturn len(buf), nil\n}", "func (mc *MockConn) Read(b []byte) (int, error) {\n\tif mc.closed {\n\t\treturn 0, errors.New(\"Connection closed.\")\n\t}\n\n\ti := 0\n\tfor i < len(b) {\n\t\tif mc.outMessage == nil {\n\t\t\tselect {\n\t\t\tcase <-mc.done:\n\t\t\t\treturn 0, errors.New(\"Connection closed.\")\n\t\t\tcase mc.outMessage = <-mc.receiveChan:\n\t\t\t}\n\t\t\tmc.outPlace = 0\n\t\t}\n\n\t\tfor mc.outPlace < len(mc.outMessage) && i < len(b) {\n\t\t\tb[i] = mc.outMessage[mc.outPlace]\n\t\t\tmc.outPlace++\n\t\t\ti++\n\t\t}\n\n\t\tif mc.outPlace == len(mc.outMessage) {\n\t\t\tmc.outMessage = nil\n\t\t}\n\t}\n\n\treturn i, nil\n}", "func read(c net.Conn) ([]byte, error) {\n\tvar msgSize, err = messageLength(c)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tmsgBuf := make([]byte, msgSize)\n\t_, err = io.ReadFull(c, msgBuf)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn msgBuf, nil\n}", "func (c *Conn) Read(b []byte) (n int, err error) {\n\tif len(b) == 0 {\n\t\treturn 0, nil\n\t}\n\terr = tryAgain\n\tfor err == tryAgain {\n\t\tn, errcb := c.read(b)\n\t\terr = c.handleError(errcb)\n\t\tif err == nil {\n\t\t\tgo c.flushOutputBuffer()\n\t\t\treturn n, nil\n\t\t}\n\t\tif err == io.ErrUnexpectedEOF {\n\t\t\terr = io.EOF\n\t\t}\n\t}\n\treturn 0, err\n}", "func (s *Session) Read() (*SessionSnapshot, error) {\n\ts.m.Lock()\n\tdefer s.m.Unlock()\n\tss, err := s.readFile()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ss, nil\n}", "func (n *Neo4jPG) Read(cypher string, params map[string]interface{}, cRHandle func(r neo4j.Record) (interface{}, error)) (res interface{}, err error) {\n\tif n.Session, err = n.Driver.Session(neo4j.AccessModeRead); err != nil {\n\t\tpkg.ReportError(pgl.ErrorReport{Msg: \"Error thrown in Session\", Err: err.Error()})\n\t\treturn nil, err\n\t}\n\tdefer n.Session.Close()\n\n\tres, err = n.Session.ReadTransaction(func(tx neo4j.Transaction) (interface{}, error) {\n\t\tvar list []interface{}\n\t\tvar result neo4j.Result\n\n\t\tif result, err = tx.Run(cypher, params); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tfor result.Next() {\n\t\t\tif cRHandle != nil {\n\t\t\t\tr, err := cRHandle(result.Record())\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tlist = append(list, r)\n\t\t\t} else {\n\t\t\t\tprops := result.Record().GetByIndex(0).(neo4j.Node).Props()\n\t\t\t\tlist = append(list, props)\n\t\t\t}\n\t\t}\n\n\t\tif err = result.Err(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn list, nil\n\t})\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn res, err\n}", "func (ls *LiveSession) Read(b []byte, v interface{}) (interface{}, error) {\n\n\tfilter, err := parseRead(b)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp := ls.Collection.FindOne(context.Background(), filter)\n\n\tif err := resp.Decode(v); err != nil {\n\t\tif err == mongo.ErrNoDocuments {\n\t\t\treturn nil, ErrNoMatchedDocument\n\t\t}\n\t\treturn nil, err\n\t}\n\n\treturn v, nil\n\n}", "func (r *ReadStreamSRTCP) Read(b []byte) (int, error) {\n\tselect {\n\tcase <-r.session.closed:\n\t\treturn 0, fmt.Errorf(\"SRTCP session is closed\")\n\tcase r.readCh <- b:\n\t}\n\n\tselect {\n\tcase <-r.session.closed:\n\t\treturn 0, fmt.Errorf(\"SRTCP session is closed\")\n\tcase res := <-r.readRetCh:\n\t\treturn res.len, nil\n\t}\n}", "func DialRead(address string) (*ConnClient, error) {\n\treturn DefaultDialer.DialRead(address)\n}", "func (s *session) Read(data []byte) (int, error) {\n\ts.readLock.Lock()\n\tdefer s.readLock.Unlock()\n\t// TODO: check error?\n\tn := len(data)\n\t// If there is anything unread, it's part of a partially read message. Return it.\n\tnu := len(s.unread)\n\tif nu > 0 {\n\t\tcopy(data, s.unread)\n\t\tif nu > n {\n\t\t\ts.unread = s.unread[n:]\n\t\t\treturn n, nil\n\t\t} else {\n\t\t\ts.unread = nil\n\t\t\treturn nu, nil\n\t\t}\n\t}\n\n\tm, ok := <-s.readQueue\n\tif !ok {\n\t\t// We're closed\n\t\treturn 0, io.EOF\n\t}\n\tmbytes := m.bytes()\n\tcopy(data, mbytes)\n\tnm := len(mbytes)\n\tif nm > n {\n\t\ts.unread = mbytes[n:]\n\t\treturn n, nil\n\t}\n\treturn nm, nil\n}", "func (client *Client) Read() {\n\tvar message Message\n\tfor {\n\t\tif err := client.socket.ReadJSON(&message); err != nil {\n\t\t\tbreak\n\t\t}\n\t\t// Call findHandler to know which handler to call. If handler in router map value matches key then call it.\n\t\tif handler, found := client.findHandler(message.Name); found {\n\t\t\thandler(client, message.Data)\n\t\t}\n\t}\n\t// close connection once finished.\n\tclient.socket.Close()\n}", "func (c *Conn) Read(file string) ([]byte, bool) {\n\tc.Log.Infof(\"Reading from {%s} with provider{%s} to bucket{%s}\", file, c.provider, c.bucketname)\n\n\tdata, err := c.bucket.ReadAll(c.ctx, file)\n\tif err != nil {\n\t\tc.Log.Errorf(\"Failed to read data from file{%s} : %s\", file, err.Error())\n\t\treturn nil, false\n\t}\n\n\tc.Log.Infof(\"successfully read object{%s} to {%s}\", file, c.provider)\n\treturn data, true\n}", "func (t TerminalSession) Read(p []byte) (int, error) {\n\tm := <-t.receiver\n\treturn copy(p, m), nil\n}", "func Read(com Communicator, con *net.TCPConn) (string, error) {\n\tkey := ReadBytes(com, con, len(com.Key()))\n\tif key != com.Key() {\n\t\treturn \"\", errors.New(KeyFail)\n\t}\n\tns := []byte(ReadBytes(com, con, MessageLengthBytes))\n\tn := 0\n\tfor _, ch := range ns {\n\t\tn = n<<Byte + int(ch)\n\t}\n\treturn ReadBytes(com, con, n), nil\n}", "func (c *conn) ReadMsg() ([]byte, error) {\n\treturn c.base.ReadMsg()\n}", "func (c *connection) read() (data []byte, err error) {\n\tif !c.available() {\n\t\terr = ErrCannotRead\n\t\treturn\n\t}\n\tc.setReadDeadline()\n\tvar count int\n\t// TODO error conditions http://golang.org/pkg/io/#ReadFull, like EOF conditions\n\tif count, err = io.ReadFull(c.conn, c.sizeBuf); err == nil && count == 4 {\n\t\tmessageLength := binary.BigEndian.Uint32(c.sizeBuf)\n\t\t// TODO: investigate using a bytes.Buffer on c instead of\n\t\t// always making a new byte slice, more in-line with Node.js client\n\t\tdata = make([]byte, messageLength)\n\t\tc.setReadDeadline()\n\t\t// TODO error conditions http://golang.org/pkg/io/#ReadFull, like EOF conditions\n\t\tcount, err = io.ReadFull(c.conn, data)\n\t\tif err != nil && err == syscall.EPIPE {\n\t\t\tc.close()\n\t\t} else if uint32(count) != messageLength {\n\t\t\terr = fmt.Errorf(\"[Connection] message length: %d, only read: %d\", messageLength, count)\n\t\t}\n\t}\n\tif err != nil {\n\t\t// TODO why not close() ?\n\t\tc.state = connInactive\n\t\tdata = nil\n\t}\n\treturn\n}", "func (e *endpoint) Read(addr *tcpip.FullAddress) (buffer.View, tcpip.ControlMessages, *tcpip.Error) {\n\te.rcvMu.Lock()\n\n\tif e.rcvList.Empty() {\n\t\terr := tcpip.ErrWouldBlock\n\t\tif e.rcvClosed {\n\t\t\terr = tcpip.ErrClosedForReceive\n\t\t}\n\t\te.rcvMu.Unlock()\n\t\treturn buffer.View{}, tcpip.ControlMessages{}, err\n\t}\n\n\tp := e.rcvList.Front()\n\te.rcvList.Remove(p)\n\te.rcvBufSize -= p.data.Size()\n\tts := e.rcvTimestamp\n\n\te.rcvMu.Unlock()\n\n\tif addr != nil {\n\t\t*addr = p.senderAddress\n\t}\n\n\tif ts && !p.hasTimestamp {\n\t\t// Linux uses the current time.\n\t\tp.timestamp = e.stack.NowNanoseconds()\n\t}\n\n\treturn p.data.ToView(), tcpip.ControlMessages{HasTimestamp: ts, Timestamp: p.timestamp}, nil\n}", "func (usrwc *UnixSingleReadWriteCloser) Read(p []byte) (int, error) {\n\tvar err error\n\tif usrwc.c == nil {\n\t\tusrwc.c, err = usrwc.l.Accept()\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\n\treturn usrwc.c.Read(p)\n}", "func (this *Roomba) Read(p []byte) (n int, err error) {\n\treturn this.S.Read(p)\n}", "func (c *Client) Read() {\n\tdefer func() {\n\t\tc.Broker.Unregister <- c\n\t\tc.Conn.Close()\n\t}()\n\n\tfor {\n\t\t_, buf, err := c.Conn.ReadMessage()\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\t\tvar move structs.Word\n\t\tdecoder := json.NewDecoder(strings.NewReader(string(buf)))\n\t\terr = decoder.Decode(&move)\n\n\t\tc.Broker.Broadcast <- move\n\t\t//log.Printf(\"Client: Move received: %+v\\n\", move)\n\t}\n}", "func (gb *MutexReadWriter) Read(p []byte) (int, error) {\n\tgb.Lock()\n\tdefer gb.Unlock()\n\treturn gb.rw.Read(p)\n}", "func (r *timeoutReadCloser) Read(b []byte) (int, error) {\n\ttimer := time.NewTimer(r.duration)\n\tc := make(chan readResult, 1)\n\n\tgo func() {\n\t\tn, err := r.reader.Read(b)\n\t\ttimer.Stop()\n\t\tc <- readResult{n: n, err: err}\n\t}()\n\n\tselect {\n\tcase data := <-c:\n\t\treturn data.n, data.err\n\tcase <-timer.C:\n\t\treturn 0, &ResponseTimeoutError{TimeoutDur: r.duration}\n\t}\n}", "func read(conn net.Conn) (b []byte, err error) {\n\tb, err = bufio.NewReader(conn).ReadBytes(Delimiter)\n\tif err == nil {\n\t\tb = b[:len(b)-1]\n\t}\n\n\treturn\n}", "func read(conn net.Conn) (b []byte, err error) {\n\tb, err = bufio.NewReader(conn).ReadBytes(Delimiter)\n\tif err == nil {\n\t\tb = b[:len(b)-1]\n\t}\n\n\treturn\n}", "func read(conn net.Conn) (b []byte, err error) {\n\tb, err = bufio.NewReader(conn).ReadBytes(Delimiter)\n\tif err == nil {\n\t\tb = b[:len(b)-1]\n\t}\n\n\treturn\n}", "func read(conn net.Conn) (b []byte, err error) {\n\tb, err = bufio.NewReader(conn).ReadBytes(Delimiter)\n\tif err == nil {\n\t\tb = b[:len(b)-1]\n\t}\n\n\treturn\n}", "func (p defaultReadParser) Read() ([]byte, error) {\n\tl := 0\n\tresponseLengthBuf := make([]byte, 4)\n\tfor {\n\t\tif p.timeout > 0 {\n\t\t\tp.broker.conn.SetReadDeadline(time.Now().Add(time.Duration(p.timeout) * time.Millisecond))\n\t\t}\n\t\tlength, err := p.broker.conn.Read(responseLengthBuf[l:])\n\t\tif err != nil {\n\t\t\tp.broker.Close()\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif length+l == 4 {\n\t\t\tbreak\n\t\t}\n\t\tl += length\n\t}\n\tresponseLength := int(binary.BigEndian.Uint32(responseLengthBuf))\n\tglog.V(10).Infof(\"response length in header: %d\", responseLength+4)\n\tresp := make([]byte, 4+responseLength)\n\n\treadLength := 0\n\tfor {\n\t\tif p.timeout > 0 {\n\t\t\tp.broker.conn.SetReadDeadline(time.Now().Add(time.Duration(p.timeout) * time.Millisecond))\n\t\t}\n\t\tlength, err := p.broker.conn.Read(resp[4+readLength:])\n\t\tif err != nil {\n\t\t\tp.broker.Close()\n\t\t\treturn nil, err\n\t\t}\n\n\t\treadLength += length\n\t\tif readLength > responseLength {\n\t\t\treturn nil, errors.New(\"fetch more data than needed while read response\")\n\t\t}\n\t\tif readLength == responseLength {\n\t\t\tbreak\n\t\t}\n\t}\n\tcopy(resp[0:4], responseLengthBuf)\n\tif glog.V(10) {\n\t\tglog.Infof(\"response length: %d. CorrelationID: %d\", len(resp), binary.BigEndian.Uint32(resp[4:]))\n\t}\n\treturn resp, nil\n}", "func (s *Socket) Read() (p *Packet, err error) {\n\ts.RLock()\n\tconn := s.Conn\n\ts.RUnlock()\n\tif err = conn.SetReadDeadline(time.Now().Add(s.readTimeout)); err != nil {\n\t\treturn\n\t}\n\tp, err = conn.ReadPacket()\n\treturn\n}", "func (c *UDPConn) Read(p []byte) (int, error) {\n\t_, err := io.ReadFull(c.ReadWriteCloser, p[:4])\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tn := binary.BigEndian.Uint32(p[:4])\n\treturn io.ReadFull(c.ReadWriteCloser, p[:n])\n}", "func (c *Configr) Read(key string) (interface{}, error) {\n\treturn c.Get(key)\n}", "func (s *Socket) ReadMsg() {\r\n\ttmpBuffer := make([]byte, 0)\r\n\tdata := make([]byte, INTERVAL)\r\n\tfor {\r\n\t\t// get length\r\n\t\tn, err := s.Conn.Read(data)\r\n\t\tif err != nil {\r\n\t\t\ts.Conn.Close()\r\n\t\t\ts.CloseChan <- true\r\n\t\t\tfmt.Println(\"Conn has been Closed.\")\r\n\t\t\ts.Closef()\r\n\t\t\tbreak\r\n\t\t}\r\n\t\ttmpBuffer = s.unpack(append(tmpBuffer, data[:n]...))\r\n\t}\r\n}", "func (clientHandler) Read(ctx context.Context, bytes int64) context.Context { return ctx }", "func (ch *IsaChannel) Read(b []byte) (int, error) {\n\treturn 0, nil\n}", "func (ch *clientSecureChannel) Read(p []byte) (int, error) {\n\tif ch.conn == nil {\n\t\treturn 0, ua.BadSecureChannelClosed\n\t}\n\n\tvar err error\n\tnum := 0\n\tn := 0\n\tcount := 8\n\tfor num < count {\n\t\tn, err = ch.conn.Read(p[num:count])\n\t\tif err != nil || n == 0 {\n\t\t\treturn num, err\n\t\t}\n\t\tnum += n\n\t}\n\n\tcount = int(binary.LittleEndian.Uint32(p[4:8]))\n\tfor num < count {\n\t\tn, err = ch.conn.Read(p[num:count])\n\t\tif err != nil || n == 0 {\n\t\t\treturn num, err\n\t\t}\n\t\tnum += n\n\t}\n\n\treturn num, err\n}", "func (d *Device) GetRead() (*bufio.Reader, error) {\n\tc, err := d.newConn()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tr := bufio.NewReader(c)\n\treturn r, nil\n}", "func (c udpConn) CloseRead() error {\n\treturn fmt.Errorf(\"Unimplemented\")\n}", "func read(conn *net.TCPConn, size int, data *bytes.Buffer) error {\n\tconn.SetReadDeadline(time.Now().Add(time.Second * 15))\n\n\tn, err := io.CopyN(data, conn, int64(size))\n\tif err != nil || n != int64(size) {\n\t\treturn errors.New(\"read error\")\n\t}\n\treturn nil\n}", "func (s *Session) Read(key *Key, offset uint64, size uint64) (b []byte, err error) {\n\t// TODO use reflect.SliceHeader and manage data ourselves?\n\tdata, dataSize, err := s.read(key, offset, size)\n\tif data == nil {\n\t\treturn\n\t}\n\tdefer C.free(data)\n\n\tb = C.GoBytes(unsafe.Pointer(uintptr(data)+readOffset), C.int(dataSize)-C.int(readOffset))\n\treturn\n}" ]
[ "0.751353", "0.74954724", "0.7471595", "0.7398077", "0.7330712", "0.7235126", "0.722001", "0.71372116", "0.71111274", "0.709893", "0.70859236", "0.70671546", "0.7060391", "0.70343703", "0.702886", "0.7021947", "0.698377", "0.6972257", "0.69662213", "0.69353044", "0.6924279", "0.69042635", "0.6892935", "0.6891072", "0.68904513", "0.68870586", "0.685705", "0.68315303", "0.6805598", "0.68013597", "0.6785431", "0.6785103", "0.6781339", "0.67784953", "0.6772997", "0.6772997", "0.6772658", "0.6662341", "0.66578543", "0.6657663", "0.6650693", "0.6647262", "0.6628278", "0.6627292", "0.6620762", "0.6606183", "0.6605275", "0.66051304", "0.66019166", "0.6570129", "0.6561449", "0.6552007", "0.6537139", "0.65089995", "0.6482489", "0.64765364", "0.6439981", "0.64394796", "0.6422407", "0.6420731", "0.64192945", "0.63937294", "0.6391875", "0.63879126", "0.6371931", "0.63690704", "0.63540107", "0.6350855", "0.63495445", "0.6335516", "0.63350064", "0.6310002", "0.62920594", "0.6281468", "0.6280822", "0.62617415", "0.6257981", "0.62513417", "0.62399524", "0.62270296", "0.62249935", "0.62245196", "0.62219214", "0.6210804", "0.6208469", "0.6208469", "0.6208469", "0.6208469", "0.62013274", "0.6192041", "0.6191228", "0.61900693", "0.6189572", "0.61893797", "0.6184003", "0.6183149", "0.6181233", "0.6169353", "0.61569816", "0.6155674" ]
0.6590935
49
Write implements the Conn Write method.
func (c *Conn) Write(b []byte) (int, error) { if !c.ok() { return 0, syscall.EINVAL } payload := b if len(payload) > mss { payload = payload[:mss] } _, err := c.sendBuf.Push(payload) if err != nil { return 0, err } l, err := c.sendDATA(payload) if err != nil { return 0, err } return l, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (connection *Connection) Write(b []byte) (int, error) {\n\t//TODO\n}", "func (p *Conn) Write(b []byte) (int, error) {\n\treturn p.conn.Write(b)\n}", "func (c *conn) Write(p []byte) (int, error) {\n\terr := binary.Write(c.Conn, binary.BigEndian, uint32(len(p)))\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn c.Conn.Write(p)\n}", "func ConnWrite(c *tls.Conn, b []byte) (int, error)", "func (clientConn *Conn) Write(p []byte) (n int, err error) {\n\treturn clientConn.dataWriter.Write(p)\n}", "func (dc *dummyConn) Write(p []byte) (int, error) { return len(p), nil }", "func (c *Connection) Write(mt int, payload []byte) error {\n\tc.Conn.SetWriteDeadline(time.Now().Add(WriteWait))\n\treturn c.Conn.WriteMessage(mt, payload)\n}", "func (c *Conn) Write(b []byte) (int, error) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\treturn c.Conn.Write(b)\n}", "func (c *WrappedConn) Write(b []byte) (n int, err error) {\n\t//c.Conn is certainly not nil\n\tn, err = c.Conn.Write(b)\n\tif err != nil {\n\t\tc.unusable = true\n\t} else {\n\t\tc.lastAccess = time.Now()\n\t}\n\treturn\n}", "func (c *Conn) Write(buf []byte) (int, error) {\n\tc.WriteToHash(buf)\n\treturn c.w.Write(buf)\n}", "func (s *session) Write(w pdu.Body) error {\n\treturn s.conn.Write(w)\n}", "func (dc *DebugConn) Write(p []byte) (int, error) {\n\tif dc.isClosed() {\n\t\treturn 0, ErrClosed\n\t}\n\n\tn, err := dc.Conn.Write(p)\n\n\tif dc.writeDebug != nil {\n\t\tdc.readDebug(dc.logger, false, dc.isClient, dc.id, p, n, err)\n\t}\n\n\treturn n, err\n}", "func (c *SodaClient) Write(sendMsg string) {\n\tmsg := strings.TrimSpace(sendMsg)\n\n\tbuf := []byte(msg)\n\n\t_, err := c.conn.Write(buf) // returns string length of write and potential write errors\n\n\tif err != nil {\n\t\tfmt.Println(msg, err)\n\t}\n}", "func (c *conn) Write(data []byte) (n int, err error) {\n\treq := &client.Packet{\n\t\tType: client.PacketType_DATA,\n\t\tPayload: &client.Packet_Data{\n\t\t\tData: &client.Data{\n\t\t\t\tConnectID: c.connID,\n\t\t\t\tData: data,\n\t\t\t},\n\t\t},\n\t}\n\n\tklog.V(5).InfoS(\"[tracing] send req\", \"type\", req.Type)\n\n\terr = c.tunnel.Send(req)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn len(data), err\n}", "func (c *connection) Write(mt int, payload []byte) error {\r\n\tc.ws.SetWriteDeadline(time.Now().Add(writeWait))\r\n\treturn c.ws.WriteMessage(mt, payload)\r\n}", "func (bc BufConn) Write(p []byte) (int, error) {\n\tif bc.IgnoreWrite {\n\t\treturn len(p), nil\n\t}\n\tif bc.OnWrite != nil {\n\t\tbc.OnWrite(p)\n\t\treturn len(p), nil\n\t}\n\treturn bc.Buf.Write(p)\n}", "func (c *Connection) Write(b []byte) (int, error) {\n\twt := config.Get().Timeout.TimeoutReadWrite\n\tif wt == 0 {\n\t\twt = 1\n\t}\n\n\twriteTimeout := time.Duration(wt) * time.Second // Max idle time for a peer\n\n\tc.lock.Lock()\n\t_ = c.Conn.SetWriteDeadline(time.Now().Add(writeTimeout))\n\tn, err := c.Conn.Write(b)\n\tc.lock.Unlock()\n\n\treturn n, err\n}", "func (c *Conn) Write(p []byte) (n int, err error) {\n\tn, err = c.bufw.Write(p)\n\tc.bufw.Flush()\n\treturn n, err\n}", "func (c *Conn) Write(b []byte) (n int, err error) {\n\treturn syscall.Write(c.fd, b)\n}", "func (t *cliTransHandler) Write(ctx context.Context, conn net.Conn, sendMsg remote.Message) (err error) {\n\tvar bufWriter remote.ByteBuffer\n\tstats2.Record(ctx, sendMsg.RPCInfo(), stats.WriteStart, nil)\n\tdefer func() {\n\t\tt.ext.ReleaseBuffer(bufWriter, err)\n\t\tstats2.Record(ctx, sendMsg.RPCInfo(), stats.WriteFinish, err)\n\t}()\n\n\tbufWriter = t.ext.NewWriteByteBuffer(ctx, conn, sendMsg)\n\tsendMsg.SetPayloadCodec(t.opt.PayloadCodec)\n\terr = t.codec.Encode(ctx, sendMsg, bufWriter)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn bufWriter.Flush()\n}", "func (c *context) write(data []byte) error {\n\tdefer c.close()\n\t_, err := c.conn.Write(data)\n\n\treturn err\n}", "func (c *Client) Write(message *Message) {\n\tfmt.Fprintf(c.Conn, message.ToString())\n}", "func (cr ConnectResponse) Write(connWriter *bufio.Writer) error {\n\n\terr := connWriter.WriteByte(cr.Ver)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = connWriter.WriteByte(cr.Method)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn connWriter.Flush()\n}", "func (c *Conn) Write(b []byte) (int, error) {\n\tif c.writeTimeout > 0 {\n\t\tif err := c.Conn.SetWriteDeadline(time.Now().Add(c.writeTimeout)); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\tn, err := c.Conn.Write(b)\n\tif err == nil && c.Stats != nil {\n\t\tc.Stats.WriteTotal.Add(uint64(n))\n\t}\n\tc.incBytesOut(n)\n\treturn n, err\n}", "func (c *minecraftConn) Write(payload []byte) (err error) {\n\tif c.Closed() {\n\t\treturn ErrClosedConn\n\t}\n\tdefer func() { c.closeOnErr(err) }()\n\tif _, err = c.encoder.Write(payload); err != nil {\n\t\treturn err\n\t}\n\treturn c.flush()\n}", "func (ch *clientSecureChannel) Write(p []byte) (int, error) {\n\treturn ch.conn.Write(p)\n}", "func (conn *Conn) Write(msgType int, data []byte) error {\n\tconn.writer.Lock()\n\tdefer conn.writer.Unlock()\n\treturn conn.socket.WriteMessage(msgType, data)\n}", "func (c *tcpConnection) Write(message []byte) error {\n\tc.conn.SetReadDeadline(time.Now().Add(c.readTimeout * time.Second))\n\tc.conn.SetWriteDeadline(time.Now().Add(c.writeTimeout * time.Second))\n\tc.cipherMutex.RLock()\n\tif c.ciph != nil {\n\t\tmessage = cryptoutil.SymmetricEncrypt(c.ciph, message)\n\t}\n\tc.cipherMutex.RUnlock()\n\n\terr := binary.Write(c.conn, binary.LittleEndian, uint32(len(message)))\n\t//fmt.Printf(\"tcpConnection.Write1\\n\")\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = binary.Write(c.conn, binary.LittleEndian, tcpConnectionMagic)\n\t//fmt.Printf(\"tcpConnection.Write2\\n\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = c.conn.Write(message)\n\t//fmt.Printf(\"tcpConnection.Write3\\n\")\n\treturn err\n}", "func (d *Device) Write(buf []byte) (n int, err error) {\n\treturn d.conn.Write(buf)\n}", "func (c *Conn) Write(p []byte) (n int, err error) {\n\terr = c.Handshake()\n\tif err != nil {\n\t\treturn\n\t}\n\n\twriter := NewSecureWriter(c.rawConn, c.priv, c.peerPublicKey)\n\treturn writer.Write(p)\n}", "func (x *pwConn) Write(buf []byte) (int, error) {\n\tif err := x.handshake(); err != nil {\n\t\treturn 0, err\n\t}\n\treturn x.Conn.Write(buf)\n}", "func (c *Connection) write(msg interface{}) {\n c.mutex.Lock()\n c.log(fmt.Sprintf(\"Sending message: %+v\", msg))\n c.socket.WriteJSON(msg)\n c.mutex.Unlock()\n}", "func (c *Conn) Write(b []byte) (int, error) {\n\terr := c.Conn.SetWriteDeadline(time.Now().Add(c.WriteTimeout))\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn c.Conn.Write(b)\n}", "func (c *Client) Write(data []byte) (err error) {\n\tif c.conn == nil {\n\t\treturn errors.New(\"connection is not defined\")\n\t}\n\n\tif c.crypto != nil {\n\t\tdata, err = c.crypto.Encrypt(data)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"failed to encrypt data\")\n\t\t}\n\t}\n\n\tdataLen := uint32(len(data))\n\n\terr = binary.Write(c.conn, binary.LittleEndian, dataLen)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to write data len\")\n\t}\n\n\terr = binary.Write(c.conn, binary.LittleEndian, Magic)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to write magic\")\n\t}\n\n\tn, err := c.conn.Write(data)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to write data\")\n\t}\n\n\tif uint32(n) != dataLen {\n\t\treturn errors.Wrap(err, \"data wasn't fully sent\")\n\t}\n\n\treturn nil\n}", "func (n *NetConn) Write([]byte) (numBytes int, err error) {\n\treturn 1, n.errOnWrite\n}", "func Write(conn net.Conn, content string) (int, error) {\n\twriter := bufio.NewWriter(conn)\n\tnumber, err := writer.WriteString(content)\n\tif err == nil {\n\t\terr = writer.Flush()\n\t}\n\treturn number, err\n}", "func ConnCloseWrite(c *tls.Conn,) error", "func (e errorConnection) Write(b []byte) (n int, err error) {\n\treturn 0, e.err\n}", "func (fwd *QuestdbForwarder) Write(b []byte) (n int, err error) {\n\tvar (\n\t\tlogp = `QuestdbForwarder.Write`\n\t\tnow = time.Now()\n\t)\n\n\terr = fwd.conn.SetWriteDeadline(now.Add(5 * time.Second))\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(`%s: SetWriteDeadline: %s`, logp, err)\n\t}\n\n\t_, err = fwd.conn.Write(b)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(`%s: %s`, logp, err)\n\t}\n\n\treturn n, nil\n}", "func (dc *Conn) Write(b []byte) (n int, err error) {\n\tif dc.inState(stateInitial) {\n\t\tif n, err = dc.writeLocalBuffer(b); err != nil {\n\t\t\treturn n, fmt.Errorf(\"Unable to write local buffer: %s\", err)\n\t\t}\n\t}\n\tif n, err = dc.getConn().Write(b); err != nil {\n\t\tlog.Debugf(\"Error while write %d bytes to %s %s: %s\", len(b), dc.addr, dc.stateDesc(), err)\n\t\treturn\n\t}\n\tlog.Tracef(\"Wrote %d bytes to %s %s\", len(b), dc.addr, dc.stateDesc())\n\treturn\n}", "func (ctn *Connection) Write(buf []byte) (total int, aerr Error) {\n\tvar err error\n\n\t// make sure all bytes are written\n\t// Don't worry about the loop, timeout has been set elsewhere\n\tif err = ctn.updateDeadline(); err == nil {\n\t\tif total, err = ctn.conn.Write(buf); err == nil {\n\t\t\treturn total, nil\n\t\t}\n\n\t\t// If all bytes are written, ignore any potential error\n\t\t// The error will bubble up on the next network io if it matters.\n\t\tif total == len(buf) {\n\t\t\treturn total, nil\n\t\t}\n\t}\n\n\taerr = chainErrors(errToAerospikeErr(ctn, err), aerr)\n\n\tif ctn.node != nil {\n\t\tctn.node.incrErrorCount()\n\t\tatomic.AddInt64(&ctn.node.stats.ConnectionsFailed, 1)\n\t}\n\n\tctn.Close()\n\n\treturn total, aerr\n}", "func (v *vsockConn) Write(buf []byte) (int, error) {\n\treturn v.vsock.Write(buf)\n}", "func (r *RPCIngressGateway) Write(req *WriteReq, resp *WriteResp) error {\n\tconn, err := r.getConn(req.ConnID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresp.N, err = conn.Write(req.B)\n\tresp.Err = ioErrToRPCIOErr(err)\n\n\t// avoid error in RPC pipeline, error is included in response body\n\treturn nil\n}", "func (w *WriteStreamSRTCP) Write(b []byte) (int, error) {\n\treturn w.session.write(b)\n}", "func (p *protocolACKN) Write(conn tcp.Connection) error {\n\t// Encapsulate the ack into a message\n\t// 4-byte message header (ACKN)\n\t// 4-byte message length\n\t// 16-byte nonce\n\t// 4-byte uint32 sequence\n\tif _, err := conn.Write([]byte{'A', 'C', 'K', 'N', 0, 0, 0, 20}); err != nil {\n\t\treturn err\n\t}\n\n\tif _, err := conn.Write([]byte(*p.nonce)); err != nil {\n\t\treturn err\n\t}\n\n\tvar sequence [4]byte\n\tbinary.BigEndian.PutUint32(sequence[:], uint32(p.sequence))\n\tif _, err := conn.Write(sequence[:]); err != nil {\n\t\treturn err\n\t}\n\treturn conn.Flush()\n}", "func (fpc *FakePacketConn) Write(b []byte) (int, error) {\n\treturn fpc.WriteTo(b, FakeAddr)\n}", "func (c *connection) write(opCode int, payload []byte) error {\n\tc.ws.SetWriteDeadline(time.Now().Add(writeWait))\n\treturn c.ws.WriteMessage(opCode, payload)\n}", "func (w WriteAdapter) Write(data []byte) (int, error) {\n\treturn w.Writer.Write(data)\n}", "func (p *PoolHeightFetcher) WriteConn(msg interface{}) {\n\tm, err := json.Marshal(msg)\n\tif err != nil {\n\t\tp.HandleError(err)\n\t}\n\tlog.WithField(\"endpoint\", p.Address).Info(string(m))\n\tif _, err := p.Conn.Write(m); err != nil {\n\t\tp.HandleError(err)\n\t}\n\tif _, err := p.Conn.Write([]byte(\"\\n\")); err != nil {\n\t\tp.HandleError(err)\n\t}\n}", "func (c *UDPConn) Write(b []byte) (int, error) {\n\treturn c.write(b, nil)\n}", "func write(msg string, conn net.Conn) error {\n\tlog.Print(msg)\n\tconn.Write([]byte(msg))\n\treturn errors.New(msg)\n}", "func (dc DeadlineConn) Write(data []byte) (int, error) {\n\tcount := 0\n\terr := dc.Conn.SetWriteDeadline(time.Now().Add(dc.timeout))\n\tif err != nil {\n\t\treturn count, err\n\t}\n\t// don't bother with resetting the deadline since it will be set\n\t// again next time we call Write()\n\treturn dc.Conn.Write(data)\n}", "func (c *Conn) Write(b []byte) (int, error) {\n\n\t//\n\tif hp := c.config.Pattern; !c.isClient && len(hp.Messages) < 2 {\n\t\treturn 0, errors.New(\"A server should not write on one-way patterns\")\n\t}\n\n\t// Make sure to go through the handshake first\n\tif err := c.Handshake(); err != nil {\n\t\treturn 0, err\n\t}\n\n\t// Lock the write socket\n\tc.outLock.Lock()\n\tdefer c.outLock.Unlock()\n\n\t// process the data in a loop\n\tvar n int\n\tdata := b\n\tfor len(data) > 0 {\n\n\t\t// fragment the data\n\t\tm := len(data)\n\t\tif m > MaxMsgLen {\n\t\t\tm = MaxMsgLen\n\t\t}\n\n\t\t// Encrypt\n\t\tciphertext := c.out.Encrypt(nil, nil, data[:m])\n\n\t\t// header (length)\n\t\tlength := []byte{byte(len(ciphertext) >> 8), byte(len(ciphertext) % 256)}\n\n\t\t// Send data\n\t\t_, err := c.conn.Write(append(length, ciphertext...))\n\t\tif err != nil {\n\t\t\treturn n, err\n\t\t}\n\n\t\tn += m\n\t\tdata = data[m:]\n\t}\n\n\treturn n, nil\n}", "func (c invertedIDConn) Write(b []byte) (n int, err error) {\n\tframe := Frame(b)\n\tnewFrame := MakeFrame(frame.Type(), frame.TpID()^1, frame.Pay())\n\treturn c.Conn.Write(newFrame)\n}", "func (c *connectSvr) write(mt int, payload []byte) error {\n\tc.ws.SetWriteDeadline(time.Now().Add(writeWait))\n\treturn c.ws.WriteMessage(mt, payload)\n}", "func (c *udpListenerConn) Write(byt []byte) (int, error) {\n\tc.listener.writeMutex.Lock()\n\tdefer c.listener.writeMutex.Unlock()\n\n\tif !c.writeDeadline.IsZero() {\n\t\terr := c.listener.packetConn.SetWriteDeadline(c.writeDeadline)\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\n\treturn c.listener.packetConn.WriteTo(byt, c.addr)\n}", "func (c *Conn) Write(message proto.Message) (int, error) {\n\tpayload, err := proto.Marshal(message)\n\n\tif err != nil {\n\t\treturn -1, err\n\t}\n\n\tvar buf bytes.Buffer\n\n\t// Prepare *type* prefix\n\tmtype := messageTypes[reflect.TypeOf(message)]\n\tif _, err := buf.Write(uint16tbs(mtype)); err != nil {\n\t\treturn -1, err\n\t}\n\n\t// Prepare *size* prefix\n\tsize := uint32(len(payload))\n\tif _, err := buf.Write(uint32tbs(size)); err != nil {\n\t\treturn -1, err\n\t}\n\n\t// Prepare *payload* body\n\tif _, err := buf.Write(payload); err != nil {\n\t\treturn -1, err\n\t}\n\n\treturn c.conn.Write(buf.Bytes())\n}", "func (u *UDP) Write(data []byte, remote net.Addr) (int, error) {\n\treturn u.conn.WriteTo(data, remote)\n}", "func (c *Conn) Write(p []byte) (n int, err error) {\n\treturn c.write(websocket.BinaryMessage, p)\n}", "func (c *digisparkI2cConnection) Write(data []byte) (countWritten int, err error) {\n\tc.mtx.Lock()\n\tdefer c.mtx.Unlock()\n\n\treturn c.writeInternal(data, true)\n}", "func (cl *DoHClient) Write(packet []byte) (n int, err error) {\n\tn, err = cl.w.Write(packet)\n\tif err != nil {\n\t\tcl.responded <- false\n\t\treturn\n\t}\n\tcl.responded <- true\n\treturn\n}", "func (conn *Conn) Write(b []byte) (n int, err error) {\n\terr = conn.Handler.WriteMessage(conn.FrameType, b)\n\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn len(b), nil\n}", "func (p *ProxyWriter) Write(buf []byte) (int, error) {\n\treturn p.W.Write(buf)\n}", "func (h *Host) Write(b []byte) (nn int, err error) {\n\treturn h.W.Write(b)\n}", "func (c *Conn) write(mt int, payload []byte) error {\n\tc.ws.SetWriteDeadline(time.Now().Add(writeWait))\n\treturn c.ws.WriteMessage(mt, payload)\n}", "func (w *WriterHttpConn) Write(b []byte) (n int, err error) {\n\treader := bytes.NewReader(b)\n\treq, err := http.NewRequest(w.Method, w.url.Scheme+\"://\"+w.url.Host+w.url.Path, reader)\n\t//log.Debug(w.url.Scheme+\"://\"+w.url.Host+w.url.Path)\n\tif err != nil {\n\t\tlog.Error(\"Request failed to construct: %s\", err)\n\t\treturn 0, err\n\t}\n\n\tres, err := w.client.Do(req)\n\n\tif err != nil {\n\t\tlog.Error(\"post request failed: `%s`\", err)\n\t\treturn 0, err\n\t}\n\tio.Copy(ioutil.Discard, res.Body)\n\tres.Body.Close()\n\treturn len(b), nil\n}", "func (c *LimitedConnection) Write(b []byte) (written int, err error) {\n\treturn c.rateLimitLoop(&c.writeNotBefore, &c.writeDeadline, c.inner.Write, b)\n}", "func (c *Client) write(mt int, payload []byte) error {\n\tc.conn.SetWriteDeadline(time.Now().Add(writeWait))\n\treturn c.conn.WriteMessage(mt, payload)\n}", "func (conn *Connection) write(mt int, payload []byte, wsc config.WebSocketSettings) error {\n\tconn.ws.SetWriteDeadline(time.Now().Add(wsc.WriteWait))\n\treturn conn.ws.WriteMessage(mt, payload)\n}", "func (c *Conn) write(t int, buf []byte) error {\n\tc.ws.SetWriteDeadline(time.Now().Add(c.WriteTimeout * time.Second))\n\treturn c.ws.WriteMessage(t, buf)\n}", "func (c *UDPConn) Write(p []byte) (int, error) {\n\tif len(p) > math.MaxUint16 {\n\t\tpanic(\"unreachable\")\n\t}\n\tb := make([]byte, 4)\n\tbinary.BigEndian.PutUint32(b, uint32(len(p)))\n\t_, err := c.ReadWriteCloser.Write(b)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn c.ReadWriteCloser.Write(p)\n}", "func (c *connection) write(mt int, payload []byte) error {\n\tc.ws.SetWriteDeadline(time.Now().Add(writeWait))\n\treturn c.ws.WriteMessage(mt, payload)\n}", "func (c *connection) write(mt int, payload []byte) error {\n\tc.ws.SetWriteDeadline(time.Now().Add(writeWait))\n\treturn c.ws.WriteMessage(mt, payload)\n}", "func (mc *MockConn) Write(b []byte) (n int, err error) {\n\tif mc.closed {\n\t\treturn 0, errors.New(\"Connection closed.\")\n\t}\n\n\tdata := make([]byte, len(b))\n\tcopy(data, b)\n\tmc.sendChan <- data\n\treturn len(b), nil\n}", "func (c *client3E) Write(deviceName string, offset, numPoints int64, writeData []byte) ([]byte, error) {\n\trequestStr := c.stn.BuildWriteRequest(deviceName, offset, numPoints, writeData)\n\tpayload, err := hex.DecodeString(requestStr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tconn, err := net.DialTCP(\"tcp\", nil, c.tcpAddr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer conn.Close()\n\n\t// Send message\n\tif _, err = conn.Write(payload); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Receive message\n\treadBuff := make([]byte, 22) // 22 is response header size. [sub header + network num + unit i/o num + unit station num + response length + response code]\n\n\treadLen, err := conn.Read(readBuff)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn readBuff[:readLen], nil\n}", "func (c *Context) Write(d []byte) (int, error) {\n\treturn c.writer.Write(d)\n}", "func (c *TestConnection) Write(b []byte) (n int, err error) {\n if c.WriteError != nil && c.ThrowWriteErrorAfter == c.TimesWriteCalled {\n return 0, c.WriteError\n }\n\n if c.WriteCount > -1 {\n return c.WriteCount, nil\n }\n\n c.TimesWriteCalled++\n c.Written = append(c.Written, string(b))\n return len(b), nil\n}", "func Write(L *lua.LState) int {\n\tn := checkLuaNetClient(L, 1)\n\tdata := L.CheckString(2)\n\n\tif (n.writeTimeout) > 0 {\n\t\tn.SetWriteDeadline(time.Now().Add(n.readTimeout))\n\t}\n\tcount, err := n.Write([]byte(data))\n\tif err != nil {\n\t\tL.Push(lua.LNumber(count))\n\t\tL.Push(lua.LString(err.Error()))\n\t\treturn 2\n\t}\n\n\tL.Push(lua.LNumber(count))\n\treturn 1\n}", "func (c *Client) Write(msgType int, message []byte) error {\n\n\tif msgType == 0 {\n\t\treturn errors.New(\"Message type 0 is reserved\")\n\t}\n\n\tif c.status != Connected {\n\t\treturn errors.New(c.status.String())\n\t}\n\n\tmlen := len(message)\n\tif mlen > c.maxMsgSize {\n\t\treturn errors.New(\"Message exceeds maximum message length\")\n\t}\n\n\tc.toWrite <- &Message{MsgType: msgType, Data: message}\n\n\treturn nil\n}", "func (ctn *Connection) Write(buf []byte) (total int, err error) {\n\t// make sure all bytes are written\n\t// Don't worry about the loop, timeout has been set elsewhere\n\tlength := len(buf)\n\tfor total < length {\n\t\tvar r int\n\t\tif err = ctn.updateDeadline(); err != nil {\n\t\t\tbreak\n\t\t}\n\t\tr, err = ctn.conn.Write(buf[total:])\n\t\ttotal += r\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// If all bytes are written, ignore any potential error\n\t// The error will bubble up on the next network io if it matters.\n\tif total == len(buf) {\n\t\treturn total, nil\n\t}\n\n\tif ctn.node != nil {\n\t\tctn.node.incrErrorCount()\n\t\tatomic.AddInt64(&ctn.node.stats.ConnectionsFailed, 1)\n\t}\n\n\t// the line should happen before .Close()\n\terr = errToTimeoutErr(ctn, err)\n\tctn.Close()\n\n\treturn total, err\n}", "func (t *transaction) Write(msg Message) error {\n\tt.out = append(t.out, msg)\n\treturn nil\n}", "func (r *RPCTractserverTalker) Write(ctx context.Context, addr string, id core.TractID, version int, b []byte, off int64) core.Error {\n\tpri := priorityFromContext(ctx)\n\trpcid := rpc.GenID()\n\treq := core.WriteReq{ID: id, Version: version, Off: off, Pri: pri, ReqID: rpcid}\n\treq.Set(b, false)\n\tvar reply core.Error\n\tcancel := rpc.CancelAction{Method: core.CancelReqMethod, Req: rpcid}\n\tif err := r.cc.SendWithCancel(ctx, addr, core.WriteMethod, &req, &reply, &cancel); err != nil {\n\t\tlog.Errorf(\"Write RPC error for tract (id: %s, version: %d, offset: %d) on tractserver @%s: %s\", id, version, off, addr, err)\n\t\treturn core.ErrRPC\n\t}\n\tif reply != core.NoError {\n\t\tlog.Errorf(\"Write error for tract (id: %s, version: %d, offset: %d) on tractserver @%s: %s\", id, version, off, addr, reply)\n\t}\n\treturn reply\n}", "func (w *Writer) Write(buf []byte) {\n\tif w.err != nil {\n\t\treturn\n\t}\n\n\t_, w.err = w.w.Write(buf)\n}", "func (rw *NopConn) SetWriteDeadline(time.Time) error { return nil }", "func Write(tx Transport, host string, data, info []string, options ...TransportOption) error {\n\t// the Kind should configure the transport parameters before\n\n\terr := tx.Connect(host, options...)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s: %s\", host, err)\n\t}\n\n\tdefer tx.Close()\n\n\tfor i1, d1 := range data {\n\t\terr := tx.Write(&d1, &info[i1])\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not write config %s: %s\", d1, err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (d *Driver) Write(path string, data []byte) error {\n\t_, stat, err := d.conn.Get(path)\n\tif err != nil && err == zk.ErrNoNode {\n\t\terr := d.makePath(path)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif err != nil && err != zk.ErrNoNode {\n\t\treturn err\n\t}\n\n\t_, er := d.conn.Set(path, data, stat.Version)\n\tif er != nil {\n\t\treturn errors.Wrap(err, \"Error writing data to node. Path: \"+path)\n\t}\n\treturn nil\n}", "func (s *SRTOutbound) Write(data []byte) (int, error) {\n\ts.channelsMux.Lock()\n\tfor addr, c := range s.channels {\n\t\tselect {\n\t\tcase c <- data:\n\t\tdefault:\n\t\t\ts.logger.WithFields(log.Fields{\"addr\": addr}).Warn(\"Connection blocked\")\n\t\t}\n\t}\n\ts.channelsMux.Unlock()\n\treturn len(data), nil\n}", "func (l *LogWriter) Write(msg []byte) (n int, err error) {\n\tdefer func() {\n\t\tif v := recover(); v != nil {\n\t\t\terrMsg := fmt.Sprintf(\"gocutelog.Write panicked with value: %v\", v)\n\t\t\terr = errors.New(errMsg)\n\t\t}\n\t}()\n\n\tif l.conn == nil || l.connecting {\n\t\tif l.connecting == false {\n\t\t\tgo l.connect()\n\t\t}\n\t\treturn len(msg), nil\n\t}\n\treturn len(msg), l.sendMsg(msg)\n}", "func (s *Session) Write(msg []byte) error {\n\terr := s.ws.WriteMessage(websocket.BinaryMessage, msg)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tatomic.StoreInt32(&s.timeout, 0)\n\n\treturn nil\n}", "func (clientHandler) Write(ctx context.Context, bytes int64) context.Context { return ctx }", "func Write(conn net.Conn, u *url.URL, kv map[string]string, data string) {\r\n\t//write to connection\r\n\ti := 0\r\n\targ := \"\"\r\n\tfor k, v := range kv {\r\n\t\targ += fmt.Sprintf(\"%s: %s\", k, v)\r\n\t\ti++\r\n\t}\r\n\tif i > 0 {\r\n\t\t// data = strings.Replace(data, \"'\", \"\", -1)\r\n\t\t// data = strings.Replace(data, \" \", \"\", -1)\r\n\t\t// data = strings.Replace(data, \"\\\"\", \"\", -1)\r\n\t\t// data = strings.Replace(data, \"{\", \"\", -1)\r\n\t\t// data = strings.Replace(data, \"}\", \"\", -1)\r\n\t\t// data = strings.Replace(data, \":\", \"=\", -1)\r\n\t\tcl := fmt.Sprintf(\"Content-length: %d\", len(data))\r\n\t\tfmt.Fprintf(conn, \"POST %s HTTP/1.0\\r\\nHost: www.%s\\r\\n%s\\r\\n%s\\r\\n\\r\\n%s\", u.Path, u.Host, cl, arg, data)\r\n\t\treturn\r\n\t}\r\n\tfmt.Fprintf(conn, \"POST /%s HTTP/1.0\\r\\nHost: www.%s\\r\\n\\r\\n\", u.Path, u.Host)\r\n}", "func (c *RESPConn) write(raw []byte) error {\n\tif c.conn == nil {\n\t\treturn ErrConnClosed\n\t}\n\n\tc.conn.SetWriteDeadline(time.Now().Add(c.timeout))\n\t_, err := c.conn.Write(raw)\n\terr = wrapErr(err)\n\tif err == ErrConnClosed {\n\t\tc.close()\n\t}\n\n\treturn err\n}", "func (conn *PacketPipe) Write(p []byte) (n int, err error) {\n\tn, err = conn.writeEnd.Write(p)\n\treturn\n}", "func (c *Conn) Write(b []byte) (written int, err error) {\n\tif len(b) == 0 {\n\t\treturn 0, nil\n\t}\n\terr = tryAgain\n\tfor err == tryAgain {\n\t\tn, errcb := c.write(b)\n\t\terr = c.handleError(errcb)\n\t\tif err == nil {\n\t\t\treturn n, c.flushOutputBuffer()\n\t\t}\n\t}\n\treturn 0, err\n}", "func (c *CipherWriter) Write(p []byte) (n int, err error) {\n\tcp := pbytes.GetLen(len(p))\n\tdefer pbytes.Put(cp)\n\n\tcopy(cp, p)\n\tws.Cipher(cp, c.mask, c.pos)\n\tn, err = c.w.Write(cp)\n\tc.pos += n\n\n\treturn\n}", "func (c *Conn) Write(h ws.Header, b []byte) error {\n\tc.mu.Lock()\n\t_ = c.conn.SetWriteDeadline(time.Now().Add(3000 * time.Millisecond))\n\terr := ws.WriteHeader(c.conn, h)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = c.conn.Write(b)\n\tc.mu.Unlock()\n\treturn err\n}", "func (c *WSCodec) Write(res interface{}) error {\n\tresult, err := json.Marshal(res)\n\tif err != nil {\n\t\treturn err\n\t}\n\tc.client.SendMessage(result, nil)\n\treturn nil\n}", "func (db *DB) Write(wo *WriteOptions, w *WriteBatch) error {\n\tif db.closed {\n\t\tpanic(ErrDBClosed)\n\t}\n\n\tvar errStr *C.char\n\tC.leveldb_write(db.Ldb, wo.Opt, w.wbatch, &errStr)\n\tif errStr != nil {\n\t\tgs := C.GoString(errStr)\n\t\tC.leveldb_free(unsafe.Pointer(errStr))\n\t\treturn DatabaseError(gs)\n\t}\n\treturn nil\n}", "func (b Broadcaster) Write(v interface{}) {\n\tutils.Debugf(\"Sending %v\\n\", v)\n\tb.Sendc <- v // write value on send channel\n}", "func (c *Conn) Write(b []byte) (n int, err error) {\n\treturn c.WriteToStream(b, c.sctpInfo.Stream)\n}" ]
[ "0.75177634", "0.74215007", "0.73879325", "0.7332111", "0.7312324", "0.7310505", "0.7264981", "0.72418797", "0.7232844", "0.7203702", "0.71649534", "0.71483743", "0.7077446", "0.7073222", "0.7066996", "0.70635927", "0.7054253", "0.7044179", "0.6984287", "0.6943448", "0.69400537", "0.6913779", "0.6876968", "0.687347", "0.6859213", "0.68478364", "0.68252033", "0.6774561", "0.67663544", "0.67456865", "0.67371404", "0.6727843", "0.67238426", "0.67179734", "0.67161864", "0.67141265", "0.67032003", "0.66858506", "0.6673108", "0.6657667", "0.66399235", "0.6638906", "0.660994", "0.6603489", "0.65686196", "0.65635216", "0.65632594", "0.6549171", "0.65432006", "0.6523562", "0.6519642", "0.65185314", "0.6516915", "0.65059125", "0.65023905", "0.64955455", "0.6489383", "0.648115", "0.64712405", "0.6452265", "0.6446544", "0.6434782", "0.6418508", "0.6415568", "0.638224", "0.6379239", "0.63601357", "0.63505137", "0.6350416", "0.6349559", "0.6347587", "0.6345522", "0.6345522", "0.6338314", "0.63275117", "0.63187957", "0.6307424", "0.6301605", "0.62976426", "0.6275272", "0.6251276", "0.6238867", "0.6234658", "0.62165093", "0.6207949", "0.6201024", "0.61884326", "0.61877126", "0.6186433", "0.6185968", "0.6180833", "0.61781335", "0.617037", "0.6163464", "0.6131873", "0.6126131", "0.611829", "0.6115812", "0.6104483", "0.6083783" ]
0.64009035
64
Close closes the connection.
func (c *Conn) Close() error { if !c.ok() { return syscall.EINVAL } select { case <-c.closeChan: default: c.closeSendBuf() c.sendFIN() } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Conn) Close() error { return nil }", "func Close() {\n\tconn.Close()\n}", "func (c *Conn) Close() error { return c.pc.Close() }", "func (v *connection) Close() error {\n\tconnectionLogger.Trace(\"connection.Close()\")\n\n\tv.sendMessage(&msgs.FETerminateMsg{})\n\n\tvar result error = nil\n\n\tif v.conn != nil {\n\t\tresult = v.conn.Close()\n\t\tv.conn = nil\n\t}\n\n\treturn result\n}", "func (c *ManetConnection) Close() {\n\tc.conn.Close()\n}", "func (c *Connection) Close() {\n\tc.conn.Close()\n}", "func (c *SodaClient) Close() {\n\tc.conn.Close()\n}", "func (c *client) Close() error { return c.c.Close() }", "func (r ResourceConn) Close() {\n\tr.Conn.Close()\n}", "func (c *Connector) Close() {\n\tc.conn.Close()\n\tclose(c.die)\n}", "func (c *conn) Close() error {\n\treturn c.s.Close()\n}", "func (r *Connection) Close() {\n\t// no-op\n}", "func (c Connection) Close() error {\n\tpanic(\"TODO\")\n}", "func (i ios) Close(ctx context.Context) error {\n\ti.Connection.Close(ctx)\n\n\treturn nil\n}", "func (b *BIRDClient) Close() error { return b.conn.Close() }", "func (conn *Connection) Close() error {\n\tconn.connected = false\n\treturn nil\n}", "func (c *Connection) Close() error {\n\terr := c.Connection.Close()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *conn) Close() error {\n\tif atomic.CompareAndSwapInt32(&c.closed, 0, 1) {\n\t\tc.log(\"close connection\", c.url.Scheme, c.url.Host, c.url.Path)\n\t\tcancel := c.cancel\n\t\ttransport := c.transport\n\t\tc.transport = nil\n\t\tc.cancel = nil\n\n\t\tif cancel != nil {\n\t\t\tcancel()\n\t\t}\n\t\tif transport != nil {\n\t\t\ttransport.CloseIdleConnections()\n\t\t}\n\t}\n\treturn nil\n}", "func (rw *NopConn) Close() error { return nil }", "func (c *TestConnection) Close() error {\n if c.CloseError != nil {\n return c.CloseError\n }\n \n c.Closed = true\n return nil\n}", "func (conn *Conn) Close() {\n\tconn.conn.Close()\n}", "func (p *Conn) Close() error {\n\treturn p.conn.Close()\n}", "func (c *Connection) Close() error {\n\tc.identity = nil\n\tif c.clientConn != nil {\n\t\terr := c.clientConn.Close()\n\t\tc.clientConn = nil\n\t\treturn err\n\t}\n\treturn nil\n}", "func (ts *Stream) Close() error {\n\tif ts.err != nil {\n\t\treturn ts.err\n\t}\n\treturn ts.conn.Close()\n}", "func (c *Conn) Close() error {\n\treturn nil // TODO(TimSatke): implement\n}", "func (c *CryptoStreamConn) Close() error {\n\treturn nil\n}", "func (conn *WSConnection) Close() error {\n\treturn conn.conn.Close()\n}", "func (rc *OneByteWriteConn) Close() error {\n\treturn rc.conn.Close()\n}", "func (r *ResourceConn) Close() {\n\tr.ClientConn.Close()\n}", "func (c *Connection) Close() error {\n\trerr := c.ReadCloser.Close()\n\twerr := c.WriteCloser.Close()\n\tif rerr != nil {\n\t\treturn rerr\n\t}\n\treturn werr\n}", "func (s *session) Close() error {\n\treturn s.conn.Close()\n}", "func (c *Conn) Close() {\n\tc.conn.Close()\n}", "func (bc BufConn) Close() error { return nil }", "func (c *Conn) Close() error {\n\t// Resets client\n\tc.client = nil\n\treturn nil\n}", "func (r *Response) Close() error {\n\treturn r.conn.Close()\n}", "func (c *Conn) Close(ctx context.Context) error {\n\treturn c.redfishwrapper.Close(ctx)\n}", "func (c *Client) Close() {\n\t_ = c.conn.Close()\n}", "func (rc *OneByteReadConn) Close() error {\n\treturn rc.conn.Close()\n}", "func (c *Conn) Close() error {\n\treturn c.conn.Close()\n}", "func (c *Conn) Close() error {\n\treturn c.conn.Close()\n}", "func (c *Conn) Close() error {\n\treturn c.conn.Close()\n}", "func (c *RuntimeSecurityClient) Close() {\n\tc.conn.Close()\n}", "func (gw *Gateway) Close() error {\n\treturn gw.conn.Close()\n}", "func (r *client) Close() error {\n\treturn r.conn.Close()\n}", "func (c *Connection) Close() error { return c.pump.Close() }", "func (r *response) Close() error {\n\terr := r.conn.Close()\n\t_, _, err2 := r.c.conn.ReadResponse(StatusClosingDataConnection)\n\tif err2 != nil {\n\t\terr = err2\n\t}\n\treturn err\n}", "func (cl *Client) Close() (err error) {\n\tcl.url = nil\n\treturn cl.conn.Close()\n}", "func (self *SQL_Client) Close() {\n\tself.cc.Close()\n}", "func (c *Conn) Close() error {\n\tc.handshakeMutex.Lock()\n\tdefer c.handshakeMutex.Unlock()\n\tif err := c.rawConn.Close(); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *Client) Close() {}", "func (c *Client) Close() {}", "func (gc *GokuyamaClient) Close() error {\n\tvar err error\n\terr = gc.conn.Close()\n\treturn err\n}", "func (rc *DelayConn) Close() error {\n\treturn rc.conn.Close()\n}", "func (c *Conn) Close() {\n\tc.c.Close()\n}", "func (c *Connection) Close() (err error) {\n\treturn c.connection.Disconnect()\n}", "func (c *Conn) Close() error {\n\treturn syscall.Close(c.fd)\n}", "func (c *Conn) Close() error {\n\treturn c.c.Close()\n}", "func (c *connection) Close() {\n\tbaseurl := \"http://fritz.box/webservices/homeautoswitch.lua\"\n\tparameters := make(map[string]string)\n\tparameters[\"sid\"] = c.sid\n\tparameters[\"logout\"] = \"logout\"\n\tUrl := prepareRequest(baseurl, parameters)\n\tsendRequest(Url)\n}", "func (c *Conn) Close() error {\n\tc.Logout()\n\treturn c.Conn.Close()\n}", "func (c *Conn) Close() error {\n\terr := c.conn.Close()\n\treturn err\n}", "func (c *Client) Close() error {\n\treturn c.connection.Close()\n}", "func (c *Client) Close() {\n\tc.conn.Close()\n}", "func (c *Client) Close() {\n\tc.conn.Close()\n}", "func (c *Client) Close() {\n\tc.conn.Close()\n}", "func (c *Client) Close() {\n\tc.conn.Close()\n}", "func (c *Client) Close() {\n\tc.conn.Close()\n}", "func (c *Client) Close() {\n\tc.conn.Close()\n}", "func (h *handler) Close() error {\n\th.logMessage(fmt.Sprintf(\"Closing connection to %v\", h.conn.RemoteAddr()))\n\treturn h.conn.Close()\n}", "func (w *reply) Close() (err error) {\n\treturn w.conn.Close()\n}", "func (ch *ClickHouse) Close() error {\n\treturn ch.conn.Close()\n}", "func (c *baseConn) Close() error {\n\treturn c.c.Close()\n}", "func (s *SocksAdapter) Close() {\n\ts.conn.Close()\n}", "func (n *Connection) Close() (err error) {\n\tdefer func() {\n\t\t_ = logger.ZSLogger.Sync()\n\t}()\n\n\terr = n.stan.Close()\n\tif err != nil {\n\t\tlogger.ZSLogger.Errorf(\"can not close NATS Streaming connection: %v\", err)\n\t}\n\tn.nats.Close()\n\n\treturn err\n}", "func (rc *PerWriteDelayConn) Close() error {\n\treturn rc.conn.Close()\n}", "func (rc *WriteDelayConn) Close() error {\n\treturn rc.conn.Close()\n}", "func (c *Connection) Close() {\n\tc.C.Close()\n}", "func (f *fetcher) Close() error {\n\treturn f.conn.Close()\n}", "func (c *Conn) Close() error {\n\treturn c.nconn.Close()\n}", "func (c *Connection) Close() {\n\tif c.IsConnected == false {\n\t\treturn\n\t}\n\tc.IsConnected = false\n\tif r := recover(); r != nil {\n\t\tlog.Print(\"Closing due to problematic connection.\")\n\t} else {\n\t\tc.Send(CommandBasic{\n\t\t\tType: Cya,\n\t\t})\n\t}\n\tc.Conn.Close()\n\tvar blank struct{}\n\tc.ClosedChan <- blank\n}", "func (c *Client) Close() { c.streamLayer.Close() }", "func (p *packetConn) Close() error {\n\treturn ErrNotImplemented\n}", "func (rc *RecognitionClient) Close() error {\n\treturn rc.conn.Close()\n}", "func (pc *Client) Close() {\n\tpc.connected = false\n\tpc.connection.Close()\n}", "func (c *conn) Close() error {\n\tklog.V(4).Infoln(\"closing connection\")\n\tif c.closeTunnel != nil {\n\t\tdefer c.closeTunnel()\n\t}\n\n\tvar req *client.Packet\n\tif c.connID != 0 {\n\t\treq = &client.Packet{\n\t\t\tType: client.PacketType_CLOSE_REQ,\n\t\t\tPayload: &client.Packet_CloseRequest{\n\t\t\t\tCloseRequest: &client.CloseRequest{\n\t\t\t\t\tConnectID: c.connID,\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t} else {\n\t\t// Never received a DIAL response so no connection ID.\n\t\treq = &client.Packet{\n\t\t\tType: client.PacketType_DIAL_CLS,\n\t\t\tPayload: &client.Packet_CloseDial{\n\t\t\t\tCloseDial: &client.CloseDial{\n\t\t\t\t\tRandom: c.random,\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t}\n\n\tklog.V(5).InfoS(\"[tracing] send req\", \"type\", req.Type)\n\n\tif err := c.tunnel.Send(req); err != nil {\n\t\treturn err\n\t}\n\n\tselect {\n\tcase errMsg := <-c.closeCh:\n\t\tif errMsg != \"\" {\n\t\t\treturn errors.New(errMsg)\n\t\t}\n\t\treturn nil\n\tcase <-time.After(CloseTimeout):\n\t}\n\n\treturn errConnCloseTimeout\n}", "func (c *Client) Close() error {\n\treturn c.conn.Close()\n}", "func (c *Client) Close() error {\n\treturn c.conn.Close()\n}", "func (c *Client) Close() error {\n\treturn c.conn.Close()\n}", "func (c *Client) Close() error {\n\treturn c.conn.Close()\n}", "func (c *Client) Close() error {\n\treturn c.conn.Close()\n}", "func (c *Client) Close() error {\n\treturn c.conn.Close()\n}", "func (c *Client) Close() error {\n\treturn c.conn.Close()\n}", "func (c *Client) Close() error {\n\treturn c.conn.Close()\n}", "func (c *Client) Close() error {\n\treturn c.conn.Close()\n}", "func (c *Client) Close() error {\n\treturn c.conn.Close()\n}", "func (c *Client) Close() error {\n\treturn c.conn.Close()\n}", "func (c *Client) Close() error {\n\treturn c.conn.Close()\n}", "func (c *Client) Close() error {\n\treturn c.conn.Close()\n}", "func (hd *hostDownloader) Close() error {\n\t// don't care about these errors\n\t_, _ = verifySettings(hd.conn, hd.host, hd.contractor.hdb)\n\t_ = modules.WriteNegotiationStop(hd.conn)\n\treturn hd.conn.Close()\n}", "func (c *Connection) Close() (err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlog.Trace(\"Recovered in Close\", r)\n\t\t}\n\t}()\n\n\tc.ready = false\n\tif c.client != nil {\n\t\tc.client.CloseIdleConnections()\n\t}\n\tif c.tor != nil {\n\t\terr = c.tor.Close()\n\t}\n\treturn\n}", "func (c *Client) Close() error {\n\treturn c.conn.close()\n}", "func (d *Driver) Close() error {\n\td.conn.Close()\n\treturn nil\n}" ]
[ "0.7775359", "0.7427443", "0.7338917", "0.7321364", "0.7235921", "0.72172064", "0.7214366", "0.7186836", "0.71783304", "0.717726", "0.71748966", "0.7154546", "0.71541876", "0.7110452", "0.7101479", "0.7098534", "0.70903337", "0.7086785", "0.7075161", "0.7068597", "0.7064785", "0.705745", "0.70477974", "0.70315444", "0.7025527", "0.7014377", "0.7008425", "0.7004589", "0.70039696", "0.69975924", "0.6988087", "0.6985333", "0.6977918", "0.69709575", "0.6961238", "0.69608176", "0.6958883", "0.69517726", "0.6914184", "0.6914184", "0.6914184", "0.68965536", "0.6883036", "0.6876039", "0.6864702", "0.6858133", "0.68570614", "0.68544275", "0.6849654", "0.6845745", "0.6845745", "0.6845587", "0.68416435", "0.6840236", "0.6828214", "0.6817254", "0.68144375", "0.6811285", "0.6809584", "0.6807442", "0.6804604", "0.6802009", "0.6802009", "0.6802009", "0.6802009", "0.6802009", "0.6802009", "0.6796769", "0.6780063", "0.6774915", "0.6766792", "0.67666185", "0.6760758", "0.67527163", "0.67516744", "0.6749989", "0.67443013", "0.6737604", "0.6734762", "0.6721934", "0.6720822", "0.67162985", "0.6708989", "0.6707422", "0.669956", "0.669956", "0.669956", "0.669956", "0.669956", "0.669956", "0.669956", "0.669956", "0.669956", "0.669956", "0.669956", "0.669956", "0.669956", "0.6699082", "0.6686028", "0.66765255", "0.66667414" ]
0.0
-1
LocalAddr returns the local network address.
func (c *Conn) LocalAddr() net.Addr { if !c.ok() { return nil } return c.conn.LocalAddr() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *Conn) LocalAddr() net.Addr {\n\treturn Addr{s.local}\n}", "func (c *Client) LocalAddr() net.Addr {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\treturn c.lAddr\n}", "func (s *Server) LocalAddr() net.Addr {\n\treturn s.udpServ.PacketConn.LocalAddr()\n}", "func (u *UDP) LocalAddr() net.Addr {\n\treturn u.conn.LocalAddr()\n}", "func (dc *Conn) LocalAddr() net.Addr {\n\treturn dc.getConn().LocalAddr()\n}", "func (c *cConn) LocalAddr() net.Addr {\n\tsa, _ := syscall.Getsockname(c.fd)\n\treturn parseSa(sa)\n}", "func (c *ConnUDP) LocalAddr() net.Addr {\n\treturn c.connection.LocalAddr()\n}", "func (p *Peer) LocalAddr() net.Addr {\n\tvar localAddr net.Addr\n\tif atomic.LoadInt32(&p.connected) != 0 {\n\t\tlocalAddr = p.conn.LocalAddr()\n\t}\n\treturn localAddr\n}", "func (s *udtSocket) LocalAddr() net.Addr {\n\treturn s.m.laddr\n}", "func (c *UDPSerialConn) LocalAddr() Addr {\n\treturn c.laddr.opAddr()\n}", "func (c *Conn) LocalAddr() net.Addr {\n\tif c.localAddr != nil {\n\t\treturn c.localAddr\n\t}\n\treturn c.Conn.LocalAddr()\n}", "func (c *Conn) LocalAddr() net.Addr {\n\treturn c.s.LocalAddr()\n}", "func (c *Conn) LocalAddr() net.Addr {\n\treturn c.laddr\n}", "func LocalAddr() string {\n\tif devel() {\n\t\treturn defaultIP\n\t}\n\taddr, err := awsLocalIPv4()\n\tif err != nil {\n\t\talt.Warnf(\"env: Could not fetch instance local IPv4 from environment: %v\", err)\n\t\taddr = defaultIP // punt\n\t}\n\treturn addr\n}", "func (c Conn) LocalAddr() smb.Addr {\n\treturn c.nc.LocalAddr()\n}", "func (v *vsockConn) LocalAddr() net.Addr {\n\treturn v.local\n}", "func (c *LimitedConnection) LocalAddr() net.Addr {\n\treturn c.inner.LocalAddr()\n}", "func (c *TCPSerialConn) LocalAddr() Addr {\n\treturn c.laddr.opAddr()\n}", "func (clientConn *Conn) LocalAddr() net.Addr {\n\treturn clientConn.conn.LocalAddr()\n}", "func (c *Conn) LocalAddr() net.Addr {\n\treturn c.conn.LocalAddr()\n}", "func (c *Conn) LocalAddr() net.Addr {\n\treturn c.conn.LocalAddr()\n}", "func (c *Conn) LocalAddr() net.Addr {\n\treturn c.conn.LocalAddr()\n}", "func (v *Context) LocalAddr() net.Addr {\n\treturn v.laddr\n}", "func (c *Conn) LocalAddr() net.Addr {\n\treturn c.sctpConn.LocalAddr()\n}", "func (p *Conn) LocalAddr() net.Addr {\n\treturn p.conn.LocalAddr()\n}", "func (mc *MockConn) LocalAddr() net.Addr {\n\treturn mc.localAddr\n}", "func (rc *DelayConn) LocalAddr() net.Addr {\n\treturn rc.conn.LocalAddr()\n}", "func LocalIP() string {\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tfor _, address := range addrs {\n\t\t// check the address type and if it is not a loopback the display it\n\t\tif ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tif ipnet.IP.To4() != nil {\n\t\t\t\treturn ipnet.IP.String()\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\"\n}", "func GetLocalIP() string {\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\n\tfor _, address := range addrs {\n\t\tipnet, ok := address.(*net.IPNet)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tif ipnet.IP.IsLoopback() {\n\t\t\tcontinue\n\t\t}\n\t\tif ipnet.IP.To4() == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\treturn ipnet.IP.String()\n\t}\n\n\treturn \"\"\n}", "func GetLocalIP() string {\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\n\tfor _, address := range addrs {\n\t\t// Check the IP address to determine whether to loop back the address\n\t\tif ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tif ipnet.IP.To4() != nil {\n\t\t\t\treturn ipnet.IP.String()\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\"\n}", "func (s ServerInfo) GetLocalAddr() string {\n\treturn \"127.0.0.1:\" + strconv.Itoa(s.LocalPort)\n}", "func GetLocalAddr(network string, ip net.IP) (net.Addr, error) {\n\t// ugly porkaround until I find how to get the local address in a better\n\t// way. A port different from 0 is required on darwin, so using udp/53.\n\tconn, err := net.Dial(network, net.JoinHostPort(ip.String(), \"53\"))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlocalAddr := conn.LocalAddr()\n\t_ = conn.Close()\n\treturn localAddr, nil\n}", "func (s *Session) LocalAddr() net.Addr {\n\tif conn, ok := s.conn.(localAddrer); ok {\n\t\treturn conn.LocalAddr()\n\t}\n\treturn nil\n}", "func (s *server) LocalAddress(ctx context.Context, in *tt.Empty) (*tt.NodeAddress, error) {\n\tip := smudge.GetListenIP()\n\tport := smudge.GetListenPort()\n\treturn &tt.NodeAddress{IP: ip.String(), Port: uint32(port)}, nil\n}", "func (c *wsConn) LocalAddr() net.Addr {\n\treturn c.conn.LocalAddr()\n}", "func GetLocalIP() string {\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tfor _, address := range addrs {\n\t\t// check the address type and if it is not a loopback the display it\n\t\tif ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tif ipnet.IP.To4() != nil {\n\t\t\t\treturn ipnet.IP.String()\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\"\n}", "func GetLocalIP() string {\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tfor _, address := range addrs {\n\t\t// check the address type and if it is not a loopback the display it\n\t\tif ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tif ipnet.IP.To4() != nil {\n\t\t\t\treturn ipnet.IP.String()\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\"\n}", "func (c Conn) LocalAddr() net.Addr {\n\treturn c.conn.LocalAddr()\n}", "func GetLocalIP() string {\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tbestIP := \"\"\n\tfor _, address := range addrs {\n\t\t// check the address type and if it is not a loopback the display it\n\t\tif ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tif ipnet.IP.To4() != nil {\n\t\t\t\treturn ipnet.IP.String()\n\t\t\t}\n\t\t}\n\t}\n\treturn bestIP\n}", "func GetLocalIp() string {\n\taddresses, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn \"127.0.0.1\"\n\t}\n\n\tfor _, addr := range addresses {\n\t\tif ipNet, ok := addr.(*net.IPNet); ok && !ipNet.IP.IsLoopback() {\n\t\t\tif ipNet.IP.To4() != nil {\n\t\t\t\treturn ipNet.IP.String()\n\t\t\t}\n\t\t}\n\t}\n\n\treturn \"127.0.0.1\"\n}", "func (e *endpoint) GetLocalAddress() (tcpip.FullAddress, *tcpip.Error) {\n\te.mu.RLock()\n\tdefer e.mu.RUnlock()\n\n\treturn tcpip.FullAddress{\n\t\tNIC: e.regNICID,\n\t\tAddr: e.id.LocalAddress,\n\t\tPort: e.id.LocalPort,\n\t}, nil\n}", "func GetLocalIP() string {\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn \"localhost\"\n\t}\n\tbestIP := \"localhost\"\n\tfor _, address := range addrs {\n\t\t// check the address type and if it is not a loopback the display it\n\t\tif ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tif ipnet.IP.To4() != nil && (strings.Contains(ipnet.IP.String(), \"192.168.1\") || strings.Contains(ipnet.IP.String(), \"192.168\")) {\n\t\t\t\treturn ipnet.IP.String()\n\t\t\t}\n\t\t}\n\t}\n\treturn bestIP\n}", "func (rw *NopConn) LocalAddr() net.Addr { return nil }", "func (ws *WSPacketConn) LocalAddr() net.Addr {\n\treturn ws.localAddr\n}", "func (conn *connection) LocalAddress() string {\n\treturn conn.laddr\n}", "func GetLocalIP() (ip string) {\n\taddrs, _ := net.InterfaceAddrs()\n\tfor _, address := range addrs {\n\t\t// check the address type and if it is not a loopback the display it\n\t\tif ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tif ipnet.IP.To4() != nil {\n\t\t\t\tip = ipnet.IP.String()\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func GetLocalIP() string {\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tbestIP := \"\"\n\tfor _, address := range addrs {\n\t\t// check the address type and if it is not a loopback the display it\n\t\tif ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tif ipnet.IP.To4() != nil && (strings.Contains(ipnet.IP.String(), \"192.168.1\") || strings.Contains(ipnet.IP.String(), \"192.168\")) {\n\t\t\t\treturn ipnet.IP.String()\n\t\t\t}\n\t\t}\n\t}\n\treturn bestIP\n}", "func GetLocalIP() (string, error) {\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tfor _, address := range addrs {\n\t\t// check the address type and if it is not a loopback the display it\n\t\tif ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tif ipnet.IP.To4() != nil {\n\t\t\t\treturn ipnet.IP.String(), nil\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\", nil\n}", "func (c Conn) LocalAddr() Addr { return c.local }", "func LocalIP() (net.IP, error) {\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, addr := range addrs {\n\t\tif ipnet, ok := addr.(*net.IPNet); ok && ipnet.IP.IsGlobalUnicast() {\n\t\t\tif ipnet.IP.To4() != nil || ipnet.IP.To16() != nil {\n\t\t\t\treturn ipnet.IP, nil\n\t\t\t}\n\t\t}\n\t}\n\treturn nil, nil\n}", "func (rc *ReadDelayConn) LocalAddr() net.Addr {\n\treturn rc.conn.LocalAddr()\n}", "func (rc *WriteDelayConn) LocalAddr() net.Addr {\n\treturn rc.conn.LocalAddr()\n}", "func (r *Route) LocalAddress() tcpip.Address {\n\treturn r.routeInfo.LocalAddress\n}", "func (rc *PerWriteDelayConn) LocalAddr() net.Addr {\n\treturn rc.conn.LocalAddr()\n}", "func GetLocalIP() (string, error) {\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn \"\", errors.WithStack(err)\n\t}\n\tfor _, address := range addrs {\n\t\t// check the address type and if it is not a loopback the display it\n\t\tif ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tif ipnet.IP.To4() != nil {\n\t\t\t\treturn ipnet.IP.String(), nil\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\", errors.New(\"unable to resolve local IP address\")\n}", "func (s ServerListener) LocalAddr() net.Addr {\n\tif s.packet == nil {\n\t\treturn nil\n\t}\n\treturn s.packet.LocalAddr()\n}", "func localIP() (string, error) {\n\t/* Local addresses */\n\taddrs, err := net.InterfaceAddrs()\n\tif nil != err {\n\t\treturn \"127.0.0.1\", err\n\t}\n\t/* Find the first non-loopback address */\n\tfor _, v := range addrs {\n\t\t/* Cast to something we can use */\n\t\ti, ok := v.(*net.IPNet)\n\t\tif !ok {\n\t\t\tlog.Printf(\"Found strange address: %v\", v)\n\t\t\tcontinue\n\t\t}\n\t\t/* Only get external addresses */\n\t\tif !i.IP.IsGlobalUnicast() {\n\t\t\tcontinue\n\t\t}\n\t\treturn i.IP.String(), nil\n\t}\n\treturn \"127.0.0.1\", nil\n}", "func (c *ChannelConn) LocalAddr() net.Addr {\n\treturn nil\n}", "func (mph *MockPeerHandler) LocalAddr() string {\n\treturn \"\"\n}", "func (session *TCPSession) LocalAddress() string {\n\tif session.isWebSocket {\n\t\tif session.wsConn != nil {\n\t\t\treturn session.wsConn.LocalAddr().String()\n\t\t}\n\t} else {\n\t\tif session.conn != nil {\n\t\t\treturn session.conn.LocalAddr().String()\n\t\t}\n\t}\n\treturn \"\"\n}", "func (session *TCPSession) LocalAddress() string {\n\tif session.conn != nil {\n\t\treturn session.conn.LocalAddr().String()\n\t}\n\treturn \"\"\n}", "func GetLocalIp() string {\n\tif localIPStr == \"\" {\n\t\treturn UnknownIPAddr\n\t}\n\treturn localIPStr\n}", "func GetLocalIP() string {\n addrs, err := net.InterfaceAddrs()\n if err != nil {\n return \"\"\n }\n for _, address := range addrs {\n // check the address type and if it is not a loopback the display it\n if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n if ipnet.IP.To4() != nil {\n return ipnet.IP.String()\n }\n }\n }\n return \"\"\n}", "func GetLocalIP() string {\n addrs, err := net.InterfaceAddrs()\n if err != nil {\n return \"\"\n }\n for _, address := range addrs {\n // check the address type and if it is not a loopback the display it\n if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n if ipnet.IP.To4() != nil {\n return ipnet.IP.String()\n }\n }\n }\n return \"\"\n}", "func (t *tcpchanconn) LocalAddr() net.Addr {\n\treturn t.laddr\n}", "func (p *packetConn) LocalAddr() net.Addr {\n\treturn nil\n}", "func (c *clientHandler) LocalAddr() net.Addr {\n\treturn c.conn.LocalAddr()\n}", "func (c *TestConnection) LocalAddr() net.Addr {\n return nil\n}", "func (rc *OneByteWriteConn) LocalAddr() net.Addr {\n\treturn rc.conn.LocalAddr()\n}", "func (c *Conn) LocalAddr() net.Addr {\n // return c.conn.LocalAddr()\n fmt.Println(\"getting lcoal addr\")\n return nil\n}", "func (s *Session) GetLocalAddr() net.Addr {\n\treturn s.session.LocalAddr()\n}", "func (rc *OneByteReadConn) LocalAddr() net.Addr {\n\treturn rc.conn.LocalAddr()\n}", "func (bc BufConn) LocalAddr() net.Addr { return TestAddr{Addr: \"\"} }", "func LocalIP() net.IP {\n\tconn, err := net.Dial(\"udp\", \"8.8.8.8:80\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer conn.Close()\n\n\tlocalAddr := conn.LocalAddr().(*net.UDPAddr)\n\n\treturn localAddr.IP\n}", "func (my *clientConn) LocalAddr() net.Addr {\n\treturn my.conn.LocalAddr()\n}", "func LocalIP() (string, error) {\n\t// Based on https://play.golang.org/p/BDt3qEQ_2H from https://stackoverflow.com/a/23558495\n\tifaces, err := net.Interfaces()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tfor _, iface := range ifaces {\n\t\tif iface.Flags&net.FlagUp == 0 {\n\t\t\tcontinue // interface down\n\t\t}\n\t\tif iface.Flags&net.FlagLoopback != 0 {\n\t\t\tcontinue // loopback interface\n\t\t}\n\t\taddrs, err := iface.Addrs()\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tfor _, addr := range addrs {\n\t\t\tvar ip net.IP\n\t\t\tswitch v := addr.(type) {\n\t\t\tcase *net.IPNet:\n\t\t\t\tip = v.IP\n\t\t\tcase *net.IPAddr:\n\t\t\t\tip = v.IP\n\t\t\t}\n\t\t\tif ip == nil || ip.IsLoopback() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tip = ip.To4()\n\t\t\tif ip == nil {\n\t\t\t\tcontinue // not an ipv4 address\n\t\t\t}\n\t\t\treturn ip.String(), nil\n\t\t}\n\t}\n\treturn \"\", errors.New(\"No IP found\")\n}", "func getLocalIp() string {\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tfor _, address := range addrs {\n\t\t// check the address type and if it is not a loopback the display it\n\t\tif ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tif ipnet.IP.To4() != nil {\n\t\t\t\tfmt.Println(\"local ip address: \", ipnet.IP.String())\n\t\t\t\treturn ipnet.IP.String()\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\"\n}", "func GetLocalIP() (*net.IP, error) {\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, address := range addrs {\n\t\t// check the address type and if it is not a loopback the display it\n\t\tif ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\treturn &ipnet.IP, nil\n\t\t}\n\t}\n\treturn nil, errors.New(\"unable to obtain non loopback local ip address\")\n}", "func (c *WebSocketConn) LocalAddr() net.Addr {\n\treturn c.conn.LocalAddr()\n}", "func getLocalIP() string {\n\taddresses, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tfor _, address := range addresses {\n\t\tip := address.(*net.IPNet)\n\t\tif ip.IP.To4() != nil && !ip.IP.IsLoopback() {\n\t\t\treturn ip.IP.String()\n\t\t}\n\t}\n\treturn \"\"\n}", "func (c *CryptoStreamConn) LocalAddr() net.Addr {\n\treturn nil\n}", "func LocalIP() *net.IP {\n\tif localIP != nil {\n\t\treturn localIP\n\t}\n\tlocalIP, _ := GetLocalIP()\n\treturn localIP\n}", "func localIP() string {\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfor _, addr := range addrs {\n\t\tif strings.HasPrefix(addr.String(), \"192\") {\n\t\t\taddress := strings.TrimSuffix(addr.String(), \"/24\")\n\t\t\tif len(Port) > 0 {\n\t\t\t\taddress = fmt.Sprintf(\"%v:%v\", address, Port)\n\t\t\t}\n\t\t\treturn address\n\t\t}\n\t}\n\tpossible_addresses := \"No 192.168.X.X found, try one of:\\n\"\n\tfor _, addr := range addrs {\n\t\tfmt.Println(addr.String())\n\t\taddress := strings.Split(addr.String(), \"/\")[0]\n\t\tif len(Port) > 0 {\n\t\t\tpossible_addresses += fmt.Sprintf(\"%v:%v\\n\", address, Port)\n\t\t}\n\t}\n\treturn possible_addresses\n}", "func ConnLocalAddr(c *tls.Conn,) net.Addr", "func (o *SmscSession) GetLocalAddr() string {\n\tif o == nil || o.LocalAddr == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.LocalAddr\n}", "func (ctx *Context) LocalIP() string {\n\txForwardedFor := ctx.Request.Header.Get(\"X-Forwarded-For\")\n\tip := strings.TrimSpace(strings.Split(xForwardedFor, \",\")[0])\n\tif ip != \"\" {\n\t\treturn ip\n\t}\n\n\tip = strings.TrimSpace(ctx.Request.Header.Get(\"X-Real-Ip\"))\n\tif ip != \"\" {\n\t\treturn ip\n\t}\n\n\tif ip, _, err := net.SplitHostPort(strings.TrimSpace(ctx.Request.RemoteAddr)); err == nil {\n\t\treturn ip\n\t}\n\n\treturn \"127.0.0.1\"\n}", "func (t *netUtils) GetLocalIpv4() string {\n\tt.once.Do(func() {\n\t\tif ias, err := net.InterfaceAddrs(); err == nil {\n\t\t\tfor _, address := range ias {\n\t\t\t\tif ipNet, ok := address.(*net.IPNet); ok && !ipNet.IP.IsLoopback() {\n\t\t\t\t\tif ipNet.IP.To4() != nil {\n\t\t\t\t\t\tt.localIpv4 = ipNet.IP.String()\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n\treturn t.localIpv4\n}", "func GetLocalIp() string {\n\t// testing with 198.18.0.0/15 , see https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml\n\tconn, err := net.Dial(\"udp\", \"198.18.0.30:80\")\n\tif err != nil {\n\t\tlog.Printf(\"[TOOLS][UTILS][OS] : cannot use UDP: %s\", err.Error())\n\t\treturn \"127.0.0.1\" // wanted to use 0.0.0.0 but golang cannot make use of it\n\t}\n\tconn.Close()\n\ttorn := strings.Split(conn.LocalAddr().String(), \":\")\n\treturn torn[0]\n}", "func localIP() (net.IP, error) {\n\ttt, err := net.Interfaces()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, t := range tt {\n\t\taa, err := t.Addrs()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tfor _, a := range aa {\n\t\t\tipnet, ok := a.(*net.IPNet)\n\t\t\tif !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tv4 := ipnet.IP.To4()\n\n\t\t\tif v4 == nil || v4[0] == 127 { // loopback address\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn v4, nil\n\t\t}\n\t}\n\n\treturn nil, errors.New(\"cannot find local IP address\")\n}", "func getLocalIp() string {\n addrs, err := net.InterfaceAddrs()\n if err != nil {\n return \"\"\n }\n for _, address := range addrs {\n // check the address type and if it is not a loopback the display it\n if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n if ipnet.IP.To4() != nil {\n return ipnet.IP.String()\n }\n }\n }\n return \"\"\n}", "func LocalAddr(addr net.IPAddr) func(*Attacker) {\n\treturn func(a *Attacker) {\n\t\ttr := a.client.Transport.(*http.Transport)\n\t\ta.dialer.LocalAddr = &net.TCPAddr{IP: addr.IP, Zone: addr.Zone}\n\t\ttr.Dial = a.dialer.Dial\n\t}\n}", "func (conn *PacketPipe) LocalAddr() net.Addr { return fakeAddr{} }", "func (c *ThrottledConn) LocalAddr() net.Addr {\n\treturn c.originalConn.LocalAddr()\n}", "func getLocalIP() string {\n\tconn, err := net.Dial(\"udp\", \"8.8.8.8:80\")\n\tif err != nil {\n\t\treturn \"127.0.0.1\"\n\t}\n\tdefer conn.Close()\n\tlocalAddr := conn.LocalAddr().(*net.UDPAddr)\n\treturn localAddr.IP.String()\n}", "func GetLocalIP(ipClass string) (string, error) {\n\tnetInterfaceAddresses, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tfor _, netInterfaceAddress := range netInterfaceAddresses {\n\t\tnetworkIP, ok := netInterfaceAddress.(*net.IPNet)\n\t\tif ok && !networkIP.IP.IsLoopback() && networkIP.IP.To4() != nil {\n\t\t\tip := networkIP.IP.String()\n\t\t\tif strings.Contains(ip, ipClass) == true {\n\t\t\t\treturn ip, nil\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\", nil\n}", "func getLocalIP()(ipv4 string, err error) {\n\tvar (\n\t\taddrs []net.Addr\n\t\taddr net.Addr\n\t\tipNet *net.IPNet\n\t\tisIpNet bool\n\t)\n\t//get all network interface\n\tif addrs, err = net.InterfaceAddrs(); err != nil {\n\t\treturn\n\t}\n\t//get first none localhost IP address\n\tfor _, addr = range addrs {\n\t\t//ipv4, ipv6\n\t\t//this network address is ip address\n\t\tif ipNet, isIpNet = addr.(*net.IPNet); isIpNet && !ipNet.IP.IsLoopback() {\n\t\t\t//skip ipv6\n\t\t\tif ipNet.IP.To4() != nil {\n\t\t\t\tipv4 = ipNet.IP.String() //192.168.1.1\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\terr = common.ERR_NO_LOCAL_IP_FOUND\n\treturn\n}", "func LocalFor(l logger.Logger, ra net.IP) net.IP {\n\tif ra == nil || ra.IsUnspecified() {\n\t\treturn nil\n\t}\n\taddrCacheMux.RLock()\n\tdefer addrCacheMux.RUnlock()\n\tremote := net.IP(make([]byte, 16))\n\tcopy(remote, ra.To16())\n\tkey := a2i(remote)\n\tidx := sort.Search(len(addrCache), func(i int) bool {\n\t\treturn a2i(addrCache[i].remote).Cmp(key) != 1\n\t})\n\tif idx < len(addrCache) && addrCache[idx].remote.Equal(remote) {\n\t\taddrCache[idx].timeout = time.Now().Add(connCacheTimeout)\n\t\tl.Debugf(\"addrCache: Remote %s talks through local %s\", remote, addrCache[idx].local)\n\t\treturn addrCache[idx].local\n\t}\n\treturn nil\n}", "func FindLocalIP() (string, int) {\n addrs, err := net.InterfaceAddrs()\n if err != nil {\n fmt.Println(\"Error Lookup: \", err.Error())\n return \"\", -1\n }\n\n //TODO : what if the address we need is not the first! O.o\n for _, ipAddr := range addrs {\n if ipnet, ok := ipAddr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n return ipnet.IP.String(), 1\n }\n/*\n if strings.Contains(ipAddr.String(), \"/23\") { // TODO: fix how to get the actual local IP, dont want to do the /23 or /24....\n candidate := strings.TrimRight(ipAddr.String(), \"/23\")\n return candidate, 1 //TODO: fix this nasty conversion\n }\n*/\n }\n\n return \"\", -1\n}", "func (i Internet) LocalIpv4() string {\n\tips := make([]string, 0, 4)\n\tips = append(ips, i.Faker.RandomStringElement([]string{\"10\", \"172\", \"192\"}))\n\n\tif ips[0] == \"10\" {\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tips = append(ips, strconv.Itoa(i.Faker.IntBetween(0, 255)))\n\t\t}\n\t}\n\n\tif ips[0] == \"172\" {\n\t\tips = append(ips, strconv.Itoa(i.Faker.IntBetween(16, 31)))\n\n\t\tfor j := 0; j < 2; j++ {\n\t\t\tips = append(ips, strconv.Itoa(i.Faker.IntBetween(0, 255)))\n\t\t}\n\t}\n\n\tif ips[0] == \"192\" {\n\t\tips = append(ips, \"168\")\n\n\t\tfor j := 0; j < 2; j++ {\n\t\t\tips = append(ips, strconv.Itoa(i.Faker.IntBetween(0, 255)))\n\t\t}\n\t}\n\n\treturn strings.Join(ips, \".\")\n}", "func (v Global) GetLocal() *Local {\n\treturn &v.addressLocal\n}" ]
[ "0.819511", "0.81470126", "0.80634415", "0.8026287", "0.8009632", "0.80041057", "0.79830116", "0.791989", "0.7919187", "0.7894389", "0.7838935", "0.7817483", "0.7807562", "0.7787841", "0.77753973", "0.7737554", "0.7707347", "0.7702835", "0.7686021", "0.7678269", "0.7678269", "0.7678269", "0.7646841", "0.7642321", "0.764214", "0.76399976", "0.7633825", "0.7633441", "0.7632452", "0.76299995", "0.76213986", "0.76192886", "0.76185083", "0.7613293", "0.7611681", "0.76062506", "0.76062506", "0.7605347", "0.7576021", "0.7570997", "0.75654674", "0.75651026", "0.75577384", "0.7550889", "0.7549457", "0.7545431", "0.7543036", "0.7529846", "0.7510453", "0.7505818", "0.7502373", "0.74985325", "0.74821", "0.74641955", "0.7461365", "0.7456859", "0.7438325", "0.7420992", "0.7420253", "0.741825", "0.7410519", "0.74077326", "0.74065596", "0.7395808", "0.738144", "0.7343764", "0.7324937", "0.73100364", "0.73053634", "0.7304297", "0.7302817", "0.7284147", "0.72687036", "0.7249016", "0.72483957", "0.7195314", "0.7191177", "0.7149692", "0.7147555", "0.7120699", "0.70990145", "0.7095198", "0.70701516", "0.7069895", "0.7066976", "0.7044522", "0.6978191", "0.69724476", "0.69569606", "0.69254446", "0.69200444", "0.6902014", "0.6803118", "0.67630756", "0.6752523", "0.67258716", "0.66834414", "0.66665053", "0.65816975", "0.6581343" ]
0.7668036
22
RemoteAddr returns the remote network address.
func (c *Conn) RemoteAddr() net.Addr { if !c.ok() { return nil } return c.raddr }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (dc *Conn) RemoteAddr() net.Addr {\n\treturn dc.getConn().RemoteAddr()\n}", "func (s *Conn) RemoteAddr() net.Addr {\n\treturn Addr{s.remote}\n}", "func (c *Conn) RemoteAddr() net.Addr {\n\tvar err error\n\n\tc.once.Do(func() {\n\t\terr = c.scanProxyData()\n\t})\n\tif err != nil {\n\t\treturn nil\n\t}\n\n\tif c.srcAddr != nil && c.useRemoteAddress == true {\n\t\treturn c.srcAddr\n\t}\n\treturn c.Conn.RemoteAddr()\n}", "func (c *Conn) RemoteAddr() net.Addr {\n\treturn c.raddr\n}", "func (client *Client) RemoteAddr() net.Addr {\n\tif client.conn != nil {\n\t\treturn client.conn.RemoteAddr()\n\t}\n\n\treturn nil\n}", "func (c *Conn) RemoteAddr() net.Addr {\n\tif c.remoteAddr != nil {\n\t\treturn c.remoteAddr\n\t}\n\treturn c.Conn.RemoteAddr()\n}", "func (rw *NopConn) RemoteAddr() net.Addr { return nil }", "func (cl *DoHClient) RemoteAddr() string {\n\treturn cl.addr.String()\n}", "func (c *Conn) RemoteAddr() net.Addr {\n\treturn c.ws.RemoteAddr()\n}", "func (c *Conn) RemoteAddr() net.Addr {\n\treturn c.conn.RemoteAddr()\n}", "func (c *Conn) RemoteAddr() net.Addr {\n\treturn c.conn.RemoteAddr()\n}", "func (c *Conn) RemoteAddr() net.Addr {\n\treturn c.conn.RemoteAddr()\n}", "func (c *Conn) RemoteAddr() net.Addr {\n\treturn c.c.RemoteAddr()\n}", "func (c Conn) RemoteAddr() Addr { return c.remote }", "func (c *Conn) RemoteAddr() net.Addr {\n\treturn c.nc.RemoteAddr()\n}", "func (v *vsockConn) RemoteAddr() net.Addr {\n\treturn v.remote\n}", "func (c *cConn) RemoteAddr() net.Addr {\n\tsa, _ := syscall.Getpeername(c.fd)\n\treturn parseSa(sa)\n}", "func (clientConn *Conn) RemoteAddr() net.Addr {\n\treturn clientConn.conn.RemoteAddr()\n}", "func (c *UDPChannel) RemoteAddr() string {\n\treturn c.ClientAddr.String()\n}", "func (cl *UDPClient) RemoteAddr() string {\n\treturn cl.Addr.String()\n}", "func (c *ConnUDP) RemoteAddr() net.Addr {\n\treturn c.connection.RemoteAddr()\n}", "func (c Conn) RemoteAddr() smb.Addr {\n\treturn c.nc.RemoteAddr()\n}", "func (ctx *Context) RemoteAddr() string {\n\tif ctx.HTTPReq != nil {\n\t\treturn ctx.HTTPReq.RemoteAddr\n\t} else if ctx.WSConn != nil {\n\t\treturn ctx.WSConn.GetRemoteAddr()\n\t}\n\treturn \"\"\n}", "func (c *LimitedConnection) RemoteAddr() net.Addr {\n\treturn c.inner.RemoteAddr()\n}", "func (c *Conn) RemoteAddr() net.Addr {\n // return c.conn.RemoteAddr()\n fmt.Println(\"getting remote addr\")\n return nil\n}", "func (s *udtSocket) RemoteAddr() net.Addr {\n\treturn s.raddr\n}", "func (p *Conn) RemoteAddr() net.Addr {\n\tp.checkProxyHeaderOnce()\n\tif p.srcAddr != nil {\n\t\treturn p.srcAddr\n\t}\n\treturn p.conn.RemoteAddr()\n}", "func (c Conn) RemoteAddr() net.Addr {\n\treturn c.conn.RemoteAddr()\n}", "func (s *session) RemoteAddr() net.Addr {\n\t//TODO maybe make path dependent?\n\treturn s.smm.connection(s.defaultPathId).RemoteAddr()\n}", "func (p *Conn) RemoteAddr() net.Addr {\n\tp.once.Do(func() {\n\t\tif err := p.checkPrefix(); err != nil && err != io.EOF {\n\t\t\tlog.Printf(\"[ERR] Failed to read proxy prefix: %v\", err)\n\t\t\tp.Close()\n\t\t\tp.bufReader = bufio.NewReader(p.conn)\n\t\t}\n\t})\n\tif p.srcAddr != nil && !p.useConnRemoteAddr {\n\t\treturn p.srcAddr\n\t}\n\treturn p.conn.RemoteAddr()\n}", "func (p *conn) RemoteAddr() net.Addr {\n\tif p.srcAddr != nil {\n\t\treturn p.srcAddr\n\t}\n\treturn p.conn.RemoteAddr()\n}", "func (c *conn) RemoteAddr() net.Addr {\n\treturn c.tc.RemoteAddr()\n}", "func (c *TestConnection) RemoteAddr() net. Addr {\n return nil\n}", "func (bp *Processer) GetRemoteAddr() string {\n\taddr := bp.g.Sock.RemoteAddr()\n\treturn addr.String()\n}", "func (c *UDPSerialConn) RemoteAddr() Addr {\n\treturn c.raddr.opAddr()\n}", "func (mc *MockConn) RemoteAddr() net.Addr {\n\treturn mc.remoteAddr\n}", "func (c *TCPSerialConn) RemoteAddr() Addr {\n\treturn c.raddr.opAddr()\n}", "func (v *Context) RemoteAddr() net.Addr {\n\treturn v.raddr\n}", "func (conn *connection) RemoteAddress() string {\n\treturn conn.raddr\n}", "func (client *Client) RemoteAddress() string {\n\treturn client.address\n}", "func (p *ProxyConn) RemoteAddr() net.Addr {\n\tif p.srcAddr != nil {\n\t\treturn p.srcAddr\n\t}\n\treturn p.BufferedConn.RemoteAddr()\n}", "func (s *SessionUDP) RemoteAddr() net.Addr { return s.raddr }", "func (s *SessionUDP) RemoteAddr() net.Addr { return s.raddr }", "func (t *tcpchanconn) RemoteAddr() net.Addr {\n\treturn t.raddr\n}", "func (c *CryptoStreamConn) RemoteAddr() net.Addr {\n\treturn c.remoteAddr\n}", "func (bc BufConn) RemoteAddr() net.Addr { return TestAddr{Addr: \"\"} }", "func (s *Session) RemoteAddr() net.Addr {\n\tif conn, ok := s.conn.(remoteAddrer); ok {\n\t\treturn conn.RemoteAddr()\n\t}\n\treturn nil\n}", "func (s *Session) GetRemoteAddr() net.Addr {\n\treturn s.session.RemoteAddr()\n}", "func (rc *DelayConn) RemoteAddr() net.Addr {\n\treturn rc.conn.RemoteAddr()\n}", "func (c *ChannelConn) RemoteAddr() net.Addr {\n\treturn nil\n}", "func (c *MsgConnection) RemoteAddr() net.Addr {\n\treturn c.remoteAddr\n}", "func (my *clientConn) RemoteAddr() net.Addr {\n\treturn my.conn.RemoteAddr()\n}", "func (c *clientHandler) RemoteAddr() net.Addr {\n\treturn c.conn.RemoteAddr()\n}", "func (rc *PerWriteDelayConn) RemoteAddr() net.Addr {\n\treturn rc.conn.RemoteAddr()\n}", "func (fpc *FakePacketConn) RemoteAddr() net.Addr { return FakeAddr }", "func (rc *OneByteReadConn) RemoteAddr() net.Addr {\n\treturn rc.conn.RemoteAddr()\n}", "func (o *SmscSession) GetRemoteAddr() string {\n\tif o == nil || o.RemoteAddr == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.RemoteAddr\n}", "func (e *endpoint) GetRemoteAddress() (tcpip.FullAddress, *tcpip.Error) {\n\te.mu.RLock()\n\tdefer e.mu.RUnlock()\n\n\tif e.state != stateConnected {\n\t\treturn tcpip.FullAddress{}, tcpip.ErrNotConnected\n\t}\n\n\treturn tcpip.FullAddress{\n\t\tNIC: e.regNICID,\n\t\tAddr: e.id.RemoteAddress,\n\t\tPort: e.id.RemotePort,\n\t}, nil\n}", "func (rc *OneByteWriteConn) RemoteAddr() net.Addr {\n\treturn rc.conn.RemoteAddr()\n}", "func (rc *ReadDelayConn) RemoteAddr() net.Addr {\n\treturn rc.conn.RemoteAddr()\n}", "func (rc *WriteDelayConn) RemoteAddr() net.Addr {\n\treturn rc.conn.RemoteAddr()\n}", "func (c *Conn) RemoteAddr() net.Addr {\n\treturn c.sctpConn.RemoteAddr()\n}", "func (session *TCPSession) RemoteAddress() string {\n\tif session.isWebSocket {\n\t\tif session.wsConn != nil {\n\t\t\treturn session.wsConn.RemoteAddr().String()\n\t\t}\n\t} else {\n\t\tif session.conn != nil {\n\t\t\treturn session.conn.RemoteAddr().String()\n\t\t}\n\t}\n\treturn \"\"\n}", "func (c *UDPChannel) RemoteIP() string {\n\treturn fmt.Sprintf(\"%v\", c.ClientAddr.IP)\n}", "func (session *TCPSession) RemoteAddress() string {\n\tif session.conn != nil {\n\t\treturn session.conn.RemoteAddr().String()\n\t}\n\treturn \"\"\n}", "func ConnRemoteAddr(c *tls.Conn,) net.Addr", "func (c *WebSocketConn) RemoteAddr() net.Addr {\n\treturn c.conn.RemoteAddr()\n}", "func (c *Conn) RemoteAddr() net.Addr {\n\treturn c.stanzaWriter.to\n}", "func RemoteAddr(r *http.Request) string {\n\tfor _, h := range RemoteAddrHeaders {\n\t\tval := r.Header.Get(h)\n\t\tif val != \"\" {\n\t\t\treturn val\n\t\t}\n\t}\n\n\treturn r.RemoteAddr\n}", "func RemoteAddr(req *http.Request) string {\n\tremoteAddr, _ := splitHost(req.RemoteAddr)\n\treturn remoteAddr\n}", "func (fconn *FakeClientConn) RemoteAddr() net.Addr {\n\treturn nil\n}", "func GetRemoteAddr(r *http.Request) string {\n\tip := r.Header.Get(\"CF-Connecting-IP\")\n\tif ip == \"\" {\n\t\treturn r.RemoteAddr\n\t}\n\treturn ip\n}", "func (c *ThrottledConn) RemoteAddr() net.Addr {\n\treturn c.originalConn.RemoteAddr()\n}", "func (conn *PacketPipe) RemoteAddr() net.Addr { return fakeAddr{} }", "func (o *NSQProducer) GetRemoteAddress() string {\n\tif o == nil || o.RemoteAddress == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.RemoteAddress\n}", "func (conn *LocalConnection) RemoteUDPAddr() *net.UDPAddr {\n\tconn.RLock()\n\tdefer conn.RUnlock()\n\treturn conn.remoteUDPAddr\n}", "func (r *Route) RemoteAddress() tcpip.Address {\n\treturn r.routeInfo.RemoteAddress\n}", "func RemoteAddress(r *http.Request) (string, bool) {\n\thdr := r.Header\n\n\t// Try to obtain the ip from the X-Forwarded-For header\n\tip := hdr.Get(\"X-Forwarded-For\")\n\tif ip != \"\" {\n\t\t// X-Forwarded-For is potentially a list of addresses separated with \",\"\n\t\tparts := strings.Split(ip, \",\")\n\t\tif len(parts) > 0 {\n\t\t\tip = strings.TrimSpace(parts[0])\n\n\t\t\tif ip != \"\" {\n\t\t\t\treturn ip, false\n\t\t\t}\n\t\t}\n\t}\n\n\t// Try to obtain the ip from the X-Real-Ip header\n\tip = strings.TrimSpace(hdr.Get(\"X-Real-Ip\"))\n\tif ip != \"\" {\n\t\treturn ip, false\n\t}\n\n\t// Fallback to the request remote address\n\treturn RemovePortFromRemoteAddr(r.RemoteAddr), true\n}", "func GetRemoteIP(r *http.Request) string {\n\tremoteIP := \"\"\n\tif parts := strings.Split(r.RemoteAddr, \":\"); len(parts) == 2 {\n\t\tremoteIP = parts[0]\n\t}\n\n\tif xff := strings.Trim(r.Header.Get(\"X-Forwarded-For\"), \",\"); len(xff) > 0 {\n\t\taddrs := strings.Split(xff, \",\")\n\t\tlastFwd := addrs[len(addrs)-1]\n\t\tif ip := net.ParseIP(lastFwd); ip != nil {\n\t\t\tremoteIP = ip.String()\n\t\t}\n\t} else if xri := r.Header.Get(\"X-Real-Ip\"); len(xri) > 0 {\n\t\tif ip := net.ParseIP(xri); ip != nil {\n\t\t\tremoteIP = ip.String()\n\t\t}\n\t}\n\n\treturn remoteIP\n}", "func RemoteAddr(r *http.Request) string {\n\tvia := r.RemoteAddr\n\txff := r.Header.Get(pdv1.Forward)\n\tif xff != \"\" {\n\t\treturn fmt.Sprintf(\"%v via %v\", xff, r.RemoteAddr)\n\t}\n\treturn via\n}", "func IpAddrFromRemoteAddr(s string) string {\n\tidx := strings.LastIndex(s, \":\")\n\tif idx == -1 {\n\t\treturn s\n\t}\n\treturn s[:idx]\n}", "func (c *fakeRedisConn) RemoteAddr() string { return \"\" }", "func GetRemoteIP(r *http.Request) string {\n\tips := r.Header.Get(\"X-Forwarded-For\")\n\n\tsplitIps := strings.Split(ips, \",\")\n\n\tif ips != \"\" {\n\t\t// trim IP list\n\t\tfor i := range splitIps {\n\t\t\tsplitIps[i] = strings.TrimSpace(splitIps[i])\n\t\t}\n\n\t\t// get last IP in list since ELB prepends other user defined IPs, meaning the last one is the actual client IP.\n\t\tnetIP := net.ParseIP(splitIps[0])\n\t\tif netIP != nil {\n\t\t\treturn netIP.String()\n\t\t}\n\t}\n\n\tip, _, err := net.SplitHostPort(r.RemoteAddr)\n\tif err != nil {\n\t\treturn r.RemoteAddr\n\t}\n\n\tnetIP := net.ParseIP(ip)\n\tif netIP != nil {\n\t\tip := netIP.String()\n\t\tif ip == \"::1\" {\n\t\t\treturn \"127.0.0.1\"\n\t\t}\n\t\treturn ip\n\t}\n\n\treturn r.RemoteAddr\n}", "func (rs *requestContext) RemoteAddress() string {\n\treturn rs.remoteAddress\n}", "func getRemoteAddress(r *http.Request) string {\n\thdr := r.Header\n\thdrRealIP := hdr.Get(\"X-Real-Ip\")\n\thdrForwardedFor := hdr.Get(\"X-Forwarded-For\")\n\tif hdrRealIP == \"\" && hdrForwardedFor == \"\" {\n\t\treturn ipAddrFromRemoteAddr(r.RemoteAddr)\n\t}\n\tif hdrForwardedFor != \"\" {\n\t\t// X-Forwarded-For is potentially a list of addresses separated with \",\"\n\t\tparts := strings.Split(hdrForwardedFor, \",\")\n\t\tfor i, p := range parts {\n\t\t\tparts[i] = strings.TrimSpace(p)\n\t\t}\n\t\t// TODO: should return first non-local address\n\t\treturn parts[0]\n\t}\n\treturn hdrRealIP\n}", "func (cfg Config) GetRemoteHost() (remoteHost string) {\n\treturn cfg.RemoteHost\n}", "func (m MetaData) GetRemoteIP() string {\n\tif len(m) == 0 {\n\t\treturn \"\"\n\t}\n\tif ip := m[\"x-forwarded-for\"]; ip != \"\" {\n\t\tparts := strings.Split(ip, \",\")\n\t\tif len(parts) > 0 {\n\t\t\treturn parts[0]\n\t\t}\n\t}\n\treturn m[remoteIPFromPeer]\n}", "func getRemoteIP() (ip string, err error) {\n\tclient := &http.Client{\n\t\tTimeout: time.Second * 10,\n\t}\n\n\treq, err := http.NewRequest(\"GET\", \"http://ip.cn\", nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tres, err := client.Do(req)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tdefer res.Body.Close()\n\n\tdata, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tip = string(ipPattern.Find(data))\n\n\treturn\n}", "func (c *Config) GetRemoteHost() string {\n\tif c.sandboxMode {\n\t\treturn fmt.Sprintf(\"sandbox.payfast.co.za\")\n\t}\n\n\treturn fmt.Sprintf(\"www.payfast.co.za\")\n}", "func (c *Context) RemoteIP() (remoteIP string) {\n\tremoteIP = metadata.String(c, metadata.RemoteIP)\n\tif remoteIP != \"\" {\n\t\treturn\n\t}\n\n\tremoteIP = c.Request.Header.Get(\"X-Forwarded-For\")\n\tremoteIP = strings.TrimSpace(strings.Split(remoteIP, \",\")[0])\n\tif remoteIP == \"\" {\n\t\tremoteIP = strings.TrimSpace(c.Request.Header.Get(\"X-Real-Ip\"))\n\t}\n\n\treturn\n}", "func (c *webCtx) RemoteIP() string {\n\treturn c.remoteIP\n}", "func (pc peerConn) RemoteIP() net.IP {\r\n\tif pc.ip != nil {\r\n\t\treturn pc.ip\r\n\t}\r\n\r\n\t// In test cases a conn could not be present at all or be an in-memory\r\n\t// implementation where we want to return a fake ip.\r\n\tif pc.conn == nil || pc.conn.RemoteAddr().String() == \"pipe\" {\r\n\t\tpc.ip = net.IP{172, 16, 0, byte(atomic.AddUint32(&testIPSuffix, 1))}\r\n\r\n\t\treturn pc.ip\r\n\t}\r\n\r\n\thost, _, err := net.SplitHostPort(pc.conn.RemoteAddr().String())\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\r\n\tips, err := net.LookupIP(host)\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\r\n\tpc.ip = ips[0]\r\n\r\n\treturn pc.ip\r\n}", "func GetRemoteAddrFromRepo(repo rr.LocalRepo, remoteName string) (string, int, bool) {\n\turls := repo.GetRemoteURLs(remoteName)\n\tif len(urls) > 0 {\n\t\tfor _, url := range urls {\n\t\t\tep, err := transport.NewEndpoint(url)\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn ep.Host, ep.Port, true\n\t\t}\n\t}\n\treturn \"\", 0, false\n}", "func ipAddrFromRemoteAddr(s string) string {\n\tidx := strings.LastIndex(s, \":\")\n\tif idx == -1 {\n\t\treturn s\n\t}\n\treturn s[:idx]\n}", "func ipAddrFromRemoteAddr(s string) string {\n\tidx := strings.LastIndex(s, \":\")\n\tif idx == -1 {\n\t\treturn s\n\t}\n\treturn s[:idx]\n}", "func ipAddrFromRemoteAddr(s string) string {\n\tidx := strings.LastIndex(s, \":\")\n\tif idx == -1 {\n\t\treturn s\n\t}\n\treturn s[:idx]\n}", "func ipAddrFromRemoteAddr(s string) string {\n\tidx := strings.LastIndex(s, \":\")\n\tif idx == -1 {\n\t\treturn s\n\t}\n\treturn s[:idx]\n}", "func getRemoteIP() (ip string, err error) {\n\tclient := &http.Client{\n\t\tTimeout: time.Second * 30,\n\t}\n\n\treq, err := http.NewRequest(\"GET\", \"http://ifconfig.me\", nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treq.Header.Set(\"User-Agent\", \"curl\")\n\tres, err := client.Do(req)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tdefer res.Body.Close()\n\n\tdata, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn\n\t}\n\tip = string(data)\n\n\treturn\n}", "func (m *MockSession) RemoteAddr() net.Addr {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"RemoteAddr\")\n\tret0, _ := ret[0].(net.Addr)\n\treturn ret0\n}", "func (m *MockPacketHandler) RemoteAddr() net.Addr {\n\tret := m.ctrl.Call(m, \"RemoteAddr\")\n\tret0, _ := ret[0].(net.Addr)\n\treturn ret0\n}" ]
[ "0.77139986", "0.77115506", "0.76626843", "0.7597765", "0.7562441", "0.7547449", "0.7542905", "0.7530346", "0.7527101", "0.74879175", "0.74879175", "0.74879175", "0.74846125", "0.7463457", "0.74571884", "0.7453051", "0.7443206", "0.74371713", "0.74066687", "0.7380345", "0.7365068", "0.7364354", "0.73637086", "0.73588836", "0.7329912", "0.7315931", "0.73154306", "0.73046565", "0.7298326", "0.72800994", "0.72740924", "0.72492045", "0.72214264", "0.7213172", "0.72124743", "0.7190192", "0.7172428", "0.71703017", "0.71699977", "0.71628195", "0.7158169", "0.71543384", "0.71543384", "0.71511877", "0.7140489", "0.71225274", "0.71218204", "0.7121068", "0.7117786", "0.71139246", "0.70811224", "0.7044007", "0.70376533", "0.7007657", "0.7002682", "0.6980312", "0.6959602", "0.6950954", "0.6940181", "0.69314504", "0.69229203", "0.6915348", "0.6862899", "0.6828488", "0.6803801", "0.67675626", "0.67542285", "0.6730792", "0.66770476", "0.66752714", "0.6662031", "0.6661188", "0.66014963", "0.6596878", "0.6588493", "0.6571415", "0.6566035", "0.6534393", "0.64025235", "0.63480216", "0.6270396", "0.6244015", "0.6201538", "0.6192136", "0.6186635", "0.6139331", "0.61222327", "0.6106395", "0.6078054", "0.6063597", "0.6018353", "0.59871083", "0.59709245", "0.5896054", "0.5896054", "0.5896054", "0.5896054", "0.5892834", "0.585849", "0.58154607" ]
0.76058763
3
SetDeadline implements the Conn SetDeadline method.
func (c *Conn) SetDeadline(t time.Time) error { if !c.ok() { return syscall.EINVAL } err := c.SetReadDeadline(t) if err != nil { return err } return c.SetWriteDeadline(t) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Conn) SetDeadline(t time.Time) error {\n\treturn fmt.Errorf(\"No supported\")\n}", "func (c *Conn) SetDeadline(t time.Time) error { return c.pc.SetDeadline(t) }", "func (c *Conn) SetDeadline(t time.Time) error {\n // return c.conn.SetDeadline(t)\n fmt.Println(\"set deadline\", t)\n return nil\n}", "func (p *Conn) SetDeadline(t time.Time) error {\n\treturn p.conn.SetDeadline(t)\n}", "func (c *Conn) SetDeadline(t time.Time) error {\n\treturn c.conn.SetDeadline(t)\n}", "func (c *Conn) SetDeadline(t time.Time) error {\n\treturn c.conn.SetDeadline(t)\n}", "func (c *cConn) SetDeadline(t time.Time) error {\n\treturn syscall.EINVAL\n}", "func (conn *Conn) SetDeadline(t time.Time) error {\n\tif conn, ok := conn.rwc.(net.Conn); ok {\n\t\treturn conn.SetDeadline(t)\n\t}\n\n\treturn errSetDeadline\n}", "func (rw *NopConn) SetDeadline(time.Time) error { return nil }", "func (p *packetConn) SetDeadline(t time.Time) error {\n\treturn ErrNotImplemented\n}", "func (bc BufConn) SetDeadline(t time.Time) error { return nil }", "func (c *TestConnection) SetDeadline(t time.Time) error {\n return errors.New(\"Not implemented\")\n}", "func (v *vsockConn) SetDeadline(t time.Time) error {\n\treturn nil // FIXME\n}", "func (dc *Conn) SetDeadline(t time.Time) error {\n\tdc.SetReadDeadline(t)\n\tdc.SetWriteDeadline(t)\n\treturn nil\n}", "func (c *ChannelConn) SetDeadline(_ time.Time) error {\n\treturn nil\n}", "func (t *tcpchanconn) SetDeadline(deadline time.Time) error {\n\tif err := t.SetReadDeadline(deadline); err != nil {\n\t\treturn err\n\t}\n\treturn t.SetWriteDeadline(deadline)\n}", "func (s *Stream) SetDeadline(t time.Time) error {\n\treturn s.conn.conn.SetDeadline(t)\n}", "func ConnSetDeadline(c *tls.Conn, t time.Time) error", "func (v *HVsockConn) SetDeadline(deadline time.Time) error {\n\tif err := v.SetReadDeadline(deadline); err != nil {\n\t\treturn err\n\t}\n\treturn v.SetWriteDeadline(deadline)\n}", "func (r *RPCIngressGateway) SetDeadline(req *DeadlineReq, _ *struct{}) error {\n\tconn, err := r.getConn(req.ConnID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn conn.SetDeadline(req.Deadline)\n}", "func (s *Conn) SetDeadline(t time.Time) error {\n\terr1 := s.SetReadDeadline(t)\n\terr2 := s.SetWriteDeadline(t)\n\tif err1 != nil {\n\t\treturn err1\n\t}\n\treturn err2\n}", "func (w *WebrtcConn) SetDeadline(t time.Time) error {\n\treturn nil\n}", "func (c *CryptoStreamConn) SetDeadline(time.Time) error {\n\treturn nil\n}", "func (c *Conn) SetDeadline(t time.Time) error {\n\treturn c.sctpConn.SetDeadline(t)\n}", "func (e errorConnection) SetDeadline(t time.Time) error {\n\treturn e.err\n}", "func (cr *ChecksumReader) SetDeadline(t time.Time) error {\n\tcr.deadline = t\n\t// Return the error at connection time.\n\treturn nil\n}", "func (c *LimitedConnection) SetDeadline(t time.Time) error {\n\terr := c.SetReadDeadline(t)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn c.SetWriteDeadline(t)\n}", "func (wsConn *WSConn) SetDeadline(t time.Time) error {\n\terr := wsConn.conn.SetReadDeadline(t)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn wsConn.conn.SetWriteDeadline(t)\n}", "func (bw *BlockWriter) SetDeadline(t time.Time) error {\n\tbw.deadline = t\n\tif bw.conn != nil {\n\t\treturn bw.conn.SetDeadline(t)\n\t}\n\n\t// Return the error at connection time.\n\treturn nil\n}", "func (c *Client) SetDeadline(t time.Time) error {\n\treturn c.p.SetDeadline(t)\n}", "func (c *ThrottledConn) SetDeadline(t time.Time) error {\n\treturn c.originalConn.SetDeadline(t)\n}", "func (d *Dialer) SetDeadline(deadline time.Time) {\n\td.deadline = deadline\n\td.okdeadline = true\n}", "func (l *TCPListener) SetDeadline(t time.Time) error {\n\tif l == nil || l.fd == nil {\n\t\treturn syscall.EINVAL\n\t}\n\treturn l.fd.setDeadline(t)\n}", "func (w *ChannelWriter) SetDeadline(t time.Time) {\n\tw.deadline = t\n}", "func (dec *StreamDecoder) SetDeadline(t time.Time) {\n\tdec.deadline = &t\n}", "func (p *Port) SetDeadline(t time.Time) error {\n\t// Funky Town\n\terr := p.f.SetDeadline(t)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (r *timeoutReader) SetDeadline(t time.Time) {\n\tr.t = t\n}", "func (conn *PacketPipe) SetDeadline(t time.Time) error {\n\t_ = conn.SetReadDeadline(t)\n\t_ = conn.SetWriteDeadline(t)\n\treturn nil\n}", "func (r *Reader) SetDeadline(t time.Time) {\n\tr.mu.Lock()\n\tdefer r.mu.Unlock()\n\n\tr.deadline = t\n}", "func (r *ChannelReader) SetDeadline(deadline time.Time) {\n\tr.deadline = deadline\n}", "func (s *StdioConn) SetDeadline(t time.Time) error {\n\terr1 := s.stdin.SetReadDeadline(t)\n\terr2 := s.stdout.SetWriteDeadline(t)\n\tif err1 != nil {\n\t\treturn err1\n\t}\n\treturn err2\n}", "func (s *StdioConn) SetDeadline(t time.Time) error {\n\terr1 := s.stdin.SetReadDeadline(t)\n\terr2 := s.stdout.SetWriteDeadline(t)\n\tif err1 != nil {\n\t\treturn err1\n\t}\n\treturn err2\n}", "func (f *FileWriter) SetDeadline(t time.Time) error {\n\tf.deadline = t\n\tif f.blockWriter != nil {\n\t\treturn f.blockWriter.SetDeadline(t)\n\t}\n\n\t// Return the error at connection time.\n\treturn nil\n}", "func (c *Conn) SetWriteDeadline(t time.Time) error {\n // return c.conn.SetWriteDeadline(t)\n fmt.Println(\"set write deadline\", t)\n return nil\n}", "func (s *Stream) SetDeadline(t time.Time) error {\n\tif err := s.SetReadDeadline(t); err != nil {\n\t\treturn err\n\t}\n\tif err := s.SetWriteDeadline(t); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (self *LoggerWriter) SetDeadline(t time.Time) error {\n\treturn nil\n}", "func (p *tubePool) setDeadline(ctx context.Context, tube tube) error {\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tdefault:\n\t}\n\tvar deadline time.Time\n\tif d, ok := ctx.Deadline(); ok {\n\t\tdeadline = d\n\t}\n\treturn tube.SetDeadline(deadline)\n}", "func (c *Conn) SetReadDeadline(t time.Time) error {\n // return c.conn.SetReadDeadline(t)\n fmt.Println(\"set read deadline\", t)\n return nil\n}", "func (self *LoggerReader) SetDeadline(t time.Time) error {\n\treturn self.f.SetReadDeadline(t)\n}", "func (o *InlineResponse20033Milestones) SetDeadline(v string) {\n\to.Deadline = &v\n}", "func (f *File) setDeadline(t time.Time) error {\n\tif err := f.checkValid(\"SetDeadline\"); err != nil {\n\t\treturn err\n\t}\n\treturn f.pfd.SetDeadline(t)\n}", "func (o *V0037JobProperties) SetDeadline(v string) {\n\to.Deadline = &v\n}", "func ConnSetReadDeadline(c *tls.Conn, t time.Time) error", "func ConnSetWriteDeadline(c *tls.Conn, t time.Time) error", "func (bc BufConn) SetReadDeadline(t time.Time) error { return nil }", "func (o *InlineResponse20034Milestone) SetDeadline(v string) {\n\to.Deadline = &v\n}", "func (bc BufConn) SetWriteDeadline(t time.Time) error { return nil }", "func (t *tcpchanconn) SetWriteDeadline(deadline time.Time) error {\n\treturn errors.New(\"ssh: tcpchan: deadline not supported\")\n}", "func (p *packetConn) SetReadDeadline(t time.Time) error {\n\treturn ErrNotImplemented\n}", "func (c *cConn) SetWriteDeadline(t time.Time) error {\n\treturn syscall.EINVAL\n}", "func (c *Conn) SetReadDeadline(t time.Time) error { return c.pc.SetReadDeadline(t) }", "func (c *cConn) SetReadDeadline(t time.Time) error {\n\treturn syscall.EINVAL\n}", "func (c *Conn) SetWriteDeadline(t time.Time) error {\n\treturn fmt.Errorf(\"No supported\")\n}", "func (p *packetConn) SetWriteDeadline(t time.Time) error {\n\treturn ErrNotImplemented\n}", "func (w *ConnWrapper) SetReadDeadline(t time.Time) error {\n\t// TODO: put int Deadline\n\tvar err error\n\tswitch w.conn.(type) {\n\tcase net.Conn:\n\t\tconn := w.conn.(net.Conn)\n\t\terr = conn.SetReadDeadline(t)\n\tdefault:\n\t\tklog.Warningf(\"unsupported conn type: %T\", w.conn)\n\t}\n\treturn err\n}", "func (c *Conn) SetWriteDeadline(t time.Time) error { return c.pc.SetWriteDeadline(t) }", "func (c *Conn) SetWriteDeadline(t time.Time) error {\n\tif !c.ok() {\n\t\treturn syscall.EINVAL\n\t}\n\tc.deadlineMutex.Lock()\n\tdefer c.deadlineMutex.Unlock()\n\tc.wdeadline = t\n\treturn nil\n}", "func (m *MockConn) SetDeadline(deadline time.Time) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"SetDeadline\", deadline)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (conn *Conn) SetWriteDeadline(t time.Time) error {\n\tif conn, ok := conn.rwc.(net.Conn); ok {\n\t\treturn conn.SetWriteDeadline(t)\n\t}\n\n\treturn errSetDeadline\n}", "func (o *ViewMilestone) SetDeadline(v string) {\n\to.Deadline = &v\n}", "func (ctn *Connection) SetTimeout(deadline time.Time, socketTimeout time.Duration) error {\n\tctn.deadline = deadline\n\tctn.socketTimeout = socketTimeout\n\n\treturn nil\n}", "func (c *TestConnection) SetWriteDeadline(t time.Time) error {\n return errors.New(\"Not implemented\")\n}", "func (e errorConnection) SetWriteDeadline(t time.Time) error {\n\treturn e.err\n}", "func (c *Conn) SetReadDeadline(t time.Time) error {\n\treturn fmt.Errorf(\"No supported\")\n}", "func (ctn *Connection) SetTimeout(deadline time.Time, socketTimeout time.Duration) Error {\n\tctn.deadline = deadline\n\tctn.socketTimeout = socketTimeout\n\n\treturn nil\n}", "func (ctn *Connection) updateDeadline() error {\n\tnow := time.Now()\n\tvar socketDeadline time.Time\n\tif ctn.deadline.IsZero() {\n\t\tif ctn.socketTimeout > 0 {\n\t\t\tsocketDeadline = now.Add(ctn.socketTimeout)\n\t\t}\n\t} else {\n\t\tif now.After(ctn.deadline) {\n\t\t\treturn types.NewAerospikeError(types.TIMEOUT)\n\t\t}\n\t\tif ctn.socketTimeout == 0 {\n\t\t\tsocketDeadline = ctn.deadline\n\t\t} else {\n\t\t\ttDeadline := now.Add(ctn.socketTimeout)\n\t\t\tif tDeadline.After(ctn.deadline) {\n\t\t\t\tsocketDeadline = ctn.deadline\n\t\t\t} else {\n\t\t\t\tsocketDeadline = tDeadline\n\t\t\t}\n\t\t}\n\n\t\t// floor to a millisecond to avoid too short timeouts\n\t\tif socketDeadline.Sub(now) < time.Millisecond {\n\t\t\tsocketDeadline = now.Add(time.Millisecond)\n\t\t}\n\t}\n\n\tif err := ctn.conn.SetDeadline(socketDeadline); err != nil {\n\t\tif ctn.node != nil {\n\t\t\tatomic.AddInt64(&ctn.node.stats.ConnectionsFailed, 1)\n\t\t}\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (v *vsockConn) SetWriteDeadline(t time.Time) error {\n\treturn nil // FIXME\n}", "func (c Conn) SetWriteDeadline(t time.Time) error {\n\treturn c.conn.SetWriteDeadline(t)\n}", "func (my *clientConn) SetWriteDeadline(t time.Time) error {\n\treturn my.conn.SetWriteDeadline(t)\n}", "func (s *Conn) SetWriteDeadline(t time.Time) error {\n\td, ok := s.writer.(interface {\n\t\tSetWriteDeadline(time.Time) error\n\t})\n\tif !ok {\n\t\treturn &net.OpError{Op: \"set\", Net: \"stdio\", Addr: s.LocalAddr(),\n\t\t\tErr: errors.New(\"write deadline not supported\")}\n\t}\n\treturn d.SetWriteDeadline(t)\n}", "func (mr *MockConnMockRecorder) SetDeadline(deadline interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"SetDeadline\", reflect.TypeOf((*MockConn)(nil).SetDeadline), deadline)\n}", "func (c *Conn) SetReadDeadline(t time.Time) error {\n\tif !c.ok() {\n\t\treturn syscall.EINVAL\n\t}\n\tc.deadlineMutex.Lock()\n\tdefer c.deadlineMutex.Unlock()\n\tc.rdeadline = t\n\treturn nil\n}", "func (c *Ctx) WithDeadline(deadline time.Time) (cf context.CancelFunc) {\n\tc.netContext, cf = context.WithDeadline(c.netContext, deadline)\n\treturn\n}", "func (s *Conn) SetReadDeadline(t time.Time) error {\n\td, ok := s.reader.(interface {\n\t\tSetReadDeadline(time.Time) error\n\t})\n\tif !ok {\n\t\treturn &net.OpError{Op: \"set\", Net: \"stdio\", Addr: s.LocalAddr(),\n\t\t\tErr: errors.New(\"read deadline not supported\")}\n\t}\n\treturn d.SetReadDeadline(t)\n}", "func (c *ChannelConn) SetWriteDeadline(_ time.Time) error {\n\treturn nil\n}", "func (c Conn) SetReadDeadline(t time.Time) error {\n\treturn c.conn.SetReadDeadline(t)\n}", "func (rw *NopConn) SetWriteDeadline(time.Time) error { return nil }", "func (conn *Conn) SetReadDeadline(t time.Time) error {\n\tif conn, ok := conn.rwc.(net.Conn); ok {\n\t\treturn conn.SetReadDeadline(t)\n\t}\n\n\treturn errSetDeadline\n}", "func (rc *DelayConn) SetWriteDeadline(t time.Time) error {\n\treturn rc.conn.SetWriteDeadline(t)\n}", "func (dc *Conn) SetWriteDeadline(t time.Time) error {\n\tdc.writeDeadline = t\n\tdc.getConn().SetWriteDeadline(t)\n\treturn nil\n}", "func (ctn *Connection) updateDeadline() Error {\n\tnow := time.Now()\n\tvar socketDeadline time.Time\n\tif ctn.deadline.IsZero() {\n\t\tif ctn.socketTimeout > 0 {\n\t\t\tsocketDeadline = now.Add(ctn.socketTimeout)\n\t\t}\n\t} else {\n\t\tif now.After(ctn.deadline) {\n\t\t\treturn newError(types.TIMEOUT)\n\t\t}\n\t\tif ctn.socketTimeout == 0 {\n\t\t\tsocketDeadline = ctn.deadline\n\t\t} else {\n\t\t\ttDeadline := now.Add(ctn.socketTimeout)\n\t\t\tif tDeadline.After(ctn.deadline) {\n\t\t\t\tsocketDeadline = ctn.deadline\n\t\t\t} else {\n\t\t\t\tsocketDeadline = tDeadline\n\t\t\t}\n\t\t}\n\n\t\t// floor to a millisecond to avoid too short timeouts\n\t\tif socketDeadline.Sub(now) < time.Millisecond {\n\t\t\tsocketDeadline = now.Add(time.Millisecond)\n\t\t}\n\t}\n\n\tif err := ctn.conn.SetDeadline(socketDeadline); err != nil {\n\t\tif ctn.node != nil {\n\t\t\tatomic.AddInt64(&ctn.node.stats.ConnectionsFailed, 1)\n\t\t}\n\t\treturn errToAerospikeErr(ctn, err)\n\t}\n\n\treturn nil\n}", "func (c *SerialConn) SetWriteDeadline(t time.Time) error {\n\treturn nil\n}", "func (rc *WriteDelayConn) SetWriteDeadline(t time.Time) error {\n\treturn rc.conn.SetWriteDeadline(t)\n}", "func (my *clientConn) SetReadDeadline(t time.Time) error {\n\treturn my.conn.SetReadDeadline(t)\n}", "func (r *RPCIngressGateway) SetWriteDeadline(req *DeadlineReq, _ *struct{}) error {\n\tconn, err := r.getConn(req.ConnID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn conn.SetWriteDeadline(req.Deadline)\n}", "func (dc DeadlineConn) SetTimeout(timeout time.Duration) error {\n\tif timeout <= 0 {\n\t\treturn ErrInvalidTimeout\n\t}\n\tdc.timeout = timeout\n\treturn nil\n}", "func (c *Conn) SetWriteDeadline(t time.Time) error {\n\treturn c.sctpConn.SetWriteDeadline(t)\n}", "func (c *Conn) SetWriteDeadline(t time.Time) error {\n\tc.stanzaWriter.writeDeadline = t\n\treturn nil\n}", "func (c *TestConnection) SetReadDeadline(t time.Time) error {\n return errors.New(\"Not implemented\")\n}", "func (c *HostClient) DoDeadline(req *Request, resp *Response, deadline time.Time) error {\n\treq.timeout = time.Until(deadline)\n\tif req.timeout < 0 {\n\t\treturn ErrTimeout\n\t}\n\treturn c.Do(req, resp)\n}" ]
[ "0.89029294", "0.8833888", "0.88141", "0.8760783", "0.8758353", "0.8758353", "0.87352335", "0.86974245", "0.86226743", "0.8615378", "0.85717165", "0.85715985", "0.85475075", "0.84554946", "0.84285027", "0.8362345", "0.83554965", "0.83529186", "0.8343889", "0.8312316", "0.8293524", "0.8269377", "0.82410735", "0.8238704", "0.8201999", "0.8199819", "0.81221604", "0.80621845", "0.8061184", "0.805724", "0.8005573", "0.8000968", "0.7980518", "0.79527354", "0.7894367", "0.7808446", "0.77697605", "0.7767395", "0.7753349", "0.77483183", "0.7741383", "0.7741383", "0.75436467", "0.73914534", "0.73617786", "0.7350782", "0.7164135", "0.7143599", "0.70837927", "0.7066766", "0.6990306", "0.69423276", "0.6923532", "0.68913794", "0.6879868", "0.68371046", "0.6825433", "0.6820466", "0.680139", "0.6770453", "0.6756735", "0.67529786", "0.6734127", "0.6726199", "0.67199606", "0.6711722", "0.6686999", "0.6668733", "0.66552806", "0.6652976", "0.6612949", "0.6607867", "0.6595573", "0.6581664", "0.65812767", "0.65701973", "0.65663433", "0.6564212", "0.65381306", "0.65377015", "0.65168875", "0.65166646", "0.65115607", "0.6500835", "0.6476957", "0.6466628", "0.64511955", "0.6444913", "0.6444009", "0.6438918", "0.6435694", "0.64335316", "0.6423716", "0.6419655", "0.6412453", "0.6382045", "0.63687843", "0.6358062", "0.63464963", "0.63278335" ]
0.8424976
15
SetReadDeadline implements the Conn SetReadDeadline method.
func (c *Conn) SetReadDeadline(t time.Time) error { if !c.ok() { return syscall.EINVAL } c.deadlineMutex.Lock() defer c.deadlineMutex.Unlock() c.rdeadline = t return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Conn) SetReadDeadline(t time.Time) error {\n\treturn fmt.Errorf(\"No supported\")\n}", "func (c *Conn) SetReadDeadline(t time.Time) error { return c.pc.SetReadDeadline(t) }", "func (c Conn) SetReadDeadline(t time.Time) error {\n\treturn c.conn.SetReadDeadline(t)\n}", "func (c *cConn) SetReadDeadline(t time.Time) error {\n\treturn syscall.EINVAL\n}", "func (c *Conn) SetReadDeadline(t time.Time) error {\n // return c.conn.SetReadDeadline(t)\n fmt.Println(\"set read deadline\", t)\n return nil\n}", "func (rc *OneByteReadConn) SetReadDeadline(t time.Time) error {\n\treturn rc.conn.SetReadDeadline(t)\n}", "func (my *clientConn) SetReadDeadline(t time.Time) error {\n\treturn my.conn.SetReadDeadline(t)\n}", "func (rw *NopConn) SetReadDeadline(time.Time) error { return nil }", "func (conn *Conn) SetReadDeadline(t time.Time) error {\n\tif conn, ok := conn.rwc.(net.Conn); ok {\n\t\treturn conn.SetReadDeadline(t)\n\t}\n\n\treturn errSetDeadline\n}", "func (dc *Conn) SetReadDeadline(t time.Time) error {\n\tdc.readDeadline = t\n\tdc.getConn().SetReadDeadline(t)\n\treturn nil\n}", "func (v *vsockConn) SetReadDeadline(t time.Time) error {\n\treturn nil // FIXME\n}", "func (c *Conn) SetReadDeadline(t time.Time) error {\n\treturn c.conn.SetReadDeadline(t)\n}", "func (c *Conn) SetReadDeadline(t time.Time) error {\n\treturn c.conn.SetReadDeadline(t)\n}", "func (c *Conn) SetReadDeadline(t time.Time) error {\n\treturn c.conn.SetReadDeadline(t)\n}", "func (c *Conn) SetReadDeadline(t time.Time) error {\n\tc.readDeadline = t\n\treturn nil\n}", "func (p *packetConn) SetReadDeadline(t time.Time) error {\n\treturn ErrNotImplemented\n}", "func (c *TestConnection) SetReadDeadline(t time.Time) error {\n return errors.New(\"Not implemented\")\n}", "func (c *Conn) SetReadDeadline(t time.Time) error {\n\treturn c.c.SetReadDeadline(t)\n}", "func (p *Conn) SetReadDeadline(t time.Time) error {\n\treturn p.conn.SetReadDeadline(t)\n}", "func (rc *ReadDelayConn) SetReadDeadline(t time.Time) error {\n\treturn rc.conn.SetReadDeadline(t)\n}", "func (rc *DelayConn) SetReadDeadline(t time.Time) error {\n\treturn rc.conn.SetReadDeadline(t)\n}", "func (c *ChannelConn) SetReadDeadline(_ time.Time) error {\n\treturn nil\n}", "func (w *ConnWrapper) SetReadDeadline(t time.Time) error {\n\t// TODO: put int Deadline\n\tvar err error\n\tswitch w.conn.(type) {\n\tcase net.Conn:\n\t\tconn := w.conn.(net.Conn)\n\t\terr = conn.SetReadDeadline(t)\n\tdefault:\n\t\tklog.Warningf(\"unsupported conn type: %T\", w.conn)\n\t}\n\treturn err\n}", "func (c *SerialConn) SetReadDeadline(t time.Time) error {\n\treturn nil\n}", "func (bc BufConn) SetReadDeadline(t time.Time) error { return nil }", "func (s *Conn) SetReadDeadline(t time.Time) error {\n\td, ok := s.reader.(interface {\n\t\tSetReadDeadline(time.Time) error\n\t})\n\tif !ok {\n\t\treturn &net.OpError{Op: \"set\", Net: \"stdio\", Addr: s.LocalAddr(),\n\t\t\tErr: errors.New(\"read deadline not supported\")}\n\t}\n\treturn d.SetReadDeadline(t)\n}", "func (c *wsConn) SetReadDeadline(t time.Time) error {\n\treturn c.conn.SetReadDeadline(t)\n}", "func (c *CryptoStreamConn) SetReadDeadline(time.Time) error {\n\treturn nil\n}", "func (c *LimitedConnection) SetReadDeadline(t time.Time) error {\n\tc.readDeadline = t\n\treturn c.inner.SetReadDeadline(t)\n}", "func (v *HVsockConn) SetReadDeadline(deadline time.Time) error {\n\treturn v.readDeadline.set(deadline)\n}", "func (wsConn *WSConn) SetReadDeadline(t time.Time) error {\n\treturn wsConn.conn.SetReadDeadline(t)\n}", "func (e errorConnection) SetReadDeadline(t time.Time) error {\n\treturn e.err\n}", "func (r *RPCIngressGateway) SetReadDeadline(req *DeadlineReq, _ *struct{}) error {\n\tconn, err := r.getConn(req.ConnID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn conn.SetReadDeadline(req.Deadline)\n}", "func ConnSetReadDeadline(c *tls.Conn, t time.Time) error", "func (rc *PerWriteDelayConn) SetReadDeadline(t time.Time) error {\n\treturn rc.conn.SetReadDeadline(t)\n}", "func (rc *OneByteWriteConn) SetReadDeadline(t time.Time) error {\n\treturn rc.conn.SetReadDeadline(t)\n}", "func (rc *WriteDelayConn) SetReadDeadline(t time.Time) error {\n\treturn rc.conn.SetReadDeadline(t)\n}", "func (s *StdioConn) SetReadDeadline(t time.Time) error {\n\treturn s.stdin.SetReadDeadline(t)\n}", "func (s *StdioConn) SetReadDeadline(t time.Time) error {\n\treturn s.stdin.SetReadDeadline(t)\n}", "func (c *Conn) SetReadDeadline(t time.Time) error {\n\treturn c.sctpConn.SetReadDeadline(t)\n}", "func (c *connection) setReadDeadline() {\n\tc.conn.SetReadDeadline(time.Now().Add(c.requestTimeout))\n}", "func (c *connection) setReadDeadline() {\n\tc.conn.SetReadDeadline(time.Now().Add(c.requestTimeout))\n}", "func (w *WebrtcConn) SetReadDeadline(t time.Time) error {\n\treturn nil\n}", "func (conn *PacketPipe) SetReadDeadline(t time.Time) error {\n\tconn.readEnd.SetReadDeadline(t)\n\treturn nil\n}", "func (c *ThrottledConn) SetReadDeadline(t time.Time) error {\n\treturn c.originalConn.SetReadDeadline(t)\n}", "func (s *udtSocket) SetReadDeadline(t time.Time) error {\n\ts.setDeadline(t, &s.readDeadline, &s.readDeadlinePassed)\n\treturn nil\n}", "func (c *RawConnectionMock) SetReadDeadline(t time.Time) error {\n\targs := c.Called(t)\n\treturn args.Error(0)\n}", "func setReadDeadline(c net.Conn, duration uint) {\n\t// disable timeout used for test failure\n\ttimeoutDuration := time.Duration(time.Duration(duration) * time.Second)\n\tc.SetReadDeadline(time.Now().Add(timeoutDuration))\n}", "func (s *Stream) SetReadDeadline(t time.Time) error {\n\ts.readDeadline.Store(t)\n\tasyncNotify(s.recvNotifyCh)\n\treturn nil\n}", "func (p *WSPacketConn) SetReadDeadline(t time.Time) error {\n\tp.wsConnMap.Range(func(k, v interface{}) bool {\n\t\tconn := v.(*websocket.Conn)\n\t\tconn.SetReadDeadline(t)\n\t\treturn true\n\t})\n\tnow := time.Now()\n\tif !t.After(now) {\n\t\tp.readCtxCancel()\n\t} else {\n\t\ttime.AfterFunc(t.Sub(now), func() {\n\t\t\tp.readCtxCancel()\n\t\t})\n\t}\n\treturn nil\n}", "func (b *Bucket) SetReadDeadline(t time.Time) error {\n\tb.readDeadline = t\n\treturn nil\n}", "func SetReadDeadline(w http.ResponseWriter, deadline time.Time) error {\n\trw := w\n\tfor {\n\t\tswitch t := rw.(type) {\n\t\tcase interface{ SetReadDeadline(time.Time) error }:\n\t\t\treturn t.SetReadDeadline(deadline)\n\t\tcase interface{ Unwrap() http.ResponseWriter }:\n\t\t\trw = t.Unwrap()\n\t\tdefault:\n\t\t\treturn errDeadlineUnsupported\n\t\t}\n\t}\n}", "func (s *Conn) SetTcpReadDeadline(t time.Duration) {\n\ts.Conn.(*net.TCPConn).SetReadDeadline(time.Now().Add(time.Duration(t) * time.Second))\n}", "func (io *JSONWSIO) SetReadDeadline(time time.Time) error {\n\treturn io.WSConn.SetReadDeadline(time)\n}", "func (f *File) setReadDeadline(t time.Time) error {\n\tif err := f.checkValid(\"SetReadDeadline\"); err != nil {\n\t\treturn err\n\t}\n\treturn f.pfd.SetReadDeadline(t)\n}", "func (s *Conn) SetKcpReadDeadline(t time.Duration) {\n\ts.Conn.(*kcp.UDPSession).SetReadDeadline(time.Now().Add(time.Duration(t) * time.Second))\n}", "func (r *ChannelReader) SetDeadline(deadline time.Time) {\n\tr.deadline = deadline\n}", "func (self *LoggerReader) SetDeadline(t time.Time) error {\n\treturn self.f.SetReadDeadline(t)\n}", "func (cr *ChecksumReader) SetDeadline(t time.Time) error {\n\tcr.deadline = t\n\t// Return the error at connection time.\n\treturn nil\n}", "func (dc *Conn) SetDeadline(t time.Time) error {\n\tdc.SetReadDeadline(t)\n\tdc.SetWriteDeadline(t)\n\treturn nil\n}", "func (mr *MockConnIMockRecorder) SetReadDeadline(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"SetReadDeadline\", reflect.TypeOf((*MockConnI)(nil).SetReadDeadline), arg0)\n}", "func (c *BaseConn) SetReadTimeout(timeout time.Duration) {\n\t// acquire mutex\n\tc.receiveMutex.Lock()\n\tdefer c.receiveMutex.Unlock()\n\n\t// set new timeout\n\tc.readTimeout = timeout\n\n\t// apply new timeout immediately\n\t_ = c.resetTimeout()\n}", "func (r *Reader) SetDeadline(t time.Time) {\n\tr.mu.Lock()\n\tdefer r.mu.Unlock()\n\n\tr.deadline = t\n}", "func (rw *NopConn) SetDeadline(time.Time) error { return nil }", "func (m *MockConnI) SetReadDeadline(arg0 time.Time) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"SetReadDeadline\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (c *Conn) SetDeadline(t time.Time) error {\n\tif !c.ok() {\n\t\treturn syscall.EINVAL\n\t}\n\terr := c.SetReadDeadline(t)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn c.SetWriteDeadline(t)\n}", "func (s *Conn) SetDeadline(t time.Time) error {\n\terr1 := s.SetReadDeadline(t)\n\terr2 := s.SetWriteDeadline(t)\n\tif err1 != nil {\n\t\treturn err1\n\t}\n\treturn err2\n}", "func (c *LimitedConnection) SetDeadline(t time.Time) error {\n\terr := c.SetReadDeadline(t)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn c.SetWriteDeadline(t)\n}", "func (t *tcpchanconn) SetDeadline(deadline time.Time) error {\n\tif err := t.SetReadDeadline(deadline); err != nil {\n\t\treturn err\n\t}\n\treturn t.SetWriteDeadline(deadline)\n}", "func (s *StdioConn) SetDeadline(t time.Time) error {\n\terr1 := s.stdin.SetReadDeadline(t)\n\terr2 := s.stdout.SetWriteDeadline(t)\n\tif err1 != nil {\n\t\treturn err1\n\t}\n\treturn err2\n}", "func (s *StdioConn) SetDeadline(t time.Time) error {\n\terr1 := s.stdin.SetReadDeadline(t)\n\terr2 := s.stdout.SetWriteDeadline(t)\n\tif err1 != nil {\n\t\treturn err1\n\t}\n\treturn err2\n}", "func (c *Conn) SetDeadline(t time.Time) error {\n // return c.conn.SetDeadline(t)\n fmt.Println(\"set deadline\", t)\n return nil\n}", "func (r *timeoutReader) SetDeadline(t time.Time) {\n\tr.t = t\n}", "func (conn *Conn) SetDeadline(t time.Time) error {\n\tif conn, ok := conn.rwc.(net.Conn); ok {\n\t\treturn conn.SetDeadline(t)\n\t}\n\n\treturn errSetDeadline\n}", "func (bc BufConn) SetDeadline(t time.Time) error { return nil }", "func FileSetReadDeadline(f *os.File, t time.Time) error", "func (s *Stream) SetDeadline(t time.Time) error {\n\treturn s.conn.conn.SetDeadline(t)\n}", "func (c *Connect) setRTimeout() {\n\tif c.readTimeout != 0 {\n\t\tc.nc.SetReadDeadline(time.Now().Add(c.readTimeout))\n\t}\n}", "func (rc *OneByteReadConn) SetWriteDeadline(t time.Time) error {\n\treturn rc.conn.SetWriteDeadline(t)\n}", "func (v *HVsockConn) SetDeadline(deadline time.Time) error {\n\tif err := v.SetReadDeadline(deadline); err != nil {\n\t\treturn err\n\t}\n\treturn v.SetWriteDeadline(deadline)\n}", "func (c *Conn) SetDeadline(t time.Time) error {\n\treturn fmt.Errorf(\"No supported\")\n}", "func (dc DeadlineConn) Read(data []byte) (int, error) {\n\tcount := 0\n\terr := dc.Conn.SetReadDeadline(time.Now().Add(dc.timeout))\n\tif err != nil {\n\t\treturn count, err\n\t}\n\t// don't bother with resetting the deadline since it will be set\n\t// again next time we call Read()\n\treturn dc.Conn.Read(data)\n}", "func (c *Conn) SetDeadline(t time.Time) error {\n\treturn c.conn.SetDeadline(t)\n}", "func (c *Conn) SetDeadline(t time.Time) error {\n\treturn c.conn.SetDeadline(t)\n}", "func (c *Conn) SetDeadline(t time.Time) error { return c.pc.SetDeadline(t) }", "func (wsConn *WSConn) SetDeadline(t time.Time) error {\n\terr := wsConn.conn.SetReadDeadline(t)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn wsConn.conn.SetWriteDeadline(t)\n}", "func GetReadDeadline() time.Time {\n\treturn time.Now().Add(UDPReadTimeout)\n}", "func (c *Conn) SetReadTimeout(timeout time.Duration) {\n\tc.readTimeout = timeout\n}", "func (p *Conn) SetDeadline(t time.Time) error {\n\treturn p.conn.SetDeadline(t)\n}", "func (c *cConn) SetDeadline(t time.Time) error {\n\treturn syscall.EINVAL\n}", "func (rc *ReadDelayConn) SetWriteDeadline(t time.Time) error {\n\treturn rc.conn.SetWriteDeadline(t)\n}", "func (c *CryptoStreamConn) SetDeadline(time.Time) error {\n\treturn nil\n}", "func (c *TestConnection) SetDeadline(t time.Time) error {\n return errors.New(\"Not implemented\")\n}", "func (c *ChannelConn) SetDeadline(_ time.Time) error {\n\treturn nil\n}", "func (c *Conn) SetWriteDeadline(t time.Time) error {\n // return c.conn.SetWriteDeadline(t)\n fmt.Println(\"set write deadline\", t)\n return nil\n}", "func (s *settings) SetReadTimeout(timeout time.Duration) {\n\ts.rTimeout = timeout\n}", "func (b *bpfHandle) SetReadTimeout(d time.Duration) error {\n\tvalue := make([]byte, 16)\n\tbinary.LittleEndian.PutUint64(value, uint64(d/time.Second))\n\tbinary.LittleEndian.PutUint64(value[8:], uint64((d%time.Second)/time.Microsecond))\n\tif ok, err := b.ioctlWithData(ioctlBIOCSRTIMEOUT, value); ok {\n\t\treturn nil\n\t} else {\n\t\treturn err\n\t}\n}", "func (s *Server) SetReadTimeout(t time.Duration) {\n\ts.config.ReadTimeout = t\n}", "func (s *Stream) SetDeadline(t time.Time) error {\n\tif err := s.SetReadDeadline(t); err != nil {\n\t\treturn err\n\t}\n\tif err := s.SetWriteDeadline(t); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (e errorConnection) SetDeadline(t time.Time) error {\n\treturn e.err\n}" ]
[ "0.88569814", "0.8804388", "0.87452424", "0.87290215", "0.86889523", "0.86709", "0.8662243", "0.86535764", "0.8639709", "0.8635167", "0.8631107", "0.8623234", "0.8623234", "0.8623234", "0.8616967", "0.8611767", "0.86115295", "0.8609532", "0.8597688", "0.85944986", "0.8548238", "0.85351425", "0.8488744", "0.8483581", "0.84765625", "0.84587896", "0.84322125", "0.83699036", "0.83616596", "0.83597845", "0.8356114", "0.8337672", "0.8304588", "0.82934034", "0.8278651", "0.8267697", "0.82454616", "0.8242766", "0.8242766", "0.8240647", "0.82287925", "0.82287925", "0.81734735", "0.8135468", "0.80773515", "0.8076419", "0.80029523", "0.7970609", "0.79588526", "0.7887427", "0.7736011", "0.76266277", "0.7530789", "0.751898", "0.7350995", "0.7151546", "0.69099385", "0.6849247", "0.6813768", "0.6761952", "0.6715079", "0.6679857", "0.6659907", "0.6605803", "0.6564773", "0.655107", "0.64864767", "0.6456961", "0.6433511", "0.6418179", "0.6418179", "0.6416584", "0.6407184", "0.6391641", "0.6368063", "0.6364919", "0.63572913", "0.63512146", "0.63483566", "0.6342547", "0.630184", "0.6257782", "0.6242374", "0.6242374", "0.62192297", "0.6215776", "0.61931497", "0.6173929", "0.6165554", "0.61602974", "0.6157778", "0.61391735", "0.6103417", "0.6093679", "0.6083762", "0.60518926", "0.5964815", "0.59642595", "0.5961546", "0.59574544" ]
0.849646
22
SetWriteDeadline implements the Conn SetWriteDeadline method.
func (c *Conn) SetWriteDeadline(t time.Time) error { if !c.ok() { return syscall.EINVAL } c.deadlineMutex.Lock() defer c.deadlineMutex.Unlock() c.wdeadline = t return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Conn) SetWriteDeadline(t time.Time) error { return c.pc.SetWriteDeadline(t) }", "func (c *Conn) SetWriteDeadline(t time.Time) error {\n\treturn fmt.Errorf(\"No supported\")\n}", "func (c *cConn) SetWriteDeadline(t time.Time) error {\n\treturn syscall.EINVAL\n}", "func (c *Conn) SetWriteDeadline(t time.Time) error {\n // return c.conn.SetWriteDeadline(t)\n fmt.Println(\"set write deadline\", t)\n return nil\n}", "func (p *packetConn) SetWriteDeadline(t time.Time) error {\n\treturn ErrNotImplemented\n}", "func (rw *NopConn) SetWriteDeadline(time.Time) error { return nil }", "func (conn *Conn) SetWriteDeadline(t time.Time) error {\n\tif conn, ok := conn.rwc.(net.Conn); ok {\n\t\treturn conn.SetWriteDeadline(t)\n\t}\n\n\treturn errSetDeadline\n}", "func (c Conn) SetWriteDeadline(t time.Time) error {\n\treturn c.conn.SetWriteDeadline(t)\n}", "func (c *TestConnection) SetWriteDeadline(t time.Time) error {\n return errors.New(\"Not implemented\")\n}", "func (rc *PerWriteDelayConn) SetWriteDeadline(t time.Time) error {\n\treturn rc.conn.SetWriteDeadline(t)\n}", "func (my *clientConn) SetWriteDeadline(t time.Time) error {\n\treturn my.conn.SetWriteDeadline(t)\n}", "func (dc *Conn) SetWriteDeadline(t time.Time) error {\n\tdc.writeDeadline = t\n\tdc.getConn().SetWriteDeadline(t)\n\treturn nil\n}", "func (rc *OneByteWriteConn) SetWriteDeadline(t time.Time) error {\n\treturn rc.conn.SetWriteDeadline(t)\n}", "func (rc *WriteDelayConn) SetWriteDeadline(t time.Time) error {\n\treturn rc.conn.SetWriteDeadline(t)\n}", "func (v *vsockConn) SetWriteDeadline(t time.Time) error {\n\treturn nil // FIXME\n}", "func (rc *DelayConn) SetWriteDeadline(t time.Time) error {\n\treturn rc.conn.SetWriteDeadline(t)\n}", "func (p *Conn) SetWriteDeadline(t time.Time) error {\n\treturn p.conn.SetWriteDeadline(t)\n}", "func (c *Conn) SetWriteDeadline(t time.Time) error {\n\tc.writeDeadline = t\n\treturn nil\n}", "func (c *Conn) SetWriteDeadline(t time.Time) error {\n\treturn c.conn.SetWriteDeadline(t)\n}", "func (c *Conn) SetWriteDeadline(t time.Time) error {\n\treturn c.conn.SetWriteDeadline(t)\n}", "func (c *wsConn) SetWriteDeadline(t time.Time) error {\n\treturn c.conn.SetWriteDeadline(t)\n}", "func (c *ChannelConn) SetWriteDeadline(_ time.Time) error {\n\treturn nil\n}", "func (c *LimitedConnection) SetWriteDeadline(t time.Time) error {\n\tc.writeDeadline = t\n\treturn c.inner.SetWriteDeadline(t)\n}", "func (c *SerialConn) SetWriteDeadline(t time.Time) error {\n\treturn nil\n}", "func (v *HVsockConn) SetWriteDeadline(deadline time.Time) error {\n\treturn v.writeDeadline.set(deadline)\n}", "func (wsConn *WSConn) SetWriteDeadline(t time.Time) error {\n\treturn wsConn.conn.SetWriteDeadline(t)\n}", "func (bc BufConn) SetWriteDeadline(t time.Time) error { return nil }", "func (rc *OneByteReadConn) SetWriteDeadline(t time.Time) error {\n\treturn rc.conn.SetWriteDeadline(t)\n}", "func (r *RPCIngressGateway) SetWriteDeadline(req *DeadlineReq, _ *struct{}) error {\n\tconn, err := r.getConn(req.ConnID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn conn.SetWriteDeadline(req.Deadline)\n}", "func (rc *ReadDelayConn) SetWriteDeadline(t time.Time) error {\n\treturn rc.conn.SetWriteDeadline(t)\n}", "func ConnSetWriteDeadline(c *tls.Conn, t time.Time) error", "func (t *tcpchanconn) SetWriteDeadline(deadline time.Time) error {\n\treturn errors.New(\"ssh: tcpchan: deadline not supported\")\n}", "func (s *Conn) SetWriteDeadline(t time.Time) error {\n\td, ok := s.writer.(interface {\n\t\tSetWriteDeadline(time.Time) error\n\t})\n\tif !ok {\n\t\treturn &net.OpError{Op: \"set\", Net: \"stdio\", Addr: s.LocalAddr(),\n\t\t\tErr: errors.New(\"write deadline not supported\")}\n\t}\n\treturn d.SetWriteDeadline(t)\n}", "func (w *WebrtcConn) SetWriteDeadline(t time.Time) error {\n\treturn nil\n}", "func (ctx *RecordContext) SetWriteDeadline(t time.Time) error {\n\treturn nil\n}", "func (e errorConnection) SetWriteDeadline(t time.Time) error {\n\treturn e.err\n}", "func (s *udtSocket) SetWriteDeadline(t time.Time) error {\n\ts.setDeadline(t, &s.writeDeadline, &s.writeDeadlinePassed)\n\treturn nil\n}", "func (c *CryptoStreamConn) SetWriteDeadline(time.Time) error {\n\treturn nil\n}", "func (c *Conn) SetWriteDeadline(t time.Time) error {\n\treturn c.sctpConn.SetWriteDeadline(t)\n}", "func (c *Conn) SetWriteDeadline(t time.Time) error {\n\tc.stanzaWriter.writeDeadline = t\n\treturn nil\n}", "func (c *RawConnectionMock) SetWriteDeadline(t time.Time) error {\n\targs := c.Called(t)\n\treturn args.Error(0)\n}", "func (conn *PacketPipe) SetWriteDeadline(t time.Time) error {\n\tconn.writeEnd.SetWriteDeadline(t)\n\treturn nil\n}", "func (c *ThrottledConn) SetWriteDeadline(t time.Time) error {\n\treturn c.originalConn.SetWriteDeadline(t)\n}", "func (s *StdioConn) SetWriteDeadline(t time.Time) error {\n\treturn s.stdout.SetWriteDeadline(t)\n}", "func (s *StdioConn) SetWriteDeadline(t time.Time) error {\n\treturn s.stdout.SetWriteDeadline(t)\n}", "func (p *WSPacketConn) SetWriteDeadline(t time.Time) error {\n\tp.wsConnMap.Range(func(k, v interface{}) bool {\n\t\tconn := v.(*websocket.Conn)\n\t\tconn.SetWriteDeadline(t)\n\t\treturn true\n\t})\n\tnow := time.Now()\n\tif !t.After(now) {\n\t\tp.writeCtxCancel()\n\t} else {\n\t\ttime.AfterFunc(t.Sub(now), func() {\n\t\t\tp.writeCtxCancel()\n\t\t})\n\t}\n\treturn nil\n}", "func (s *Stream) SetWriteDeadline(t time.Time) error {\n\ts.writeDeadline.Store(t)\n\tasyncNotify(s.sendNotifyCh)\n\treturn nil\n}", "func (io *JSONWSIO) SetWriteDeadline(time time.Time) error {\n\treturn io.WSConn.SetWriteDeadline(time)\n}", "func (s *WritableStream) SetWriteDeadline(t time.Time) error {\n\treturn s.s.SetWriteDeadline(t)\n}", "func (b *Bucket) SetWriteDeadline(t time.Time) error {\n\tb.writeDeadline = t\n\treturn nil\n}", "func (f *File) setWriteDeadline(t time.Time) error {\n\tif err := f.checkValid(\"SetWriteDeadline\"); err != nil {\n\t\treturn err\n\t}\n\treturn f.pfd.SetWriteDeadline(t)\n}", "func (rw *NopConn) SetDeadline(time.Time) error { return nil }", "func (dc *Conn) SetDeadline(t time.Time) error {\n\tdc.SetReadDeadline(t)\n\tdc.SetWriteDeadline(t)\n\treturn nil\n}", "func (s *Conn) SetDeadline(t time.Time) error {\n\terr1 := s.SetReadDeadline(t)\n\terr2 := s.SetWriteDeadline(t)\n\tif err1 != nil {\n\t\treturn err1\n\t}\n\treturn err2\n}", "func (c *Conn) SetDeadline(t time.Time) error {\n\tif !c.ok() {\n\t\treturn syscall.EINVAL\n\t}\n\terr := c.SetReadDeadline(t)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn c.SetWriteDeadline(t)\n}", "func (wsConn *WSConn) SetDeadline(t time.Time) error {\n\terr := wsConn.conn.SetReadDeadline(t)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn wsConn.conn.SetWriteDeadline(t)\n}", "func (bw *BlockWriter) SetDeadline(t time.Time) error {\n\tbw.deadline = t\n\tif bw.conn != nil {\n\t\treturn bw.conn.SetDeadline(t)\n\t}\n\n\t// Return the error at connection time.\n\treturn nil\n}", "func (c *Conn) SetDeadline(t time.Time) error {\n\treturn fmt.Errorf(\"No supported\")\n}", "func (c *cConn) SetDeadline(t time.Time) error {\n\treturn syscall.EINVAL\n}", "func (conn *Conn) SetDeadline(t time.Time) error {\n\tif conn, ok := conn.rwc.(net.Conn); ok {\n\t\treturn conn.SetDeadline(t)\n\t}\n\n\treturn errSetDeadline\n}", "func (p *packetConn) SetDeadline(t time.Time) error {\n\treturn ErrNotImplemented\n}", "func (c *Conn) SetDeadline(t time.Time) error { return c.pc.SetDeadline(t) }", "func (w *ChannelWriter) SetDeadline(t time.Time) {\n\tw.deadline = t\n}", "func (c *LimitedConnection) SetDeadline(t time.Time) error {\n\terr := c.SetReadDeadline(t)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn c.SetWriteDeadline(t)\n}", "func (t *tcpchanconn) SetDeadline(deadline time.Time) error {\n\tif err := t.SetReadDeadline(deadline); err != nil {\n\t\treturn err\n\t}\n\treturn t.SetWriteDeadline(deadline)\n}", "func (p *Conn) SetDeadline(t time.Time) error {\n\treturn p.conn.SetDeadline(t)\n}", "func (v *HVsockConn) SetDeadline(deadline time.Time) error {\n\tif err := v.SetReadDeadline(deadline); err != nil {\n\t\treturn err\n\t}\n\treturn v.SetWriteDeadline(deadline)\n}", "func (c *Conn) SetDeadline(t time.Time) error {\n // return c.conn.SetDeadline(t)\n fmt.Println(\"set deadline\", t)\n return nil\n}", "func (bc BufConn) SetDeadline(t time.Time) error { return nil }", "func (c *Conn) SetDeadline(t time.Time) error {\n\treturn c.conn.SetDeadline(t)\n}", "func (c *Conn) SetDeadline(t time.Time) error {\n\treturn c.conn.SetDeadline(t)\n}", "func (f *FileWriter) SetDeadline(t time.Time) error {\n\tf.deadline = t\n\tif f.blockWriter != nil {\n\t\treturn f.blockWriter.SetDeadline(t)\n\t}\n\n\t// Return the error at connection time.\n\treturn nil\n}", "func (mr *MockConnIMockRecorder) SetWriteDeadline(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"SetWriteDeadline\", reflect.TypeOf((*MockConnI)(nil).SetWriteDeadline), arg0)\n}", "func (c *TestConnection) SetDeadline(t time.Time) error {\n return errors.New(\"Not implemented\")\n}", "func ConnSetDeadline(c *tls.Conn, t time.Time) error", "func FileSetWriteDeadline(f *os.File, t time.Time) error", "func (v *vsockConn) SetDeadline(t time.Time) error {\n\treturn nil // FIXME\n}", "func (s *StdioConn) SetDeadline(t time.Time) error {\n\terr1 := s.stdin.SetReadDeadline(t)\n\terr2 := s.stdout.SetWriteDeadline(t)\n\tif err1 != nil {\n\t\treturn err1\n\t}\n\treturn err2\n}", "func (s *StdioConn) SetDeadline(t time.Time) error {\n\terr1 := s.stdin.SetReadDeadline(t)\n\terr2 := s.stdout.SetWriteDeadline(t)\n\tif err1 != nil {\n\t\treturn err1\n\t}\n\treturn err2\n}", "func (c *ChannelConn) SetDeadline(_ time.Time) error {\n\treturn nil\n}", "func (self *LoggerWriter) SetDeadline(t time.Time) error {\n\treturn nil\n}", "func (w *WebrtcConn) SetDeadline(t time.Time) error {\n\treturn nil\n}", "func (conn *PacketPipe) SetDeadline(t time.Time) error {\n\t_ = conn.SetReadDeadline(t)\n\t_ = conn.SetWriteDeadline(t)\n\treturn nil\n}", "func (m *MockConnI) SetWriteDeadline(arg0 time.Time) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"SetWriteDeadline\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (c *ThrottledConn) SetDeadline(t time.Time) error {\n\treturn c.originalConn.SetDeadline(t)\n}", "func (s *Stream) SetDeadline(t time.Time) error {\n\treturn s.conn.conn.SetDeadline(t)\n}", "func (c *CryptoStreamConn) SetDeadline(time.Time) error {\n\treturn nil\n}", "func (rc *PerWriteDelayConn) SetReadDeadline(t time.Time) error {\n\treturn rc.conn.SetReadDeadline(t)\n}", "func (p *packetConn) SetReadDeadline(t time.Time) error {\n\treturn ErrNotImplemented\n}", "func (rc *WriteDelayConn) SetReadDeadline(t time.Time) error {\n\treturn rc.conn.SetReadDeadline(t)\n}", "func (rc *OneByteWriteConn) SetReadDeadline(t time.Time) error {\n\treturn rc.conn.SetReadDeadline(t)\n}", "func (r *RPCIngressGateway) SetDeadline(req *DeadlineReq, _ *struct{}) error {\n\tconn, err := r.getConn(req.ConnID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn conn.SetDeadline(req.Deadline)\n}", "func (c *Conn) SetReadDeadline(t time.Time) error {\n // return c.conn.SetReadDeadline(t)\n fmt.Println(\"set read deadline\", t)\n return nil\n}", "func (c *cConn) SetReadDeadline(t time.Time) error {\n\treturn syscall.EINVAL\n}", "func (e errorConnection) SetDeadline(t time.Time) error {\n\treturn e.err\n}", "func (w *ConnWrapper) SetReadDeadline(t time.Time) error {\n\t// TODO: put int Deadline\n\tvar err error\n\tswitch w.conn.(type) {\n\tcase net.Conn:\n\t\tconn := w.conn.(net.Conn)\n\t\terr = conn.SetReadDeadline(t)\n\tdefault:\n\t\tklog.Warningf(\"unsupported conn type: %T\", w.conn)\n\t}\n\treturn err\n}", "func (c *Conn) SetReadDeadline(t time.Time) error { return c.pc.SetReadDeadline(t) }", "func (bc BufConn) SetReadDeadline(t time.Time) error { return nil }", "func (p *Port) SetDeadline(t time.Time) error {\n\t// Funky Town\n\terr := p.f.SetDeadline(t)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (l *TCPListener) SetDeadline(t time.Time) error {\n\tif l == nil || l.fd == nil {\n\t\treturn syscall.EINVAL\n\t}\n\treturn l.fd.setDeadline(t)\n}" ]
[ "0.8970274", "0.8926833", "0.89109606", "0.8867294", "0.88668895", "0.88653904", "0.8826544", "0.8816165", "0.88076603", "0.87781227", "0.87760365", "0.87662244", "0.87433636", "0.87411124", "0.87369555", "0.87160337", "0.8684204", "0.8683646", "0.8677109", "0.8677109", "0.8665412", "0.8662656", "0.8646331", "0.8639305", "0.8610856", "0.8595618", "0.85910916", "0.8566563", "0.85565305", "0.85556066", "0.8523824", "0.85222393", "0.85170907", "0.8488233", "0.8459245", "0.84400946", "0.84364253", "0.84291524", "0.83822024", "0.8349083", "0.83277225", "0.8326872", "0.8303244", "0.82609004", "0.82609004", "0.8224025", "0.8129201", "0.80938137", "0.80795854", "0.8048121", "0.76361424", "0.75751245", "0.7508502", "0.7482937", "0.74702996", "0.7432335", "0.74051833", "0.73838717", "0.73645604", "0.73605317", "0.7319527", "0.7299314", "0.7277619", "0.7257971", "0.7209684", "0.7199226", "0.71896505", "0.71826243", "0.7173043", "0.71607244", "0.71607244", "0.7065119", "0.70493937", "0.70302427", "0.70233744", "0.6988657", "0.69657594", "0.69330853", "0.69330853", "0.692468", "0.6914151", "0.6912209", "0.68947166", "0.6894035", "0.6795482", "0.67273146", "0.66825163", "0.66787595", "0.65962535", "0.65821236", "0.6566506", "0.6520721", "0.6506037", "0.64983433", "0.64947003", "0.6466305", "0.6451636", "0.6440724", "0.64172155", "0.63901263" ]
0.8790527
9
namespace returns the namespace of tiller
func namespace() string { if ns := os.Getenv("TILLER_NAMESPACE"); ns != "" { return ns } // Fall back to the namespace associated with the service account token, if available if data, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace"); err == nil { if ns := strings.TrimSpace(string(data)); len(ns) > 0 { return ns } } return environment.DefaultTillerNamespace }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o ApplicationSpecRolloutplanCanarymetricTemplaterefOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationSpecRolloutplanCanarymetricTemplateref) *string { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func getNamespace() string {\n\tns := os.Getenv(\"POD_NAMESPACE\")\n\tif ns == \"\" {\n\t\t// Useful especially for ci tests.\n\t\tns = metav1.NamespaceSystem\n\t}\n\treturn ns\n}", "func getNamespace() string {\n\tns := os.Getenv(\"POD_NAMESPACE\")\n\tif ns == \"\" {\n\t\t// Useful especially for ci tests.\n\t\tns = metav1.NamespaceSystem\n\t}\n\treturn ns\n}", "func (a *Application) Namespace() string {\n\treturn fmt.Sprintf(\"app_%d_%d\", a.OrgID, a.ID)\n}", "func getNamespace() (string, error) {\n\n\tns, found := os.LookupEnv(namespaceEnvVar)\n\tif !found {\n\t\terr := fmt.Errorf(\"%s must be set\", namespaceEnvVar)\n\t\treturn \"\", err\n\t}\n\treturn ns, nil\n}", "func (o MfaPingidOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *MfaPingid) pulumi.StringPtrOutput { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (o ApplicationSpecRolloutplanCanarymetricTemplaterefPtrOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ApplicationSpecRolloutplanCanarymetricTemplateref) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Namespace\n\t}).(pulumi.StringPtrOutput)\n}", "func (o ApplicationSpecRolloutplanRolloutbatchesCanarymetricTemplaterefOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationSpecRolloutplanRolloutbatchesCanarymetricTemplateref) *string { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (ls *LocationStore) Namespace() string {\n\treturn fmt.Sprintf(\"locations.%s\", ls.name)\n}", "func GetNamespace() string {\n\tveryFlagInput()\n\treturn ns\n}", "func (n *node) Namespace() string {\n\treturn n.namespace\n}", "func TenantNamespace(tenant string) string {\n\treturn fmt.Sprintf(\"cyclone--%s\", tenant)\n}", "func getNamespaceFromProp() string {\n\tnamespace := os.Getenv(\"FUNCTION_NAMESPACE\")\n\treturn namespace\n}", "func (f *Frugal) Namespace(scope string) *Namespace {\n\tnamespace := f.namespaceIndex[scope]\n\tif namespace != nil {\n\t\treturn namespace\n\t}\n\treturn f.namespaceIndex[\"*\"]\n}", "func (o ApplicationSpecRolloutplanRolloutbatchesCanarymetricTemplaterefPtrOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ApplicationSpecRolloutplanRolloutbatchesCanarymetricTemplateref) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Namespace\n\t}).(pulumi.StringPtrOutput)\n}", "func Namespace() string {\n\treturn gfile.GetContents(kubernetesNamespaceFilePath)\n}", "func (this *KeyspaceTerm) Namespace() string {\n\tif this.path != nil {\n\t\treturn this.path.Namespace()\n\t}\n\treturn \"\"\n}", "func Namespace(ctx context.Context) string {\n\tv := ctx.Value(ContextKey(\"namespace\"))\n\tif v == nil {\n\t\treturn \"\"\n\t} else {\n\t\treturn v.(string)\n\t}\n}", "func (res moduleBase) Namespace() *types.Namespace {\n\treturn res.namespace\n}", "func namespace(t *testing.T) (*corev1.Namespace, func()) {\n\tnamespace, ok := namespaces[t.Name()]\n\tif !ok {\n\t\tfmt.Fprintf(os.Stderr, \"Error: test case %s did not have a namespace set up\\n\", t.Name())\n\t\tos.Exit(ExitCodeCantCreateCluster)\n\t}\n\n\tcleanup := func() {\n\t\tassert.NoError(t, clusters.CleanupGeneratedResources(ctx, env.Cluster(), t.Name()))\n\t}\n\n\treturn namespace, cleanup\n}", "func (f *EnvFlags) Namespace() string {\n\treturn f.namespace\n}", "func (o AppV2Output) Namespace() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *AppV2) pulumi.StringOutput { return v.Namespace }).(pulumi.StringOutput)\n}", "func Namespace() []string {\n\treturn []string{name}\n}", "func (o ForwardingRuleServiceDirectoryRegistrationOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ForwardingRuleServiceDirectoryRegistration) *string { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (o ApplicationStatusWorkflowContextbackendOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationStatusWorkflowContextbackend) *string { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (m *MockDocumentHandler) Namespace() string {\n\treturn m.namespace\n}", "func podNamespace(pod corev1.Pod) string {\n\t// An empty namespace is the default namespace.\n\tnamespace := pod.Namespace\n\tif namespace == \"\" {\n\t\tnamespace = \"default\"\n\t}\n\n\treturn namespace\n}", "func (b *KubervisorServiceItem) Namespace() string {\n\treturn b.namespace\n}", "func (c *ZtunnelComponent) Namespace() string {\n\treturn c.CommonComponentFields.Namespace\n}", "func (c *Current) Namespace() string {\n\tswitch c.selectedRadio {\n\tcase FocusOnInvolved, FocusOnCurrentNamespace:\n\t\treturn curr.namespace\n\tcase FocusOnAllNamespace:\n\t\treturn \"\"\n\t}\n\treturn \"\"\n}", "func (o ForwardingRuleServiceDirectoryRegistrationResponseOutput) Namespace() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ForwardingRuleServiceDirectoryRegistrationResponse) string { return v.Namespace }).(pulumi.StringOutput)\n}", "func (o SecretBackendV2Output) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *SecretBackendV2) pulumi.StringPtrOutput { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (a *ALBIngress) Namespace() string {\n\treturn a.namespace\n}", "func (c *configuration) Namespace(clientSet ClientSet) *Namespace {\n\tif clientSet != nil {\n\t\treturn NewNamespace(clientSet)\n\t}\n\treturn nil\n\n}", "func Namespace(iops *v1alpha1.IstioOperatorSpec) string {\n\tif iops.Namespace != \"\" {\n\t\treturn iops.Namespace\n\t}\n\tif iops.Values == nil {\n\t\treturn \"\"\n\t}\n\tif iops.Values[globalKey] == nil {\n\t\treturn \"\"\n\t}\n\tv := iops.Values[globalKey].(map[string]interface{})\n\tn := v[istioNamespaceKey]\n\tif n == nil {\n\t\treturn \"\"\n\t}\n\treturn n.(string)\n}", "func (h *Handler) getNamespace(ns *corev1.Namespace) (*corev1.Namespace, error) {\n\treturn h.clientset.CoreV1().Namespaces().Get(h.ctx, ns.Name, h.Options.GetOptions)\n}", "func (ds *DaemonSet) Namespace() string {\n\treturn ds.daemonSet.Namespace\n}", "func (c *knDynamicClient) Namespace() string {\n\treturn c.namespace\n}", "func (o MrScalarTerminationPolicyStatementOutput) Namespace() pulumi.StringOutput {\n\treturn o.ApplyT(func(v MrScalarTerminationPolicyStatement) string { return v.Namespace }).(pulumi.StringOutput)\n}", "func (o MrScalarTaskScalingDownPolicyOutput) Namespace() pulumi.StringOutput {\n\treturn o.ApplyT(func(v MrScalarTaskScalingDownPolicy) string { return v.Namespace }).(pulumi.StringOutput)\n}", "func (o ApplicationSpecDestinationOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationSpecDestination) *string { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (m *Import) namespace(req *sdk.GetReq) Namespace {\n\tif global, ok := m.Root.(Namespace); ok {\n\t\treturn global\n\t}\n\n\t// Look for it in the cache of executions\n\tm.namespaceLock.RLock()\n\tns, ok := m.namespaceMap[req.ExecId]\n\tm.namespaceLock.RUnlock()\n\tif ok {\n\t\treturn ns\n\t}\n\n\tnsFunc, ok := m.Root.(NamespaceCreator)\n\tif !ok {\n\t\tpanic(\"Root must be NamespaceCreator if not Namespace\")\n\t}\n\n\t// Not found, we have to create it\n\tm.namespaceLock.Lock()\n\tdefer m.namespaceLock.Unlock()\n\n\t// If it was created while we didn't have the lock, return it\n\tns, ok = m.namespaceMap[req.ExecId]\n\tif ok {\n\t\treturn ns\n\t}\n\n\t// Init if we have to\n\tif m.namespaceMap == nil {\n\t\tm.namespaceMap = make(map[uint64]Namespace)\n\t}\n\n\t// Create it\n\tns = nsFunc.Namespace()\n\tm.namespaceMap[req.ExecId] = ns\n\n\t// Create the expiration function\n\ttime.AfterFunc(time.Until(req.ExecDeadline), func() {\n\t\tm.invalidateNamespace(req.ExecId)\n\t})\n\n\treturn ns\n}", "func (o ArgoCDSpecImportOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ArgoCDSpecImport) *string { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (o ApplicationStatusWorkflowContextbackendPtrOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ApplicationStatusWorkflowContextbackend) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Namespace\n\t}).(pulumi.StringPtrOutput)\n}", "func (p protobuf) Namespace() string {\n\tif n, ok := protoNameToNamespace[p.TypeName]; ok {\n\t\treturn n\n\t}\n\treturn \"?\"\n}", "func (r *ReplicaSet) Namespace() string {\n\treturn r.raw.Namespace\n}", "func getNamespace(deploymentID string, objectMeta metav1.ObjectMeta) (string, bool) {\n\tvar isProvided bool\n\tvar namespace string\n\tvar providedNamespace string\n\tif &objectMeta != nil {\n\t\tprovidedNamespace = objectMeta.Namespace\n\t}\n\n\tif providedNamespace != \"\" {\n\t\tnamespace = providedNamespace\n\t\tisProvided = true\n\t} else {\n\t\tnamespace, _ = defaultNamespace(deploymentID)\n\t}\n\n\treturn namespace, isProvided\n}", "func (pi *proxyItem) Namespace() string {\n\treturn pi.ns\n}", "func (o AppProjectSpecDestinationsOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v AppProjectSpecDestinations) *string { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (c *Client) Namespace() string {\n\treturn \"testNamespace\"\n}", "func (m *MachineScope) Namespace() string {\n\treturn m.AzureMachine.Namespace\n}", "func Namespace(featureName FeatureName, componentName ComponentName, controlPlaneSpec *v1alpha2.IstioControlPlaneSpec) (string, error) {\n\tdefaultNamespaceI, found, err := tpath.GetFromStructPath(controlPlaneSpec, \"DefaultNamespace\")\n\tif !found {\n\t\treturn \"\", fmt.Errorf(\"can't find any setting for defaultNamespace for feature=%s, component=%s\", featureName, componentName)\n\t}\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error in Namepsace for feature=%s, component=%s: %s\", featureName, componentName, err)\n\n\t}\n\tdefaultNamespace, ok := defaultNamespaceI.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"defaultNamespace has bad type %T, expect string\", defaultNamespaceI)\n\t}\n\tif defaultNamespace == \"\" {\n\t\treturn \"\", fmt.Errorf(\"defaultNamespace must be set\")\n\t}\n\n\tfeatureNamespace := defaultNamespace\n\tfeatureNodeI, found, err := tpath.GetFromStructPath(controlPlaneSpec, string(featureName)+\".Components.Namespace\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error in Namepsace GetFromStructPath featureNamespace for feature=%s, component=%s: %s\", featureName, componentName, err)\n\t}\n\tif found && featureNodeI != nil {\n\t\tfeatureNamespace, ok = featureNodeI.(string)\n\t\tif !ok {\n\t\t\treturn \"\", fmt.Errorf(\"feature %s namespace has bad type %T, expect string\", featureName, featureNodeI)\n\t\t}\n\t\tif featureNamespace == \"\" {\n\t\t\tfeatureNamespace = defaultNamespace\n\t\t}\n\t}\n\n\tcomponentNodeI, found, err := tpath.GetFromStructPath(controlPlaneSpec, string(featureName)+\".Components.\"+string(componentName)+\".Namespace\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error in Namepsace GetFromStructPath componentNamespace for feature=%s, component=%s: %s\", featureName, componentName, err)\n\t}\n\tif !found {\n\t\treturn featureNamespace, nil\n\t}\n\tif componentNodeI == nil {\n\t\treturn featureNamespace, nil\n\t}\n\tcomponentNamespace, ok := componentNodeI.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"component %s enabled has bad type %T, expect string\", componentName, componentNodeI)\n\t}\n\tif componentNamespace == \"\" {\n\t\treturn featureNamespace, nil\n\t}\n\treturn componentNamespace, nil\n}", "func (o FluxConfigurationOutput) Namespace() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *FluxConfiguration) pulumi.StringOutput { return v.Namespace }).(pulumi.StringOutput)\n}", "func (c *Controller) Namespace() string {\n\treturn c.namespace.Name\n}", "func (o ApplicationStatusServicesScopesOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationStatusServicesScopes) *string { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (k *Key) Namespace() string { return k.kc.Namespace }", "func (rs *ReplicaSet) Namespace() string {\n\treturn rs.replicaSet.Namespace\n}", "func (o MachineInstanceSpecResourceRefPtrOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *MachineInstanceSpecResourceRef) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Namespace\n\t}).(pulumi.StringPtrOutput)\n}", "func (o ApplicationStatusSyncComparedToDestinationOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationStatusSyncComparedToDestination) *string { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (o MrScalarCoreScalingDownPolicyOutput) Namespace() pulumi.StringOutput {\n\treturn o.ApplyT(func(v MrScalarCoreScalingDownPolicy) string { return v.Namespace }).(pulumi.StringOutput)\n}", "func (o ParamRefPatchOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ParamRefPatch) *string { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (opts UnsetEnvOptions) Namespace() string {\n\treturn opts.toConfig().Namespace\n}", "func (c *Client) Namespace() string {\n\tc.modifyLock.Lock()\n\tdefer c.modifyLock.Unlock()\n\tif c.headers == nil {\n\t\treturn \"\"\n\t}\n\treturn c.headers.Get(NamespaceHeaderName)\n}", "func (o ElastigroupScalingDownPolicyOutput) Namespace() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ElastigroupScalingDownPolicy) string { return v.Namespace }).(pulumi.StringOutput)\n}", "func Namespace(file *descriptor.FileDescriptorProto) string {\n\toptions := file.GetOptions()\n\n\t// When there is a namespace option defined we use it\n\tif options.PhpNamespace != nil {\n\t\treturn options.GetPhpNamespace()\n\t}\n\n\treturn Name(file.GetPackage())\n}", "func (o DataSetRowLevelPermissionDataSetOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v DataSetRowLevelPermissionDataSet) *string { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (o ArgoCDSpecImportPtrOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ArgoCDSpecImport) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Namespace\n\t}).(pulumi.StringPtrOutput)\n}", "func (meta *Metadata) GetNamespace() string {\n\treturn object.SystemNS\n}", "func (p *Expression) Namespace() string {\n\treturn p.namespace\n}", "func (c *Cluster) Namespace() string {\n\treturn c.definition.Namespace\n}", "func (o ElastigroupScalingTargetPolicyOutput) Namespace() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ElastigroupScalingTargetPolicy) string { return v.Namespace }).(pulumi.StringOutput)\n}", "func Namespace() string {\n\tif ns := os.Getenv(NamespaceEnvKey); ns != \"\" {\n\t\treturn ns\n\t}\n\n\tpanic(fmt.Sprintf(`The environment variable %q is not set\n\nIf this is a process running on Kubernetes, then it should be using the downward\nAPI to initialize this variable via:\n\n env:\n - name: %s\n valueFrom:\n fieldRef:\n fieldPath: metadata.namespace\n\nIf this is a Go unit test consuming system.Namespace() then it should add the\nfollowing import:\n\nimport (\n\t_ \"knative.dev/pkg/system/testing\"\n)`, NamespaceEnvKey, NamespaceEnvKey))\n}", "func (m Metadata) Namespace() string {\n\tif !m.HasNamespace() {\n\t\treturn \"\"\n\t}\n\treturn m[\"namespace\"].(string)\n}", "func (c *Config) Namespace() string {\n\treturn c.namespace\n}", "func (cc *ClientContext) Namespace() string {\n\treturn cc.namespace\n}", "func (c *C) NameSpace(prefix string, beforeControllers ...action) *NS {\n\tns := &NS{\n\t\tc: c,\n\t\tprefix: prefix,\n\t\tbCtrl: beforeControllers,\n\t}\n\n\treturn ns\n}", "func (o AuthBackendRoleOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *AuthBackendRole) pulumi.StringPtrOutput { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (o GetReposRepoOutput) Namespace() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetReposRepo) string { return v.Namespace }).(pulumi.StringOutput)\n}", "func (o MachineInstanceSpecClassRefOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v MachineInstanceSpecClassRef) *string { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (o MachineInstanceSpecResourceRefOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v MachineInstanceSpecResourceRef) *string { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (o MrScalarTaskScalingUpPolicyOutput) Namespace() pulumi.StringOutput {\n\treturn o.ApplyT(func(v MrScalarTaskScalingUpPolicy) string { return v.Namespace }).(pulumi.StringOutput)\n}", "func (o ApplicationSpecDestinationPtrOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ApplicationSpecDestination) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Namespace\n\t}).(pulumi.StringPtrOutput)\n}", "func GetNamespace() string {\n\tns, found := os.LookupEnv(\"POD_NAMESPACE\")\n\tif found {\n\t\treturn ns\n\t}\n\tnsb, err := ioutil.ReadFile(\"/var/run/secrets/kubernetes.io/serviceaccount/namespace\")\n\tif err == nil && len(nsb) > 0 {\n\t\treturn string(nsb)\n\t}\n\treturn DefaultNamespace\n}", "func getUTSNamespace(pid uint32) string {\n\treturn fmt.Sprintf(utsNSFormat, pid)\n}", "func (o MachineInstanceSpecClassRefPtrOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *MachineInstanceSpecClassRef) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Namespace\n\t}).(pulumi.StringPtrOutput)\n}", "func (o ApplicationStatusSyncComparedToDestinationPtrOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ApplicationStatusSyncComparedToDestination) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Namespace\n\t}).(pulumi.StringPtrOutput)\n}", "func (c *clientWrapper) lookupNamespace(ns string) string {\n\tif c.isNamespaceAll {\n\t\treturn metav1.NamespaceAll\n\t}\n\treturn ns\n}", "func (o ApplicationStatusComponentsOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationStatusComponents) *string { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (o DataSetRowLevelPermissionDataSetPtrOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *DataSetRowLevelPermissionDataSet) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Namespace\n\t}).(pulumi.StringPtrOutput)\n}", "func (o KubernetesClusterSpecResourceRefPtrOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *KubernetesClusterSpecResourceRef) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Namespace\n\t}).(pulumi.StringPtrOutput)\n}", "func (r *Root) Namespace() namespace {\n\tswitch currentVariant {\n\tcase noVariant:\n\t\tfidlgen.TemplateFatalf(\"Called Root.Namespace() when currentVariant isn't set.\\n\")\n\tcase hlcppVariant:\n\t\treturn hlcppNamespace(r.Library)\n\tcase unifiedVariant, wireVariant:\n\t\treturn unifiedNamespace(r.Library)\n\t}\n\tpanic(\"not reached\")\n}", "func defaultNamespace(deploymentID string) (string, error) {\n\treturn strings.ToLower(deploymentID), nil\n}", "func (o SecretBackendRoleOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *SecretBackendRole) pulumi.StringPtrOutput { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func (o SecretBackendRoleOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *SecretBackendRole) pulumi.StringPtrOutput { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func GetAppNamespace(ctx *scheduler.Context, taskname string) string {\n\treturn ctx.App.GetID(fmt.Sprintf(\"%s-%s\", taskname, Inst().InstanceID))\n}", "func (o ApplicationStatusAppliedresourcesOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationStatusAppliedresources) *string { return v.Namespace }).(pulumi.StringPtrOutput)\n}", "func toNamespace(spec *engine.Spec) *v1.Namespace {\n\treturn &v1.Namespace{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: spec.Metadata.Namespace,\n\t\t\tLabels: spec.Metadata.Labels,\n\t\t},\n\t}\n}", "func (c *Census) CleanNamespace() string {\n\tif strings.Contains(c.namespace, \":\") {\n\t\treturn strings.Split(c.namespace, \":\")[0]\n\t}\n\treturn c.namespace\n}", "func (_ EventFilterAliases) Namespace(p graphql.ResolveParams) (string, error) {\n\tval, err := graphql.DefaultResolver(p.Source, p.Info.FieldName)\n\tret, ok := val.(string)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\tif !ok {\n\t\treturn ret, errors.New(\"unable to coerce value for field 'namespace'\")\n\t}\n\treturn ret, err\n}", "func (o ParamRefPatchPtrOutput) Namespace() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ParamRefPatch) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Namespace\n\t}).(pulumi.StringPtrOutput)\n}" ]
[ "0.68790233", "0.6823478", "0.6823478", "0.68113446", "0.6795647", "0.66579765", "0.66444504", "0.6587921", "0.65514493", "0.6545297", "0.64766943", "0.6472167", "0.645568", "0.64538574", "0.6449971", "0.64347273", "0.64197195", "0.64137775", "0.6413226", "0.63904345", "0.6388918", "0.63823044", "0.6375537", "0.6348748", "0.6317653", "0.6302563", "0.6289688", "0.6272302", "0.62717605", "0.62640834", "0.62535435", "0.6246517", "0.62419945", "0.6238465", "0.6237382", "0.6230062", "0.62190014", "0.6205607", "0.62038153", "0.62019604", "0.618309", "0.6181868", "0.6167984", "0.6163909", "0.6162345", "0.6151285", "0.6141586", "0.6139814", "0.6139105", "0.6134224", "0.61254334", "0.6117843", "0.6113684", "0.6110826", "0.61014986", "0.6096556", "0.6093925", "0.60767883", "0.6064607", "0.60508597", "0.60453176", "0.6043102", "0.60365045", "0.6036218", "0.60358137", "0.6034898", "0.6034479", "0.6030505", "0.6027106", "0.60209525", "0.6016044", "0.60051066", "0.60050106", "0.5998369", "0.5992993", "0.59881294", "0.59873617", "0.5983834", "0.5981032", "0.5974564", "0.5967983", "0.5963138", "0.59590673", "0.59506917", "0.5925386", "0.59243405", "0.59212756", "0.591744", "0.5914896", "0.59137726", "0.59089327", "0.5903674", "0.5899998", "0.5899998", "0.5891003", "0.5887854", "0.58815813", "0.58802104", "0.58766043", "0.58565295" ]
0.7538144
0
TestLocalWriteWithExpiredContext ensures that writes are at least attempted even with an expired context, this is so that data is not lost even if the original writer has already disconnected.
func TestLocalWriteWithExpiredContext(t *testing.T) { ctrl := xtest.NewController(t) defer ctrl.Finish() store := setupLocalWrite(t, ctrl) writeQuery := newWriteQuery(t) past := time.Now().Add(-time.Minute) ctx, cancel := context.WithDeadline(context.Background(), past) defer cancel() // Ensure expired. var expired bool select { case <-ctx.Done(): expired = true default: } require.True(t, expired, "context expected to be expired") err := store.Write(ctx, writeQuery) assert.NoError(t, err) assert.NoError(t, store.Close()) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestLocalWritesWithExpiredContext(t *testing.T) {\n\tctrl := xtest.NewController(t)\n\tdefer ctrl.Finish()\n\tstore := setupLocalWrite(t, ctrl)\n\twriteQueryOpts := newWriteQuery(t).Options()\n\twriteQueryOpts.Datapoints = ts.Datapoints{\n\t\tts.Datapoint{\n\t\t\tTimestamp: xtime.Now(),\n\t\t\tValue: 42,\n\t\t},\n\t\tts.Datapoint{\n\t\t\tTimestamp: xtime.Now(),\n\t\t\tValue: 84,\n\t\t},\n\t}\n\twriteQuery, err := storage.NewWriteQuery(writeQueryOpts)\n\trequire.NoError(t, err)\n\n\tpast := time.Now().Add(-time.Minute)\n\n\tctx, cancel := context.WithDeadline(context.Background(), past)\n\tdefer cancel()\n\n\t// Ensure expired.\n\tvar expired bool\n\tselect {\n\tcase <-ctx.Done():\n\t\texpired = true\n\tdefault:\n\t}\n\trequire.True(t, expired, \"context expected to be expired\")\n\n\terr = store.Write(ctx, writeQuery)\n\tassert.NoError(t, err)\n\tassert.NoError(t, store.Close())\n}", "func testExpired(ttl time.Duration) cache.DirtyFunc {\n\treturn func(file storage.FileEntry) bool {\n\t\treturn file.LastModified.Before(time.Now().Add(-ttl))\n\t}\n}", "func Test_Ctx_Write(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\tctx.Write(\"Hello, \")\n\tctx.Write([]byte(\"World! \"))\n\tctx.Write(123)\n\tctx.Write(123.321)\n\tctx.Write(true)\n\tctx.Write(bytes.NewReader([]byte(\"Don't crash please\")))\n\tutils.AssertEqual(t, \"Don't crash please\", string(ctx.Fasthttp.Response.Body()))\n}", "func Test_Ctx_Stale(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\tutils.AssertEqual(t, true, ctx.Stale())\n}", "func (s *InMemorySuite) TestFIFOEviction(c *C) {\n\ttest.WithTimeout(func(ctx context.Context) {\n\t\t// Limit timeline capacity to 1.\n\t\t// Necessary to easily test if events are evicted if max capacity is reached.\n\t\ttimeline := s.newLimitedTimeline(1)\n\t\tnode := \"test-node\"\n\t\told := &pb.NodeStatus{Name: node, Status: pb.NodeStatus_Running}\n\t\tnew := &pb.NodeStatus{Name: node, Status: pb.NodeStatus_Degraded}\n\t\texpected := []*pb.TimelineEvent{history.NewNodeDegraded(s.clock.Now(), node)}\n\n\t\t// Recording two statuses should result in timeline to exceed capacity.\n\t\tc.Assert(timeline.RecordStatus(ctx, old), IsNil)\n\t\tc.Assert(timeline.RecordStatus(ctx, new), IsNil)\n\n\t\tactual, err := timeline.GetEvents(ctx, nil)\n\t\tc.Assert(err, IsNil)\n\t\tc.Assert(actual, test.DeepCompare, expected, Commentf(\"Expected degraded event.\"))\n\t})\n}", "func TestGetSetScopeAndAclWithExpiredToken(t *testing.T) {\n\tif testing.Short() {\n\t\tt.Skip(\"Skipping integration tests in short mode\")\n\t}\n\tdeleteAll(t)\n\talice := tu.UniqueString(\"alice\")\n\taliceClient, adminClient := getPachClient(t, alice), getPachClient(t, admin)\n\n\t// alice creates a repo\n\trepo := tu.UniqueString(\"TestGetSetScopeAndAclWithExpiredToken\")\n\trequire.NoError(t, aliceClient.CreateRepo(repo))\n\trequire.Equal(t, entries(alice, \"owner\"), GetACL(t, aliceClient, repo))\n\n\t// Make current enterprise token expire\n\tadminClient.Enterprise.Activate(adminClient.Ctx(),\n\t\t&enterprise.ActivateRequest{\n\t\t\tActivationCode: tu.GetTestEnterpriseCode(),\n\t\t\tExpires: TSProtoOrDie(t, time.Now().Add(-30*time.Second)),\n\t\t})\n\t// wait for Enterprise token to expire\n\trequire.NoError(t, backoff.Retry(func() error {\n\t\tresp, err := adminClient.Enterprise.GetState(adminClient.Ctx(),\n\t\t\t&enterprise.GetStateRequest{})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif resp.State == enterprise.State_ACTIVE {\n\t\t\treturn errors.New(\"Pachyderm Enterprise is still active\")\n\t\t}\n\t\treturn nil\n\t}, backoff.NewTestingBackOff()))\n\n\t// alice can't call GetScope on repo, even though she owns it\n\t_, err := aliceClient.GetScope(aliceClient.Ctx(), &auth.GetScopeRequest{\n\t\tRepos: []string{repo},\n\t})\n\trequire.YesError(t, err)\n\trequire.Matches(t, \"not active\", err.Error())\n\n\t// alice can't call SetScope on repo\n\t_, err = aliceClient.SetScope(aliceClient.Ctx(), &auth.SetScopeRequest{\n\t\tRepo: repo,\n\t\tUsername: \"carol\",\n\t\tScope: auth.Scope_READER,\n\t})\n\trequire.YesError(t, err)\n\trequire.Matches(t, \"not active\", err.Error())\n\trequire.Equal(t, entries(alice, \"owner\"), GetACL(t, adminClient, repo))\n\n\t// alice can't call GetAcl on repo\n\t_, err = aliceClient.GetACL(aliceClient.Ctx(), &auth.GetACLRequest{\n\t\tRepo: repo,\n\t})\n\trequire.YesError(t, err)\n\trequire.Matches(t, \"not active\", err.Error())\n\n\t// alice can't call GetAcl on repo\n\t_, err = aliceClient.SetACL(aliceClient.Ctx(), &auth.SetACLRequest{\n\t\tRepo: repo,\n\t\tEntries: []*auth.ACLEntry{\n\t\t\t{alice, auth.Scope_OWNER},\n\t\t\t{\"carol\", auth.Scope_READER},\n\t\t},\n\t})\n\trequire.YesError(t, err)\n\trequire.Matches(t, \"not active\", err.Error())\n\trequire.Equal(t, entries(alice, \"owner\"), GetACL(t, adminClient, repo))\n\n\t// admin *can* call GetScope on repo\n\tresp, err := adminClient.GetScope(adminClient.Ctx(), &auth.GetScopeRequest{\n\t\tRepos: []string{repo},\n\t})\n\trequire.NoError(t, err)\n\trequire.Equal(t, []auth.Scope{auth.Scope_NONE}, resp.Scopes)\n\n\t// admin can call SetScope on repo\n\t_, err = adminClient.SetScope(adminClient.Ctx(), &auth.SetScopeRequest{\n\t\tRepo: repo,\n\t\tUsername: \"carol\",\n\t\tScope: auth.Scope_READER,\n\t})\n\trequire.NoError(t, err)\n\trequire.ElementsEqual(t,\n\t\tentries(alice, \"owner\", \"carol\", \"reader\"), GetACL(t, adminClient, repo))\n\n\t// admin can call GetAcl on repo\n\taclResp, err := adminClient.GetACL(adminClient.Ctx(), &auth.GetACLRequest{\n\t\tRepo: repo,\n\t})\n\trequire.NoError(t, err)\n\trequire.ElementsEqual(t,\n\t\tentries(alice, \"owner\", \"carol\", \"reader\"), aclResp.Entries)\n\n\t// admin can call SetAcl on repo\n\t_, err = adminClient.SetACL(adminClient.Ctx(), &auth.SetACLRequest{\n\t\tRepo: repo,\n\t\tEntries: []*auth.ACLEntry{\n\t\t\t{alice, auth.Scope_OWNER},\n\t\t\t{\"carol\", auth.Scope_WRITER},\n\t\t},\n\t})\n\trequire.NoError(t, err)\n\trequire.ElementsEqual(t,\n\t\tentries(alice, \"owner\", \"carol\", \"writer\"), GetACL(t, adminClient, repo))\n}", "func TestAuthorizerBypassLocal(t *testing.T) {\n\tconfig := &Config{\n\t\tRealmConfigs: []*RealmConfig{\n\t\t\t{\n\t\t\t\tURI: testRealm,\n\t\t\t\tAuthorizer: &testAuthzMod{},\n\t\t\t},\n\t\t},\n\t\tDebug: debug,\n\t}\n\tr, err := NewRouter(config, logger)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer r.Close()\n\n\tsub, err := testClient(r)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tsubscribeID := wamp.GlobalID()\n\tsub.Send(&wamp.Subscribe{Request: subscribeID, Topic: denyTopic})\n\tmsg := <-sub.Recv()\n\tif _, ok := msg.(*wamp.Subscribed); !ok {\n\t\tt.Fatal(\"Expected SUBSCRIBED, got:\", msg.MessageType())\n\t}\n}", "func (w *writer) isExpired(now time.Time) bool {\n\tif w.count == 0 {\n\t\treturn false\n\t}\n\tif w.expiryTime == nil {\n\t\treturn false\n\t}\n\treturn w.expiryTime.Before(now)\n}", "func TestFlushWriteError(t *testing.T) {\n\tmockTr := new(mockTTransport)\n\ttr := NewTFramedTransport(mockTr)\n\tbuff := make([]byte, 10)\n\t_, err := tr.Write(buff)\n\tassert.Nil(t, err)\n\tmockTr.On(\"Write\", []byte{0, 0, 0, 10}).Return(4, nil)\n\tmockTr.On(\"Write\", buff).Return(0, errors.New(\"error\"))\n\n\tassert.Error(t, tr.Flush(context.TODO()))\n\tmockTr.AssertExpectations(t)\n}", "func TestGetCorruptFileAfterPut(t *testing.T) {\n\tvar (\n\t\tm = ioContext{\n\t\t\tt: t,\n\t\t\tnum: 1,\n\t\t\tfileSize: cos.KiB,\n\t\t}\n\n\t\tproxyURL = tools.RandomProxyURL(t)\n\t\tbaseParams = tools.BaseAPIParams(proxyURL)\n\t)\n\n\tif docker.IsRunning() {\n\t\tt.Skipf(\"%q requires setting xattrs, doesn't work with docker\", t.Name())\n\t}\n\n\tm.init(true /*cleanup*/)\n\tinitMountpaths(t, proxyURL)\n\n\ttools.CreateBucket(t, proxyURL, m.bck, nil, true /*cleanup*/)\n\n\tm.puts()\n\n\t// Test corrupting the file contents.\n\tobjName := m.objNames[0]\n\tfqn := findObjOnDisk(m.bck, objName)\n\ttlog.Logf(\"Corrupting object data %q: %s\\n\", objName, fqn)\n\terr := os.WriteFile(fqn, []byte(\"this file has been corrupted\"), cos.PermRWR)\n\ttassert.CheckFatal(t, err)\n\n\t_, err = api.GetObjectWithValidation(baseParams, m.bck, objName, nil)\n\ttassert.Errorf(t, err != nil, \"error is nil, expected error getting corrupted object\")\n}", "func (s *InMemorySuite) TestFIFOEviction(c *C) {\n\t// Limit timeline capacity to 1.\n\t// Necessary to easily test if events are evicted if max capacity is reached.\n\ttimeline := s.newLimitedTimeline(1)\n\tevents := []*pb.TimelineEvent{\n\t\tpb.NewNodeHealthy(s.clock.Now().Add(-time.Second), node), // older event should be evicted first\n\t\tpb.NewNodeDegraded(s.clock.Now(), node),\n\t}\n\texpected := []*pb.TimelineEvent{pb.NewNodeDegraded(s.clock.Now(), node)}\n\tcomment := Commentf(\"Expected node degraded event.\")\n\n\ttest.WithTimeout(func(ctx context.Context) {\n\t\t// Recording two statuses should result in timeline exceeding capacity.\n\t\tc.Assert(timeline.RecordEvents(ctx, events), IsNil, comment)\n\n\t\tactual, err := timeline.GetEvents(ctx, nil)\n\t\tc.Assert(err, IsNil, comment)\n\t\tc.Assert(actual, test.DeepCompare, expected, comment)\n\t})\n}", "func TestContextHolder_RaceConditions(t *testing.T) {\n\tconst lifeTime = 50 * time.Millisecond\n\tconst extendUntil = 200 * time.Millisecond\n\n\tctx, actuator := WithHeartBeat(context.Background(), lifeTime)\n\twaitForAllHeartbeats := time.After(2 * extendUntil)\n\n\tfor i := 0; i < 100; i++ {\n\t\tgo func() {\n\t\t\tstopHeartbeating := time.After(extendUntil)\n\t\t\tfor {\n\t\t\t\tselect {\n\t\t\t\tcase <-stopHeartbeating:\n\t\t\t\t\treturn\n\t\t\t\tcase <-ctx.Done():\n\t\t\t\t\trequire.Fail(t, \"context should haven't been finished yet\")\n\t\t\t\t\treturn\n\t\t\t\tdefault:\n\t\t\t\t\ttime.Sleep(lifeTime / 10)\n\t\t\t\t\tactuator.HeartBeat()\n\t\t\t\t}\n\t\t\t}\n\t\t}()\n\t}\n\n\t<-waitForAllHeartbeats\n\n\tselect {\n\tcase <-ctx.Done():\n\tcase <-time.After(5 * time.Second):\n\t\trequire.Fail(t, \"error waiting for context to be done\")\n\t}\n}", "func TestRecoverTxn(t *testing.T) {\n\tdefer leaktest.AfterTest(t)()\n\tdefer log.Scope(t).Close(t)\n\n\tctx := context.Background()\n\tk, k2 := roachpb.Key(\"a\"), roachpb.Key(\"b\")\n\tts := hlc.Timestamp{WallTime: 1}\n\ttxn := roachpb.MakeTransaction(\"test\", k, 0, ts, 0)\n\ttxn.Status = roachpb.STAGING\n\ttxn.LockSpans = []roachpb.Span{{Key: k}}\n\ttxn.InFlightWrites = []roachpb.SequencedWrite{{Key: k2, Sequence: 0}}\n\n\ttestutils.RunTrueAndFalse(t, \"missing write\", func(t *testing.T, missingWrite bool) {\n\t\tdb := storage.NewDefaultInMemForTesting()\n\t\tdefer db.Close()\n\n\t\t// Write the transaction record.\n\t\ttxnKey := keys.TransactionKey(txn.Key, txn.ID)\n\t\ttxnRecord := txn.AsRecord()\n\t\tif err := storage.MVCCPutProto(ctx, db, nil, txnKey, hlc.Timestamp{}, nil, &txnRecord); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\t// Issue a RecoverTxn request.\n\t\tvar resp roachpb.RecoverTxnResponse\n\t\tif _, err := RecoverTxn(ctx, db, CommandArgs{\n\t\t\tArgs: &roachpb.RecoverTxnRequest{\n\t\t\t\tRequestHeader: roachpb.RequestHeader{Key: txn.Key},\n\t\t\t\tTxn: txn.TxnMeta,\n\t\t\t\tImplicitlyCommitted: !missingWrite,\n\t\t\t},\n\t\t\tHeader: roachpb.Header{\n\t\t\t\tTimestamp: ts,\n\t\t\t},\n\t\t}, &resp); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\t// Assert that the response is correct.\n\t\texpTxnRecord := txn.AsRecord()\n\t\texpTxn := expTxnRecord.AsTransaction()\n\t\t// Merge the in-flight writes into the lock spans.\n\t\texpTxn.LockSpans = []roachpb.Span{{Key: k}, {Key: k2}}\n\t\texpTxn.InFlightWrites = nil\n\t\t// Set the correct status.\n\t\tif !missingWrite {\n\t\t\texpTxn.Status = roachpb.COMMITTED\n\t\t} else {\n\t\t\texpTxn.Status = roachpb.ABORTED\n\t\t}\n\t\trequire.Equal(t, expTxn, resp.RecoveredTxn)\n\n\t\t// Assert that the updated txn record was persisted correctly.\n\t\tvar resTxnRecord roachpb.Transaction\n\t\tif _, err := storage.MVCCGetProto(\n\t\t\tctx, db, txnKey, hlc.Timestamp{}, &resTxnRecord, storage.MVCCGetOptions{},\n\t\t); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\trequire.Equal(t, expTxn, resTxnRecord)\n\t})\n}", "func TestMock_WithDeadline(t *testing.T) {\n\tm := NewMock()\n\tctx, _ := m.WithDeadline(context.Background(), m.Now().Add(time.Second))\n\tm.Add(time.Second)\n\tselect {\n\tcase <-ctx.Done():\n\t\tif !errors.Is(ctx.Err(), context.DeadlineExceeded) {\n\t\t\tt.Error(\"invalid type of error returned when deadline exceeded\")\n\t\t}\n\tdefault:\n\t\tt.Error(\"context is not cancelled when deadline exceeded\")\n\t}\n}", "func TestRaftFreesReadOnlyMem(t *testing.T) {\n\tsm := newTestRaft(1, []uint64{1, 2}, 5, 1, NewMemoryStorage())\n\tdefer closeAndFreeRaft(sm)\n\tsm.becomeCandidate()\n\tsm.becomeLeader()\n\tsm.raftLog.commitTo(sm.raftLog.lastIndex())\n\n\tctx := []byte(\"ctx\")\n\n\t// leader starts linearizable read request.\n\t// more info: raft dissertation 6.4, step 2.\n\tsm.Step(pb.Message{From: 2, Type: pb.MsgReadIndex, Entries: []pb.Entry{{Data: ctx}}})\n\tmsgs := sm.readMessages()\n\tif len(msgs) != 1 {\n\t\tt.Fatalf(\"len(msgs) = %d, want 1\", len(msgs))\n\t}\n\tif msgs[0].Type != pb.MsgHeartbeat {\n\t\tt.Fatalf(\"type = %v, want MsgHeartbeat\", msgs[0].Type)\n\t}\n\tif !bytes.Equal(msgs[0].Context, ctx) {\n\t\tt.Fatalf(\"Context = %v, want %v\", msgs[0].Context, ctx)\n\t}\n\tif len(sm.readOnly.readIndexQueue) != 1 {\n\t\tt.Fatalf(\"len(readIndexQueue) = %v, want 1\", len(sm.readOnly.readIndexQueue))\n\t}\n\tif len(sm.readOnly.pendingReadIndex) != 1 {\n\t\tt.Fatalf(\"len(pendingReadIndex) = %v, want 1\", len(sm.readOnly.pendingReadIndex))\n\t}\n\tif _, ok := sm.readOnly.pendingReadIndex[string(ctx)]; !ok {\n\t\tt.Fatalf(\"can't find context %v in pendingReadIndex \", ctx)\n\t}\n\n\t// heartbeat responses from majority of followers (1 in this case)\n\t// acknowledge the authority of the leader.\n\t// more info: raft dissertation 6.4, step 3.\n\tsm.Step(pb.Message{From: 2, Type: pb.MsgHeartbeatResp, Context: ctx})\n\tif len(sm.readOnly.readIndexQueue) != 0 {\n\t\tt.Fatalf(\"len(readIndexQueue) = %v, want 0\", len(sm.readOnly.readIndexQueue))\n\t}\n\tif len(sm.readOnly.pendingReadIndex) != 0 {\n\t\tt.Fatalf(\"len(pendingReadIndex) = %v, want 0\", len(sm.readOnly.pendingReadIndex))\n\t}\n\tif _, ok := sm.readOnly.pendingReadIndex[string(ctx)]; ok {\n\t\tt.Fatalf(\"found context %v in pendingReadIndex, want none\", ctx)\n\t}\n}", "func TestMock_WithTimeout(t *testing.T) {\n\tm := NewMock()\n\tctx, _ := m.WithTimeout(context.Background(), time.Second)\n\tm.Add(time.Second)\n\tselect {\n\tcase <-ctx.Done():\n\t\tif !errors.Is(ctx.Err(), context.DeadlineExceeded) {\n\t\t\tt.Error(\"invalid type of error returned when time is over\")\n\t\t}\n\tdefault:\n\t\tt.Error(\"context is not cancelled when time is over\")\n\t}\n}", "func TestCleanupExpiredSinkService_WithExpiredGcsMirrorRevisions(t *testing.T) {\n\tt.Skip()\n\n\thttpMockHandler.Start()\n\tdefer httpMockHandler.Stop()\n\n\tconfigProvider := &MockImpersonatedTokenConfigProvider{\n\t\tTargetPrincipal: \"[email protected]\",\n\t\tError: nil,\n\t}\n\n\thttpMockHandler.Register(mock.ImpersonationHTTPMock)\n\n\tctx := context.Background()\n\tbackupRepository, err := repository.NewBackupRepository(ctx, secret.NewEnvSecretProvider())\n\trequire.NoErrorf(t, err, \"backupRepository should be instantiate\")\n\n\tsourceTrashcanRepository, err := repository.NewSourceTrashcanRepository(ctx, secret.NewEnvSecretProvider())\n\trequire.NoError(t, err, \"sourceMetadataRepository should be instantiate\")\n\n\tservice, err := newCleanupExpiredSinkService(ctx, configProvider, secret.NewEnvSecretProvider())\n\trequire.NoErrorf(t, err, \"CleanupBackupService should be instantiate\")\n\n\tbackup := cleanupBackupServiceBackup(cleanupServiceBackupID, repository.Prepared)\n\tbackup.Strategy = repository.Mirror\n\tbackup.Type = repository.CloudStorage\n\tbackup.CreatedTimestamp = time.Date(2019, 3, 14, 14, 57, 00, 0, time.Local)\n\tbackup.CloudStorageOptions = repository.CloudStorageOptions{Bucket: \"greg_test_bucket\"}\n\n\t_, err = backupRepository.AddBackup(ctx, backup)\n\trequire.NoError(t, err, \"should add new backup\")\n\tdefer func() { deleteBackup(cleanupServiceBackupID) }()\n\n\tsourceTrashcanRepository.Add(ctx, cleanupServiceBackupID, \"test_storage/2/10.txt\", time.Now().AddDate(0, -1, 0))\n\n\t_, stdErr, err := captureStderr(func() {\n\t\tservice.Run(ctx)\n\t})\n\n\trequire.NoError(t, err)\n\t// FIXME currently the tests failed because we didn't find any way to mock GRPCConn, thus this tests checks for the failing error message\n\t// FIXME: any code which changes this behavior must be aware of this or rollback this bypass\n\t//logMsg := \"[START] Deleting old CloudStorage revision\"\n\tlogMsg := \"Expected OAuth 2 access token, login cookie or other valid authentication credential.\"\n\tassert.Containsf(t, strings.TrimSpace(stdErr), logMsg, \"Run should not write log message %q but it logged\\n\\t%s\", logMsg, stdErr)\n\n\t//var sources []repository.SourceTrashcan\n\t//exists, err := sourceTrashcanRepository.FilterExistingEntries(ctx, sources)\n\t//require.NoError(t, err)\n\t//assert.Len(t, exists, 0)\n}", "func TestShardWriter_Write_ErrDialTimeout(t *testing.T) {\n\tts := newTestWriteService(nil)\n\tts.TSDBStore.WriteToShardFn = ts.writeShardSuccess\n\ts := coordinator.NewService(coordinator.Config{})\n\ts.Listener = ts.muxln\n\ts.TSDBStore = &ts.TSDBStore\n\tif err := s.Open(); err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer s.Close()\n\tdefer ts.Close()\n\n\t// Zero timeout set to support all platforms.\n\tw := coordinator.NewShardWriter(0, 1)\n\tw.MetaClient = &metaClient{host: ts.ln.Addr().String()}\n\tnow := time.Now()\n\n\tshardID := uint64(1)\n\townerID := uint64(2)\n\tvar points []models.Point\n\n\tpoints = append(points, models.MustNewPoint(\n\t\t\"cpu\", models.Tags{\"host\": \"server01\"}, map[string]interface{}{\"value\": int64(100)}, now,\n\t))\n\n\tif err, exp := w.WriteShard(shardID, ownerID, points), \"i/o timeout\"; err == nil || !strings.Contains(err.Error(), exp) {\n\t\tt.Fatalf(\"expected error %v, to contain %s\", err, exp)\n\t}\n}", "func TestContextIsAccessibleWithGo17Context(t *testing.T) {\n\tsuccHand := func(w http.ResponseWriter, r *http.Request) {\n\t\tr = r.WithContext(context.WithValue(r.Context(), \"dummykey\", \"dummyval\"))\n\t\ttoken := Token(r)\n\t\tif token == \"\" {\n\t\t\tt.Errorf(\"Token is inaccessible in the success handler\")\n\t\t}\n\t}\n\n\thand := New()\n\tchain := alice.New(hand.Handler).Then(http.HandlerFunc(succHand))\n\n\t// we need a request that passes. Let's just use a safe method for that.\n\treq := dummyGet()\n\twriter := httptest.NewRecorder()\n\n\tchain.ServeHTTP(writer, req)\n}", "func TestPoolContext(t *testing.T) {\n\tctx, _ := context.WithTimeout(context.Background(), time.Second)\n\tdefer leaktest.CheckContext(ctx, t)()\n\n\tgo func() {\n\t\tfor {\n\t\t\ttime.Sleep(time.Second)\n\t\t}\n\t}()\n}", "func Test_Limiter_Fixed_Window_Custom_Storage_Skip_Successful_Requests(t *testing.T) {\n\tt.Parallel()\n\t// Test concurrency using a default store\n\n\tapp := fiber.New()\n\n\tapp.Use(New(Config{\n\t\tMax: 1,\n\t\tExpiration: 2 * time.Second,\n\t\tStorage: memory.New(),\n\t\tSkipSuccessfulRequests: true,\n\t\tLimiterMiddleware: FixedWindow{},\n\t}))\n\n\tapp.Get(\"/:status\", func(c *fiber.Ctx) error {\n\t\tif c.Params(\"status\") == \"fail\" {\n\t\t\treturn c.SendStatus(400)\n\t\t}\n\t\treturn c.SendStatus(200)\n\t})\n\n\tresp, err := app.Test(httptest.NewRequest(fiber.MethodGet, \"/success\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 200, resp.StatusCode)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/fail\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 400, resp.StatusCode)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/fail\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 429, resp.StatusCode)\n\n\ttime.Sleep(3 * time.Second)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/fail\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 400, resp.StatusCode)\n}", "func (lru *LRU) FlushExpired() {\n\tif lru.removalFunc == nil || lru.ttl == 0 {\n\t\treturn\n\t}\n\n\tlru.mu.Lock()\n\tdefer lru.mu.Unlock()\n\n\tcutoff := time.Now().Add(-1 * lru.ttl)\n\tvar next *list.Element\n\tfor e := lru.list.Front(); e != nil; e = next {\n\t\t// get the next before removal below which causes Next to return nil\n\t\tnext = e.Next()\n\t\tn := e.Value.(*entry)\n\t\tif cutoff.After(n.ts) {\n\t\t\tlru.list.Remove(e)\n\t\t\tdelete(lru.table, n.Key)\n\t\t\tlru.removalFunc(n.Key, n.Value)\n\t\t}\n\t}\n}", "func TestWriteKeyOrderViolation(t *testing.T) {\n\tvar ctx = context.Background()\n\tvar buf = internal.NewAnonymousFile()\n\tvar writer = NewWriter(ctx, buf)\n\tvar err error\n\n\terr = writer.WriteString(ctx, \"test2\", \"data2\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error writing test data to sstable: %s\", err)\n\t}\n\n\terr = writer.WriteString(ctx, \"test1\", \"data1\")\n\tif err == nil {\n\t\tt.Error(\"WriteString in reverse order didn't fire, expected it to\")\n\t}\n\tif err != Err_KeyOrderViolation {\n\t\tt.Errorf(\"Unexpected error type after key order violation: %s\", err)\n\t}\n\n\terr = writer.WriteString(ctx, \"test2\", \"data3\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error writing second record to same key: %s\", err)\n\t}\n}", "func TestMock_WithDeadlineLaterThanCurrent(t *testing.T) {\n\tm := NewMock()\n\tctx, _ := m.WithDeadline(context.Background(), m.Now().Add(time.Second))\n\tctx, _ = m.WithDeadline(ctx, m.Now().Add(10*time.Second))\n\tm.Add(time.Second)\n\tselect {\n\tcase <-ctx.Done():\n\t\tif !errors.Is(ctx.Err(), context.DeadlineExceeded) {\n\t\t\tt.Error(\"invalid type of error returned when deadline exceeded\")\n\t\t}\n\tdefault:\n\t\tt.Error(\"context is not cancelled when deadline exceeded\")\n\t}\n}", "func verifyCacheExpiration(t *testing.T, sweepSettings cache.SweepSettings, wantEvicted []blob.ID) {\n\tcacheData := blobtesting.DataMap{}\n\n\t// on Windows, the time does not always move forward (sometimes clock.Now() returns exactly the same value for consecutive invocations)\n\t// this matters here so we return a fake clock.Now() function that always moves forward.\n\tvar currentTimeMutex sync.Mutex\n\n\tcurrentTime := clock.Now()\n\n\tmovingTimeFunc := func() time.Time {\n\t\tcurrentTimeMutex.Lock()\n\t\tdefer currentTimeMutex.Unlock()\n\n\t\tcurrentTime = currentTime.Add(1 * time.Millisecond)\n\n\t\treturn currentTime\n\t}\n\tcacheStorage := blobtesting.NewMapStorage(cacheData, nil, movingTimeFunc)\n\n\tunderlyingStorage := newUnderlyingStorageForContentCacheTesting(t)\n\n\tctx := testlogging.Context(t)\n\tcc, err := cache.NewContentCache(ctx, underlyingStorage, cache.Options{\n\t\tStorage: cacheStorage.(cache.Storage),\n\t\tSweep: sweepSettings,\n\t\tTimeNow: movingTimeFunc,\n\t}, nil)\n\n\trequire.NoError(t, err)\n\n\tdefer cc.Close(ctx)\n\n\tvar tmp gather.WriteBuffer\n\tdefer tmp.Close()\n\n\tconst underlyingBlobID = \"content-4k\"\n\n\terr = cc.GetContent(ctx, \"a\", underlyingBlobID, 0, -1, &tmp) // 4k\n\trequire.NoError(t, err)\n\terr = cc.GetContent(ctx, \"b\", underlyingBlobID, 0, -1, &tmp) // 4k\n\trequire.NoError(t, err)\n\terr = cc.GetContent(ctx, \"c\", underlyingBlobID, 0, -1, &tmp) // 4k\n\trequire.NoError(t, err)\n\terr = cc.GetContent(ctx, \"d\", underlyingBlobID, 0, -1, &tmp) // 4k\n\trequire.NoError(t, err)\n\n\t// delete underlying storage blob to identify cache items that have been evicted\n\t// all other items will be fetched from the cache.\n\trequire.NoError(t, underlyingStorage.DeleteBlob(ctx, underlyingBlobID))\n\n\tfor _, blobID := range []blob.ID{\"a\", \"b\", \"c\", \"d\"} {\n\t\tif slices.Contains(wantEvicted, blobID) {\n\t\t\trequire.ErrorIs(t, cc.GetContent(ctx, string(blobID), underlyingBlobID, 0, -1, &tmp), blob.ErrBlobNotFound, \"expected item not found %v\", blobID)\n\t\t} else {\n\t\t\trequire.NoError(t, cc.GetContent(ctx, string(blobID), underlyingBlobID, 0, -1, &tmp), \"expected item to be found %v\", blobID)\n\t\t}\n\t}\n}", "func TestMock_WithDeadlineImmediate(t *testing.T) {\n\tm := NewMock()\n\tctx, _ := m.WithDeadline(context.Background(), m.Now().Add(-time.Second))\n\tselect {\n\tcase <-ctx.Done():\n\t\tif !errors.Is(ctx.Err(), context.DeadlineExceeded) {\n\t\t\tt.Error(\"invalid type of error returned when deadline has already passed\")\n\t\t}\n\tdefault:\n\t\tt.Error(\"context is not cancelled when deadline has already passed\")\n\t}\n}", "func TestTruncateThenWrite(t *testing.T) {\n\tif runtime.GOOS == windowsOS {\n\t\tt.Skip(\"Rotation tests have been flaky on Windows. See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16331\")\n\t}\n\tt.Parallel()\n\n\ttempDir := t.TempDir()\n\tcfg := NewConfig().includeDir(tempDir)\n\tcfg.StartAt = \"beginning\"\n\toperator, emitCalls := buildTestManager(t, cfg)\n\toperator.persister = testutil.NewMockPersister(\"test\")\n\n\ttemp1 := openTemp(t, tempDir)\n\twriteString(t, temp1, \"testlog1\\ntestlog2\\n\")\n\n\toperator.poll(context.Background())\n\tdefer func() {\n\t\trequire.NoError(t, operator.Stop())\n\t}()\n\n\twaitForToken(t, emitCalls, []byte(\"testlog1\"))\n\twaitForToken(t, emitCalls, []byte(\"testlog2\"))\n\n\trequire.NoError(t, temp1.Truncate(0))\n\t_, err := temp1.Seek(0, 0)\n\trequire.NoError(t, err)\n\n\twriteString(t, temp1, \"testlog3\\n\")\n\toperator.poll(context.Background())\n\twaitForToken(t, emitCalls, []byte(\"testlog3\"))\n\texpectNoTokens(t, emitCalls)\n}", "func TestWSConnDeadline(t *testing.T) {\n\t// Defines a server which just reads some data and if successful writes the\n\t// data back. This way the clients won't get blocked.\n\tdata := fastrand.Bytes(10)\n\tserverFunc := func(conn *WSConn) {\n\t\t// Read some data.\n\t\tb := make([]byte, len(data))\n\t\t_, err := io.ReadFull(conn, b)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\t// Write data back.\n\t\t_, _ = conn.Write(b)\n\t\treturn\n\t}\n\n\t// Start the server.\n\twst := newWSTester(serverFunc)\n\tdefer wst.Close()\n\n\t// Declare helper for determining deadline error.\n\tisErrDeadline := func(err error) bool {\n\t\tif err == nil {\n\t\t\treturn false\n\t\t}\n\t\treturn strings.Contains(err.Error(), \"i/o timeout\")\n\t}\n\n\t// Declare helper.\n\tcheckDeadline := func(wst *wsTester, writeDeadline, readDeadline func(*WSConn), readFail, writeFail bool) {\n\t\t// Get client.\n\t\tclient, err := wst.NewClient()\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\tdefer client.Close()\n\t\t// Set pre-write deadline.\n\t\twriteDeadline(client)\n\t\ttime.Sleep(100 * time.Millisecond)\n\t\t// Write some data. This should fail if \"writeFail\" is specified.\n\t\t_, err = client.Write(data)\n\t\tif err != nil && !writeFail {\n\t\t\tt.Fatal(err)\n\t\t} else if writeFail && !isErrDeadline(err) {\n\t\t\tt.Fatal(\"expected write to fail\", err)\n\t\t}\n\t\t// If writing was expected to fail we abort since we won't receive a\n\t\t// response from the server.\n\t\tif writeFail {\n\t\t\treturn\n\t\t}\n\t\t// Set post-write deadline.\n\t\treadDeadline(client)\n\t\ttime.Sleep(100 * time.Millisecond)\n\t\t// Try reading. This should fail if \"readFail\" is specified.\n\t\t_, err = io.ReadFull(client, make([]byte, len(data)))\n\t\tif err != nil && !readFail {\n\t\t\tt.Fatal(err)\n\t\t} else if readFail && !isErrDeadline(err) {\n\t\t\tt.Fatal(\"expected read to fail\", err)\n\t\t}\n\t}\n\n\t// Execute tests.\n\tdeadline := time.Now()\n\n\t// No deadline\n\tnoDeadline := func(client *WSConn) {\n\t\tif err := client.SetDeadline(time.Time{}); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}\n\tcheckDeadline(wst, noDeadline, noDeadline, false, false)\n\n\t// ReadDeadline\n\tcheckDeadline(wst, noDeadline, func(client *WSConn) {\n\t\tif err := client.SetReadDeadline(deadline); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}, true, false)\n\n\t// WriteDeadline\n\tcheckDeadline(wst, func(client *WSConn) {\n\t\tif err := client.SetWriteDeadline(deadline); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}, noDeadline, false, true)\n\n\t// Same again but with SetDeadline.\n\tcheckDeadline(wst, noDeadline, func(client *WSConn) {\n\t\tif err := client.SetDeadline(deadline); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}, true, false)\n\n\tcheckDeadline(wst, func(client *WSConn) {\n\t\tif err := client.SetDeadline(deadline); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}, noDeadline, false, true)\n}", "func Test_Ctx_Fresh(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Request.Header.Set(HeaderIfNoneMatch, \"*\")\n\tctx.Fasthttp.Request.Header.Set(HeaderCacheControl, \"no-cache\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Request.Header.Set(HeaderIfNoneMatch, \"*\")\n\tctx.Fasthttp.Request.Header.Set(HeaderCacheControl, \",no-cache,\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Request.Header.Set(HeaderIfNoneMatch, \"*\")\n\tctx.Fasthttp.Request.Header.Set(HeaderCacheControl, \"aa,no-cache,\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Request.Header.Set(HeaderIfNoneMatch, \"*\")\n\tctx.Fasthttp.Request.Header.Set(HeaderCacheControl, \",no-cache,bb\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Request.Header.Set(HeaderIfNoneMatch, \"675af34563dc-tr34\")\n\tctx.Fasthttp.Request.Header.Set(HeaderCacheControl, \"public\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Request.Header.Set(HeaderIfNoneMatch, \"a, b\")\n\tctx.Fasthttp.Response.Header.Set(HeaderETag, \"c\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Response.Header.Set(HeaderETag, \"a\")\n\tutils.AssertEqual(t, true, ctx.Fresh())\n\n\tctx.Fasthttp.Request.Header.Set(HeaderIfModifiedSince, \"xxWed, 21 Oct 2015 07:28:00 GMT\")\n\tctx.Fasthttp.Response.Header.Set(HeaderLastModified, \"xxWed, 21 Oct 2015 07:28:00 GMT\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Response.Header.Set(HeaderLastModified, \"Wed, 21 Oct 2015 07:28:00 GMT\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Request.Header.Set(HeaderIfModifiedSince, \"Wed, 21 Oct 2015 07:28:00 GMT\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n}", "func TestNonDlmIdle(t *testing.T) {\n\tlogger.GetLogger().Log(logger.Debug, \"TestNonDlmIdle begin +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\\n\")\n\n\thostname := testutil.GetHostname()\n fmt.Println (\"Hostname: \", hostname);\n db, err := sql.Open(\"hera\", hostname + \":31002\")\n if err != nil {\n t.Fatal(\"Error starting Mux:\", err)\n return\n }\n\n\tdb.SetMaxIdleConns(0)\n\tdefer db.Close()\n\n fmt.Println (\"Open new connection\");\n ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n conn, err := db.Conn(ctx)\n if err != nil {\n t.Fatalf(\"Error getting connection %s\\n\", err.Error())\n }\n\n\ttx, _ := conn.BeginTx(ctx, nil)\n\tfmt.Println (\"Perform an insert & commit\");\n stmt, _ := tx.PrepareContext(ctx, \"/*TestBasic*/ insert into test_simple_table_2 (accountID, Name, Status) VALUES (12345, 'Linda Smith' , '111')\")\n\t_, err = stmt.Exec()\n\tif err != nil {\n t.Fatalf(\"Error preparing test (create row in table) %s\\n\", err.Error())\n }\n\terr = tx.Commit()\n if err != nil {\n t.Fatalf(\"Error commit %s\\n\", err.Error())\n }\n\tstmt, _ = conn.PrepareContext(ctx, \"/*cmd*/Select accountID, name from test_simple_table_2 where accountID=?\")\n rows, _ := stmt.Query(\"12345\")\n\tif !rows.Next() {\n t.Fatalf(\"Expected 1 row\")\n }\n\n\ttime.Sleep(7 * time.Second);\n\tfmt.Println (\"Verify idle timeout kicked in and server closes connection\");\n\tif ( testutil.RegexCount(\"Connection handler idle timeout\") < 1) {\n t.Fatalf (\"Error: Connection should close due to idle timeout\");\n }\n\n count := testutil.RegexCountFile (\"E.*OCCMUX.*idle_timeout_5000\", \"cal.log\")\n\tif (count > 0) {\n\t t.Fatalf (\"Error: should see idle_timeout event in CAL\");\n\t}\n\trows.Close() \n stmt.Close()\n\tcancel()\n\tconn.Close()\n\n\tlogger.GetLogger().Log(logger.Debug, \"TestNonDlmIdle done -------------------------------------------------------------\")\n}", "func TestEmitContextEvents(t *testing.T) {\n\tassert := asserts.NewTesting(t, asserts.FailStop)\n\tmsh := mesh.New()\n\n\terr := msh.SpawnCells(NewTestBehavior(\"foo\"))\n\tassert.NoError(err)\n\n\tctxA := context.Background()\n\tctxB, cancel := context.WithTimeout(ctxA, 5*time.Millisecond)\n\tdefer cancel()\n\n\tmsh.Emit(\"foo\", event.WithContext(ctxA, \"set\", \"a\", 5))\n\tmsh.Emit(\"foo\", event.WithContext(ctxA, \"set\", \"b\", 5))\n\n\ttime.Sleep(20 * time.Millisecond)\n\n\tmsh.Emit(\"foo\", event.WithContext(ctxB, \"set\", \"b\", 10))\n\n\tpl, plc := event.NewReplyPayload()\n\n\tmsh.Emit(\"foo\", event.New(\"send\", pl))\n\n\tplr, err := plc.Wait(waitTimeout)\n\n\tassert.NoError(err)\n\tassert.Equal(plr.At(\"a\").AsInt(0), 5)\n\tassert.Equal(plr.At(\"b\").AsInt(0), 5)\n\n\terr = msh.Stop()\n\tassert.NoError(err)\n}", "func (tc *TestCase) TestCorruptLoseTract() error {\n\t// We need at least five tractservers.\n\tif tc.clusterCfg.Tractservers < 5 {\n\t\treturn fmt.Errorf(\"need at least five tractservers for TestCorruptTract\")\n\t}\n\n\t// Create a blob and write some data to it.\n\tblob, err := tc.c.Create()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdata := makeRandom(1 * mb)\n\tblob.Seek(0, os.SEEK_SET)\n\tif n, err := blob.Write(data); err != nil || n != len(data) {\n\t\treturn err\n\t}\n\n\t// Pick two random tractservers that own the first tract. We will do\n\t// something evil to them.\n\ttracts, err := tc.c.GetTracts(context.Background(), blob.ID(), 0, 1)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(tracts) == 0 {\n\t\treturn fmt.Errorf(\"The blob has no tracts\")\n\t}\n\tfirstTract := tracts[0]\n\tfirstTS := int(rand.Uint32()) % len(firstTract.Hosts)\n\tsecondTS := (firstTS + 1) % len(firstTract.Hosts)\n\n\tcapture := tc.captureLogs()\n\n\t// Corrupt the replica on the first picked ts.\n\tif err := tc.corruptTract(firstTract.Tract, tc.bc.FindByServiceAddress(firstTract.Hosts[firstTS]), 1234); err != nil {\n\t\treturn err\n\t}\n\t// Kill the second picked ts.\n\tproc, perr := tc.getTractserverProc(firstTract.Tract, secondTS)\n\tif perr != nil {\n\t\treturn perr\n\t}\n\tproc.Stop()\n\n\t// Trigger a rereplication request.\n\tif err := tc.triggerRereplRequest(firstTract.Tract); err != nil {\n\t\treturn err\n\t}\n\n\t// Wait for a curator to log success.\n\tlog.Infof(\"waiting for rerepl...\")\n\tif err := capture.WaitFor(\n\t\tfmt.Sprintf(\"c:@@@ rerepl %v succeeded\", firstTract.Tract)); err != nil {\n\t\treturn err\n\t}\n\n\t// Now a write should succeed.\n\tblob.Seek(0, os.SEEK_SET)\n\tn, werr := blob.Write([]byte(\"spicy sichuan food\"))\n\tif werr != nil {\n\t\treturn werr\n\t}\n\tlog.Infof(\"wrote %d bytes\", n)\n\n\treturn nil\n}", "func Test_Limiter_Sliding_Window_Custom_Storage_Skip_Successful_Requests(t *testing.T) {\n\tt.Parallel()\n\t// Test concurrency using a default store\n\n\tapp := fiber.New()\n\n\tapp.Use(New(Config{\n\t\tMax: 1,\n\t\tExpiration: 2 * time.Second,\n\t\tStorage: memory.New(),\n\t\tSkipSuccessfulRequests: true,\n\t\tLimiterMiddleware: SlidingWindow{},\n\t}))\n\n\tapp.Get(\"/:status\", func(c *fiber.Ctx) error {\n\t\tif c.Params(\"status\") == \"fail\" {\n\t\t\treturn c.SendStatus(400)\n\t\t}\n\t\treturn c.SendStatus(200)\n\t})\n\n\tresp, err := app.Test(httptest.NewRequest(fiber.MethodGet, \"/success\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 200, resp.StatusCode)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/fail\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 400, resp.StatusCode)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/fail\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 429, resp.StatusCode)\n\n\ttime.Sleep(4 * time.Second)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/fail\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 400, resp.StatusCode)\n}", "func TestFreezerModifyRollback(t *testing.T) {\n\tt.Parallel()\n\n\tf, dir := newFreezerForTesting(t, freezerTestTableDef)\n\n\ttheError := errors.New(\"oops\")\n\t_, err := f.ModifyAncients(func(op database.AncientWriteOp) error {\n\t\t// Append three items. This creates two files immediately,\n\t\t// because the table size limit of the test freezer is 2048.\n\t\trequire.NoError(t, op.AppendRaw(\"test\", 0, make([]byte, 2048)))\n\t\trequire.NoError(t, op.AppendRaw(\"test\", 1, make([]byte, 2048)))\n\t\trequire.NoError(t, op.AppendRaw(\"test\", 2, make([]byte, 2048)))\n\t\treturn theError\n\t})\n\tif err != theError {\n\t\tt.Errorf(\"ModifyAncients returned wrong error %q\", err)\n\t}\n\tcheckAncientCount(t, f, \"test\", 0)\n\tf.Close()\n\n\t// Reopen and check that the rolled-back data doesn't reappear.\n\ttables := map[string]bool{\"test\": true}\n\tf2, err := NewFreezer(dir, \"\", false, 2049, tables)\n\tif err != nil {\n\t\tt.Fatalf(\"can't reopen freezer after failed ModifyAncients: %v\", err)\n\t}\n\tdefer f2.Close()\n\tcheckAncientCount(t, f2, \"test\", 0)\n}", "func TestAccountCorrupted(t *testing.T) {\n\tif testing.Short() {\n\t\tt.SkipNow()\n\t}\n\tt.Parallel()\n\n\t// create a renter\n\trt, err := newRenterTester(t.Name())\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer func() {\n\t\terr := rt.Close()\n\t\tif err != nil {\n\t\t\tt.Log(err)\n\t\t}\n\t}()\n\tr := rt.renter\n\n\t// create a number accounts\n\taccounts, err := openRandomTestAccountsOnRenter(r)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// select a random account of which we'll corrupt data on disk\n\tvar corrupted *account\n\tfor _, account := range accounts {\n\t\tcorrupted = account\n\t\tbreak\n\t}\n\n\t// manually close the renter and corrupt the data at that offset\n\terr = r.Close()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tfile, err := r.deps.OpenFile(filepath.Join(r.persistDir, accountsFilename), os.O_RDWR, defaultFilePerm)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\trN := fastrand.Intn(5) + 1\n\trOffset := corrupted.staticOffset + int64(fastrand.Intn(accountSize-rN))\n\tn, err := file.WriteAt(fastrand.Bytes(rN), rOffset)\n\tif n != rN {\n\t\tt.Fatalf(\"Unexpected amount of bytes written, %v != %v\", n, rN)\n\t}\n\tif err != nil {\n\t\tt.Fatal(\"Could not write corrupted account data\")\n\t}\n\n\t// reopen the renter\n\tpersistDir := filepath.Join(rt.dir, modules.RenterDir)\n\trl := ratelimit.NewRateLimit(0, 0, 0)\n\tr, errChan := New(rt.gateway, rt.cs, rt.wallet, rt.tpool, rt.mux, rl, persistDir)\n\tif err := <-errChan; err != nil {\n\t\tt.Fatal(err)\n\t}\n\terr = rt.addRenter(r)\n\n\t// verify only the non corrupted accounts got reloaded properly\n\tam := r.staticAccountManager\n\tam.mu.Lock()\n\t// verify the amount of accounts reloaded is one less\n\texpected := len(accounts) - 1\n\tif len(am.accounts) != expected {\n\t\tt.Errorf(\"Unexpected amount of accounts, %v != %v\", len(am.accounts), expected)\n\t}\n\tfor _, account := range am.accounts {\n\t\tif account.staticID.SPK().Equals(corrupted.staticID.SPK()) {\n\t\t\tt.Error(\"Corrupted account was not properly skipped\")\n\t\t}\n\t}\n\tam.mu.Unlock()\n}", "func testContext(t *testing.T) (context.Context, func()) {\n\tctxTest, completeTest := context.WithTimeout(context.Background(), 1100*time.Millisecond)\n\tgo func() {\n\t\tafter := time.NewTimer(1 * time.Second)\n\t\tselect {\n\t\tcase <-ctxTest.Done():\n\t\t\tafter.Stop()\n\t\tcase <-after.C:\n\t\t\trequire.Fail(t, \"test timed out\")\n\t\t}\n\t}()\n\treturn ctxTest, completeTest\n}", "func cleanContext(ctx context.Context) context.Context {\n\treturn datastore.WithoutTransaction(ctx)\n}", "func TestWriteErrorWhenReader(t *testing.T) {\n\t// Ensure the db exists for this test\n\tdb, err := Open(db_filename, \"c\")\n\tdb.Close()\n\n\tdb, err = Open(db_filename, \"r\")\n\tdefer db.Close()\n\tdefer os.Remove(db_filename)\n\n\tif err != nil {\n\t\tt.Error(\"Couldn't read database\")\n\t}\n\n\terr = db.Insert(\"foo\", \"bar\")\n\tif err == nil {\n\t\tt.Error(\"Database let readonly client write\")\n\t}\n}", "func Test_Ctx_SendFile(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\n\t// fetch file content\n\tf, err := os.Open(\"./ctx.go\")\n\tutils.AssertEqual(t, nil, err)\n\tdefer f.Close()\n\texpectFileContent, err := ioutil.ReadAll(f)\n\tutils.AssertEqual(t, nil, err)\n\t// fetch file info for the not modified test case\n\tfI, err := os.Stat(\"./ctx.go\")\n\tutils.AssertEqual(t, nil, err)\n\n\t// simple test case\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\terr = ctx.SendFile(\"ctx.go\")\n\t// check expectation\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, expectFileContent, ctx.Fasthttp.Response.Body())\n\tutils.AssertEqual(t, StatusOK, ctx.Fasthttp.Response.StatusCode())\n\tapp.ReleaseCtx(ctx)\n\n\t// test with custom error code\n\tctx = app.AcquireCtx(&fasthttp.RequestCtx{})\n\terr = ctx.Status(StatusInternalServerError).SendFile(\"ctx.go\")\n\t// check expectation\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, expectFileContent, ctx.Fasthttp.Response.Body())\n\tutils.AssertEqual(t, StatusInternalServerError, ctx.Fasthttp.Response.StatusCode())\n\tapp.ReleaseCtx(ctx)\n\n\t// test not modified\n\tctx = app.AcquireCtx(&fasthttp.RequestCtx{})\n\tctx.Fasthttp.Request.Header.Set(HeaderIfModifiedSince, fI.ModTime().Format(time.RFC1123))\n\terr = ctx.SendFile(\"ctx.go\")\n\t// check expectation\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, StatusNotModified, ctx.Fasthttp.Response.StatusCode())\n\tutils.AssertEqual(t, []byte(nil), ctx.Fasthttp.Response.Body())\n\tapp.ReleaseCtx(ctx)\n}", "func TestNameCacheEntryDoesntReturnExpiredLease(t *testing.T) {\n\tdefer leaktest.AfterTest(t)()\n\ts, db, kvDB := serverutils.StartServer(t, base.TestServerArgs{})\n\tdefer s.Stopper().Stop()\n\tleaseManager := s.LeaseManager().(*LeaseManager)\n\n\tif _, err := db.Exec(`\nCREATE DATABASE t;\nCREATE TABLE t.test (k CHAR PRIMARY KEY, v CHAR);\n`); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Populate the name cache.\n\tif _, err := db.Exec(\"SELECT * FROM t.test;\"); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\ttableDesc := sqlbase.GetTableDescriptor(kvDB, \"t\", \"test\")\n\n\t// Check the assumptions this tests makes: that there is a cache entry\n\t// (with a valid lease).\n\tlease := leaseManager.tableNames.get(tableDesc.ParentID, \"test\", s.Clock())\n\tif lease == nil {\n\t\tt.Fatalf(\"no name cache entry\")\n\t}\n\tif err := leaseManager.Release(lease); err != nil {\n\t\tt.Fatal(err)\n\t}\n\t// Advance the clock to expire the lease.\n\ts.Clock().SetMaxOffset(10 * LeaseDuration)\n\ts.Clock().Update(s.Clock().Now().Add(int64(2*LeaseDuration), 0))\n\n\t// Check the name no longer resolves.\n\tif leaseManager.tableNames.get(tableDesc.ParentID, \"test\", s.Clock()) != nil {\n\t\tt.Fatalf(\"name resolves when it shouldn't\")\n\t}\n}", "func TestUnsafeGracefulClose(t *testing.T) {\n\tnMsgs := 10\n\tkp := newFakeProd(nMsgs)\n\taw := NewUnsafeWriter(testTopic, kp)\n\n\tvar doneWg, startedWg sync.WaitGroup\n\n\tdoneWg.Add(nMsgs)\n\tstartedWg.Add(nMsgs)\n\tfor _ = range iter.N(nMsgs) {\n\t\tgo func() {\n\t\t\tstartedWg.Done()\n\t\t\tn, err := aw.Write(testBytes)\n\n\t\t\tif n != tbLen {\n\t\t\t\tt.Errorf(\"Wrote %d bytes, expected %d\", n, tbLen)\n\t\t\t}\n\n\t\t\tif err != nil {\n\t\t\t\tt.Error(err)\n\t\t\t}\n\t\t\tdoneWg.Done()\n\t\t}()\n\t}\n\tstartedWg.Wait()\n\n\tgo func() {\n\t\ttime.Sleep(50 * time.Millisecond)\n\t\tif err := aw.Close(); err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\ttime.Sleep(80 * time.Millisecond)\n\tgo kp.allSucc(defChk, t)\n\tdoneWg.Wait()\n\n\t// wait a little bit more so kp.allSucc has a chance to do stuff. Brittle and stupid but Works For Me™\n\ttime.Sleep(80 * time.Millisecond)\n\n\tif kp.count() != int32(nMsgs) {\n\t\tt.Fatalf(\"%d messages delivered to Successes(), expected %d\", kp.count(), nMsgs)\n\t}\n}", "func TestLogWriteFail(t *testing.T) {\n\tcm := NewChatManager(&FailWriter{}, historySize)\n\tdc := dummyconn.NewDummyConn()\n\terr := cm.Join(\"testuser\", dc)\n\tif err != nil {\n\t\tt.Fatalf(\"Unexpected error: %s\", err)\n\t}\n\n\tbuf := make([]byte, bufSize)\n\tn, err := dc.Read(buf)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\trMsg := buf[:n]\n\texpected := []byte(testTime + \" * testuser has joined\\n\")\n\tif !bytes.Equal(rMsg, expected) {\n\t\tt.Fatalf(\"Unexpected read: %s, want %s.\", rMsg, expected)\n\t}\n}", "func TestEngine_WritePoints_ErrPointsWriter(t *testing.T) {\n\te := OpenDefaultEngine()\n\tdefer e.Close()\n\n\t// Ensure points writer returns an error.\n\te.PointsWriter.WritePointsFn = func(a []tsdb.Point) error { return errors.New(\"marker\") }\n\n\t// Write to engine.\n\tif err := e.WritePoints(nil, nil, nil); err == nil || err.Error() != `write points: marker` {\n\t\tt.Fatal(err)\n\t}\n}", "func (tx *WriteTx) RunWithContext(ctx context.Context) error {\n\tif tx.err != nil {\n\t\treturn tx.err\n\t}\n\tinput, err := tx.input()\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = retry(ctx, func() error {\n\t\tout, err := tx.db.client.TransactWriteItemsWithContext(ctx, input)\n\t\tif tx.cc != nil && out != nil {\n\t\t\tfor _, cc := range out.ConsumedCapacity {\n\t\t\t\taddConsumedCapacity(tx.cc, cc)\n\t\t\t}\n\t\t}\n\t\treturn err\n\t})\n\treturn err\n}", "func TestDirCacheFlush(t *testing.T) {\n\trun.skipIfNoFUSE(t)\n\n\trun.checkDir(t, \"\")\n\n\trun.mkdir(t, \"dir\")\n\trun.mkdir(t, \"otherdir\")\n\trun.createFile(t, \"dir/file\", \"1\")\n\trun.createFile(t, \"otherdir/file\", \"1\")\n\n\tdm := newDirMap(\"otherdir/|otherdir/file 1|dir/|dir/file 1\")\n\tlocalDm := make(dirMap)\n\trun.readLocal(t, localDm, \"\")\n\tassert.Equal(t, dm, localDm, \"expected vs fuse mount\")\n\n\terr := run.fremote.Mkdir(context.Background(), \"dir/subdir\")\n\trequire.NoError(t, err)\n\n\t// expect newly created \"subdir\" on remote to not show up\n\trun.forget(\"otherdir\")\n\trun.readLocal(t, localDm, \"\")\n\tassert.Equal(t, dm, localDm, \"expected vs fuse mount\")\n\n\trun.forget(\"dir\")\n\tdm = newDirMap(\"otherdir/|otherdir/file 1|dir/|dir/file 1|dir/subdir/\")\n\trun.readLocal(t, localDm, \"\")\n\tassert.Equal(t, dm, localDm, \"expected vs fuse mount\")\n\n\trun.rm(t, \"otherdir/file\")\n\trun.rmdir(t, \"otherdir\")\n\trun.rm(t, \"dir/file\")\n\trun.rmdir(t, \"dir/subdir\")\n\trun.rmdir(t, \"dir\")\n\trun.checkDir(t, \"\")\n}", "func TestReadOnlyTxnObeysDeadline(t *testing.T) {\n\tdefer leaktest.AfterTest(t)()\n\ts, _, _ := serverutils.StartServer(t, base.TestServerArgs{})\n\tdefer s.Stopper().Stop()\n\tdb := createTestClient(t, s.Stopper(), s.ServingAddr())\n\n\tif err := db.Put(\"k\", \"v\"); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Use txn.Exec instead of db.Txn to disable auto retry.\n\ttxn := client.NewTxn(context.TODO(), *db)\n\tif err := txn.Exec(client.TxnExecOptions{AutoRetry: false, AutoCommit: true}, func(txn *client.Txn, _ *client.TxnExecOptions) error {\n\t\t// Set deadline to sometime in the past.\n\t\ttxn.UpdateDeadlineMaybe(hlc.Timestamp{WallTime: timeutil.Now().Add(-time.Second).UnixNano()})\n\t\t_, err := txn.Get(\"k\")\n\t\treturn err\n\t}); !testutils.IsError(err, \"txn aborted\") {\n\t\tt.Fatal(err)\n\t}\n}", "func TestNoWriteAfterServeHTTPReturns(t *testing.T) {\n\tcfdHTTP2Conn, edgeTCPConn := newTestHTTP2Connection()\n\n\tctx, cancel := context.WithCancel(context.Background())\n\tvar wg sync.WaitGroup\n\n\tserverDone := make(chan struct{})\n\tgo func() {\n\t\tdefer close(serverDone)\n\t\tcfdHTTP2Conn.Serve(ctx)\n\t}()\n\n\tedgeTransport := http2.Transport{}\n\tedgeHTTP2Conn, err := edgeTransport.NewClientConn(edgeTCPConn)\n\trequire.NoError(t, err)\n\tmessage := []byte(t.Name())\n\n\tfor i := 0; i < 100; i++ {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\treadPipe, writePipe := io.Pipe()\n\t\t\treqCtx, reqCancel := context.WithCancel(ctx)\n\t\t\treq, err := http.NewRequestWithContext(reqCtx, http.MethodGet, \"http://localhost:8080/ws/flaky\", readPipe)\n\t\t\trequire.NoError(t, err)\n\t\t\treq.Header.Set(InternalUpgradeHeader, WebsocketUpgrade)\n\n\t\t\tresp, err := edgeHTTP2Conn.RoundTrip(req)\n\t\t\trequire.NoError(t, err)\n\t\t\t// http2RespWriter should rewrite status 101 to 200\n\t\t\trequire.Equal(t, http.StatusOK, resp.StatusCode)\n\n\t\t\twg.Add(1)\n\t\t\tgo func() {\n\t\t\t\tdefer wg.Done()\n\t\t\t\tfor {\n\t\t\t\t\tselect {\n\t\t\t\t\tcase <-reqCtx.Done():\n\t\t\t\t\t\treturn\n\t\t\t\t\tdefault:\n\t\t\t\t\t}\n\t\t\t\t\t_ = wsutil.WriteClientBinary(writePipe, message)\n\t\t\t\t}\n\t\t\t}()\n\n\t\t\ttime.Sleep(time.Millisecond * 100)\n\t\t\treqCancel()\n\t\t}()\n\t}\n\n\twg.Wait()\n\tcancel()\n\t<-serverDone\n}", "func TestFreezerConcurrentModifyTruncate(t *testing.T) {\n\tf, _ := newFreezerForTesting(t, freezerTestTableDef)\n\tdefer f.Close()\n\n\tvar item = make([]byte, 256)\n\n\tfor i := 0; i < 1000; i++ {\n\t\t// First reset and write 100 items.\n\t\tif err := f.TruncateHead(0); err != nil {\n\t\t\tt.Fatal(\"truncate failed:\", err)\n\t\t}\n\t\t_, err := f.ModifyAncients(func(op database.AncientWriteOp) error {\n\t\t\tfor i := uint64(0); i < 100; i++ {\n\t\t\t\tif err := op.AppendRaw(\"test\", i, item); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t\tif err != nil {\n\t\t\tt.Fatal(\"modify failed:\", err)\n\t\t}\n\t\tcheckAncientCount(t, f, \"test\", 100)\n\n\t\t// Now append 100 more items and truncate concurrently.\n\t\tvar (\n\t\t\twg sync.WaitGroup\n\t\t\ttruncateErr error\n\t\t\tmodifyErr error\n\t\t)\n\t\twg.Add(3)\n\t\tgo func() {\n\t\t\t_, modifyErr = f.ModifyAncients(func(op database.AncientWriteOp) error {\n\t\t\t\tfor i := uint64(100); i < 200; i++ {\n\t\t\t\t\tif err := op.AppendRaw(\"test\", i, item); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t})\n\t\t\twg.Done()\n\t\t}()\n\t\tgo func() {\n\t\t\ttruncateErr = f.TruncateHead(10)\n\t\t\twg.Done()\n\t\t}()\n\t\tgo func() {\n\t\t\tf.AncientSize(\"test\")\n\t\t\twg.Done()\n\t\t}()\n\t\twg.Wait()\n\n\t\t// Now check the outcome. If the truncate operation went through first, the append\n\t\t// fails, otherwise it succeeds. In either case, the freezer should be positioned\n\t\t// at 10 after both operations are done.\n\t\tif truncateErr != nil {\n\t\t\tt.Fatal(\"concurrent truncate failed:\", err)\n\t\t}\n\t\tif !(errors.Is(modifyErr, nil) || errors.Is(modifyErr, errOutOrderInsertion)) {\n\t\t\tt.Fatal(\"wrong error from concurrent modify:\", modifyErr)\n\t\t}\n\t\tcheckAncientCount(t, f, \"test\", 10)\n\t}\n}", "func TestMock_WithDeadlineCancel(t *testing.T) {\n\tm := NewMock()\n\tctx, cancel := m.WithDeadline(context.Background(), m.Now().Add(time.Second))\n\tcancel()\n\tselect {\n\tcase <-ctx.Done():\n\t\tif !errors.Is(ctx.Err(), context.Canceled) {\n\t\t\tt.Error(\"invalid type of error returned after cancellation\")\n\t\t}\n\tcase <-time.After(time.Second):\n\t\tt.Error(\"context is not cancelled after cancel was called\")\n\t}\n}", "func TestSendENIStateChangeExpired(t *testing.T) {\n\tmockCtrl := gomock.NewController(t)\n\tdefer mockCtrl.Finish()\n\n\tmockStateManager := mock_dockerstate.NewMockTaskEngineState(mockCtrl)\n\teventChannel := make(chan statechange.Event)\n\tctx := context.TODO()\n\n\tgomock.InOrder(\n\t\tmockStateManager.EXPECT().ENIByMac(randomMAC).Return(&ni.ENIAttachment{\n\t\t\tAttachmentInfo: attachmentinfo.AttachmentInfo{\n\t\t\t\tAttachStatusSent: false,\n\t\t\t\tExpiresAt: time.Now().Add(expirationTimeSubtraction),\n\t\t\t},\n\t\t\tMACAddress: randomMAC,\n\t\t}, true),\n\t\tmockStateManager.EXPECT().RemoveENIAttachment(randomMAC),\n\t)\n\n\twatcher := setupWatcher(ctx, nil, mockStateManager, eventChannel, primaryMAC)\n\n\tassert.Error(t, watcher.sendENIStateChange(randomMAC))\n}", "func TestExpire(t *testing.T) {\n\tgo drain.Archiver.Expire()\n\ttime.Sleep(2 * time.Second)\n\n\t// finish expire loop\n\tdrain.Archiver.(*drain.BoltArchive).Done <- true\n\n\t// test successful clean\n\tappMsgs, err := drain.Archiver.Slice(\"app\", \"\", []string{\"\"}, 0, 0, 100, 0)\n\tif err != nil {\n\t\tt.Error(err)\n\t\tt.FailNow()\n\t}\n\t// compare written message to original\n\tif len(appMsgs) != 0 {\n\t\tt.Errorf(\"%q doesn't match expected out\", appMsgs)\n\t\tt.FailNow()\n\t}\n\n\t// test successful clean\n\tdepMsgs, err := drain.Archiver.Slice(\"deploy\", \"\", []string{\"\"}, 0, 0, 100, 0)\n\tif err != nil {\n\t\tt.Error(err)\n\t\tt.FailNow()\n\t}\n\t// compare written message to original\n\tif len(depMsgs) != 0 {\n\t\tt.Errorf(\"%q doesn't match expected out\", depMsgs)\n\t\tt.FailNow()\n\t}\n\n\tdrain.Archiver.(*drain.BoltArchive).Close()\n\n}", "func TestCleanupExpiredSinkService_WithTrashcanedGcsMirrorRevisions(t *testing.T) {\n\tt.Skip()\n\n\thttpMockHandler.Start()\n\tdefer httpMockHandler.Stop()\n\n\tconfigProvider := &MockImpersonatedTokenConfigProvider{\n\t\tTargetPrincipal: \"[email protected]\",\n\t\tError: nil,\n\t}\n\n\thttpMockHandler.Register(mock.ImpersonationHTTPMock)\n\tctx := context.Background()\n\n\tbackupRepository, err := repository.NewBackupRepository(ctx, secret.NewEnvSecretProvider())\n\trequire.NoErrorf(t, err, \"backupRepository should be instantiate\")\n\n\tservice, err := newCleanupExpiredSinkService(ctx, configProvider, secret.NewEnvSecretProvider())\n\trequire.NoErrorf(t, err, \"CleanupBackupService should be instantiate\")\n\n\tbackup := cleanupBackupServiceBackup(cleanupServiceBackupID, repository.Prepared)\n\tbackup.Strategy = repository.Mirror\n\tbackup.Type = repository.CloudStorage\n\tbackup.CreatedTimestamp = time.Date(2019, 3, 14, 14, 57, 00, 0, time.Local)\n\tbackup.CloudStorageOptions = repository.CloudStorageOptions{Bucket: \"greg_test_bucket\"}\n\n\t_, err = backupRepository.AddBackup(ctx, backup)\n\trequire.NoError(t, err, \"should add new backup\")\n\tdefer func() { deleteBackup(cleanupServiceBackupID) }()\n\n\t_, stdErr, err := captureStderr(func() {\n\t\tservice.Run(ctx)\n\t})\n\n\trequire.NoError(t, err)\n\t// FIXME currently the tests failed because we didn't find any way to mock GRPCConn, thus this tests checks for the failing error message\n\t// FIXME: any code which changes this behavior must be aware of this or rollback this bypass\n\t//logMsg :=\"[START] Deleting old CloudStorage revision\"\n\tlogMsg := \"Expected OAuth 2 access token, login cookie or other valid authentication credential.\"\n\tassert.Containsf(t, strings.TrimSpace(stdErr), logMsg, \"Run should not write log message %q but it logged\\n\\t%s\", logMsg, stdErr)\n\n\t//sourceTrashcanRepository, err := repository.NewSourceTrashcanRepository(ctx)\n\t//require.NoError(t, err, \"sourceMetadataRepository should be instantiate\")\n\t//var sources []repository.SourceTrashcan\n\t//sources = append(sources, repository.SourceTrashcan{BackupID: cleanupServiceBackupID, Source: \"test_storage/2/10.txt\"})\n\t//exists, err := sourceTrashcanRepository.FilterExistingEntries(ctx, sources)\n\t//require.NoError(t, err)\n\t//assert.Len(t, exists, 1)\n}", "func TestReadWriteTransaction_ErrorReturned(t *testing.T) {\n\tt.Parallel()\n\tctx := context.Background()\n\tserver, client, teardown := setupMockedTestServer(t)\n\tdefer teardown()\n\n\twant := errors.New(\"an error\")\n\t_, got := client.ReadWriteTransaction(ctx, func(context.Context, *ReadWriteTransaction) error {\n\t\treturn want\n\t})\n\tif got != want {\n\t\tt.Fatalf(\"got %+v, want %+v\", got, want)\n\t}\n\trequests := drainRequestsFromServer(server.TestSpanner)\n\tif err := compareRequests([]interface{}{\n\t\t&sppb.BatchCreateSessionsRequest{}}, requests); err != nil {\n\t\t// TODO: remove this once the session pool maintainer has been changed\n\t\t// so that is doesn't delete sessions already during the first\n\t\t// maintenance window.\n\t\t// If we failed to get 3, it might have because - due to timing - we got\n\t\t// a fourth request. If this request is DeleteSession, that's OK and\n\t\t// expected.\n\t\tif err := compareRequests([]interface{}{\n\t\t\t&sppb.BatchCreateSessionsRequest{},\n\t\t\t&sppb.RollbackRequest{}}, requests); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}\n}", "func TestCompactionRemoveTemp(t *testing.T) {\n\tctx := context.Background()\n\n\ttempDir := t.TempDir()\n\n\tf := NewFactory()\n\tcfg := f.CreateDefaultConfig().(*Config)\n\tcfg.Directory = tempDir\n\n\textension, err := f.CreateExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg)\n\trequire.NoError(t, err)\n\n\tse, ok := extension.(storage.Extension)\n\trequire.True(t, ok)\n\n\tclient, err := se.GetClient(\n\t\tctx,\n\t\tcomponent.KindReceiver,\n\t\tnewTestEntity(\"my_component\"),\n\t\t\"\",\n\t)\n\trequire.NoError(t, err)\n\tt.Cleanup(func() {\n\t\trequire.NoError(t, client.Close(ctx))\n\t})\n\n\t// check if only db exists in tempDir\n\tfiles, err := os.ReadDir(tempDir)\n\trequire.NoError(t, err)\n\trequire.Equal(t, 1, len(files))\n\tfileName := files[0].Name()\n\n\t// perform compaction in the same directory\n\tc, ok := client.(*fileStorageClient)\n\trequire.True(t, ok)\n\terr = c.Compact(tempDir, cfg.Timeout, 1)\n\trequire.NoError(t, err)\n\tt.Cleanup(func() {\n\t\trequire.NoError(t, client.Close(ctx))\n\t})\n\n\t// check if only db exists in tempDir\n\tfiles, err = os.ReadDir(tempDir)\n\trequire.NoError(t, err)\n\trequire.Equal(t, 1, len(files))\n\trequire.Equal(t, fileName, files[0].Name())\n\n\t// perform compaction in different directory\n\temptyTempDir := t.TempDir()\n\n\tc, ok = client.(*fileStorageClient)\n\trequire.True(t, ok)\n\terr = c.Compact(emptyTempDir, cfg.Timeout, 1)\n\trequire.NoError(t, err)\n\tt.Cleanup(func() {\n\t\trequire.NoError(t, client.Close(ctx))\n\t})\n\n\t// check if emptyTempDir is empty after compaction\n\tfiles, err = os.ReadDir(emptyTempDir)\n\trequire.NoError(t, err)\n\trequire.Equal(t, 0, len(files))\n}", "func TestWrite(t *testing.T) {\n\ttr := NewTFramedTransport(new(mockTTransport))\n\tbuff := make([]byte, 10)\n\n\tn, err := tr.Write(buff)\n\n\tassert.Equal(t, 10, n)\n\tassert.Nil(t, err)\n\tassert.Equal(t, buff, tr.buf.Bytes())\n}", "func TestShardWriter_Write_ErrReadTimeout(t *testing.T) {\n\tln, err := net.Listen(\"tcp\", \"127.0.0.1:0\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tw := coordinator.NewShardWriter(time.Millisecond, 1)\n\tw.MetaClient = &metaClient{host: ln.Addr().String()}\n\tnow := time.Now()\n\n\tshardID := uint64(1)\n\townerID := uint64(2)\n\tvar points []models.Point\n\tpoints = append(points, models.MustNewPoint(\n\t\t\"cpu\", models.Tags{\"host\": \"server01\"}, map[string]interface{}{\"value\": int64(100)}, now,\n\t))\n\n\tif err := w.WriteShard(shardID, ownerID, points); err == nil || !strings.Contains(err.Error(), \"i/o timeout\") {\n\t\tt.Fatalf(\"unexpected error: %s\", err)\n\t}\n}", "func (w *Writer) flushStaleWriters() error {\n\tw.mu.Lock()\n\tdefer w.mu.Unlock()\n\n\tnow := time.Now()\n\tvar stale []*tsDirWriter\n\tfor tsd, writer := range w.writers {\n\t\tif now.Sub(writer.modts.Time()) >= w.staleDuration {\n\t\t\tstale = append(stale, writer)\n\t\t\tdelete(w.writers, tsd)\n\t\t}\n\t}\n\n\tfor _, writer := range stale {\n\t\tif err := writer.flush(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (store *db) DeleteExpired() {\n\tif store == nil {\n\t\tfmt.Println(\"DeleteExpired : store is nil\")\n\t\treturn\n\t}\n\n\tvar evictedItems []keyAndValue\n\tnow := time.Now().UnixNano()\n\n\tstore.mapDBLock.Lock()\n\tdefer store.mapDBLock.Unlock()\n\t\n\tfor key, entry := range store.mapEntry {\n\t\t// \"Inlining\" of expired\n\t\tif entry.Expiration > 0 && now > entry.Expiration {\n\t\t\tentry, evicted := store.Delete(key)\n\t\t\tif evicted {\n\t\t\t\tevictedItems = append(evictedItems, keyAndValue{key, entry})\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, v := range evictedItems {\n\t\tstore.onEvicted(v.key, v.value)\n\t}\n}", "func TestEngine_WritePoints_PointsWriter(t *testing.T) {\n\te := OpenDefaultEngine()\n\tdefer e.Close()\n\n\t// Points to be inserted.\n\tpoints := []tsdb.Point{\n\t\ttsdb.NewPoint(\"cpu\", tsdb.Tags{}, tsdb.Fields{}, time.Unix(0, 1)),\n\t\ttsdb.NewPoint(\"cpu\", tsdb.Tags{}, tsdb.Fields{}, time.Unix(0, 0)),\n\t\ttsdb.NewPoint(\"cpu\", tsdb.Tags{}, tsdb.Fields{}, time.Unix(1, 0)),\n\n\t\ttsdb.NewPoint(\"cpu\", tsdb.Tags{\"host\": \"serverA\"}, tsdb.Fields{}, time.Unix(0, 0)),\n\t}\n\n\t// Mock points writer to ensure points are passed through.\n\tvar invoked bool\n\te.PointsWriter.WritePointsFn = func(a []tsdb.Point) error {\n\t\tinvoked = true\n\t\tif !reflect.DeepEqual(points, a) {\n\t\t\tt.Fatalf(\"unexpected points: %#v\", a)\n\t\t}\n\t\treturn nil\n\t}\n\n\t// Write points against two separate series.\n\tif err := e.WritePoints(points, nil, nil); err != nil {\n\t\tt.Fatal(err)\n\t} else if !invoked {\n\t\tt.Fatal(\"PointsWriter.WritePoints() not called\")\n\t}\n}", "func TestReadOnlyTransaction_UseAfterClose(t *testing.T) {\n\tt.Parallel()\n\tctx := context.Background()\n\t_, client, teardown := setupMockedTestServer(t)\n\tdefer teardown()\n\n\ttxn := client.ReadOnlyTransaction()\n\ttxn.Close()\n\n\t_, _, e := txn.acquire(ctx)\n\tif wantErr := errTxClosed(); !testEqual(e, wantErr) {\n\t\tt.Fatalf(\"Second acquire for multi use, got %v, want %v.\", e, wantErr)\n\t}\n}", "func TestTransactionIdleTimeout(t *testing.T) {\n\tlogger.GetLogger().Log(logger.Debug, \"TestTransactionIdleTimeout begin +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\\n\")\n\n\thostname := testutil.GetHostname()\n fmt.Println (\"Hostname: \", hostname);\n db, err := sql.Open(\"hera\", hostname + \":31002\")\n if err != nil {\n t.Fatal(\"Error starting Mux:\", err)\n return\n }\n\n\tdb.SetMaxIdleConns(0)\n\tdefer db.Close()\n\n\tvar wait_second int\n wait_second = 8\n\tfmt.Println (\"Verify idle timeout will not kick in, but tnx timeout will kick in for DML transaction\")\n\ttestutil.RunDMLCommitLater(\"/*cmd*/insert into test_simple_table_2 (accountID, Name, Status) VALUES (12345, 'Linda Smith' , '111')\", wait_second)\n\n fmt.Println (\"Open new connection to check fetch result\");\n ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n // cleanup and insert one row in the table\n conn, err := db.Conn(ctx)\n if err != nil {\n t.Fatalf(\"Error getting connection %s\\n\", err.Error())\n }\n\n fmt.Println (\"Verify fetch request returns correct result\");\n stmt, _ := conn.PrepareContext(ctx, \"/*TestBasic*/Select name, status from test_simple_table_2 where accountID=:accountID\")\n rows, _ := stmt.Query(sql.Named(\"accountID\", \"12345\"))\n if rows.Next() {\n t.Fatalf(\"Expected 0 row\")\n }\n\n\ttime.Sleep(2 * time.Second)\n\n\tif ( testutil.RegexCount(\"Connection handler idle timeout\") < 1) {\n t.Fatalf (\"Error: should have txn timeout\");\n }\n\n\tif ( testutil.RegexCountFile(\"E.*MUX.*idle_timeout_5000\", \"cal.log\") < 1) {\n t.Fatalf (\"Error: should have txn timeout\");\n }\n\n\tfmt.Println (\"Verify idle timeout event is NOT seen in CALlog\")\n count := testutil.RegexCountFile (\"E.*MUX.*idle_timeout_3000\", \"cal.log\")\n\tif (count > 0) {\n\t t.Fatalf (\"Error: should NOT see idle_timeout event\");\n\t}\n\n\trows.Close()\t\n stmt.Close()\n cancel()\n conn.Close()\n\ttestutil.DoDefaultValidation(t)\n\tlogger.GetLogger().Log(logger.Debug, \"TestTransactionIdleTimeout done -------------------------------------------------------------\")\n}", "func TestSaveEncryptionFails(t *testing.T) {\n\tmetadata, entries, snapshot := makeWALData(1, 1)\n\n\ttempdir, err := ioutil.TempDir(\"\", \"waltests\")\n\trequire.NoError(t, err)\n\tos.RemoveAll(tempdir)\n\tdefer os.RemoveAll(tempdir)\n\n\t// fail encrypting one of the entries, but not the first one\n\tc := NewWALFactory(&meowCrypter{encryptFailures: map[string]struct{}{\n\t\t\"Entry 3\": {},\n\t}}, nil)\n\twrapped, err := c.Create(tempdir, metadata)\n\trequire.NoError(t, err)\n\n\trequire.NoError(t, wrapped.SaveSnapshot(snapshot))\n\terr = wrapped.Save(raftpb.HardState{}, entries)\n\trequire.Error(t, err)\n\trequire.Contains(t, err.Error(), \"refusing to encrypt\")\n\trequire.NoError(t, wrapped.Close())\n\n\t// no entries are written at all\n\togWAL, err := OriginalWAL.Open(tempdir, snapshot)\n\trequire.NoError(t, err)\n\tdefer ogWAL.Close()\n\n\t_, _, ents, err := ogWAL.ReadAll()\n\trequire.NoError(t, err)\n\trequire.Empty(t, ents)\n}", "func (w *HotCache) ExpiredWriteItems(region *core.RegionInfo) []*HotPeerStat {\n\treturn w.writeFlow.CollectExpiredItems(region)\n}", "func TestVerifyExpired(t *testing.T) {\n\toptions := iniVerifyOptions(t)\n\toptions.CurrentTime = time.Date(2020, 01, 01, 01, 01, 01, 0, gmt)\n\n\tp := loadProxy(\"test-samples/RfcProxy.pem\", t)\n\tif e := p.Verify(options); e == nil {\n\t\tt.Error(\"Verification must fail\")\n\t} else {\n\t\tt.Log(e)\n\t}\n}", "func TestExpiry(t *testing.T) {\n\t_, privateBytes, err := GenerateKeyPair()\n\trequire.NoError(t, err)\n\tprivateKey, err := utils.ParsePrivateKey(privateBytes)\n\trequire.NoError(t, err)\n\n\tclock := clockwork.NewFakeClockAt(time.Now())\n\n\t// Create a new key that can be used to sign and verify tokens.\n\tkey, err := New(&Config{\n\t\tClock: clock,\n\t\tPrivateKey: privateKey,\n\t\tAlgorithm: defaults.ApplicationTokenAlgorithm,\n\t\tClusterName: \"example.com\",\n\t})\n\trequire.NoError(t, err)\n\n\t// Sign a token with a 1 minute expiration.\n\ttoken, err := key.Sign(SignParams{\n\t\tUsername: \"[email protected]\",\n\t\tRoles: []string{\"foo\", \"bar\"},\n\t\tTraits: wrappers.Traits{\n\t\t\t\"trait1\": []string{\"value-1\", \"value-2\"},\n\t\t},\n\t\tExpires: clock.Now().Add(1 * time.Minute),\n\t\tURI: \"http://127.0.0.1:8080\",\n\t})\n\trequire.NoError(t, err)\n\n\t// Verify that the token is still valid.\n\tclaims, err := key.Verify(VerifyParams{\n\t\tUsername: \"[email protected]\",\n\t\tURI: \"http://127.0.0.1:8080\",\n\t\tRawToken: token,\n\t})\n\trequire.NoError(t, err)\n\trequire.Equal(t, claims.Username, \"[email protected]\")\n\trequire.Equal(t, claims.Roles, []string{\"foo\", \"bar\"})\n\trequire.Equal(t, claims.IssuedAt, josejwt.NewNumericDate(clock.Now()))\n\n\t// Advance time by two minutes and verify the token is no longer valid.\n\tclock.Advance(2 * time.Minute)\n\t_, err = key.Verify(VerifyParams{\n\t\tUsername: \"[email protected]\",\n\t\tURI: \"http://127.0.0.1:8080\",\n\t\tRawToken: token,\n\t})\n\trequire.Error(t, err)\n}", "func TestTokenExpiracy(t *testing.T) {\n\tdb.InitDB()\n\tvar router *gin.Engine = routes.SetupRouter()\n\n\tos.Setenv(\"TOKEN_VALIDITY_MINUTES\", \"0\")\n\n\tvar user models.UserCreate = utils.CreateUser(\"Tom\", \"qwerty1234\", t, router)\n\tuser.Token = utils.ConnectUser(\"Tom\", \"qwerty1234\", t, router)\n\ttime.Sleep(1 * time.Second)\n\n\tvar url string = \"/v1/user/\" + strconv.Itoa(user.ID)\n\tvar bearer = \"Bearer \" + user.Token\n\trecord := httptest.NewRecorder()\n\trequest, _ := http.NewRequest(\"GET\", url, nil)\n\trequest.Header.Add(\"Content-Type\", \"application/json\")\n\trequest.Header.Add(\"Authorization\", bearer)\n\n\trouter.ServeHTTP(record, request)\n\n\tvar message Message\n\terr := json.Unmarshal([]byte(record.Body.String()), &message)\n\tif err != nil {\n\t\tlog.Fatal(\"Bad output: \", err.Error())\n\t\tt.Fail()\n\t}\n\n\tassert.Equal(t, record.Code, 401)\n\tassert.Equal(t, message.Message, \"Token expired.\")\n\n\tos.Setenv(\"TOKEN_VALIDITY_MINUTES\", \"15\")\n\n\tuser.Token = utils.ConnectUser(\"Tom\", \"qwerty1234\", t, router)\n\n\tutils.CleanUser(user.ID, user.Token, t, router)\n\tdb.CloseDB()\n}", "func Test_Ctx_SaveFile(t *testing.T) {\n\t// TODO We should clean this up\n\tt.Parallel()\n\tapp := New()\n\n\tapp.Post(\"/test\", func(c *Ctx) {\n\t\tfh, err := c.FormFile(\"file\")\n\t\tutils.AssertEqual(t, nil, err)\n\n\t\ttempFile, err := ioutil.TempFile(os.TempDir(), \"test-\")\n\t\tutils.AssertEqual(t, nil, err)\n\n\t\tdefer os.Remove(tempFile.Name())\n\t\terr = c.SaveFile(fh, tempFile.Name())\n\t\tutils.AssertEqual(t, nil, err)\n\n\t\tbs, err := ioutil.ReadFile(tempFile.Name())\n\t\tutils.AssertEqual(t, nil, err)\n\t\tutils.AssertEqual(t, \"hello world\", string(bs))\n\t})\n\n\tbody := &bytes.Buffer{}\n\twriter := multipart.NewWriter(body)\n\n\tioWriter, err := writer.CreateFormFile(\"file\", \"test\")\n\tutils.AssertEqual(t, nil, err)\n\n\t_, err = ioWriter.Write([]byte(\"hello world\"))\n\tutils.AssertEqual(t, nil, err)\n\twriter.Close()\n\n\treq := httptest.NewRequest(MethodPost, \"/test\", body)\n\treq.Header.Set(\"Content-Type\", writer.FormDataContentType())\n\treq.Header.Set(\"Content-Length\", strconv.Itoa(len(body.Bytes())))\n\n\tresp, err := app.Test(req)\n\tutils.AssertEqual(t, nil, err, \"app.Test(req)\")\n\tutils.AssertEqual(t, StatusOK, resp.StatusCode, \"Status code\")\n}", "func (s *PipelinedCopySuite) TestFailedRW(c *C) {\n\tsyncChan := make(chan bool, 1)\n\treadCount := 0\n\trw := &fakeReaderWriter{\n\t\treader: func(buf []byte) (int, error) {\n\t\t\tif readCount == 1 {\n\t\t\t\tselect {\n\t\t\t\tcase <-syncChan:\n\t\t\t\t\treturn 0, fmt.Errorf(\"second read fails\")\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treadCount++\n\t\t\t\treturn len(buf), nil\n\t\t\t}\n\n\t\t},\n\t\twriter: func(b []byte) (int, error) {\n\t\t\tclose(syncChan)\n\t\t\treturn 0, fmt.Errorf(\"write fails\")\n\t\t},\n\t}\n\t_, err := PipelinedCopy(rw, rw, 4, 10, 9)\n\tc.Assert(err, NotNil)\n}", "func TestFlush(t *testing.T) {\n\tmockTr := new(mockTTransport)\n\ttr := NewTFramedTransport(mockTr)\n\tbuff := make([]byte, 10)\n\t_, err := tr.Write(buff)\n\tassert.Nil(t, err)\n\tmockTr.On(\"Write\", []byte{0, 0, 0, 10}).Return(4, nil)\n\tmockTr.On(\"Write\", buff).Return(len(buff), nil)\n\tmockTr.On(\"Flush\", mock.Anything).Return(nil)\n\n\tassert.Nil(t, tr.Flush(context.TODO()))\n\tmockTr.AssertExpectations(t)\n}", "func (m *LocalExecutorManager) purgeExpiredEntries() {\n\tfor {\n\t\tfunc() {\n\t\t\tm.Lock()\n\t\t\tcutoverLimit := time.Now().Add(-24 * time.Hour)\n\t\t\tfor id, executorStatus := range m.id2ExecutorStatus {\n\t\t\t\tif executorStatus.LastAccessTime.Before(cutoverLimit) {\n\t\t\t\t\tdelete(m.id2ExecutorStatus, id)\n\t\t\t\t}\n\t\t\t}\n\t\t\tm.Unlock()\n\t\t\ttime.Sleep(1 * time.Hour)\n\t\t}()\n\t}\n}", "func expired(token *Token) bool {\n\tif token.Expires.IsZero() && len(token.Access) != 0 {\n\t\treturn false\n\t}\n\treturn token.Expires.Add(-expiryDelta).\n\t\tBefore(time.Now())\n}", "func TestRecoverTxnRecordChanged(t *testing.T) {\n\tdefer leaktest.AfterTest(t)()\n\tdefer log.Scope(t).Close(t)\n\n\tctx := context.Background()\n\tk := roachpb.Key(\"a\")\n\tts := hlc.Timestamp{WallTime: 1}\n\ttxn := roachpb.MakeTransaction(\"test\", k, 0, ts, 0)\n\ttxn.Status = roachpb.STAGING\n\n\ttestCases := []struct {\n\t\tname string\n\t\timplicitlyCommitted bool\n\t\texpError string\n\t\tchangedTxn roachpb.Transaction\n\t}{\n\t\t{\n\t\t\tname: \"transaction commit after all writes found\",\n\t\t\timplicitlyCommitted: true,\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.Status = roachpb.COMMITTED\n\t\t\t\ttxnCopy.InFlightWrites = nil\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction abort after all writes found\",\n\t\t\timplicitlyCommitted: true,\n\t\t\texpError: \"found ABORTED record for implicitly committed transaction\",\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.Status = roachpb.ABORTED\n\t\t\t\ttxnCopy.InFlightWrites = nil\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction restart after all writes found\",\n\t\t\timplicitlyCommitted: true,\n\t\t\texpError: \"epoch change by implicitly committed transaction: 0->1\",\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.BumpEpoch()\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction timestamp increase after all writes found\",\n\t\t\timplicitlyCommitted: true,\n\t\t\texpError: \"timestamp change by implicitly committed transaction: 0.000000001,0->0.000000002,0\",\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.WriteTimestamp = txnCopy.WriteTimestamp.Add(1, 0)\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction commit after write prevented\",\n\t\t\timplicitlyCommitted: false,\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.Status = roachpb.COMMITTED\n\t\t\t\ttxnCopy.InFlightWrites = nil\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction abort after write prevented\",\n\t\t\timplicitlyCommitted: false,\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.Status = roachpb.ABORTED\n\t\t\t\ttxnCopy.InFlightWrites = nil\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction restart (pending) after write prevented\",\n\t\t\timplicitlyCommitted: false,\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.BumpEpoch()\n\t\t\t\ttxnCopy.Status = roachpb.PENDING\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction restart (staging) after write prevented\",\n\t\t\timplicitlyCommitted: false,\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.BumpEpoch()\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction timestamp increase (pending) after write prevented\",\n\t\t\timplicitlyCommitted: false,\n\t\t\texpError: \"cannot recover PENDING transaction in same epoch\",\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.Status = roachpb.PENDING\n\t\t\t\ttxnCopy.InFlightWrites = nil\n\t\t\t\ttxnCopy.WriteTimestamp = txnCopy.WriteTimestamp.Add(1, 0)\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction timestamp increase (staging) after write prevented\",\n\t\t\timplicitlyCommitted: false,\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.WriteTimestamp = txnCopy.WriteTimestamp.Add(1, 0)\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t}\n\tfor _, c := range testCases {\n\t\tt.Run(c.name, func(t *testing.T) {\n\t\t\tdb := storage.NewDefaultInMemForTesting()\n\t\t\tdefer db.Close()\n\n\t\t\t// Write the modified transaction record, simulating a concurrent\n\t\t\t// actor changing the transaction record before the RecoverTxn\n\t\t\t// request is evaluated.\n\t\t\ttxnKey := keys.TransactionKey(txn.Key, txn.ID)\n\t\t\ttxnRecord := c.changedTxn.AsRecord()\n\t\t\tif err := storage.MVCCPutProto(ctx, db, nil, txnKey, hlc.Timestamp{}, nil, &txnRecord); err != nil {\n\t\t\t\tt.Fatal(err)\n\t\t\t}\n\n\t\t\t// Issue a RecoverTxn request.\n\t\t\tvar resp roachpb.RecoverTxnResponse\n\t\t\t_, err := RecoverTxn(ctx, db, CommandArgs{\n\t\t\t\tArgs: &roachpb.RecoverTxnRequest{\n\t\t\t\t\tRequestHeader: roachpb.RequestHeader{Key: txn.Key},\n\t\t\t\t\tTxn: txn.TxnMeta,\n\t\t\t\t\tImplicitlyCommitted: c.implicitlyCommitted,\n\t\t\t\t},\n\t\t\t\tHeader: roachpb.Header{\n\t\t\t\t\tTimestamp: ts,\n\t\t\t\t},\n\t\t\t}, &resp)\n\n\t\t\tif c.expError != \"\" {\n\t\t\t\tif !testutils.IsError(err, c.expError) {\n\t\t\t\t\tt.Fatalf(\"expected error %q; found %v\", c.expError, err)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatal(err)\n\t\t\t\t}\n\n\t\t\t\t// Assert that the response is correct.\n\t\t\t\texpTxnRecord := c.changedTxn.AsRecord()\n\t\t\t\texpTxn := expTxnRecord.AsTransaction()\n\t\t\t\trequire.Equal(t, expTxn, resp.RecoveredTxn)\n\n\t\t\t\t// Assert that the txn record was not modified.\n\t\t\t\tvar resTxnRecord roachpb.Transaction\n\t\t\t\tif _, err := storage.MVCCGetProto(\n\t\t\t\t\tctx, db, txnKey, hlc.Timestamp{}, &resTxnRecord, storage.MVCCGetOptions{},\n\t\t\t\t); err != nil {\n\t\t\t\t\tt.Fatal(err)\n\t\t\t\t}\n\t\t\t\trequire.Equal(t, expTxn, resTxnRecord)\n\t\t\t}\n\t\t})\n\t}\n}", "func TestPacketDropIsExpired(t *testing.T) {\n\texpiredTime := util.GetExpiredTimeInString(util.DefaultPacketDropExpirationMinutes, PacketDropLogTimeLayout)\n\texpiredPacketDrop := PacketDrop{LogTime: expiredTime}\n\tif !expiredPacketDrop.IsExpired() {\n\t\tt.Fatal(\"Expected IsExpired() return true, got false\")\n\t}\n\n\tcurTime := time.Now().Format(PacketDropLogTimeLayout)\n\tcurPacketDrop := PacketDrop{LogTime: curTime}\n\tif curPacketDrop.IsExpired() {\n\t\tt.Fatal(\"Expected IsExpired() return false, got true\")\n\t}\n\n}", "func TestNotIdle(t *testing.T) {\n\tdir := test_helpers.InitFS(t)\n\tmnt := dir + \".mnt\"\n\terr := test_helpers.Mount(dir, mnt, false, \"-extpass\", \"echo test\", \"-i=100ms\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\terr = ioutil.WriteFile(mnt+\"/foo\", []byte(\"foo\"), 0600)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\t// Read every 10 milliseconds for a total of 1 second\n\tfor i := 1; i < 100; i++ {\n\t\t_, err = ioutil.ReadFile(mnt + \"/foo\")\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"iteration %d failed: %v\", i, err)\n\t\t}\n\t\ttime.Sleep(10 * time.Millisecond)\n\t}\n\t// Keep a file handle open for 1 second\n\tfd, err := os.Open(mnt + \"/foo\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\ttime.Sleep(1 * time.Second)\n\tbuf := make([]byte, 100)\n\t_, err = fd.Read(buf)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tfd.Close()\n\t// All good.\n\ttest_helpers.UnmountPanic(mnt)\n}", "func (h *datastoreHandler) FlushLocalCache(ctx context.Context) {\n\tFromContext(ctx).FlushLocalCache()\n}", "func TestSBSExistingWriter(t *testing.T) {\n\ttest(t,\n\t\tusers(\"alice\", \"bob\"),\n\t\tinPrivateTlf(\"alice,bob,bob@twitter\"),\n\t\tas(alice,\n\t\t\tmkfile(\"alice.txt\", \"hello bob\"),\n\t\t),\n\t\tas(bob,\n\t\t\tmkfile(\"bob.txt\", \"hello alice\"),\n\t\t\tread(\"alice.txt\", \"hello bob\"),\n\t\t),\n\t\tas(alice,\n\t\t\tread(\"bob.txt\", \"hello alice\"),\n\t\t),\n\n\t\taddNewAssertion(\"bob\", \"bob@twitter\"),\n\t\tas(alice,\n\t\t\t// TODO: Ideally, we wouldn't have to do this,\n\t\t\t// and we'd just wait for a rekey.\n\t\t\trekey(),\n\t\t),\n\n\t\tinPrivateTlf(\"alice,bob\"),\n\t\tas(alice,\n\t\t\tread(\"alice.txt\", \"hello bob\"),\n\t\t\tread(\"bob.txt\", \"hello alice\"),\n\t\t),\n\t\tas(bob,\n\t\t\tread(\"alice.txt\", \"hello bob\"),\n\t\t\tread(\"bob.txt\", \"hello alice\"),\n\t\t),\n\n\t\tinPrivateTlfNonCanonical(\"alice,bob,bob@twitter\", \"alice,bob\"),\n\t\tas(alice,\n\t\t\tread(\"alice.txt\", \"hello bob\"),\n\t\t\tread(\"bob.txt\", \"hello alice\"),\n\t\t),\n\t\tas(bob,\n\t\t\tread(\"alice.txt\", \"hello bob\"),\n\t\t\tread(\"bob.txt\", \"hello alice\"),\n\t\t),\n\t)\n}", "func TestCommitterFailure(t *testing.T) {\n\te := []*transformer.Envelope{\n\t\t&transformer.Envelope{},\n\t\t&transformer.Envelope{},\n\t\t&transformer.Envelope{},\n\t}\n\n\texp := errors.New(\"OH MY GOD EVERYTHING IS BURNING\")\n\tc := NewCommitter(&dumbWriter{}, func(envs []*transformer.Envelope) error {\n\t\treturn exp\n\t})\n\n\terr := c.Write(e...)\n\tif err != exp {\n\t\tt.Fatalf(\"unexpected error %v\", err)\n\t}\n}", "func TestDataEEscapeOverflow(t *testing.T) {\n\tb := bytes.Buffer{}\n\tw := NewWriter(&b)\n\tw.Open(\"[email protected]\", time.Now())\n\tn, err := w.Write([]byte(test10))\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif n != 90 {\n\t\tt.Error(\"Expecting 90 bytes\")\n\t}\n\tw.Close()\n\t//fmt.Println(b.String(), n, err)\n}", "func TestFlushError(t *testing.T) {\n\tmockTr := new(mockTTransport)\n\ttr := NewTFramedTransport(mockTr)\n\tbuff := make([]byte, 10)\n\t_, err := tr.Write(buff)\n\tassert.Nil(t, err)\n\tmockTr.On(\"Write\", []byte{0, 0, 0, 10}).Return(4, nil)\n\tmockTr.On(\"Write\", buff).Return(len(buff), nil)\n\tmockTr.On(\"Flush\", mock.Anything).Return(errors.New(\"error\"))\n\n\tassert.Error(t, tr.Flush(context.TODO()))\n\tmockTr.AssertExpectations(t)\n}", "func (a *AzureBlobStorage) WriteWithContext(_ context.Context, msg *message.Batch) error {\n\treturn IterateBatchedSend(msg, func(i int, p *message.Part) error {\n\t\tc := a.client.GetContainerReference(a.container.String(i, msg))\n\t\tb := c.GetBlobReference(a.path.String(i, msg))\n\t\tif err := a.uploadBlob(b, a.blobType.String(i, msg), p.Get()); err != nil {\n\t\t\tif containerNotFound(err) {\n\t\t\t\tif cerr := a.createContainer(c, a.accessLevel.String(i, msg)); cerr != nil {\n\t\t\t\t\ta.log.Debugf(\"error creating container: %v.\", cerr)\n\t\t\t\t\treturn cerr\n\t\t\t\t}\n\t\t\t\terr = a.uploadBlob(b, a.blobType.String(i, msg), p.Get())\n\t\t\t\tif err != nil {\n\t\t\t\t\ta.log.Debugf(\"error retrying to upload blob: %v.\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n}", "func Test_Limiter_Fixed_Window_Custom_Storage_Skip_Failed_Requests(t *testing.T) {\n\tt.Parallel()\n\tapp := fiber.New()\n\n\tapp.Use(New(Config{\n\t\tMax: 1,\n\t\tExpiration: 2 * time.Second,\n\t\tStorage: memory.New(),\n\t\tSkipFailedRequests: true,\n\t\tLimiterMiddleware: FixedWindow{},\n\t}))\n\n\tapp.Get(\"/:status\", func(c *fiber.Ctx) error {\n\t\tif c.Params(\"status\") == \"fail\" {\n\t\t\treturn c.SendStatus(400)\n\t\t}\n\t\treturn c.SendStatus(200)\n\t})\n\n\tresp, err := app.Test(httptest.NewRequest(fiber.MethodGet, \"/fail\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 400, resp.StatusCode)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/success\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 200, resp.StatusCode)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/success\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 429, resp.StatusCode)\n\n\ttime.Sleep(3 * time.Second)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/success\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 200, resp.StatusCode)\n}", "func Test_Ctx_Locals(t *testing.T) {\n\tapp := New()\n\tapp.Use(func(c *Ctx) {\n\t\tc.Locals(\"john\", \"doe\")\n\t\tc.Next()\n\t})\n\tapp.Get(\"/test\", func(c *Ctx) {\n\t\tutils.AssertEqual(t, \"doe\", c.Locals(\"john\"))\n\t})\n\tresp, err := app.Test(httptest.NewRequest(MethodGet, \"/test\", nil))\n\tutils.AssertEqual(t, nil, err, \"app.Test(req)\")\n\tutils.AssertEqual(t, StatusOK, resp.StatusCode, \"Status code\")\n}", "func (m *MockConnectionTracer) LossTimerExpired(arg0 TimerType, arg1 protocol.EncryptionLevel) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"LossTimerExpired\", arg0, arg1)\n}", "func TestTFramedMemoryBufferWrite(t *testing.T) {\n\tbuff := NewTMemoryOutputBuffer(100)\n\tassert.Equal(t, 4, buff.Len())\n\tn, err := buff.Write(make([]byte, 50))\n\tassert.Nil(t, err)\n\tassert.Equal(t, 50, n)\n\tn, err = buff.Write(make([]byte, 40))\n\tassert.Nil(t, err)\n\tassert.Equal(t, 40, n)\n\tassert.Equal(t, 94, buff.Len())\n\t_, err = buff.Write(make([]byte, 20))\n\tassert.True(t, IsErrTooLarge(err))\n\tassert.Equal(t, TRANSPORT_EXCEPTION_REQUEST_TOO_LARGE, err.(thrift.TTransportException).TypeId())\n\tassert.Equal(t, 4, buff.Len())\n}", "func TestRenewBeforeTTLExpires(t *testing.T) {\n\tttl := 10\n\tc, v, secret := loginHelper(t, fmt.Sprintf(\"%vs\", ttl))\n\tif secret.LeaseDuration < 2 {\n\t\tt.Fatalf(\"expected lease to be at least 2s, but was: %d\", secret.LeaseDuration)\n\t} else if secret.LeaseDuration > 10 {\n\t\tt.Fatalf(\"expected lease to be at most 10s, but was: %d\", secret.LeaseDuration)\n\t}\n\n\t_, err := c.AuthAPIClient.GetAdmins(c.Ctx(), &auth.GetAdminsRequest{})\n\tif err != nil {\n\t\tt.Fatalf(err.Error())\n\t}\n\n\trenewer, err := v.NewRenewer(&vault.RenewerInput{\n\t\tSecret: secret,\n\t\tIncrement: ttl,\n\t})\n\tif err != nil {\n\t\tt.Fatalf(err.Error())\n\t}\n\n\t// Begin a renewer background process, and wait until it fires\n\ttime.Sleep(time.Duration(ttl/2) * time.Second)\n\tgo renewer.Renew()\n\tdefer renewer.Stop()\n\tselect {\n\tcase err := <-renewer.DoneCh():\n\t\tif err != nil {\n\t\t\tt.Fatalf(err.Error())\n\t\t}\n\tcase <-renewer.RenewCh():\n\t}\n\n\t// Make sure that the vault lease was only extended by 10s\n\tleaseInfo, err := v.Logical().Write(\"/sys/leases/lookup\", map[string]interface{}{\n\t\t\"lease_id\": secret.LeaseID,\n\t})\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\tnewDurationStr := leaseInfo.Data[\"ttl\"].(json.Number)\n\tnewDuration, err := newDurationStr.Int64()\n\tif err != nil {\n\t\tt.Fatalf(err.Error())\n\t}\n\tif newDuration < 2 {\n\t\tt.Fatalf(\"expected lease to be at least 2s, but was: %d\", newDuration)\n\t} else if newDuration > 20 {\n\t\tt.Fatalf(\"expected lease to be at most 20s, but was: %d\", newDuration)\n\t}\n\n\t// Make sure that the Pachyderm token was also renewed\n\ttime.Sleep(time.Duration(ttl/2+1) * time.Second) // wait til old lease exires\n\t_, err = c.AuthAPIClient.GetAdmins(c.Ctx(), &auth.GetAdminsRequest{})\n\tif err != nil {\n\t\tt.Fatalf(err.Error())\n\t}\n}", "func TestCacheGetContext(t *testing.T) {\n\tcache := New()\n\tsimpleM := &SimpleMemoryCache{\n\t\tdata: make(map[string]int64),\n\t}\n\tcache.Use(simpleM)\n\tnow := time.Now().Unix()\n\n\tcache.Set(\"foo\", now)\n\tctx := &Context{\n\t\tKey: \"foo\",\n\t}\n\n\tcache.GetContext(ctx)\n\n\tif ctx.Err != nil {\n\t\tt.Errorf(\"Failed to get data, err = %s\", ctx.Err)\n\t}\n\n\tif ctx.Value != now {\n\t\tt.Errorf(\"Failed to get, %d != %d\", ctx.Value, now)\n\t}\n\n\tif ctx.Source != \"simple-cache\" {\n\t\tt.Errorf(\"Get data from wrong source, %s\", ctx.Source)\n\t}\n}", "func TestSave(t *testing.T) {\n\tmetadata, entries, snapshot := makeWALData(1, 1)\n\n\tcrypter := &meowCrypter{}\n\tc := NewWALFactory(crypter, encryption.NoopCrypter)\n\ttempdir := createWithWAL(t, c, metadata, snapshot, entries)\n\tdefer os.RemoveAll(tempdir)\n\n\togWAL, err := OriginalWAL.Open(tempdir, snapshot)\n\trequire.NoError(t, err)\n\tdefer ogWAL.Close()\n\n\tmeta, state, ents, err := ogWAL.ReadAll()\n\trequire.NoError(t, err)\n\trequire.Equal(t, metadata, meta)\n\trequire.Equal(t, state, state)\n\tfor _, ent := range ents {\n\t\tvar encrypted api.MaybeEncryptedRecord\n\t\trequire.NoError(t, encrypted.Unmarshal(ent.Data))\n\n\t\trequire.Equal(t, crypter.Algorithm(), encrypted.Algorithm)\n\t\trequire.True(t, bytes.HasSuffix(encrypted.Data, []byte(\"🐱\")))\n\t}\n}", "func TestTokenTTLExtend(t *testing.T) {\n\tif testing.Short() {\n\t\tt.Skip(\"Skipping integration tests in short mode\")\n\t}\n\tdeleteAll(t)\n\tadminClient := getPachClient(t, admin)\n\n\t// Create repo (so alice has something to list)\n\trepo := tu.UniqueString(\"TestTokenTTLExtend\")\n\trequire.NoError(t, adminClient.CreateRepo(repo))\n\n\talice := tu.UniqueString(\"alice\")\n\tresp, err := adminClient.GetAuthToken(adminClient.Ctx(), &auth.GetAuthTokenRequest{\n\t\tSubject: alice,\n\t\tTTL: 5, // seconds\n\t})\n\trequire.NoError(t, err)\n\taliceClient := adminClient.WithCtx(context.Background())\n\taliceClient.SetAuthToken(resp.Token)\n\n\t// alice's token is valid, but expires quickly\n\trepos, err := aliceClient.ListRepo()\n\trequire.NoError(t, err)\n\trequire.ElementsEqualUnderFn(t, []string{repo}, repos, RepoInfoToName)\n\ttime.Sleep(10 * time.Second)\n\trepos, err = aliceClient.ListRepo()\n\trequire.True(t, auth.IsErrBadToken(err), err.Error())\n\trequire.Equal(t, 0, len(repos))\n\n\t// admin gives alice another token but extends it. Now it doesn't expire after\n\t// 10 seconds, but 20\n\tresp, err = adminClient.GetAuthToken(adminClient.Ctx(), &auth.GetAuthTokenRequest{\n\t\tSubject: alice,\n\t\tTTL: 5, // seconds\n\t})\n\trequire.NoError(t, err)\n\taliceClient.SetAuthToken(resp.Token)\n\t// token is valid\n\trepos, err = aliceClient.ListRepo()\n\trequire.NoError(t, err)\n\trequire.ElementsEqualUnderFn(t, []string{repo}, repos, RepoInfoToName)\n\t// admin extends token\n\t_, err = adminClient.ExtendAuthToken(adminClient.Ctx(), &auth.ExtendAuthTokenRequest{\n\t\tToken: resp.Token,\n\t\tTTL: 15,\n\t})\n\trequire.NoError(t, err)\n\n\t// token is still valid after 10 seconds\n\ttime.Sleep(10 * time.Second)\n\ttime.Sleep(time.Second)\n\trepos, err = aliceClient.ListRepo()\n\trequire.NoError(t, err)\n\trequire.ElementsEqualUnderFn(t, []string{repo}, repos, RepoInfoToName)\n\t// wait longer, now token is expired\n\ttime.Sleep(10 * time.Second)\n\trepos, err = aliceClient.ListRepo()\n\trequire.True(t, auth.IsErrBadToken(err), err.Error())\n\trequire.Equal(t, 0, len(repos))\n}", "func TestCreateOpenInvalidDirFails(t *testing.T) {\n\tc := NewWALFactory(encryption.NoopCrypter, encryption.NoopCrypter)\n\n\t_, err := c.Create(\"/not/existing/directory\", []byte(\"metadata\"))\n\trequire.Error(t, err)\n\n\ttempDir, err := ioutil.TempDir(\"\", \"test-migrate\")\n\trequire.NoError(t, err)\n\tdefer os.RemoveAll(tempDir)\n\n\t_, err = c.Open(tempDir, walpb.Snapshot{}) // invalid because no WAL file\n\trequire.Error(t, err)\n}", "func TestConn_ReadWrite_interruptSleepByDeadline(t *testing.T) {\n\tnw, dconn, _, stop, err := makePipe(\"earth\", \"mars\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer stop()\n\n\tnow := time.Now()\n\ttimeNow = func() time.Time {\n\t\treturn now.Add(time.Hour)\n\t}\n\tnw.SetBandwidth(\"earth\", \"mars\", Bandwidth(1024))\n\ttimeNow = func() time.Time {\n\t\treturn time.Now()\n\t}\n\n\tvar wg sync.WaitGroup\n\twg.Add(3)\n\tdefer wg.Wait()\n\tch := make(chan struct{})\n\tgo func() {\n\t\tdefer wg.Done()\n\t\tclose(ch)\n\t\ttime.Sleep(100 * time.Millisecond)\n\t\tif err := dconn.SetDeadline(time.Now().Add(100 * time.Millisecond)); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}()\n\tgo func() {\n\t\tdefer wg.Done()\n\t\t<-ch\n\t\tn, err := dconn.Read(make([]byte, 1024))\n\t\tensureTimeout(t, err)\n\t\tif n != 0 {\n\t\t\tt.Fatalf(\"Read: got %d, want 0\", n)\n\t\t}\n\t}()\n\tgo func() {\n\t\tdefer wg.Done()\n\t\t<-ch\n\t\tn, err := dconn.Write(make([]byte, 1024))\n\t\tensureTimeout(t, err)\n\t\tif n != 0 {\n\t\t\tt.Fatalf(\"Write: got %d, want 0\", n)\n\t\t}\n\t}()\n}", "func TestRenewAfterTTLExpires(t *testing.T) {\n\tttl := 2\n\tc, v, secret := loginHelper(t, fmt.Sprintf(\"%vs\", ttl))\n\n\t_, err := c.AuthAPIClient.GetAdmins(c.Ctx(), &auth.GetAdminsRequest{})\n\tif err != nil {\n\t\tt.Fatalf(err.Error())\n\t}\n\n\trenewer, err := v.NewRenewer(&vault.RenewerInput{\n\t\tSecret: secret,\n\t\tIncrement: ttl,\n\t})\n\tif err != nil {\n\t\tt.Fatalf(err.Error())\n\t}\n\n\ttime.Sleep(time.Duration(ttl+1) * time.Second)\n\tgo renewer.Renew()\n\tdefer renewer.Stop()\n\n\tselect {\n\tcase err := <-renewer.DoneCh():\n\t\tif err == nil {\n\t\t\tt.Fatalf(\"Expected an error renewing but got none\\n\")\n\t\t}\n\tcase <-renewer.RenewCh():\n\t\tt.Fatal(\"Expected failed renewal, but got successful renewal\\n\")\n\t}\n\n\t_, err = c.AuthAPIClient.GetAdmins(c.Ctx(), &auth.GetAdminsRequest{})\n\tif err == nil {\n\t\tt.Fatalf(\"Expected error using pach token after expiry, but got no error\\n\")\n\t}\n}", "func testCtx() context.Context {\n\treturn testCtxWithLevel(zerolog.WarnLevel)\n}", "func testNoNilTimeoutReplacement(ctx context.Context, t *testing.T, w *Wallet) {\n\terr := w.Unlock(ctx, testPrivPass, nil)\n\tif err != nil {\n\t\tt.Fatal(\"failed to unlock wallet\")\n\t}\n\ttimeChan := make(chan time.Time)\n\terr = w.Unlock(ctx, testPrivPass, timeChan)\n\tif err != nil {\n\t\tt.Fatal(\"failed to unlock wallet with time channel\")\n\t}\n\tselect {\n\tcase timeChan <- time.Time{}:\n\tcase <-time.After(100 * time.Millisecond):\n\t\tt.Fatal(\"time channel was not read in 100ms\")\n\t}\n\tif w.Locked() {\n\t\tt.Fatal(\"expected wallet to remain unlocked due to previous unlock without timeout\")\n\t}\n}", "func TestMarkOffline(t *testing.T) {\n\tsuicide := int64(0)\n\tgo func() {\n\t\ts.Join()\n\t\tatomic.StoreInt64(&suicide, 1)\n\t}()\n\n\terr := models.SetProxyStatus(conn, conf.productName, conf.proxyId, models.PROXY_STATE_MARK_OFFLINE)\n\tassert.MustNoError(err)\n\n\ttime.Sleep(3 * time.Second)\n\n\tif atomic.LoadInt64(&suicide) == 0 {\n\t\tt.Error(\"shoud be suicided\")\n\t}\n}", "func TestPrewriteLocked4A(t *testing.T) {\n}", "func TestShardWriter_WriteShard_Success(t *testing.T) {\n\tts := newTestWriteService(nil)\n\tts.TSDBStore.WriteToShardFn = ts.writeShardSuccess\n\ts := coordinator.NewService(coordinator.Config{})\n\ts.Listener = ts.muxln\n\ts.TSDBStore = &ts.TSDBStore\n\tif err := s.Open(); err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer s.Close()\n\tdefer ts.Close()\n\n\tw := coordinator.NewShardWriter(time.Minute, 1)\n\tw.MetaClient = &metaClient{host: ts.ln.Addr().String()}\n\n\t// Build a single point.\n\tnow := time.Now()\n\tvar points []models.Point\n\tpoints = append(points, models.MustNewPoint(\"cpu\", models.Tags{\"host\": \"server01\"}, map[string]interface{}{\"value\": int64(100)}, now))\n\n\t// Write to shard and close.\n\tif err := w.WriteShard(1, 2, points); err != nil {\n\t\tt.Fatal(err)\n\t} else if err := w.Close(); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Validate response.\n\tresponses, err := ts.ResponseN(1)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t} else if responses[0].shardID != 1 {\n\t\tt.Fatalf(\"unexpected shard id: %d\", responses[0].shardID)\n\t}\n\n\t// Validate point.\n\tif p := responses[0].points[0]; p.Name() != \"cpu\" {\n\t\tt.Fatalf(\"unexpected name: %s\", p.Name())\n\t} else if p.Fields()[\"value\"] != int64(100) {\n\t\tt.Fatalf(\"unexpected 'value' field: %d\", p.Fields()[\"value\"])\n\t} else if p.Tags()[\"host\"] != \"server01\" {\n\t\tt.Fatalf(\"unexpected 'host' tag: %s\", p.Tags()[\"host\"])\n\t} else if p.Time().UnixNano() != now.UnixNano() {\n\t\tt.Fatalf(\"unexpected time: %s\", p.Time())\n\t}\n}", "func Test_Ctx_Status(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\tctx.Status(400)\n\tutils.AssertEqual(t, 400, ctx.Fasthttp.Response.StatusCode())\n\tctx.Status(415).Send(\"Hello, World\")\n\tutils.AssertEqual(t, 415, ctx.Fasthttp.Response.StatusCode())\n\tutils.AssertEqual(t, \"Hello, World\", string(ctx.Fasthttp.Response.Body()))\n}", "func testFailingWrite(c *testContext, flow testFlow, wantErr *tcpip.Error) {\n\tc.t.Helper()\n\n\th := flow.header4Tuple(outgoing)\n\twriteDstAddr := flow.mapAddrIfApplicable(h.dstAddr.Addr)\n\n\tpayload := buffer.View(newPayload())\n\t_, _, gotErr := c.ep.Write(tcpip.SlicePayload(payload), tcpip.WriteOptions{\n\t\tTo: &tcpip.FullAddress{Addr: writeDstAddr, Port: h.dstAddr.Port},\n\t})\n\tif gotErr != wantErr {\n\t\tc.t.Fatalf(\"Write returned unexpected error: got %v, want %v\", gotErr, wantErr)\n\t}\n}", "func (m *MockBaseStore) DeleteExpiredKeys(arg0 context.Context) (int, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"DeleteExpiredKeys\", arg0)\n\tret0, _ := ret[0].(int)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func withHealthT(t *testing.T, ctx context.Context, client arangodb.Client, f healthFunc) {\n\tctxInner := ctx\n\tif _, ok := ctx.Deadline(); !ok {\n\t\t// When caller does not provide timeout, wait for healthiness for 30 seconds.\n\t\tvar cancel context.CancelFunc\n\n\t\tctxInner, cancel = context.WithTimeout(ctx, time.Second*30)\n\t\tdefer cancel()\n\t}\n\n\tfor {\n\t\thealth, err := client.Health(ctxInner)\n\t\tif err == nil && len(health.Health) > 0 {\n\t\t\tnotGood := 0\n\t\t\tfor _, h := range health.Health {\n\t\t\t\tif h.Status != arangodb.ServerStatusGood {\n\t\t\t\t\tnotGood++\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif notGood == 0 {\n\t\t\t\tf(t, ctxInner, health)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tselect {\n\t\tcase <-time.After(time.Second):\n\t\t\tbreak\n\t\tcase <-ctxInner.Done():\n\t\t\tif err == nil {\n\t\t\t\t// It is not health error, but context error.\n\t\t\t\terr = ctxInner.Err()\n\t\t\t}\n\n\t\t\terr = errors.WithMessagef(err, \"health %#v\", health)\n\t\t\trequire.NoError(t, err)\n\t\t}\n\t}\n}" ]
[ "0.86863756", "0.535115", "0.50087106", "0.4998404", "0.48275077", "0.47786194", "0.46923557", "0.4685437", "0.46595412", "0.46560925", "0.46249428", "0.46072173", "0.4568705", "0.45547703", "0.45439237", "0.45234445", "0.4492733", "0.44916826", "0.44442126", "0.4440123", "0.44393754", "0.44388315", "0.44301343", "0.4430001", "0.4428615", "0.44133252", "0.4388898", "0.43782547", "0.43722743", "0.43614745", "0.4355828", "0.4352842", "0.4324352", "0.43230826", "0.43205112", "0.43155947", "0.4309885", "0.42989105", "0.42819053", "0.42758292", "0.42746824", "0.4271992", "0.42707926", "0.42633623", "0.4253605", "0.4253452", "0.42492986", "0.42460734", "0.42441696", "0.4244104", "0.42418486", "0.42337936", "0.42333743", "0.42182258", "0.42132318", "0.42104632", "0.41962174", "0.41937557", "0.41907015", "0.41903087", "0.4188971", "0.41883552", "0.41876176", "0.41834947", "0.41784817", "0.4173355", "0.41676506", "0.41603136", "0.41518593", "0.41483724", "0.4145423", "0.41430032", "0.41423985", "0.4139321", "0.4136657", "0.41341478", "0.41255948", "0.4120044", "0.41187638", "0.41164923", "0.41145286", "0.411395", "0.41134134", "0.41096994", "0.41076842", "0.4104657", "0.41031352", "0.40938973", "0.40898255", "0.40823907", "0.4082097", "0.4076025", "0.4073507", "0.4052881", "0.40495098", "0.4048705", "0.40444258", "0.4039003", "0.40378448", "0.40307266" ]
0.8729709
0
TestLocalWritesWithExpiredContext ensures that writes are at least attempted even with an expired context, this is so that data is not lost even if the original writer has already disconnected.
func TestLocalWritesWithExpiredContext(t *testing.T) { ctrl := xtest.NewController(t) defer ctrl.Finish() store := setupLocalWrite(t, ctrl) writeQueryOpts := newWriteQuery(t).Options() writeQueryOpts.Datapoints = ts.Datapoints{ ts.Datapoint{ Timestamp: xtime.Now(), Value: 42, }, ts.Datapoint{ Timestamp: xtime.Now(), Value: 84, }, } writeQuery, err := storage.NewWriteQuery(writeQueryOpts) require.NoError(t, err) past := time.Now().Add(-time.Minute) ctx, cancel := context.WithDeadline(context.Background(), past) defer cancel() // Ensure expired. var expired bool select { case <-ctx.Done(): expired = true default: } require.True(t, expired, "context expected to be expired") err = store.Write(ctx, writeQuery) assert.NoError(t, err) assert.NoError(t, store.Close()) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestLocalWriteWithExpiredContext(t *testing.T) {\n\tctrl := xtest.NewController(t)\n\tdefer ctrl.Finish()\n\tstore := setupLocalWrite(t, ctrl)\n\twriteQuery := newWriteQuery(t)\n\n\tpast := time.Now().Add(-time.Minute)\n\n\tctx, cancel := context.WithDeadline(context.Background(), past)\n\tdefer cancel()\n\n\t// Ensure expired.\n\tvar expired bool\n\tselect {\n\tcase <-ctx.Done():\n\t\texpired = true\n\tdefault:\n\t}\n\trequire.True(t, expired, \"context expected to be expired\")\n\n\terr := store.Write(ctx, writeQuery)\n\tassert.NoError(t, err)\n\tassert.NoError(t, store.Close())\n}", "func testExpired(ttl time.Duration) cache.DirtyFunc {\n\treturn func(file storage.FileEntry) bool {\n\t\treturn file.LastModified.Before(time.Now().Add(-ttl))\n\t}\n}", "func Test_Ctx_Write(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\tctx.Write(\"Hello, \")\n\tctx.Write([]byte(\"World! \"))\n\tctx.Write(123)\n\tctx.Write(123.321)\n\tctx.Write(true)\n\tctx.Write(bytes.NewReader([]byte(\"Don't crash please\")))\n\tutils.AssertEqual(t, \"Don't crash please\", string(ctx.Fasthttp.Response.Body()))\n}", "func Test_Ctx_Stale(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\tutils.AssertEqual(t, true, ctx.Stale())\n}", "func TestAuthorizerBypassLocal(t *testing.T) {\n\tconfig := &Config{\n\t\tRealmConfigs: []*RealmConfig{\n\t\t\t{\n\t\t\t\tURI: testRealm,\n\t\t\t\tAuthorizer: &testAuthzMod{},\n\t\t\t},\n\t\t},\n\t\tDebug: debug,\n\t}\n\tr, err := NewRouter(config, logger)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer r.Close()\n\n\tsub, err := testClient(r)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tsubscribeID := wamp.GlobalID()\n\tsub.Send(&wamp.Subscribe{Request: subscribeID, Topic: denyTopic})\n\tmsg := <-sub.Recv()\n\tif _, ok := msg.(*wamp.Subscribed); !ok {\n\t\tt.Fatal(\"Expected SUBSCRIBED, got:\", msg.MessageType())\n\t}\n}", "func TestContextHolder_RaceConditions(t *testing.T) {\n\tconst lifeTime = 50 * time.Millisecond\n\tconst extendUntil = 200 * time.Millisecond\n\n\tctx, actuator := WithHeartBeat(context.Background(), lifeTime)\n\twaitForAllHeartbeats := time.After(2 * extendUntil)\n\n\tfor i := 0; i < 100; i++ {\n\t\tgo func() {\n\t\t\tstopHeartbeating := time.After(extendUntil)\n\t\t\tfor {\n\t\t\t\tselect {\n\t\t\t\tcase <-stopHeartbeating:\n\t\t\t\t\treturn\n\t\t\t\tcase <-ctx.Done():\n\t\t\t\t\trequire.Fail(t, \"context should haven't been finished yet\")\n\t\t\t\t\treturn\n\t\t\t\tdefault:\n\t\t\t\t\ttime.Sleep(lifeTime / 10)\n\t\t\t\t\tactuator.HeartBeat()\n\t\t\t\t}\n\t\t\t}\n\t\t}()\n\t}\n\n\t<-waitForAllHeartbeats\n\n\tselect {\n\tcase <-ctx.Done():\n\tcase <-time.After(5 * time.Second):\n\t\trequire.Fail(t, \"error waiting for context to be done\")\n\t}\n}", "func (w *writer) isExpired(now time.Time) bool {\n\tif w.count == 0 {\n\t\treturn false\n\t}\n\tif w.expiryTime == nil {\n\t\treturn false\n\t}\n\treturn w.expiryTime.Before(now)\n}", "func (w *Writer) flushStaleWriters() error {\n\tw.mu.Lock()\n\tdefer w.mu.Unlock()\n\n\tnow := time.Now()\n\tvar stale []*tsDirWriter\n\tfor tsd, writer := range w.writers {\n\t\tif now.Sub(writer.modts.Time()) >= w.staleDuration {\n\t\t\tstale = append(stale, writer)\n\t\t\tdelete(w.writers, tsd)\n\t\t}\n\t}\n\n\tfor _, writer := range stale {\n\t\tif err := writer.flush(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func TestGetSetScopeAndAclWithExpiredToken(t *testing.T) {\n\tif testing.Short() {\n\t\tt.Skip(\"Skipping integration tests in short mode\")\n\t}\n\tdeleteAll(t)\n\talice := tu.UniqueString(\"alice\")\n\taliceClient, adminClient := getPachClient(t, alice), getPachClient(t, admin)\n\n\t// alice creates a repo\n\trepo := tu.UniqueString(\"TestGetSetScopeAndAclWithExpiredToken\")\n\trequire.NoError(t, aliceClient.CreateRepo(repo))\n\trequire.Equal(t, entries(alice, \"owner\"), GetACL(t, aliceClient, repo))\n\n\t// Make current enterprise token expire\n\tadminClient.Enterprise.Activate(adminClient.Ctx(),\n\t\t&enterprise.ActivateRequest{\n\t\t\tActivationCode: tu.GetTestEnterpriseCode(),\n\t\t\tExpires: TSProtoOrDie(t, time.Now().Add(-30*time.Second)),\n\t\t})\n\t// wait for Enterprise token to expire\n\trequire.NoError(t, backoff.Retry(func() error {\n\t\tresp, err := adminClient.Enterprise.GetState(adminClient.Ctx(),\n\t\t\t&enterprise.GetStateRequest{})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif resp.State == enterprise.State_ACTIVE {\n\t\t\treturn errors.New(\"Pachyderm Enterprise is still active\")\n\t\t}\n\t\treturn nil\n\t}, backoff.NewTestingBackOff()))\n\n\t// alice can't call GetScope on repo, even though she owns it\n\t_, err := aliceClient.GetScope(aliceClient.Ctx(), &auth.GetScopeRequest{\n\t\tRepos: []string{repo},\n\t})\n\trequire.YesError(t, err)\n\trequire.Matches(t, \"not active\", err.Error())\n\n\t// alice can't call SetScope on repo\n\t_, err = aliceClient.SetScope(aliceClient.Ctx(), &auth.SetScopeRequest{\n\t\tRepo: repo,\n\t\tUsername: \"carol\",\n\t\tScope: auth.Scope_READER,\n\t})\n\trequire.YesError(t, err)\n\trequire.Matches(t, \"not active\", err.Error())\n\trequire.Equal(t, entries(alice, \"owner\"), GetACL(t, adminClient, repo))\n\n\t// alice can't call GetAcl on repo\n\t_, err = aliceClient.GetACL(aliceClient.Ctx(), &auth.GetACLRequest{\n\t\tRepo: repo,\n\t})\n\trequire.YesError(t, err)\n\trequire.Matches(t, \"not active\", err.Error())\n\n\t// alice can't call GetAcl on repo\n\t_, err = aliceClient.SetACL(aliceClient.Ctx(), &auth.SetACLRequest{\n\t\tRepo: repo,\n\t\tEntries: []*auth.ACLEntry{\n\t\t\t{alice, auth.Scope_OWNER},\n\t\t\t{\"carol\", auth.Scope_READER},\n\t\t},\n\t})\n\trequire.YesError(t, err)\n\trequire.Matches(t, \"not active\", err.Error())\n\trequire.Equal(t, entries(alice, \"owner\"), GetACL(t, adminClient, repo))\n\n\t// admin *can* call GetScope on repo\n\tresp, err := adminClient.GetScope(adminClient.Ctx(), &auth.GetScopeRequest{\n\t\tRepos: []string{repo},\n\t})\n\trequire.NoError(t, err)\n\trequire.Equal(t, []auth.Scope{auth.Scope_NONE}, resp.Scopes)\n\n\t// admin can call SetScope on repo\n\t_, err = adminClient.SetScope(adminClient.Ctx(), &auth.SetScopeRequest{\n\t\tRepo: repo,\n\t\tUsername: \"carol\",\n\t\tScope: auth.Scope_READER,\n\t})\n\trequire.NoError(t, err)\n\trequire.ElementsEqual(t,\n\t\tentries(alice, \"owner\", \"carol\", \"reader\"), GetACL(t, adminClient, repo))\n\n\t// admin can call GetAcl on repo\n\taclResp, err := adminClient.GetACL(adminClient.Ctx(), &auth.GetACLRequest{\n\t\tRepo: repo,\n\t})\n\trequire.NoError(t, err)\n\trequire.ElementsEqual(t,\n\t\tentries(alice, \"owner\", \"carol\", \"reader\"), aclResp.Entries)\n\n\t// admin can call SetAcl on repo\n\t_, err = adminClient.SetACL(adminClient.Ctx(), &auth.SetACLRequest{\n\t\tRepo: repo,\n\t\tEntries: []*auth.ACLEntry{\n\t\t\t{alice, auth.Scope_OWNER},\n\t\t\t{\"carol\", auth.Scope_WRITER},\n\t\t},\n\t})\n\trequire.NoError(t, err)\n\trequire.ElementsEqual(t,\n\t\tentries(alice, \"owner\", \"carol\", \"writer\"), GetACL(t, adminClient, repo))\n}", "func TestCleanupExpiredSinkService_WithExpiredGcsMirrorRevisions(t *testing.T) {\n\tt.Skip()\n\n\thttpMockHandler.Start()\n\tdefer httpMockHandler.Stop()\n\n\tconfigProvider := &MockImpersonatedTokenConfigProvider{\n\t\tTargetPrincipal: \"[email protected]\",\n\t\tError: nil,\n\t}\n\n\thttpMockHandler.Register(mock.ImpersonationHTTPMock)\n\n\tctx := context.Background()\n\tbackupRepository, err := repository.NewBackupRepository(ctx, secret.NewEnvSecretProvider())\n\trequire.NoErrorf(t, err, \"backupRepository should be instantiate\")\n\n\tsourceTrashcanRepository, err := repository.NewSourceTrashcanRepository(ctx, secret.NewEnvSecretProvider())\n\trequire.NoError(t, err, \"sourceMetadataRepository should be instantiate\")\n\n\tservice, err := newCleanupExpiredSinkService(ctx, configProvider, secret.NewEnvSecretProvider())\n\trequire.NoErrorf(t, err, \"CleanupBackupService should be instantiate\")\n\n\tbackup := cleanupBackupServiceBackup(cleanupServiceBackupID, repository.Prepared)\n\tbackup.Strategy = repository.Mirror\n\tbackup.Type = repository.CloudStorage\n\tbackup.CreatedTimestamp = time.Date(2019, 3, 14, 14, 57, 00, 0, time.Local)\n\tbackup.CloudStorageOptions = repository.CloudStorageOptions{Bucket: \"greg_test_bucket\"}\n\n\t_, err = backupRepository.AddBackup(ctx, backup)\n\trequire.NoError(t, err, \"should add new backup\")\n\tdefer func() { deleteBackup(cleanupServiceBackupID) }()\n\n\tsourceTrashcanRepository.Add(ctx, cleanupServiceBackupID, \"test_storage/2/10.txt\", time.Now().AddDate(0, -1, 0))\n\n\t_, stdErr, err := captureStderr(func() {\n\t\tservice.Run(ctx)\n\t})\n\n\trequire.NoError(t, err)\n\t// FIXME currently the tests failed because we didn't find any way to mock GRPCConn, thus this tests checks for the failing error message\n\t// FIXME: any code which changes this behavior must be aware of this or rollback this bypass\n\t//logMsg := \"[START] Deleting old CloudStorage revision\"\n\tlogMsg := \"Expected OAuth 2 access token, login cookie or other valid authentication credential.\"\n\tassert.Containsf(t, strings.TrimSpace(stdErr), logMsg, \"Run should not write log message %q but it logged\\n\\t%s\", logMsg, stdErr)\n\n\t//var sources []repository.SourceTrashcan\n\t//exists, err := sourceTrashcanRepository.FilterExistingEntries(ctx, sources)\n\t//require.NoError(t, err)\n\t//assert.Len(t, exists, 0)\n}", "func (s *InMemorySuite) TestFIFOEviction(c *C) {\n\ttest.WithTimeout(func(ctx context.Context) {\n\t\t// Limit timeline capacity to 1.\n\t\t// Necessary to easily test if events are evicted if max capacity is reached.\n\t\ttimeline := s.newLimitedTimeline(1)\n\t\tnode := \"test-node\"\n\t\told := &pb.NodeStatus{Name: node, Status: pb.NodeStatus_Running}\n\t\tnew := &pb.NodeStatus{Name: node, Status: pb.NodeStatus_Degraded}\n\t\texpected := []*pb.TimelineEvent{history.NewNodeDegraded(s.clock.Now(), node)}\n\n\t\t// Recording two statuses should result in timeline to exceed capacity.\n\t\tc.Assert(timeline.RecordStatus(ctx, old), IsNil)\n\t\tc.Assert(timeline.RecordStatus(ctx, new), IsNil)\n\n\t\tactual, err := timeline.GetEvents(ctx, nil)\n\t\tc.Assert(err, IsNil)\n\t\tc.Assert(actual, test.DeepCompare, expected, Commentf(\"Expected degraded event.\"))\n\t})\n}", "func TestShardWriter_Write_ErrDialTimeout(t *testing.T) {\n\tts := newTestWriteService(nil)\n\tts.TSDBStore.WriteToShardFn = ts.writeShardSuccess\n\ts := coordinator.NewService(coordinator.Config{})\n\ts.Listener = ts.muxln\n\ts.TSDBStore = &ts.TSDBStore\n\tif err := s.Open(); err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer s.Close()\n\tdefer ts.Close()\n\n\t// Zero timeout set to support all platforms.\n\tw := coordinator.NewShardWriter(0, 1)\n\tw.MetaClient = &metaClient{host: ts.ln.Addr().String()}\n\tnow := time.Now()\n\n\tshardID := uint64(1)\n\townerID := uint64(2)\n\tvar points []models.Point\n\n\tpoints = append(points, models.MustNewPoint(\n\t\t\"cpu\", models.Tags{\"host\": \"server01\"}, map[string]interface{}{\"value\": int64(100)}, now,\n\t))\n\n\tif err, exp := w.WriteShard(shardID, ownerID, points), \"i/o timeout\"; err == nil || !strings.Contains(err.Error(), exp) {\n\t\tt.Fatalf(\"expected error %v, to contain %s\", err, exp)\n\t}\n}", "func TestRecoverTxn(t *testing.T) {\n\tdefer leaktest.AfterTest(t)()\n\tdefer log.Scope(t).Close(t)\n\n\tctx := context.Background()\n\tk, k2 := roachpb.Key(\"a\"), roachpb.Key(\"b\")\n\tts := hlc.Timestamp{WallTime: 1}\n\ttxn := roachpb.MakeTransaction(\"test\", k, 0, ts, 0)\n\ttxn.Status = roachpb.STAGING\n\ttxn.LockSpans = []roachpb.Span{{Key: k}}\n\ttxn.InFlightWrites = []roachpb.SequencedWrite{{Key: k2, Sequence: 0}}\n\n\ttestutils.RunTrueAndFalse(t, \"missing write\", func(t *testing.T, missingWrite bool) {\n\t\tdb := storage.NewDefaultInMemForTesting()\n\t\tdefer db.Close()\n\n\t\t// Write the transaction record.\n\t\ttxnKey := keys.TransactionKey(txn.Key, txn.ID)\n\t\ttxnRecord := txn.AsRecord()\n\t\tif err := storage.MVCCPutProto(ctx, db, nil, txnKey, hlc.Timestamp{}, nil, &txnRecord); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\t// Issue a RecoverTxn request.\n\t\tvar resp roachpb.RecoverTxnResponse\n\t\tif _, err := RecoverTxn(ctx, db, CommandArgs{\n\t\t\tArgs: &roachpb.RecoverTxnRequest{\n\t\t\t\tRequestHeader: roachpb.RequestHeader{Key: txn.Key},\n\t\t\t\tTxn: txn.TxnMeta,\n\t\t\t\tImplicitlyCommitted: !missingWrite,\n\t\t\t},\n\t\t\tHeader: roachpb.Header{\n\t\t\t\tTimestamp: ts,\n\t\t\t},\n\t\t}, &resp); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\t// Assert that the response is correct.\n\t\texpTxnRecord := txn.AsRecord()\n\t\texpTxn := expTxnRecord.AsTransaction()\n\t\t// Merge the in-flight writes into the lock spans.\n\t\texpTxn.LockSpans = []roachpb.Span{{Key: k}, {Key: k2}}\n\t\texpTxn.InFlightWrites = nil\n\t\t// Set the correct status.\n\t\tif !missingWrite {\n\t\t\texpTxn.Status = roachpb.COMMITTED\n\t\t} else {\n\t\t\texpTxn.Status = roachpb.ABORTED\n\t\t}\n\t\trequire.Equal(t, expTxn, resp.RecoveredTxn)\n\n\t\t// Assert that the updated txn record was persisted correctly.\n\t\tvar resTxnRecord roachpb.Transaction\n\t\tif _, err := storage.MVCCGetProto(\n\t\t\tctx, db, txnKey, hlc.Timestamp{}, &resTxnRecord, storage.MVCCGetOptions{},\n\t\t); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\trequire.Equal(t, expTxn, resTxnRecord)\n\t})\n}", "func Test_Limiter_Fixed_Window_Custom_Storage_Skip_Successful_Requests(t *testing.T) {\n\tt.Parallel()\n\t// Test concurrency using a default store\n\n\tapp := fiber.New()\n\n\tapp.Use(New(Config{\n\t\tMax: 1,\n\t\tExpiration: 2 * time.Second,\n\t\tStorage: memory.New(),\n\t\tSkipSuccessfulRequests: true,\n\t\tLimiterMiddleware: FixedWindow{},\n\t}))\n\n\tapp.Get(\"/:status\", func(c *fiber.Ctx) error {\n\t\tif c.Params(\"status\") == \"fail\" {\n\t\t\treturn c.SendStatus(400)\n\t\t}\n\t\treturn c.SendStatus(200)\n\t})\n\n\tresp, err := app.Test(httptest.NewRequest(fiber.MethodGet, \"/success\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 200, resp.StatusCode)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/fail\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 400, resp.StatusCode)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/fail\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 429, resp.StatusCode)\n\n\ttime.Sleep(3 * time.Second)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/fail\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 400, resp.StatusCode)\n}", "func TestMock_WithTimeout(t *testing.T) {\n\tm := NewMock()\n\tctx, _ := m.WithTimeout(context.Background(), time.Second)\n\tm.Add(time.Second)\n\tselect {\n\tcase <-ctx.Done():\n\t\tif !errors.Is(ctx.Err(), context.DeadlineExceeded) {\n\t\t\tt.Error(\"invalid type of error returned when time is over\")\n\t\t}\n\tdefault:\n\t\tt.Error(\"context is not cancelled when time is over\")\n\t}\n}", "func TestPoolContext(t *testing.T) {\n\tctx, _ := context.WithTimeout(context.Background(), time.Second)\n\tdefer leaktest.CheckContext(ctx, t)()\n\n\tgo func() {\n\t\tfor {\n\t\t\ttime.Sleep(time.Second)\n\t\t}\n\t}()\n}", "func TestFlushWriteError(t *testing.T) {\n\tmockTr := new(mockTTransport)\n\ttr := NewTFramedTransport(mockTr)\n\tbuff := make([]byte, 10)\n\t_, err := tr.Write(buff)\n\tassert.Nil(t, err)\n\tmockTr.On(\"Write\", []byte{0, 0, 0, 10}).Return(4, nil)\n\tmockTr.On(\"Write\", buff).Return(0, errors.New(\"error\"))\n\n\tassert.Error(t, tr.Flush(context.TODO()))\n\tmockTr.AssertExpectations(t)\n}", "func TestRaftFreesReadOnlyMem(t *testing.T) {\n\tsm := newTestRaft(1, []uint64{1, 2}, 5, 1, NewMemoryStorage())\n\tdefer closeAndFreeRaft(sm)\n\tsm.becomeCandidate()\n\tsm.becomeLeader()\n\tsm.raftLog.commitTo(sm.raftLog.lastIndex())\n\n\tctx := []byte(\"ctx\")\n\n\t// leader starts linearizable read request.\n\t// more info: raft dissertation 6.4, step 2.\n\tsm.Step(pb.Message{From: 2, Type: pb.MsgReadIndex, Entries: []pb.Entry{{Data: ctx}}})\n\tmsgs := sm.readMessages()\n\tif len(msgs) != 1 {\n\t\tt.Fatalf(\"len(msgs) = %d, want 1\", len(msgs))\n\t}\n\tif msgs[0].Type != pb.MsgHeartbeat {\n\t\tt.Fatalf(\"type = %v, want MsgHeartbeat\", msgs[0].Type)\n\t}\n\tif !bytes.Equal(msgs[0].Context, ctx) {\n\t\tt.Fatalf(\"Context = %v, want %v\", msgs[0].Context, ctx)\n\t}\n\tif len(sm.readOnly.readIndexQueue) != 1 {\n\t\tt.Fatalf(\"len(readIndexQueue) = %v, want 1\", len(sm.readOnly.readIndexQueue))\n\t}\n\tif len(sm.readOnly.pendingReadIndex) != 1 {\n\t\tt.Fatalf(\"len(pendingReadIndex) = %v, want 1\", len(sm.readOnly.pendingReadIndex))\n\t}\n\tif _, ok := sm.readOnly.pendingReadIndex[string(ctx)]; !ok {\n\t\tt.Fatalf(\"can't find context %v in pendingReadIndex \", ctx)\n\t}\n\n\t// heartbeat responses from majority of followers (1 in this case)\n\t// acknowledge the authority of the leader.\n\t// more info: raft dissertation 6.4, step 3.\n\tsm.Step(pb.Message{From: 2, Type: pb.MsgHeartbeatResp, Context: ctx})\n\tif len(sm.readOnly.readIndexQueue) != 0 {\n\t\tt.Fatalf(\"len(readIndexQueue) = %v, want 0\", len(sm.readOnly.readIndexQueue))\n\t}\n\tif len(sm.readOnly.pendingReadIndex) != 0 {\n\t\tt.Fatalf(\"len(pendingReadIndex) = %v, want 0\", len(sm.readOnly.pendingReadIndex))\n\t}\n\tif _, ok := sm.readOnly.pendingReadIndex[string(ctx)]; ok {\n\t\tt.Fatalf(\"found context %v in pendingReadIndex, want none\", ctx)\n\t}\n}", "func TestGetCorruptFileAfterPut(t *testing.T) {\n\tvar (\n\t\tm = ioContext{\n\t\t\tt: t,\n\t\t\tnum: 1,\n\t\t\tfileSize: cos.KiB,\n\t\t}\n\n\t\tproxyURL = tools.RandomProxyURL(t)\n\t\tbaseParams = tools.BaseAPIParams(proxyURL)\n\t)\n\n\tif docker.IsRunning() {\n\t\tt.Skipf(\"%q requires setting xattrs, doesn't work with docker\", t.Name())\n\t}\n\n\tm.init(true /*cleanup*/)\n\tinitMountpaths(t, proxyURL)\n\n\ttools.CreateBucket(t, proxyURL, m.bck, nil, true /*cleanup*/)\n\n\tm.puts()\n\n\t// Test corrupting the file contents.\n\tobjName := m.objNames[0]\n\tfqn := findObjOnDisk(m.bck, objName)\n\ttlog.Logf(\"Corrupting object data %q: %s\\n\", objName, fqn)\n\terr := os.WriteFile(fqn, []byte(\"this file has been corrupted\"), cos.PermRWR)\n\ttassert.CheckFatal(t, err)\n\n\t_, err = api.GetObjectWithValidation(baseParams, m.bck, objName, nil)\n\ttassert.Errorf(t, err != nil, \"error is nil, expected error getting corrupted object\")\n}", "func TestNonDlmIdle(t *testing.T) {\n\tlogger.GetLogger().Log(logger.Debug, \"TestNonDlmIdle begin +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\\n\")\n\n\thostname := testutil.GetHostname()\n fmt.Println (\"Hostname: \", hostname);\n db, err := sql.Open(\"hera\", hostname + \":31002\")\n if err != nil {\n t.Fatal(\"Error starting Mux:\", err)\n return\n }\n\n\tdb.SetMaxIdleConns(0)\n\tdefer db.Close()\n\n fmt.Println (\"Open new connection\");\n ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n conn, err := db.Conn(ctx)\n if err != nil {\n t.Fatalf(\"Error getting connection %s\\n\", err.Error())\n }\n\n\ttx, _ := conn.BeginTx(ctx, nil)\n\tfmt.Println (\"Perform an insert & commit\");\n stmt, _ := tx.PrepareContext(ctx, \"/*TestBasic*/ insert into test_simple_table_2 (accountID, Name, Status) VALUES (12345, 'Linda Smith' , '111')\")\n\t_, err = stmt.Exec()\n\tif err != nil {\n t.Fatalf(\"Error preparing test (create row in table) %s\\n\", err.Error())\n }\n\terr = tx.Commit()\n if err != nil {\n t.Fatalf(\"Error commit %s\\n\", err.Error())\n }\n\tstmt, _ = conn.PrepareContext(ctx, \"/*cmd*/Select accountID, name from test_simple_table_2 where accountID=?\")\n rows, _ := stmt.Query(\"12345\")\n\tif !rows.Next() {\n t.Fatalf(\"Expected 1 row\")\n }\n\n\ttime.Sleep(7 * time.Second);\n\tfmt.Println (\"Verify idle timeout kicked in and server closes connection\");\n\tif ( testutil.RegexCount(\"Connection handler idle timeout\") < 1) {\n t.Fatalf (\"Error: Connection should close due to idle timeout\");\n }\n\n count := testutil.RegexCountFile (\"E.*OCCMUX.*idle_timeout_5000\", \"cal.log\")\n\tif (count > 0) {\n\t t.Fatalf (\"Error: should see idle_timeout event in CAL\");\n\t}\n\trows.Close() \n stmt.Close()\n\tcancel()\n\tconn.Close()\n\n\tlogger.GetLogger().Log(logger.Debug, \"TestNonDlmIdle done -------------------------------------------------------------\")\n}", "func TestWSConnDeadline(t *testing.T) {\n\t// Defines a server which just reads some data and if successful writes the\n\t// data back. This way the clients won't get blocked.\n\tdata := fastrand.Bytes(10)\n\tserverFunc := func(conn *WSConn) {\n\t\t// Read some data.\n\t\tb := make([]byte, len(data))\n\t\t_, err := io.ReadFull(conn, b)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\t// Write data back.\n\t\t_, _ = conn.Write(b)\n\t\treturn\n\t}\n\n\t// Start the server.\n\twst := newWSTester(serverFunc)\n\tdefer wst.Close()\n\n\t// Declare helper for determining deadline error.\n\tisErrDeadline := func(err error) bool {\n\t\tif err == nil {\n\t\t\treturn false\n\t\t}\n\t\treturn strings.Contains(err.Error(), \"i/o timeout\")\n\t}\n\n\t// Declare helper.\n\tcheckDeadline := func(wst *wsTester, writeDeadline, readDeadline func(*WSConn), readFail, writeFail bool) {\n\t\t// Get client.\n\t\tclient, err := wst.NewClient()\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\tdefer client.Close()\n\t\t// Set pre-write deadline.\n\t\twriteDeadline(client)\n\t\ttime.Sleep(100 * time.Millisecond)\n\t\t// Write some data. This should fail if \"writeFail\" is specified.\n\t\t_, err = client.Write(data)\n\t\tif err != nil && !writeFail {\n\t\t\tt.Fatal(err)\n\t\t} else if writeFail && !isErrDeadline(err) {\n\t\t\tt.Fatal(\"expected write to fail\", err)\n\t\t}\n\t\t// If writing was expected to fail we abort since we won't receive a\n\t\t// response from the server.\n\t\tif writeFail {\n\t\t\treturn\n\t\t}\n\t\t// Set post-write deadline.\n\t\treadDeadline(client)\n\t\ttime.Sleep(100 * time.Millisecond)\n\t\t// Try reading. This should fail if \"readFail\" is specified.\n\t\t_, err = io.ReadFull(client, make([]byte, len(data)))\n\t\tif err != nil && !readFail {\n\t\t\tt.Fatal(err)\n\t\t} else if readFail && !isErrDeadline(err) {\n\t\t\tt.Fatal(\"expected read to fail\", err)\n\t\t}\n\t}\n\n\t// Execute tests.\n\tdeadline := time.Now()\n\n\t// No deadline\n\tnoDeadline := func(client *WSConn) {\n\t\tif err := client.SetDeadline(time.Time{}); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}\n\tcheckDeadline(wst, noDeadline, noDeadline, false, false)\n\n\t// ReadDeadline\n\tcheckDeadline(wst, noDeadline, func(client *WSConn) {\n\t\tif err := client.SetReadDeadline(deadline); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}, true, false)\n\n\t// WriteDeadline\n\tcheckDeadline(wst, func(client *WSConn) {\n\t\tif err := client.SetWriteDeadline(deadline); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}, noDeadline, false, true)\n\n\t// Same again but with SetDeadline.\n\tcheckDeadline(wst, noDeadline, func(client *WSConn) {\n\t\tif err := client.SetDeadline(deadline); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}, true, false)\n\n\tcheckDeadline(wst, func(client *WSConn) {\n\t\tif err := client.SetDeadline(deadline); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}, noDeadline, false, true)\n}", "func (s *InMemorySuite) TestFIFOEviction(c *C) {\n\t// Limit timeline capacity to 1.\n\t// Necessary to easily test if events are evicted if max capacity is reached.\n\ttimeline := s.newLimitedTimeline(1)\n\tevents := []*pb.TimelineEvent{\n\t\tpb.NewNodeHealthy(s.clock.Now().Add(-time.Second), node), // older event should be evicted first\n\t\tpb.NewNodeDegraded(s.clock.Now(), node),\n\t}\n\texpected := []*pb.TimelineEvent{pb.NewNodeDegraded(s.clock.Now(), node)}\n\tcomment := Commentf(\"Expected node degraded event.\")\n\n\ttest.WithTimeout(func(ctx context.Context) {\n\t\t// Recording two statuses should result in timeline exceeding capacity.\n\t\tc.Assert(timeline.RecordEvents(ctx, events), IsNil, comment)\n\n\t\tactual, err := timeline.GetEvents(ctx, nil)\n\t\tc.Assert(err, IsNil, comment)\n\t\tc.Assert(actual, test.DeepCompare, expected, comment)\n\t})\n}", "func TestEmitContextEvents(t *testing.T) {\n\tassert := asserts.NewTesting(t, asserts.FailStop)\n\tmsh := mesh.New()\n\n\terr := msh.SpawnCells(NewTestBehavior(\"foo\"))\n\tassert.NoError(err)\n\n\tctxA := context.Background()\n\tctxB, cancel := context.WithTimeout(ctxA, 5*time.Millisecond)\n\tdefer cancel()\n\n\tmsh.Emit(\"foo\", event.WithContext(ctxA, \"set\", \"a\", 5))\n\tmsh.Emit(\"foo\", event.WithContext(ctxA, \"set\", \"b\", 5))\n\n\ttime.Sleep(20 * time.Millisecond)\n\n\tmsh.Emit(\"foo\", event.WithContext(ctxB, \"set\", \"b\", 10))\n\n\tpl, plc := event.NewReplyPayload()\n\n\tmsh.Emit(\"foo\", event.New(\"send\", pl))\n\n\tplr, err := plc.Wait(waitTimeout)\n\n\tassert.NoError(err)\n\tassert.Equal(plr.At(\"a\").AsInt(0), 5)\n\tassert.Equal(plr.At(\"b\").AsInt(0), 5)\n\n\terr = msh.Stop()\n\tassert.NoError(err)\n}", "func TestTruncateThenWrite(t *testing.T) {\n\tif runtime.GOOS == windowsOS {\n\t\tt.Skip(\"Rotation tests have been flaky on Windows. See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16331\")\n\t}\n\tt.Parallel()\n\n\ttempDir := t.TempDir()\n\tcfg := NewConfig().includeDir(tempDir)\n\tcfg.StartAt = \"beginning\"\n\toperator, emitCalls := buildTestManager(t, cfg)\n\toperator.persister = testutil.NewMockPersister(\"test\")\n\n\ttemp1 := openTemp(t, tempDir)\n\twriteString(t, temp1, \"testlog1\\ntestlog2\\n\")\n\n\toperator.poll(context.Background())\n\tdefer func() {\n\t\trequire.NoError(t, operator.Stop())\n\t}()\n\n\twaitForToken(t, emitCalls, []byte(\"testlog1\"))\n\twaitForToken(t, emitCalls, []byte(\"testlog2\"))\n\n\trequire.NoError(t, temp1.Truncate(0))\n\t_, err := temp1.Seek(0, 0)\n\trequire.NoError(t, err)\n\n\twriteString(t, temp1, \"testlog3\\n\")\n\toperator.poll(context.Background())\n\twaitForToken(t, emitCalls, []byte(\"testlog3\"))\n\texpectNoTokens(t, emitCalls)\n}", "func TestMock_WithDeadline(t *testing.T) {\n\tm := NewMock()\n\tctx, _ := m.WithDeadline(context.Background(), m.Now().Add(time.Second))\n\tm.Add(time.Second)\n\tselect {\n\tcase <-ctx.Done():\n\t\tif !errors.Is(ctx.Err(), context.DeadlineExceeded) {\n\t\t\tt.Error(\"invalid type of error returned when deadline exceeded\")\n\t\t}\n\tdefault:\n\t\tt.Error(\"context is not cancelled when deadline exceeded\")\n\t}\n}", "func Test_Limiter_Sliding_Window_Custom_Storage_Skip_Successful_Requests(t *testing.T) {\n\tt.Parallel()\n\t// Test concurrency using a default store\n\n\tapp := fiber.New()\n\n\tapp.Use(New(Config{\n\t\tMax: 1,\n\t\tExpiration: 2 * time.Second,\n\t\tStorage: memory.New(),\n\t\tSkipSuccessfulRequests: true,\n\t\tLimiterMiddleware: SlidingWindow{},\n\t}))\n\n\tapp.Get(\"/:status\", func(c *fiber.Ctx) error {\n\t\tif c.Params(\"status\") == \"fail\" {\n\t\t\treturn c.SendStatus(400)\n\t\t}\n\t\treturn c.SendStatus(200)\n\t})\n\n\tresp, err := app.Test(httptest.NewRequest(fiber.MethodGet, \"/success\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 200, resp.StatusCode)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/fail\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 400, resp.StatusCode)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/fail\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 429, resp.StatusCode)\n\n\ttime.Sleep(4 * time.Second)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/fail\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 400, resp.StatusCode)\n}", "func (w *HotCache) ExpiredWriteItems(region *core.RegionInfo) []*HotPeerStat {\n\treturn w.writeFlow.CollectExpiredItems(region)\n}", "func TestContextIsAccessibleWithGo17Context(t *testing.T) {\n\tsuccHand := func(w http.ResponseWriter, r *http.Request) {\n\t\tr = r.WithContext(context.WithValue(r.Context(), \"dummykey\", \"dummyval\"))\n\t\ttoken := Token(r)\n\t\tif token == \"\" {\n\t\t\tt.Errorf(\"Token is inaccessible in the success handler\")\n\t\t}\n\t}\n\n\thand := New()\n\tchain := alice.New(hand.Handler).Then(http.HandlerFunc(succHand))\n\n\t// we need a request that passes. Let's just use a safe method for that.\n\treq := dummyGet()\n\twriter := httptest.NewRecorder()\n\n\tchain.ServeHTTP(writer, req)\n}", "func TestUnsafeGracefulClose(t *testing.T) {\n\tnMsgs := 10\n\tkp := newFakeProd(nMsgs)\n\taw := NewUnsafeWriter(testTopic, kp)\n\n\tvar doneWg, startedWg sync.WaitGroup\n\n\tdoneWg.Add(nMsgs)\n\tstartedWg.Add(nMsgs)\n\tfor _ = range iter.N(nMsgs) {\n\t\tgo func() {\n\t\t\tstartedWg.Done()\n\t\t\tn, err := aw.Write(testBytes)\n\n\t\t\tif n != tbLen {\n\t\t\t\tt.Errorf(\"Wrote %d bytes, expected %d\", n, tbLen)\n\t\t\t}\n\n\t\t\tif err != nil {\n\t\t\t\tt.Error(err)\n\t\t\t}\n\t\t\tdoneWg.Done()\n\t\t}()\n\t}\n\tstartedWg.Wait()\n\n\tgo func() {\n\t\ttime.Sleep(50 * time.Millisecond)\n\t\tif err := aw.Close(); err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\ttime.Sleep(80 * time.Millisecond)\n\tgo kp.allSucc(defChk, t)\n\tdoneWg.Wait()\n\n\t// wait a little bit more so kp.allSucc has a chance to do stuff. Brittle and stupid but Works For Me™\n\ttime.Sleep(80 * time.Millisecond)\n\n\tif kp.count() != int32(nMsgs) {\n\t\tt.Fatalf(\"%d messages delivered to Successes(), expected %d\", kp.count(), nMsgs)\n\t}\n}", "func TestCleanupExpiredSinkService_WithTrashcanedGcsMirrorRevisions(t *testing.T) {\n\tt.Skip()\n\n\thttpMockHandler.Start()\n\tdefer httpMockHandler.Stop()\n\n\tconfigProvider := &MockImpersonatedTokenConfigProvider{\n\t\tTargetPrincipal: \"[email protected]\",\n\t\tError: nil,\n\t}\n\n\thttpMockHandler.Register(mock.ImpersonationHTTPMock)\n\tctx := context.Background()\n\n\tbackupRepository, err := repository.NewBackupRepository(ctx, secret.NewEnvSecretProvider())\n\trequire.NoErrorf(t, err, \"backupRepository should be instantiate\")\n\n\tservice, err := newCleanupExpiredSinkService(ctx, configProvider, secret.NewEnvSecretProvider())\n\trequire.NoErrorf(t, err, \"CleanupBackupService should be instantiate\")\n\n\tbackup := cleanupBackupServiceBackup(cleanupServiceBackupID, repository.Prepared)\n\tbackup.Strategy = repository.Mirror\n\tbackup.Type = repository.CloudStorage\n\tbackup.CreatedTimestamp = time.Date(2019, 3, 14, 14, 57, 00, 0, time.Local)\n\tbackup.CloudStorageOptions = repository.CloudStorageOptions{Bucket: \"greg_test_bucket\"}\n\n\t_, err = backupRepository.AddBackup(ctx, backup)\n\trequire.NoError(t, err, \"should add new backup\")\n\tdefer func() { deleteBackup(cleanupServiceBackupID) }()\n\n\t_, stdErr, err := captureStderr(func() {\n\t\tservice.Run(ctx)\n\t})\n\n\trequire.NoError(t, err)\n\t// FIXME currently the tests failed because we didn't find any way to mock GRPCConn, thus this tests checks for the failing error message\n\t// FIXME: any code which changes this behavior must be aware of this or rollback this bypass\n\t//logMsg :=\"[START] Deleting old CloudStorage revision\"\n\tlogMsg := \"Expected OAuth 2 access token, login cookie or other valid authentication credential.\"\n\tassert.Containsf(t, strings.TrimSpace(stdErr), logMsg, \"Run should not write log message %q but it logged\\n\\t%s\", logMsg, stdErr)\n\n\t//sourceTrashcanRepository, err := repository.NewSourceTrashcanRepository(ctx)\n\t//require.NoError(t, err, \"sourceMetadataRepository should be instantiate\")\n\t//var sources []repository.SourceTrashcan\n\t//sources = append(sources, repository.SourceTrashcan{BackupID: cleanupServiceBackupID, Source: \"test_storage/2/10.txt\"})\n\t//exists, err := sourceTrashcanRepository.FilterExistingEntries(ctx, sources)\n\t//require.NoError(t, err)\n\t//assert.Len(t, exists, 1)\n}", "func TestExpire(t *testing.T) {\n\tgo drain.Archiver.Expire()\n\ttime.Sleep(2 * time.Second)\n\n\t// finish expire loop\n\tdrain.Archiver.(*drain.BoltArchive).Done <- true\n\n\t// test successful clean\n\tappMsgs, err := drain.Archiver.Slice(\"app\", \"\", []string{\"\"}, 0, 0, 100, 0)\n\tif err != nil {\n\t\tt.Error(err)\n\t\tt.FailNow()\n\t}\n\t// compare written message to original\n\tif len(appMsgs) != 0 {\n\t\tt.Errorf(\"%q doesn't match expected out\", appMsgs)\n\t\tt.FailNow()\n\t}\n\n\t// test successful clean\n\tdepMsgs, err := drain.Archiver.Slice(\"deploy\", \"\", []string{\"\"}, 0, 0, 100, 0)\n\tif err != nil {\n\t\tt.Error(err)\n\t\tt.FailNow()\n\t}\n\t// compare written message to original\n\tif len(depMsgs) != 0 {\n\t\tt.Errorf(\"%q doesn't match expected out\", depMsgs)\n\t\tt.FailNow()\n\t}\n\n\tdrain.Archiver.(*drain.BoltArchive).Close()\n\n}", "func (lru *LRU) FlushExpired() {\n\tif lru.removalFunc == nil || lru.ttl == 0 {\n\t\treturn\n\t}\n\n\tlru.mu.Lock()\n\tdefer lru.mu.Unlock()\n\n\tcutoff := time.Now().Add(-1 * lru.ttl)\n\tvar next *list.Element\n\tfor e := lru.list.Front(); e != nil; e = next {\n\t\t// get the next before removal below which causes Next to return nil\n\t\tnext = e.Next()\n\t\tn := e.Value.(*entry)\n\t\tif cutoff.After(n.ts) {\n\t\t\tlru.list.Remove(e)\n\t\t\tdelete(lru.table, n.Key)\n\t\t\tlru.removalFunc(n.Key, n.Value)\n\t\t}\n\t}\n}", "func TestMock_WithDeadlineLaterThanCurrent(t *testing.T) {\n\tm := NewMock()\n\tctx, _ := m.WithDeadline(context.Background(), m.Now().Add(time.Second))\n\tctx, _ = m.WithDeadline(ctx, m.Now().Add(10*time.Second))\n\tm.Add(time.Second)\n\tselect {\n\tcase <-ctx.Done():\n\t\tif !errors.Is(ctx.Err(), context.DeadlineExceeded) {\n\t\t\tt.Error(\"invalid type of error returned when deadline exceeded\")\n\t\t}\n\tdefault:\n\t\tt.Error(\"context is not cancelled when deadline exceeded\")\n\t}\n}", "func TestShardWriter_Write_ErrReadTimeout(t *testing.T) {\n\tln, err := net.Listen(\"tcp\", \"127.0.0.1:0\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tw := coordinator.NewShardWriter(time.Millisecond, 1)\n\tw.MetaClient = &metaClient{host: ln.Addr().String()}\n\tnow := time.Now()\n\n\tshardID := uint64(1)\n\townerID := uint64(2)\n\tvar points []models.Point\n\tpoints = append(points, models.MustNewPoint(\n\t\t\"cpu\", models.Tags{\"host\": \"server01\"}, map[string]interface{}{\"value\": int64(100)}, now,\n\t))\n\n\tif err := w.WriteShard(shardID, ownerID, points); err == nil || !strings.Contains(err.Error(), \"i/o timeout\") {\n\t\tt.Fatalf(\"unexpected error: %s\", err)\n\t}\n}", "func TestReadWriteTransaction_ErrorReturned(t *testing.T) {\n\tt.Parallel()\n\tctx := context.Background()\n\tserver, client, teardown := setupMockedTestServer(t)\n\tdefer teardown()\n\n\twant := errors.New(\"an error\")\n\t_, got := client.ReadWriteTransaction(ctx, func(context.Context, *ReadWriteTransaction) error {\n\t\treturn want\n\t})\n\tif got != want {\n\t\tt.Fatalf(\"got %+v, want %+v\", got, want)\n\t}\n\trequests := drainRequestsFromServer(server.TestSpanner)\n\tif err := compareRequests([]interface{}{\n\t\t&sppb.BatchCreateSessionsRequest{}}, requests); err != nil {\n\t\t// TODO: remove this once the session pool maintainer has been changed\n\t\t// so that is doesn't delete sessions already during the first\n\t\t// maintenance window.\n\t\t// If we failed to get 3, it might have because - due to timing - we got\n\t\t// a fourth request. If this request is DeleteSession, that's OK and\n\t\t// expected.\n\t\tif err := compareRequests([]interface{}{\n\t\t\t&sppb.BatchCreateSessionsRequest{},\n\t\t\t&sppb.RollbackRequest{}}, requests); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}\n}", "func Test_Ctx_Locals(t *testing.T) {\n\tapp := New()\n\tapp.Use(func(c *Ctx) {\n\t\tc.Locals(\"john\", \"doe\")\n\t\tc.Next()\n\t})\n\tapp.Get(\"/test\", func(c *Ctx) {\n\t\tutils.AssertEqual(t, \"doe\", c.Locals(\"john\"))\n\t})\n\tresp, err := app.Test(httptest.NewRequest(MethodGet, \"/test\", nil))\n\tutils.AssertEqual(t, nil, err, \"app.Test(req)\")\n\tutils.AssertEqual(t, StatusOK, resp.StatusCode, \"Status code\")\n}", "func verifyCacheExpiration(t *testing.T, sweepSettings cache.SweepSettings, wantEvicted []blob.ID) {\n\tcacheData := blobtesting.DataMap{}\n\n\t// on Windows, the time does not always move forward (sometimes clock.Now() returns exactly the same value for consecutive invocations)\n\t// this matters here so we return a fake clock.Now() function that always moves forward.\n\tvar currentTimeMutex sync.Mutex\n\n\tcurrentTime := clock.Now()\n\n\tmovingTimeFunc := func() time.Time {\n\t\tcurrentTimeMutex.Lock()\n\t\tdefer currentTimeMutex.Unlock()\n\n\t\tcurrentTime = currentTime.Add(1 * time.Millisecond)\n\n\t\treturn currentTime\n\t}\n\tcacheStorage := blobtesting.NewMapStorage(cacheData, nil, movingTimeFunc)\n\n\tunderlyingStorage := newUnderlyingStorageForContentCacheTesting(t)\n\n\tctx := testlogging.Context(t)\n\tcc, err := cache.NewContentCache(ctx, underlyingStorage, cache.Options{\n\t\tStorage: cacheStorage.(cache.Storage),\n\t\tSweep: sweepSettings,\n\t\tTimeNow: movingTimeFunc,\n\t}, nil)\n\n\trequire.NoError(t, err)\n\n\tdefer cc.Close(ctx)\n\n\tvar tmp gather.WriteBuffer\n\tdefer tmp.Close()\n\n\tconst underlyingBlobID = \"content-4k\"\n\n\terr = cc.GetContent(ctx, \"a\", underlyingBlobID, 0, -1, &tmp) // 4k\n\trequire.NoError(t, err)\n\terr = cc.GetContent(ctx, \"b\", underlyingBlobID, 0, -1, &tmp) // 4k\n\trequire.NoError(t, err)\n\terr = cc.GetContent(ctx, \"c\", underlyingBlobID, 0, -1, &tmp) // 4k\n\trequire.NoError(t, err)\n\terr = cc.GetContent(ctx, \"d\", underlyingBlobID, 0, -1, &tmp) // 4k\n\trequire.NoError(t, err)\n\n\t// delete underlying storage blob to identify cache items that have been evicted\n\t// all other items will be fetched from the cache.\n\trequire.NoError(t, underlyingStorage.DeleteBlob(ctx, underlyingBlobID))\n\n\tfor _, blobID := range []blob.ID{\"a\", \"b\", \"c\", \"d\"} {\n\t\tif slices.Contains(wantEvicted, blobID) {\n\t\t\trequire.ErrorIs(t, cc.GetContent(ctx, string(blobID), underlyingBlobID, 0, -1, &tmp), blob.ErrBlobNotFound, \"expected item not found %v\", blobID)\n\t\t} else {\n\t\t\trequire.NoError(t, cc.GetContent(ctx, string(blobID), underlyingBlobID, 0, -1, &tmp), \"expected item to be found %v\", blobID)\n\t\t}\n\t}\n}", "func BenchmarkWriterReset(b *testing.B) {\n\tb.ReportAllocs()\n\n\tzw := lz4.NewWriter(nil)\n\tsrc := mustLoadFile(\"testdata/gettysburg.txt\")\n\tvar buf bytes.Buffer\n\n\tfor n := 0; n < b.N; n++ {\n\t\tbuf.Reset()\n\t\tzw.Reset(&buf)\n\n\t\t_, _ = zw.Write(src)\n\t\t_ = zw.Close()\n\t}\n}", "func TestEngine_WritePoints_ErrPointsWriter(t *testing.T) {\n\te := OpenDefaultEngine()\n\tdefer e.Close()\n\n\t// Ensure points writer returns an error.\n\te.PointsWriter.WritePointsFn = func(a []tsdb.Point) error { return errors.New(\"marker\") }\n\n\t// Write to engine.\n\tif err := e.WritePoints(nil, nil, nil); err == nil || err.Error() != `write points: marker` {\n\t\tt.Fatal(err)\n\t}\n}", "func (tx *WriteTx) RunWithContext(ctx context.Context) error {\n\tif tx.err != nil {\n\t\treturn tx.err\n\t}\n\tinput, err := tx.input()\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = retry(ctx, func() error {\n\t\tout, err := tx.db.client.TransactWriteItemsWithContext(ctx, input)\n\t\tif tx.cc != nil && out != nil {\n\t\t\tfor _, cc := range out.ConsumedCapacity {\n\t\t\t\taddConsumedCapacity(tx.cc, cc)\n\t\t\t}\n\t\t}\n\t\treturn err\n\t})\n\treturn err\n}", "func TestNoWriteAfterServeHTTPReturns(t *testing.T) {\n\tcfdHTTP2Conn, edgeTCPConn := newTestHTTP2Connection()\n\n\tctx, cancel := context.WithCancel(context.Background())\n\tvar wg sync.WaitGroup\n\n\tserverDone := make(chan struct{})\n\tgo func() {\n\t\tdefer close(serverDone)\n\t\tcfdHTTP2Conn.Serve(ctx)\n\t}()\n\n\tedgeTransport := http2.Transport{}\n\tedgeHTTP2Conn, err := edgeTransport.NewClientConn(edgeTCPConn)\n\trequire.NoError(t, err)\n\tmessage := []byte(t.Name())\n\n\tfor i := 0; i < 100; i++ {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\treadPipe, writePipe := io.Pipe()\n\t\t\treqCtx, reqCancel := context.WithCancel(ctx)\n\t\t\treq, err := http.NewRequestWithContext(reqCtx, http.MethodGet, \"http://localhost:8080/ws/flaky\", readPipe)\n\t\t\trequire.NoError(t, err)\n\t\t\treq.Header.Set(InternalUpgradeHeader, WebsocketUpgrade)\n\n\t\t\tresp, err := edgeHTTP2Conn.RoundTrip(req)\n\t\t\trequire.NoError(t, err)\n\t\t\t// http2RespWriter should rewrite status 101 to 200\n\t\t\trequire.Equal(t, http.StatusOK, resp.StatusCode)\n\n\t\t\twg.Add(1)\n\t\t\tgo func() {\n\t\t\t\tdefer wg.Done()\n\t\t\t\tfor {\n\t\t\t\t\tselect {\n\t\t\t\t\tcase <-reqCtx.Done():\n\t\t\t\t\t\treturn\n\t\t\t\t\tdefault:\n\t\t\t\t\t}\n\t\t\t\t\t_ = wsutil.WriteClientBinary(writePipe, message)\n\t\t\t\t}\n\t\t\t}()\n\n\t\t\ttime.Sleep(time.Millisecond * 100)\n\t\t\treqCancel()\n\t\t}()\n\t}\n\n\twg.Wait()\n\tcancel()\n\t<-serverDone\n}", "func Test_Ctx_Fresh(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Request.Header.Set(HeaderIfNoneMatch, \"*\")\n\tctx.Fasthttp.Request.Header.Set(HeaderCacheControl, \"no-cache\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Request.Header.Set(HeaderIfNoneMatch, \"*\")\n\tctx.Fasthttp.Request.Header.Set(HeaderCacheControl, \",no-cache,\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Request.Header.Set(HeaderIfNoneMatch, \"*\")\n\tctx.Fasthttp.Request.Header.Set(HeaderCacheControl, \"aa,no-cache,\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Request.Header.Set(HeaderIfNoneMatch, \"*\")\n\tctx.Fasthttp.Request.Header.Set(HeaderCacheControl, \",no-cache,bb\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Request.Header.Set(HeaderIfNoneMatch, \"675af34563dc-tr34\")\n\tctx.Fasthttp.Request.Header.Set(HeaderCacheControl, \"public\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Request.Header.Set(HeaderIfNoneMatch, \"a, b\")\n\tctx.Fasthttp.Response.Header.Set(HeaderETag, \"c\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Response.Header.Set(HeaderETag, \"a\")\n\tutils.AssertEqual(t, true, ctx.Fresh())\n\n\tctx.Fasthttp.Request.Header.Set(HeaderIfModifiedSince, \"xxWed, 21 Oct 2015 07:28:00 GMT\")\n\tctx.Fasthttp.Response.Header.Set(HeaderLastModified, \"xxWed, 21 Oct 2015 07:28:00 GMT\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Response.Header.Set(HeaderLastModified, \"Wed, 21 Oct 2015 07:28:00 GMT\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n\n\tctx.Fasthttp.Request.Header.Set(HeaderIfModifiedSince, \"Wed, 21 Oct 2015 07:28:00 GMT\")\n\tutils.AssertEqual(t, false, ctx.Fresh())\n}", "func TestSBSExistingWriter(t *testing.T) {\n\ttest(t,\n\t\tusers(\"alice\", \"bob\"),\n\t\tinPrivateTlf(\"alice,bob,bob@twitter\"),\n\t\tas(alice,\n\t\t\tmkfile(\"alice.txt\", \"hello bob\"),\n\t\t),\n\t\tas(bob,\n\t\t\tmkfile(\"bob.txt\", \"hello alice\"),\n\t\t\tread(\"alice.txt\", \"hello bob\"),\n\t\t),\n\t\tas(alice,\n\t\t\tread(\"bob.txt\", \"hello alice\"),\n\t\t),\n\n\t\taddNewAssertion(\"bob\", \"bob@twitter\"),\n\t\tas(alice,\n\t\t\t// TODO: Ideally, we wouldn't have to do this,\n\t\t\t// and we'd just wait for a rekey.\n\t\t\trekey(),\n\t\t),\n\n\t\tinPrivateTlf(\"alice,bob\"),\n\t\tas(alice,\n\t\t\tread(\"alice.txt\", \"hello bob\"),\n\t\t\tread(\"bob.txt\", \"hello alice\"),\n\t\t),\n\t\tas(bob,\n\t\t\tread(\"alice.txt\", \"hello bob\"),\n\t\t\tread(\"bob.txt\", \"hello alice\"),\n\t\t),\n\n\t\tinPrivateTlfNonCanonical(\"alice,bob,bob@twitter\", \"alice,bob\"),\n\t\tas(alice,\n\t\t\tread(\"alice.txt\", \"hello bob\"),\n\t\t\tread(\"bob.txt\", \"hello alice\"),\n\t\t),\n\t\tas(bob,\n\t\t\tread(\"alice.txt\", \"hello bob\"),\n\t\t\tread(\"bob.txt\", \"hello alice\"),\n\t\t),\n\t)\n}", "func testContext(t *testing.T) (context.Context, func()) {\n\tctxTest, completeTest := context.WithTimeout(context.Background(), 1100*time.Millisecond)\n\tgo func() {\n\t\tafter := time.NewTimer(1 * time.Second)\n\t\tselect {\n\t\tcase <-ctxTest.Done():\n\t\t\tafter.Stop()\n\t\tcase <-after.C:\n\t\t\trequire.Fail(t, \"test timed out\")\n\t\t}\n\t}()\n\treturn ctxTest, completeTest\n}", "func (tc *TestCase) TestCorruptLoseTract() error {\n\t// We need at least five tractservers.\n\tif tc.clusterCfg.Tractservers < 5 {\n\t\treturn fmt.Errorf(\"need at least five tractservers for TestCorruptTract\")\n\t}\n\n\t// Create a blob and write some data to it.\n\tblob, err := tc.c.Create()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdata := makeRandom(1 * mb)\n\tblob.Seek(0, os.SEEK_SET)\n\tif n, err := blob.Write(data); err != nil || n != len(data) {\n\t\treturn err\n\t}\n\n\t// Pick two random tractservers that own the first tract. We will do\n\t// something evil to them.\n\ttracts, err := tc.c.GetTracts(context.Background(), blob.ID(), 0, 1)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(tracts) == 0 {\n\t\treturn fmt.Errorf(\"The blob has no tracts\")\n\t}\n\tfirstTract := tracts[0]\n\tfirstTS := int(rand.Uint32()) % len(firstTract.Hosts)\n\tsecondTS := (firstTS + 1) % len(firstTract.Hosts)\n\n\tcapture := tc.captureLogs()\n\n\t// Corrupt the replica on the first picked ts.\n\tif err := tc.corruptTract(firstTract.Tract, tc.bc.FindByServiceAddress(firstTract.Hosts[firstTS]), 1234); err != nil {\n\t\treturn err\n\t}\n\t// Kill the second picked ts.\n\tproc, perr := tc.getTractserverProc(firstTract.Tract, secondTS)\n\tif perr != nil {\n\t\treturn perr\n\t}\n\tproc.Stop()\n\n\t// Trigger a rereplication request.\n\tif err := tc.triggerRereplRequest(firstTract.Tract); err != nil {\n\t\treturn err\n\t}\n\n\t// Wait for a curator to log success.\n\tlog.Infof(\"waiting for rerepl...\")\n\tif err := capture.WaitFor(\n\t\tfmt.Sprintf(\"c:@@@ rerepl %v succeeded\", firstTract.Tract)); err != nil {\n\t\treturn err\n\t}\n\n\t// Now a write should succeed.\n\tblob.Seek(0, os.SEEK_SET)\n\tn, werr := blob.Write([]byte(\"spicy sichuan food\"))\n\tif werr != nil {\n\t\treturn werr\n\t}\n\tlog.Infof(\"wrote %d bytes\", n)\n\n\treturn nil\n}", "func TestTransactionIdleTimeout(t *testing.T) {\n\tlogger.GetLogger().Log(logger.Debug, \"TestTransactionIdleTimeout begin +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\\n\")\n\n\thostname := testutil.GetHostname()\n fmt.Println (\"Hostname: \", hostname);\n db, err := sql.Open(\"hera\", hostname + \":31002\")\n if err != nil {\n t.Fatal(\"Error starting Mux:\", err)\n return\n }\n\n\tdb.SetMaxIdleConns(0)\n\tdefer db.Close()\n\n\tvar wait_second int\n wait_second = 8\n\tfmt.Println (\"Verify idle timeout will not kick in, but tnx timeout will kick in for DML transaction\")\n\ttestutil.RunDMLCommitLater(\"/*cmd*/insert into test_simple_table_2 (accountID, Name, Status) VALUES (12345, 'Linda Smith' , '111')\", wait_second)\n\n fmt.Println (\"Open new connection to check fetch result\");\n ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n // cleanup and insert one row in the table\n conn, err := db.Conn(ctx)\n if err != nil {\n t.Fatalf(\"Error getting connection %s\\n\", err.Error())\n }\n\n fmt.Println (\"Verify fetch request returns correct result\");\n stmt, _ := conn.PrepareContext(ctx, \"/*TestBasic*/Select name, status from test_simple_table_2 where accountID=:accountID\")\n rows, _ := stmt.Query(sql.Named(\"accountID\", \"12345\"))\n if rows.Next() {\n t.Fatalf(\"Expected 0 row\")\n }\n\n\ttime.Sleep(2 * time.Second)\n\n\tif ( testutil.RegexCount(\"Connection handler idle timeout\") < 1) {\n t.Fatalf (\"Error: should have txn timeout\");\n }\n\n\tif ( testutil.RegexCountFile(\"E.*MUX.*idle_timeout_5000\", \"cal.log\") < 1) {\n t.Fatalf (\"Error: should have txn timeout\");\n }\n\n\tfmt.Println (\"Verify idle timeout event is NOT seen in CALlog\")\n count := testutil.RegexCountFile (\"E.*MUX.*idle_timeout_3000\", \"cal.log\")\n\tif (count > 0) {\n\t t.Fatalf (\"Error: should NOT see idle_timeout event\");\n\t}\n\n\trows.Close()\t\n stmt.Close()\n cancel()\n conn.Close()\n\ttestutil.DoDefaultValidation(t)\n\tlogger.GetLogger().Log(logger.Debug, \"TestTransactionIdleTimeout done -------------------------------------------------------------\")\n}", "func TestMock_WithDeadlineImmediate(t *testing.T) {\n\tm := NewMock()\n\tctx, _ := m.WithDeadline(context.Background(), m.Now().Add(-time.Second))\n\tselect {\n\tcase <-ctx.Done():\n\t\tif !errors.Is(ctx.Err(), context.DeadlineExceeded) {\n\t\t\tt.Error(\"invalid type of error returned when deadline has already passed\")\n\t\t}\n\tdefault:\n\t\tt.Error(\"context is not cancelled when deadline has already passed\")\n\t}\n}", "func cleanContext(ctx context.Context) context.Context {\n\treturn datastore.WithoutTransaction(ctx)\n}", "func (s *PipelinedCopySuite) TestFailedRW(c *C) {\n\tsyncChan := make(chan bool, 1)\n\treadCount := 0\n\trw := &fakeReaderWriter{\n\t\treader: func(buf []byte) (int, error) {\n\t\t\tif readCount == 1 {\n\t\t\t\tselect {\n\t\t\t\tcase <-syncChan:\n\t\t\t\t\treturn 0, fmt.Errorf(\"second read fails\")\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treadCount++\n\t\t\t\treturn len(buf), nil\n\t\t\t}\n\n\t\t},\n\t\twriter: func(b []byte) (int, error) {\n\t\t\tclose(syncChan)\n\t\t\treturn 0, fmt.Errorf(\"write fails\")\n\t\t},\n\t}\n\t_, err := PipelinedCopy(rw, rw, 4, 10, 9)\n\tc.Assert(err, NotNil)\n}", "func TestCompactionRemoveTemp(t *testing.T) {\n\tctx := context.Background()\n\n\ttempDir := t.TempDir()\n\n\tf := NewFactory()\n\tcfg := f.CreateDefaultConfig().(*Config)\n\tcfg.Directory = tempDir\n\n\textension, err := f.CreateExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg)\n\trequire.NoError(t, err)\n\n\tse, ok := extension.(storage.Extension)\n\trequire.True(t, ok)\n\n\tclient, err := se.GetClient(\n\t\tctx,\n\t\tcomponent.KindReceiver,\n\t\tnewTestEntity(\"my_component\"),\n\t\t\"\",\n\t)\n\trequire.NoError(t, err)\n\tt.Cleanup(func() {\n\t\trequire.NoError(t, client.Close(ctx))\n\t})\n\n\t// check if only db exists in tempDir\n\tfiles, err := os.ReadDir(tempDir)\n\trequire.NoError(t, err)\n\trequire.Equal(t, 1, len(files))\n\tfileName := files[0].Name()\n\n\t// perform compaction in the same directory\n\tc, ok := client.(*fileStorageClient)\n\trequire.True(t, ok)\n\terr = c.Compact(tempDir, cfg.Timeout, 1)\n\trequire.NoError(t, err)\n\tt.Cleanup(func() {\n\t\trequire.NoError(t, client.Close(ctx))\n\t})\n\n\t// check if only db exists in tempDir\n\tfiles, err = os.ReadDir(tempDir)\n\trequire.NoError(t, err)\n\trequire.Equal(t, 1, len(files))\n\trequire.Equal(t, fileName, files[0].Name())\n\n\t// perform compaction in different directory\n\temptyTempDir := t.TempDir()\n\n\tc, ok = client.(*fileStorageClient)\n\trequire.True(t, ok)\n\terr = c.Compact(emptyTempDir, cfg.Timeout, 1)\n\trequire.NoError(t, err)\n\tt.Cleanup(func() {\n\t\trequire.NoError(t, client.Close(ctx))\n\t})\n\n\t// check if emptyTempDir is empty after compaction\n\tfiles, err = os.ReadDir(emptyTempDir)\n\trequire.NoError(t, err)\n\trequire.Equal(t, 0, len(files))\n}", "func TestEngine_WritePoints_PointsWriter(t *testing.T) {\n\te := OpenDefaultEngine()\n\tdefer e.Close()\n\n\t// Points to be inserted.\n\tpoints := []tsdb.Point{\n\t\ttsdb.NewPoint(\"cpu\", tsdb.Tags{}, tsdb.Fields{}, time.Unix(0, 1)),\n\t\ttsdb.NewPoint(\"cpu\", tsdb.Tags{}, tsdb.Fields{}, time.Unix(0, 0)),\n\t\ttsdb.NewPoint(\"cpu\", tsdb.Tags{}, tsdb.Fields{}, time.Unix(1, 0)),\n\n\t\ttsdb.NewPoint(\"cpu\", tsdb.Tags{\"host\": \"serverA\"}, tsdb.Fields{}, time.Unix(0, 0)),\n\t}\n\n\t// Mock points writer to ensure points are passed through.\n\tvar invoked bool\n\te.PointsWriter.WritePointsFn = func(a []tsdb.Point) error {\n\t\tinvoked = true\n\t\tif !reflect.DeepEqual(points, a) {\n\t\t\tt.Fatalf(\"unexpected points: %#v\", a)\n\t\t}\n\t\treturn nil\n\t}\n\n\t// Write points against two separate series.\n\tif err := e.WritePoints(points, nil, nil); err != nil {\n\t\tt.Fatal(err)\n\t} else if !invoked {\n\t\tt.Fatal(\"PointsWriter.WritePoints() not called\")\n\t}\n}", "func (m *LocalExecutorManager) purgeExpiredEntries() {\n\tfor {\n\t\tfunc() {\n\t\t\tm.Lock()\n\t\t\tcutoverLimit := time.Now().Add(-24 * time.Hour)\n\t\t\tfor id, executorStatus := range m.id2ExecutorStatus {\n\t\t\t\tif executorStatus.LastAccessTime.Before(cutoverLimit) {\n\t\t\t\t\tdelete(m.id2ExecutorStatus, id)\n\t\t\t\t}\n\t\t\t}\n\t\t\tm.Unlock()\n\t\t\ttime.Sleep(1 * time.Hour)\n\t\t}()\n\t}\n}", "func TestFreezerModifyRollback(t *testing.T) {\n\tt.Parallel()\n\n\tf, dir := newFreezerForTesting(t, freezerTestTableDef)\n\n\ttheError := errors.New(\"oops\")\n\t_, err := f.ModifyAncients(func(op database.AncientWriteOp) error {\n\t\t// Append three items. This creates two files immediately,\n\t\t// because the table size limit of the test freezer is 2048.\n\t\trequire.NoError(t, op.AppendRaw(\"test\", 0, make([]byte, 2048)))\n\t\trequire.NoError(t, op.AppendRaw(\"test\", 1, make([]byte, 2048)))\n\t\trequire.NoError(t, op.AppendRaw(\"test\", 2, make([]byte, 2048)))\n\t\treturn theError\n\t})\n\tif err != theError {\n\t\tt.Errorf(\"ModifyAncients returned wrong error %q\", err)\n\t}\n\tcheckAncientCount(t, f, \"test\", 0)\n\tf.Close()\n\n\t// Reopen and check that the rolled-back data doesn't reappear.\n\ttables := map[string]bool{\"test\": true}\n\tf2, err := NewFreezer(dir, \"\", false, 2049, tables)\n\tif err != nil {\n\t\tt.Fatalf(\"can't reopen freezer after failed ModifyAncients: %v\", err)\n\t}\n\tdefer f2.Close()\n\tcheckAncientCount(t, f2, \"test\", 0)\n}", "func TestLogWriteFail(t *testing.T) {\n\tcm := NewChatManager(&FailWriter{}, historySize)\n\tdc := dummyconn.NewDummyConn()\n\terr := cm.Join(\"testuser\", dc)\n\tif err != nil {\n\t\tt.Fatalf(\"Unexpected error: %s\", err)\n\t}\n\n\tbuf := make([]byte, bufSize)\n\tn, err := dc.Read(buf)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\trMsg := buf[:n]\n\texpected := []byte(testTime + \" * testuser has joined\\n\")\n\tif !bytes.Equal(rMsg, expected) {\n\t\tt.Fatalf(\"Unexpected read: %s, want %s.\", rMsg, expected)\n\t}\n}", "func TestCommitterFailure(t *testing.T) {\n\te := []*transformer.Envelope{\n\t\t&transformer.Envelope{},\n\t\t&transformer.Envelope{},\n\t\t&transformer.Envelope{},\n\t}\n\n\texp := errors.New(\"OH MY GOD EVERYTHING IS BURNING\")\n\tc := NewCommitter(&dumbWriter{}, func(envs []*transformer.Envelope) error {\n\t\treturn exp\n\t})\n\n\terr := c.Write(e...)\n\tif err != exp {\n\t\tt.Fatalf(\"unexpected error %v\", err)\n\t}\n}", "func TestWriteKeyOrderViolation(t *testing.T) {\n\tvar ctx = context.Background()\n\tvar buf = internal.NewAnonymousFile()\n\tvar writer = NewWriter(ctx, buf)\n\tvar err error\n\n\terr = writer.WriteString(ctx, \"test2\", \"data2\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error writing test data to sstable: %s\", err)\n\t}\n\n\terr = writer.WriteString(ctx, \"test1\", \"data1\")\n\tif err == nil {\n\t\tt.Error(\"WriteString in reverse order didn't fire, expected it to\")\n\t}\n\tif err != Err_KeyOrderViolation {\n\t\tt.Errorf(\"Unexpected error type after key order violation: %s\", err)\n\t}\n\n\terr = writer.WriteString(ctx, \"test2\", \"data3\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error writing second record to same key: %s\", err)\n\t}\n}", "func TestFreezerConcurrentModifyTruncate(t *testing.T) {\n\tf, _ := newFreezerForTesting(t, freezerTestTableDef)\n\tdefer f.Close()\n\n\tvar item = make([]byte, 256)\n\n\tfor i := 0; i < 1000; i++ {\n\t\t// First reset and write 100 items.\n\t\tif err := f.TruncateHead(0); err != nil {\n\t\t\tt.Fatal(\"truncate failed:\", err)\n\t\t}\n\t\t_, err := f.ModifyAncients(func(op database.AncientWriteOp) error {\n\t\t\tfor i := uint64(0); i < 100; i++ {\n\t\t\t\tif err := op.AppendRaw(\"test\", i, item); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t\tif err != nil {\n\t\t\tt.Fatal(\"modify failed:\", err)\n\t\t}\n\t\tcheckAncientCount(t, f, \"test\", 100)\n\n\t\t// Now append 100 more items and truncate concurrently.\n\t\tvar (\n\t\t\twg sync.WaitGroup\n\t\t\ttruncateErr error\n\t\t\tmodifyErr error\n\t\t)\n\t\twg.Add(3)\n\t\tgo func() {\n\t\t\t_, modifyErr = f.ModifyAncients(func(op database.AncientWriteOp) error {\n\t\t\t\tfor i := uint64(100); i < 200; i++ {\n\t\t\t\t\tif err := op.AppendRaw(\"test\", i, item); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t})\n\t\t\twg.Done()\n\t\t}()\n\t\tgo func() {\n\t\t\ttruncateErr = f.TruncateHead(10)\n\t\t\twg.Done()\n\t\t}()\n\t\tgo func() {\n\t\t\tf.AncientSize(\"test\")\n\t\t\twg.Done()\n\t\t}()\n\t\twg.Wait()\n\n\t\t// Now check the outcome. If the truncate operation went through first, the append\n\t\t// fails, otherwise it succeeds. In either case, the freezer should be positioned\n\t\t// at 10 after both operations are done.\n\t\tif truncateErr != nil {\n\t\t\tt.Fatal(\"concurrent truncate failed:\", err)\n\t\t}\n\t\tif !(errors.Is(modifyErr, nil) || errors.Is(modifyErr, errOutOrderInsertion)) {\n\t\t\tt.Fatal(\"wrong error from concurrent modify:\", modifyErr)\n\t\t}\n\t\tcheckAncientCount(t, f, \"test\", 10)\n\t}\n}", "func (w *Watches) cleanupExpiredWatches(ctx context.Context) {\n\t// Because of lock ordering, we cannot acquire Inotify.mu for each watch\n\t// owner while holding w.mu. As a result, store expired watches locally\n\t// before removing.\n\tvar toRemove []*Watch\n\tw.mu.RLock()\n\tfor _, watch := range w.ws {\n\t\tif watch.expired.Load() == 1 {\n\t\t\ttoRemove = append(toRemove, watch)\n\t\t}\n\t}\n\tw.mu.RUnlock()\n\tfor _, watch := range toRemove {\n\t\twatch.owner.RmWatch(ctx, watch.wd)\n\t}\n}", "func Test_Limiter_Fixed_Window_Custom_Storage_Skip_Failed_Requests(t *testing.T) {\n\tt.Parallel()\n\tapp := fiber.New()\n\n\tapp.Use(New(Config{\n\t\tMax: 1,\n\t\tExpiration: 2 * time.Second,\n\t\tStorage: memory.New(),\n\t\tSkipFailedRequests: true,\n\t\tLimiterMiddleware: FixedWindow{},\n\t}))\n\n\tapp.Get(\"/:status\", func(c *fiber.Ctx) error {\n\t\tif c.Params(\"status\") == \"fail\" {\n\t\t\treturn c.SendStatus(400)\n\t\t}\n\t\treturn c.SendStatus(200)\n\t})\n\n\tresp, err := app.Test(httptest.NewRequest(fiber.MethodGet, \"/fail\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 400, resp.StatusCode)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/success\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 200, resp.StatusCode)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/success\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 429, resp.StatusCode)\n\n\ttime.Sleep(3 * time.Second)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/success\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 200, resp.StatusCode)\n}", "func (m *MockConnectionTracer) LossTimerExpired(arg0 TimerType, arg1 protocol.EncryptionLevel) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"LossTimerExpired\", arg0, arg1)\n}", "func TestPacketDropIsExpired(t *testing.T) {\n\texpiredTime := util.GetExpiredTimeInString(util.DefaultPacketDropExpirationMinutes, PacketDropLogTimeLayout)\n\texpiredPacketDrop := PacketDrop{LogTime: expiredTime}\n\tif !expiredPacketDrop.IsExpired() {\n\t\tt.Fatal(\"Expected IsExpired() return true, got false\")\n\t}\n\n\tcurTime := time.Now().Format(PacketDropLogTimeLayout)\n\tcurPacketDrop := PacketDrop{LogTime: curTime}\n\tif curPacketDrop.IsExpired() {\n\t\tt.Fatal(\"Expected IsExpired() return false, got true\")\n\t}\n\n}", "func TestRecoverTxnRecordChanged(t *testing.T) {\n\tdefer leaktest.AfterTest(t)()\n\tdefer log.Scope(t).Close(t)\n\n\tctx := context.Background()\n\tk := roachpb.Key(\"a\")\n\tts := hlc.Timestamp{WallTime: 1}\n\ttxn := roachpb.MakeTransaction(\"test\", k, 0, ts, 0)\n\ttxn.Status = roachpb.STAGING\n\n\ttestCases := []struct {\n\t\tname string\n\t\timplicitlyCommitted bool\n\t\texpError string\n\t\tchangedTxn roachpb.Transaction\n\t}{\n\t\t{\n\t\t\tname: \"transaction commit after all writes found\",\n\t\t\timplicitlyCommitted: true,\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.Status = roachpb.COMMITTED\n\t\t\t\ttxnCopy.InFlightWrites = nil\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction abort after all writes found\",\n\t\t\timplicitlyCommitted: true,\n\t\t\texpError: \"found ABORTED record for implicitly committed transaction\",\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.Status = roachpb.ABORTED\n\t\t\t\ttxnCopy.InFlightWrites = nil\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction restart after all writes found\",\n\t\t\timplicitlyCommitted: true,\n\t\t\texpError: \"epoch change by implicitly committed transaction: 0->1\",\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.BumpEpoch()\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction timestamp increase after all writes found\",\n\t\t\timplicitlyCommitted: true,\n\t\t\texpError: \"timestamp change by implicitly committed transaction: 0.000000001,0->0.000000002,0\",\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.WriteTimestamp = txnCopy.WriteTimestamp.Add(1, 0)\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction commit after write prevented\",\n\t\t\timplicitlyCommitted: false,\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.Status = roachpb.COMMITTED\n\t\t\t\ttxnCopy.InFlightWrites = nil\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction abort after write prevented\",\n\t\t\timplicitlyCommitted: false,\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.Status = roachpb.ABORTED\n\t\t\t\ttxnCopy.InFlightWrites = nil\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction restart (pending) after write prevented\",\n\t\t\timplicitlyCommitted: false,\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.BumpEpoch()\n\t\t\t\ttxnCopy.Status = roachpb.PENDING\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction restart (staging) after write prevented\",\n\t\t\timplicitlyCommitted: false,\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.BumpEpoch()\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction timestamp increase (pending) after write prevented\",\n\t\t\timplicitlyCommitted: false,\n\t\t\texpError: \"cannot recover PENDING transaction in same epoch\",\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.Status = roachpb.PENDING\n\t\t\t\ttxnCopy.InFlightWrites = nil\n\t\t\t\ttxnCopy.WriteTimestamp = txnCopy.WriteTimestamp.Add(1, 0)\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tname: \"transaction timestamp increase (staging) after write prevented\",\n\t\t\timplicitlyCommitted: false,\n\t\t\tchangedTxn: func() roachpb.Transaction {\n\t\t\t\ttxnCopy := txn\n\t\t\t\ttxnCopy.WriteTimestamp = txnCopy.WriteTimestamp.Add(1, 0)\n\t\t\t\treturn txnCopy\n\t\t\t}(),\n\t\t},\n\t}\n\tfor _, c := range testCases {\n\t\tt.Run(c.name, func(t *testing.T) {\n\t\t\tdb := storage.NewDefaultInMemForTesting()\n\t\t\tdefer db.Close()\n\n\t\t\t// Write the modified transaction record, simulating a concurrent\n\t\t\t// actor changing the transaction record before the RecoverTxn\n\t\t\t// request is evaluated.\n\t\t\ttxnKey := keys.TransactionKey(txn.Key, txn.ID)\n\t\t\ttxnRecord := c.changedTxn.AsRecord()\n\t\t\tif err := storage.MVCCPutProto(ctx, db, nil, txnKey, hlc.Timestamp{}, nil, &txnRecord); err != nil {\n\t\t\t\tt.Fatal(err)\n\t\t\t}\n\n\t\t\t// Issue a RecoverTxn request.\n\t\t\tvar resp roachpb.RecoverTxnResponse\n\t\t\t_, err := RecoverTxn(ctx, db, CommandArgs{\n\t\t\t\tArgs: &roachpb.RecoverTxnRequest{\n\t\t\t\t\tRequestHeader: roachpb.RequestHeader{Key: txn.Key},\n\t\t\t\t\tTxn: txn.TxnMeta,\n\t\t\t\t\tImplicitlyCommitted: c.implicitlyCommitted,\n\t\t\t\t},\n\t\t\t\tHeader: roachpb.Header{\n\t\t\t\t\tTimestamp: ts,\n\t\t\t\t},\n\t\t\t}, &resp)\n\n\t\t\tif c.expError != \"\" {\n\t\t\t\tif !testutils.IsError(err, c.expError) {\n\t\t\t\t\tt.Fatalf(\"expected error %q; found %v\", c.expError, err)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatal(err)\n\t\t\t\t}\n\n\t\t\t\t// Assert that the response is correct.\n\t\t\t\texpTxnRecord := c.changedTxn.AsRecord()\n\t\t\t\texpTxn := expTxnRecord.AsTransaction()\n\t\t\t\trequire.Equal(t, expTxn, resp.RecoveredTxn)\n\n\t\t\t\t// Assert that the txn record was not modified.\n\t\t\t\tvar resTxnRecord roachpb.Transaction\n\t\t\t\tif _, err := storage.MVCCGetProto(\n\t\t\t\t\tctx, db, txnKey, hlc.Timestamp{}, &resTxnRecord, storage.MVCCGetOptions{},\n\t\t\t\t); err != nil {\n\t\t\t\t\tt.Fatal(err)\n\t\t\t\t}\n\t\t\t\trequire.Equal(t, expTxn, resTxnRecord)\n\t\t\t}\n\t\t})\n\t}\n}", "func TestWrite(t *testing.T) {\n\ttr := NewTFramedTransport(new(mockTTransport))\n\tbuff := make([]byte, 10)\n\n\tn, err := tr.Write(buff)\n\n\tassert.Equal(t, 10, n)\n\tassert.Nil(t, err)\n\tassert.Equal(t, buff, tr.buf.Bytes())\n}", "func TestShardWriter_WriteShard_Success(t *testing.T) {\n\tts := newTestWriteService(nil)\n\tts.TSDBStore.WriteToShardFn = ts.writeShardSuccess\n\ts := coordinator.NewService(coordinator.Config{})\n\ts.Listener = ts.muxln\n\ts.TSDBStore = &ts.TSDBStore\n\tif err := s.Open(); err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer s.Close()\n\tdefer ts.Close()\n\n\tw := coordinator.NewShardWriter(time.Minute, 1)\n\tw.MetaClient = &metaClient{host: ts.ln.Addr().String()}\n\n\t// Build a single point.\n\tnow := time.Now()\n\tvar points []models.Point\n\tpoints = append(points, models.MustNewPoint(\"cpu\", models.Tags{\"host\": \"server01\"}, map[string]interface{}{\"value\": int64(100)}, now))\n\n\t// Write to shard and close.\n\tif err := w.WriteShard(1, 2, points); err != nil {\n\t\tt.Fatal(err)\n\t} else if err := w.Close(); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Validate response.\n\tresponses, err := ts.ResponseN(1)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t} else if responses[0].shardID != 1 {\n\t\tt.Fatalf(\"unexpected shard id: %d\", responses[0].shardID)\n\t}\n\n\t// Validate point.\n\tif p := responses[0].points[0]; p.Name() != \"cpu\" {\n\t\tt.Fatalf(\"unexpected name: %s\", p.Name())\n\t} else if p.Fields()[\"value\"] != int64(100) {\n\t\tt.Fatalf(\"unexpected 'value' field: %d\", p.Fields()[\"value\"])\n\t} else if p.Tags()[\"host\"] != \"server01\" {\n\t\tt.Fatalf(\"unexpected 'host' tag: %s\", p.Tags()[\"host\"])\n\t} else if p.Time().UnixNano() != now.UnixNano() {\n\t\tt.Fatalf(\"unexpected time: %s\", p.Time())\n\t}\n}", "func TestTokenExpiracy(t *testing.T) {\n\tdb.InitDB()\n\tvar router *gin.Engine = routes.SetupRouter()\n\n\tos.Setenv(\"TOKEN_VALIDITY_MINUTES\", \"0\")\n\n\tvar user models.UserCreate = utils.CreateUser(\"Tom\", \"qwerty1234\", t, router)\n\tuser.Token = utils.ConnectUser(\"Tom\", \"qwerty1234\", t, router)\n\ttime.Sleep(1 * time.Second)\n\n\tvar url string = \"/v1/user/\" + strconv.Itoa(user.ID)\n\tvar bearer = \"Bearer \" + user.Token\n\trecord := httptest.NewRecorder()\n\trequest, _ := http.NewRequest(\"GET\", url, nil)\n\trequest.Header.Add(\"Content-Type\", \"application/json\")\n\trequest.Header.Add(\"Authorization\", bearer)\n\n\trouter.ServeHTTP(record, request)\n\n\tvar message Message\n\terr := json.Unmarshal([]byte(record.Body.String()), &message)\n\tif err != nil {\n\t\tlog.Fatal(\"Bad output: \", err.Error())\n\t\tt.Fail()\n\t}\n\n\tassert.Equal(t, record.Code, 401)\n\tassert.Equal(t, message.Message, \"Token expired.\")\n\n\tos.Setenv(\"TOKEN_VALIDITY_MINUTES\", \"15\")\n\n\tuser.Token = utils.ConnectUser(\"Tom\", \"qwerty1234\", t, router)\n\n\tutils.CleanUser(user.ID, user.Token, t, router)\n\tdb.CloseDB()\n}", "func (store *db) DeleteExpired() {\n\tif store == nil {\n\t\tfmt.Println(\"DeleteExpired : store is nil\")\n\t\treturn\n\t}\n\n\tvar evictedItems []keyAndValue\n\tnow := time.Now().UnixNano()\n\n\tstore.mapDBLock.Lock()\n\tdefer store.mapDBLock.Unlock()\n\t\n\tfor key, entry := range store.mapEntry {\n\t\t// \"Inlining\" of expired\n\t\tif entry.Expiration > 0 && now > entry.Expiration {\n\t\t\tentry, evicted := store.Delete(key)\n\t\t\tif evicted {\n\t\t\t\tevictedItems = append(evictedItems, keyAndValue{key, entry})\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, v := range evictedItems {\n\t\tstore.onEvicted(v.key, v.value)\n\t}\n}", "func TestWriteErrorWhenReader(t *testing.T) {\n\t// Ensure the db exists for this test\n\tdb, err := Open(db_filename, \"c\")\n\tdb.Close()\n\n\tdb, err = Open(db_filename, \"r\")\n\tdefer db.Close()\n\tdefer os.Remove(db_filename)\n\n\tif err != nil {\n\t\tt.Error(\"Couldn't read database\")\n\t}\n\n\terr = db.Insert(\"foo\", \"bar\")\n\tif err == nil {\n\t\tt.Error(\"Database let readonly client write\")\n\t}\n}", "func TestMock_WithDeadlineCancel(t *testing.T) {\n\tm := NewMock()\n\tctx, cancel := m.WithDeadline(context.Background(), m.Now().Add(time.Second))\n\tcancel()\n\tselect {\n\tcase <-ctx.Done():\n\t\tif !errors.Is(ctx.Err(), context.Canceled) {\n\t\t\tt.Error(\"invalid type of error returned after cancellation\")\n\t\t}\n\tcase <-time.After(time.Second):\n\t\tt.Error(\"context is not cancelled after cancel was called\")\n\t}\n}", "func Benchmark_Ctx_Write(b *testing.B) {\n\tapp := New()\n\tc := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(c)\n\tvar str = \"Hello, World!\"\n\tvar byt = []byte(\"Hello, World!\")\n\tvar nmb = 123\n\tvar bol = true\n\tb.ReportAllocs()\n\tb.ResetTimer()\n\tfor n := 0; n < b.N; n++ {\n\t\tc.Write(str)\n\t\tc.Write(byt)\n\t\tc.Write(nmb)\n\t\tc.Write(bol)\n\t}\n}", "func TestAccountCorrupted(t *testing.T) {\n\tif testing.Short() {\n\t\tt.SkipNow()\n\t}\n\tt.Parallel()\n\n\t// create a renter\n\trt, err := newRenterTester(t.Name())\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer func() {\n\t\terr := rt.Close()\n\t\tif err != nil {\n\t\t\tt.Log(err)\n\t\t}\n\t}()\n\tr := rt.renter\n\n\t// create a number accounts\n\taccounts, err := openRandomTestAccountsOnRenter(r)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// select a random account of which we'll corrupt data on disk\n\tvar corrupted *account\n\tfor _, account := range accounts {\n\t\tcorrupted = account\n\t\tbreak\n\t}\n\n\t// manually close the renter and corrupt the data at that offset\n\terr = r.Close()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tfile, err := r.deps.OpenFile(filepath.Join(r.persistDir, accountsFilename), os.O_RDWR, defaultFilePerm)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\trN := fastrand.Intn(5) + 1\n\trOffset := corrupted.staticOffset + int64(fastrand.Intn(accountSize-rN))\n\tn, err := file.WriteAt(fastrand.Bytes(rN), rOffset)\n\tif n != rN {\n\t\tt.Fatalf(\"Unexpected amount of bytes written, %v != %v\", n, rN)\n\t}\n\tif err != nil {\n\t\tt.Fatal(\"Could not write corrupted account data\")\n\t}\n\n\t// reopen the renter\n\tpersistDir := filepath.Join(rt.dir, modules.RenterDir)\n\trl := ratelimit.NewRateLimit(0, 0, 0)\n\tr, errChan := New(rt.gateway, rt.cs, rt.wallet, rt.tpool, rt.mux, rl, persistDir)\n\tif err := <-errChan; err != nil {\n\t\tt.Fatal(err)\n\t}\n\terr = rt.addRenter(r)\n\n\t// verify only the non corrupted accounts got reloaded properly\n\tam := r.staticAccountManager\n\tam.mu.Lock()\n\t// verify the amount of accounts reloaded is one less\n\texpected := len(accounts) - 1\n\tif len(am.accounts) != expected {\n\t\tt.Errorf(\"Unexpected amount of accounts, %v != %v\", len(am.accounts), expected)\n\t}\n\tfor _, account := range am.accounts {\n\t\tif account.staticID.SPK().Equals(corrupted.staticID.SPK()) {\n\t\t\tt.Error(\"Corrupted account was not properly skipped\")\n\t\t}\n\t}\n\tam.mu.Unlock()\n}", "func testCtx() context.Context {\n\treturn testCtxWithLevel(zerolog.WarnLevel)\n}", "func (scp *ConfigCache) FlushExpired() {\n\tvar forDeletion []string\n\n\tscp.cache.IterCb(func(key string, v interface{}) {\n\t\titem := v.(Value)\n\t\tif item.isExpired() {\n\t\t\tforDeletion = append(forDeletion, key)\n\t\t}\n\t})\n\tfor _, key := range forDeletion {\n\t\tscp.Delete(key)\n\t}\n}", "func testNoNilTimeoutReplacement(ctx context.Context, t *testing.T, w *Wallet) {\n\terr := w.Unlock(ctx, testPrivPass, nil)\n\tif err != nil {\n\t\tt.Fatal(\"failed to unlock wallet\")\n\t}\n\ttimeChan := make(chan time.Time)\n\terr = w.Unlock(ctx, testPrivPass, timeChan)\n\tif err != nil {\n\t\tt.Fatal(\"failed to unlock wallet with time channel\")\n\t}\n\tselect {\n\tcase timeChan <- time.Time{}:\n\tcase <-time.After(100 * time.Millisecond):\n\t\tt.Fatal(\"time channel was not read in 100ms\")\n\t}\n\tif w.Locked() {\n\t\tt.Fatal(\"expected wallet to remain unlocked due to previous unlock without timeout\")\n\t}\n}", "func TestActiveReplicatorRecoverFromLocalFlush(t *testing.T) {\n\n\tbase.RequireNumTestBuckets(t, 3)\n\n\tbase.SetUpTestLogging(t, logger.LevelInfo, logger.KeyReplicate, logger.KeyHTTP, logger.KeyHTTPResp, logger.KeySync, logger.KeySyncMsg)\n\n\t// Passive\n\trt2 := NewRestTester(t, &RestTesterConfig{\n\t\tTestBucket: base.GetTestBucket(t),\n\t\tDatabaseConfig: &DatabaseConfig{DbConfig: DbConfig{\n\t\t\tUsers: map[string]*db.PrincipalConfig{\n\t\t\t\t\"alice\": {\n\t\t\t\t\tPassword: base.StringPtr(\"pass\"),\n\t\t\t\t\tExplicitChannels: utils.SetOf(\"alice\"),\n\t\t\t\t},\n\t\t\t},\n\t\t}},\n\t})\n\tdefer rt2.Close()\n\n\t// Create doc on rt2\n\tdocID := t.Name() + \"rt2doc\"\n\tresp := rt2.SendAdminRequest(http.MethodPut, \"/db/\"+docID, `{\"source\":\"rt2\",\"channels\":[\"alice\"]}`)\n\tassertStatus(t, resp, http.StatusCreated)\n\n\tassert.NoError(t, rt2.WaitForPendingChanges())\n\n\t// Make rt2 listen on an actual HTTP port, so it can receive the blipsync request from rt1\n\tsrv := httptest.NewServer(rt2.TestPublicHandler())\n\tdefer srv.Close()\n\n\t// Build passiveDBURL with basic auth creds\n\tpassiveDBURL, err := url.Parse(srv.URL + \"/db\")\n\trequire.NoError(t, err)\n\tpassiveDBURL.User = url.UserPassword(\"alice\", \"pass\")\n\n\t// Active\n\trt1 := NewRestTester(t, &RestTesterConfig{\n\t\tTestBucket: base.GetTestBucket(t),\n\t})\n\n\tarConfig := db.ActiveReplicatorConfig{\n\t\tID: t.Name(),\n\t\tDirection: db.ActiveReplicatorTypePull,\n\t\tRemoteDBURL: passiveDBURL,\n\t\tActiveDB: &db.Database{\n\t\t\tDatabaseContext: rt1.GetDatabase(),\n\t\t},\n\t\tContinuous: true,\n\t\tReplicationStatsMap: base.SyncGatewayStats.NewDBStats(t.Name(), false, false, false).DBReplicatorStats(t.Name()),\n\t}\n\n\t// Create the first active replicator to pull from seq:0\n\tar := db.NewActiveReplicator(&arConfig)\n\trequire.NoError(t, err)\n\n\tstartNumChangesRequestedFromZeroTotal := rt2.GetDatabase().DbStats.CBLReplicationPull().NumPullReplSinceZero.Value()\n\tstartNumRevsSentTotal := rt2.GetDatabase().DbStats.CBLReplicationPull().RevSendCount.Value()\n\n\tassert.NoError(t, ar.Start())\n\n\t// wait for document originally written to rt2 to arrive at rt1\n\tchangesResults, err := rt1.WaitForChanges(1, \"/db/_changes?since=0\", \"\", true)\n\trequire.NoError(t, err)\n\trequire.Len(t, changesResults.Results, 1)\n\tassert.Equal(t, docID, changesResults.Results[0].ID)\n\n\tdoc, err := rt1.GetDatabase().GetDocument(logger.TestCtx(t), docID, db.DocUnmarshalAll)\n\tassert.NoError(t, err)\n\n\tbody, err := doc.GetDeepMutableBody()\n\trequire.NoError(t, err)\n\tassert.Equal(t, \"rt2\", body[\"source\"])\n\n\t// one _changes from seq:0 with initial number of docs sent\n\tnumChangesRequestedFromZeroTotal := rt2.GetDatabase().DbStats.CBLReplicationPull().NumPullReplSinceZero.Value()\n\tassert.Equal(t, startNumChangesRequestedFromZeroTotal+1, numChangesRequestedFromZeroTotal)\n\n\t// rev assertions\n\tnumRevsSentTotal := rt2.GetDatabase().DbStats.CBLReplicationPull().RevSendCount.Value()\n\tassert.Equal(t, startNumRevsSentTotal+1, numRevsSentTotal)\n\tassert.Equal(t, int64(1), ar.Pull.Checkpointer.Stats().ProcessedSequenceCount)\n\tassert.Equal(t, int64(1), ar.Pull.Checkpointer.Stats().ExpectedSequenceCount)\n\n\t// checkpoint assertions\n\tassert.Equal(t, int64(0), ar.Pull.Checkpointer.Stats().GetCheckpointHitCount)\n\tassert.Equal(t, int64(1), ar.Pull.Checkpointer.Stats().GetCheckpointMissCount)\n\t// Since we bumped the checkpointer interval, we're only setting checkpoints on replicator close.\n\tassert.Equal(t, int64(0), ar.Pull.Checkpointer.Stats().SetCheckpointCount)\n\tar.Pull.Checkpointer.CheckpointNow()\n\tassert.Equal(t, int64(1), ar.Pull.Checkpointer.Stats().SetCheckpointCount)\n\n\tassert.NoError(t, ar.Stop())\n\n\t// close rt1, and release the underlying bucket back to the pool.\n\trt1.Close()\n\n\t// recreate rt1 with a new bucket\n\trt1 = NewRestTester(t, &RestTesterConfig{\n\t\tTestBucket: base.GetTestBucket(t),\n\t})\n\tdefer rt1.Close()\n\n\t// Create a new replicator using the same config, which should use the checkpoint set from the first.\n\t// Have to re-set ActiveDB because we recreated it with the new rt1.\n\tarConfig.ActiveDB = &db.Database{\n\t\tDatabaseContext: rt1.GetDatabase(),\n\t}\n\tar = db.NewActiveReplicator(&arConfig)\n\trequire.NoError(t, err)\n\n\tassert.NoError(t, ar.Start())\n\n\t// we pulled the remote checkpoint, but the local checkpoint wasn't there to match it.\n\tassert.Equal(t, int64(0), ar.Pull.Checkpointer.Stats().GetCheckpointHitCount)\n\n\t// wait for document originally written to rt2 to arrive at rt1\n\tchangesResults, err = rt1.WaitForChanges(1, \"/db/_changes?since=0\", \"\", true)\n\trequire.NoError(t, err)\n\trequire.Len(t, changesResults.Results, 1)\n\tassert.Equal(t, docID, changesResults.Results[0].ID)\n\n\tdoc, err = rt1.GetDatabase().GetDocument(logger.TestCtx(t), docID, db.DocUnmarshalAll)\n\trequire.NoError(t, err)\n\n\tbody, err = doc.GetDeepMutableBody()\n\trequire.NoError(t, err)\n\tassert.Equal(t, \"rt2\", body[\"source\"])\n\n\t// one _changes from seq:0 with initial number of docs sent\n\tendNumChangesRequestedFromZeroTotal := rt2.GetDatabase().DbStats.CBLReplicationPull().NumPullReplSinceZero.Value()\n\tassert.Equal(t, numChangesRequestedFromZeroTotal+1, endNumChangesRequestedFromZeroTotal)\n\n\t// make sure rt2 thinks it has sent all of the revs via a 2.x replicator\n\tnumRevsSentTotal = rt2.GetDatabase().DbStats.CBLReplicationPull().RevSendCount.Value()\n\tassert.Equal(t, startNumRevsSentTotal+2, numRevsSentTotal)\n\tassert.Equal(t, int64(1), ar.Pull.Checkpointer.Stats().ProcessedSequenceCount)\n\tassert.Equal(t, int64(1), ar.Pull.Checkpointer.Stats().ExpectedSequenceCount)\n\n\t// assert the second active replicator stats\n\tassert.Equal(t, int64(1), ar.Pull.Checkpointer.Stats().GetCheckpointMissCount)\n\tassert.Equal(t, int64(0), ar.Pull.Checkpointer.Stats().SetCheckpointCount)\n\tar.Pull.Checkpointer.CheckpointNow()\n\tassert.Equal(t, int64(1), ar.Pull.Checkpointer.Stats().SetCheckpointCount)\n\n\tassert.NoError(t, ar.Stop())\n}", "func TestNameCacheEntryDoesntReturnExpiredLease(t *testing.T) {\n\tdefer leaktest.AfterTest(t)()\n\ts, db, kvDB := serverutils.StartServer(t, base.TestServerArgs{})\n\tdefer s.Stopper().Stop()\n\tleaseManager := s.LeaseManager().(*LeaseManager)\n\n\tif _, err := db.Exec(`\nCREATE DATABASE t;\nCREATE TABLE t.test (k CHAR PRIMARY KEY, v CHAR);\n`); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Populate the name cache.\n\tif _, err := db.Exec(\"SELECT * FROM t.test;\"); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\ttableDesc := sqlbase.GetTableDescriptor(kvDB, \"t\", \"test\")\n\n\t// Check the assumptions this tests makes: that there is a cache entry\n\t// (with a valid lease).\n\tlease := leaseManager.tableNames.get(tableDesc.ParentID, \"test\", s.Clock())\n\tif lease == nil {\n\t\tt.Fatalf(\"no name cache entry\")\n\t}\n\tif err := leaseManager.Release(lease); err != nil {\n\t\tt.Fatal(err)\n\t}\n\t// Advance the clock to expire the lease.\n\ts.Clock().SetMaxOffset(10 * LeaseDuration)\n\ts.Clock().Update(s.Clock().Now().Add(int64(2*LeaseDuration), 0))\n\n\t// Check the name no longer resolves.\n\tif leaseManager.tableNames.get(tableDesc.ParentID, \"test\", s.Clock()) != nil {\n\t\tt.Fatalf(\"name resolves when it shouldn't\")\n\t}\n}", "func TestDirCacheFlush(t *testing.T) {\n\trun.skipIfNoFUSE(t)\n\n\trun.checkDir(t, \"\")\n\n\trun.mkdir(t, \"dir\")\n\trun.mkdir(t, \"otherdir\")\n\trun.createFile(t, \"dir/file\", \"1\")\n\trun.createFile(t, \"otherdir/file\", \"1\")\n\n\tdm := newDirMap(\"otherdir/|otherdir/file 1|dir/|dir/file 1\")\n\tlocalDm := make(dirMap)\n\trun.readLocal(t, localDm, \"\")\n\tassert.Equal(t, dm, localDm, \"expected vs fuse mount\")\n\n\terr := run.fremote.Mkdir(context.Background(), \"dir/subdir\")\n\trequire.NoError(t, err)\n\n\t// expect newly created \"subdir\" on remote to not show up\n\trun.forget(\"otherdir\")\n\trun.readLocal(t, localDm, \"\")\n\tassert.Equal(t, dm, localDm, \"expected vs fuse mount\")\n\n\trun.forget(\"dir\")\n\tdm = newDirMap(\"otherdir/|otherdir/file 1|dir/|dir/file 1|dir/subdir/\")\n\trun.readLocal(t, localDm, \"\")\n\tassert.Equal(t, dm, localDm, \"expected vs fuse mount\")\n\n\trun.rm(t, \"otherdir/file\")\n\trun.rmdir(t, \"otherdir\")\n\trun.rm(t, \"dir/file\")\n\trun.rmdir(t, \"dir/subdir\")\n\trun.rmdir(t, \"dir\")\n\trun.checkDir(t, \"\")\n}", "func Test_Ctx_Status(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\tctx.Status(400)\n\tutils.AssertEqual(t, 400, ctx.Fasthttp.Response.StatusCode())\n\tctx.Status(415).Send(\"Hello, World\")\n\tutils.AssertEqual(t, 415, ctx.Fasthttp.Response.StatusCode())\n\tutils.AssertEqual(t, \"Hello, World\", string(ctx.Fasthttp.Response.Body()))\n}", "func TestConn_ReadWrite_interruptSleepByDeadline(t *testing.T) {\n\tnw, dconn, _, stop, err := makePipe(\"earth\", \"mars\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer stop()\n\n\tnow := time.Now()\n\ttimeNow = func() time.Time {\n\t\treturn now.Add(time.Hour)\n\t}\n\tnw.SetBandwidth(\"earth\", \"mars\", Bandwidth(1024))\n\ttimeNow = func() time.Time {\n\t\treturn time.Now()\n\t}\n\n\tvar wg sync.WaitGroup\n\twg.Add(3)\n\tdefer wg.Wait()\n\tch := make(chan struct{})\n\tgo func() {\n\t\tdefer wg.Done()\n\t\tclose(ch)\n\t\ttime.Sleep(100 * time.Millisecond)\n\t\tif err := dconn.SetDeadline(time.Now().Add(100 * time.Millisecond)); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}()\n\tgo func() {\n\t\tdefer wg.Done()\n\t\t<-ch\n\t\tn, err := dconn.Read(make([]byte, 1024))\n\t\tensureTimeout(t, err)\n\t\tif n != 0 {\n\t\t\tt.Fatalf(\"Read: got %d, want 0\", n)\n\t\t}\n\t}()\n\tgo func() {\n\t\tdefer wg.Done()\n\t\t<-ch\n\t\tn, err := dconn.Write(make([]byte, 1024))\n\t\tensureTimeout(t, err)\n\t\tif n != 0 {\n\t\t\tt.Fatalf(\"Write: got %d, want 0\", n)\n\t\t}\n\t}()\n}", "func TestRenewAfterTTLExpires(t *testing.T) {\n\tttl := 2\n\tc, v, secret := loginHelper(t, fmt.Sprintf(\"%vs\", ttl))\n\n\t_, err := c.AuthAPIClient.GetAdmins(c.Ctx(), &auth.GetAdminsRequest{})\n\tif err != nil {\n\t\tt.Fatalf(err.Error())\n\t}\n\n\trenewer, err := v.NewRenewer(&vault.RenewerInput{\n\t\tSecret: secret,\n\t\tIncrement: ttl,\n\t})\n\tif err != nil {\n\t\tt.Fatalf(err.Error())\n\t}\n\n\ttime.Sleep(time.Duration(ttl+1) * time.Second)\n\tgo renewer.Renew()\n\tdefer renewer.Stop()\n\n\tselect {\n\tcase err := <-renewer.DoneCh():\n\t\tif err == nil {\n\t\t\tt.Fatalf(\"Expected an error renewing but got none\\n\")\n\t\t}\n\tcase <-renewer.RenewCh():\n\t\tt.Fatal(\"Expected failed renewal, but got successful renewal\\n\")\n\t}\n\n\t_, err = c.AuthAPIClient.GetAdmins(c.Ctx(), &auth.GetAdminsRequest{})\n\tif err == nil {\n\t\tt.Fatalf(\"Expected error using pach token after expiry, but got no error\\n\")\n\t}\n}", "func ContextMustWriter(ctx context.Context) Writer {\n\tr, ok := ctx.Value(CtxKeyWriter).(Writer)\n\tif !ok {\n\t\tpanic(ErrTypeAssertionWriterFailed)\n\t}\n\treturn r\n}", "func expired(token *Token) bool {\n\tif token.Expires.IsZero() && len(token.Access) != 0 {\n\t\treturn false\n\t}\n\treturn token.Expires.Add(-expiryDelta).\n\t\tBefore(time.Now())\n}", "func TestReadOnlyTransaction_UseAfterClose(t *testing.T) {\n\tt.Parallel()\n\tctx := context.Background()\n\t_, client, teardown := setupMockedTestServer(t)\n\tdefer teardown()\n\n\ttxn := client.ReadOnlyTransaction()\n\ttxn.Close()\n\n\t_, _, e := txn.acquire(ctx)\n\tif wantErr := errTxClosed(); !testEqual(e, wantErr) {\n\t\tt.Fatalf(\"Second acquire for multi use, got %v, want %v.\", e, wantErr)\n\t}\n}", "func TestTFramedMemoryBufferWrite(t *testing.T) {\n\tbuff := NewTMemoryOutputBuffer(100)\n\tassert.Equal(t, 4, buff.Len())\n\tn, err := buff.Write(make([]byte, 50))\n\tassert.Nil(t, err)\n\tassert.Equal(t, 50, n)\n\tn, err = buff.Write(make([]byte, 40))\n\tassert.Nil(t, err)\n\tassert.Equal(t, 40, n)\n\tassert.Equal(t, 94, buff.Len())\n\t_, err = buff.Write(make([]byte, 20))\n\tassert.True(t, IsErrTooLarge(err))\n\tassert.Equal(t, TRANSPORT_EXCEPTION_REQUEST_TOO_LARGE, err.(thrift.TTransportException).TypeId())\n\tassert.Equal(t, 4, buff.Len())\n}", "func TestExpiry(t *testing.T) {\n\t_, privateBytes, err := GenerateKeyPair()\n\trequire.NoError(t, err)\n\tprivateKey, err := utils.ParsePrivateKey(privateBytes)\n\trequire.NoError(t, err)\n\n\tclock := clockwork.NewFakeClockAt(time.Now())\n\n\t// Create a new key that can be used to sign and verify tokens.\n\tkey, err := New(&Config{\n\t\tClock: clock,\n\t\tPrivateKey: privateKey,\n\t\tAlgorithm: defaults.ApplicationTokenAlgorithm,\n\t\tClusterName: \"example.com\",\n\t})\n\trequire.NoError(t, err)\n\n\t// Sign a token with a 1 minute expiration.\n\ttoken, err := key.Sign(SignParams{\n\t\tUsername: \"[email protected]\",\n\t\tRoles: []string{\"foo\", \"bar\"},\n\t\tTraits: wrappers.Traits{\n\t\t\t\"trait1\": []string{\"value-1\", \"value-2\"},\n\t\t},\n\t\tExpires: clock.Now().Add(1 * time.Minute),\n\t\tURI: \"http://127.0.0.1:8080\",\n\t})\n\trequire.NoError(t, err)\n\n\t// Verify that the token is still valid.\n\tclaims, err := key.Verify(VerifyParams{\n\t\tUsername: \"[email protected]\",\n\t\tURI: \"http://127.0.0.1:8080\",\n\t\tRawToken: token,\n\t})\n\trequire.NoError(t, err)\n\trequire.Equal(t, claims.Username, \"[email protected]\")\n\trequire.Equal(t, claims.Roles, []string{\"foo\", \"bar\"})\n\trequire.Equal(t, claims.IssuedAt, josejwt.NewNumericDate(clock.Now()))\n\n\t// Advance time by two minutes and verify the token is no longer valid.\n\tclock.Advance(2 * time.Minute)\n\t_, err = key.Verify(VerifyParams{\n\t\tUsername: \"[email protected]\",\n\t\tURI: \"http://127.0.0.1:8080\",\n\t\tRawToken: token,\n\t})\n\trequire.Error(t, err)\n}", "func TestReadOnlyTxnObeysDeadline(t *testing.T) {\n\tdefer leaktest.AfterTest(t)()\n\ts, _, _ := serverutils.StartServer(t, base.TestServerArgs{})\n\tdefer s.Stopper().Stop()\n\tdb := createTestClient(t, s.Stopper(), s.ServingAddr())\n\n\tif err := db.Put(\"k\", \"v\"); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Use txn.Exec instead of db.Txn to disable auto retry.\n\ttxn := client.NewTxn(context.TODO(), *db)\n\tif err := txn.Exec(client.TxnExecOptions{AutoRetry: false, AutoCommit: true}, func(txn *client.Txn, _ *client.TxnExecOptions) error {\n\t\t// Set deadline to sometime in the past.\n\t\ttxn.UpdateDeadlineMaybe(hlc.Timestamp{WallTime: timeutil.Now().Add(-time.Second).UnixNano()})\n\t\t_, err := txn.Get(\"k\")\n\t\treturn err\n\t}); !testutils.IsError(err, \"txn aborted\") {\n\t\tt.Fatal(err)\n\t}\n}", "func (wsc *WSConnection) refreshLocalConnection(forceCreate bool) (err error) {\n\n\tlog := wsc.tun.log\n\tconnMutex.Lock()\n\tdefer connMutex.Unlock()\n\n\tif wsc.localConnection != nil && !forceCreate {\n\t\tc := wsc.localConnection\n\t\tone := []byte{}\n\t\tc.SetReadDeadline(time.Now())\n\t\t_, err := c.Read(one)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Error encountered while testing local connection: %s\", err.Error())\n\t\t\tif err == io.EOF ||\n\t\t\t\terr == io.ErrClosedPipe ||\n\t\t\t\terr == io.ErrUnexpectedEOF {\n\t\t\t\tlog.Trace(\"Lost local server connection, reconnecting...\")\n\t\t\t\tif err := wsc.dialLocalConnection(); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif err := wsc.dialLocalConnection(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func TestUnsafeBatchIdWriting(t *testing.T) {\n\ts := new(service)\n\ts.metaLock = new(sync.RWMutex)\n\ts.withdrawBatch = make(map[string]int)\n\tbatchID := \"test\"\n\n\tfor i := 0; i < 100; i++ {\n\t\tfmt.Println(s.ApplyWithdrawal(batchID, i))\n\t}\n\n\tsig := make(chan os.Signal, 1)\n\tsignal.Notify(sig, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGSTOP)\n\tfor {\n\t\ts := <-sig\n\t\tswitch s {\n\t\tcase syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:\n\t\t\treturn\n\t\tcase syscall.SIGHUP:\n\t\tdefault:\n\t\t\treturn\n\t\t}\n\t}\n}", "func TestTokenTTLExtend(t *testing.T) {\n\tif testing.Short() {\n\t\tt.Skip(\"Skipping integration tests in short mode\")\n\t}\n\tdeleteAll(t)\n\tadminClient := getPachClient(t, admin)\n\n\t// Create repo (so alice has something to list)\n\trepo := tu.UniqueString(\"TestTokenTTLExtend\")\n\trequire.NoError(t, adminClient.CreateRepo(repo))\n\n\talice := tu.UniqueString(\"alice\")\n\tresp, err := adminClient.GetAuthToken(adminClient.Ctx(), &auth.GetAuthTokenRequest{\n\t\tSubject: alice,\n\t\tTTL: 5, // seconds\n\t})\n\trequire.NoError(t, err)\n\taliceClient := adminClient.WithCtx(context.Background())\n\taliceClient.SetAuthToken(resp.Token)\n\n\t// alice's token is valid, but expires quickly\n\trepos, err := aliceClient.ListRepo()\n\trequire.NoError(t, err)\n\trequire.ElementsEqualUnderFn(t, []string{repo}, repos, RepoInfoToName)\n\ttime.Sleep(10 * time.Second)\n\trepos, err = aliceClient.ListRepo()\n\trequire.True(t, auth.IsErrBadToken(err), err.Error())\n\trequire.Equal(t, 0, len(repos))\n\n\t// admin gives alice another token but extends it. Now it doesn't expire after\n\t// 10 seconds, but 20\n\tresp, err = adminClient.GetAuthToken(adminClient.Ctx(), &auth.GetAuthTokenRequest{\n\t\tSubject: alice,\n\t\tTTL: 5, // seconds\n\t})\n\trequire.NoError(t, err)\n\taliceClient.SetAuthToken(resp.Token)\n\t// token is valid\n\trepos, err = aliceClient.ListRepo()\n\trequire.NoError(t, err)\n\trequire.ElementsEqualUnderFn(t, []string{repo}, repos, RepoInfoToName)\n\t// admin extends token\n\t_, err = adminClient.ExtendAuthToken(adminClient.Ctx(), &auth.ExtendAuthTokenRequest{\n\t\tToken: resp.Token,\n\t\tTTL: 15,\n\t})\n\trequire.NoError(t, err)\n\n\t// token is still valid after 10 seconds\n\ttime.Sleep(10 * time.Second)\n\ttime.Sleep(time.Second)\n\trepos, err = aliceClient.ListRepo()\n\trequire.NoError(t, err)\n\trequire.ElementsEqualUnderFn(t, []string{repo}, repos, RepoInfoToName)\n\t// wait longer, now token is expired\n\ttime.Sleep(10 * time.Second)\n\trepos, err = aliceClient.ListRepo()\n\trequire.True(t, auth.IsErrBadToken(err), err.Error())\n\trequire.Equal(t, 0, len(repos))\n}", "func (r *Redis) FlushExpiredDataPoints(flushHandler func(string, []byte) error) error {\n\tif err := r.initExpiredStream(); err != nil {\n\t\treturn err\n\t}\n\n\tconsumerID := generateConsumerID()\n\n\tlog.Printf(\"Subscribing '%s' as ('%s','%s')\",\n\t\tr.selfExpiredStreamKey, flusherXGroup, consumerID)\n\n\tfor {\n\t\tstartTime := time.Now()\n\n\t\texpiredMetricIDs := []string{}\n\t\texpiredStreamIDs := []string{}\n\n\t\txstreams, err := r.client.XReadGroup(&goredis.XReadGroupArgs{\n\t\t\tGroup: flusherXGroup,\n\t\t\tConsumer: consumerID,\n\t\t\tStreams: []string{r.selfExpiredStreamKey, \">\"},\n\t\t\tCount: flusherReadCount,\n\t\t}).Result()\n\t\tif err != nil {\n\t\t\tif err != goredis.Nil {\n\t\t\t\tlog.Println(err)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, xstream := range xstreams {\n\t\t\tfor _, xmsg := range xstream.Messages {\n\t\t\t\tfor metricID := range xmsg.Values {\n\t\t\t\t\texpiredMetricIDs = append(expiredMetricIDs, metricID)\n\t\t\t\t}\n\t\t\t\texpiredStreamIDs = append(expiredStreamIDs, xmsg.ID)\n\t\t\t}\n\t\t}\n\n\t\tif len(expiredMetricIDs) < 1 {\n\t\t\tcontinue\n\t\t}\n\n\t\tvar datapointsCnt int32\n\n\t\teg := errgroup.Group{}\n\t\tfor _, mid := range expiredMetricIDs {\n\t\t\tmid := mid\n\t\t\teg.Go(func() error {\n\t\t\t\tres, err := r.client.Get(mid).Result()\n\t\t\t\tif err != nil {\n\t\t\t\t\tif err != goredis.Nil {\n\t\t\t\t\t\treturn xerrors.Errorf(\"Could not GET %q: %w\", mid, err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdatapoints := bytesutil.ToUnsafeBytes(res)\n\t\t\t\tatomic.AddInt32(&datapointsCnt, int32(len(datapoints)/16))\n\t\t\t\treturn flushHandler(mid, datapoints)\n\t\t\t})\n\t\t}\n\n\t\tif err := eg.Wait(); err != nil {\n\t\t\tlog.Printf(\"%+v\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\teg = errgroup.Group{}\n\n\t\teg.Go(func() error {\n\t\t\t// TODO: lua script for xack and del\n\t\t\t_, err := r.client.Pipelined(func(pipe goredis.Pipeliner) error {\n\t\t\t\tpipe.XAck(r.selfExpiredStreamKey, flusherXGroup, expiredStreamIDs...)\n\t\t\t\tpipe.XDel(r.selfExpiredStreamKey, expiredStreamIDs...)\n\t\t\t\treturn nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn xerrors.Errorf(\"Could not ack and del (%v...): %w\\n\", expiredMetricIDs[0], err)\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\n\t\teg.Go(func() error {\n\t\t\t// TODO: handling in case of delete failure\n\t\t\t_, err = r.client.Pipelined(func(pipe goredis.Pipeliner) error {\n\t\t\t\tfor _, id := range expiredMetricIDs {\n\t\t\t\t\tpipe.Unlink(id)\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn xerrors.Errorf(\"Could not complete to pipeline for deleteing old metrics (%v...): %w\", expiredMetricIDs[0], err)\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\n\t\tif err := eg.Wait(); err != nil {\n\t\t\tlog.Printf(\"%+v\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\tflushDuration.UpdateDuration(startTime)\n\t\tmetricsFlushed.Add(len(expiredStreamIDs))\n\t\tdatapointsFlushed.Add(int(datapointsCnt))\n\t}\n}", "func TestWriteError(t *testing.T) {\n\tbuf := new(bytes.Buffer)\n\tn := 65536\n\tif !testing.Short() {\n\t\tn *= 4\n\t}\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Fprintf(buf, \"asdasfasf%d%dfghfgujyut%dyutyu\\n\", i, i, i)\n\t}\n\tin := buf.Bytes()\n\t// We create our own buffer to control number of writes.\n\tcopyBuf := make([]byte, 128)\n\tfor l := 0; l < 10; l++ {\n\t\tfor fail := 1; fail <= 256; fail *= 2 {\n\t\t\t// Fail after 'fail' writes\n\t\t\tew := &errorWriter{N: fail}\n\t\t\tw, err := NewWriter(ew, l)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"NewWriter: level %d: %v\", l, err)\n\t\t\t}\n\t\t\tn, err := copyBuffer(w, bytes.NewBuffer(in), copyBuf)\n\t\t\tif err == nil {\n\t\t\t\tt.Fatalf(\"Level %d: Expected an error, writer was %#v\", l, ew)\n\t\t\t}\n\t\t\tn2, err := w.Write([]byte{1, 2, 2, 3, 4, 5})\n\t\t\tif n2 != 0 {\n\t\t\t\tt.Fatal(\"Level\", l, \"Expected 0 length write, got\", n)\n\t\t\t}\n\t\t\tif err == nil {\n\t\t\t\tt.Fatal(\"Level\", l, \"Expected an error\")\n\t\t\t}\n\t\t\terr = w.Flush()\n\t\t\tif err == nil {\n\t\t\t\tt.Fatal(\"Level\", l, \"Expected an error on flush\")\n\t\t\t}\n\t\t\terr = w.Close()\n\t\t\tif err == nil {\n\t\t\t\tt.Fatal(\"Level\", l, \"Expected an error on close\")\n\t\t\t}\n\n\t\t\tw.Reset(ioutil.Discard)\n\t\t\tn2, err = w.Write([]byte{1, 2, 3, 4, 5, 6})\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(\"Level\", l, \"Got unexpected error after reset:\", err)\n\t\t\t}\n\t\t\tif n2 == 0 {\n\t\t\t\tt.Fatal(\"Level\", l, \"Got 0 length write, expected > 0\")\n\t\t\t}\n\t\t\tif testing.Short() {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}", "func Test_Limiter_Sliding_Window_Custom_Storage_Skip_Failed_Requests(t *testing.T) {\n\tt.Parallel()\n\tapp := fiber.New()\n\n\tapp.Use(New(Config{\n\t\tMax: 1,\n\t\tExpiration: 2 * time.Second,\n\t\tStorage: memory.New(),\n\t\tSkipFailedRequests: true,\n\t\tLimiterMiddleware: SlidingWindow{},\n\t}))\n\n\tapp.Get(\"/:status\", func(c *fiber.Ctx) error {\n\t\tif c.Params(\"status\") == \"fail\" {\n\t\t\treturn c.SendStatus(400)\n\t\t}\n\t\treturn c.SendStatus(200)\n\t})\n\n\tresp, err := app.Test(httptest.NewRequest(fiber.MethodGet, \"/fail\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 400, resp.StatusCode)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/success\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 200, resp.StatusCode)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/success\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 429, resp.StatusCode)\n\n\ttime.Sleep(4 * time.Second)\n\n\tresp, err = app.Test(httptest.NewRequest(fiber.MethodGet, \"/success\", nil))\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, 200, resp.StatusCode)\n}", "func TestRaceWriteBroadcaster(t *testing.T) {\n\twriter := NewWriteBroadcaster()\n\tc := make(chan bool)\n\tgo func() {\n\t\twriter.AddWriter(devNullCloser(0), \"\")\n\t\tc <- true\n\t}()\n\twriter.Write([]byte(\"hello\"))\n\t<-c\n}", "func TestSaveEncryptionFails(t *testing.T) {\n\tmetadata, entries, snapshot := makeWALData(1, 1)\n\n\ttempdir, err := ioutil.TempDir(\"\", \"waltests\")\n\trequire.NoError(t, err)\n\tos.RemoveAll(tempdir)\n\tdefer os.RemoveAll(tempdir)\n\n\t// fail encrypting one of the entries, but not the first one\n\tc := NewWALFactory(&meowCrypter{encryptFailures: map[string]struct{}{\n\t\t\"Entry 3\": {},\n\t}}, nil)\n\twrapped, err := c.Create(tempdir, metadata)\n\trequire.NoError(t, err)\n\n\trequire.NoError(t, wrapped.SaveSnapshot(snapshot))\n\terr = wrapped.Save(raftpb.HardState{}, entries)\n\trequire.Error(t, err)\n\trequire.Contains(t, err.Error(), \"refusing to encrypt\")\n\trequire.NoError(t, wrapped.Close())\n\n\t// no entries are written at all\n\togWAL, err := OriginalWAL.Open(tempdir, snapshot)\n\trequire.NoError(t, err)\n\tdefer ogWAL.Close()\n\n\t_, _, ents, err := ogWAL.ReadAll()\n\trequire.NoError(t, err)\n\trequire.Empty(t, ents)\n}", "func Test_Ctx_SendFile(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\n\t// fetch file content\n\tf, err := os.Open(\"./ctx.go\")\n\tutils.AssertEqual(t, nil, err)\n\tdefer f.Close()\n\texpectFileContent, err := ioutil.ReadAll(f)\n\tutils.AssertEqual(t, nil, err)\n\t// fetch file info for the not modified test case\n\tfI, err := os.Stat(\"./ctx.go\")\n\tutils.AssertEqual(t, nil, err)\n\n\t// simple test case\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\terr = ctx.SendFile(\"ctx.go\")\n\t// check expectation\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, expectFileContent, ctx.Fasthttp.Response.Body())\n\tutils.AssertEqual(t, StatusOK, ctx.Fasthttp.Response.StatusCode())\n\tapp.ReleaseCtx(ctx)\n\n\t// test with custom error code\n\tctx = app.AcquireCtx(&fasthttp.RequestCtx{})\n\terr = ctx.Status(StatusInternalServerError).SendFile(\"ctx.go\")\n\t// check expectation\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, expectFileContent, ctx.Fasthttp.Response.Body())\n\tutils.AssertEqual(t, StatusInternalServerError, ctx.Fasthttp.Response.StatusCode())\n\tapp.ReleaseCtx(ctx)\n\n\t// test not modified\n\tctx = app.AcquireCtx(&fasthttp.RequestCtx{})\n\tctx.Fasthttp.Request.Header.Set(HeaderIfModifiedSince, fI.ModTime().Format(time.RFC1123))\n\terr = ctx.SendFile(\"ctx.go\")\n\t// check expectation\n\tutils.AssertEqual(t, nil, err)\n\tutils.AssertEqual(t, StatusNotModified, ctx.Fasthttp.Response.StatusCode())\n\tutils.AssertEqual(t, []byte(nil), ctx.Fasthttp.Response.Body())\n\tapp.ReleaseCtx(ctx)\n}", "func withHealthT(t *testing.T, ctx context.Context, client arangodb.Client, f healthFunc) {\n\tctxInner := ctx\n\tif _, ok := ctx.Deadline(); !ok {\n\t\t// When caller does not provide timeout, wait for healthiness for 30 seconds.\n\t\tvar cancel context.CancelFunc\n\n\t\tctxInner, cancel = context.WithTimeout(ctx, time.Second*30)\n\t\tdefer cancel()\n\t}\n\n\tfor {\n\t\thealth, err := client.Health(ctxInner)\n\t\tif err == nil && len(health.Health) > 0 {\n\t\t\tnotGood := 0\n\t\t\tfor _, h := range health.Health {\n\t\t\t\tif h.Status != arangodb.ServerStatusGood {\n\t\t\t\t\tnotGood++\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif notGood == 0 {\n\t\t\t\tf(t, ctxInner, health)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tselect {\n\t\tcase <-time.After(time.Second):\n\t\t\tbreak\n\t\tcase <-ctxInner.Done():\n\t\t\tif err == nil {\n\t\t\t\t// It is not health error, but context error.\n\t\t\t\terr = ctxInner.Err()\n\t\t\t}\n\n\t\t\terr = errors.WithMessagef(err, \"health %#v\", health)\n\t\t\trequire.NoError(t, err)\n\t\t}\n\t}\n}", "func testFailingWrite(c *testContext, flow testFlow, wantErr *tcpip.Error) {\n\tc.t.Helper()\n\n\th := flow.header4Tuple(outgoing)\n\twriteDstAddr := flow.mapAddrIfApplicable(h.dstAddr.Addr)\n\n\tpayload := buffer.View(newPayload())\n\t_, _, gotErr := c.ep.Write(tcpip.SlicePayload(payload), tcpip.WriteOptions{\n\t\tTo: &tcpip.FullAddress{Addr: writeDstAddr, Port: h.dstAddr.Port},\n\t})\n\tif gotErr != wantErr {\n\t\tc.t.Fatalf(\"Write returned unexpected error: got %v, want %v\", gotErr, wantErr)\n\t}\n}", "func TestNotIdle(t *testing.T) {\n\tdir := test_helpers.InitFS(t)\n\tmnt := dir + \".mnt\"\n\terr := test_helpers.Mount(dir, mnt, false, \"-extpass\", \"echo test\", \"-i=100ms\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\terr = ioutil.WriteFile(mnt+\"/foo\", []byte(\"foo\"), 0600)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\t// Read every 10 milliseconds for a total of 1 second\n\tfor i := 1; i < 100; i++ {\n\t\t_, err = ioutil.ReadFile(mnt + \"/foo\")\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"iteration %d failed: %v\", i, err)\n\t\t}\n\t\ttime.Sleep(10 * time.Millisecond)\n\t}\n\t// Keep a file handle open for 1 second\n\tfd, err := os.Open(mnt + \"/foo\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\ttime.Sleep(1 * time.Second)\n\tbuf := make([]byte, 100)\n\t_, err = fd.Read(buf)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tfd.Close()\n\t// All good.\n\ttest_helpers.UnmountPanic(mnt)\n}", "func TestVerifyExpired(t *testing.T) {\n\toptions := iniVerifyOptions(t)\n\toptions.CurrentTime = time.Date(2020, 01, 01, 01, 01, 01, 0, gmt)\n\n\tp := loadProxy(\"test-samples/RfcProxy.pem\", t)\n\tif e := p.Verify(options); e == nil {\n\t\tt.Error(\"Verification must fail\")\n\t} else {\n\t\tt.Log(e)\n\t}\n}", "func TestRenewBeforeTTLExpires(t *testing.T) {\n\tttl := 10\n\tc, v, secret := loginHelper(t, fmt.Sprintf(\"%vs\", ttl))\n\tif secret.LeaseDuration < 2 {\n\t\tt.Fatalf(\"expected lease to be at least 2s, but was: %d\", secret.LeaseDuration)\n\t} else if secret.LeaseDuration > 10 {\n\t\tt.Fatalf(\"expected lease to be at most 10s, but was: %d\", secret.LeaseDuration)\n\t}\n\n\t_, err := c.AuthAPIClient.GetAdmins(c.Ctx(), &auth.GetAdminsRequest{})\n\tif err != nil {\n\t\tt.Fatalf(err.Error())\n\t}\n\n\trenewer, err := v.NewRenewer(&vault.RenewerInput{\n\t\tSecret: secret,\n\t\tIncrement: ttl,\n\t})\n\tif err != nil {\n\t\tt.Fatalf(err.Error())\n\t}\n\n\t// Begin a renewer background process, and wait until it fires\n\ttime.Sleep(time.Duration(ttl/2) * time.Second)\n\tgo renewer.Renew()\n\tdefer renewer.Stop()\n\tselect {\n\tcase err := <-renewer.DoneCh():\n\t\tif err != nil {\n\t\t\tt.Fatalf(err.Error())\n\t\t}\n\tcase <-renewer.RenewCh():\n\t}\n\n\t// Make sure that the vault lease was only extended by 10s\n\tleaseInfo, err := v.Logical().Write(\"/sys/leases/lookup\", map[string]interface{}{\n\t\t\"lease_id\": secret.LeaseID,\n\t})\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\tnewDurationStr := leaseInfo.Data[\"ttl\"].(json.Number)\n\tnewDuration, err := newDurationStr.Int64()\n\tif err != nil {\n\t\tt.Fatalf(err.Error())\n\t}\n\tif newDuration < 2 {\n\t\tt.Fatalf(\"expected lease to be at least 2s, but was: %d\", newDuration)\n\t} else if newDuration > 20 {\n\t\tt.Fatalf(\"expected lease to be at most 20s, but was: %d\", newDuration)\n\t}\n\n\t// Make sure that the Pachyderm token was also renewed\n\ttime.Sleep(time.Duration(ttl/2+1) * time.Second) // wait til old lease exires\n\t_, err = c.AuthAPIClient.GetAdmins(c.Ctx(), &auth.GetAdminsRequest{})\n\tif err != nil {\n\t\tt.Fatalf(err.Error())\n\t}\n}", "func TestPostWriteWhenLogStoreNotReady(t *testing.T) {\n\t// set up test server and mocked LogStore\n\tmockLogStore := new(MockedLogStore)\n\tserver := newTestServer(mockLogStore)\n\ttestServer := httptest.NewServer(server.server.Handler)\n\tdefer testServer.Close()\n\tclient := testServer.Client()\n\n\tlogsToWrite := []logstore.LogEntry{\n\t\tlogEntry(MustParse(\"2018-01-01T12:00:00.000Z\"), \"event 1\"),\n\t}\n\n\t//\n\t// set up mock expectations\n\t//\n\n\tmockLogStore.On(\"Ready\").Return(false, fmt.Errorf(\"connection refused\"))\n\n\t//\n\t// make call\n\t//\n\tjsonBytes, _ := json.Marshal(logsToWrite)\n\tbody := strings.NewReader(string(jsonBytes))\n\tresp, _ := client.Post(testServer.URL+\"/write\", \"application/json\", body)\n\t// should return 503 (Service Unavailable)\n\tassert.Equalf(t, http.StatusServiceUnavailable, resp.StatusCode, \"unexpected response code\")\n\tassert.Equalf(t, `{\"message\":\"data store is not ready\",\"detail\":\"connection refused\"}`, readBody(t, resp), \"unexpected response\")\n\n\t// verify that expected calls were made\n\tmockLogStore.AssertExpectations(t)\n}" ]
[ "0.8501558", "0.51481897", "0.49856946", "0.4984615", "0.47959307", "0.4789426", "0.469212", "0.46893492", "0.4668998", "0.46620876", "0.46356317", "0.45818096", "0.45338818", "0.45038548", "0.44520673", "0.4442732", "0.44425097", "0.4439125", "0.443855", "0.4431337", "0.44303966", "0.44287515", "0.44215262", "0.440526", "0.43932575", "0.43908858", "0.4389119", "0.43873656", "0.43848276", "0.4382077", "0.4379994", "0.43559647", "0.43425304", "0.43374327", "0.43225014", "0.43157104", "0.43124983", "0.43042588", "0.42925906", "0.42911735", "0.4282983", "0.4280087", "0.42791584", "0.42692396", "0.42632762", "0.4251998", "0.42413998", "0.4237946", "0.42348596", "0.42259687", "0.42199847", "0.42178872", "0.42063722", "0.42053616", "0.41987062", "0.41955593", "0.41803068", "0.41792476", "0.41774252", "0.41688505", "0.41598958", "0.41558084", "0.41539884", "0.414277", "0.4135612", "0.41337737", "0.4124274", "0.41206855", "0.4114685", "0.41049767", "0.4099948", "0.4094085", "0.40914857", "0.40887475", "0.4087553", "0.40852898", "0.40850738", "0.4078516", "0.40761253", "0.4067931", "0.40673795", "0.40659407", "0.40656388", "0.40654776", "0.40644085", "0.4059675", "0.40595347", "0.40543795", "0.40537378", "0.40534076", "0.4046482", "0.40460056", "0.4042607", "0.40424934", "0.40405995", "0.40375817", "0.40351635", "0.40332186", "0.4024952", "0.40219882" ]
0.8570746
0
NewListIssueGroupOfProjectVersionParams creates a new ListIssueGroupOfProjectVersionParams object with the default values initialized.
func NewListIssueGroupOfProjectVersionParams() *ListIssueGroupOfProjectVersionParams { var ( limitDefault = int32(200) showhiddenDefault = bool(false) showremovedDefault = bool(false) showshortfilenamesDefault = bool(false) showsuppressedDefault = bool(false) startDefault = int32(0) ) return &ListIssueGroupOfProjectVersionParams{ Limit: &limitDefault, Showhidden: &showhiddenDefault, Showremoved: &showremovedDefault, Showshortfilenames: &showshortfilenamesDefault, Showsuppressed: &showsuppressedDefault, Start: &startDefault, timeout: cr.DefaultTimeout, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewListIssueGroupOfProjectVersionParamsWithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\t\tHTTPClient: client,\n\t}\n}", "func NewListIssueGroupOfProjectVersionParamsWithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithContext(ctx context.Context) *ListIssueGroupOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFields(fields *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFields(fields)\n\treturn o\n}", "func NewListIssueGroupOfProjectVersionParamsWithContext(ctx context.Context) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\tContext: ctx,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFilter(filter *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFilter(filter)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithLimit(limit *int32) *ListIssueGroupOfProjectVersionParams {\n\to.SetLimit(limit)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithParentID(parentID int64) *ListIssueGroupOfProjectVersionParams {\n\to.SetParentID(parentID)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithQ(q *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetQ(q)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithStart(start *int32) *ListIssueGroupOfProjectVersionParams {\n\to.SetStart(start)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFilterset(filterset *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFilterset(filterset)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithGroupingtype(groupingtype *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetGroupingtype(groupingtype)\n\treturn o\n}", "func NewListSourceFileOfProjectVersionParams() *ListSourceFileOfProjectVersionParams {\n\tvar ()\n\treturn &ListSourceFileOfProjectVersionParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filter != nil {\n\n\t\t// query param filter\n\t\tvar qrFilter string\n\t\tif o.Filter != nil {\n\t\t\tqrFilter = *o.Filter\n\t\t}\n\t\tqFilter := qrFilter\n\t\tif qFilter != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filter\", qFilter); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filterset != nil {\n\n\t\t// query param filterset\n\t\tvar qrFilterset string\n\t\tif o.Filterset != nil {\n\t\t\tqrFilterset = *o.Filterset\n\t\t}\n\t\tqFilterset := qrFilterset\n\t\tif qFilterset != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filterset\", qFilterset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Groupingtype != nil {\n\n\t\t// query param groupingtype\n\t\tvar qrGroupingtype string\n\t\tif o.Groupingtype != nil {\n\t\t\tqrGroupingtype = *o.Groupingtype\n\t\t}\n\t\tqGroupingtype := qrGroupingtype\n\t\tif qGroupingtype != \"\" {\n\t\t\tif err := r.SetQueryParam(\"groupingtype\", qGroupingtype); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int32\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt32(qrLimit)\n\t\tif qLimit != \"\" {\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param parentId\n\tif err := r.SetPathParam(\"parentId\", swag.FormatInt64(o.ParentID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Qm != nil {\n\n\t\t// query param qm\n\t\tvar qrQm string\n\t\tif o.Qm != nil {\n\t\t\tqrQm = *o.Qm\n\t\t}\n\t\tqQm := qrQm\n\t\tif qQm != \"\" {\n\t\t\tif err := r.SetQueryParam(\"qm\", qQm); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showhidden != nil {\n\n\t\t// query param showhidden\n\t\tvar qrShowhidden bool\n\t\tif o.Showhidden != nil {\n\t\t\tqrShowhidden = *o.Showhidden\n\t\t}\n\t\tqShowhidden := swag.FormatBool(qrShowhidden)\n\t\tif qShowhidden != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showhidden\", qShowhidden); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showremoved != nil {\n\n\t\t// query param showremoved\n\t\tvar qrShowremoved bool\n\t\tif o.Showremoved != nil {\n\t\t\tqrShowremoved = *o.Showremoved\n\t\t}\n\t\tqShowremoved := swag.FormatBool(qrShowremoved)\n\t\tif qShowremoved != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showremoved\", qShowremoved); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showshortfilenames != nil {\n\n\t\t// query param showshortfilenames\n\t\tvar qrShowshortfilenames bool\n\t\tif o.Showshortfilenames != nil {\n\t\t\tqrShowshortfilenames = *o.Showshortfilenames\n\t\t}\n\t\tqShowshortfilenames := swag.FormatBool(qrShowshortfilenames)\n\t\tif qShowshortfilenames != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showshortfilenames\", qShowshortfilenames); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showsuppressed != nil {\n\n\t\t// query param showsuppressed\n\t\tvar qrShowsuppressed bool\n\t\tif o.Showsuppressed != nil {\n\t\t\tqrShowsuppressed = *o.Showsuppressed\n\t\t}\n\t\tqShowsuppressed := swag.FormatBool(qrShowsuppressed)\n\t\tif qShowsuppressed != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showsuppressed\", qShowsuppressed); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Start != nil {\n\n\t\t// query param start\n\t\tvar qrStart int32\n\t\tif o.Start != nil {\n\t\t\tqrStart = *o.Start\n\t\t}\n\t\tqStart := swag.FormatInt32(qrStart)\n\t\tif qStart != \"\" {\n\t\t\tif err := r.SetQueryParam(\"start\", qStart); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithShowhidden(showhidden *bool) *ListIssueGroupOfProjectVersionParams {\n\to.SetShowhidden(showhidden)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithQm(qm *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetQm(qm)\n\treturn o\n}", "func NewListSourceFileOfProjectVersionParamsWithHTTPClient(client *http.Client) *ListSourceFileOfProjectVersionParams {\n\tvar ()\n\treturn &ListSourceFileOfProjectVersionParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetUserIssueSearchOptionsOfProjectVersionParams() *GetUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &GetUserIssueSearchOptionsOfProjectVersionParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewUpdateUserIssueSearchOptionsOfProjectVersionParams() *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &UpdateUserIssueSearchOptionsOfProjectVersionParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewTestProjectVersionParams() *TestProjectVersionParams {\n\tvar ()\n\treturn &TestProjectVersionParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (c *UDBClient) NewChangeUDBParamGroupRequest() *ChangeUDBParamGroupRequest {\n\treq := &ChangeUDBParamGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(true)\n\treturn req\n}", "func NewListGroupsBadRequest() *ListGroupsBadRequest {\n\treturn &ListGroupsBadRequest{}\n}", "func CreateListExperimentGroupsRequest() (request *ListExperimentGroupsRequest) {\n\trequest = &ListExperimentGroupsRequest{\n\t\tRoaRequest: &requests.RoaRequest{},\n\t}\n\trequest.InitWithApiInfo(\"PaiRecService\", \"2022-12-13\", \"ListExperimentGroups\", \"/api/v1/experimentgroups\", \"\", \"\")\n\trequest.Method = requests.GET\n\treturn\n}", "func NewUserGroupListBadRequest() *UserGroupListBadRequest {\n\treturn &UserGroupListBadRequest{}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithShowremoved(showremoved *bool) *ListIssueGroupOfProjectVersionParams {\n\to.SetShowremoved(showremoved)\n\treturn o\n}", "func NewListSourceFileOfProjectVersionParamsWithTimeout(timeout time.Duration) *ListSourceFileOfProjectVersionParams {\n\tvar ()\n\treturn &ListSourceFileOfProjectVersionParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewUpdateUserIssueSearchOptionsOfProjectVersionParamsWithHTTPClient(client *http.Client) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &UpdateUserIssueSearchOptionsOfProjectVersionParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (m *MockProjectServiceIface) NewListProjectInvitationsParams() *ListProjectInvitationsParams {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"NewListProjectInvitationsParams\")\n\tret0, _ := ret[0].(*ListProjectInvitationsParams)\n\treturn ret0\n}", "func NewDeleteVeditProjectRequestWithoutParam() *DeleteVeditProjectRequest {\n\n return &DeleteVeditProjectRequest{\n JDCloudRequest: core.JDCloudRequest{\n URL: \"/veditProjects/{projectId}\",\n Method: \"DELETE\",\n Header: nil,\n Version: \"v1\",\n },\n }\n}", "func NewListServerGroupBadRequest() *ListServerGroupBadRequest {\n\treturn &ListServerGroupBadRequest{}\n}", "func (o *ListParams) WithProject(project string) *ListParams {\n\to.SetProject(project)\n\treturn o\n}", "func (o *ListSourceFileOfProjectVersionParams) WithContext(ctx context.Context) *ListSourceFileOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func NewGetGroupListPublicV1BadRequest() *GetGroupListPublicV1BadRequest {\n\treturn &GetGroupListPublicV1BadRequest{}\n}", "func NewGetUserIssueSearchOptionsOfProjectVersionParamsWithHTTPClient(client *http.Client) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &GetUserIssueSearchOptionsOfProjectVersionParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewListGroupsNotFound() *ListGroupsNotFound {\n\treturn &ListGroupsNotFound{}\n}", "func (c *UDBClient) NewDescribeUDBParamGroupRequest() *DescribeUDBParamGroupRequest {\n\treq := &DescribeUDBParamGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(true)\n\treturn req\n}", "func newUpdateProjectUpdateProjectRequest(ctx context.Context, f *Project, c *Client) (map[string]interface{}, error) {\n\treq := map[string]interface{}{}\n\n\tif v := f.Labels; !dcl.IsEmptyValueIndirect(v) {\n\t\treq[\"labels\"] = v\n\t}\n\treturn req, nil\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) WithContext(ctx context.Context) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) WithContext(ctx context.Context) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) WithFields(fields *string) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetFields(fields)\n\treturn o\n}", "func NewVulnerabilitiesRequest(packageList []string, ) *VulnerabilitiesRequest {\n\tthis := VulnerabilitiesRequest{}\n\tthis.PackageList = packageList\n\tvar thirdParty bool = false\n\tthis.ThirdParty = &thirdParty\n\treturn &this\n}", "func (o *ListSourceFileOfProjectVersionParams) WithFields(fields *string) *ListSourceFileOfProjectVersionParams {\n\to.SetFields(fields)\n\treturn o\n}", "func DecodeListProjectRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Decoder) func(*http.Request) (interface{}, error) {\n\treturn func(r *http.Request) (interface{}, error) {\n\t\tvar (\n\t\t\tid int32\n\t\t\tauth *string\n\t\t\terr error\n\n\t\t\tparams = mux.Vars(r)\n\t\t)\n\t\t{\n\t\t\tidRaw := params[\"id\"]\n\t\t\tv, err2 := strconv.ParseInt(idRaw, 10, 32)\n\t\t\tif err2 != nil {\n\t\t\t\terr = goa.MergeErrors(err, goa.InvalidFieldTypeError(\"id\", idRaw, \"integer\"))\n\t\t\t}\n\t\t\tid = int32(v)\n\t\t}\n\t\tauthRaw := r.Header.Get(\"Authorization\")\n\t\tif authRaw != \"\" {\n\t\t\tauth = &authRaw\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tpayload := NewListProjectPayload(id, auth)\n\t\tif payload.Auth != nil {\n\t\t\tif strings.Contains(*payload.Auth, \" \") {\n\t\t\t\t// Remove authorization scheme prefix (e.g. \"Bearer\")\n\t\t\t\tcred := strings.SplitN(*payload.Auth, \" \", 2)[1]\n\t\t\t\tpayload.Auth = &cred\n\t\t\t}\n\t\t}\n\n\t\treturn payload, nil\n\t}\n}", "func (m *MockProjectServiceIface) NewListProjectsParams() *ListProjectsParams {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"NewListProjectsParams\")\n\tret0, _ := ret[0].(*ListProjectsParams)\n\treturn ret0\n}", "func (client *AvailabilityGroupListenersClient) listByGroupCreateRequest(ctx context.Context, resourceGroupName string, sqlVirtualMachineGroupName string, options *AvailabilityGroupListenersClientListByGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif sqlVirtualMachineGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter sqlVirtualMachineGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sqlVirtualMachineGroupName}\", url.PathEscape(sqlVirtualMachineGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreateListDAGVersionsRequest() (request *ListDAGVersionsRequest) {\n\trequest = &ListDAGVersionsRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"dms-enterprise\", \"2018-11-01\", \"ListDAGVersions\", \"dms-enterprise\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func DecodeListProjectRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Decoder) func(*http.Request) (interface{}, error) {\n\treturn func(r *http.Request) (interface{}, error) {\n\t\tvar (\n\t\t\tid int32\n\t\t\tauth string\n\t\t\terr error\n\n\t\t\tparams = mux.Vars(r)\n\t\t)\n\t\t{\n\t\t\tidRaw := params[\"id\"]\n\t\t\tv, err2 := strconv.ParseInt(idRaw, 10, 32)\n\t\t\tif err2 != nil {\n\t\t\t\terr = goa.MergeErrors(err, goa.InvalidFieldTypeError(\"id\", idRaw, \"integer\"))\n\t\t\t}\n\t\t\tid = int32(v)\n\t\t}\n\t\tauth = r.Header.Get(\"Authorization\")\n\t\tif auth == \"\" {\n\t\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"Authorization\", \"header\"))\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tpayload := NewListProjectPayload(id, auth)\n\t\tif strings.Contains(payload.Auth, \" \") {\n\t\t\t// Remove authorization scheme prefix (e.g. \"Bearer\")\n\t\t\tcred := strings.SplitN(payload.Auth, \" \", 2)[1]\n\t\t\tpayload.Auth = cred\n\t\t}\n\n\t\treturn payload, nil\n\t}\n}", "func NewPostVolumeGroupsListDefault(code int) *PostVolumeGroupsListDefault {\n\treturn &PostVolumeGroupsListDefault{\n\t\t_statusCode: code,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithShowshortfilenames(showshortfilenames *bool) *ListIssueGroupOfProjectVersionParams {\n\to.SetShowshortfilenames(showshortfilenames)\n\treturn o\n}", "func NewListNSGroupsParams() *ListNSGroupsParams {\n\tvar (\n\t\tpageSizeDefault = int64(1000)\n\t\tpopulateReferencesDefault = bool(false)\n\t)\n\treturn &ListNSGroupsParams{\n\t\tPageSize: &pageSizeDefault,\n\t\tPopulateReferences: &populateReferencesDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetExampleNewProjectDescriptionCompatibilityVersion1Params() *GetExampleNewProjectDescriptionCompatibilityVersion1Params {\n\tvar ()\n\treturn &GetExampleNewProjectDescriptionCompatibilityVersion1Params{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (client *ConnectedEnvironmentsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ConnectedEnvironmentsClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func NewPatchApi24ProtectionGroupsBadRequest() *PatchApi24ProtectionGroupsBadRequest {\n\treturn &PatchApi24ProtectionGroupsBadRequest{}\n}", "func NewListComponentVersionsDefault(code int) *ListComponentVersionsDefault {\n\treturn &ListComponentVersionsDefault{\n\t\t_statusCode: code,\n\t}\n}", "func newKubeListRequest(values url.Values, site, resourceKind string) (*kubeproto.ListKubernetesResourcesRequest, error) {\n\tlimit, err := queryLimitAsInt32(values, \"limit\", defaults.MaxIterationLimit)\n\tif err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\n\tsortBy := types.GetSortByFromString(values.Get(\"sort\"))\n\n\tstartKey := values.Get(\"startKey\")\n\treq := &kubeproto.ListKubernetesResourcesRequest{\n\t\tResourceType: resourceKind,\n\t\tLimit: limit,\n\t\tStartKey: startKey,\n\t\tSortBy: &sortBy,\n\t\tPredicateExpression: values.Get(\"query\"),\n\t\tSearchKeywords: client.ParseSearchKeywords(values.Get(\"search\"), ' '),\n\t\tUseSearchAsRoles: values.Get(\"searchAsRoles\") == \"yes\",\n\t\tTeleportCluster: site,\n\t\tKubernetesCluster: values.Get(\"kubeCluster\"),\n\t\tKubernetesNamespace: values.Get(\"kubeNamespace\"),\n\t}\n\treturn req, nil\n}", "func NewUpdateUserIssueSearchOptionsOfProjectVersionParamsWithTimeout(timeout time.Duration) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &UpdateUserIssueSearchOptionsOfProjectVersionParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (client *ClustersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ClustersClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-11-08\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (rm *resourceManager) newListRequestPayload(\n\tr *resource,\n) (*svcsdk.DescribeReplicationGroupsInput, error) {\n\tres := &svcsdk.DescribeReplicationGroupsInput{}\n\n\tif r.ko.Spec.ReplicationGroupID != nil {\n\t\tres.SetReplicationGroupId(*r.ko.Spec.ReplicationGroupID)\n\t}\n\n\treturn res, nil\n}", "func NewProjectList(controller controller.Controller, router *Router) *ProjectList {\n\tp := &ProjectList{\n\t\tcontroller: controller,\n\t\trouter: router,\n\t}\n\tp.createComponents()\n\treturn p\n}", "func NewUpdateHostGroupsDefault(code int) *UpdateHostGroupsDefault {\n\treturn &UpdateHostGroupsDefault{\n\t\t_statusCode: code,\n\t}\n}", "func NewPcloudVolumegroupsGetBadRequest() *PcloudVolumegroupsGetBadRequest {\n\treturn &PcloudVolumegroupsGetBadRequest{}\n}", "func NewListGroupsDefault(code int) *ListGroupsDefault {\n\treturn &ListGroupsDefault{\n\t\t_statusCode: code,\n\t}\n}", "func NewUpdateCollectionBugTrackerOfProjectVersionBadRequest() *UpdateCollectionBugTrackerOfProjectVersionBadRequest {\n\treturn &UpdateCollectionBugTrackerOfProjectVersionBadRequest{}\n}", "func NewGetUserIssueSearchOptionsOfProjectVersionParamsWithTimeout(timeout time.Duration) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &GetUserIssueSearchOptionsOfProjectVersionParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (p *ProjectKeyManager) NewProjectKeyList() (pk []*ProjectKey) {\n\treturn NewProjectKeyList()\n}", "func (l *GroupLookup) newKeyGroup(entries []groupKeyListElement) *groupKeyList {\n\tid := l.nextID\n\tl.nextID++\n\treturn &groupKeyList{\n\t\tid: id,\n\t\telements: entries,\n\t}\n}", "func (client *ContainerGroupsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ContainerGroupsClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ManagedClustersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ManagedClustersClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func buildParams(region string, groups []string) []string {\n\tparams := []string{\n\t\t\"-g\", strings.Join(groups, \",\"),\n\t\t\"-M\", reportFormat,\n\t\t\"-F\", reportName,\n\t}\n\tif region != \"\" {\n\t\tparams = append(params, \"-r\", region, \"-f\", region)\n\t} else {\n\t\tparams = append(params, \"-r\", defaultAPIRegion)\n\t}\n\treturn params\n}", "func (client *SQLVirtualMachinesClient) listBySQLVMGroupCreateRequest(ctx context.Context, resourceGroupName string, sqlVirtualMachineGroupName string, options *SQLVirtualMachinesClientListBySQLVMGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/sqlVirtualMachines\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif sqlVirtualMachineGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter sqlVirtualMachineGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sqlVirtualMachineGroupName}\", url.PathEscape(sqlVirtualMachineGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-03-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func NewGetExampleNewProjectDescriptionCompatibilityVersion1ParamsWithHTTPClient(client *http.Client) *GetExampleNewProjectDescriptionCompatibilityVersion1Params {\n\tvar ()\n\treturn &GetExampleNewProjectDescriptionCompatibilityVersion1Params{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetAviServiceEngineGroupsBadRequest() *GetAviServiceEngineGroupsBadRequest {\n\n\treturn &GetAviServiceEngineGroupsBadRequest{}\n}", "func (c *UDBClient) NewCreateUDBParamGroupRequest() *CreateUDBParamGroupRequest {\n\treq := &CreateUDBParamGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(false)\n\treturn req\n}", "func (c *UDBClient) NewCreateUDBParamGroupRequest() *CreateUDBParamGroupRequest {\n\treq := &CreateUDBParamGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(false)\n\treturn req\n}", "func (c *UDBClient) NewUpdateUDBParamGroupRequest() *UpdateUDBParamGroupRequest {\n\treq := &UpdateUDBParamGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(true)\n\treturn req\n}", "func (m *OpenStackInstanceGroupV4Parameters) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func NewListPrioritiesBadRequest() *ListPrioritiesBadRequest {\n\treturn &ListPrioritiesBadRequest{}\n}", "func NewTestProjectVersionParamsWithTimeout(timeout time.Duration) *TestProjectVersionParams {\n\tvar ()\n\treturn &TestProjectVersionParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewUpdateBugfieldTemplateGroupBadRequest() *UpdateBugfieldTemplateGroupBadRequest {\n\treturn &UpdateBugfieldTemplateGroupBadRequest{}\n}", "func NewGetGroupMembersListPublicV1BadRequest() *GetGroupMembersListPublicV1BadRequest {\n\treturn &GetGroupMembersListPublicV1BadRequest{}\n}", "func newBGPFilterList() *api.BGPFilterList {\n\treturn &api.BGPFilterList{\n\t\tTypeMeta: metav1.TypeMeta{\n\t\t\tKind: api.KindBGPFilterList,\n\t\t\tAPIVersion: api.GroupVersionCurrent,\n\t\t},\n\t}\n}", "func NewListSourceFileOfProjectVersionParamsWithContext(ctx context.Context) *ListSourceFileOfProjectVersionParams {\n\tvar ()\n\treturn &ListSourceFileOfProjectVersionParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (client *MonitorsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *MonitorsClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-03-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func ProjectList(c *gin.Context) error {\n\tuserID, err := GetIDParam(c, userIDParam)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\toption := &model.ProjectQueryOption{\n\t\tUserID: userID,\n\t}\n\n\tif limit := c.Query(\"limit\"); limit != \"\" {\n\t\tif i, err := strconv.Atoi(limit); err == nil {\n\t\t\toption.Limit = i\n\t\t}\n\t}\n\n\tif offset := c.Query(\"offset\"); offset != \"\" {\n\t\tif i, err := strconv.Atoi(offset); err == nil {\n\t\t\toption.Offset = i\n\t\t}\n\t}\n\n\tif order := c.Query(\"order\"); order != \"\" {\n\t\toption.Order = order\n\t} else {\n\t\toption.Order = \"-created_at\"\n\t}\n\n\tif err := CheckUserPermission(c, *userID); err == nil {\n\t\toption.Private = true\n\t}\n\n\tlist, err := model.GetProjectList(option)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn common.APIResponse(c, http.StatusOK, list)\n}", "func (m *MockProjectServiceIface) NewListProjectRolePermissionsParams(projectid string) *ListProjectRolePermissionsParams {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"NewListProjectRolePermissionsParams\", projectid)\n\tret0, _ := ret[0].(*ListProjectRolePermissionsParams)\n\treturn ret0\n}", "func (s *ProjectService) NewListProjectInvitationsParams() *ListProjectInvitationsParams {\n\tp := &ListProjectInvitationsParams{}\n\tp.p = make(map[string]interface{})\n\treturn p\n}", "func NewPostApi24HostsProtectionGroupsBadRequest() *PostApi24HostsProtectionGroupsBadRequest {\n\treturn &PostApi24HostsProtectionGroupsBadRequest{}\n}", "func (o *TestProjectVersionParams) WithContext(ctx context.Context) *TestProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithShowsuppressed(showsuppressed *bool) *ListIssueGroupOfProjectVersionParams {\n\to.SetShowsuppressed(showsuppressed)\n\treturn o\n}", "func NewParamList(m map[string]interface{}) (*ParamList, error) {\n\tol := newOptionLoader(m)\n\n\tpl := &ParamList{\n\t\tapp: ol.LoadApp(),\n\t\tmoduleName: ol.LoadOptionalString(OptionModule),\n\t\tcomponentName: ol.LoadOptionalString(OptionComponentName),\n\t\tenvName: ol.LoadOptionalString(OptionEnvName),\n\n\t\tout: os.Stdout,\n\t\tfindModulesFn: component.ModulesFromEnv,\n\t\tfindModuleFn: component.GetModule,\n\t\tfindComponentFn: component.LocateComponent,\n\t}\n\n\tif ol.err != nil {\n\t\treturn nil, ol.err\n\t}\n\n\treturn pl, nil\n}", "func (o *TestProjectVersionParams) WithProjectVersionTestRequest(projectVersionTestRequest *models.ProjectVersionTestRequest) *TestProjectVersionParams {\n\to.SetProjectVersionTestRequest(projectVersionTestRequest)\n\treturn o\n}", "func CreateListServerGroupsRequest() (request *ListServerGroupsRequest) {\n\trequest = &ListServerGroupsRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Alb\", \"2020-06-16\", \"ListServerGroups\", \"alb\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func NewPcloudPlacementgroupsGetallBadRequest() *PcloudPlacementgroupsGetallBadRequest {\n\treturn &PcloudPlacementgroupsGetallBadRequest{}\n}", "func (client *ClustersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ClustersListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) WithParentID(parentID int64) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetParentID(parentID)\n\treturn o\n}", "func NewGetExampleNewProjectDescriptionCompatibilityVersion1ParamsWithTimeout(timeout time.Duration) *GetExampleNewProjectDescriptionCompatibilityVersion1Params {\n\tvar ()\n\treturn &GetExampleNewProjectDescriptionCompatibilityVersion1Params{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewOperatorGroupGetOperatorGroupMembersBadRequest() *OperatorGroupGetOperatorGroupMembersBadRequest {\n\treturn &OperatorGroupGetOperatorGroupMembersBadRequest{}\n}", "func (client *WorkspacesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *WorkspacesListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}" ]
[ "0.77106774", "0.7519926", "0.7266955", "0.7068472", "0.69551784", "0.6806871", "0.6550852", "0.6518673", "0.6478527", "0.641597", "0.63347816", "0.6258998", "0.61002636", "0.5913099", "0.57597464", "0.5716092", "0.5573168", "0.54209363", "0.5116466", "0.5106761", "0.50922406", "0.5089918", "0.50050324", "0.49314585", "0.48539278", "0.48478064", "0.47834992", "0.4775712", "0.47372413", "0.47159192", "0.46546474", "0.4615479", "0.46051347", "0.46011811", "0.45965326", "0.45848894", "0.45822603", "0.4581664", "0.45804042", "0.45763323", "0.45677906", "0.45629203", "0.45420676", "0.45367992", "0.45358437", "0.45230862", "0.45201296", "0.45186976", "0.45109963", "0.45012477", "0.4467901", "0.44547382", "0.44244763", "0.44085675", "0.43966648", "0.4388899", "0.43887138", "0.43876475", "0.4387446", "0.4385851", "0.43835902", "0.43814808", "0.43773276", "0.4363827", "0.43568888", "0.4326703", "0.43198448", "0.43042055", "0.42932528", "0.42931387", "0.42828435", "0.42649958", "0.4264913", "0.4262525", "0.42596555", "0.42596555", "0.42591015", "0.42527357", "0.42464405", "0.42455965", "0.42344096", "0.42320892", "0.42268485", "0.42139357", "0.4195726", "0.4190622", "0.4159134", "0.415894", "0.41530877", "0.4141204", "0.4134076", "0.41174492", "0.41161194", "0.41103283", "0.41068238", "0.4094059", "0.40928438", "0.40926018", "0.40879953", "0.4086237" ]
0.8728173
0
NewListIssueGroupOfProjectVersionParamsWithTimeout creates a new ListIssueGroupOfProjectVersionParams object with the default values initialized, and the ability to set a timeout on a request
func NewListIssueGroupOfProjectVersionParamsWithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams { var ( limitDefault = int32(200) showhiddenDefault = bool(false) showremovedDefault = bool(false) showshortfilenamesDefault = bool(false) showsuppressedDefault = bool(false) startDefault = int32(0) ) return &ListIssueGroupOfProjectVersionParams{ Limit: &limitDefault, Showhidden: &showhiddenDefault, Showremoved: &showremovedDefault, Showshortfilenames: &showshortfilenamesDefault, Showsuppressed: &showsuppressedDefault, Start: &startDefault, timeout: timeout, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ListIssueGroupOfProjectVersionParams) WithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func NewListIssueGroupOfProjectVersionParams() *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewListIssueGroupOfProjectVersionParamsWithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\t\tHTTPClient: client,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewTestProjectVersionParamsWithTimeout(timeout time.Duration) *TestProjectVersionParams {\n\tvar ()\n\treturn &TestProjectVersionParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithContext(ctx context.Context) *ListIssueGroupOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func NewListSourceFileOfProjectVersionParamsWithTimeout(timeout time.Duration) *ListSourceFileOfProjectVersionParams {\n\tvar ()\n\treturn &ListSourceFileOfProjectVersionParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) WithTimeout(timeout time.Duration) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *TestProjectVersionParams) WithTimeout(timeout time.Duration) *TestProjectVersionParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func NewGetUserIssueSearchOptionsOfProjectVersionParamsWithTimeout(timeout time.Duration) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &GetUserIssueSearchOptionsOfProjectVersionParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFields(fields *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFields(fields)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithLimit(limit *int32) *ListIssueGroupOfProjectVersionParams {\n\to.SetLimit(limit)\n\treturn o\n}", "func NewUpdateUserIssueSearchOptionsOfProjectVersionParamsWithTimeout(timeout time.Duration) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &UpdateUserIssueSearchOptionsOfProjectVersionParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ListSourceFileOfProjectVersionParams) WithTimeout(timeout time.Duration) *ListSourceFileOfProjectVersionParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) WithTimeout(timeout time.Duration) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListSourceFileOfProjectVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithParentID(parentID int64) *ListIssueGroupOfProjectVersionParams {\n\to.SetParentID(parentID)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFilter(filter *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFilter(filter)\n\treturn o\n}", "func NewTestProjectVersionParams() *TestProjectVersionParams {\n\tvar ()\n\treturn &TestProjectVersionParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *TestProjectVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewListNSGroupsParamsWithTimeout(timeout time.Duration) *ListNSGroupsParams {\n\tvar (\n\t\tpageSizeDefault = int64(1000)\n\t\tpopulateReferencesDefault = bool(false)\n\t)\n\treturn &ListNSGroupsParams{\n\t\tPageSize: &pageSizeDefault,\n\t\tPopulateReferences: &populateReferencesDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filter != nil {\n\n\t\t// query param filter\n\t\tvar qrFilter string\n\t\tif o.Filter != nil {\n\t\t\tqrFilter = *o.Filter\n\t\t}\n\t\tqFilter := qrFilter\n\t\tif qFilter != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filter\", qFilter); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filterset != nil {\n\n\t\t// query param filterset\n\t\tvar qrFilterset string\n\t\tif o.Filterset != nil {\n\t\t\tqrFilterset = *o.Filterset\n\t\t}\n\t\tqFilterset := qrFilterset\n\t\tif qFilterset != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filterset\", qFilterset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Groupingtype != nil {\n\n\t\t// query param groupingtype\n\t\tvar qrGroupingtype string\n\t\tif o.Groupingtype != nil {\n\t\t\tqrGroupingtype = *o.Groupingtype\n\t\t}\n\t\tqGroupingtype := qrGroupingtype\n\t\tif qGroupingtype != \"\" {\n\t\t\tif err := r.SetQueryParam(\"groupingtype\", qGroupingtype); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int32\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt32(qrLimit)\n\t\tif qLimit != \"\" {\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param parentId\n\tif err := r.SetPathParam(\"parentId\", swag.FormatInt64(o.ParentID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Qm != nil {\n\n\t\t// query param qm\n\t\tvar qrQm string\n\t\tif o.Qm != nil {\n\t\t\tqrQm = *o.Qm\n\t\t}\n\t\tqQm := qrQm\n\t\tif qQm != \"\" {\n\t\t\tif err := r.SetQueryParam(\"qm\", qQm); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showhidden != nil {\n\n\t\t// query param showhidden\n\t\tvar qrShowhidden bool\n\t\tif o.Showhidden != nil {\n\t\t\tqrShowhidden = *o.Showhidden\n\t\t}\n\t\tqShowhidden := swag.FormatBool(qrShowhidden)\n\t\tif qShowhidden != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showhidden\", qShowhidden); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showremoved != nil {\n\n\t\t// query param showremoved\n\t\tvar qrShowremoved bool\n\t\tif o.Showremoved != nil {\n\t\t\tqrShowremoved = *o.Showremoved\n\t\t}\n\t\tqShowremoved := swag.FormatBool(qrShowremoved)\n\t\tif qShowremoved != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showremoved\", qShowremoved); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showshortfilenames != nil {\n\n\t\t// query param showshortfilenames\n\t\tvar qrShowshortfilenames bool\n\t\tif o.Showshortfilenames != nil {\n\t\t\tqrShowshortfilenames = *o.Showshortfilenames\n\t\t}\n\t\tqShowshortfilenames := swag.FormatBool(qrShowshortfilenames)\n\t\tif qShowshortfilenames != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showshortfilenames\", qShowshortfilenames); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showsuppressed != nil {\n\n\t\t// query param showsuppressed\n\t\tvar qrShowsuppressed bool\n\t\tif o.Showsuppressed != nil {\n\t\t\tqrShowsuppressed = *o.Showsuppressed\n\t\t}\n\t\tqShowsuppressed := swag.FormatBool(qrShowsuppressed)\n\t\tif qShowsuppressed != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showsuppressed\", qShowsuppressed); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Start != nil {\n\n\t\t// query param start\n\t\tvar qrStart int32\n\t\tif o.Start != nil {\n\t\t\tqrStart = *o.Start\n\t\t}\n\t\tqStart := swag.FormatInt32(qrStart)\n\t\tif qStart != \"\" {\n\t\t\tif err := r.SetQueryParam(\"start\", qStart); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewGetProjectMetricsParamsWithTimeout(timeout time.Duration) *GetProjectMetricsParams {\n\tvar ()\n\treturn &GetProjectMetricsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *TicketProjectsImportProjectParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewDeletePackageVersionParamsWithTimeout(timeout time.Duration) *DeletePackageVersionParams {\n\tvar ()\n\treturn &DeletePackageVersionParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewContainerListParamsWithTimeout(timeout time.Duration) *ContainerListParams {\n\tvar (\n\t\tallDefault = bool(false)\n\t\tsizeDefault = bool(false)\n\t)\n\treturn &ContainerListParams{\n\t\tAll: &allDefault,\n\t\tSize: &sizeDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithQ(q *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetQ(q)\n\treturn o\n}", "func NewListIssueGroupOfProjectVersionParamsWithContext(ctx context.Context) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\tContext: ctx,\n\t}\n}", "func NewIssueGetLabelParamsWithTimeout(timeout time.Duration) *IssueGetLabelParams {\n\tvar ()\n\treturn &IssueGetLabelParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ReplaceProjectsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListNSGroupsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewListStacksByWorkspaceParamsWithTimeout(timeout time.Duration) *ListStacksByWorkspaceParams {\n\tvar ()\n\treturn &ListStacksByWorkspaceParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewServeGroupsParamsWithTimeout(timeout time.Duration) *ServeGroupsParams {\n\tvar ()\n\treturn &ServeGroupsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewListEnvironmentsParamsWithTimeout(timeout time.Duration) *ListEnvironmentsParams {\n\tvar ()\n\treturn &ListEnvironmentsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetUserIssueSearchOptionsOfProjectVersionParams() *GetUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &GetUserIssueSearchOptionsOfProjectVersionParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewIssueRemoveLabelParamsWithTimeout(timeout time.Duration) *IssueRemoveLabelParams {\n\tvar ()\n\treturn &IssueRemoveLabelParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewListParamsWithTimeout(timeout time.Duration) *ListParams {\n\tvar ()\n\treturn &ListParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetV1TicketingProjectsTicketingProjectIDConfigurationOptionsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewGetExampleNewProjectDescriptionCompatibilityVersion1ParamsWithTimeout(timeout time.Duration) *GetExampleNewProjectDescriptionCompatibilityVersion1Params {\n\tvar ()\n\treturn &GetExampleNewProjectDescriptionCompatibilityVersion1Params{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetExampleNewProjectDescriptionCompatibilityVersion1Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewUpdateUserIssueSearchOptionsOfProjectVersionParams() *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &UpdateUserIssueSearchOptionsOfProjectVersionParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewReplaceProjectsParamsWithTimeout(timeout time.Duration) *ReplaceProjectsParams {\n\tvar ()\n\treturn &ReplaceProjectsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewListNodesParamsWithTimeout(timeout time.Duration) *ListNodesParams {\n\tvar (\n\t\tpageSizeDefault = int64(1000)\n\t)\n\treturn &ListNodesParams{\n\t\tPageSize: &pageSizeDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewRemoveUserGroupParamsWithTimeout(timeout time.Duration) *RemoveUserGroupParams {\n\treturn &RemoveUserGroupParams{\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ServeGroupsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithStart(start *int32) *ListIssueGroupOfProjectVersionParams {\n\to.SetStart(start)\n\treturn o\n}", "func NewListSourceFileOfProjectVersionParams() *ListSourceFileOfProjectVersionParams {\n\tvar ()\n\treturn &ListSourceFileOfProjectVersionParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithShowhidden(showhidden *bool) *ListIssueGroupOfProjectVersionParams {\n\to.SetShowhidden(showhidden)\n\treturn o\n}", "func NewListInventoryModelsParamsWithTimeout(timeout time.Duration) *ListInventoryModelsParams {\n\tvar ()\n\treturn &ListInventoryModelsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewV2ListEventsParamsWithTimeout(timeout time.Duration) *V2ListEventsParams {\n\treturn &V2ListEventsParams{\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetTreeParamsWithTimeout(timeout time.Duration) *GetTreeParams {\n\tvar ()\n\treturn &GetTreeParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetProjectMetricsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewTemplateListParamsWithTimeout(timeout time.Duration) *TemplateListParams {\n\n\treturn &TemplateListParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewServeBuildTypesInProjectParamsWithTimeout(timeout time.Duration) *ServeBuildTypesInProjectParams {\n\tvar ()\n\treturn &ServeBuildTypesInProjectParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetActionTemplateLogoVersionParamsWithTimeout(timeout time.Duration) *GetActionTemplateLogoVersionParams {\n\tvar ()\n\treturn &GetActionTemplateLogoVersionParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetExampleNewProjectDescriptionCompatibilityVersion1Params) WithTimeout(timeout time.Duration) *GetExampleNewProjectDescriptionCompatibilityVersion1Params {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func NewRemoveControlFromGroupParamsWithTimeout(timeout time.Duration) *RemoveControlFromGroupParams {\n\tvar ()\n\treturn &RemoveControlFromGroupParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewPatchSepainstantIDParamsWithTimeout(timeout time.Duration) *PatchSepainstantIDParams {\n\tvar ()\n\treturn &PatchSepainstantIDParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewDeleteVersionControlRequestParamsWithTimeout(timeout time.Duration) *DeleteVersionControlRequestParams {\n\treturn &DeleteVersionControlRequestParams{\n\t\ttimeout: timeout,\n\t}\n}", "func (o *DeletePoolProjectParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *IssueGetLabelParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewListTaskNexusParamsWithTimeout(timeout time.Duration) *ListTaskNexusParams {\n\n\treturn &ListTaskNexusParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewListInstancesParamsWithTimeout(timeout time.Duration) *ListInstancesParams {\n\tvar ()\n\treturn &ListInstancesParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ListStacksByWorkspaceParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewWaitListParamsWithTimeout(timeout time.Duration) *WaitListParams {\n\treturn &WaitListParams{\n\t\ttimeout: timeout,\n\t}\n}", "func NewListEventsParamsWithTimeout(timeout time.Duration) *ListEventsParams {\n\tvar ()\n\treturn &ListEventsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetPackageSearchParamsWithTimeout(timeout time.Duration) *GetPackageSearchParams {\n\tvar ()\n\treturn &GetPackageSearchParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetGroupsByTypeUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ServiceBrokerOpenstacksHostsGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ServeBuildTypesInProjectParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *DeleteAPI24ProtectionGroupSnapshotsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewTicketProjectsImportProjectParamsWithTimeout(timeout time.Duration) *TicketProjectsImportProjectParams {\n\tvar ()\n\treturn &TicketProjectsImportProjectParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *CreateListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewDeprecatedCycleParamsWithTimeout(timeout time.Duration) *DeprecatedCycleParams {\n\n\treturn &DeprecatedCycleParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListEnvironmentsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *WaitListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ContainerListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewListEngineTypeParamsWithTimeout(timeout time.Duration) *ListEngineTypeParams {\n\tvar ()\n\treturn &ListEngineTypeParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (builder *TsListKeysCommandBuilder) WithTimeout(timeout time.Duration) *TsListKeysCommandBuilder {\n\ttimeoutMilliseconds := uint32(timeout / time.Millisecond)\n\tbuilder.timeout = timeout\n\tbuilder.protobuf.Timeout = &timeoutMilliseconds\n\treturn builder\n}", "func (o *ListDeploymentsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewGetAPI24ArraysNtpTestParamsWithTimeout(timeout time.Duration) *GetAPI24ArraysNtpTestParams {\n\tvar ()\n\treturn &GetAPI24ArraysNtpTestParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewDeleteAPI24ProtectionGroupSnapshotsParamsWithTimeout(timeout time.Duration) *DeleteAPI24ProtectionGroupSnapshotsParams {\n\tvar ()\n\treturn &DeleteAPI24ProtectionGroupSnapshotsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetProjectMetricsParams) WithTimeout(timeout time.Duration) *GetProjectMetricsParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func NewDeletePoolProjectParamsWithTimeout(timeout time.Duration) *DeletePoolProjectParams {\n\tvar ()\n\treturn &DeletePoolProjectParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewDeleteVeditProjectRequestWithoutParam() *DeleteVeditProjectRequest {\n\n return &DeleteVeditProjectRequest{\n JDCloudRequest: core.JDCloudRequest{\n URL: \"/veditProjects/{projectId}\",\n Method: \"DELETE\",\n Header: nil,\n Version: \"v1\",\n },\n }\n}", "func (o *DeletePackageVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PostAPI24ProtectionGroupSnapshotsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewQueryEntitlementsParamsWithTimeout(timeout time.Duration) *QueryEntitlementsParams {\n\tvar (\n\t\tactiveOnlyDefault = bool(true)\n\t\tlimitDefault = int32(20)\n\t\toffsetDefault = int32(0)\n\t)\n\treturn &QueryEntitlementsParams{\n\t\tActiveOnly: &activeOnlyDefault,\n\t\tLimit: &limitDefault,\n\t\tOffset: &offsetDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetAllPublicIPUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListParams) WithTimeout(timeout time.Duration) *ListParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *DeleteVersionControlRequestParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewPostAPI24ProtectionGroupSnapshotsParamsWithTimeout(timeout time.Duration) *PostAPI24ProtectionGroupSnapshotsParams {\n\tvar ()\n\treturn &PostAPI24ProtectionGroupSnapshotsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewPatchCategoriesGroupsGroupIDParamsWithTimeout(timeout time.Duration) *PatchCategoriesGroupsGroupIDParams {\n\tvar ()\n\treturn &PatchCategoriesGroupsGroupIDParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetBuildPropertiesParamsWithTimeout(timeout time.Duration) *GetBuildPropertiesParams {\n\tvar ()\n\treturn &GetBuildPropertiesParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFilterset(filterset *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFilterset(filterset)\n\treturn o\n}" ]
[ "0.8285777", "0.76709485", "0.6999598", "0.6788122", "0.6615298", "0.64738816", "0.6425471", "0.627703", "0.6234231", "0.6165254", "0.61050606", "0.60693634", "0.59893113", "0.5973421", "0.596011", "0.5880141", "0.5867417", "0.58638144", "0.5848223", "0.57892823", "0.5765758", "0.573725", "0.573315", "0.5666349", "0.5647953", "0.55885667", "0.5563744", "0.5545342", "0.5538737", "0.55181074", "0.5511512", "0.5444435", "0.54138917", "0.5394231", "0.5376588", "0.53300434", "0.53192943", "0.5290875", "0.52803075", "0.52674174", "0.52567095", "0.5241181", "0.5227356", "0.5226985", "0.52237964", "0.52030694", "0.5203039", "0.51768774", "0.5165836", "0.5146979", "0.50782764", "0.50555366", "0.505257", "0.50421935", "0.50367486", "0.5031406", "0.5027097", "0.50268495", "0.50258714", "0.5024304", "0.5019724", "0.501783", "0.5017816", "0.50136113", "0.50062287", "0.5005138", "0.50009817", "0.49939623", "0.49915588", "0.49877825", "0.49811777", "0.4978401", "0.4974511", "0.4972895", "0.4969671", "0.49637213", "0.4957479", "0.49548903", "0.49547356", "0.49417463", "0.49413627", "0.49255502", "0.49229205", "0.49159777", "0.4915719", "0.490784", "0.49026465", "0.48978442", "0.48977315", "0.48968467", "0.48966625", "0.48935425", "0.48927465", "0.48902214", "0.4889201", "0.4889169", "0.48748493", "0.48745248", "0.4869087", "0.48667493" ]
0.866563
0
NewListIssueGroupOfProjectVersionParamsWithContext creates a new ListIssueGroupOfProjectVersionParams object with the default values initialized, and the ability to set a context for a request
func NewListIssueGroupOfProjectVersionParamsWithContext(ctx context.Context) *ListIssueGroupOfProjectVersionParams { var ( limitDefault = int32(200) showhiddenDefault = bool(false) showremovedDefault = bool(false) showshortfilenamesDefault = bool(false) showsuppressedDefault = bool(false) startDefault = int32(0) ) return &ListIssueGroupOfProjectVersionParams{ Limit: &limitDefault, Showhidden: &showhiddenDefault, Showremoved: &showremovedDefault, Showshortfilenames: &showshortfilenamesDefault, Showsuppressed: &showsuppressedDefault, Start: &startDefault, Context: ctx, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ListIssueGroupOfProjectVersionParams) WithContext(ctx context.Context) *ListIssueGroupOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func NewListIssueGroupOfProjectVersionParams() *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFields(fields *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFields(fields)\n\treturn o\n}", "func NewListIssueGroupOfProjectVersionParamsWithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\t\tHTTPClient: client,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFilter(filter *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFilter(filter)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithQ(q *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetQ(q)\n\treturn o\n}", "func NewListIssueGroupOfProjectVersionParamsWithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewListSourceFileOfProjectVersionParamsWithContext(ctx context.Context) *ListSourceFileOfProjectVersionParams {\n\tvar ()\n\treturn &ListSourceFileOfProjectVersionParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithParentID(parentID int64) *ListIssueGroupOfProjectVersionParams {\n\to.SetParentID(parentID)\n\treturn o\n}", "func NewUpdateUserIssueSearchOptionsOfProjectVersionParamsWithContext(ctx context.Context) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &UpdateUserIssueSearchOptionsOfProjectVersionParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithLimit(limit *int32) *ListIssueGroupOfProjectVersionParams {\n\to.SetLimit(limit)\n\treturn o\n}", "func NewGetUserIssueSearchOptionsOfProjectVersionParamsWithContext(ctx context.Context) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &GetUserIssueSearchOptionsOfProjectVersionParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewTestProjectVersionParamsWithContext(ctx context.Context) *TestProjectVersionParams {\n\tvar ()\n\treturn &TestProjectVersionParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithStart(start *int32) *ListIssueGroupOfProjectVersionParams {\n\to.SetStart(start)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFilterset(filterset *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFilterset(filterset)\n\treturn o\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) WithContext(ctx context.Context) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) WithContext(ctx context.Context) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithGroupingtype(groupingtype *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetGroupingtype(groupingtype)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithQm(qm *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetQm(qm)\n\treturn o\n}", "func (o *ListSourceFileOfProjectVersionParams) WithContext(ctx context.Context) *ListSourceFileOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *TestProjectVersionParams) WithContext(ctx context.Context) *TestProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func NewUpdateUserIssueSearchOptionsOfProjectVersionParamsWithHTTPClient(client *http.Client) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &UpdateUserIssueSearchOptionsOfProjectVersionParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithShowhidden(showhidden *bool) *ListIssueGroupOfProjectVersionParams {\n\to.SetShowhidden(showhidden)\n\treturn o\n}", "func NewGetUserIssueSearchOptionsOfProjectVersionParams() *GetUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &GetUserIssueSearchOptionsOfProjectVersionParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetUserIssueSearchOptionsOfProjectVersionParamsWithHTTPClient(client *http.Client) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &GetUserIssueSearchOptionsOfProjectVersionParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewUpdateUserIssueSearchOptionsOfProjectVersionParams() *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &UpdateUserIssueSearchOptionsOfProjectVersionParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewV2ListEventsParamsWithContext(ctx context.Context) *V2ListEventsParams {\n\treturn &V2ListEventsParams{\n\t\tContext: ctx,\n\t}\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) WithFields(fields *string) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetFields(fields)\n\treturn o\n}", "func NewListSourceFileOfProjectVersionParams() *ListSourceFileOfProjectVersionParams {\n\tvar ()\n\treturn &ListSourceFileOfProjectVersionParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetExampleNewProjectDescriptionCompatibilityVersion1ParamsWithContext(ctx context.Context) *GetExampleNewProjectDescriptionCompatibilityVersion1Params {\n\tvar ()\n\treturn &GetExampleNewProjectDescriptionCompatibilityVersion1Params{\n\n\t\tContext: ctx,\n\t}\n}", "func NewListSourceFileOfProjectVersionParamsWithHTTPClient(client *http.Client) *ListSourceFileOfProjectVersionParams {\n\tvar ()\n\treturn &ListSourceFileOfProjectVersionParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (mr *MockRDSAPIMockRecorder) ModifyDBClusterParameterGroupWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ModifyDBClusterParameterGroupWithContext\", reflect.TypeOf((*MockRDSAPI)(nil).ModifyDBClusterParameterGroupWithContext), varargs...)\n}", "func (mr *MockRDSAPIMockRecorder) ModifyDBParameterGroupWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ModifyDBParameterGroupWithContext\", reflect.TypeOf((*MockRDSAPI)(nil).ModifyDBParameterGroupWithContext), varargs...)\n}", "func (m *MockRDSAPI) ModifyDBClusterParameterGroupWithContext(arg0 aws.Context, arg1 *rds.ModifyDBClusterParameterGroupInput, arg2 ...request.Option) (*rds.DBClusterParameterGroupNameMessage, error) {\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"ModifyDBClusterParameterGroupWithContext\", varargs...)\n\tret0, _ := ret[0].(*rds.DBClusterParameterGroupNameMessage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func NewPostLolHighlightsV1HighlightsParamsWithContext(ctx context.Context) *PostLolHighlightsV1HighlightsParams {\n\n\treturn &PostLolHighlightsV1HighlightsParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewListAlertableEventTypeParamsWithContext(ctx context.Context) *ListAlertableEventTypeParams {\n\tvar ()\n\treturn &ListAlertableEventTypeParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (c *Connect) ListEvaluationFormVersionsWithContext(ctx aws.Context, input *ListEvaluationFormVersionsInput, opts ...request.Option) (*ListEvaluationFormVersionsOutput, error) {\n\treq, out := c.ListEvaluationFormVersionsRequest(input)\n\treq.SetContext(ctx)\n\treq.ApplyOptions(opts...)\n\treturn out, req.Send()\n}", "func NewPatchApi24ProtectionGroupsBadRequest() *PatchApi24ProtectionGroupsBadRequest {\n\treturn &PatchApi24ProtectionGroupsBadRequest{}\n}", "func NewListGroupsBadRequest() *ListGroupsBadRequest {\n\treturn &ListGroupsBadRequest{}\n}", "func NewPatchV1ChangesEventsChangeEventIDParamsWithContext(ctx context.Context) *PatchV1ChangesEventsChangeEventIDParams {\n\tvar ()\n\treturn &PatchV1ChangesEventsChangeEventIDParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewUpdateCollectionBugTrackerOfProjectVersionBadRequest() *UpdateCollectionBugTrackerOfProjectVersionBadRequest {\n\treturn &UpdateCollectionBugTrackerOfProjectVersionBadRequest{}\n}", "func NewGetFirmwareUpgradeStatusesMoidParamsWithContext(ctx context.Context) *GetFirmwareUpgradeStatusesMoidParams {\n\tvar ()\n\treturn &GetFirmwareUpgradeStatusesMoidParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (c *SageMaker) ListModelPackageGroupsWithContext(ctx aws.Context, input *ListModelPackageGroupsInput, opts ...request.Option) (*ListModelPackageGroupsOutput, error) {\n\treq, out := c.ListModelPackageGroupsRequest(input)\n\treq.SetContext(ctx)\n\treq.ApplyOptions(opts...)\n\treturn out, req.Send()\n}", "func (mr *MockRDSAPIMockRecorder) DescribeDBClusterParameterGroupsWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"DescribeDBClusterParameterGroupsWithContext\", reflect.TypeOf((*MockRDSAPI)(nil).DescribeDBClusterParameterGroupsWithContext), varargs...)\n}", "func NewUpdateUserIssueSearchOptionsOfProjectVersionParamsWithTimeout(timeout time.Duration) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &UpdateUserIssueSearchOptionsOfProjectVersionParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewListEnvironmentsParamsWithContext(ctx context.Context) *ListEnvironmentsParams {\n\tvar ()\n\treturn &ListEnvironmentsParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (o *ListSourceFileOfProjectVersionParams) WithFields(fields *string) *ListSourceFileOfProjectVersionParams {\n\to.SetFields(fields)\n\treturn o\n}", "func (c *Client) GetVersionsContext(ctx context.Context, projectIDOrKey interface{}) ([]*Version, error) {\n\tu := fmt.Sprintf(\"/api/v2/projects/%v/versions\", projectIDOrKey)\n\n\treq, err := c.NewRequest(\"GET\", u, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar versions []*Version\n\tif err := c.Do(ctx, req, &versions); err != nil {\n\t\treturn nil, err\n\t}\n\treturn versions, nil\n}", "func NewTestProjectVersionParams() *TestProjectVersionParams {\n\tvar ()\n\treturn &TestProjectVersionParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (m *MockRDSAPI) ModifyDBParameterGroupWithContext(arg0 aws.Context, arg1 *rds.ModifyDBParameterGroupInput, arg2 ...request.Option) (*rds.DBParameterGroupNameMessage, error) {\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"ModifyDBParameterGroupWithContext\", varargs...)\n\tret0, _ := ret[0].(*rds.DBParameterGroupNameMessage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockRDSAPI) DescribeDBClusterParameterGroupsWithContext(arg0 aws.Context, arg1 *rds.DescribeDBClusterParameterGroupsInput, arg2 ...request.Option) (*rds.DescribeDBClusterParameterGroupsOutput, error) {\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"DescribeDBClusterParameterGroupsWithContext\", varargs...)\n\tret0, _ := ret[0].(*rds.DescribeDBClusterParameterGroupsOutput)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func NewDeleteChartrepoRepoChartsNameVersionLabelsIDParamsWithContext(ctx context.Context) *DeleteChartrepoRepoChartsNameVersionLabelsIDParams {\n\tvar ()\n\treturn &DeleteChartrepoRepoChartsNameVersionLabelsIDParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (m *OpenStackInstanceGroupV4Parameters) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func NewGetUserIssueSearchOptionsOfProjectVersionParamsWithTimeout(timeout time.Duration) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &GetUserIssueSearchOptionsOfProjectVersionParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filter != nil {\n\n\t\t// query param filter\n\t\tvar qrFilter string\n\t\tif o.Filter != nil {\n\t\t\tqrFilter = *o.Filter\n\t\t}\n\t\tqFilter := qrFilter\n\t\tif qFilter != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filter\", qFilter); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filterset != nil {\n\n\t\t// query param filterset\n\t\tvar qrFilterset string\n\t\tif o.Filterset != nil {\n\t\t\tqrFilterset = *o.Filterset\n\t\t}\n\t\tqFilterset := qrFilterset\n\t\tif qFilterset != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filterset\", qFilterset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Groupingtype != nil {\n\n\t\t// query param groupingtype\n\t\tvar qrGroupingtype string\n\t\tif o.Groupingtype != nil {\n\t\t\tqrGroupingtype = *o.Groupingtype\n\t\t}\n\t\tqGroupingtype := qrGroupingtype\n\t\tif qGroupingtype != \"\" {\n\t\t\tif err := r.SetQueryParam(\"groupingtype\", qGroupingtype); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int32\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt32(qrLimit)\n\t\tif qLimit != \"\" {\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param parentId\n\tif err := r.SetPathParam(\"parentId\", swag.FormatInt64(o.ParentID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Qm != nil {\n\n\t\t// query param qm\n\t\tvar qrQm string\n\t\tif o.Qm != nil {\n\t\t\tqrQm = *o.Qm\n\t\t}\n\t\tqQm := qrQm\n\t\tif qQm != \"\" {\n\t\t\tif err := r.SetQueryParam(\"qm\", qQm); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showhidden != nil {\n\n\t\t// query param showhidden\n\t\tvar qrShowhidden bool\n\t\tif o.Showhidden != nil {\n\t\t\tqrShowhidden = *o.Showhidden\n\t\t}\n\t\tqShowhidden := swag.FormatBool(qrShowhidden)\n\t\tif qShowhidden != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showhidden\", qShowhidden); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showremoved != nil {\n\n\t\t// query param showremoved\n\t\tvar qrShowremoved bool\n\t\tif o.Showremoved != nil {\n\t\t\tqrShowremoved = *o.Showremoved\n\t\t}\n\t\tqShowremoved := swag.FormatBool(qrShowremoved)\n\t\tif qShowremoved != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showremoved\", qShowremoved); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showshortfilenames != nil {\n\n\t\t// query param showshortfilenames\n\t\tvar qrShowshortfilenames bool\n\t\tif o.Showshortfilenames != nil {\n\t\t\tqrShowshortfilenames = *o.Showshortfilenames\n\t\t}\n\t\tqShowshortfilenames := swag.FormatBool(qrShowshortfilenames)\n\t\tif qShowshortfilenames != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showshortfilenames\", qShowshortfilenames); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showsuppressed != nil {\n\n\t\t// query param showsuppressed\n\t\tvar qrShowsuppressed bool\n\t\tif o.Showsuppressed != nil {\n\t\t\tqrShowsuppressed = *o.Showsuppressed\n\t\t}\n\t\tqShowsuppressed := swag.FormatBool(qrShowsuppressed)\n\t\tif qShowsuppressed != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showsuppressed\", qShowsuppressed); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Start != nil {\n\n\t\t// query param start\n\t\tvar qrStart int32\n\t\tif o.Start != nil {\n\t\t\tqrStart = *o.Start\n\t\t}\n\t\tqStart := swag.FormatInt32(qrStart)\n\t\tif qStart != \"\" {\n\t\t\tif err := r.SetQueryParam(\"start\", qStart); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func NewDeleteAPI24ProtectionGroupSnapshotsParamsWithContext(ctx context.Context) *DeleteAPI24ProtectionGroupSnapshotsParams {\n\tvar ()\n\treturn &DeleteAPI24ProtectionGroupSnapshotsParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewPostAPI24ProtectionGroupSnapshotsParamsWithContext(ctx context.Context) *PostAPI24ProtectionGroupSnapshotsParams {\n\tvar ()\n\treturn &PostAPI24ProtectionGroupSnapshotsParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithShowremoved(showremoved *bool) *ListIssueGroupOfProjectVersionParams {\n\to.SetShowremoved(showremoved)\n\treturn o\n}", "func (c *RAM) ListPermissionVersionsWithContext(ctx aws.Context, input *ListPermissionVersionsInput, opts ...request.Option) (*ListPermissionVersionsOutput, error) {\n\treq, out := c.ListPermissionVersionsRequest(input)\n\treq.SetContext(ctx)\n\treq.ApplyOptions(opts...)\n\treturn out, req.Send()\n}", "func NewListEngineTypeParamsWithContext(ctx context.Context) *ListEngineTypeParams {\n\tvar ()\n\treturn &ListEngineTypeParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) WithHTTPClient(client *http.Client) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *TestProjectVersionParams) WithProjectVersionTestRequest(projectVersionTestRequest *models.ProjectVersionTestRequest) *TestProjectVersionParams {\n\to.SetProjectVersionTestRequest(projectVersionTestRequest)\n\treturn o\n}", "func NewListEventsParamsWithContext(ctx context.Context) *ListEventsParams {\n\tvar ()\n\treturn &ListEventsParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (o *ListSourceFileOfProjectVersionParams) WithQ(q *string) *ListSourceFileOfProjectVersionParams {\n\to.SetQ(q)\n\treturn o\n}", "func NewGetApi24RemoteProtectionGroupSnapshotsBadRequest() *GetApi24RemoteProtectionGroupSnapshotsBadRequest {\n\treturn &GetApi24RemoteProtectionGroupSnapshotsBadRequest{}\n}", "func NewUserGroupListBadRequest() *UserGroupListBadRequest {\n\treturn &UserGroupListBadRequest{}\n}", "func NewOperatorGroupGetOperatorGroupMembersBadRequest() *OperatorGroupGetOperatorGroupMembersBadRequest {\n\treturn &OperatorGroupGetOperatorGroupMembersBadRequest{}\n}", "func NewPcloudVolumegroupsGetBadRequest() *PcloudVolumegroupsGetBadRequest {\n\treturn &PcloudVolumegroupsGetBadRequest{}\n}", "func NewAdminSearchUserV3ParamsWithContext(ctx context.Context) *AdminSearchUserV3Params {\n\tvar ()\n\treturn &AdminSearchUserV3Params{\n\n\t\tContext: ctx,\n\t}\n}", "func NewValidateUpdateSymfilePinningParamsWithContext(ctx context.Context) *ValidateUpdateSymfilePinningParams {\n\tvar ()\n\treturn &ValidateUpdateSymfilePinningParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (mr *MockRDSAPIMockRecorder) ResetDBClusterParameterGroupWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ResetDBClusterParameterGroupWithContext\", reflect.TypeOf((*MockRDSAPI)(nil).ResetDBClusterParameterGroupWithContext), varargs...)\n}", "func NewQueryEntitlementsParamsWithContext(ctx context.Context) *QueryEntitlementsParams {\n\tvar (\n\t\tactiveOnlyDefault = bool(true)\n\t\tlimitDefault = int32(20)\n\t\toffsetDefault = int32(0)\n\t)\n\treturn &QueryEntitlementsParams{\n\t\tActiveOnly: &activeOnlyDefault,\n\t\tLimit: &limitDefault,\n\t\tOffset: &offsetDefault,\n\n\t\tContext: ctx,\n\t}\n}", "func (b *MessagesGetLongPollServerBuilder) LpVersion(v int) *MessagesGetLongPollServerBuilder {\n\tb.Params[\"lp_version\"] = v\n\treturn b\n}", "func NewListSourceFileOfProjectVersionParamsWithTimeout(timeout time.Duration) *ListSourceFileOfProjectVersionParams {\n\tvar ()\n\treturn &ListSourceFileOfProjectVersionParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewListServerGroupBadRequest() *ListServerGroupBadRequest {\n\treturn &ListServerGroupBadRequest{}\n}", "func (o *ListParams) WithAPIVersion(aPIVersion string) *ListParams {\n\to.SetAPIVersion(aPIVersion)\n\treturn o\n}", "func (mr *MockRDSAPIMockRecorder) DescribeDBParameterGroupsWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"DescribeDBParameterGroupsWithContext\", reflect.TypeOf((*MockRDSAPI)(nil).DescribeDBParameterGroupsWithContext), varargs...)\n}", "func NewDeletePackageVersionParamsWithContext(ctx context.Context) *DeletePackageVersionParams {\n\tvar ()\n\treturn &DeletePackageVersionParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewListAlertsParamsWithContext(ctx context.Context) *ListAlertsParams {\n\tvar ()\n\treturn &ListAlertsParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (mr *MockRDSAPIMockRecorder) CreateDBClusterParameterGroupWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"CreateDBClusterParameterGroupWithContext\", reflect.TypeOf((*MockRDSAPI)(nil).CreateDBClusterParameterGroupWithContext), varargs...)\n}", "func NewFieldHistogramKeywordParamsWithContext(ctx context.Context) *FieldHistogramKeywordParams {\n\tvar ()\n\treturn &FieldHistogramKeywordParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) WithHTTPClient(client *http.Client) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (m *MockRDSAPI) DescribeDBParameterGroupsWithContext(arg0 aws.Context, arg1 *rds.DescribeDBParameterGroupsInput, arg2 ...request.Option) (*rds.DescribeDBParameterGroupsOutput, error) {\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"DescribeDBParameterGroupsWithContext\", varargs...)\n\tret0, _ := ret[0].(*rds.DescribeDBParameterGroupsOutput)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) WithParentID(parentID int64) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetParentID(parentID)\n\treturn o\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) WithResource(resource *models.UserIssueSearchOptions) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetResource(resource)\n\treturn o\n}", "func (mr *MockRDSAPIMockRecorder) ModifyOptionGroupWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ModifyOptionGroupWithContext\", reflect.TypeOf((*MockRDSAPI)(nil).ModifyOptionGroupWithContext), varargs...)\n}", "func (mr *MockRDSAPIMockRecorder) ResetDBParameterGroupWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ResetDBParameterGroupWithContext\", reflect.TypeOf((*MockRDSAPI)(nil).ResetDBParameterGroupWithContext), varargs...)\n}", "func (o *ListParams) WithProject(project string) *ListParams {\n\to.SetProject(project)\n\treturn o\n}", "func NewAlertGetMonitorGroupAlertsParamsWithContext(ctx context.Context) *AlertGetMonitorGroupAlertsParams {\n\tvar (\n\t\tincludeRemindersDefault = bool(false)\n\t\tpresetPeriodDefault = string(\"Last24Hours\")\n\t\tsortingDefault = string(\"Descending\")\n\t\ttakeDefault = int32(100)\n\t)\n\treturn &AlertGetMonitorGroupAlertsParams{\n\t\tIncludeReminders: &includeRemindersDefault,\n\t\tPresetPeriod: &presetPeriodDefault,\n\t\tSorting: &sortingDefault,\n\t\tTake: &takeDefault,\n\n\t\tContext: ctx,\n\t}\n}", "func NewListStacksByWorkspaceParamsWithContext(ctx context.Context) *ListStacksByWorkspaceParams {\n\tvar ()\n\treturn &ListStacksByWorkspaceParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetGroupListPublicV1BadRequest() *GetGroupListPublicV1BadRequest {\n\treturn &GetGroupListPublicV1BadRequest{}\n}", "func NewValidateParamsWithContext(ctx context.Context) *ValidateParams {\n\treturn &ValidateParams{\n\t\tContext: ctx,\n\t}\n}", "func (c *SageMaker) ListImageVersionsWithContext(ctx aws.Context, input *ListImageVersionsInput, opts ...request.Option) (*ListImageVersionsOutput, error) {\n\treq, out := c.ListImageVersionsRequest(input)\n\treq.SetContext(ctx)\n\treq.ApplyOptions(opts...)\n\treturn out, req.Send()\n}", "func NewUpdateComparisonReportParamsWithContext(ctx context.Context) *UpdateComparisonReportParams {\n\treturn &UpdateComparisonReportParams{\n\t\tContext: ctx,\n\t}\n}", "func NewUserPasswordCheckParamsWithContext(ctx context.Context) *UserPasswordCheckParams {\n\tvar ()\n\treturn &UserPasswordCheckParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewUpdateBuildPropertiesParamsWithContext(ctx context.Context) *UpdateBuildPropertiesParams {\n\tvar ()\n\treturn &UpdateBuildPropertiesParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewMonitorCheckGetScreenshotsParamsWithContext(ctx context.Context) *MonitorCheckGetScreenshotsParams {\n\tvar ()\n\treturn &MonitorCheckGetScreenshotsParams{\n\n\t\tContext: ctx,\n\t}\n}" ]
[ "0.7456868", "0.7009486", "0.656374", "0.65403444", "0.6411083", "0.6195592", "0.60353374", "0.5974516", "0.5833243", "0.58255297", "0.57971835", "0.5711053", "0.5581234", "0.5545537", "0.55109894", "0.5403098", "0.5391696", "0.53086615", "0.528166", "0.515868", "0.503509", "0.48862678", "0.47990295", "0.4784236", "0.4770165", "0.47440797", "0.4707916", "0.4698091", "0.4648388", "0.4584277", "0.45771202", "0.4571332", "0.4514925", "0.44005823", "0.42942396", "0.42805037", "0.42715326", "0.42620307", "0.4261095", "0.42426696", "0.4233813", "0.42237443", "0.4203852", "0.42021188", "0.41777197", "0.41736898", "0.41507286", "0.41501606", "0.41411734", "0.4139789", "0.41386405", "0.4120117", "0.4119447", "0.41167557", "0.41158465", "0.4102275", "0.40995115", "0.40868855", "0.4071977", "0.40698546", "0.4068421", "0.40676042", "0.40581685", "0.40451944", "0.40327787", "0.40213966", "0.40205058", "0.401181", "0.3977544", "0.39736634", "0.39695272", "0.3968843", "0.39681524", "0.3949671", "0.39443126", "0.3928503", "0.39208597", "0.39186442", "0.39111686", "0.39097828", "0.3908019", "0.39074457", "0.38977194", "0.38962233", "0.38912567", "0.38877106", "0.386806", "0.3853332", "0.38501456", "0.38490233", "0.38478318", "0.38468885", "0.38466713", "0.38446128", "0.38287532", "0.3819499", "0.38131374", "0.3810926", "0.38072884", "0.38056841" ]
0.8186808
0
NewListIssueGroupOfProjectVersionParamsWithHTTPClient creates a new ListIssueGroupOfProjectVersionParams object with the default values initialized, and the ability to set a custom HTTPClient for a request
func NewListIssueGroupOfProjectVersionParamsWithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams { var ( limitDefault = int32(200) showhiddenDefault = bool(false) showremovedDefault = bool(false) showshortfilenamesDefault = bool(false) showsuppressedDefault = bool(false) startDefault = int32(0) ) return &ListIssueGroupOfProjectVersionParams{ Limit: &limitDefault, Showhidden: &showhiddenDefault, Showremoved: &showremovedDefault, Showshortfilenames: &showshortfilenamesDefault, Showsuppressed: &showsuppressedDefault, Start: &startDefault, HTTPClient: client, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ListIssueGroupOfProjectVersionParams) WithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewListIssueGroupOfProjectVersionParams() *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewListIssueGroupOfProjectVersionParamsWithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewTestProjectVersionParamsWithHTTPClient(client *http.Client) *TestProjectVersionParams {\n\tvar ()\n\treturn &TestProjectVersionParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *ListSourceFileOfProjectVersionParams) WithHTTPClient(client *http.Client) *ListSourceFileOfProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) WithHTTPClient(client *http.Client) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func NewListSourceFileOfProjectVersionParamsWithHTTPClient(client *http.Client) *ListSourceFileOfProjectVersionParams {\n\tvar ()\n\treturn &ListSourceFileOfProjectVersionParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *ListSourceFileOfProjectVersionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *TestProjectVersionParams) WithHTTPClient(client *http.Client) *TestProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) WithHTTPClient(client *http.Client) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithContext(ctx context.Context) *ListIssueGroupOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *ListNSGroupsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *TestProjectVersionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFields(fields *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFields(fields)\n\treturn o\n}", "func (o *TicketProjectsImportProjectParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewListParamsWithHTTPClient(client *http.Client) *ListParams {\n\tvar ()\n\treturn &ListParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetUserIssueSearchOptionsOfProjectVersionParamsWithHTTPClient(client *http.Client) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &GetUserIssueSearchOptionsOfProjectVersionParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *ReplaceProjectsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewGetProjectMetricsParamsWithHTTPClient(client *http.Client) *GetProjectMetricsParams {\n\tvar ()\n\treturn &GetProjectMetricsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewContainerListParamsWithHTTPClient(client *http.Client) *ContainerListParams {\n\tvar (\n\t\tallDefault = bool(false)\n\t\tsizeDefault = bool(false)\n\t)\n\treturn &ContainerListParams{\n\t\tAll: &allDefault,\n\t\tSize: &sizeDefault,\n\t\tHTTPClient: client,\n\t}\n}", "func (o *ServeGroupsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewServeGroupsParamsWithHTTPClient(client *http.Client) *ServeGroupsParams {\n\tvar ()\n\treturn &ServeGroupsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *GetProjectMetricsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ContainerListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *WaitListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewUpdateUserIssueSearchOptionsOfProjectVersionParamsWithHTTPClient(client *http.Client) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &UpdateUserIssueSearchOptionsOfProjectVersionParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *CreateListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PostAPI24ProtectionGroupSnapshotsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListParams) WithHTTPClient(client *http.Client) *ListParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func NewHTTPClient(formats strfmt.Registry) *V3 {\n\treturn NewHTTPClientWithConfig(formats, nil)\n}", "func (o *GetListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *WaitListParams) WithHTTPClient(client *http.Client) *WaitListParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *GetProjectMetricsParams) WithHTTPClient(client *http.Client) *GetProjectMetricsParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *ApplicationComponentSnapshotCollectionGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewListIssueGroupOfProjectVersionParamsWithContext(ctx context.Context) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\tContext: ctx,\n\t}\n}", "func (o *DeletePoolProjectParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *DeleteAPI24ProtectionGroupSnapshotsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *MultiDeleteIssueAttachmentOfIssueParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *AlertGetMonitorGroupAlertsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewIssueGetLabelParamsWithHTTPClient(client *http.Client) *IssueGetLabelParams {\n\tvar ()\n\treturn &IssueGetLabelParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *CreateNetworkGroupPolicyParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetV1MembershipsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *IssueGetLabelParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *GetV1TicketingProjectsTicketingProjectIDConfigurationOptionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *RepoGetAllCommitsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListPipelinesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLolAcsV2MatchlistsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *IgroupInitiatorCreateParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PostAPI24PoliciesNfsMembersParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewReplaceProjectsParamsWithHTTPClient(client *http.Client) *ReplaceProjectsParams {\n\tvar ()\n\treturn &ReplaceProjectsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *ListStacksByWorkspaceParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *RemoveUserGroupParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *SafeObjectListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ChatNewParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *RetrieveCustomerGroupParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetGroupsGidPermissionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListSSHKeysParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLolInventoryV1PlayersByPuuidInventoryParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ImagePruneParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *QtreeCollectionGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewListNSGroupsParamsWithHTTPClient(client *http.Client) *ListNSGroupsParams {\n\tvar (\n\t\tpageSizeDefault = int64(1000)\n\t\tpopulateReferencesDefault = bool(false)\n\t)\n\treturn &ListNSGroupsParams{\n\t\tPageSize: &pageSizeDefault,\n\t\tPopulateReferences: &populateReferencesDefault,\n\t\tHTTPClient: client,\n\t}\n}", "func (o *CreateRepoNotificationParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListRepoLogsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLolClashV1ThirdpartyTeamDataParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetAllPublicIPUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *DeleteChartrepoRepoChartsNameVersionLabelsIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetGroupsByTypeUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *StatusCollectionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *DeleteVersionControlRequestParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListPipelinesParams) WithHTTPClient(client *http.Client) *ListPipelinesParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *ListNSGroupsParams) WithHTTPClient(client *http.Client) *ListNSGroupsParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *ListInstancesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListNodesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewWaitListParamsWithHTTPClient(client *http.Client) *WaitListParams {\n\treturn &WaitListParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *ReplaceProjectsParams) WithHTTPClient(client *http.Client) *ReplaceProjectsParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *GetPortfolioPositionsConidParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListTaskNexusParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetIngredientVersionRevisionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListEventsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewHTTPClient(options ...Opt) *HTTP {\n\tc := &HTTP{\n\t\tHTTPClient: &http.Client{},\n\t}\n\n\tfor _, option := range options {\n\t\toption(c)\n\t}\n\n\tif c.latestManifestURLFmt == \"\" {\n\t\tc.latestManifestURLFmt = defaultLatestManifestURLFmt\n\t}\n\n\tif c.manifestURLFmt == \"\" {\n\t\tc.manifestURLFmt = defaultManifestURLFmt\n\t}\n\n\treturn c\n}", "func (o *GetLolReplaysV1RoflsPathDefaultParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *BucketsCollectionGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithGroupingtype(groupingtype *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetGroupingtype(groupingtype)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFilter(filter *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFilter(filter)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFilterset(filterset *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFilterset(filterset)\n\treturn o\n}", "func (o *ServiceBrokerOpenstacksHostsGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetExampleNewProjectDescriptionCompatibilityVersion1Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewRebuildIndexSetParamsWithHTTPClient(client *http.Client) *RebuildIndexSetParams {\n\tvar ()\n\treturn &RebuildIndexSetParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *PetListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ConfigListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *FieldHistogramKeywordParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PublicPlatformLinkV3Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PcloudPlacementgroupsMembersDeleteParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *RepoListStatusesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *V2ListEventsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}" ]
[ "0.8360157", "0.70928437", "0.6931408", "0.6445891", "0.6429422", "0.635374", "0.63402766", "0.6332963", "0.6255657", "0.61940205", "0.61775863", "0.6096276", "0.6079328", "0.59976125", "0.59611464", "0.5923058", "0.58905584", "0.58664536", "0.58020717", "0.57899433", "0.57067025", "0.5648393", "0.56224096", "0.5582409", "0.55693895", "0.5556386", "0.5555109", "0.5548741", "0.5536851", "0.5536461", "0.55163634", "0.5510542", "0.5491244", "0.5480863", "0.5463449", "0.5444074", "0.54391503", "0.54341286", "0.54176694", "0.5417181", "0.5404115", "0.53908336", "0.5387205", "0.53847027", "0.53833914", "0.5381545", "0.53673315", "0.53661484", "0.536338", "0.5361327", "0.53484267", "0.5346275", "0.53404075", "0.533525", "0.53347254", "0.53306806", "0.5330677", "0.53294164", "0.53293085", "0.5329243", "0.53243643", "0.53063416", "0.53039074", "0.53009653", "0.5295283", "0.5286238", "0.5285125", "0.5282778", "0.5282107", "0.52819794", "0.5280578", "0.5278402", "0.5277506", "0.52770203", "0.52756226", "0.5264351", "0.52591705", "0.52515244", "0.5247928", "0.524543", "0.52449584", "0.522237", "0.5221759", "0.5216393", "0.5211171", "0.5207609", "0.5199106", "0.51952624", "0.5194008", "0.51935834", "0.51934147", "0.51913744", "0.519084", "0.51884407", "0.5180481", "0.51786774", "0.5178226", "0.51733124", "0.5172131", "0.5169154" ]
0.82316375
1
WithTimeout adds the timeout to the list issue group of project version params
func (o *ListIssueGroupOfProjectVersionParams) WithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams { o.SetTimeout(timeout) return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewListIssueGroupOfProjectVersionParamsWithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListSourceFileOfProjectVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *TestProjectVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) WithTimeout(timeout time.Duration) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *TestProjectVersionParams) WithTimeout(timeout time.Duration) *TestProjectVersionParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) WithTimeout(timeout time.Duration) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func NewListIssueGroupOfProjectVersionParams() *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *TicketProjectsImportProjectParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListSourceFileOfProjectVersionParams) WithTimeout(timeout time.Duration) *ListSourceFileOfProjectVersionParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *GetExampleNewProjectDescriptionCompatibilityVersion1Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ReplaceProjectsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewTestProjectVersionParamsWithTimeout(timeout time.Duration) *TestProjectVersionParams {\n\tvar ()\n\treturn &TestProjectVersionParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ServeBuildTypesInProjectParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListNSGroupsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewListIssueGroupOfProjectVersionParamsWithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\t\tHTTPClient: client,\n\t}\n}", "func (o *GetV1TicketingProjectsTicketingProjectIDConfigurationOptionsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListStacksByWorkspaceParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (builder *TsListKeysCommandBuilder) WithTimeout(timeout time.Duration) *TsListKeysCommandBuilder {\n\ttimeoutMilliseconds := uint32(timeout / time.Millisecond)\n\tbuilder.timeout = timeout\n\tbuilder.protobuf.Timeout = &timeoutMilliseconds\n\treturn builder\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithContext(ctx context.Context) *ListIssueGroupOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *ServeGroupsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewListSourceFileOfProjectVersionParamsWithTimeout(timeout time.Duration) *ListSourceFileOfProjectVersionParams {\n\tvar ()\n\treturn &ListSourceFileOfProjectVersionParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ListEnvironmentsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListDeploymentsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetIngredientVersionRevisionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PatchSepainstantIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func WithTimeout(t time.Duration) apiOption {\n\treturn func(m *Management) {\n\t\tm.timeout = t\n\t}\n}", "func (o *GetProjectMetricsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PostAPI24ProtectionGroupSnapshotsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListTaskNexusParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PostDockerRegistriesUUIDSearchListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *DeletePackageVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *DeleteChartrepoRepoChartsNameVersionLabelsIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ContainerListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PostDockerRegistriesSearchListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ConfigListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetGroupsByTypeUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *DeletePoolProjectParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListInstancesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *CreateBlueprintInWorkspaceInternalParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ShowPackageParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *WaitListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetLolAcsV2MatchlistsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *IssueGetLabelParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPackageSearchParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewGetUserIssueSearchOptionsOfProjectVersionParamsWithTimeout(timeout time.Duration) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\tvar ()\n\treturn &GetUserIssueSearchOptionsOfProjectVersionParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetBuildPropertiesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func With_timeout(parent *Group, timeout time.Duration) option {\n\treturn func(o *Group) {\n\t\tif o.Context != nil {\n\t\t\tpanic(\"context already set\")\n\t\t}\n\t\tif parent == nil {\n\t\t\tpanic(\"parent is nil\")\n\t\t}\n\t\to.Context, o.CancelFunc = context.WithTimeout(parent, timeout)\n\t\to.parent = parent\n\t}\n}", "func (o *ListTeamMemberWagesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *DeleteAPI24ProtectionGroupSnapshotsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *UpdateOrganizationTeamParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PatchAddonParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *QueryEntitlementsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func WithTimeout(duration time.Duration) Option {\n\treturn wrappedOption{otlpconfig.WithTimeout(duration)}\n}", "func (o *CreateListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetRepositoriesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithLimit(limit *int32) *ListIssueGroupOfProjectVersionParams {\n\to.SetLimit(limit)\n\treturn o\n}", "func (o *ListSSHKeysParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *RepoListStatusesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetEntitiesEntityFidConfigSectionNameItemsItemNameParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetOrganizationalUnitInventoryListsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ServiceBrokerOpenstacksHostsGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PatchLibrariesByIDContentByIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *TemplateListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *MultiDeleteIssueAttachmentOfIssueParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListPipelinesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListRepoLogsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *UpdateZoneProjectsUsingPUTParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetActionTemplateLogoVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetLolClashV1ThirdpartyTeamDataParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (c *OrganizationsEnvironmentsApisRevisionsDebugsessionsCreateCall) Timeout(timeout int64) *OrganizationsEnvironmentsApisRevisionsDebugsessionsCreateCall {\n\tc.urlParams_.Set(\"timeout\", fmt.Sprint(timeout))\n\treturn c\n}", "func (o *PatchSepainstantIDParams) WithTimeout(timeout time.Duration) *PatchSepainstantIDParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *PcloudNetworksGetallParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetWorkflowBuildTaskMetaMoidParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *RepoGetAllCommitsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetDeploymentTargetOperatingSystemNamesListAllParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *UpdateGroupAttributesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ServeBuildFieldShortParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListInventoryModelsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *CreateRepoNotificationParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func WithTimeout(timeout time.Duration) Option {\n\treturn func(o *options) {\n\t\to.timeout = timeout\n\t}\n}", "func WithTimeout(timeout time.Duration) Option {\n\treturn func(o *options) {\n\t\to.timeout = timeout\n\t}\n}", "func (o *EmployeeEntitlementGrantEntitlementsByTemplateGrantEntitlementsByTemplateParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *SearchWorkspacesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListAllTeamsSpacesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetReleasesReleaseIDContainersParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPublicsRecipeParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListIssueGroupOfProjectVersionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filter != nil {\n\n\t\t// query param filter\n\t\tvar qrFilter string\n\t\tif o.Filter != nil {\n\t\t\tqrFilter = *o.Filter\n\t\t}\n\t\tqFilter := qrFilter\n\t\tif qFilter != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filter\", qFilter); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filterset != nil {\n\n\t\t// query param filterset\n\t\tvar qrFilterset string\n\t\tif o.Filterset != nil {\n\t\t\tqrFilterset = *o.Filterset\n\t\t}\n\t\tqFilterset := qrFilterset\n\t\tif qFilterset != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filterset\", qFilterset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Groupingtype != nil {\n\n\t\t// query param groupingtype\n\t\tvar qrGroupingtype string\n\t\tif o.Groupingtype != nil {\n\t\t\tqrGroupingtype = *o.Groupingtype\n\t\t}\n\t\tqGroupingtype := qrGroupingtype\n\t\tif qGroupingtype != \"\" {\n\t\t\tif err := r.SetQueryParam(\"groupingtype\", qGroupingtype); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int32\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt32(qrLimit)\n\t\tif qLimit != \"\" {\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param parentId\n\tif err := r.SetPathParam(\"parentId\", swag.FormatInt64(o.ParentID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Qm != nil {\n\n\t\t// query param qm\n\t\tvar qrQm string\n\t\tif o.Qm != nil {\n\t\t\tqrQm = *o.Qm\n\t\t}\n\t\tqQm := qrQm\n\t\tif qQm != \"\" {\n\t\t\tif err := r.SetQueryParam(\"qm\", qQm); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showhidden != nil {\n\n\t\t// query param showhidden\n\t\tvar qrShowhidden bool\n\t\tif o.Showhidden != nil {\n\t\t\tqrShowhidden = *o.Showhidden\n\t\t}\n\t\tqShowhidden := swag.FormatBool(qrShowhidden)\n\t\tif qShowhidden != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showhidden\", qShowhidden); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showremoved != nil {\n\n\t\t// query param showremoved\n\t\tvar qrShowremoved bool\n\t\tif o.Showremoved != nil {\n\t\t\tqrShowremoved = *o.Showremoved\n\t\t}\n\t\tqShowremoved := swag.FormatBool(qrShowremoved)\n\t\tif qShowremoved != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showremoved\", qShowremoved); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showshortfilenames != nil {\n\n\t\t// query param showshortfilenames\n\t\tvar qrShowshortfilenames bool\n\t\tif o.Showshortfilenames != nil {\n\t\t\tqrShowshortfilenames = *o.Showshortfilenames\n\t\t}\n\t\tqShowshortfilenames := swag.FormatBool(qrShowshortfilenames)\n\t\tif qShowshortfilenames != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showshortfilenames\", qShowshortfilenames); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showsuppressed != nil {\n\n\t\t// query param showsuppressed\n\t\tvar qrShowsuppressed bool\n\t\tif o.Showsuppressed != nil {\n\t\t\tqrShowsuppressed = *o.Showsuppressed\n\t\t}\n\t\tqShowsuppressed := swag.FormatBool(qrShowsuppressed)\n\t\tif qShowsuppressed != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showsuppressed\", qShowsuppressed); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Start != nil {\n\n\t\t// query param start\n\t\tvar qrStart int32\n\t\tif o.Start != nil {\n\t\t\tqrStart = *o.Start\n\t\t}\n\t\tqStart := swag.FormatInt32(qrStart)\n\t\tif qStart != \"\" {\n\t\t\tif err := r.SetQueryParam(\"start\", qStart); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *SafeObjectListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetVersioningPolicyParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetBundleByKeyParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *AddRepositoryParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetOrganizationTeamPermissionsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPackageSearchActionOldSpacesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *UpdateBuildPropertiesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetRepositoriesRepoNameSignaturesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}" ]
[ "0.76033574", "0.71231157", "0.6361641", "0.63389295", "0.61667013", "0.6160391", "0.61558175", "0.60834527", "0.59376264", "0.59171396", "0.59017605", "0.5847091", "0.58287615", "0.5822885", "0.5785406", "0.57296455", "0.5713106", "0.5704875", "0.5696664", "0.5583554", "0.5581082", "0.5569461", "0.5553401", "0.5527108", "0.54943514", "0.548079", "0.5451365", "0.5414595", "0.5410886", "0.5408704", "0.53897005", "0.538503", "0.5384355", "0.53539664", "0.534103", "0.5339516", "0.5322073", "0.5316666", "0.5309241", "0.53055906", "0.5304323", "0.5297188", "0.5288028", "0.5283946", "0.52800596", "0.5274966", "0.52660215", "0.52584434", "0.525666", "0.5255908", "0.5245816", "0.52374226", "0.52363515", "0.5236127", "0.5236071", "0.5228227", "0.5214438", "0.521332", "0.52129674", "0.52075434", "0.5206174", "0.5195119", "0.5189561", "0.5188519", "0.518658", "0.5181348", "0.5156375", "0.5155847", "0.51533616", "0.5147877", "0.5145132", "0.5143795", "0.51422197", "0.5140682", "0.51359", "0.5134499", "0.513247", "0.51289356", "0.51285297", "0.51257443", "0.5122057", "0.51217234", "0.51212955", "0.5118295", "0.5113499", "0.5113499", "0.5109597", "0.5100878", "0.5099705", "0.5097209", "0.5090919", "0.50879323", "0.50879", "0.50852233", "0.5084085", "0.5082608", "0.50787634", "0.50782627", "0.5078041", "0.50746185" ]
0.79587877
0
SetTimeout adds the timeout to the list issue group of project version params
func (o *ListIssueGroupOfProjectVersionParams) SetTimeout(timeout time.Duration) { o.timeout = timeout }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *TestProjectVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *ListSourceFileOfProjectVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetExampleNewProjectDescriptionCompatibilityVersion1Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ServeBuildTypesInProjectParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *TicketProjectsImportProjectParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ReplaceProjectsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetV1TicketingProjectsTicketingProjectIDConfigurationOptionsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListEnvironmentsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetIngredientVersionRevisionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ServeGroupsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListStacksByWorkspaceParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetProjectMetricsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *UpdateOrganizationTeamParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetWorkflowBuildTaskMetaMoidParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListDeploymentsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PatchSepainstantIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewListIssueGroupOfProjectVersionParamsWithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *PatchAddonParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *DeleteChartrepoRepoChartsNameVersionLabelsIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetBuildPropertiesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *UpdateBuildPropertiesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PostAPI24ProtectionGroupSnapshotsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListNSGroupsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListTaskNexusParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *CreateBlueprintInWorkspaceInternalParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetActionTemplateLogoVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *DeletePoolProjectParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ConfigListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *AllLookmlTestsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PostDockerRegistriesUUIDSearchListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ServeBuildFieldShortParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListTeamMemberWagesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *DeletePackageVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *WaitListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ContainerListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PatchStorageVirtualDriveExtensionsMoidParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *UpdateNetworkSwitchAccessControlListsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *UpdateProjectTriggerSpacesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *UpdateGroupAttributesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListEngineTypeParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetFirmwareUpgradeStatusesMoidParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *QueryEntitlementsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetReleasesReleaseIDContainersParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetLolAcsV2MatchlistsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *IssueGetLabelParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPrivateOrderstateParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PostDockerRegistriesSearchListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetLolClashV1ThirdpartyTeamDataParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *AddOrUpdateNodePoolConfigItemParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListInstancesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListSSHKeysParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPublicsRecipeParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListPipelinesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ShowPackageParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetTaskStatesDeprecatedParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetEntitiesEntityFidConfigSectionNameItemsItemNameParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *SearchWorkspacesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetOrganizationTeamPermissionsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetVersioningPolicyParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetAPI24ArraysNtpTestParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PostHyperflexAutoSupportPoliciesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *EmployeeEntitlementGrantEntitlementsByTemplateGrantEntitlementsByTemplateParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPackageSearchParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetRepositoriesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *DevicesGetModuleComponentCommandHistoryParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ExtractionListV1Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListMachineDeploymentNodesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PostSecdefSearchParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetLolRankedV1ApexLeaguesByQueueTypeByTierParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *DeprecatedCycleParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *UpdateSingleGroupPublicV1Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetNdmpSettingsVariableParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *DeleteAPI24ProtectionGroupSnapshotsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *RebuildIndexSetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPlatformsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetOrganizationalUnitInventoryListsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *SafeObjectListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PostAPIV3MachinesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *UpdateAddonParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ListRepoLogsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PostAPI24PoliciesNfsMembersParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PatchAssetDeviceConfigurationsMoidParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPackageSearchActionOldSpacesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetLolInventoryV1PlayersByPuuidInventoryParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetProductsByIDPromotionsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetTreeParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *TemplateListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PutFlagSettingParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *EditParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *CreateRepoNotificationParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *TestProjectVersionParams) WithTimeout(timeout time.Duration) *TestProjectVersionParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *GetDeploymentPreview1Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *AddServerGroupInUpstreamParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *DeleteSystemObjectDefinitionsByIDAttributeGroupsByIDAttributeDefinitionsByIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *RepoListStatusesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}" ]
[ "0.7419088", "0.7415998", "0.74146557", "0.7346928", "0.7313649", "0.70382524", "0.7035942", "0.7019492", "0.6918667", "0.6724615", "0.67212605", "0.6717218", "0.668169", "0.6655724", "0.6655445", "0.66514814", "0.663366", "0.66275287", "0.6624522", "0.6608101", "0.65465057", "0.6536015", "0.65354574", "0.65146315", "0.6513489", "0.6513129", "0.64809996", "0.64454955", "0.6445474", "0.6426211", "0.64078766", "0.6385002", "0.6382661", "0.6376694", "0.6373848", "0.6373331", "0.6372592", "0.636901", "0.6360093", "0.6356786", "0.63554394", "0.6355264", "0.63529253", "0.6352578", "0.6347863", "0.63474554", "0.6346987", "0.6342919", "0.63414973", "0.6336795", "0.63362443", "0.632597", "0.6321912", "0.6319824", "0.6311566", "0.63108176", "0.6308704", "0.63071156", "0.63053674", "0.6299084", "0.6291994", "0.6291396", "0.6284725", "0.62841874", "0.6280437", "0.6277739", "0.6277241", "0.6273062", "0.62725866", "0.62639195", "0.62635785", "0.62634146", "0.6256228", "0.6249226", "0.62492144", "0.6249004", "0.62478685", "0.6244361", "0.62403417", "0.6239395", "0.6238273", "0.6237933", "0.62366086", "0.6229249", "0.6218722", "0.62166256", "0.6214829", "0.62106544", "0.62088054", "0.6206946", "0.62050515", "0.62048787", "0.61987066", "0.61978483", "0.61969846", "0.61966854", "0.61966544", "0.6196593", "0.61946106", "0.6184072" ]
0.79935664
0
WithContext adds the context to the list issue group of project version params
func (o *ListIssueGroupOfProjectVersionParams) WithContext(ctx context.Context) *ListIssueGroupOfProjectVersionParams { o.SetContext(ctx) return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewListIssueGroupOfProjectVersionParamsWithContext(ctx context.Context) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\tContext: ctx,\n\t}\n}", "func NewListIssueGroupOfProjectVersionParamsWithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\t\tHTTPClient: client,\n\t}\n}", "func NewListIssueGroupOfProjectVersionParams() *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (p *Provider) listWithContext(ctx context.Context, dir string, recursive bool, keys []*provider.KVPair, nextToken *string) ([]*provider.KVPair, error) {\n\tvar err error\n\n\t// input to the SSM to get parameters by path\n\tinput := &ssm.GetParametersByPathInput{\n\t\tPath: aws.String(dir),\n\t\tRecursive: aws.Bool(recursive),\n\t\t// WithDecryption: t.Bool(p.cfg.WithDecryption),\n\t}\n\n\tif nextToken != nil {\n\t\tinput.NextToken = nextToken\n\t}\n\n\toutput, err := p.ssm.GetParametersByPathWithContext(ctx, input)\n\tif err != nil {\n\t\treturn keys, err\n\t}\n\n\tfor _, param := range output.Parameters {\n\t\tkeys = append(keys, parameterKVPair(param))\n\t}\n\n\t// s.parameters = append(s.parameters, output.Parameters...)\n\n\tif nextToken != nil {\n\t\tp.listWithContext(ctx, dir, recursive, keys, nextToken)\n\t}\n\n\treturn keys, err\n}", "func (c *AppsModulesVersionsListCall) Context(ctx context.Context) *AppsModulesVersionsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *ProjectsGroupsListCall) Context(ctx context.Context) *ProjectsGroupsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func NewListIssueGroupOfProjectVersionParamsWithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithQ(q *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetQ(q)\n\treturn o\n}", "func (c *AdvertiserGroupsListCall) Context(ctx context.Context) *AdvertiserGroupsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func ListWithContext(ctx context.Context, repo name.Repository, options ...Option) ([]string, error) {\n\treturn List(repo, append(options, WithContext(ctx))...)\n}", "func (c *OrganizationsAppgroupsListCall) Context(ctx context.Context) *OrganizationsAppgroupsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFilter(filter *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFilter(filter)\n\treturn o\n}", "func (mr *MockRDSAPIMockRecorder) ModifyDBParameterGroupWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ModifyDBParameterGroupWithContext\", reflect.TypeOf((*MockRDSAPI)(nil).ModifyDBParameterGroupWithContext), varargs...)\n}", "func (o *ListIssueGroupOfProjectVersionParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (m *MockRDSAPI) ModifyDBParameterGroupWithContext(arg0 aws.Context, arg1 *rds.ModifyDBParameterGroupInput, arg2 ...request.Option) (*rds.DBParameterGroupNameMessage, error) {\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"ModifyDBParameterGroupWithContext\", varargs...)\n\tret0, _ := ret[0].(*rds.DBParameterGroupNameMessage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (c *ProjectsGroupsMembersListCall) Context(ctx context.Context) *ProjectsGroupsMembersListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (page *ProjectListPage) NextWithContext(ctx context.Context) (err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/ProjectListPage.NextWithContext\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif page.Response().Response.Response != nil {\n\t\t\t\tsc = page.Response().Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tnext, err := page.fn(ctx, page.pl)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.pl = next\n\treturn nil\n}", "func errGroupWithContext(ctx context.Context) (*errGroup, context.Context) {\n\tctx, cancel := context.WithCancel(ctx)\n\treturn &errGroup{cancel: cancel}, ctx\n}", "func (mr *MockRDSAPIMockRecorder) ModifyDBClusterParameterGroupWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ModifyDBClusterParameterGroupWithContext\", reflect.TypeOf((*MockRDSAPI)(nil).ModifyDBClusterParameterGroupWithContext), varargs...)\n}", "func (c *AccountPermissionGroupsListCall) Context(ctx context.Context) *AccountPermissionGroupsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (c *OrganizationsEnvgroupsListCall) Context(ctx context.Context) *OrganizationsEnvgroupsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *PlacementGroupsListCall) Context(ctx context.Context) *PlacementGroupsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *UserRolePermissionGroupsListCall) Context(ctx context.Context) *UserRolePermissionGroupsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *OperatingSystemVersionsListCall) Context(ctx context.Context) *OperatingSystemVersionsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *CreativeGroupsListCall) Context(ctx context.Context) *CreativeGroupsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *ProjectsGroupsUpdateCall) Context(ctx context.Context) *ProjectsGroupsUpdateCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) WithContext(ctx context.Context) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (m *MockRDSAPI) ModifyDBClusterParameterGroupWithContext(arg0 aws.Context, arg1 *rds.ModifyDBClusterParameterGroupInput, arg2 ...request.Option) (*rds.DBClusterParameterGroupNameMessage, error) {\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"ModifyDBClusterParameterGroupWithContext\", varargs...)\n\tret0, _ := ret[0].(*rds.DBClusterParameterGroupNameMessage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (o *ListSourceFileOfProjectVersionParams) WithContext(ctx context.Context) *ListSourceFileOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFilterset(filterset *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFilterset(filterset)\n\treturn o\n}", "func (c *ProjectsPatchDeploymentsListCall) Context(ctx context.Context) *ProjectsPatchDeploymentsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (c *FloodlightActivityGroupsListCall) Context(ctx context.Context) *FloodlightActivityGroupsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFields(fields *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFields(fields)\n\treturn o\n}", "func ErrfWithContext(ctx context.Context, format string, args ...interface{}) {\n\tif hub := sentry.GetHubFromContext(ctx); hub != nil {\n\t\terrdeps(hub.CaptureMessage, 3, format, args...)\n\t\treturn\n\t}\n\n\terrdeps(sentry.CaptureMessage, 3, format, args...)\n}", "func (c *OrganizationsDevelopersAppsAttributesListCall) Context(ctx context.Context) *OrganizationsDevelopersAppsAttributesListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (mr *MockRDSAPIMockRecorder) ModifyOptionGroupWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ModifyOptionGroupWithContext\", reflect.TypeOf((*MockRDSAPI)(nil).ModifyOptionGroupWithContext), varargs...)\n}", "func (c *AdvertiserGroupsPatchCall) Context(ctx context.Context) *AdvertiserGroupsPatchCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *VideoFormatsListCall) Context(ctx context.Context) *VideoFormatsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *ProjectsLocationsInstancesVulnerabilityReportsListCall) Context(ctx context.Context) *ProjectsLocationsInstancesVulnerabilityReportsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *ProjectsInstancesListCall) Context(ctx context.Context) *ProjectsInstancesListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithParentID(parentID int64) *ListIssueGroupOfProjectVersionParams {\n\to.SetParentID(parentID)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithStart(start *int32) *ListIssueGroupOfProjectVersionParams {\n\to.SetStart(start)\n\treturn o\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) WithContext(ctx context.Context) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (m *ListInvoicesRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (c *AdvertiserGroupsUpdateCall) Context(ctx context.Context) *AdvertiserGroupsUpdateCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (p *Provider) ListKeysWithContext(ctx context.Context, dir string, recursive bool) ([]*provider.KVPair, error) {\n\treturn p.listWithContext(ctx, dir, recursive, nil, nil)\n}", "func (s *SizedWaitGroup) AddWithContext(ctx context.Context) error {\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tcase s.current <- struct{}{}:\n\t\tbreak\n\t}\n\ts.wg.Add(1)\n\treturn nil\n}", "func (c *ProjectsPatchPoliciesListCall) Context(ctx context.Context) *ProjectsPatchPoliciesListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *OrganizationsAppgroupsUpdateCall) Context(ctx context.Context) *OrganizationsAppgroupsUpdateCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *OrganizationsInstancesAttachmentsListCall) Context(ctx context.Context) *OrganizationsInstancesAttachmentsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *ProjectsAssignmentsListCall) Context(ctx context.Context) *ProjectsAssignmentsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *OrganizationsAppgroupsAppsListCall) Context(ctx context.Context) *OrganizationsAppgroupsAppsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *OrganizationsDevelopersAttributesListCall) Context(ctx context.Context) *OrganizationsDevelopersAttributesListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *Client) GetVersionsContext(ctx context.Context, projectIDOrKey interface{}) ([]*Version, error) {\n\tu := fmt.Sprintf(\"/api/v2/projects/%v/versions\", projectIDOrKey)\n\n\treq, err := c.NewRequest(\"GET\", u, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar versions []*Version\n\tif err := c.Do(ctx, req, &versions); err != nil {\n\t\treturn nil, err\n\t}\n\treturn versions, nil\n}", "func (c *OrganizationsEnvgroupsPatchCall) Context(ctx context.Context) *OrganizationsEnvgroupsPatchCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (_obj *Apichannels) Channels_setDiscussionGroupWithContext(tarsCtx context.Context, params *TLchannels_setDiscussionGroup, _opt ...map[string]string) (ret Bool, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"channels_setDiscussionGroup\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (c *AppsModulesListCall) Context(ctx context.Context) *AppsModulesListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *CreativeGroupsUpdateCall) Context(ctx context.Context) *CreativeGroupsUpdateCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (mr *MockRDSAPIMockRecorder) DescribeDBParameterGroupsWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"DescribeDBParameterGroupsWithContext\", reflect.TypeOf((*MockRDSAPI)(nil).DescribeDBParameterGroupsWithContext), varargs...)\n}", "func (c *ProjectsListCall) Context(ctx context.Context) *ProjectsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *ProjectsListCall) Context(ctx context.Context) *ProjectsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *CreativeGroupsPatchCall) Context(ctx context.Context) *CreativeGroupsPatchCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *OrganizationsEnvgroupsAttachmentsListCall) Context(ctx context.Context) *OrganizationsEnvgroupsAttachmentsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (m *MockSQSAPI) ListQueueTagsWithContext(arg0 context.Context, arg1 *sqs.ListQueueTagsInput, arg2 ...request.Option) (*sqs.ListQueueTagsOutput, error) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"ListQueueTagsWithContext\", varargs...)\n\tret0, _ := ret[0].(*sqs.ListQueueTagsOutput)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (c *ProjectsOsConfigsListCall) Context(ctx context.Context) *ProjectsOsConfigsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (_obj *Apichannels) Channels_getAdminLogWithContext(tarsCtx context.Context, params *TLchannels_getAdminLog, _opt ...map[string]string) (ret Channels_AdminLogResults, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"channels_getAdminLog\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (c *RemarketingListsPatchCall) Context(ctx context.Context) *RemarketingListsPatchCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *PlacementGroupsUpdateCall) Context(ctx context.Context) *PlacementGroupsUpdateCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (c *OrganizationsInstancesListCall) Context(ctx context.Context) *OrganizationsInstancesListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *ProjectsOccurrencesPatchCall) Context(ctx context.Context) *ProjectsOccurrencesPatchCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (mr *MockRDSAPIMockRecorder) DescribeDBClusterParameterGroupsWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"DescribeDBClusterParameterGroupsWithContext\", reflect.TypeOf((*MockRDSAPI)(nil).DescribeDBClusterParameterGroupsWithContext), varargs...)\n}", "func (iter * MaintenanceWindowListResultIterator) NextWithContext(ctx context.Context) (err error) {\n if tracing.IsEnabled() {\n ctx = tracing.StartSpan(ctx, fqdn + \"/MaintenanceWindowListResultIterator.NextWithContext\")\n defer func() {\n sc := -1\n if iter.Response().Response.Response != nil {\n sc = iter.Response().Response.Response.StatusCode\n }\n tracing.EndSpan(ctx, sc, err)\n }()\n }\n iter.i++\n if iter.i < len(iter. page.Values()) {\n return nil\n }\n err = iter.page.NextWithContext(ctx)\n if err != nil {\n iter. i--\n return err\n }\n iter.i = 0\n return nil\n }", "func (c *ProjectsOsConfigsPatchCall) Context(ctx context.Context) *ProjectsOsConfigsPatchCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *ListIssueGroupOfProjectVersionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filter != nil {\n\n\t\t// query param filter\n\t\tvar qrFilter string\n\t\tif o.Filter != nil {\n\t\t\tqrFilter = *o.Filter\n\t\t}\n\t\tqFilter := qrFilter\n\t\tif qFilter != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filter\", qFilter); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filterset != nil {\n\n\t\t// query param filterset\n\t\tvar qrFilterset string\n\t\tif o.Filterset != nil {\n\t\t\tqrFilterset = *o.Filterset\n\t\t}\n\t\tqFilterset := qrFilterset\n\t\tif qFilterset != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filterset\", qFilterset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Groupingtype != nil {\n\n\t\t// query param groupingtype\n\t\tvar qrGroupingtype string\n\t\tif o.Groupingtype != nil {\n\t\t\tqrGroupingtype = *o.Groupingtype\n\t\t}\n\t\tqGroupingtype := qrGroupingtype\n\t\tif qGroupingtype != \"\" {\n\t\t\tif err := r.SetQueryParam(\"groupingtype\", qGroupingtype); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int32\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt32(qrLimit)\n\t\tif qLimit != \"\" {\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param parentId\n\tif err := r.SetPathParam(\"parentId\", swag.FormatInt64(o.ParentID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Qm != nil {\n\n\t\t// query param qm\n\t\tvar qrQm string\n\t\tif o.Qm != nil {\n\t\t\tqrQm = *o.Qm\n\t\t}\n\t\tqQm := qrQm\n\t\tif qQm != \"\" {\n\t\t\tif err := r.SetQueryParam(\"qm\", qQm); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showhidden != nil {\n\n\t\t// query param showhidden\n\t\tvar qrShowhidden bool\n\t\tif o.Showhidden != nil {\n\t\t\tqrShowhidden = *o.Showhidden\n\t\t}\n\t\tqShowhidden := swag.FormatBool(qrShowhidden)\n\t\tif qShowhidden != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showhidden\", qShowhidden); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showremoved != nil {\n\n\t\t// query param showremoved\n\t\tvar qrShowremoved bool\n\t\tif o.Showremoved != nil {\n\t\t\tqrShowremoved = *o.Showremoved\n\t\t}\n\t\tqShowremoved := swag.FormatBool(qrShowremoved)\n\t\tif qShowremoved != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showremoved\", qShowremoved); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showshortfilenames != nil {\n\n\t\t// query param showshortfilenames\n\t\tvar qrShowshortfilenames bool\n\t\tif o.Showshortfilenames != nil {\n\t\t\tqrShowshortfilenames = *o.Showshortfilenames\n\t\t}\n\t\tqShowshortfilenames := swag.FormatBool(qrShowshortfilenames)\n\t\tif qShowshortfilenames != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showshortfilenames\", qShowshortfilenames); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showsuppressed != nil {\n\n\t\t// query param showsuppressed\n\t\tvar qrShowsuppressed bool\n\t\tif o.Showsuppressed != nil {\n\t\t\tqrShowsuppressed = *o.Showsuppressed\n\t\t}\n\t\tqShowsuppressed := swag.FormatBool(qrShowsuppressed)\n\t\tif qShowsuppressed != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showsuppressed\", qShowsuppressed); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Start != nil {\n\n\t\t// query param start\n\t\tvar qrStart int32\n\t\tif o.Start != nil {\n\t\t\tqrStart = *o.Start\n\t\t}\n\t\tqStart := swag.FormatInt32(qrStart)\n\t\tif qStart != \"\" {\n\t\t\tif err := r.SetQueryParam(\"start\", qStart); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (c *OrganizationsApiproductsListCall) Context(ctx context.Context) *OrganizationsApiproductsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *ProjectsLocationsOsPolicyAssignmentsListRevisionsCall) Context(ctx context.Context) *ProjectsLocationsOsPolicyAssignmentsListRevisionsCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *OrganizationsApiproductsAttributesListCall) Context(ctx context.Context) *OrganizationsApiproductsAttributesListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func With(ctx context.Context, kvs ...interface{}) context.Context {\n\tl := fromCtx(ctx)\n\tl = l.With(kvs...)\n\treturn toCtx(ctx, l)\n}", "func WithContext(ctx context.Context) (*Group, context.Context)", "func (c *ProjectsLocationsVolumesSnapshotsListCall) Context(ctx context.Context) *ProjectsLocationsVolumesSnapshotsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *OrganizationsDevelopersAppsListCall) Context(ctx context.Context) *OrganizationsDevelopersAppsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (_obj *DataService) GetClubListWithContext(tarsCtx context.Context, index int32, batch int32, wx_id string, nextIndex *int32, clubInfoList *[]ClubInfo, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_int32(index, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(batch, 2)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_string(wx_id, 3)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32((*nextIndex), 4)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.WriteHead(codec.LIST, 5)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(int32(len((*clubInfoList))), 0)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tfor _, v := range *clubInfoList {\n\n\t\terr = v.WriteBlock(_os, 0)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"getClubList\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _is.Read_int32(&(*nextIndex), 4, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr, have, ty = _is.SkipToNoCheck(5, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif ty == codec.LIST {\n\t\terr = _is.Read_int32(&length, 0, true)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t\t(*clubInfoList) = make([]ClubInfo, length)\n\t\tfor i6, e6 := int32(0), length; i6 < e6; i6++ {\n\n\t\t\terr = (*clubInfoList)[i6].ReadBlock(_is, 0, false)\n\t\t\tif err != nil {\n\t\t\t\treturn ret, err\n\t\t\t}\n\n\t\t}\n\t} else if ty == codec.SIMPLE_LIST {\n\t\terr = fmt.Errorf(\"not support simple_list type\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t} else {\n\t\terr = fmt.Errorf(\"require vector, but not\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (_obj *DataService) GetMsgListWithContext(tarsCtx context.Context, index int32, date string, wx_id string, nextIndex *int32, msgList *[]Message, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_int32(index, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_string(date, 2)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_string(wx_id, 3)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32((*nextIndex), 4)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.WriteHead(codec.LIST, 5)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(int32(len((*msgList))), 0)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tfor _, v := range *msgList {\n\n\t\terr = v.WriteBlock(_os, 0)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"getMsgList\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _is.Read_int32(&(*nextIndex), 4, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr, have, ty = _is.SkipToNoCheck(5, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif ty == codec.LIST {\n\t\terr = _is.Read_int32(&length, 0, true)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t\t(*msgList) = make([]Message, length)\n\t\tfor i23, e23 := int32(0), length; i23 < e23; i23++ {\n\n\t\t\terr = (*msgList)[i23].ReadBlock(_is, 0, false)\n\t\t\tif err != nil {\n\t\t\t\treturn ret, err\n\t\t\t}\n\n\t\t}\n\t} else if ty == codec.SIMPLE_LIST {\n\t\terr = fmt.Errorf(\"not support simple_list type\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t} else {\n\t\terr = fmt.Errorf(\"require vector, but not\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (c *OrganizationsEnvironmentsApisRevisionsDebugsessionsListCall) Context(ctx context.Context) *OrganizationsEnvironmentsApisRevisionsDebugsessionsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *OrganizationsInstancesPatchCall) Context(ctx context.Context) *OrganizationsInstancesPatchCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *GetPastUsageOKBodyItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (c *PlacementGroupsPatchCall) Context(ctx context.Context) *PlacementGroupsPatchCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *FloodlightActivityGroupsPatchCall) Context(ctx context.Context) *FloodlightActivityGroupsPatchCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *ProjectsOccurrencesListCall) Context(ctx context.Context) *ProjectsOccurrencesListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *ProjectsInstancesUpdateCall) Context(ctx context.Context) *ProjectsInstancesUpdateCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (_obj *Apichannels) Channels_getGroupsForDiscussionWithContext(tarsCtx context.Context, params *TLchannels_getGroupsForDiscussion, _opt ...map[string]string) (ret Messages_Chats, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"channels_getGroupsForDiscussion\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (c *OrganizationsApisDeploymentsListCall) Context(ctx context.Context) *OrganizationsApisDeploymentsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *AppsModulesVersionsGetCall) Context(ctx context.Context) *AppsModulesVersionsGetCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *OrganizationsAssignmentsListCall) Context(ctx context.Context) *OrganizationsAssignmentsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c *ProjectsNotesListCall) Context(ctx context.Context) *ProjectsNotesListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (secretsManager *SecretsManagerV2) ListSecretVersionLocksWithContext(ctx context.Context, listSecretVersionLocksOptions *ListSecretVersionLocksOptions) (result *SecretVersionLocksPaginatedCollection, response *core.DetailedResponse, err error) {\n\terr = core.ValidateNotNil(listSecretVersionLocksOptions, \"listSecretVersionLocksOptions cannot be nil\")\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.ValidateStruct(listSecretVersionLocksOptions, \"listSecretVersionLocksOptions\")\n\tif err != nil {\n\t\treturn\n\t}\n\n\tpathParamsMap := map[string]string{\n\t\t\"secret_id\": *listSecretVersionLocksOptions.SecretID,\n\t\t\"id\": *listSecretVersionLocksOptions.ID,\n\t}\n\n\tbuilder := core.NewRequestBuilder(core.GET)\n\tbuilder = builder.WithContext(ctx)\n\tbuilder.EnableGzipCompression = secretsManager.GetEnableGzipCompression()\n\t_, err = builder.ResolveRequestURL(secretsManager.Service.Options.URL, `/api/v2/secrets/{secret_id}/versions/{id}/locks`, pathParamsMap)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tfor headerName, headerValue := range listSecretVersionLocksOptions.Headers {\n\t\tbuilder.AddHeader(headerName, headerValue)\n\t}\n\n\tsdkHeaders := common.GetSdkHeaders(\"secrets_manager\", \"V2\", \"ListSecretVersionLocks\")\n\tfor headerName, headerValue := range sdkHeaders {\n\t\tbuilder.AddHeader(headerName, headerValue)\n\t}\n\tbuilder.AddHeader(\"Accept\", \"application/json\")\n\n\tif listSecretVersionLocksOptions.Offset != nil {\n\t\tbuilder.AddQuery(\"offset\", fmt.Sprint(*listSecretVersionLocksOptions.Offset))\n\t}\n\tif listSecretVersionLocksOptions.Limit != nil {\n\t\tbuilder.AddQuery(\"limit\", fmt.Sprint(*listSecretVersionLocksOptions.Limit))\n\t}\n\tif listSecretVersionLocksOptions.Sort != nil {\n\t\tbuilder.AddQuery(\"sort\", fmt.Sprint(*listSecretVersionLocksOptions.Sort))\n\t}\n\tif listSecretVersionLocksOptions.Search != nil {\n\t\tbuilder.AddQuery(\"search\", fmt.Sprint(*listSecretVersionLocksOptions.Search))\n\t}\n\n\trequest, err := builder.Build()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar rawResponse map[string]json.RawMessage\n\tresponse, err = secretsManager.Service.Request(request, &rawResponse)\n\tif err != nil {\n\t\treturn\n\t}\n\tif rawResponse != nil {\n\t\terr = core.UnmarshalModel(rawResponse, \"\", &result, UnmarshalSecretVersionLocksPaginatedCollection)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tresponse.Result = result\n\t}\n\n\treturn\n}", "func (c MethodsCollection) WithContext() pWithContext {\n\treturn pWithContext{\n\t\tMethod: c.MustGet(\"WithContext\"),\n\t}\n}" ]
[ "0.62948304", "0.598528", "0.5581085", "0.552212", "0.54645795", "0.545413", "0.5422915", "0.5419807", "0.5402281", "0.5400749", "0.5349832", "0.53158486", "0.53141356", "0.5290659", "0.51958764", "0.51732075", "0.51531976", "0.5130647", "0.5128487", "0.5125622", "0.5115193", "0.51007956", "0.5086895", "0.50813204", "0.506794", "0.5053948", "0.5051572", "0.5047126", "0.5045084", "0.5031607", "0.5026848", "0.50098467", "0.49959698", "0.49955443", "0.49870864", "0.49717802", "0.49661294", "0.49561775", "0.49505708", "0.49501052", "0.49297845", "0.49207884", "0.4917714", "0.49143666", "0.48928764", "0.48844832", "0.4884213", "0.48833638", "0.48784295", "0.4872608", "0.48548353", "0.4852894", "0.48528764", "0.48514333", "0.48421296", "0.48324922", "0.48276696", "0.4819524", "0.48001972", "0.4798176", "0.4792923", "0.47910693", "0.47906747", "0.4786669", "0.47855836", "0.47680274", "0.47675148", "0.47609335", "0.47591603", "0.47466108", "0.4739275", "0.47341618", "0.47277614", "0.4723338", "0.47200415", "0.47191876", "0.47174037", "0.47164392", "0.47123155", "0.4711989", "0.47112873", "0.47103745", "0.46943152", "0.46870542", "0.4684496", "0.46814358", "0.46789137", "0.4676576", "0.46660915", "0.46657303", "0.4660085", "0.4658872", "0.46546897", "0.4653643", "0.46531594", "0.46523032", "0.46517953", "0.46468928", "0.46447328", "0.46439645" ]
0.70730007
0
SetContext adds the context to the list issue group of project version params
func (o *ListIssueGroupOfProjectVersionParams) SetContext(ctx context.Context) { o.Context = ctx }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ListIssueGroupOfProjectVersionParams) WithContext(ctx context.Context) *ListIssueGroupOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListSourceFileOfProjectVersionParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *TestProjectVersionParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PostAPI24ProtectionGroupSnapshotsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ReplaceProjectsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetExampleNewProjectDescriptionCompatibilityVersion1Params) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ServeGroupsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PatchAddonParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetIngredientVersionRevisionParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *SafeObjectListParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *DeleteAPI24ProtectionGroupSnapshotsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListNSGroupsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListRepoLogsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ServeBuildTypesInProjectParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetLolClashV1ThirdpartyTeamDataParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetProjectMetricsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PatchStorageVirtualDriveExtensionsMoidParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PatchSepainstantIDParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *TicketProjectsImportProjectParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *UpdateSingleGroupPublicV1Params) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *CreateRepoNotificationParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetRepository15Params) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetDeploymentPreview1Params) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListDeploymentsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *DeleteChartrepoRepoChartsNameVersionLabelsIDParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PostDockerRegistriesUUIDSearchListParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (c *AppsModulesVersionsListCall) Context(ctx context.Context) *AppsModulesVersionsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *ListPipelinesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PostDockerRegistriesSearchListParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PostAPI24PoliciesNfsMembersParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetLolInventoryV1PlayersByPuuidInventoryParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (c *ProjectsGroupsUpdateCall) Context(ctx context.Context) *ProjectsGroupsUpdateCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *UpdateAddonParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetPrivateOrderstateParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *AddServerGroupInUpstreamParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetRepositoriesRepoNameSignaturesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetProductsByIDPromotionsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetFirmwareUpgradeStatusesMoidParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListTeamMemberWagesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetLolAcsV2MatchlistsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetRepositoriesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListStacksByWorkspaceParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListEnvironmentsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetApplianceUpgradePoliciesMoidParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetActionTemplateLogoVersionParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *RepoGetAllCommitsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *UpdateProjectTriggerSpacesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *WaitListParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetPackageSearchActionOldSpacesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ContainerListParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListInstancesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *UpdateComparisonReportParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListEventsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PatchLibrariesByIDContentByIDParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *AllLookmlTestsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *CreateListParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetBlockLatestParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *AddRepositoryParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListRepositoryImagesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ExtractionListV1Params) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *EditParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *UpdateOrganizationTeamParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *StatusCollectionParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (c *ProjectsGroupsListCall) Context(ctx context.Context) *ProjectsGroupsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *RebuildIndexSetParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListInventoryModelsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListTaskNexusParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetListParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *UpdateGroupAttributesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetOrdersByIDNotesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetWorkflowBuildTaskMetaMoidParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PutLolPerksV1CurrentpageParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListSourceFileOfProjectVersionParams) WithContext(ctx context.Context) *ListSourceFileOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *GetMarketsRegionIDHistoryParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PostSecdefSearchParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *RevertProductSnapshotRequestUsingPOSTParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *UpdateCustomIDPParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (c *AdvertiserGroupsPatchCall) Context(ctx context.Context) *AdvertiserGroupsPatchCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *CreateBlueprintInWorkspaceInternalParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PostPartsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetVersioningPolicyParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PatchV1ChangesEventsChangeEventIDParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetAPI24ArraysNtpTestParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *UpdatePriceListParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *VectorThumbnailParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *CreateGitWebhookUsingPOSTParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *QueryEntitlementsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *UpdateFolderParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *AddOrUpdateNodePoolConfigItemParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *RepoListStatusesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetaspecificPbxDeviceFirmwareBinaryParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetProductUpgradeURLUsingGETParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetPublicsRecipeParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ShowPackageParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListEngineTypeParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PatchRetryEventUsingPATCHParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ApplicationComponentSnapshotCollectionGetParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}" ]
[ "0.7051063", "0.6554501", "0.65222734", "0.64833874", "0.6381549", "0.63245904", "0.60549706", "0.6049594", "0.6018889", "0.59537435", "0.5920727", "0.590724", "0.5905415", "0.58888704", "0.58767873", "0.585948", "0.5840669", "0.583863", "0.5824884", "0.58164436", "0.58100796", "0.58087426", "0.5806681", "0.58020836", "0.5798738", "0.5789723", "0.5774517", "0.5773282", "0.5769899", "0.5766362", "0.57650083", "0.5762301", "0.57608867", "0.5758546", "0.57360846", "0.5734818", "0.57273245", "0.5727098", "0.57267684", "0.5723626", "0.5712417", "0.5703738", "0.5696726", "0.5692297", "0.56806433", "0.5675642", "0.5674682", "0.56650734", "0.5664381", "0.56637496", "0.5653388", "0.5648739", "0.5647602", "0.56393117", "0.56387395", "0.5629596", "0.5626999", "0.5618981", "0.5613783", "0.56134653", "0.5610503", "0.5608233", "0.5604318", "0.5600149", "0.5600003", "0.5597642", "0.5596781", "0.5593336", "0.55927783", "0.5587337", "0.55871004", "0.5586844", "0.5585222", "0.55825436", "0.5580199", "0.55800396", "0.5580028", "0.55750924", "0.55728215", "0.5571451", "0.5570965", "0.5570736", "0.5568408", "0.55680466", "0.5567257", "0.55658585", "0.5564835", "0.556379", "0.55625105", "0.55590725", "0.5557842", "0.5557652", "0.5555508", "0.5554493", "0.55537665", "0.55495155", "0.55438364", "0.5542009", "0.5539744", "0.5537138" ]
0.7039994
1
WithHTTPClient adds the HTTPClient to the list issue group of project version params
func (o *ListIssueGroupOfProjectVersionParams) WithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams { o.SetHTTPClient(client) return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewListIssueGroupOfProjectVersionParamsWithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\t\tHTTPClient: client,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListSourceFileOfProjectVersionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListNSGroupsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) WithHTTPClient(client *http.Client) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *TicketProjectsImportProjectParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ServeGroupsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListSourceFileOfProjectVersionParams) WithHTTPClient(client *http.Client) *ListSourceFileOfProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *TestProjectVersionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ReplaceProjectsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ContainerListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewListIssueGroupOfProjectVersionParams() *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *GetListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *WaitListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetGroupsByTypeUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *MultiDeleteIssueAttachmentOfIssueParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLolAcsV2MatchlistsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetV1TicketingProjectsTicketingProjectIDConfigurationOptionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *SafeObjectListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithContext(ctx context.Context) *ListIssueGroupOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *GetProjectMetricsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListStacksByWorkspaceParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewListIssueGroupOfProjectVersionParamsWithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) WithHTTPClient(client *http.Client) *UpdateUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *PostAPI24ProtectionGroupSnapshotsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *LineStatusByIdsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLolClashV1ThirdpartyTeamDataParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *RepoGetAllCommitsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ConfigListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetGroupsGidPermissionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *CreateListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *IssueGetLabelParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListPipelinesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *QueryEntitlementsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ApplicationComponentSnapshotCollectionGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *StatusCollectionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *FileInfoCollectionGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListEventsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *QtreeCollectionGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *DeleteAPI24ProtectionGroupSnapshotsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetOrdersByIDNotesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListRepoLogsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ServeBuildTypesInProjectParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *DeleteChartrepoRepoChartsNameVersionLabelsIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *UpdateGroupAttributesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListSSHKeysParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetDeploymentByIDV3UsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLolInventoryV1PlayersByPuuidInventoryParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListTeamMemberWagesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *AlertGetMonitorGroupAlertsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetIngredientVersionRevisionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListTaskNexusParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *AddServerGroupInUpstreamParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetAPI24ArraysNtpTestParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetInviteByIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetAllPublicIPUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetV1MembershipsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFilterset(filterset *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFilterset(filterset)\n\treturn o\n}", "func (o *GetOrganizationTeamPermissionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *UpdateNetworkSwitchAccessControlListsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetEntitiesEntityFidConfigSectionNameItemsItemNameParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *RemoveControlFromGroupParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetInviteByEmailParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ResolveBatchParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetProductsByIDPromotionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetInterceptionitemsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetItemByAppIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *V2ListEventsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetReleasesReleaseIDContainersParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *IpamIPAddressesListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *RepoListStatusesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *DeletePoolProjectParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *AddItemParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PatchAddonParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *RetrieveCustomerGroupParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListAllTeamsSpacesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PetListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PatchLibrariesByIDContentByIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PortsetCollectionGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *TestProjectVersionParams) WithHTTPClient(client *http.Client) *TestProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *RemoveUserGroupParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetExampleNewProjectDescriptionCompatibilityVersion1Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *DeleteSystemObjectDefinitionsByIDAttributeGroupsByIDAttributeDefinitionsByIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PatchSepainstantIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListInstancesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *TemplateListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetOrganizationalUnitInventoryListsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *DeleteVersionControlRequestParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PostAPI24PoliciesNfsMembersParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *SearchIngredientsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ExtractionListV1Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *BucketsCollectionGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *UsersGroupsBulkDeleteParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PatchReferenceEntityRecordsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ImagePruneParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *WaitListParams) WithHTTPClient(client *http.Client) *WaitListParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *AccountCollectionGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}" ]
[ "0.7229135", "0.7128695", "0.62978494", "0.62627566", "0.612443", "0.60220456", "0.5927224", "0.58634484", "0.58452076", "0.58451164", "0.5792246", "0.57803667", "0.5738177", "0.571743", "0.5710379", "0.57090145", "0.56999815", "0.56932706", "0.56893724", "0.56738585", "0.56480134", "0.56418705", "0.56406677", "0.5623149", "0.5600595", "0.5583273", "0.55793446", "0.55638796", "0.5551337", "0.5549821", "0.5521321", "0.550651", "0.5495623", "0.5495218", "0.54869515", "0.5486854", "0.54685926", "0.54617125", "0.5455755", "0.54555887", "0.54349715", "0.54261726", "0.5422138", "0.54179263", "0.541778", "0.54177135", "0.54165316", "0.5399807", "0.5390998", "0.5387934", "0.5378244", "0.53758967", "0.5374039", "0.5372687", "0.5371298", "0.5356744", "0.535165", "0.53509057", "0.53492534", "0.5346741", "0.5346652", "0.53402644", "0.53389275", "0.5333556", "0.53232795", "0.5321521", "0.5321442", "0.53213996", "0.5319757", "0.53188777", "0.5318798", "0.53165245", "0.5315555", "0.531432", "0.53123105", "0.5311933", "0.5310596", "0.5309953", "0.5309586", "0.5303688", "0.5303526", "0.5298235", "0.5297545", "0.5286351", "0.5285816", "0.52847624", "0.5284434", "0.52816314", "0.52816135", "0.52794915", "0.52711374", "0.52685827", "0.52633446", "0.5262465", "0.5261425", "0.5255152", "0.52527803", "0.525196", "0.52490914", "0.52480984" ]
0.7929709
0
SetHTTPClient adds the HTTPClient to the list issue group of project version params
func (o *ListIssueGroupOfProjectVersionParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListSourceFileOfProjectVersionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *UpdateUserIssueSearchOptionsOfProjectVersionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *TicketProjectsImportProjectParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ReplaceProjectsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *TestProjectVersionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ServeGroupsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListNSGroupsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *WaitListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListStacksByWorkspaceParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ContainerListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetProjectMetricsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ConfigListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListPipelinesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *SafeObjectListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *UpdateNetworkSwitchAccessControlListsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *MultiDeleteIssueAttachmentOfIssueParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetV1TicketingProjectsTicketingProjectIDConfigurationOptionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLolAcsV2MatchlistsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PatchAddonParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLolClashV1ThirdpartyTeamDataParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ResolveBatchParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ServeBuildTypesInProjectParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *UpdateGroupAttributesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PostAPI24ProtectionGroupSnapshotsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *RebuildIndexSetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PatchRetryEventUsingPATCHParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListTaskNexusParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListRepoLogsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetGroupsByTypeUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetExampleNewProjectDescriptionCompatibilityVersion1Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *RepoGetAllCommitsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *AddServerGroupInUpstreamParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *QueryEntitlementsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *StatusCollectionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetIngredientVersionRevisionParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListSSHKeysParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *UpdateSingleGroupPublicV1Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetProductsByIDPromotionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *AddOrUpdateNodePoolConfigItemParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *UpdateOrganizationTeamParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *RecommendMultiClusterParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *DevicesGetModuleComponentCommandHistoryParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetOrdersByIDNotesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PatchReferenceEntityRecordsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *DeprecatedCycleParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetAPI24ArraysNtpTestParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *AlertGetMonitorGroupAlertsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetWorkflowBuildTaskMetaMoidParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ImagePruneParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *CreateListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *EditParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *IssueGetLabelParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListTeamMemberWagesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ExtractionListV1Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *UpdateComparisonReportParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *LineStatusByIdsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PostAPI24ArrayConnectionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *AddItemParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *QtreeCollectionGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *UpdateProjectTriggerSpacesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *CleanUpTasksDeprecatedParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetInterceptionitemsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetDeploymentByIDV3UsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *DeletePoolProjectParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *AllLookmlTestsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ReportAssignmentResultParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *CreateNetworkGroupPolicyParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *QueryChangesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PostPartsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PatchSepainstantIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ApplicationComponentSnapshotCollectionGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *UpdateAddonParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *TemplateListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListEventsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetFirmwareUpgradeStatusesMoidParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetApplianceUpgradePoliciesMoidParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *SetPlanParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListNodesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *DeleteChartrepoRepoChartsNameVersionLabelsIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetReleasesReleaseIDContainersParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *RemoveControlFromGroupParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PatchLibrariesByIDContentByIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *FileInfoCollectionGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListEngineTypeParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLolInventoryV1PlayersByPuuidInventoryParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetPackageSearchActionOldSpacesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PortsetCollectionGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PatchStorageVirtualDriveExtensionsMoidParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetGroupsGidPermissionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *NetworkPruneParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetWorkItemParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *RetrieveCustomerGroupParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *AssignUserToCustomerGroupUsingPATCH1Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetOrganizationTeamPermissionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *DeleteVersionControlRequestParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PostLolHighlightsV1HighlightsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}" ]
[ "0.75781035", "0.7545774", "0.7496822", "0.74832404", "0.7327541", "0.72963005", "0.7206542", "0.7167657", "0.7121102", "0.70960355", "0.7063285", "0.7042941", "0.7024429", "0.7010168", "0.7000214", "0.6990505", "0.69846416", "0.69845563", "0.6974066", "0.69693106", "0.69643366", "0.69256955", "0.6915394", "0.69123733", "0.6911905", "0.6905428", "0.6886405", "0.68703246", "0.686541", "0.68649215", "0.68534714", "0.6850784", "0.6845659", "0.68321383", "0.68240356", "0.681678", "0.6814191", "0.681265", "0.6779426", "0.67765045", "0.67672384", "0.6766385", "0.6764215", "0.6760932", "0.67522407", "0.6749207", "0.6747055", "0.67421854", "0.6741101", "0.67400074", "0.6738896", "0.6737275", "0.6734888", "0.67347425", "0.673462", "0.6727762", "0.67268014", "0.6723126", "0.6722432", "0.6721426", "0.6721336", "0.6718228", "0.67134535", "0.6712842", "0.6712443", "0.6709669", "0.6709466", "0.67094296", "0.6708026", "0.6703905", "0.6702022", "0.67009574", "0.6700242", "0.66997176", "0.6698258", "0.6698188", "0.66947025", "0.66882294", "0.6687821", "0.6686334", "0.6686075", "0.667949", "0.6673884", "0.66725355", "0.66710305", "0.6669045", "0.6669023", "0.66607064", "0.6660439", "0.6659498", "0.6657658", "0.6656414", "0.6650363", "0.6645776", "0.6642929", "0.66419756", "0.66399354", "0.66370696", "0.66362405", "0.6635563" ]
0.82597166
0
WithFields adds the fields to the list issue group of project version params
func (o *ListIssueGroupOfProjectVersionParams) WithFields(fields *string) *ListIssueGroupOfProjectVersionParams { o.SetFields(fields) return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewListIssueGroupOfProjectVersionParamsWithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\t\tHTTPClient: client,\n\t}\n}", "func NewListIssueGroupOfProjectVersionParams() *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewListIssueGroupOfProjectVersionParamsWithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filter != nil {\n\n\t\t// query param filter\n\t\tvar qrFilter string\n\t\tif o.Filter != nil {\n\t\t\tqrFilter = *o.Filter\n\t\t}\n\t\tqFilter := qrFilter\n\t\tif qFilter != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filter\", qFilter); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filterset != nil {\n\n\t\t// query param filterset\n\t\tvar qrFilterset string\n\t\tif o.Filterset != nil {\n\t\t\tqrFilterset = *o.Filterset\n\t\t}\n\t\tqFilterset := qrFilterset\n\t\tif qFilterset != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filterset\", qFilterset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Groupingtype != nil {\n\n\t\t// query param groupingtype\n\t\tvar qrGroupingtype string\n\t\tif o.Groupingtype != nil {\n\t\t\tqrGroupingtype = *o.Groupingtype\n\t\t}\n\t\tqGroupingtype := qrGroupingtype\n\t\tif qGroupingtype != \"\" {\n\t\t\tif err := r.SetQueryParam(\"groupingtype\", qGroupingtype); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int32\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt32(qrLimit)\n\t\tif qLimit != \"\" {\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param parentId\n\tif err := r.SetPathParam(\"parentId\", swag.FormatInt64(o.ParentID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Qm != nil {\n\n\t\t// query param qm\n\t\tvar qrQm string\n\t\tif o.Qm != nil {\n\t\t\tqrQm = *o.Qm\n\t\t}\n\t\tqQm := qrQm\n\t\tif qQm != \"\" {\n\t\t\tif err := r.SetQueryParam(\"qm\", qQm); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showhidden != nil {\n\n\t\t// query param showhidden\n\t\tvar qrShowhidden bool\n\t\tif o.Showhidden != nil {\n\t\t\tqrShowhidden = *o.Showhidden\n\t\t}\n\t\tqShowhidden := swag.FormatBool(qrShowhidden)\n\t\tif qShowhidden != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showhidden\", qShowhidden); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showremoved != nil {\n\n\t\t// query param showremoved\n\t\tvar qrShowremoved bool\n\t\tif o.Showremoved != nil {\n\t\t\tqrShowremoved = *o.Showremoved\n\t\t}\n\t\tqShowremoved := swag.FormatBool(qrShowremoved)\n\t\tif qShowremoved != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showremoved\", qShowremoved); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showshortfilenames != nil {\n\n\t\t// query param showshortfilenames\n\t\tvar qrShowshortfilenames bool\n\t\tif o.Showshortfilenames != nil {\n\t\t\tqrShowshortfilenames = *o.Showshortfilenames\n\t\t}\n\t\tqShowshortfilenames := swag.FormatBool(qrShowshortfilenames)\n\t\tif qShowshortfilenames != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showshortfilenames\", qShowshortfilenames); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showsuppressed != nil {\n\n\t\t// query param showsuppressed\n\t\tvar qrShowsuppressed bool\n\t\tif o.Showsuppressed != nil {\n\t\t\tqrShowsuppressed = *o.Showsuppressed\n\t\t}\n\t\tqShowsuppressed := swag.FormatBool(qrShowsuppressed)\n\t\tif qShowsuppressed != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showsuppressed\", qShowsuppressed); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Start != nil {\n\n\t\t// query param start\n\t\tvar qrStart int32\n\t\tif o.Start != nil {\n\t\t\tqrStart = *o.Start\n\t\t}\n\t\tqStart := swag.FormatInt32(qrStart)\n\t\tif qStart != \"\" {\n\t\t\tif err := r.SetQueryParam(\"start\", qStart); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithContext(ctx context.Context) *ListIssueGroupOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) WithFields(fields *string) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetFields(fields)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFilter(filter *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFilter(filter)\n\treturn o\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithQ(q *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetQ(q)\n\treturn o\n}", "func (o *ListSourceFileOfProjectVersionParams) WithFields(fields *string) *ListSourceFileOfProjectVersionParams {\n\to.SetFields(fields)\n\treturn o\n}", "func (c *AppsModulesVersionsCreateCall) Fields(s ...googleapi.Field) *AppsModulesVersionsCreateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (o *ListIssueGroupOfProjectVersionParams) SetFields(fields *string) {\n\to.Fields = fields\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFilterset(filterset *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFilterset(filterset)\n\treturn o\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) SetFields(fields *string) {\n\to.Fields = fields\n}", "func (c *AppsModulesVersionsGetCall) Fields(s ...googleapi.Field) *AppsModulesVersionsGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func WithFields(fields ...string) ReqOption {\n\treturn func(v url.Values) {\n\t\tv.Set(\"fields\", strings.Join(fields, \",\"))\n\t\tv.Set(\"include_fields\", \"true\")\n\t}\n}", "func WithFields(vs ...string) *Entry {\n\tfs := logrus.Fields{}\n\tfor index := 0; index < len(vs)-1; index = index + 2 {\n\t\tfs[vs[index]] = vs[index+1]\n\t}\n\treturn &Entry{entry: root.entry.WithFields(fs)}\n}", "func (c *OrganizationsAppgroupsAppsKeysApiproductsUpdateAppGroupAppKeyApiProductCall) Fields(s ...googleapi.Field) *OrganizationsAppgroupsAppsKeysApiproductsUpdateAppGroupAppKeyApiProductCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func NewListIssueGroupOfProjectVersionParamsWithContext(ctx context.Context) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\tContext: ctx,\n\t}\n}", "func newUpdateProjectUpdateProjectRequest(ctx context.Context, f *Project, c *Client) (map[string]interface{}, error) {\n\treq := map[string]interface{}{}\n\n\tif v := f.Labels; !dcl.IsEmptyValueIndirect(v) {\n\t\treq[\"labels\"] = v\n\t}\n\treturn req, nil\n}", "func (c *ProjectsSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsSetIamPolicyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsSetIamPolicyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *AppsModulesVersionsListCall) Fields(s ...googleapi.Field) *AppsModulesVersionsListCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsListCall) Fields(s ...googleapi.Field) *ProjectsListCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsListCall) Fields(s ...googleapi.Field) *ProjectsListCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsUpdateCall) Fields(s ...googleapi.Field) *ProjectsUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsGetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsGetIamPolicyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsGetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsGetIamPolicyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func WithFields(f Fields) Entry {\n\tentry := Entry{\n\t\tPair: (*Pair)(nil),\n\t}\n\n\tfor k, v := range f {\n\t\tentry.Pair = entry.Pair.Append(k, v)\n\t}\n\n\treturn entry\n}", "func (o *ListSourceFileOfProjectVersionParams) SetFields(fields *string) {\n\to.Fields = fields\n}", "func (b *GroupsGetBuilder) Fields(v []string) *GroupsGetBuilder {\n\tb.Params[\"fields\"] = v\n\treturn b\n}", "func (c *AppsModulesPatchCall) Fields(s ...googleapi.Field) *AppsModulesPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsCreateCall) Fields(s ...googleapi.Field) *ProjectsCreateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithLimit(limit *int32) *ListIssueGroupOfProjectVersionParams {\n\to.SetLimit(limit)\n\treturn o\n}", "func (c *ProjectsGetCall) Fields(s ...googleapi.Field) *ProjectsGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsGetCall) Fields(s ...googleapi.Field) *ProjectsGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsGroupsUpdateCall) Fields(s ...googleapi.Field) *ProjectsGroupsUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (e *Entry) WithFields(vs ...string) *Entry {\n\tfs := logrus.Fields{}\n\tfor index := 0; index < len(vs)-1; index = index + 2 {\n\t\tfs[vs[index]] = vs[index+1]\n\t}\n\treturn &Entry{entry: e.entry.WithFields(fs)}\n}", "func (c *ProjectsOsConfigsPatchCall) Fields(s ...googleapi.Field) *ProjectsOsConfigsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *OrganizationsAppgroupsAppsKeysUpdateAppGroupAppKeyCall) Fields(s ...googleapi.Field) *OrganizationsAppgroupsAppsKeysUpdateAppGroupAppKeyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *OrganizationsDevelopersAppsGenerateKeyPairOrUpdateDeveloperAppStatusCall) Fields(s ...googleapi.Field) *OrganizationsDevelopersAppsGenerateKeyPairOrUpdateDeveloperAppStatusCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsPatchDeploymentsCreateCall) Fields(s ...googleapi.Field) *ProjectsPatchDeploymentsCreateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsPatchDeploymentsPatchCall) Fields(s ...googleapi.Field) *ProjectsPatchDeploymentsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (c *OrganizationsDevelopersAppsKeysApiproductsUpdateDeveloperAppKeyApiProductCall) Fields(s ...googleapi.Field) *OrganizationsDevelopersAppsKeysApiproductsUpdateDeveloperAppKeyApiProductCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (e Entry) WithFields(f Fields) Entry {\n\tentry := Entry{\n\t\tPair: e.Pair,\n\t\tMessage: e.Message,\n\t}\n\n\tfor k, v := range f {\n\t\tentry.Pair = entry.Pair.Append(k, v)\n\t}\n\n\treturn entry\n}", "func (c *ProjectsUpdateBillingInfoCall) Fields(s ...googleapi.Field) *ProjectsUpdateBillingInfoCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithParentID(parentID int64) *ListIssueGroupOfProjectVersionParams {\n\to.SetParentID(parentID)\n\treturn o\n}", "func (b *GroupsGetByIDBuilder) Fields(v []string) *GroupsGetByIDBuilder {\n\tb.Params[\"fields\"] = v\n\treturn b\n}", "func (c *ProjectsAssignmentsPatchCall) Fields(s ...googleapi.Field) *ProjectsAssignmentsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsPatchDeploymentsResumeCall) Fields(s ...googleapi.Field) *ProjectsPatchDeploymentsResumeCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsOccurrencesPatchCall) Fields(s ...googleapi.Field) *ProjectsOccurrencesPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsInstancesUpdateCall) Fields(s ...googleapi.Field) *ProjectsInstancesUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsProvisionOrganizationCall) Fields(s ...googleapi.Field) *ProjectsProvisionOrganizationCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func WithFields(ctx context.Context, fields ...LogField) context.Context {\n\tif val := ctx.Value(fieldsContextKey); val != nil {\n\t\tif arr, ok := val.([]LogField); ok {\n\t\t\treturn context.WithValue(ctx, fieldsContextKey, append(arr, fields...))\n\t\t}\n\t}\n\n\treturn context.WithValue(ctx, fieldsContextKey, fields)\n}", "func (b *GroupsGetRequestsBuilder) Fields(v []string) *GroupsGetRequestsBuilder {\n\tb.Params[\"fields\"] = v\n\treturn b\n}", "func (c *ProjectsOccurrencesGetVulnerabilitySummaryCall) Fields(s ...googleapi.Field) *ProjectsOccurrencesGetVulnerabilitySummaryCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithStart(start *int32) *ListIssueGroupOfProjectVersionParams {\n\to.SetStart(start)\n\treturn o\n}", "func (c *OrganizationsApiproductsRateplansUpdateCall) Fields(s ...googleapi.Field) *OrganizationsApiproductsRateplansUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (c *CreativeGroupsPatchCall) Fields(s ...googleapi.Field) *CreativeGroupsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *OrganizationsDevelopersAppsKeysReplaceDeveloperAppKeyCall) Fields(s ...googleapi.Field) *OrganizationsDevelopersAppsKeysReplaceDeveloperAppKeyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsPatchDeploymentsGetCall) Fields(s ...googleapi.Field) *ProjectsPatchDeploymentsGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsGroupsCreateCall) Fields(s ...googleapi.Field) *ProjectsGroupsCreateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *OrganizationsApiproductsRateplansCreateCall) Fields(s ...googleapi.Field) *OrganizationsApiproductsRateplansCreateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *OrganizationsDevelopersAppsKeysUpdateDeveloperAppKeyCall) Fields(s ...googleapi.Field) *OrganizationsDevelopersAppsKeysUpdateDeveloperAppKeyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *FloodlightActivityGroupsPatchCall) Fields(s ...googleapi.Field) *FloodlightActivityGroupsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func WithFields(fields Fields) *logrus.Entry {\n\tdata := make(logrus.Fields, len(fields))\n\tfor k, v := range fields {\n\t\tdata[k] = v\n\t}\n\n\treturn wrapFields().WithFields(data)\n}", "func (c *LicenseAssignmentsPatchCall) Fields(s ...googleapi.Field) *LicenseAssignmentsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *OrganizationsEnvironmentsApisRevisionsDeploymentsGenerateDeployChangeReportCall) Fields(s ...googleapi.Field) *OrganizationsEnvironmentsApisRevisionsDeploymentsGenerateDeployChangeReportCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func buildParams(region string, groups []string) []string {\n\tparams := []string{\n\t\t\"-g\", strings.Join(groups, \",\"),\n\t\t\"-M\", reportFormat,\n\t\t\"-F\", reportName,\n\t}\n\tif region != \"\" {\n\t\tparams = append(params, \"-r\", region, \"-f\", region)\n\t} else {\n\t\tparams = append(params, \"-r\", defaultAPIRegion)\n\t}\n\treturn params\n}", "func (c *OrganizationsEnvironmentsUpdateDebugmaskCall) Fields(s ...googleapi.Field) *OrganizationsEnvironmentsUpdateDebugmaskCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *RemarketingListsPatchCall) Fields(s ...googleapi.Field) *RemarketingListsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *CallsetsPatchCall) Fields(s ...googleapi.Field) *CallsetsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (err *Err) WithFields(fields Fields) *Err {\n\tif err.Fields == nil {\n\t\terr.Fields = make(Fields)\n\t}\n\n\tfor name, value := range fields {\n\t\terr.Fields[name] = value\n\t}\n\n\treturn err\n}", "func (c *ProjectsServiceAccountsPatchCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *CreativesPatchCall) Fields(s ...googleapi.Field) *CreativesPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *SubaccountsPatchCall) Fields(s ...googleapi.Field) *SubaccountsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsServiceAccountsSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsSetIamPolicyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsServiceAccountsSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsSetIamPolicyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsLocationsDataExchangesListingsPatchCall) Fields(s ...googleapi.Field) *ProjectsLocationsDataExchangesListingsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *RetryCall) Fields(s ...googleapi.Field) *RetryCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *UrlInspectionIndexInspectCall) Fields(s ...googleapi.Field) *UrlInspectionIndexInspectCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param parentId\n\tif err := r.SetPathParam(\"parentId\", swag.FormatInt64(o.ParentID)); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (c *FloodlightActivitiesPatchCall) Fields(s ...googleapi.Field) *FloodlightActivitiesPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *AdvertisersPatchCall) Fields(s ...googleapi.Field) *AdvertisersPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *AdsPatchCall) Fields(s ...googleapi.Field) *AdsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsServiceAccountsSignJwtCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsSignJwtCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsServiceAccountsSignJwtCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsSignJwtCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsBrokersV2ServiceInstancesPatchCall) Fields(s ...googleapi.Field) *ProjectsBrokersV2ServiceInstancesPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsGroupsGetCall) Fields(s ...googleapi.Field) *ProjectsGroupsGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (e *err) WithFields(fields map[string]interface{}) Err {\n\tfor k, v := range fields {\n\t\te.fields[k] = v\n\t}\n\treturn e\n}", "func (c *OrganizationsSharedflowsRevisionsUpdateSharedFlowRevisionCall) Fields(s ...googleapi.Field) *OrganizationsSharedflowsRevisionsUpdateSharedFlowRevisionCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *CreativeGroupsUpdateCall) Fields(s ...googleapi.Field) *CreativeGroupsUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsPatchDeploymentsListCall) Fields(s ...googleapi.Field) *ProjectsPatchDeploymentsListCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *VideoFormatsGetCall) Fields(s ...googleapi.Field) *VideoFormatsGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsPatchTracesCall) Fields(s ...googleapi.Field) *ProjectsPatchTracesCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *OperatingSystemVersionsGetCall) Fields(s ...googleapi.Field) *OperatingSystemVersionsGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsInstancesCreateCall) Fields(s ...googleapi.Field) *ProjectsInstancesCreateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *OrganizationsApisRevisionsGetCall) Fields(s ...googleapi.Field) *OrganizationsApisRevisionsGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (s ProjectDetails) MarshalFields(e protocol.FieldEncoder) error {\n\tif s.ConsoleUrl != nil {\n\t\tv := *s.ConsoleUrl\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.BodyTarget, \"consoleUrl\", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)\n\t}\n\tif s.CreatedDate != nil {\n\t\tv := *s.CreatedDate\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.BodyTarget, \"createdDate\", protocol.TimeValue{V: v, Format: protocol.UnixTimeFormat}, metadata)\n\t}\n\tif s.LastUpdatedDate != nil {\n\t\tv := *s.LastUpdatedDate\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.BodyTarget, \"lastUpdatedDate\", protocol.TimeValue{V: v, Format: protocol.UnixTimeFormat}, metadata)\n\t}\n\tif s.Name != nil {\n\t\tv := *s.Name\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.BodyTarget, \"name\", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)\n\t}\n\tif s.ProjectId != nil {\n\t\tv := *s.ProjectId\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.BodyTarget, \"projectId\", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)\n\t}\n\tif s.Region != nil {\n\t\tv := *s.Region\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.BodyTarget, \"region\", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)\n\t}\n\tif len(s.Resources) > 0 {\n\t\tv := s.Resources\n\n\t\tmetadata := protocol.Metadata{}\n\t\tls0 := e.List(protocol.BodyTarget, \"resources\", metadata)\n\t\tls0.Start()\n\t\tfor _, v1 := range v {\n\t\t\tls0.ListAddFields(v1)\n\t\t}\n\t\tls0.End()\n\n\t}\n\tif len(s.State) > 0 {\n\t\tv := s.State\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.BodyTarget, \"state\", protocol.QuotedValue{ValueMarshaler: v}, metadata)\n\t}\n\treturn nil\n}" ]
[ "0.6581097", "0.64508575", "0.6125761", "0.6103511", "0.6050853", "0.5857859", "0.58447516", "0.578941", "0.5752445", "0.5636374", "0.5558553", "0.54393566", "0.54314333", "0.5418689", "0.5353155", "0.53410625", "0.5295799", "0.5289252", "0.5279767", "0.5277713", "0.5277713", "0.5260563", "0.5206591", "0.5206591", "0.51999027", "0.5198435", "0.5198435", "0.51954633", "0.5189481", "0.5184487", "0.5167314", "0.5144342", "0.5141847", "0.5136016", "0.5136016", "0.5129489", "0.51244783", "0.512051", "0.5095887", "0.50798184", "0.50707924", "0.506991", "0.50643104", "0.50429684", "0.5032988", "0.50301474", "0.5025792", "0.5025251", "0.5021437", "0.49986762", "0.49982345", "0.49910185", "0.4984015", "0.49767664", "0.49710533", "0.49536973", "0.49373826", "0.4915896", "0.4903071", "0.4898521", "0.48984933", "0.4895178", "0.4888222", "0.48873344", "0.4883776", "0.48643264", "0.48632228", "0.48572984", "0.48547053", "0.48435068", "0.4842605", "0.48424485", "0.48393857", "0.48374808", "0.4835631", "0.48295414", "0.4828957", "0.48211935", "0.48211935", "0.481908", "0.48182365", "0.48118404", "0.48113254", "0.48094562", "0.48082852", "0.48025414", "0.48020038", "0.48020038", "0.4801006", "0.4799939", "0.47992924", "0.47939157", "0.47938883", "0.47935718", "0.47933516", "0.47930235", "0.47917855", "0.47914547", "0.47893855", "0.47883257" ]
0.72750825
0
SetFields adds the fields to the list issue group of project version params
func (o *ListIssueGroupOfProjectVersionParams) SetFields(fields *string) { o.Fields = fields }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ListIssueGroupOfProjectVersionParams) WithFields(fields *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFields(fields)\n\treturn o\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) SetFields(fields *string) {\n\to.Fields = fields\n}", "func (o *ListSourceFileOfProjectVersionParams) SetFields(fields *string) {\n\to.Fields = fields\n}", "func (o *ServeBuildTypesInProjectParams) SetFields(fields *string) {\n\to.Fields = fields\n}", "func (o *ListIssueGroupOfProjectVersionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filter != nil {\n\n\t\t// query param filter\n\t\tvar qrFilter string\n\t\tif o.Filter != nil {\n\t\t\tqrFilter = *o.Filter\n\t\t}\n\t\tqFilter := qrFilter\n\t\tif qFilter != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filter\", qFilter); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filterset != nil {\n\n\t\t// query param filterset\n\t\tvar qrFilterset string\n\t\tif o.Filterset != nil {\n\t\t\tqrFilterset = *o.Filterset\n\t\t}\n\t\tqFilterset := qrFilterset\n\t\tif qFilterset != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filterset\", qFilterset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Groupingtype != nil {\n\n\t\t// query param groupingtype\n\t\tvar qrGroupingtype string\n\t\tif o.Groupingtype != nil {\n\t\t\tqrGroupingtype = *o.Groupingtype\n\t\t}\n\t\tqGroupingtype := qrGroupingtype\n\t\tif qGroupingtype != \"\" {\n\t\t\tif err := r.SetQueryParam(\"groupingtype\", qGroupingtype); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int32\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt32(qrLimit)\n\t\tif qLimit != \"\" {\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param parentId\n\tif err := r.SetPathParam(\"parentId\", swag.FormatInt64(o.ParentID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Qm != nil {\n\n\t\t// query param qm\n\t\tvar qrQm string\n\t\tif o.Qm != nil {\n\t\t\tqrQm = *o.Qm\n\t\t}\n\t\tqQm := qrQm\n\t\tif qQm != \"\" {\n\t\t\tif err := r.SetQueryParam(\"qm\", qQm); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showhidden != nil {\n\n\t\t// query param showhidden\n\t\tvar qrShowhidden bool\n\t\tif o.Showhidden != nil {\n\t\t\tqrShowhidden = *o.Showhidden\n\t\t}\n\t\tqShowhidden := swag.FormatBool(qrShowhidden)\n\t\tif qShowhidden != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showhidden\", qShowhidden); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showremoved != nil {\n\n\t\t// query param showremoved\n\t\tvar qrShowremoved bool\n\t\tif o.Showremoved != nil {\n\t\t\tqrShowremoved = *o.Showremoved\n\t\t}\n\t\tqShowremoved := swag.FormatBool(qrShowremoved)\n\t\tif qShowremoved != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showremoved\", qShowremoved); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showshortfilenames != nil {\n\n\t\t// query param showshortfilenames\n\t\tvar qrShowshortfilenames bool\n\t\tif o.Showshortfilenames != nil {\n\t\t\tqrShowshortfilenames = *o.Showshortfilenames\n\t\t}\n\t\tqShowshortfilenames := swag.FormatBool(qrShowshortfilenames)\n\t\tif qShowshortfilenames != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showshortfilenames\", qShowshortfilenames); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Showsuppressed != nil {\n\n\t\t// query param showsuppressed\n\t\tvar qrShowsuppressed bool\n\t\tif o.Showsuppressed != nil {\n\t\t\tqrShowsuppressed = *o.Showsuppressed\n\t\t}\n\t\tqShowsuppressed := swag.FormatBool(qrShowsuppressed)\n\t\tif qShowsuppressed != \"\" {\n\t\t\tif err := r.SetQueryParam(\"showsuppressed\", qShowsuppressed); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Start != nil {\n\n\t\t// query param start\n\t\tvar qrStart int32\n\t\tif o.Start != nil {\n\t\t\tqrStart = *o.Start\n\t\t}\n\t\tqStart := swag.FormatInt32(qrStart)\n\t\tif qStart != \"\" {\n\t\t\tif err := r.SetQueryParam(\"start\", qStart); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func NewListIssueGroupOfProjectVersionParams() *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (c *AppsModulesVersionsCreateCall) Fields(s ...googleapi.Field) *AppsModulesVersionsCreateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func NewListIssueGroupOfProjectVersionParamsWithHTTPClient(client *http.Client) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\t\tHTTPClient: client,\n\t}\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithFilterset(filterset *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFilterset(filterset)\n\treturn o\n}", "func (c *ProjectsSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsSetIamPolicyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsSetIamPolicyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (fm *FieldModelOrder) SetFields(fbeValue *Order) error {\n var err error = nil\n\n if err = fm.Id.Set(fbeValue.Id); err != nil {\n return err\n }\n if err = fm.Symbol.Set(fbeValue.Symbol); err != nil {\n return err\n }\n if err = fm.Side.Set(&fbeValue.Side); err != nil {\n return err\n }\n if err = fm.Type.Set(&fbeValue.Type); err != nil {\n return err\n }\n if err = fm.Price.Set(fbeValue.Price); err != nil {\n return err\n }\n if err = fm.Volume.Set(fbeValue.Volume); err != nil {\n return err\n }\n return err\n}", "func (c *AppsModulesVersionsGetCall) Fields(s ...googleapi.Field) *AppsModulesVersionsGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsUpdateCall) Fields(s ...googleapi.Field) *ProjectsUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *AppsModulesPatchCall) Fields(s ...googleapi.Field) *AppsModulesPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *OrganizationsEnvironmentsUpdateDebugmaskCall) Fields(s ...googleapi.Field) *OrganizationsEnvironmentsUpdateDebugmaskCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *AppsModulesVersionsListCall) Fields(s ...googleapi.Field) *AppsModulesVersionsListCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsGroupsUpdateCall) Fields(s ...googleapi.Field) *ProjectsGroupsUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsPatchDeploymentsPatchCall) Fields(s ...googleapi.Field) *ProjectsPatchDeploymentsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsAssignmentsPatchCall) Fields(s ...googleapi.Field) *ProjectsAssignmentsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *OrganizationsAppgroupsAppsKeysApiproductsUpdateAppGroupAppKeyApiProductCall) Fields(s ...googleapi.Field) *OrganizationsAppgroupsAppsKeysApiproductsUpdateAppGroupAppKeyApiProductCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsOsConfigsPatchCall) Fields(s ...googleapi.Field) *ProjectsOsConfigsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (t *Type) SetFields(fields []*Field)", "func (o *ListIssueGroupOfProjectVersionParams) WithFilter(filter *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetFilter(filter)\n\treturn o\n}", "func (b *GroupsGetBuilder) Fields(v []string) *GroupsGetBuilder {\n\tb.Params[\"fields\"] = v\n\treturn b\n}", "func (o *ListSourceFileOfProjectVersionParams) WithFields(fields *string) *ListSourceFileOfProjectVersionParams {\n\to.SetFields(fields)\n\treturn o\n}", "func (c *OrganizationsSharedflowsRevisionsUpdateSharedFlowRevisionCall) Fields(s ...googleapi.Field) *OrganizationsSharedflowsRevisionsUpdateSharedFlowRevisionCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *OrganizationsApisRevisionsUpdateApiProxyRevisionCall) Fields(s ...googleapi.Field) *OrganizationsApisRevisionsUpdateApiProxyRevisionCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsServiceAccountsSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsSetIamPolicyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsServiceAccountsSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsSetIamPolicyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (o *GetWorkItemParams) SetFields(fields *string) {\n\to.Fields = fields\n}", "func (c *VariantsetsPatchCall) Fields(s ...googleapi.Field) *VariantsetsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsInstancesUpdateCall) Fields(s ...googleapi.Field) *ProjectsInstancesUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *CallsetsPatchCall) Fields(s ...googleapi.Field) *CallsetsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *LicenseAssignmentsPatchCall) Fields(s ...googleapi.Field) *LicenseAssignmentsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsPatchDeploymentsResumeCall) Fields(s ...googleapi.Field) *ProjectsPatchDeploymentsResumeCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsLocationsOsPolicyAssignmentsListRevisionsCall) Fields(s ...googleapi.Field) *ProjectsLocationsOsPolicyAssignmentsListRevisionsCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsUpdateBillingInfoCall) Fields(s ...googleapi.Field) *ProjectsUpdateBillingInfoCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (e *CallEvent) SetFields(array []string) *CallEvent {\n\n\ttimeObj, err := time.Parse(TIME_FORMAT, array[0])\n\tif err != nil {\n\t\ttimeObj = time.Now()\n\t}\n\te.Date = timeObj\n\n\tif len(array) > 2 {\n\t\te.Operation = array[1]\n\t}\n\n\tif len(array) > 3 {\n\t\te.Irrelevant = array[2]\n\t}\n\n\tif len(array) > 4 {\n\t\te.Line = array[3]\n\t}\n\n\tif len(array) > 5 {\n\t\te.SourceNumber = array[4]\n\t}\n\n\tif len(array) > 6 {\n\t\te.TargetNumber = array[5]\n\t}\n\n\tif len(array) > 7 {\n\t\te.InternalPort = array[6]\n\t}\n\treturn e\n}", "func (o *SearchKeywordChunkedParams) SetFields(fields string) {\n\to.Fields = fields\n}", "func (b *GroupsGetByIDBuilder) Fields(v []string) *GroupsGetByIDBuilder {\n\tb.Params[\"fields\"] = v\n\treturn b\n}", "func (c *ProjectsServiceAccountsPatchCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithQ(q *string) *ListIssueGroupOfProjectVersionParams {\n\to.SetQ(q)\n\treturn o\n}", "func (c *OrganizationsEnvironmentsApisRevisionsDeploymentsGenerateDeployChangeReportCall) Fields(s ...googleapi.Field) *OrganizationsEnvironmentsApisRevisionsDeploymentsGenerateDeployChangeReportCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsBrokersV2ServiceInstancesPatchCall) Fields(s ...googleapi.Field) *ProjectsBrokersV2ServiceInstancesPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (fm *FinalModelStructOptional) SetFields(fbeValue *StructOptional) (int, error) {\n var err error = nil\n fbeCurrentOffset := 0\n fbeCurrentSize := 0\n fbeFieldSize := 0\n\n fm.FinalModelStructSimple.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.FinalModelStructSimple.SetFields(fbeValue.StructSimple); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F100.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F100.Set(fbeValue.F100); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F101.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F101.Set(fbeValue.F101); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F102.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F102.Set(fbeValue.F102); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F103.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F103.Set(fbeValue.F103); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F104.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F104.Set(fbeValue.F104); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F105.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F105.Set(fbeValue.F105); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F106.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F106.Set(fbeValue.F106); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F107.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F107.Set(fbeValue.F107); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F108.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F108.Set(fbeValue.F108); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F109.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F109.Set(fbeValue.F109); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F110.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F110.Set(fbeValue.F110); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F111.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F111.Set(fbeValue.F111); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F112.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F112.Set(fbeValue.F112); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F113.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F113.Set(fbeValue.F113); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F114.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F114.Set(fbeValue.F114); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F115.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F115.Set(fbeValue.F115); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F116.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F116.Set(fbeValue.F116); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F117.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F117.Set(fbeValue.F117); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F118.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F118.Set(fbeValue.F118); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F119.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F119.Set(fbeValue.F119); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F120.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F120.Set(fbeValue.F120); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F121.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F121.Set(fbeValue.F121); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F122.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F122.Set(fbeValue.F122); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F123.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F123.Set(fbeValue.F123); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F124.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F124.Set(fbeValue.F124); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F125.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F125.Set(fbeValue.F125); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F126.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F126.Set(fbeValue.F126); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F127.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F127.Set(fbeValue.F127); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F128.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F128.Set(fbeValue.F128); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F129.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F129.Set(fbeValue.F129); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F130.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F130.Set(fbeValue.F130); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F131.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F131.Set(fbeValue.F131); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F132.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F132.Set(fbeValue.F132); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F133.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F133.Set(fbeValue.F133); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F134.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F134.Set(fbeValue.F134); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F135.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F135.Set(fbeValue.F135); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F136.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F136.Set(fbeValue.F136); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F137.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F137.Set(fbeValue.F137); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F138.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F138.Set(fbeValue.F138); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F139.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F139.Set(fbeValue.F139); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F140.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F140.Set(fbeValue.F140); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F141.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F141.Set(fbeValue.F141); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F142.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F142.Set(fbeValue.F142); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F143.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F143.Set(fbeValue.F143); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F144.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F144.Set(fbeValue.F144); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F145.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F145.Set(fbeValue.F145); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F146.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F146.Set(fbeValue.F146); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F147.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F147.Set(fbeValue.F147); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F148.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F148.Set(fbeValue.F148); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F149.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F149.Set(fbeValue.F149); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F150.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F150.Set(fbeValue.F150); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F151.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F151.Set(fbeValue.F151); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F152.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F152.Set(fbeValue.F152); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F153.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F153.Set(fbeValue.F153); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F154.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F154.Set(fbeValue.F154); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F155.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F155.Set(fbeValue.F155); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F156.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F156.Set(fbeValue.F156); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F157.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F157.Set(fbeValue.F157); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F158.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F158.Set(fbeValue.F158); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F159.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F159.Set(fbeValue.F159); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F160.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F160.Set(fbeValue.F160); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F161.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F161.Set(fbeValue.F161); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F162.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F162.Set(fbeValue.F162); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F163.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F163.Set(fbeValue.F163); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F164.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F164.Set(fbeValue.F164); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n fm.F165.SetFBEOffset(fbeCurrentOffset)\n if fbeFieldSize, err = fm.F165.Set(fbeValue.F165); err != nil {\n return fbeCurrentSize, err\n }\n fbeCurrentOffset += fbeFieldSize\n fbeCurrentSize += fbeFieldSize\n\n return fbeCurrentSize, err\n}", "func (c *ReadgroupsetsPatchCall) Fields(s ...googleapi.Field) *ReadgroupsetsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsPatchDeploymentsCreateCall) Fields(s ...googleapi.Field) *ProjectsPatchDeploymentsCreateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *LicenseAssignmentsUpdateCall) Fields(s ...googleapi.Field) *LicenseAssignmentsUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (o *ServeGroupsParams) SetFields(fields *string) {\n\to.Fields = fields\n}", "func (c *RemarketingListsPatchCall) Fields(s ...googleapi.Field) *RemarketingListsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (o *SetBuildQueuePositionParams) SetFields(fields *string) {\n\to.Fields = fields\n}", "func (c *OrganizationsDevelopersUpdateMonetizationConfigCall) Fields(s ...googleapi.Field) *OrganizationsDevelopersUpdateMonetizationConfigCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *OrganizationsAppgroupsAppsKeysUpdateAppGroupAppKeyCall) Fields(s ...googleapi.Field) *OrganizationsAppgroupsAppsKeysUpdateAppGroupAppKeyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *OrganizationsApiproductsRateplansUpdateCall) Fields(s ...googleapi.Field) *OrganizationsApiproductsRateplansUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (b *GroupsGetRequestsBuilder) Fields(v []string) *GroupsGetRequestsBuilder {\n\tb.Params[\"fields\"] = v\n\treturn b\n}", "func (c *OrganizationsDevelopersAppsKeysApiproductsUpdateDeveloperAppKeyApiProductCall) Fields(s ...googleapi.Field) *OrganizationsDevelopersAppsKeysApiproductsUpdateDeveloperAppKeyApiProductCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsListCall) Fields(s ...googleapi.Field) *ProjectsListCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsListCall) Fields(s ...googleapi.Field) *ProjectsListCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsNotesSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsNotesSetIamPolicyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsProvisionOrganizationCall) Fields(s ...googleapi.Field) *ProjectsProvisionOrganizationCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsOccurrencesPatchCall) Fields(s ...googleapi.Field) *ProjectsOccurrencesPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (o *PublicViewInfo) SetFields(v []PublicField) {\n\to.Fields = v\n}", "func (c *AccountsContainersVersionsUpdateCall) Fields(s ...googleapi.Field) *AccountsContainersVersionsUpdateCall {\n\tc.params_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *CreativeGroupsUpdateCall) Fields(s ...googleapi.Field) *CreativeGroupsUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *OrganizationsEnvgroupsPatchCall) Fields(s ...googleapi.Field) *OrganizationsEnvgroupsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *CreativeGroupsPatchCall) Fields(s ...googleapi.Field) *CreativeGroupsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *LicenseAssignmentsListForProductCall) Fields(s ...googleapi.Field) *LicenseAssignmentsListForProductCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsPatchPoliciesPatchCall) Fields(s ...googleapi.Field) *ProjectsPatchPoliciesPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (o *PortsetCollectionGetParams) SetFields(fields []string) {\n\to.Fields = fields\n}", "func (c *SubaccountsPatchCall) Fields(s ...googleapi.Field) *SubaccountsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (l *Logger) SetFields(fields ...Field) {\n\tl.mu.Lock()\n\tl.setFields(fields...)\n\tl.mu.Unlock()\n}", "func (c *FloodlightActivityGroupsPatchCall) Fields(s ...googleapi.Field) *FloodlightActivityGroupsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (o *FileInfoCollectionGetParams) SetFields(fields []string) {\n\to.Fields = fields\n}", "func (c *FloodlightActivityGroupsUpdateCall) Fields(s ...googleapi.Field) *FloodlightActivityGroupsUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (o *GetUserIssueSearchOptionsOfProjectVersionParams) WithFields(fields *string) *GetUserIssueSearchOptionsOfProjectVersionParams {\n\to.SetFields(fields)\n\treturn o\n}", "func (s ProjectDetails) MarshalFields(e protocol.FieldEncoder) error {\n\tif s.ConsoleUrl != nil {\n\t\tv := *s.ConsoleUrl\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.BodyTarget, \"consoleUrl\", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)\n\t}\n\tif s.CreatedDate != nil {\n\t\tv := *s.CreatedDate\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.BodyTarget, \"createdDate\", protocol.TimeValue{V: v, Format: protocol.UnixTimeFormat}, metadata)\n\t}\n\tif s.LastUpdatedDate != nil {\n\t\tv := *s.LastUpdatedDate\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.BodyTarget, \"lastUpdatedDate\", protocol.TimeValue{V: v, Format: protocol.UnixTimeFormat}, metadata)\n\t}\n\tif s.Name != nil {\n\t\tv := *s.Name\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.BodyTarget, \"name\", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)\n\t}\n\tif s.ProjectId != nil {\n\t\tv := *s.ProjectId\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.BodyTarget, \"projectId\", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)\n\t}\n\tif s.Region != nil {\n\t\tv := *s.Region\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.BodyTarget, \"region\", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)\n\t}\n\tif len(s.Resources) > 0 {\n\t\tv := s.Resources\n\n\t\tmetadata := protocol.Metadata{}\n\t\tls0 := e.List(protocol.BodyTarget, \"resources\", metadata)\n\t\tls0.Start()\n\t\tfor _, v1 := range v {\n\t\t\tls0.ListAddFields(v1)\n\t\t}\n\t\tls0.End()\n\n\t}\n\tif len(s.State) > 0 {\n\t\tv := s.State\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.BodyTarget, \"state\", protocol.QuotedValue{ValueMarshaler: v}, metadata)\n\t}\n\treturn nil\n}", "func (c *ProjectsNotesPatchCall) Fields(s ...googleapi.Field) *ProjectsNotesPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsPatchTracesCall) Fields(s ...googleapi.Field) *ProjectsPatchTracesCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *OrganizationsEnvironmentsResourcefilesUpdateCall) Fields(s ...googleapi.Field) *OrganizationsEnvironmentsResourcefilesUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsGetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsGetIamPolicyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsGetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsGetIamPolicyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithContext(ctx context.Context) *ListIssueGroupOfProjectVersionParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (c *RemarketingListsUpdateCall) Fields(s ...googleapi.Field) *RemarketingListsUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *OrganizationsApiproductsUpdateCall) Fields(s ...googleapi.Field) *OrganizationsApiproductsUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *DatasetsPatchCall) Fields(s ...googleapi.Field) *DatasetsPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsPatchDeploymentsGetCall) Fields(s ...googleapi.Field) *ProjectsPatchDeploymentsGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsGetCall) Fields(s ...googleapi.Field) *ProjectsGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsGetCall) Fields(s ...googleapi.Field) *ProjectsGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func NewListIssueGroupOfProjectVersionParamsWithTimeout(timeout time.Duration) *ListIssueGroupOfProjectVersionParams {\n\tvar (\n\t\tlimitDefault = int32(200)\n\t\tshowhiddenDefault = bool(false)\n\t\tshowremovedDefault = bool(false)\n\t\tshowshortfilenamesDefault = bool(false)\n\t\tshowsuppressedDefault = bool(false)\n\t\tstartDefault = int32(0)\n\t)\n\treturn &ListIssueGroupOfProjectVersionParams{\n\t\tLimit: &limitDefault,\n\t\tShowhidden: &showhiddenDefault,\n\t\tShowremoved: &showremovedDefault,\n\t\tShowshortfilenames: &showshortfilenamesDefault,\n\t\tShowsuppressed: &showsuppressedDefault,\n\t\tStart: &startDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *InventoryStocktakingSearchParams) SetFields(fields *string) {\n\to.Fields = fields\n}", "func (o *ListIssueGroupOfProjectVersionParams) WithLimit(limit *int32) *ListIssueGroupOfProjectVersionParams {\n\to.SetLimit(limit)\n\treturn o\n}", "func (c *OrganizationsEnvironmentsUpdateEnvironmentCall) Fields(s ...googleapi.Field) *OrganizationsEnvironmentsUpdateEnvironmentCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsAssignmentsListCall) Fields(s ...googleapi.Field) *ProjectsAssignmentsListCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (b *MessagesGetHistoryBuilder) Fields(v []string) *MessagesGetHistoryBuilder {\n\tb.Params[\"fields\"] = v\n\treturn b\n}", "func (c *OrganizationsApisPatchCall) Fields(s ...googleapi.Field) *OrganizationsApisPatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsCreateCall) Fields(s ...googleapi.Field) *ProjectsCreateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (s *Select) SetFields(fieldName ...string) *Select {\n\tfor _, field := range fieldName {\n\t\ts.fields = append(s.fields, strings.ToLower(field))\n\t}\n\treturn s\n}", "func (c *OrganizationsEnvironmentsApisRevisionsDeploymentsGenerateUndeployChangeReportCall) Fields(s ...googleapi.Field) *OrganizationsEnvironmentsApisRevisionsDeploymentsGenerateUndeployChangeReportCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *ProjectsServiceAccountsUpdateCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}" ]
[ "0.6598279", "0.6416085", "0.62957495", "0.5919385", "0.5818365", "0.57457006", "0.56834465", "0.5646775", "0.5639487", "0.5610329", "0.5610329", "0.5608815", "0.54954934", "0.54609525", "0.5449537", "0.5446919", "0.544069", "0.54366577", "0.5426538", "0.5410048", "0.5400385", "0.5399336", "0.53935856", "0.5392011", "0.5388485", "0.5383491", "0.5348764", "0.53205675", "0.5301825", "0.5301825", "0.52975905", "0.5283147", "0.52750427", "0.5272224", "0.52693546", "0.52639914", "0.5261023", "0.5245853", "0.5245173", "0.5244119", "0.5239606", "0.52370834", "0.52328587", "0.5231302", "0.5227702", "0.5227098", "0.52175885", "0.52163935", "0.5213639", "0.521112", "0.520659", "0.52059054", "0.5192021", "0.51877534", "0.5185651", "0.51855236", "0.51787704", "0.516607", "0.516607", "0.5160803", "0.51605713", "0.5159897", "0.5148899", "0.51422626", "0.51399714", "0.5131774", "0.51297665", "0.5127177", "0.51260847", "0.5119725", "0.5108405", "0.51025456", "0.5090615", "0.5089086", "0.50796133", "0.507605", "0.50747186", "0.5070232", "0.5068413", "0.50682116", "0.50671923", "0.50671923", "0.5065997", "0.50657785", "0.50610167", "0.5059364", "0.5055052", "0.50536853", "0.50536853", "0.50474024", "0.5039903", "0.5039897", "0.5039686", "0.50374925", "0.50370264", "0.5024978", "0.5023608", "0.50201535", "0.50083274", "0.5007694" ]
0.66055834
0