018structs

command
v0.0.0-...-db3ee8d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2021 License: MPL-2.0 Imports: 1 Imported by: 0

README

Structs

Go's structs are typed collections of fields. They are useful for grouping data together to form records.

// declare struct
type person struct {
  name string
  age int
}

// create new struct
newPerson := person{"James", 30}
otherNewPerson := person{name: "James", age: 30}
noAge := person{name: "James"} // age will default to int 0

It’s idiomatic to encapsulate new struct creation in constructor functions.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL