[Solved] Go Get Download Dependency Error: is not using a known version control system

Background

GoLand input command

C:\Users\HI\go\GoPack> go get -u github.com/gin-gonic/gin

Errors are reported as follows

package github.com/gin-gonic/gin: directory "C:\\Users\\HI\\go\\src\\github.com\\gin-gonic\\gin" is not using a known version control system

analysis

This problem belongs to dependency management, go module is an official version management tool launched after go1.11, and from go1.13, go module will be the default dependency management tool of go language
Enter go env to view the specific contents of go module. First, pay attention to go111module, which is the environment variable of go module , and the default is auto
when go111module = off, module support is not enabled. During compilation, dependencies will be found under gopath and vendor
when go111module = on, the module support is enabled. During compilation, the gopath and vendor dependencies will be ignored and downloaded directly from go. Mod
when go111module = auto, when the project is outside $gopath/SRC and there are go. Mod files in the project root directory, open the module support
.

Currently, there is no go.Mod in the root directory of the project I created, so the module supports closing by default

Solution:

 C:\Users\HI\go\GoPack> $env:GO111MODULE="on"

Read More: