From 8cf8ec078ae92620c511170df2808ea6235d93c2 Mon Sep 17 00:00:00 2001 From: hau Date: Wed, 14 Oct 2020 14:32:31 +0700 Subject: [PATCH] go modules --- Development/Go/Modules.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Development/Go/Modules.md b/Development/Go/Modules.md index 7acc153..7879ec6 100644 --- a/Development/Go/Modules.md +++ b/Development/Go/Modules.md @@ -12,8 +12,8 @@ Daily workflow: # Update modules go get -u ./... -# Install module with chosen commit or branch -go get public.git.com/module@branch +# Install module with chosen commit or version +go get public.git.com/module@version # Prune no longer used modules go mod tidy @@ -28,10 +28,22 @@ Outside modules: GOMODULE11=on go get example.com/foo/bar ``` -Update go version in `go.mod`: +Update go version: ```sh -go mod edit -go-1.xy +go mod edit -go=1.XY +``` + +Replace module path and version pair: + +```sh +go mod edit -replace old[@v]=new[@v] +``` + +Drop replace module path: + +```sh +go mod edit -dropreplace old[@v] ``` In world of corporation, we work with private repository, add to `~/.bashrc`, `~/.zshrc`: