What's the function to create a int value from string
i := ???.????( "10" )
What's the function to create a int value from string
i := ???.????( "10" )
Import the strconv
package (src/pkg/strconv), then use strconv.Atoi("10")
Some other options:
package main
import "fmt"
func main() {
var n int
fmt.Sscan("100", &n)
fmt.Println(n == 100)
}
package main
import "strconv"
func main() {
n, e := strconv.ParseInt("100", 10, 64)
if e != nil {
panic(e)
}
println(n == 100)
}
© 2022 - 2024 — McMap. All rights reserved.