Golang convert string to int

Code examples

6
0

golang convert string to int

Int, err := strconv.Atoi("12345")
0
0

golang string to int

i, err := strconv.Atoi("-42")
s := strconv.Itoa(-42)
0
0

golang convert string to int64

s := "97"
n, err := strconv.ParseInt(s, 10, 64)
if err == nil {
    fmt.Printf("%d of type %T", n, n)
}
-1
0

convert string to int golang

var s string
i, err := strconv.Atoi(s)

Similar pages

Similar pages with examples

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................