github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/internal/gosmith/gosmith.go (about) 1 package main 2 3 import ( 4 "flag" 5 "fmt" 6 "math/rand" 7 "os" 8 ) 9 10 var ( 11 seed = flag.Int64("seed", 0, "random generator seed") 12 workdir = flag.String("dir", "", "directory to write the program to") 13 singlepkg = flag.Bool("singlepkg", false, "generate single-package program") 14 singlefile = flag.Bool("singlefile", false, "generate single-file packages") 15 ) 16 17 func main() { 18 flag.Parse() 19 if *workdir == "" { 20 fmt.Fprintf(os.Stderr, "-dir flag is missing\n") 21 os.Exit(1) 22 } 23 rand.Seed(*seed) 24 smith := &Smith{ 25 rng: rand.New(rand.NewSource(*seed)), 26 } 27 smith.writeProgram(*workdir) 28 }