Skip to content

Instantly share code, notes, and snippets.

@ianfoo
Created July 9, 2019 13:50
Show Gist options
  • Select an option

  • Save ianfoo/225101fb9a59d5c7754e6c9673970c5a to your computer and use it in GitHub Desktop.

Select an option

Save ianfoo/225101fb9a59d5c7754e6c9673970c5a to your computer and use it in GitHub Desktop.
V2 packages in go
$ for f in main.go fooprinter.go foo/foo.go foo/v2/foo.go; do echo -e "\n======= $f ======="; cat $f; done
======= main.go =======
package main
import "./foo"
func main() {
foo.Print()
printFooV2()
}
======= fooprinter.go =======
package main
import "./foo/v2"
func printFooV2() {
foo.Print()
}
======= foo/foo.go =======
package foo
import "fmt"
func Print() {
fmt.Println("Foo")
}
======= foo/v2/foo.go =======
package foo
import "fmt"
func Print() {
fmt.Println("Foo V2")
}
$ go run *.go
Foo
Foo V2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment