How can I manually use go tool compile to compile multiple packages into a single executable file

611 views Asked by At

For some reasons I need to use "go tool compile" to compile go files instead of using the automatic go build. "go tool compile" works fine with one file or multiple files in the same package, but if my project structure is like:

-package1
--p1.go
-package2
--p2.go
main.go
go.mod

where main.go uses symbols defined in package1 and package2. Then how am I supposed to use :go tool compile" to eventually get an executable program?

0

There are 0 answers