how to import package from github


I’m trying to build a api using Go and I tried running a existing file from GitHub that I got from udemy course. I’m getting this kind of output:

C:\goworkspace\src\grpc-go-course-master\blog\blog_client>go run client.go
client.go:4:2: cannot find package "context" in any of:
        C:\go\src\context (from $GOROOT)
        C:\goworkspace\src\context (from $GOPATH)
..\..\..\\x\net\http2\not_go111.go:10:2: cannot find package "net/http/httptrace" in any of:
        C:\go\src\net\http\httptrace (from $GOROOT)
        C:\goworkspace\src\net\http\httptrace (from $GOPATH)

Could you suggest me what can cause this error?


In order to download the dependencies, you have to use the go get command:

go get -v -u

Change with the package that you need (in that repo you can find a bunch of ‘utils’ method).

If the project, instead, have the go.mod file, you have to type:

go clean
go build

By this way you are going to install the dependencies listed in the go.mod file.

For update the dependencies to the latest version:

go get -v -u all

Answered By – alessiosavi

Answer Checked By – Dawn Plyler (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.