What (exactly) does the type keyword do in go?

The type keyword is there to create a new type. This is called type definition. The new type (in your case, Vertex) will have the same structure as the underlying type (the struct with X and Y). That line is basically saying “create a type called Vertex based on a struct of X int and Y int”.

Don’t confuse type definition with type aliasing. When you declare a new type, you are not just giving it a new name – it will be considered a distinct type. Take a look at type identity for more information on the subject.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)