10 examples of 'golang range' in Go

Every line of 'golang 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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
33func (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}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

59func Range(frame wdte.Frame, args ...wdte.Func) wdte.Func {
60 frame = frame.Sub("range")
61
62 if len(args) == 0 {
63 return wdte.GoFunc(Range)
64 }
65
66 // Current index, minimum/maximum value, and step.
67 var i, m wdte.Number
68 s := wdte.Number(1)
69
70 switch len(args) {
71 case 1:
72 m = args[0].(wdte.Number)
73
74 case 2:
75 i = args[0].(wdte.Number)
76 m = args[1].(wdte.Number)
77
78 if i > m {
79 s = -1
80 }
81
82 default:
83 i = args[0].(wdte.Number)
84 m = args[1].(wdte.Number)
85 s = args[2].(wdte.Number)
86 }
87
88 return NextFunc(func(frame wdte.Frame) (wdte.Func, bool) {
89 if (s >= 0) && (i >= m) {
90 return nil, false
91 }
92 if (s < 0) && (i <= m) {
93 return nil, false
94 }
95
96 n := i
97 i += s
98 return n, true
99 })
100}
203func SetRange(i int) func() private {
204 return func() private {
205 siegfried.rng = i
206 return private{}
207 }
208}
95func (v *Validation) Range(obj interface{}, min, max int, key string) *Result {
96 return v.validate(Range{Min{Min: min}, Max{Max: max}, key}, obj)
97}
585func (m *AS) Range() []*A {
586 if m == nil {
587 return nil
588 }
589
590 return m.theSlice
591}
100func (m *MySlice) Range() []string {
101 if m == nil {
102 return nil
103 }
104
105 return m.theSlice
106}
18func (s *readOnlySelector) Range(callback func(types.GeneralFactory) bool, types ...reflect.Type) bool {
19 return true
20}
44func (storage *Storage) Range(callback func(key string, value TimeStampedData) bool) {
45 storage.underlying.Range(func(iKey, iValue interface{}) bool {
46 return callback(iKey.(string), iValue.(TimeStampedData))
47 })
48}
120func (r *Range) SetRange(begin, end int) {
121 r.Sel = nil
122 r.AddRange(begin, end)
123}
72func (tfs *IncludedTaskfiles) Range(yield func(key string, includedTaskfile IncludedTaskfile) error) error {
73 if tfs == nil {
74 return nil
75 }
76 for _, k := range tfs.Keys {
77 if err := yield(k, tfs.Mapping[k]); err != nil {
78 return err
79 }
80 }
81 return nil
82}

Related snippets