Skip to content

Instantly share code, notes, and snippets.

@mindscratch
Created December 7, 2013 04:18
Show Gist options
  • Select an option

  • Save mindscratch/7837213 to your computer and use it in GitHub Desktop.

Select an option

Save mindscratch/7837213 to your computer and use it in GitHub Desktop.
go using underscores in front of import package names
// $GOPATH/src/foo/foo.go
package foo
import "fmt"
func init() {
fmt.Println("foo init")
}
func init() {
fmt.Println("foo init again")
}
// $GOPATH/main.go
package main
import _ "foo"
import "fmt"
func main() {
fmt.Println("in main")
}
// RUN:
// > go run main.go
foo init
foo init again
in main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment