Jim Yang
Jim Yang

Reputation: 307

Access denied when using go get

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?

Upvotes: 1

Views: 9946

Answers (3)

sukant kalpande
sukant kalpande

Reputation: 1

On windows, even after elevating user rights (Run as admin) you are getting same error you shoud check file/dir properties and make sure file is not read only.

1 RClick on file/dir -> properties 2 Uncheck Read only checkbox -> apply

One should perform this check even before elevating the user rights as you may not even require to do "Run as admin".

Upvotes: -1

Hossein
Hossein

Reputation: 867

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

Upvotes: 0

Rathish Kumar B
Rathish Kumar B

Reputation: 1422

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.

Upvotes: 3

Related Questions