在使用goinstall后导入web.go时出现错误。

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

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&#39;t find import: web

On this code

package main

import (
    &quot;web&quot;
)

func hello(val string) string { return &quot;hello &quot; + val }

func main() {
    web.Get(&quot;/(.*)&quot;, hello)
    web.Run(&quot;0.0.0.0:9999&quot;)
}

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 &quot;github.com/hoisie/web.go&quot;

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 &quot;github.com/hoisie/web.go&quot;

huangapple
  • 本文由 发表于 2010年5月24日 06:34:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/2893772.html
匿名

发表评论

匿名网友

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

确定