10 examples of 'multiple-value strconv.atoi() in single-value context' in Go

Every line of 'multiple-value strconv.atoi() in single-value context' 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
296func (p *parser) parseInt() (Int, error) {
297 n := p.skipOpenParens()
298 t, err := p.expectInt()
299 if err != nil {
300 return 0, err
301 }
302 err = p.expectCloseParens(n)
303 if err != nil {
304 return 0, err
305 }
306 return t, nil
307}
217func tcAtoi(eng *Engine, index int64, args []uint64) (uint64, error) {
218 app, _ := eng.RunningAppFrame()
219 vmem := app.VM.VMemory()
220 addr := args[0]
221
222 pBytes, err := vmem.GetString(addr)
223 if err != nil {
224 return 0, errors.New("GetString err:" + err.Error())
225 }
226 if pBytes == nil || len(pBytes) == 0 {
227 return 0, nil
228 }
229
230 str := TrimBuffToString(pBytes)
231 i, err := strconv.Atoi(str)
232 if err != nil {
233 return 0, errors.New("Atoi err:" + err.Error())
234 }
235
236 return uint64(int32(i)), nil
237}
9func atoi(s string) int {
10 v, err := strconv.Atoi(s)
11 if err != nil {
12 return 0
13 }
14 return v
15}
37func atoi(s string) int32 {
38 i, err := strconv.Atoi(s)
39 if err != nil {
40 fmt.Printf("can't parse coordinate %q: %v\n", s, err)
41 os.Exit(1)
42 }
43 return int32(i)
44}
8func ParseInt(s string) int {
9 i, err := strconv.Atoi(s)
10 if err != nil {
11 panic(err)
12 }
13
14 return i
15}
87func parseInt(s string) int {
88 i, _ := strconv.Atoi(s)
89 return i
90}
182func parseInt(val string, fallback int) int {
183 if val == "" {
184 return fallback
185 }
186
187 v, err := strconv.Atoi(val)
188 if err != nil {
189 return fallback
190 }
191
192 return v
193}
237func Atoi(s string) int {
238 i, _ := strconv.Atoi(s)
239 return i
240}
57func ParseInt(value string, defaultValue int) int {
58 if value == "" {
59 return defaultValue
60 }
61 result, err := strconv.Atoi(value)
62 if err != nil {
63 result = defaultValue
64 }
65 return result
66}
655func (s *String) ParseUInt(line string, args ...Object) Object {
656 if len(args) != 0 && len(args) != 1 {
657 return NewError(line, ARGUMENTERROR, "0|1", len(args))
658 }
659
660 var base uint64 = 10
661
662 if len(args) == 1 {
663 iBaseObj, ok := args[0].(*UInteger)
664 if !ok {
665 return NewError(line, PARAMTYPEERROR, "first", "parseUInt", "*UInteger", args[0].Type())
666 }
667 base = iBaseObj.UInt64
668 }
669
670 ret, err := strconv.ParseUint(s.String, int(base), 64)
671 if err != nil {
672 return &UInteger{UInt64: 0, Valid: false}
673 }
674 return NewUInteger(ret)
675}

Related snippets