Go Type Aliasing: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * The Type System")
 
No edit summary
Line 2: Line 2:


* [[Go_Concepts_-_The_Type_System#Type_Aliasing|The Type System]]
* [[Go_Concepts_-_The_Type_System#Type_Aliasing|The Type System]]
=Overview=
An existing type can be used as the type specification of a new type.
Example:
<pre>
type Duration int64
</pre>
In the case above, <tt>Duration</tt> and <tt>int64</tt> are considered two distinct and different types. Values of two types cannot assigned to each other, even if they are compatible.
The standard library uses this type declaration to create high-level functionality from built-in types.

Revision as of 19:04, 12 April 2016

Internal

Overview

An existing type can be used as the type specification of a new type.

Example:

type Duration int64

In the case above, Duration and int64 are considered two distinct and different types. Values of two types cannot assigned to each other, even if they are compatible.

The standard library uses this type declaration to create high-level functionality from built-in types.