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
+5.9k Mac OSX : Find large files by size
+4.2k Golang : Constant and variable names in native language
+5.4k Grep : How to grep for strings inside binary data
+5k Golang : Detect variable or constant type
+21.7k Golang : Randomly pick an item from a slice/array example
+23.7k Golang : Storing cookies in http.CookieJar example
+12.9k Golang : Google Drive API upload and rename example
+6.3k Golang : File system scanning
+3.5k Java : Generate multiplication table example
+7k Golang : Add build version and other information in executables
+11.9k Golang : Increment string example
+15.7k Golang : How to tell if a file is compressed either gzip or zip ?