Home »
Golang »
Golang FAQ
What form of type conversion does Go support?
Learn about the conversion in Go language, what form of type conversion does Go support?
Submitted by IncludeHelp, on October 04, 2021
Go programming language supports explicit type conversion. It does not support implicit type conversion due to its strong type system.
Consider the syntax,
new_type (variable/value)
Example:
// Golang program to demonstrate the
// example of explicit type conversion
package main
import "fmt"
func main() {
var VarInt int
var VarFloat float32
VarFloat = 123.45
// Converting float32 to int
VarInt = int(VarFloat)
// Printing the values
fmt.Println(VarInt)
fmt.Println(VarFloat)
}
Output:
123
123.45
Golang FAQ »