Types with direct conversion

Report a typo

The table below shows the relations between types. In the rows, you can see the original type (the type from which the conversion is performed). In the columns, you can see the type of destination (the type to which the conversion is performed).

For example, since it is possible to convert an int type to float32 using the type conversion syntax:

package main

import "fmt"

func main() {
    var a int = 100
    b := float32(a)
    fmt.Println(b) // 100
}

You would tick the box where the int|uint types are in the rows and the float32|float64 types are in the columns.

Please do not tick the box for redundant/same-type conversions!

Tip: The string type can be converted to a slice of bytes ([]byte) or runes ([]rune).

Choose one or more options for each row
int|uintfloat32|float64rune|bytestring
int|uint
float32|float64
rune|byte
string
___

Create a free account to access the full topic