Every line of 'golang for range' 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.
14 func RangeExprType(t *types.Type) *types.Type { 15 if t.IsPtr() && t.Elem().IsArray() { 16 return t.Elem() 17 } 18 return t 19 }
635 func (pg *page) inRange(lo, hi unsafe.Pointer, itm unsafe.Pointer) bool { 636 return pg.cmp(itm, hi) < 0 && pg.cmp(itm, lo) >= 0 637 }
1338 func rangeTag(par parFunc) string { 1339 setAllAttr(par) 1340 step := int64(1) 1341 data := make([][]string, 0, 32) 1342 from := converter.StrToInt64(macro((*par.Pars)["From"], par.Workspace.Vars)) 1343 to := converter.StrToInt64(macro((*par.Pars)["To"], par.Workspace.Vars)) 1344 if len((*par.Pars)["Step"]) > 0 { 1345 step = converter.StrToInt64(macro((*par.Pars)["Step"], par.Workspace.Vars)) 1346 } 1347 if step > 0 && from < to { 1348 for i := from; i < to; i += step { 1349 data = append(data, []string{converter.Int64ToStr(i)}) 1350 } 1351 } else if step < 0 && from > to { 1352 for i := from; i > to; i += step { 1353 data = append(data, []string{converter.Int64ToStr(i)}) 1354 } 1355 } 1356 delete(par.Node.Attr, `from`) 1357 delete(par.Node.Attr, `to`) 1358 delete(par.Node.Attr, `step`) 1359 par.Node.Attr[`columns`] = &[]string{"id"} 1360 par.Node.Attr[`data`] = &data 1361 newSource(par) 1362 par.Owner.Children = append(par.Owner.Children, par.Node) 1363 return `` 1364 }
101 func inRange(begin, end int64, p Point) bool { 102 return begin <= p.Timestamp && end > p.Timestamp 103 }
33 func (g String) Range(params ...interface{}) String { 34 if len(params) < 2 { 35 fmt.Println("Not enough parameters to execute a range") 36 return g 37 } 38 39 g.AddStep("range", params...) 40 41 return g 42 }
407 func adjustBound(bound int, def int, step int, length int) int { 408 if bound == base.IntNone { 409 bound = def 410 } else { 411 if bound < 0 { 412 bound += length 413 } 414 if bound < 0 { 415 bound = 0 416 if step < 0 { 417 bound = -1 418 } 419 } 420 if bound > length { 421 bound = length 422 if step < 0 { 423 bound = length - 1 424 } 425 } 426 } 427 return bound 428 }
203 func SetRange(i int) func() private { 204 return func() private { 205 siegfried.rng = i 206 return private{} 207 } 208 }
16 func Range(mapv protoreflect.Map, keyKind protoreflect.Kind, f func(protoreflect.MapKey, protoreflect.Value) bool) { 17 var keys []protoreflect.MapKey 18 mapv.Range(func(key protoreflect.MapKey, _ protoreflect.Value) bool { 19 keys = append(keys, key) 20 return true 21 }) 22 sort.Slice(keys, func(i, j int) bool { 23 switch keyKind { 24 case protoreflect.BoolKind: 25 return !keys[i].Bool() && keys[j].Bool() 26 case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind, 27 protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: 28 return keys[i].Int() < keys[j].Int() 29 case protoreflect.Uint32Kind, protoreflect.Fixed32Kind, 30 protoreflect.Uint64Kind, protoreflect.Fixed64Kind: 31 return keys[i].Uint() < keys[j].Uint() 32 case protoreflect.StringKind: 33 return keys[i].String() < keys[j].String() 34 default: 35 panic("invalid kind: " + keyKind.String()) 36 } 37 }) 38 for _, key := range keys { 39 if !f(key, mapv.Get(key)) { 40 break 41 } 42 } 43 }