Golang "go get" command shows "go: missing git command" error

I am new to go lang. Trying to import the go library using the "get get" command, but in cmd gets this error:

go: missing Git command. See https://golang.org/s/gogetcmd package github.com/ttacon/chalk: exec: "git": executable file not found in %PATH% 

My Go Env:

 set GOARCH=amd64 set GOBIN= set GOEXE=.exe set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOOS=windows set GOPATH=F:\Works\Go set GORACE= set GOROOT=C:\Go set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64 set GO15VENDOREXPERIMENT=1 set CC=gcc set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 set CXX=g++ set CGO_ENABLED=1 

What happened to my Go environment?

+12
source share
4 answers

go get requires git if any of the packages lives (and is retrieved) from the git repository. For Windows, you can install git from the git website.

+21
source

The source code is extracted using one of the following tools expected on your system: git, svn, hg.

Install git from this link https://git-scm.com/downloads

After installing git, you need to go on to setting up the environment variables and add the path to git.exe (executable file), which is located in the trash. Thus, the path should look like this: "C: \ Program Files \ Git \ bin". Restart your IDE and the command should work.

+4
source

locally

Installing git will solve the problem.

  • for mac brew install git
  • for ubuntu sudo apt-get install git
  • for linux pacman -S git arch
  • for windows, install git according to the instructions on the git installation page .

In docker

If you are in the process of creating a Docker image, you should install git there. [I got this problem when creating a docker image]

For example: in my Dockerfile

 FROM golang:alpine RUN apk add git 
+4
source

Install Git.

for ubuntu you can use the command

 sudo apt-get install git 
+1
source

Source: https://habr.com/ru/post/1245182/


All Articles