Type casting in Golang is a way to convert the variable from one data type to another data type. For instance, if you want to save the long value into a simple integer, then you can type cast long to int. You can convert the values from one type to another using the cast operator.

Golang Type Casting

Type conversion happens when we assign a value of one data type to another data type. Statically typed languages like C++ and Java, which provide the support for Implicit Type Conversion, but the Go language is different, as it doesn’t support a Automatic Type Conversion or Implicit Type Conversion even if the data types are compatible.

Golang does not support implicit type conversion because of its Strong Type System, which doesn’t allow it to do this.

#go #golang

Golang Type Casting | Type Conversion in Go Example
8.25 GEEK