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
+8.9k Golang : Inject/embed Javascript before sending out to browser example
+22.5k Golang : Set and Get HTTP request headers example
+17.9k Golang : Get all upper case or lower case characters from string example
+5.5k PHP : Fix Call to undefined function curl_init() error
+10.1k Golang : Text file editor (accept input from screen and save to file)
+8.4k Golang : Ackermann function example
+9.1k Golang : How to find out similarity between two strings with Jaro-Winkler Distance?
+48.4k Golang : Upload file from web browser to server
+16.2k Golang :Trim white spaces from a string
+16.7k Golang : Get the IPv4 and IPv6 addresses for a specific network interface
+9.1k Golang : Generate Codabar
+4.6k Adding Skype actions such as call and chat into web page examples