Every line of 'zero value' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.
1012 func (t *StructType) ZeroValue() string { return fmt.Sprintf("%s{}", t) }
151 func Zero(value *big.Int) bool { 152 if value == nil || value.Sign() == 0 { 153 return true 154 } 155 return false 156 }
257 func Zero(data []byte) { 258 for i := 0; i < len(data); i++ { 259 data[i] = 0 260 } 261 }
540 func positiveZeroValue() Value { 541 return Value{valueNumber, __PositiveZero__} 542 }
89 func ZeroValue(t ValueType) interface{} { 90 switch t { 91 case TFloat: 92 return float64(0) 93 case TInt: 94 return int64(0) 95 case TString: 96 return "" 97 case TBool: 98 return false 99 case TRegex: 100 return (*regexp.Regexp)(nil) 101 case TTime: 102 return time.Time{} 103 case TDuration: 104 return time.Duration(0) 105 case TLambda: 106 return (*LambdaNode)(nil) 107 case TList: 108 return []interface{}(nil) 109 case TStar: 110 return (*StarNode)(nil) 111 case TMissing: 112 return (*Missing)(nil) 113 default: 114 return errors.New("invalid type") 115 } 116 }
9 func zero(x uint64) uint64 { 10 if x == 0 { 11 return 1 12 } 13 return 0 14 // branchless: 15 // return ((x>>1 | x&1) - 1) >> 63 16 }
279 func (gen *Generator) ValueZero(t *types.Type) string { 280 rt := gen.R.Resolve(t, gen.Package) 281 k := rt.Kind() 282 switch k { 283 case types.BlobKind: 284 return fmt.Sprintf("%sNewEmptyBlob()", gen.TypesPackage) 285 case types.BoolKind: 286 return fmt.Sprintf("%sBool(false)", gen.TypesPackage) 287 case types.NumberKind: 288 return fmt.Sprintf("%s%s(0)", gen.TypesPackage, kindToString(k)) 289 case types.ListKind, types.MapKind, types.RefKind, types.SetKind: 290 return gen.UserZero(t) 291 case types.PackageKind: 292 return fmt.Sprintf("%sNewPackage()", gen.TypesPackage) 293 case types.StringKind: 294 return fmt.Sprintf(`%sNewString("")`, gen.TypesPackage) 295 case types.StructKind: 296 return fmt.Sprintf("New%s()", gen.UserName(rt)) 297 case types.ValueKind: 298 // TODO: Use nil here 299 return fmt.Sprintf("%sBool(false)", gen.TypesPackage) 300 case types.TypeKind: 301 return fmt.Sprintf("%sType{R: ref.Ref{}}", gen.TypesPackage) 302 } 303 panic("unreachable") 304 }
46 func zero() *big.Int { return big.NewInt(0) }
59 func (s U8Slice) ZeroMoreThan(i int) bool { return false }
82 func (c *Conv) InitZero(cr anyvec.Creator) { 83 filterSize := c.FilterWidth * c.FilterHeight * c.InputDepth 84 c.Filters = anydiff.NewVar(cr.MakeVector(filterSize * c.FilterCount)) 85 c.Biases = anydiff.NewVar(cr.MakeVector(c.FilterCount)) 86 c.Conver = CurrentConverMaker()(*c) 87 }