Skip to content

Commit 6405cb1

Browse files
author
shijiashuai
committed
多语言和多版本的htop的实现
0 parents  commit 6405cb1

32 files changed

+3857
-0
lines changed

.editorconfig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
indent_size = 4
10+
11+
[*.rs]
12+
indent_size = 4
13+
14+
[*.go]
15+
indent_style = tab
16+
indent_size = 4
17+
18+
[*.md]
19+
trim_trailing_whitespace = false
20+
21+
[*.bat]
22+
end_of_line = crlf
23+
24+
[*.ps1]
25+
end_of_line = crlf

.gitattributes

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
* text=auto
2+
3+
# Source line endings
4+
*.rs text eol=lf
5+
*.go text eol=lf
6+
*.sh text eol=lf
7+
*.md text eol=lf
8+
*.yml text eol=lf
9+
*.yaml text eol=lf
10+
*.toml text eol=lf
11+
12+
# Windows scripts
13+
*.bat text eol=crlf
14+
*.cmd text eol=crlf
15+
*.ps1 text eol=crlf
16+
17+
# Binary files
18+
*.png binary
19+
*.jpg binary
20+
*.jpeg binary
21+
*.gif binary
22+
*.ico binary
23+
*.pdf binary
24+
*.zip binary
25+
*.tar.gz binary
26+
*.rar binary
27+
*.7z binary
28+
*.exe binary
29+
*.dll binary
30+
*.pdb binary

.github/workflows/ci.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
rust:
9+
name: Rust (${{ matrix.name }})
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
include:
15+
- name: unix-rust
16+
os: ubuntu-latest
17+
workdir: unix/rust
18+
- name: win-rust
19+
os: windows-latest
20+
workdir: win/rust
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Rust
26+
uses: dtolnay/rust-toolchain@stable
27+
with:
28+
components: rustfmt, clippy
29+
30+
- name: Cache cargo
31+
uses: actions/cache@v4
32+
with:
33+
path: |
34+
~/.cargo/registry
35+
~/.cargo/git
36+
${{ matrix.workdir }}/target
37+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
38+
39+
- name: Cargo fmt
40+
working-directory: ${{ matrix.workdir }}
41+
run: cargo fmt --all -- --check
42+
43+
- name: Cargo clippy
44+
working-directory: ${{ matrix.workdir }}
45+
run: cargo clippy --all-targets -- -D warnings
46+
47+
- name: Cargo build
48+
working-directory: ${{ matrix.workdir }}
49+
run: cargo build --release
50+
51+
- name: Cargo test
52+
working-directory: ${{ matrix.workdir }}
53+
run: cargo test --all --all-features
54+
55+
go:
56+
name: Go (win/go)
57+
runs-on: windows-latest
58+
defaults:
59+
run:
60+
working-directory: win/go
61+
steps:
62+
- name: Checkout
63+
uses: actions/checkout@v4
64+
65+
- name: Setup Go
66+
uses: actions/setup-go@v5
67+
with:
68+
go-version: stable
69+
cache: true
70+
cache-dependency-path: win/go/go.sum
71+
72+
- name: gofmt check
73+
shell: pwsh
74+
run: |
75+
$changed = gofmt -l .
76+
if ($changed) {
77+
Write-Host "Go files not formatted:"
78+
$changed
79+
exit 1
80+
}
81+
82+
- name: go vet
83+
run: go vet ./...
84+
85+
- name: go build
86+
run: go build ./...
87+
88+
- name: go test
89+
run: go test ./...

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# OS
2+
.DS_Store
3+
Thumbs.db
4+
Desktop.ini
5+
6+
# IDE
7+
.vscode/
8+
.idea/
9+
*.iml
10+
11+
# Env
12+
.env
13+
.env.*
14+
!.env.example
15+
16+
# Logs
17+
*.log
18+
19+
# Rust
20+
/target/
21+
**/target/
22+
# Keep Cargo.lock versioned for binaries
23+
24+
# Go
25+
/bin/
26+
/build/
27+
/dist/
28+
coverage.out
29+
30+
# Windows build artifacts
31+
*.exe
32+
*.dll
33+
*.pdb
34+
*.lib
35+
*.obj

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# htop (Windows/Unix)
2+
3+
跨平台 htop 学习/演示项目,包含 `unix/rust/``win/rust/``win/go/` 子模块。
4+
5+
## 特性
6+
- 轻量、可学习
7+
- Windows 与 Unix 双平台示例
8+
- Rust 与 Go 实现对比
9+
10+
## 目录结构
11+
```
12+
htop/
13+
unix/
14+
rust/
15+
win/
16+
rust/
17+
go/
18+
changelog/
19+
```
20+
21+
## 构建与运行
22+
- Rust(Unix 或 Windows)
23+
```bash
24+
# 在对应子目录执行
25+
cargo build --release
26+
cargo run
27+
```
28+
- Go(Windows 示例)
29+
```bash
30+
# 在 win/go 目录执行
31+
go build ./...
32+
```
33+
34+
## 贡献
35+
- 提交前请运行格式化与基本检查
36+
```bash
37+
cargo fmt && cargo clippy
38+
#
39+
gofmt -w . && go vet ./...
40+
```
41+
- 提交 PR 前附上动机与变更简述
42+
43+
## 许可
44+
- 待选择(建议 MIT/Apache-2.0)。请在根目录添加 `LICENSE` 文件。
45+
46+
## 变更日志
47+
-`changelog/CHANGELOG.md`

changelog/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
3+
所有重要变更都会记录在此文件中。
4+
5+
## 2025-10-20
6+
- 规范化仓库结构。
7+
- 新增根级 `.gitignore``.gitattributes``.editorconfig`
8+
- 新增根级 `README.md`
9+
- 创建根级 `changelog/` 并添加本文件。
10+
- 说明:未新增 LICENSE,等待选择。
11+
- 新增 GitHub Actions 多语言 CI(Rust:`unix/rust``win/rust`;Go:`win/go`),包含 fmt、lint、build、test。

unix/rust/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Rust
2+
/target/
3+
**/*.rs.bk
4+
5+
# Editors
6+
.vscode/
7+
.idea/
8+
9+
# OS
10+
.DS_Store
11+
Thumbs.db
12+
13+
# Logs
14+
*.log

0 commit comments

Comments
 (0)