go install creates directory os_arch - select different output directory

go

Solution

That doesn't seem possible, as illustrated in issue 6201.

`GOARCH` sets the kind of binary to build. You might be cross-compiling: `GOARCH` might be arm. You definitely don't want to run the `arm` tool on an `x86` system. The host system type is `GOHOSTARCH`.

To install the api tool (or any tools) you need to use

GOARCH=$(go env GOHOSTARCH) go install .../api

and then plain '`go tool`' will find them.

In any case (`GOARCH` or `GOHOSTARCH`), the `go` command will install in a fixed location that you cannot change.

Problem

I have this folder structure for my `fib` package: ``` $ tree . └── src └── fib ├── fib │   └── main.go ├── fib.go └── fib_test.go ``` (`main.go` is in package `main`, `fib(_test).go` is in package `fib`) GOPATH is set to `$PWD/src`, GOBIN is set to `$PWD/bin`. When I run `go install fib/fib`, I get a file called `fib` in the directory `bin` (this is what I expect): ``` $ tree bin/ bin/ └── fib ``` But when I set `GOOS` or `GOARCH`, the directory in the form `GOOS_GOARCH` is created: ``` $ GOARCH=386 GOOS=windows go install fib/fib $ tree bin/ bin/ └── windows_386 └── fib.exe ``` This is not what I want. I'd like to have the file `fib.exe` in the `bin` directory, not in the sub directory `bin/windows_386`. (How) is this possible?

Original source