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 variables

package main

import (
	"flag"
	"fmt"
)

func main() {
	var debug bool
	var score int
	var name string

	flag.BoolVar(&debug, "debug", false, "Debug or not?")
	flag.IntVar(&score, "score", 0, "The score")
	flag.StringVar(&name, "name", "", "The name")
	flag.Parse()

	fmt.Println(debug)
	fmt.Println(score)
	fmt.Println(name)
}