【发布时间】:2015-05-25 20:30:25
【问题描述】:
我在导入“golang.org/x/net/html”时遇到问题,它只是告诉我找不到包。环顾互联网只是让我更加困惑,有些人说你不能再使用它了,有些人说这样做:Install exp/html in Go 还有一些人说只使用“golang.org/x/net/html”工作得很好。
这只是我尝试运行的代码的一小部分:
package main
import (
"fmt"
"html"
"net/http"
"golang.org/x/net/html"
"os"
"strings"
)
// Helper function to pull the href attribute from a Token
func getHref(t html.Token) (ok bool, href string) {
// Iterate over all of the Token's attributes until we find an "href"
for _, a := range t.Attr {
if a.Key == "href" {
href = a.Val
ok = true
}
}
return
}
它显然不会让我使用 html 令牌,因为我无法导入包。
【问题讨论】:
-
你设置了 go path 并 go root 了吗?如果是,你可以试试 go get -u golang.org/x/net/html
-
只是为了确保我做的正确,在 Eclipse 中我转到 window->preferences->Go->然后将我的 GOROOT 设置为 C:\Go 这是正确的吗?
-
你已经
go get-ed了吗? -
当谈到使用“go get code.google.com/p/go.net/html”时,我不太确定如何使用它。把它放在导入中不起作用,我真的不明白我应该把它放在哪里
-
哦,好的,我明白了,但是我收到错误消息“无法下载,$GOPATH 未设置”,所以我一定没有正确设置路径:/。再次抱歉这是多么愚蠢。我在视觉工作室之外的编程经验非常少。在实际创建路径并尝试执行 go get golang.org/x/net/html 之后,我遇到了另一个问题:go: missing Git command....有什么想法吗?
标签: go