-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
## GOROOT | ||
|
||
`GOROOT` defines the root directory of the Go SDK and go tools installation. | ||
It is set during the Go installation process. | ||
|
||
Typically, it remains immutable and should not be modified, | ||
except when you intend to use a different version of Go. | ||
|
||
## GOPATH | ||
|
||
`GOPATH` is an environment variable that specifies the location of your Go workspace. | ||
It consists of a colon-separated list of directories where Go searches for source code. | ||
|
||
`GOPATH` was traditionally used for managing dependencies in Go before the introduction of Go Modules. | ||
With Go Modules, setting `GOPATH` is no longer necessary. | ||
|
||
After Go 1.11, `$GOPATH/pkg/mod` is utilized to store all project dependencies, | ||
and `$GOPATH/bin` is used to store binaries generated by `go install`. | ||
|
||
## Go Modules | ||
|
||
Go Modules provide a mechanism for managing dependencies in Go outside the `$GOPATH`. | ||
They enable developers to define, version, and install dependencies more effectively, | ||
reducing reliance on `GOPATH` for dependency management. | ||
|
||
```bash | ||
go mod init github.com/fadyat/<project-name> | ||
|
||
# current dependency will be allowed to be used in the project | ||
# and we can find it in go.mod, go.sum and $GOPATH/pkg/mod directory | ||
go get github.com/gorilla/mux | ||
|
||
# installing the binary in $GOPATH/bin directory, but it's | ||
# better to use some prebuilt binaries from the internet | ||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.1 | ||
``` | ||
|