Tag Archives: cannot find module providing package github.com/

[Solved] Go Language Error: cannot find module providing package github.com/

Preface

Gopath doesn’t work

Text

After using the proxy to download the go package, there is a problem that the package cannot be found. Later, it is found that if the proxy is used, it will go to the PKG package to find the dependency

Solution

When goproxy is used, go111module is turned on, which causes package management to go to the directory of $gopath/SRC/PKG instead of being in the directory of $gopath/SRC/PKG.
for details, please refer to these two articles:
go get downloaded packages
to solve the problem that go can’t download
at this time, we need to use go mod to introduce these packages/ gin@latest, Solve the problem that import can’t get the package

That is, run the following two commands

 go mod init gin
 
 go mod edit -require github.com/gin-gonic/gin@latest