We can defined our own type based on existing Go in-build types. We have declared
person as user defined type based on struct. We are not limited to struct. We can define our type based on any other type as base type.
We can declare our type using
type keyword. It generally takes form of
type type_name base_type
main.gotype marks inttype liters float64var m1 marksm1 = 20var l1 litersl1 = 3.4
liters are types based on
Go defined types most often use structs as their underlying types, but they can also be based on ints, strings, booleans, or any other type. - Head First Go