Skip to content

Commit

Permalink
feat: go env, go mod refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
fadyat committed Mar 25, 2024
1 parent ecae988 commit e0688df
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions dump/golang/modules/README.md
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
```

0 comments on commit e0688df

Please sign in to comment.