On Saturday, 10 December 2022 at 05:50:53 UTC pat2...@gmail.com wrote: > thanks, and the playground is nice. > > I think this is saying that if I want a baz and bar executable (chmod +x) > then I need the "package main" in separate folders/directories >
Yes. The approach I use (which I borrowed from some other project) is to have cmd/baz/ cmd/bar/ bin/ directories, with cmd/{baz,bar}/ containing *.go files for each executable. Then at the top level, *go build -o bin ./...* will make everything, and stick the binaries in the 'bin' directory. The binaries will be named after their enclosing directories, i.e. "baz" and "bar". Alternatively you can build them separately, e.g. (cd cmd/baz; go build .) You only need a single go.mod file at the top level. If that declares the module as github.com/xxx/yyy, then people can build and install your binaries individually as, for example, go install github.com/xxx/yyy/cmd/baz@latest I'm not sure the official way to install *all* the binaries at once, but this seems to work: go install github.com/xxx/yyy/...@latest -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/34e9e726-9ec6-4f56-95f7-75e4cf9af194n%40googlegroups.com.