Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Struct with partial information (default values)

package main

import (
	"fmt"
)

type aPerson struct {
	id       int
	name     string
	email    string
	shoeSize float32
}

func main() {
	joe := aPerson{
		id:       1,
		name:     "Joe",
		email:    "joe@joehome.com",
		shoeSize: 42.5,
	}
	fmt.Println(joe)
	fmt.Println()

	jane := aPerson{
		id:   2,
		name: "Jane",
	}
	fmt.Println(jane)
}
{1 Joe joe@joehome.com 42.5}

{2 Jane  0}