Golang converte strings, ints com ITOA
Golang program that converts strings, ints with Itoa
package main
import (
"fmt"
"strconv"
)
func main() {
value := 120
// Use Itoa to convert int to string.
result := strconv.Itoa(value)
fmt.Println(result)
if result == "120" {
fmt.Println(true)
}
// Use Atoi to convert string to int.
original, _ := strconv.Atoi(result)
if original == 120 {
fmt.Println(true)
}
}
Output
120
true
true
Grumpy Giraffe