Go Notes: Structs
Published: 24th of November 2019
A Structure or struct for short, is a type defined by the user that stores a collection of fields.
go
// create a struct
type stuffAndThings struct {
stuff string
things string
}
// Instantiate a struct
st := stuffAndThings{
stuff: "stuff",
things: "things",
}
// Use the dot (.) operator to access struct fields
st.stuff
st.things
Links
https://gobyexample.com/structs
https://golangbot.com/structs/
https://tour.golang.org/moretypes/2