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
+39.7k Golang : UDP client server read write example
+4.6k Fix Google Analytics Redundant Hostnames problem
+15.3k Golang : How to convert(cast) IP address to string?
+9.4k Golang : How to generate Code 39 barcode?
+10.9k Golang : Calculate Relative Strength Index(RSI) example
+27.7k Golang : Move file to another directory
+4.8k Golang : Display packages names during compilation
+9k Golang : Generate EAN barcode
+11.3k Golang : Find age or leap age from date of birth example
+22.7k Golang : Test file read write permission example
+8.4k Golang : Set or add headers for many or different handlers
+6.7k Golang : Decode XML data from RSS feed