From 8825514fb226fc4de119e712abdc7396fa9594f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Wed, 1 Oct 2025 00:16:07 +0800 Subject: [PATCH] fix: make lint&ci happy --- .github/workflows/nightly.yml | 1 - .github/workflows/pull.yml | 1 - .github/workflows/push.yml | 1 - .goreleaser.yml | 1 - abineundo/ref/main.go | 51 +++++++++++++++++++++++++++++++++++ custom/doc.go | 2 -- kanban/init.go | 2 +- main.go | 2 +- winres/init.go | 2 +- 9 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 abineundo/ref/main.go diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 65553d5d..0cdaad29 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -45,7 +45,6 @@ jobs: GOARCH: ${{ matrix.goarch }} IS_PR: ${{ !!github.head_ref }} run: | - if [ ! -f custom/register.go ]; then touch custom/register.go; fi go generate ./... if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi if $IS_PR ; then echo $PR_PROMPT; fi diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index 3ab04693..745ad103 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -36,7 +36,6 @@ jobs: - name: Tidy Modules run: | go mod tidy - if [ ! -f custom/register.go ]; then touch custom/register.go; fi go generate ./... - name: golangci-lint diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index f5e9f7f6..53a2db25 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -16,7 +16,6 @@ jobs: - name: Tidy Modules run: | go mod tidy - if [ ! -f custom/register.go ]; then touch custom/register.go; fi go generate ./... - name: Run Lint diff --git a/.goreleaser.yml b/.goreleaser.yml index 039208fe..3c3fac40 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -4,7 +4,6 @@ env: before: hooks: - go mod tidy - - if [ ! -f custom/register.go ]; then touch custom/register.go; fi - go generate ./... - go install github.com/tc-hib/go-winres@latest - go-winres make diff --git a/abineundo/ref/main.go b/abineundo/ref/main.go new file mode 100644 index 00000000..250d2b44 --- /dev/null +++ b/abineundo/ref/main.go @@ -0,0 +1,51 @@ +package main + +import ( + "flag" + "io" + "os" + "path" +) + +func main() { + root := flag.String("r", "", "project root dir") + flag.Parse() + + fi, err := os.Open(path.Join(*root, "main.go")) + if err != nil { + panic(err) + } + fo, err := os.Create(path.Join(*root, "abineundo/ref/main/main.go")) + if err != nil { + panic(err) + } + _, err = io.Copy(fo, fi) + if err != nil { + panic(err) + } + fi.Close() + fo.Close() + + regf := path.Join(*root, "custom/register.go") + if _, err := os.Stat(regf); err != nil { + if os.IsNotExist(err) { + return + } + panic(err) + } + + fi, err = os.Open(regf) + if err != nil { + panic(err) + } + fo, err = os.Create(path.Join(*root, "abineundo/ref/custom/register.go")) + if err != nil { + panic(err) + } + _, err = io.Copy(fo, fi) + if err != nil { + panic(err) + } + fi.Close() + fo.Close() +} diff --git a/custom/doc.go b/custom/doc.go index 6468da31..4eaacf6d 100644 --- a/custom/doc.go +++ b/custom/doc.go @@ -1,4 +1,2 @@ // Package custom 注册用户自定义插件于此 package custom - -//go:generate cp register.go ../abineundo/ref/custom diff --git a/kanban/init.go b/kanban/init.go index 5ff823c7..e9072607 100644 --- a/kanban/init.go +++ b/kanban/init.go @@ -10,7 +10,7 @@ import ( "github.com/FloatTech/ZeroBot-Plugin/kanban/banner" ) -//go:generate go run github.com/FloatTech/ZeroBot-Plugin/kanban/gen +//go:generate env GOOS= GOARCH= go run github.com/FloatTech/ZeroBot-Plugin/kanban/gen func init() { PrintBanner() diff --git a/main.go b/main.go index dba5339f..ce4fb393 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,7 @@ // Package main ZeroBot-Plugin main file package main -//go:generate cp main.go abineundo/ref/main +//go:generate env GOOS= GOARCH= go run github.com/FloatTech/ZeroBot-Plugin/abineundo/ref -r . import ( "encoding/json" diff --git a/winres/init.go b/winres/init.go index 3c7fb2e1..0becfb0b 100644 --- a/winres/init.go +++ b/winres/init.go @@ -1,4 +1,4 @@ // Package winres 生成windows资源 package winres -//go:generate go run github.com/FloatTech/ZeroBot-Plugin/winres/gen +//go:generate env GOOS= GOARCH= go run github.com/FloatTech/ZeroBot-Plugin/winres/gen