You could just do:

go build ./cmd/...
cp ./cmd/foo/foo ./
cp ./cmd/bar/bar ./

..and wrap it up in a script.

Quoting Tycho Andersen (2019-01-17 17:47:35)
> Hi everyone,
>
> I'm trying to get an existing project which outputs multiple binaries
> to work with go modules. The package follows roughly the recommended
> layout: https://github.com/golang-standards/project-layout
>
> That is, it looks like
>
> /go.mod
> /go.sum
> /code.go
> /cmd/foo/main.go
> /cmd/bar/main.go
>
> I have a top level make file that looks roughly like:
>
> all: foo bar
>
> foo: ...
>     go build -o foo ./cmd/foo/...
>
> bar: ...
>     go build -o bar ./cmd/bar/...
>
> When I type "make", it seems like go.sum and go.mod end up with only
> bar's dependencies, because the last go invocation prunes the "unused"
> dependencies from the module files. I've tried various ways of using
> mutiple go.mod and go.sum files (one in each binary directory), but I
> can't quite get the includes of the top level package right.
>
> I see https://github.com/golang/go/issues/14295, which will solve this
> problem for me, but it doesn't exist yet.
>
> Is there some clever way of structuring a project like this with go
> modules that I haven't figured out yet?
>
> Thanks,
>
> Tycho
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to