How to Convert a String Value to an Int in Go


If you need to convert a string to an int in Go, then you should use the strconv.Atoi function:

package main
import (
    "strconv"
    "fmt"
)
func main() {
    t := strconv.Atoi("123")
    fmt.Println(t)
}

Learn how to convert an int value to a string in Go .