diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml index 336aae46..4caec728 100644 --- a/.github/workflows/golangci-lint.yaml +++ b/.github/workflows/golangci-lint.yaml @@ -9,4 +9,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v2.3.0 with: - version: v1.28.3 + version: v1.44.0 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b513bab1..73b95d00 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,4 +23,5 @@ jobs: - name: Download modules run: go mod tidy -v - name: Run tests - run: go test -race ./... + run: go test -race $(go list -e ./... | grep -v v4/imgui | grep -v v4/wrapper) + diff --git a/.golangci.yml b/.golangci.yml index 48071598..2a39c6c8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,8 @@ run: deadline: 5m + skip-dirs: + - imgui + - wrapper linters: enable-all: true @@ -11,6 +14,14 @@ linters: - goimports # disabled because of so many false-positives with "imgui-go" - gofumpt # disabled because no extra need - wsl # this one has become too pedantic + - ifshort # was not available in v.1.28.3 and will be skipped for now + - exhaustivestruct # was not available in v.1.28.3 and will be skipped for now + - nlreturn # was not available in v.1.28.3 and will be skipped for now + - paralleltest # was not available in v.1.28.3 and will be skipped for now + - varnamelen # was not available in v.1.28.3 and will be skipped for now + - gci # was not available in v.1.28.3 and will be skipped for now + - forcetypeassert # was not available in v.1.28.3 and will be skipped for now + - gomnd # was not available in v.1.28.3 and will be skipped for now issues: exclude-use-default: false # disable filtering of defaults for better zero-issue policy @@ -26,3 +37,5 @@ linters-settings: gocritic: disabled-checks: - dupSubExpr + - commentFormatting + - deprecatedComment diff --git a/imgui/govendorkeep.go b/imgui/govendorkeep.go new file mode 100644 index 00000000..e27122df --- /dev/null +++ b/imgui/govendorkeep.go @@ -0,0 +1 @@ +package cgoimgui diff --git a/imgui/misc/freetype/govendorkeep.go b/imgui/misc/freetype/govendorkeep.go new file mode 100644 index 00000000..e16489f2 --- /dev/null +++ b/imgui/misc/freetype/govendorkeep.go @@ -0,0 +1 @@ +package cgofreetype diff --git a/update_imgui.sh b/update_imgui.sh index e459533e..2e340917 100755 --- a/update_imgui.sh +++ b/update_imgui.sh @@ -25,10 +25,12 @@ rm -rf $DEST/* echo "Copying files" # Copy core files cp $TMP_IMGUI/*.{h,cpp} $DEST/ +echo "package cgo${DEST}" > $DEST/govendorkeep.go # Copy freetype mkdir -p $DEST/misc/freetype cp $TMP_IMGUI/misc/freetype/*.{h,cpp} $DEST/misc/freetype +echo "package cgofreetype" > $DEST/misc/freetype/govendorkeep.go # Copy license cp $TMP_IMGUI/LICENSE.txt _licenses/imgui-LICENSE.txt diff --git a/wrapper/govendorkeep.go b/wrapper/govendorkeep.go new file mode 100644 index 00000000..f564e648 --- /dev/null +++ b/wrapper/govendorkeep.go @@ -0,0 +1 @@ +package cgowrapper diff --git a/wrapper_cgo_hack.go b/wrapper_cgo_hack.go new file mode 100644 index 00000000..0ea022f4 --- /dev/null +++ b/wrapper_cgo_hack.go @@ -0,0 +1,20 @@ +// +build required + +package imgui + +// This file exists purely to prevent the golang toolchain from stripping +// away the c source directories and files when `go mod vendor` is used +// to populate a `vendor/` directory of a project depending on `imgui-go`. +// https://github.com/golang/go/issues/26366 +// +// How it works: +// - every directory which only includes c source files receives a govendorkeep.go file. +// - every directory we want to preserve is included here as a _ import. +// - this file is given a build to exclude it from the regular build. + +import ( + // Prevent go tooling from stripping out the c source files. + _ "github.com/inkyblackness/imgui-go/v4/imgui" + _ "github.com/inkyblackness/imgui-go/v4/wrapper" + _ "github.com/inkyblackness/imgui-go/v4/imgui/misc/freetype" +)