PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, August 19, 2022

[FIXED] When should you set the $GOPATH variable?

 August 19, 2022     environment-variables, go, gopath, gopls, visual-studio-code     No comments   

Issue

Can anyone explain when to set $GOPATH? I know it's in the default, C:\Users\Username\go, location, but what if all my coding projects live in Z:<codelocation> ?


Solution

From the documentation:

The Go path is used to resolve import statements.

The GOPATH environment variable lists places to look for Go code.

When using modules, GOPATH is no longer used for resolving imports. However, it is still used to store downloaded source code (in GOPATH/pkg/mod) and compiled commands (in GOPATH/bin).

Assuming you're using modules, which you probably should be, the setting of GOPATH will not impact your projects regardless of where you put them. It only needs to be set somewhere so the Go tools have a cache to store libraries and binaries.



Answered By - Hymns For Disco
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,205,408

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing