1

I was using go get go get the go-sql-driver from github. When I ran the command go get -u github.com/go-sql-driver/mysql as prompted by the repo, I encountered an error saying "access is denied":

go: writing stat cache: mkdir C:\Program Files\GoPath\pkg: Access is denied.
go: downloading github.com/go-sql-driver/mysql v1.5.0
go get github.com/go-sql-driver/mysql: mkdir C:\Program Files\GoPath\pkg: Access is denied.

I am using Windows 10. This happened when I changed the %GOPATH% environment variable. Any suggestions on solving this?


It seems like Go doesn't have the right to access the "Program Files" folder. I created a GoPath folder at another place and go get seemed to work. However, it created a folder named "pkg" in "GoPath", but from the compilation file I am having, it looks like the package should be installed under an "src" folder. Could somebody please explain how this happened?

E_net4
  • 27,810
  • 13
  • 101
  • 139
Jim Yang
  • 177
  • 2
  • 10
  • I had a similar problem on Mac and the solution was to export these variables `GO111MODULE=on` `GOPROXY=direct` `GOSUMDB=off`. This solved my problem, but you may still have other problems. In which case check through this one https://stackoverflow.com/questions/27500861/whats-the-proper-way-to-go-get-a-private-repository – Prav Mar 30 '21 at 13:21

2 Answers2

3
mkdir C:\Program Files\GoPath\pkg: Access is denied.

It looks like access denied while trying to create directory. Either change the installation directory or grant access to the path mentioned.

If it is your development machine or laptop, open Command Prompt as administrator and try installation.

Rathish Kumar B
  • 1,271
  • 10
  • 21
0

If you are using a specific IDE run the IDE as administrator.

starball
  • 20,030
  • 7
  • 43
  • 238
Hossein
  • 797
  • 1
  • 8
  • 24