Create Modules.md
parent
32dc1ce6f7
commit
b6ddf37d2f
|
@ -0,0 +1,37 @@
|
||||||
|
# [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
|
||||||
|
```
|
||||||
|
|
||||||
|
In world of corporation, we work with private repository, add to `~/.bashrc`, `~/.zshrc`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
export GOPRIVATE=private.git.com
|
||||||
|
```
|
||||||
|
|
||||||
|
Last hope, use `~/.netrc`:
|
||||||
|
|
||||||
|
```txt
|
||||||
|
machine private.git.com
|
||||||
|
login your_user
|
||||||
|
password your_password
|
||||||
|
```
|
Loading…
Reference in New Issue