Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 800
SnowyCDN Avatar asked Oct 16 '25 16:10

SnowyCDN


1 Answers

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

like image 94
Kenan Faruk ÇAKIR Avatar answered Oct 18 '25 06:10

Kenan Faruk ÇAKIR



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!