2013-08-13 08:47
浏览 40


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:


    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.

    解决 无用
    打赏 举报

相关推荐 更多相似问题