4
我遇到導入「golang.org/x/net/html」的問題,它只是告訴我找不到包。環顧網絡只會讓一些人感到困惑,因爲有人說你不能再使用它了,有人說這樣做:Install exp/html in Go和一些人說只是使用「golang.org/x/net/html」只是工作精細。Golang導入問題
這裏是我試圖運行的代碼的一小部分:
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標記,因爲我不能導入包。
你是否設置了去路和根?如果是的話,你可以嘗試去獲取-u golang.org/x/net/html – MIkCode
就這樣我確保我做得正確,在eclipse中我去了window-> preferences-> Go->然後將我的GOROOT設置爲C:\ Go是否正確? –
你已經'去'了嗎? – icza