Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tour: Updated description of struct and added type description in moretypes/2 #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tour/content/moretypes.article
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ Unlike C, Go has no pointer arithmetic.

* Structs

A `struct` is a collection of fields.
A `struct` is a typed collection of fields. In Go, structs are the way to create user-defined concrete types.
Syntax to create a struct starts with the keyword `type`, then a name for the struct, followed by the `struct` keyword.
Inside curly backets, collection of fields are specified with field name and field type.

The `type` keyword is used to define a new type in Go. It is generally referred as [[https://golang.org/ref/spec#Type_definitions][type definition]].

In the given example, a new struct type `Vertex` is created which consist of fields `X` & `Y` of type `int`.

*Note:* Data field in a struct is declared with a known type, which could be a built-in type or a user-defined type.
.play moretypes/structs.go

* Struct Fields
Expand Down