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
+10.9k Golang : Roll the dice example
+16.7k Golang : Capture stdout of a child process and act according to the result
+8k Golang : Configure Apache and NGINX to access your Go service example
+25k Golang : Convert uint value to string type
+7.9k Golang : Find relative luminance or color brightness
+5.8k Golang : Missing Subversion command
+45.7k Golang : Read tab delimited file with encoding/csv package
+19.5k Golang : Archive directory with tar and gzip
+35.1k Golang : Integer is between a range
+16.2k Golang : How to implement two-factor authentication?
+9.2k Golang : Extract or copy items from map based on value
+13.5k Golang : Convert spaces to tabs and back to spaces example