如何重新构建 godef 以与 Go 1.4 兼容

huangapple go评论64阅读模式
英文:

How to rebuild godef to work with Go 1.4

问题

升级到Go 1.4之后,godef无法再找到许多标准库中的内容,例如Testing.Fatalf

当我尝试运行go get -u时,出现以下错误:

package code.google.com/p/goplan9/plan9/acme
	imports code.google.com/p/goplan9/plan9/acme
	imports code.google.com/p/goplan9/plan9/acme: 在以下位置都找不到包"code.google.com/p/goplan9/plan9/acme":
	/Users/bryan/local/go/src/code.google.com/p/goplan9/plan9/acme (来自$GOROOT)
	/Users/bryan/sweng/oms/src/code.google.com/p/goplan9/plan9/acme (来自$GOPATH)
英文:

After I upgraded to Go 1.4, godef is no longer finding many things in the standard libraries, for instance Testing.Fatalf.

When I try to go get -u, I get these errors:

package code.google.com/p/goplan9/plan9/acme
	imports code.google.com/p/goplan9/plan9/acme
	imports code.google.com/p/goplan9/plan9/acme: cannot find package "code.google.com/p/goplan9/plan9/acme" in any of:
	/Users/bryan/local/go/src/code.google.com/p/goplan9/plan9/acme (from $GOROOT)
	/Users/bryan/sweng/oms/src/code.google.com/p/goplan9/plan9/acme (from $GOPATH)

答案1

得分: 3

我不是一个代码编辑器,但是我可以帮你翻译这段文本。以下是翻译的结果:

我不得不编辑这个文件,因为一个依赖项已经移动了:

--- a/exp/cmd/godef/acme.go
+++ b/exp/cmd/godef/acme.go
@@ -1,7 +1,7 @@
 package main
 
 import (
-	"code.google.com/p/goplan9/plan9/acme"
+	"9fans.net/go/acme"
 	"fmt"
 	"io"
 	"os"

然后运行 go buildgo install,一切都恢复正常了。

英文:

I had to edit this file because a dependency has moved:

--- a/exp/cmd/godef/acme.go
+++ b/exp/cmd/godef/acme.go
@@ -1,7 +1,7 @@
 package main
 
 import (
-	"code.google.com/p/goplan9/plan9/acme"
+	"9fans.net/go/acme"
 	"fmt"
 	"io"
 	"os"

Then go build and go install and all working great once more.

答案2

得分: 0

我已经遇到了相同的问题,我修改了godef.go文件。

--- a/exp/cmd/godef/godef.go  2015-01-19 15:29:10.760304470 -0500
+++ b/exp/cmd/godef/godef.go  2015-02-10 21:36:29.678102962 -0500
@@ -47,7 +47,7 @@
        }
        r := runtime.GOROOT()
        if r != "" {
-               gopath = append(gopath, r+"/src/pkg")
+               gopath = append(gopath, r+"/src")
        }
        types.GoPath = gopath
}
英文:

I've experienced the same issue, I edited godef.go though.

--- a/exp/cmd/godef/godef.go  2015-01-19 15:29:10.760304470 -0500
+++ b/exp/cmd/godef/godef.go  2015-02-10 21:36:29.678102962 -0500
@@ -47,7 +47,7 @@
        }
        r := runtime.GOROOT()
        if r != "" {
-               gopath = append(gopath, r+"/src/pkg")
+               gopath = append(gopath, r+"/src")
        }
        types.GoPath = gopath
}

huangapple
  • 本文由 发表于 2015年1月9日 20:04:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/27860178.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定