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
+11.3k Golang : Characters limiter example
+16.5k Golang : Test floating point numbers not-a-number and infinite example
+16.3k Golang : convert string or integer to big.Int type
+5.6k Golang : Detect words using using consecutive letters in a given string
+10.6k Android Studio : Simple input textbox and intercept key example
+9.5k Android Studio : Indicate progression with ProgressBar example
+52.6k Golang : How to get struct field and value by name
+5.4k Javascript : How to loop over and parse JSON data?
+9.8k Golang : interface - when and where to use examples
+4.4k Linux/MacOSX : Search and delete files by extension
+9.7k Golang : How to generate Code 39 barcode?
+24.6k Golang : Time slice or date sort and reverse sort example