dri98076 2013-08-13 08:47
浏览 40
已采纳

如何在1.1.2中编译依赖项并在1.1.2中编译go程序?

Every time I try to compile my program after (this morning) upgrading go from 1.1.1 to 1.1.2 (on Windows 7 64 bits), I get error message like:

C:\Users\VonC\prog\go\src\github.com\spf13\hugo>go build -o hugo.exe main.go
# github.com/spf13/hugo/hugolib
hugolib\page.go:23: import C:\Users\VonC\prog\go\pkg\windows_amd64/github.com/emicklei/hopwatch.a: 
  object is [windows amd64 go1.1.1 X:none] 
  expected [windows amd64 go1.1.2 X:none]

I tried a go clean -r, but the error message persists?

What is the right clean command to use?

  • 写回答

1条回答 默认 最新

  • duanhuau567787 2013-08-13 08:47
    关注

    Actual solution:

    I reproduced the issue with:

    • calling the 1.1.2 go.exe directly (I didn't have %GOROOT%\bin in my path)
    • with GOROOT pointing to the previous 1.1.1 installation folder (I kept go 1.1.1 and 1.1.2 installed in separated folders).

    If you are sticking with the default go setup (ie: one C:\go installation directory, and %GOROOT%\bin in your PATH), you won't see this error.

    But if you do see this error:

    • make sure %GOROOT% is consistent with the go.exe you are calling
    • go install -a as explained below. The go clean mentioned below won't be necessary.
      As jnml comments:

    the Go build system is supposed to figure out any obsolete stuff in $GOPATH/pkg and (transitively) rebuild it on demand.


    Original solution:

    In the "Remove object files" section of "Command go" page, I missed the go clean -i option:

    -i
    

    The -i flag causes clean to remove the corresponding installed archive or binary (what 'go install' would create).

    And those .a file (like hopwatch.a) are precisely what go install generates for libraries (in Windows).

    So the full clean command, to make sure go rebuild everything, would be:

    cd C:\Users\VonC\prog\go\src\github.com\spf13\hugo
    go clean -r -i
    go install -a
    

    That will rebuild and install everything, including all dependent packages.

    The -a is actually a build option, which forces rebuilding of packages that are already up-to-date.


    As usual, go clean -r -n would show you what would be cleaned (-n: preview option).
    It doesn't hurt to be sure of what will be deleted... before actually deleting anything.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值