Example of strconv.ParseInt function usage in golang
- 2020-06-01 09:58:37
- OfStack
This article illustrates the use of the strconv.ParseInt function in golang as an example. I will share it with you for your reference as follows:
golang strconv.ParseInt is a powerful function that converts strings to Numbers.
The string form of the parameter 1 number
The base of a parameter 2 numeric string such as base 2, base 8, base 10, and base 106
Parameter 3 returns the bit size of the result, which is int8 int16 int32 int64
func ParseInt(s string, base int, bitSize int) (i int64, err error)
Code:
package main
import (
"strconv"
)
func main() {
i, err := strconv.ParseInt("123", 10, 32)
if err != nil {
panic(err)
}
println(i)
}
I hope this article has been helpful to you in the programming of Go language.