Go Structs: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
No edit summary
Line 6: Line 6:


A <tt>struct</tt> is a user-defined type that contains named fields.
A <tt>struct</tt> is a user-defined type that contains named fields.
<pre>
type myStruct {
    i int
    s string
}
</pre>


<font color=red>Are all users can define (in terms of types) structs, or there are other user-defined types?</font>
<font color=red>Are all users can define (in terms of types) structs, or there are other user-defined types?</font>

Revision as of 01:52, 30 March 2016

Internal

Overview

A struct is a user-defined type that contains named fields.

type myStruct {
    i int
    s string
}

Are all users can define (in terms of types) structs, or there are other user-defined types?

Struct Literals

Fields

A field is always exported by the package it is enclosed in.