package main import ( "fmt" "reflect" ) func main() { var i int = 42 var f float32 = float32(i) fmt.Println(reflect.TypeOf(i).ConvertibleTo(reflect.TypeOf(f))) // true }
package main import ( "fmt" "reflect" ) func main() { var s string = "Hello, world!" var b []byte = []byte(s) fmt.Println(reflect.TypeOf(s).ConvertibleTo(reflect.TypeOf(b))) // true }In this example, we convert a `string` to a `[]byte` variable `b` using the type conversion syntax `[]byte(s)`. We then check if the type of `s` (which is `string`) is convertible to the type of `b` (which is `[]byte`). The result is `true`, indicating that the conversion is possible. The `reflect` package library is used in these examples to dynamically access and manipulate objects at runtime.