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
+40.3k Golang : UDP client server read write example
+12.3k Golang : Split strings into command line arguments
+6k Golang : Use NLP to get sentences for each paragraph example
+7.8k Gogland : Where to put source code files in package directory for rookie
+14k Golang : How to check if a file is hidden?
+7.1k Golang : How to call function inside template with template.FuncMap
+6.1k Golang : Compound interest over time example
+7.5k Golang : How to detect if a sentence ends with a punctuation?
+11.3k Golang : Fix go.exe is not compatible with the version of Windows you're running
+5.4k Javascript : Shuffle or randomize array example