From defc8ea7c8409caca699b9e36114ddbc34b6f23e Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Wed, 24 Aug 2022 11:29:14 +0700 Subject: [PATCH] chore: better go modules --- Development/Go/Modules.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Development/Go/Modules.md b/Development/Go/Modules.md index af95a14..f3bd4b5 100644 --- a/Development/Go/Modules.md +++ b/Development/Go/Modules.md @@ -10,16 +10,22 @@ Daily workflow: ```sh # Update modules -go get -u ./... +go get -d -u ./... -# Install module with chosen commit or version -go get public.git.com/module@version +# Add module with chosen commit or version +go get -d public.git.com/path/to/module@version + +# Build and intall binary with latest version +go install public.git.com/path/to/module@latest # Prune no longer used modules go mod tidy -# Copy modules to local vendor directory +# Copy modules to local vendor directory (vendor is not recommend anymore) go mod vendor + +# Why use module +go mod why -m public.git.com/path/to/module ``` Update go version: @@ -33,3 +39,7 @@ In world of corporation, we work with private repository, add to `~/.bashrc`, `~ ```sh export GOPRIVATE=private.git.com ``` + +## Thanks + +- https://encore.dev/guide/go.mod