Yeahia Md Arif
Yeahia Md Arif

Reputation: 7926

golang "go get" command showing "go: missing Git command" error

I'm new in go lang. Trying to import a go library using "go get" command but in cmd getting 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's wrong with my Go environment?

Upvotes: 34

Views: 101443

Answers (5)

Neil P.
Neil P.

Reputation: 1114

If you're running this as a Jenkins pipeline script, start your Docker image like:

node('docker') {
  docker.image('golang:1.14rc1-alpine3.11').inside(' -u 0') {
    sh 'apk add curl'
    ...
  }
}

Upvotes: 1

alamin
alamin

Reputation: 2487

Locally

Installing git will solve the issue.

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

In Docker

If you are getting while running in building docker image then you should install git there. [I got this issue while building docker image]

For Example: In my Dockerfile

FROM golang:alpine 
RUN apk add git

Upvotes: 39

Pankaj Singh
Pankaj Singh

Reputation: 1178

Install git.

for Ubuntu, you can use the command

sudo apt-get install git

Upvotes: 3

Variety_Davids
Variety_Davids

Reputation: 61

The go get fetching of source code is done by using one of the following tools expected to be found on your system either git, svn, hg.

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

After installing git you should navigate to the environment variables setting and add the path of git.exe(executable file) which is found in the bin. So the path should look like this "C:\Program Files\Git\bin". Restart your IDE and the command should be working.

Upvotes: 6

T0xicCode
T0xicCode

Reputation: 4931

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

Upvotes: 44

Related Questions