5

What's the function to create a int value from string

i := ???.????( "10" )
0

2 Answers 2

8

Import the strconv package (src/pkg/strconv), then use strconv.Atoi("10")

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.