Golang : convert(cast) string to integer value
To convert or cast a string to integer value, just use the strconv.Atoi()
function. Below is the code example to demonstrate how to convert string to integer value.
package main
import (
"fmt"
"strconv"
)
func main() {
var i int
i, _ = strconv.Atoi("123")
fmt.Println(i)
}
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+8.7k PHP : Convert(cast) bigInt to string
+10.4k Golang : ROT47 (Caesar cipher by 47 characters) example
+13.6k Golang : Test floating point numbers not-a-number and infinite example
+11.2k Golang : Fix image: unknown format error
+9.1k Golang : Display a text file line by line with line number example
+8k Golang : Sort and reverse sort a slice of floats
+15.9k Golang : Generate thumbnails from images
+4.7k Golang : Derive cryptographic key from passwords with Argon2
+11.5k Golang : Simple word wrap or line breaking example
+24.5k Golang : Convert CSV data to JSON format and save to file
+9.1k Golang : Find and draw contours with OpenCV example
+17.8k Golang : Count number of digits from given integer value