英文:
Import web.go error after using goinstall
问题
根据<a href="https://stackoverflow.com/questions/2892352/web-go-install-error">halfdans的建议</a>,我成功地使用goinstall github.com/hoisie/web.go进行了安装,之前安装了git后没有出现任何错误。然而,现在当我尝试编译给出的示例代码时,go无法找到web包,我得到了以下错误:
main.go:4: 找不到导入: web
代码如下:
package main
import (
"web"
)
func hello(val string) string { return "hello " + val }
func main() {
web.Get("/(.*)", hello)
web.Run("0.0.0.0:9999")
}
是否有什么特殊的操作我需要做才能让它识别到这个包?我在$GOROOT/src/pkg/github.com/hoisie/web.go/web找到了包的源代码。我尝试使用github.com/hoisie/web.go/web作为导入,但它仍然不喜欢这样。
英文:
With <a href="https://stackoverflow.com/questions/2892352/web-go-install-error">halfdans advice</a>, I was successfully able to use goinstall github.com/hoisie/web.go without any errors after installing git first. However, now when I try to compile the sample code given, go is not finding the web package. I get the error,
main.go:4: can't find import: web
On this code
package main
import (
"web"
)
func hello(val string) string { return "hello " + val }
func main() {
web.Get("/(.*)", hello)
web.Run("0.0.0.0:9999")
}
Is there something special I need to do in order for it to recognize the package? I found the package source at $GOROOT/src/pkg/github.com/hoisie/web.go/web. I tried github.com/hoisie/web.go/web as the import and it still did not like that.
答案1
得分: 3
如果您通过goinstall安装web.go,您需要执行以下操作:
import "github.com/hoisie/web.go"
Goinstall仍然是一个实验性的系统。如果您不必包含完整路径,那将是很好的。
英文:
If you install web.go through goinstall, you need to do:
import "github.com/hoisie/web.go"
Goinstall is still an experimental system. It would be nice if you didn't have to include the full path.
答案2
得分: 2
import web "github.com/hoisie/web.go"
英文:
import web "github.com/hoisie/web.go"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论