I thought go does not allow the assignment of a named type to the actual type assignment without explicit type conversion.
But how does it compile without error if I assign []byte in json.RawMessage ?
var a json.RawMessage // type RawMessage []byte var b []byte a = b var x time.Duration // type Duration int64 var y int64 x = y // ERROR: cannot use y (type int64) as type time.Duration in assignment
https://play.golang.org/p/oD5LwJl7an
source share