Confused? type definition

Go has untyped constants, which (like literals) are assignable to variables of types with the same underlying type. This is so that you can say things like

var m Method = "hello"

and

var d = 5 * time.Millisecond

without running into an error because "hello" is not of type Method nor 5 of type time.Duration. The same assignability rule governs what you can pass as a function argument.

1 Like