File: gosmith.go

package info (click to toggle)
golang-honnef-go-tools 2023.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,784 kB
  • sloc: sh: 132; xml: 48; lisp: 30; makefile: 10; javascript: 1
file content (28 lines) | stat: -rw-r--r-- 588 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main

import (
	"flag"
	"fmt"
	"math/rand"
	"os"
)

var (
	seed       = flag.Int64("seed", 0, "random generator seed")
	workdir    = flag.String("dir", "", "directory to write the program to")
	singlepkg  = flag.Bool("singlepkg", false, "generate single-package program")
	singlefile = flag.Bool("singlefile", false, "generate single-file packages")
)

func main() {
	flag.Parse()
	if *workdir == "" {
		fmt.Fprintf(os.Stderr, "-dir flag is missing\n")
		os.Exit(1)
	}
	rand.Seed(*seed)
	smith := &Smith{
		rng: rand.New(rand.NewSource(*seed)),
	}
	smith.writeProgram(*workdir)
}