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

Flags as pointers

  • The resulting variables are pointers
package main

import (
	"flag"
	"fmt"
)

func main() {
	var debug = flag.Bool("debug", false, "Debug or not?")
	var score = flag.Int("score", 0, "The score")
	var name = flag.String("name", "", "The name")
	flag.Parse()
	fmt.Println(*debug)
	fmt.Println(*score)
	fmt.Println(*name)
}