1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| package main
import ( "fmt" "strconv" "strings" )
func main() { port1, err := strconv.Atoi("12345") if err != nil { panic(err) } port2 := uint16(port1) fmt.Printf("type:%T value:%v\n", port1, port1) fmt.Printf("type:%T value:%v\n", port2, port2) fmt.Println(port2)
port3, err := strconv.ParseUint("1234", 10, 16) if err != nil { panic(err) } port4 := uint16(port3) fmt.Printf("type:%T value:%v\n", port3, port3) fmt.Printf("type:%T value:%v\n", port4, port4) fmt.Println(port4) }
|