Compare commits

..

No commits in common. "main" and "feat/first_try" have entirely different histories.

6 changed files with 44 additions and 28 deletions

View File

@ -58,37 +58,47 @@ 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
1. 在新項目底下加入 .cargo 目錄 並新增 config.toml 檔案
```
my_project/
├── Cargo.toml
├── src/
│ ├── main.rs
│ └── utils/
│ └── first_utils/
│ └── first.rs
└── .cargo/
└── config.toml
```
強制git使用ssh方式而不是https:
2. 使用下列指令執行
```bash
mkdir -p .cargo
echo "[net]\ngit-fetch-with-cli = true" > .cargo/config.toml
git config --global --add url."git@git.30cm.net:".insteadOf "https://gitea.30cm.net/"
```
3. 在 cargo.toml 內加入下列指令,可指定分隻或者 tag 都可
```toml
[dependencies]
utils = { git = "ssh://git@git.30cm.net/Wanderland/library-rusttgeoip.git", branch = "main" }
設定go env
```bash
export GOPRIVATE="gitea.30cm.net"
```
### 如果未產生 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)
@ -106,8 +116,8 @@ $ touch ~/.ssh/config
```
```
Host code.30cm.net
Hostname code.30cm.net
Host yt.com
Hostname gitea.30cm.net
User igs170911
IdentityFile ~/.ssh/id_rsa
```
@ -115,3 +125,9 @@ Host code.30cm.net
```bash
$ ssh-add --apple-use-keychain ~/.ssh/id_ed25519
```
在自己repo底下執行:
```bash
go get gitea.30cm.net/Ark/library-go/config@v1.0.0
```

View File

@ -4,7 +4,7 @@ mod tests {
#[test]
fn test_first() {
let result: String = utils::first_utils::first::public_function();
let result: String = utils::first_utils::first::public_function();
assert!(result.contains("called public func `public_function()`"));
}
}