var a int // declare variables and set to zero values
a := 10 // declare and initialize ( type is automatically detected by Go )
/*
Common Data Types in Go:
int, uint, bool, string, rune, float, chan ( channel ),
nil (Zero value for pointers, interfaces, slices, channels, functions and maps.)
*/
Go is zero valued
Strings in Go
[]byte
using []byte(string)
and string([]byte)
, enabling low-level manipulation. For more complex conversions (e.g., string to int), the strconv
package is used.Type Conversion
var y float64 = x // This will cause an error
var y float64 = float64(x) // Explicit conversion required
Structs are basically user defined types or custom types.