Skip to content

Commit

Permalink
添加Equal函数配合Equals和Same函数
Browse files Browse the repository at this point in the history
  • Loading branch information
yangyile committed Dec 20, 2024
1 parent 0b68b88 commit 58ad6c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
path-to-profile: /tmp/coverage/combined.txt
flag-name: Go-${{ matrix.go }}
parallel: true
if: ${{ github.event.repository.fork == false }} # 仅在非 fork 时上传覆盖率

check-coverage:
name: Check coverage
Expand All @@ -51,14 +52,15 @@ jobs:
- uses: shogo82148/actions-goveralls@v1
with:
parallel-finished: true
if: ${{ github.event.repository.fork == false }} # 仅在非 fork 时检查覆盖率

# 发布 Release
release:
name: Release a new version
needs: [ lint, test ]
runs-on: ubuntu-latest
# 仅在推送标签时执行
if: ${{ success() && startsWith(github.ref, 'refs/tags/v') }}
# 仅在推送标签时执行 - && - 仅在非 fork 时执行发布
if: ${{ github.event.repository.fork == false && success() && startsWith(github.ref, 'refs/tags/v') }}
steps:
# 1. 检出代码
- name: Checkout code
Expand Down
8 changes: 8 additions & 0 deletions must.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ func Full[V *any](v any) {
}
}

// Equal expects the values to be equal. Panics if they are not equal.
// Equal 期望值相等。如果值不相等,则触发 panic。
func Equal[V comparable](a, b V) {
if a != b {
zaplog.ZAPS.P1.LOG.Panic("A AND B ARE NOT EQUAL", zap.Any("a", a), zap.Any("b", b))
}
}

// Equals expects the values to be equal. Panics if they are not equal.
// Equals 期望值相等。如果值不相等,则触发 panic。
func Equals[V comparable](a, b V) {
Expand Down

0 comments on commit 58ad6c8

Please sign in to comment.