A struct groups related variables into a single entity.

Additionally, structs can have methods, similar to classes in C++ or Java.

Unlike classes in C++ or Java, structs don’t implement inheritance. You can achieve some of the code re-use with struct embedding.

Zero value of a struct is a struct whose fields are set to their respective zero values.

Basics of structs:

https://codeeval.dev/gist/38716aa4a1102085d3c990d2c616348c

Basic declaration

Struct literals

Anonymous structs

Composition and embedding

Exported vs. unexported fields (private vs public)

Struct tags

Duplicate a struct (make a copy)

Empty struct

Methods