10 examples of 'strconv.parseint' in Go

Every line of 'strconv.parseint' 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
478func parseInt(s string) (int, error) {
479 return strconv.Atoi(s)
480}
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

87func parseInt(s string) int {
88 i, _ := strconv.Atoi(s)
89 return i
90}
43func ParseInt(s string) (int, error) {
44 if v, err := strconv.ParseInt(s, 10, 0); err != nil {
45 return 0, err
46 } else {
47 return int(v), nil
48 }
49}
8func ParseInt(s string) int {
9 i, err := strconv.Atoi(s)
10 if err != nil {
11 panic(err)
12 }
13
14 return i
15}
43func parseInt(in string) (int, error) { return strconv.Atoi(in) }
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}
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}
46func ParseInt(data string) (v int64, err error) {
47 i, err := strconv.Atoi(data)
48 if err == nil {
49 v = int64(i)
50 }
51 return
52}
348func parseInt(input string) (int, error) {
349 i, err := strconv.ParseInt(input, 10, 32)
350 return int(i), err
351}
9func parseInt(b []byte) (i int64, err error) {
10 s := unsafeBytesToString(b)
11 return strconv.ParseInt(s, 10, 64)
12}

Related snippets