Skip to content

Instantly share code, notes, and snippets.

@morrxy
Last active August 28, 2017 03:12
Show Gist options
  • Select an option

  • Save morrxy/c982e8d28f1fb5ce8e3cc394add546c6 to your computer and use it in GitHub Desktop.

Select an option

Save morrxy/c982e8d28f1fb5ce8e3cc394add546c6 to your computer and use it in GitHub Desktop.
[str to int] #golang
//https://www.dotnetperls.com/parseint-go
package main
import (
"fmt"
"strconv"
)
func main() {
value := "123"
// Convert string to int.
number, _ := strconv.ParseInt(value, 10, 0)
// We now have an int.
fmt.Println(number)
if number == 123 {
fmt.Println(true)
}
}
//Output
//123
//true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment