Golang : convert(cast) string to integer value



Tags : golang string cast integer

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)
 }


Tags : golang string cast integer

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