Answers for "golang convert uint32 to int32"

Go
-1

golang interface to int

var myInt interface{}
myInt = 8

toInt, ok := myInt.(int)
fmt.Println(toInt, ok)  // 8 true

toString, ok := myInt.(string)
fmt.Println(toString, ok)  // "" false
Posted by: Guest on May-17-2021

Browse Popular Code Answers by Language