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

Separate directories! - main redeclared in this block

  • Put each example / exercise in a separate directory
  • As each package must have only one main() function.
package main

import (
	"fmt"
)

func main() {
	fmt.Println("Hello Same One")
}
package main

import (
	"fmt"
)

func main() {
	fmt.Println("Hello Same Two")
}
go run .
# _/home/gabor/work/slides/golang/examples/same
./same_two.go:7:6: main redeclared in this block
	previous declaration at ./same_one.go:7:6