共用庫
Go to file
daniel.w c6441ef0bc feat: update errors package 2024-08-08 00:44:12 +08:00
errors feat: update errors package 2024-08-08 00:44:12 +08:00
.gitignore feat: move folder 2024-08-08 00:01:58 +08:00
go.work feat: update errors package 2024-08-08 00:44:12 +08:00
readme.md feat: move folder 2024-08-08 00:01:58 +08:00

readme.md

golang-common

Current modules

module latest version
error v1.0.0

如何新增Module

假設新增一個module叫 monitoring/grafana

  • init
mkdir -p monitoring/grafana
cd ./monitoring/grafana
go mod init yt.com/backend/common.git/monitoring/grafana
go work use ./monitoring/grafana
  • befor commit

建議測試覆蓋率盡量達到80%

before-commit-check
  • commit
git add ./monitoring/grafana
git commit -m "feat: add monitoring/grafana module"
git tag "monitoring/grafana/v1.0.0"
git push origin monitoring/grafana/v1.0.0
  • launch merge request and codereview

如何使用私有Module

強制git使用ssh方式而不是https:

git config --global --add url."git@code.30cm.net:".insteadOf "https://code.30cm.net/"

# 檢查語法
vim ~/.gitconfig

設定go env

export GOPRIVATE="code.30cm.net"

產生ssh-key 請參考 github ssh , gitlab ssh

add ssh key to the ssh-agent 請參考 Adding your SSH key to the ssh-agent

$ eval "$(ssh-agent -s)"
> Agent pid 59566
$ touch ~/.ssh/config
Host code.30cm.net
  Hostname code.30cm.net
  User Daniel.W
  IdentityFile ~/.ssh/id_rsa
$ ssh-add --apple-use-keychain ~/.ssh/id_ed25519

使用 yt.com domain git clone repo

git clone git@code.30cm.net:backend/layout-template.git

在自己repo底下執行:

go clean -modcache
go mod tidy

or
go get -x yt.com/backend/common.git/transport/http/health@1.0.0