在Golang项目引包部分

    "github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
	_ "github.com/globalsign/mgo/bson"

出现爆红或者警告,然后在go.build环节失败

 cannot find package "github.com/gin-gonic/gin" in any of:
        C:\Work\go\src\github.com\gin-gonic\gin (from $GOROOT)

然后出现这种错误。

解决办法:

打开cmd,

> go mod init gin    # 重新引入gin包

# 如果出现以下报错

> go: modules disabled by GO111MODULE=off; see 'go help modules'

> go env -w GO111MODULE=on

> go env -w GOPROXY=https:

# 执行完以上两个命令后,再执行一次下面就行了。回去看看VScode警告消失。
> go mod init gin