Golang import problem

I am having problems importing "golang.org/x/net/html", it just tells me that it cannot find the package. Looking around the Internet, I only confused me with the fact that some people say that you can’t use it anymore, some people say to do this: Install exp / html in Go and some people say that it’s just using "golang.org/ x / net / html "is working fine.

Here is just a small part of the code I'm trying to run:

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 attributes until we find an "href"
    for _, a := range t.Attr {
        if a.Key == "href" {
            href = a.Val
            ok = true
        }
    }

    return
}

This will obviously not allow me to use the html token, because I cannot import the package.

+4
source share
3 answers

https://golang.org/doc/code.html. , Go. .

, GOROOT . GOPATH , bin, pkg, src. GOPATH go get ..., .

+2

"go get golang.org/x/net/html"

0

Thank! I had the same import problem using - @storm

0
source

All Articles