feat: add use common library way readme

This commit is contained in:
daniel.w 2024-06-16 17:53:50 +08:00
parent a756bd57bf
commit 30fbd3dc37
1 changed files with 23 additions and 39 deletions

View File

@ -58,47 +58,37 @@ pub mod first;
``` ```
這樣 first 裡面的 pub 函數就會被公開了 這樣 first 裡面的 pub 函數就會被公開了
```bash
mkdir -p config
cd ./config
go mod init gitea.30cm.net/Ark/library-go/config
go work use ./config
```
p.s 建議測試覆蓋率盡量達到80% p.s 建議測試覆蓋率盡量達到80%
```bash
before-commit-check
```
2. commit
```bash
git add ./config
git commit -m "feat: add config module"
git tag "config/v1.0.0"
git push origin config/v1.0.0
```
3. Merge request and Code
Review
------------------ ------------------
## 如何使用私有Module ## 如何使用私有Module
強制git使用ssh方式而不是https: 1. 在新項目底下加入 .cargo 目錄 並新增 config.toml 檔案
```
```bash my_project/
git config --global --add url."git@git.30cm.net:".insteadOf "https://gitea.30cm.net/" ├── Cargo.toml
├── src/
│ ├── main.rs
│ └── utils/
│ └── first_utils/
│ └── first.rs
└── .cargo/
└── config.toml
``` ```
設定go env 2. 使用下列指令執行
```bash ```bash
export GOPRIVATE="gitea.30cm.net" mkdir -p .cargo
echo "[net]\ngit-fetch-with-cli = true" > .cargo/config.toml
``` ```
3. 在 cargo.toml 內加入下列指令,可指定分隻或者 tag 都可
```toml
[dependencies]
utils = { git = "ssh://git@git.30cm.net/Wanderland/library-rusttgeoip.git", branch = "main" }
```
### 如果未產生 ssh key 連線至你的 git 的話請使用下列方式
產生ssh-key 產生ssh-key
請參考 [github ssh](https://docs.github.com/en/authentication/connecting-to-github-with-ssh) , [gitlab ssh](https://docs.gitlab.com/ee/user/ssh.html) 請參考 [github ssh](https://docs.github.com/en/authentication/connecting-to-github-with-ssh) , [gitlab ssh](https://docs.gitlab.com/ee/user/ssh.html)
@ -116,8 +106,8 @@ $ touch ~/.ssh/config
``` ```
``` ```
Host yt.com Host code.30cm.net
Hostname gitea.30cm.net Hostname code.30cm.net
User igs170911 User igs170911
IdentityFile ~/.ssh/id_rsa IdentityFile ~/.ssh/id_rsa
``` ```
@ -125,9 +115,3 @@ Host yt.com
```bash ```bash
$ ssh-add --apple-use-keychain ~/.ssh/id_ed25519 $ ssh-add --apple-use-keychain ~/.ssh/id_ed25519
``` ```
在自己repo底下執行:
```bash
go get gitea.30cm.net/Ark/library-go/config@v1.0.0
```