简体   繁体   中英

How to properly download and install packages in Go?

I have no clue what I'm doing wrong, I look up steps online what to do and they all tell me to just go to CMD, type in go get ___ and then just import the github link into my file but I constantly get the could not import error in VS Code.

I am trying to parse some HTML code that I get from a response and I need the "golang.org/x/net/html" to be able to do things. Can someone please tell me what I'm doing wrong?

You can use go modules to manage dependencies.

First you initialize your module with go mod init ProjectName . Then when you build your project with go build it will find and download missing packages to module cache directory which is ~/go/pkg/mod .

You can use go mod tidy also.

For more information: Go Modules

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM