til/Development/Go/Modules.md

36 lines
524 B
Markdown
Raw Normal View History

2020-08-07 03:16:35 +00:00
# [Modules](https://github.com/golang/go/wiki/Modules)
First time:
2020-08-12 16:04:29 +00:00
```sh
2020-08-07 03:16:35 +00:00
go mod init
```
Daily workflow:
2020-08-12 16:04:29 +00:00
```sh
2020-08-07 03:16:35 +00:00
# Update modules
go get -u ./...
2020-10-14 07:32:31 +00:00
# Install module with chosen commit or version
go get public.git.com/module@version
2020-08-07 03:16:35 +00:00
# Prune no longer used modules
go mod tidy
# Copy modules to local vendor directory
go mod vendor
```
2020-10-14 07:32:31 +00:00
Update go version:
2020-08-12 16:04:29 +00:00
```sh
2020-10-14 07:32:31 +00:00
go mod edit -go=1.XY
```
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
```