doujubeng2942 2014-11-28 10:49
浏览 38
已采纳

去安装创建目录os_arch-选择不同的输出目录

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?

  • 写回答

2条回答 默认 最新

  • dongxianghuan3587 2014-11-28 12:07
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应