Compare commits

..

2 Commits

Author SHA1 Message Date
daniel.w 51da2eed19 feat: cargo fmt 2024-06-16 17:57:35 +08:00
daniel.w 30fbd3dc37 feat: add use common library way readme 2024-06-16 17:53:50 +08:00
6 changed files with 29 additions and 45 deletions

View File

@ -58,47 +58,37 @@ pub mod first;
```
這樣 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%
```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
強制git使用ssh方式而不是https:
```bash
git config --global --add url."git@git.30cm.net:".insteadOf "https://gitea.30cm.net/"
1. 在新項目底下加入 .cargo 目錄 並新增 config.toml 檔案
```
my_project/
├── Cargo.toml
├── src/
│ ├── main.rs
│ └── utils/
│ └── first_utils/
│ └── first.rs
└── .cargo/
└── config.toml
```
設定go env
2. 使用下列指令執行
```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
請參考 [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
Hostname gitea.30cm.net
Host code.30cm.net
Hostname code.30cm.net
User igs170911
IdentityFile ~/.ssh/id_rsa
```
@ -125,9 +115,3 @@ Host yt.com
```bash
$ ssh-add --apple-use-keychain ~/.ssh/id_ed25519
```
在自己repo底下執行:
```bash
go get gitea.30cm.net/Ark/library-go/config@v1.0.0
```