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.8k Golang : Create Temporary File
+9k Golang : Create and shuffle deck of cards example
+3.5k Java : Random alphabets, alpha-numeric or numbers only string generator
+17.4k Golang : Parse date string and convert to dd-mm-yyyy format
+15k Golang : How to add color to string?
+8.6k Yum Error: no such table: packages
+7.3k Gogland : Single File versus Go Application Run Configurations
+11.1k Use systeminfo to find out installed Windows Hotfix(s) or updates
+9.9k Golang : Check a web page existence with HEAD request example
+10k Golang : Embed secret text string into binary(executable) file
+5.5k Unix/Linux/MacOSx : Get local IP address