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
+4.2k Golang : Takes a plural word and makes it singular
+7.3k Golang : Bcrypting password
+15.7k Golang : Set or Add HTTP Request Headers
+22.1k Golang : Save map/struct to JSON or XML file
+26.2k Golang : Create x509 certificate, private and public keys
+5.7k Golang : Convert word to its plural form example
+6.7k Golang : Random Rune generator
+6k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+4.7k Golang : Check from web if Go application is running or not
+12.5k Golang : Read data from config file and assign to variables
+3.8k Linux/MacOSX : Search for files by filename and extension with find command