til/Development/Go/Modules.md

36 lines
534 B
Markdown
Raw Normal View History

2020-08-07 03:16:35 +00:00
# [Modules](https://github.com/golang/go/wiki/Modules)
First time:
```
go mod init
```
Daily workflow:
```
# Update modules
go get -u ./...
# Install module with chosen commit or branch
go get public.git.com/module@branch
# Prune no longer used modules
go mod tidy
# Copy modules to local vendor directory
go mod vendor
```
2020-08-12 03:39:49 +00:00
Outside modules:
```
GOMODULE11=on go get example.com/foo/bar
```
2020-08-07 03:16:35 +00:00
In world of corporation, we work with private repository, add to `~/.bashrc`, `~/.zshrc`:
```sh
export GOPRIVATE=private.git.com
```