From 58ad6c82527e2232e541be29f1a23eea85765bb7 Mon Sep 17 00:00:00 2001 From: yangyile Date: Fri, 20 Dec 2024 11:31:39 +0700 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Equal=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E9=85=8D=E5=90=88Equals=E5=92=8CSame=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 6 ++++-- must.go | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7af6886..b66f75d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -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 diff --git a/must.go b/must.go index 4c38046..8bfaa2e 100644 --- a/must.go +++ b/must.go @@ -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) {