This deduplicates examples, leaving only the most maintained or targeted ones. Notably, this makes each runnable, avoiding test dependencies. Signed-off-by: Adrian Cole <adrian@tetrate.io>
21 lines
344 B
Go
21 lines
344 B
Go
package main
|
|
|
|
import "os"
|
|
|
|
// ExampleMain ensures the following will work:
|
|
//
|
|
// go build cat.go
|
|
// ./cat ./test.txt
|
|
func ExampleMain() {
|
|
|
|
// Save the old os.Args and replace with our example input.
|
|
oldArgs := os.Args
|
|
os.Args = []string{"cat", "./test.txt"}
|
|
defer func() { os.Args = oldArgs }()
|
|
|
|
main()
|
|
|
|
// Output:
|
|
// hello filesystem
|
|
}
|