In golang you can define a type as a data structure
type MyMap map[int]int
mapper := make(MyMap)
and go on to use it like a regular map in go
mapper[13] = 133
But I don't understand when to use this or in what scenarios this will helpful?
In golang you can define a type as a data structure
type MyMap map[int]int
mapper := make(MyMap)
and go on to use it like a regular map in go
mapper[13] = 133
But I don't understand when to use this or in what scenarios this will helpful?
That is not a type alias (as the OP originally asked, before the question was edited).
That is a type definition or "defined type".
A type definition creates a new, distinct type with the same underlying type and operations as the given type, and binds an identifier to it.
TypeDef = identifier Type .
That allows you to attach method on that type that you would not have been able to with the original type.
Type alias is part of the Go 1.9 changes.
It was proposed here and documented in Code refactoring.
Go should add the ability to create alternate equivalent names for types, in order to enable gradual code repair during codebase refactoring.