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 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)