Hi all,
Here is an example project:
$GOPATH/src/project:
- foo
|- main.go
- bar
|- main.go
If I cd into foo/, run go build, it prodices foo binary in the foo/ directory. The same for bar.
But, if I run "go build -v ./..." in the project's root, I get the following output, and have no binaries:
$ go build -v ./...
project/bar
project/foo
$ find .
.
./bar
./bar/main.go
./foo
./foo/main.go
go build ./... for subdirs produces no binaries at all. go help packages do not help to understand it.
So, is it designed to be like that on purpose?
EDIT: found in go help build:
When the command line specifies a single main package, build writes the resulting executable to output. Otherwise build compiles the packages but discards the results, serving only as a check that the packages can be built.
评论:
:
divan0:[deleted]
Well, I'm aware of go install ./..., but the point is 'go build' command is a synonym for 'compile and get binary in current dir', so I do expect the same when I run with ./...
Now, I see in go help build this behavior is described, but I still wonder why it's made so. Why not build binaries for multiple packages as well on go build ./...?
