Keyword
Go struct keyword
Defines an aggregate with named fields and optional embedded fields. A struct value can be copied; reference-like fields may still refer to shared data. Use keyed literals for clarity. Example prints tea 4.
Formal Syntax & Structure
go syntaxgo
struct { fieldDeclarations }Working Example
Example Snippetgo
package main
import "fmt"
func main() { order := struct { Name string Count int }{Name: "tea", Count: 4} fmt.Println(order.Name, order.Count)}