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
+22k Golang : Use TLS version 1.2 and enforce server security configuration over client
+22.1k Golang : Join arrays or slices example
+12.7k Golang : Drop cookie to visitor's browser and http.SetCookie() example
+5.8k Linux/Unix/PHP : Restart PHP-FPM
+5.7k Swift : Get substring with rangeOfString() function example
+15.1k Golang : How do I get the local IP (non-loopback) address ?
+9.6k Golang : Changing a RGBA image number of channels with OpenCV
+6.3k Golang : Get Hokkien(福建话)/Min-nan(閩南語) Pronounciations
+5.1k Golang : Calculate a pip value and distance to target profit example
+10.3k Golang : Bcrypting password
+10.2k Golang : Edge detection with Sobel method
+12.4k Golang : Get month name from date example