diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e08085ae..db2be695b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -73,10 +73,11 @@ jobs: run: | go vet -tags=example -v ./... - - name: go vet (atomic align) + - name: go vet (atomic align, error check) + if: ${{ !startsWith(matrix.os, 'windows-') }} # TODO: Fix go vet errors on Windows. (#1306) run: | - go install .github/workflows/vettools/atomicalign.go - go vet -vettool=$(which atomicalign)${{ startsWith(matrix.os, 'windows-') && '.exe' || '' }} -tags=example -v ./... + go install .github/workflows/vettools/vettools.go + go vet -vettool=$(which vettools)${{ startsWith(matrix.os, 'windows-') && '.exe' || '' }} -tags=example -v ./... - name: go build run: | diff --git a/.github/workflows/vettools/atomicalign.go b/.github/workflows/vettools/vettools.go similarity index 66% rename from .github/workflows/vettools/atomicalign.go rename to .github/workflows/vettools/vettools.go index 66fc91297..7d39c507a 100644 --- a/.github/workflows/vettools/atomicalign.go +++ b/.github/workflows/vettools/vettools.go @@ -18,10 +18,28 @@ package main import ( + "os" + "runtime" + + "github.com/kisielk/errcheck/errcheck" "golang.org/x/tools/go/analysis/multichecker" "golang.org/x/tools/go/analysis/passes/atomicalign" ) func main() { - multichecker.Main(atomicalign.Analyzer) + GOOS, ok := os.LookupEnv("GOOS") + if !ok { + GOOS = runtime.GOOS + } + + for _, filename := range []string{ + ".errcheck_excludes", + ".errcheck_excludes_" + GOOS, + } { + if _, err := os.Stat(filename); err == nil { + errcheck.Analyzer.Flags.Set("exclude", filename) + } + } + + multichecker.Main(atomicalign.Analyzer, errcheck.Analyzer) } diff --git a/audio/audio.go b/audio/audio.go index d61602ebd..468148f70 100644 --- a/audio/audio.go +++ b/audio/audio.go @@ -339,7 +339,7 @@ func NewPlayerFromBytes(context *Context, src []byte) *Player { func (p *Player) finalize() { runtime.SetFinalizer(p, nil) if !p.IsPlaying() { - p.Close() + _ = p.Close() } } diff --git a/cmd/ebitenmobile/gomobile.go b/cmd/ebitenmobile/gomobile.go index 55fd05c59..671b33552 100644 --- a/cmd/ebitenmobile/gomobile.go +++ b/cmd/ebitenmobile/gomobile.go @@ -111,7 +111,7 @@ func prepareGomobileCommands() (string, error) { return tmp, err } defer func() { - os.Chdir(pwd) + _ = os.Chdir(pwd) }() const ( diff --git a/cmd/ebitenmobile/main.go b/cmd/ebitenmobile/main.go index 08ba0b424..2fbf25370 100644 --- a/cmd/ebitenmobile/main.go +++ b/cmd/ebitenmobile/main.go @@ -117,7 +117,7 @@ func main() { flagset.StringVar(&bindClasspath, "classpath", "", "") flagset.StringVar(&bindBootClasspath, "bootclasspath", "", "") - flagset.Parse(args[1:]) + _ = flagset.Parse(args[1:]) buildTarget, err := osFromBuildTarget(buildTarget) if err != nil { @@ -136,7 +136,7 @@ func main() { dir, err := prepareGomobileCommands() defer func() { if dir != "" && !buildWork { - removeAll(dir) + _ = removeAll(dir) } }() if err != nil { @@ -225,7 +225,9 @@ func doBind(args []string, flagset *flag.FlagSet, buildOS string) error { if err != nil { return err } - defer f.Close() + defer func() { + _ = f.Close() + }() names, err := f.Readdirnames(-1) if err != nil { @@ -265,7 +267,9 @@ func doBind(args []string, flagset *flag.FlagSet, buildOS string) error { if err != nil { return err } - defer w.Close() + defer func() { + _ = w.Close() + }() var mmVals = struct { Module string Headers []string diff --git a/ebitenutil/fs_go116.go b/ebitenutil/fs_go116.go index 95782f34a..08777b53c 100644 --- a/ebitenutil/fs_go116.go +++ b/ebitenutil/fs_go116.go @@ -33,7 +33,9 @@ func NewImageFromFileSystem(fs fs.FS, path string) (*ebiten.Image, image.Image, if err != nil { return nil, nil, err } - defer file.Close() + defer func() { + _ = file.Close() + }() img, _, err := image.Decode(file) if err != nil { return nil, nil, err diff --git a/ebitenutil/loadimage.go b/ebitenutil/loadimage.go index 744392923..342837146 100644 --- a/ebitenutil/loadimage.go +++ b/ebitenutil/loadimage.go @@ -44,7 +44,9 @@ func NewImageFromURL(url string) (*ebiten.Image, error) { if err != nil { return nil, err } - defer res.Body.Close() + defer func() { + _ = res.Body.Close() + }() img, _, err := image.Decode(res.Body) if err != nil { diff --git a/examples/flappy/main.go b/examples/flappy/main.go index c83d8c9ed..ace311b24 100644 --- a/examples/flappy/main.go +++ b/examples/flappy/main.go @@ -246,7 +246,9 @@ func (g *Game) Update() error { g.cameraX += 2 if g.isKeyJustPressed() { g.vy16 = -96 - g.jumpPlayer.Rewind() + if err := g.jumpPlayer.Rewind(); err != nil { + return err + } g.jumpPlayer.Play() } g.y16 += g.vy16 @@ -258,7 +260,9 @@ func (g *Game) Update() error { } if g.hit() { - g.hitPlayer.Rewind() + if err := g.hitPlayer.Rewind(); err != nil { + return err + } g.hitPlayer.Play() g.mode = ModeGameOver g.gameoverCount = 30 diff --git a/examples/wav/main.go b/examples/wav/main.go index 3c8c87b54..f0b9e07df 100644 --- a/examples/wav/main.go +++ b/examples/wav/main.go @@ -80,7 +80,10 @@ func (g *Game) Update() error { if inpututil.IsKeyJustPressed(ebiten.KeyP) { // As audioPlayer has one stream and remembers the playing position, // rewinding is needed before playing when reusing audioPlayer. - g.audioPlayer.Rewind() + if err := g.audioPlayer.Rewind(); err != nil { + return err + } + g.audioPlayer.Play() } return nil diff --git a/go.mod b/go.mod index f73244db2..98fe32401 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/jakecoffman/cp v1.2.1 github.com/jezek/xgb v1.0.1 github.com/jfreymuth/oggvorbis v1.0.4 + github.com/kisielk/errcheck v1.6.2 // indirect golang.org/x/image v0.0.0-20220722155232-062f8c9fd539 golang.org/x/mobile v0.0.0-20220722155234-aaac322e2105 golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 diff --git a/go.sum b/go.sum index 4bad99f97..72211a6fe 100644 --- a/go.sum +++ b/go.sum @@ -19,8 +19,11 @@ github.com/jfreymuth/oggvorbis v1.0.4 h1:cyJCd0XSoxkKzUPmqM0ZoQJ0h/WbhfyvUR+FTMx github.com/jfreymuth/oggvorbis v1.0.4/go.mod h1:1U4pqWmghcoVsCJJ4fRBKv9peUJMBHixthRlBeD6uII= github.com/jfreymuth/vorbis v1.0.2 h1:m1xH6+ZI4thH927pgKD8JOH4eaGRm18rEE9/0WKjvNE= github.com/jfreymuth/vorbis v1.0.2/go.mod h1:DoftRo4AznKnShRl1GxiTFCseHr4zR9BN3TWXyuzrqQ= +github.com/kisielk/errcheck v1.6.2 h1:uGQ9xI8/pgc9iOoCe7kWQgRE6SBTrCGmTSf0LrEtY7c= +github.com/kisielk/errcheck v1.6.2/go.mod h1:nXw/i/MfnvRHqXa7XXmQMUB0oNFGuBrNI8d8NLy0LPw= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -39,6 +42,7 @@ golang.org/x/mobile v0.0.0-20220722155234-aaac322e2105 h1:3vUV5x5+3LfQbgk7paCM6I golang.org/x/mobile v0.0.0-20220722155234-aaac322e2105/go.mod h1:pe2sM7Uk+2Su1y7u/6Z8KJ24D7lepUjFZbhFOrmDfuQ= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -46,6 +50,7 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -59,6 +64,7 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -75,6 +81,7 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.8-0.20211022200916-316ba0b74098/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/gamepad/.errcheck_excludes_windows b/internal/gamepad/.errcheck_excludes_windows new file mode 100644 index 000000000..2df895c61 --- /dev/null +++ b/internal/gamepad/.errcheck_excludes_windows @@ -0,0 +1 @@ +syscall.Syscall diff --git a/internal/gamepad/gamepad_desktop_windows.go b/internal/gamepad/gamepad_desktop_windows.go index ea4dcf00c..ac01fcda9 100644 --- a/internal/gamepad/gamepad_desktop_windows.go +++ b/internal/gamepad/gamepad_desktop_windows.go @@ -612,7 +612,7 @@ func (g *nativeGamepadDesktop) update(gamepads *gamepads) (err error) { return err } // Acquire can return an error just after a gamepad is disconnected. Ignore the error. - g.dinputDevice.Acquire() + _ = g.dinputDevice.Acquire() if err := g.dinputDevice.Poll(); err != nil { if !errors.Is(err, directInputError(_DIERR_NOTACQUIRED)) && !errors.Is(err, directInputError(_DIERR_INPUTLOST)) { return err diff --git a/internal/gamepad/gamepad_linux.go b/internal/gamepad/gamepad_linux.go index ecbbc27c8..3e3941dc6 100644 --- a/internal/gamepad/gamepad_linux.go +++ b/internal/gamepad/gamepad_linux.go @@ -120,7 +120,7 @@ func (*nativeGamepadsImpl) openGamepad(gamepads *gamepads, path string) (err err } defer func() { if err != nil { - unix.Close(fd) + _ = unix.Close(fd) } }() @@ -142,11 +142,17 @@ func (*nativeGamepadsImpl) openGamepad(gamepads *gamepads, path string) (err err } if !isBitSet(evBits, unix.EV_KEY) { - unix.Close(fd) + if err := unix.Close(fd); err != nil { + return err + } + return nil } if !isBitSet(evBits, unix.EV_ABS) { - unix.Close(fd) + if err := unix.Close(fd); err != nil { + return err + } + return nil } @@ -294,7 +300,7 @@ type nativeGamepadImpl struct { func (g *nativeGamepadImpl) close() { if g.fd != 0 { - unix.Close(g.fd) + _ = unix.Close(g.fd) } g.fd = 0 } @@ -337,7 +343,9 @@ func (g *nativeGamepadImpl) update(gamepad *gamepads) error { g.dropped = true case _SYN_REPORT: g.dropped = false - g.pollAbsState() + if err := g.pollAbsState(); err != nil { + return fmt.Errorf("gamepad: poll absolute state: %w", err) + } } } if g.dropped { diff --git a/internal/glfwwin/.errcheck_excludes_windows b/internal/glfwwin/.errcheck_excludes_windows new file mode 100644 index 000000000..fb34c4c7c --- /dev/null +++ b/internal/glfwwin/.errcheck_excludes_windows @@ -0,0 +1,2 @@ +syscall.Syscall +(*golang.org/x/sys/windows.LazyProc).Call diff --git a/internal/glfwwin/context_windows.go b/internal/glfwwin/context_windows.go index 82845de64..0cca2ff47 100644 --- a/internal/glfwwin/context_windows.go +++ b/internal/glfwwin/context_windows.go @@ -444,7 +444,9 @@ func (w *Window) refreshContextAttribs(ctxconfig *ctxconfig) (ferr error) { syscall.Syscall(glClear, 1, GL_COLOR_BUFFER_BIT, 0, 0) if w.doublebuffer { - w.context.swapBuffers(w) + if err := w.context.swapBuffers(w); err != nil { + return err + } } return nil diff --git a/internal/glfwwin/init_windows.go b/internal/glfwwin/init_windows.go index eb0ff6a90..2e0a4c15b 100644 --- a/internal/glfwwin/init_windows.go +++ b/internal/glfwwin/init_windows.go @@ -36,7 +36,7 @@ func terminate() error { func Init() (ferr error) { defer func() { if ferr != nil { - terminate() + _ = terminate() } }() diff --git a/internal/glfwwin/input_windows.go b/internal/glfwwin/input_windows.go index dbcd6d8e9..27aa41ca7 100644 --- a/internal/glfwwin/input_windows.go +++ b/internal/glfwwin/input_windows.go @@ -335,7 +335,7 @@ func CreateCursor(image *Image, xhot, yhot int) (*Cursor, error) { _glfw.cursors = append(_glfw.cursors, cursor) if err := cursor.platformCreateCursor(image, xhot, yhot); err != nil { - cursor.Destroy() + _ = cursor.Destroy() return nil, err } @@ -360,7 +360,7 @@ func CreateStandardCursor(shape StandardCursor) (*Cursor, error) { _glfw.cursors = append(_glfw.cursors, cursor) if err := cursor.platformCreateStandardCursor(shape); err != nil { - cursor.Destroy() + _ = cursor.Destroy() return nil, err } diff --git a/internal/glfwwin/monitor_windows.go b/internal/glfwwin/monitor_windows.go index be57afbf7..d96029d73 100644 --- a/internal/glfwwin/monitor_windows.go +++ b/internal/glfwwin/monitor_windows.go @@ -82,12 +82,16 @@ func inputMonitor(monitor *Monitor, action PeripheralEvent, placement int) error if err != nil { return err } - window.platformSetWindowMonitor(nil, 0, 0, width, height, 0) + if err := window.platformSetWindowMonitor(nil, 0, 0, width, height, 0); err != nil { + return err + } xoff, yoff, _, _, err := window.platformGetWindowFrameSize() if err != nil { return err } - window.platformSetWindowPos(xoff, yoff) + if err := window.platformSetWindowPos(xoff, yoff); err != nil { + return err + } } } for i, m := range _glfw.monitors { diff --git a/internal/glfwwin/wglcontext_windows.go b/internal/glfwwin/wglcontext_windows.go index f5a6bc33e..fdab2b2a7 100644 --- a/internal/glfwwin/wglcontext_windows.go +++ b/internal/glfwwin/wglcontext_windows.go @@ -208,7 +208,7 @@ func (w *Window) choosePixelFormat(ctxconfig *ctxconfig, fbconfig_ *fbconfig) (i func makeContextCurrentWGL(window *Window) error { if window != nil { if err := wglMakeCurrent(window.context.wgl.dc, window.context.wgl.handle); err != nil { - _glfw.contextSlot.set(0) + _ = _glfw.contextSlot.set(0) return err } if err := _glfw.contextSlot.set(uintptr(unsafe.Pointer(window))); err != nil { @@ -216,7 +216,7 @@ func makeContextCurrentWGL(window *Window) error { } } else { if err := wglMakeCurrent(0, 0); err != nil { - _glfw.contextSlot.set(0) + _ = _glfw.contextSlot.set(0) return err } if err := _glfw.contextSlot.set(0); err != nil { @@ -378,8 +378,8 @@ func initWGL() error { prc := wglGetCurrentContext() if err := wglMakeCurrent(dc, rc); err != nil { - wglMakeCurrent(pdc, prc) - wglDeleteContext(rc) + _ = wglMakeCurrent(pdc, prc) + _ = wglDeleteContext(rc) return err } diff --git a/internal/glfwwin/win32monitor_windows.go b/internal/glfwwin/win32monitor_windows.go index f17345cc3..5d4d812ac 100644 --- a/internal/glfwwin/win32monitor_windows.go +++ b/internal/glfwwin/win32monitor_windows.go @@ -105,7 +105,11 @@ adapterLoop: for i, monitor := range disconnected { if monitor != nil && monitor.win32.displayName == windows.UTF16ToString(display.DeviceName[:]) { disconnected[i] = nil - _EnumDisplayMonitors(0, nil, monitorCallbackPtr, _LPARAM(unsafe.Pointer(_glfw.monitors[i]))) + err := _EnumDisplayMonitors(0, nil, monitorCallbackPtr, _LPARAM(unsafe.Pointer(_glfw.monitors[i]))) + if err != nil { + return err + } + continue displayLoop } } diff --git a/internal/glfwwin/win32window_windows.go b/internal/glfwwin/win32window_windows.go index 9ff1015f3..05c8052ce 100644 --- a/internal/glfwwin/win32window_windows.go +++ b/internal/glfwwin/win32window_windows.go @@ -87,13 +87,17 @@ func createIcon(image *Image, xhot, yhot int, icon bool) (_HICON, error) { if err != nil { return 0, err } - defer _DeleteObject(_HGDIOBJ(color)) + defer func() { + _ = _DeleteObject(_HGDIOBJ(color)) + }() mask, err := _CreateBitmap(int32(image.Width), int32(image.Height), 1, 1, nil) if err != nil { return 0, err } - defer _DeleteObject(_HGDIOBJ(mask)) + defer func() { + _ = _DeleteObject(_HGDIOBJ(mask)) + }() source := image.Pixels var target []byte @@ -396,7 +400,9 @@ func (w *Window) updateFramebufferTransparency() error { if err != nil { return err } - defer _DeleteObject(_HGDIOBJ(region)) + defer func() { + _ = _DeleteObject(_HGDIOBJ(region)) + }() bb := _DWM_BLURBEHIND{ dwFlags: _DWM_BB_ENABLE | _DWM_BB_BLURREGION, @@ -1444,7 +1450,9 @@ func (w *Window) platformDestroyWindow() error { } if w.context.destroy != nil { - w.context.destroy(w) + if err := w.context.destroy(w); err != nil { + return err + } } if _glfw.win32.disabledCursorWindow == w { diff --git a/internal/glfwwin/window_windows.go b/internal/glfwwin/window_windows.go index c0ab9b23a..3955862c3 100644 --- a/internal/glfwwin/window_windows.go +++ b/internal/glfwwin/window_windows.go @@ -136,7 +136,7 @@ func CreateWindow(width, height int, title string, monitor *Monitor, share *Wind } defer func() { if ferr != nil { - window.Destroy() + _ = window.Destroy() } }() _glfw.windows = append(_glfw.windows, window) @@ -313,7 +313,10 @@ func (w *Window) Destroy() error { } } - w.platformDestroyWindow() + if err := w.platformDestroyWindow(); err != nil { + return err + } + return nil } diff --git a/internal/graphicscommand/image_js.go b/internal/graphicscommand/image_js.go index b4f63ffac..0122a8111 100644 --- a/internal/graphicscommand/image_js.go +++ b/internal/graphicscommand/image_js.go @@ -78,7 +78,7 @@ func DumpImages(images []*Image, graphicsDriver graphicsdriver.Graphics, dir str } } - zw.Close() + _ = zw.Close() zip := dir + ".zip" download(buf, "archive/zip", zip) diff --git a/internal/graphicscommand/image_notjs.go b/internal/graphicscommand/image_notjs.go index 4ff2fda34..21570f852 100644 --- a/internal/graphicscommand/image_notjs.go +++ b/internal/graphicscommand/image_notjs.go @@ -39,7 +39,9 @@ func (i *Image) Dump(graphicsDriver graphicsdriver.Graphics, path string, blackb if err != nil { return "", err } - defer f.Close() + defer func() { + _ = f.Close() + }() if err := i.dumpTo(f, graphicsDriver, blackbg, rect); err != nil { return "", err @@ -72,7 +74,9 @@ func DumpImages(images []*Image, graphicsDriver graphicsdriver.Graphics, dir str if err != nil { return "", err } - defer f.Close() + defer func() { + _ = f.Close() + }() if err := img.dumpTo(f, graphicsDriver, false, image.Rect(0, 0, img.width, img.height)); err != nil { return "", err diff --git a/internal/graphicsdriver/directx/.errcheck_excludes_windows b/internal/graphicsdriver/directx/.errcheck_excludes_windows new file mode 100644 index 000000000..ac490e942 --- /dev/null +++ b/internal/graphicsdriver/directx/.errcheck_excludes_windows @@ -0,0 +1,4 @@ +syscall.Syscall +syscall.Syscall6 +syscall.Syscall9 +syscall.Syscall12 diff --git a/internal/graphicsdriver/directx/graphics_windows.go b/internal/graphicsdriver/directx/graphics_windows.go index 26794917f..6759b47fd 100644 --- a/internal/graphicsdriver/directx/graphics_windows.go +++ b/internal/graphicsdriver/directx/graphics_windows.go @@ -860,12 +860,11 @@ func (g *Graphics) presentDesktop() error { } func (g *Graphics) presentXbox() error { - g.commandQueue.PresentX(1, &_D3D12XBOX_PRESENT_PLANE_PARAMETERS{ + return g.commandQueue.PresentX(1, &_D3D12XBOX_PRESENT_PLANE_PARAMETERS{ Token: g.framePipelineToken, ResourceCount: 1, ppResources: &g.renderTargets[g.frameIndex], }, nil) - return nil } func (g *Graphics) moveToNextFrame() error { diff --git a/internal/graphicsdriver/metal/mtl/mtl_darwin_test.go b/internal/graphicsdriver/metal/mtl/mtl_darwin_test.go index 3a35a77be..0d8449ec5 100644 --- a/internal/graphicsdriver/metal/mtl/mtl_darwin_test.go +++ b/internal/graphicsdriver/metal/mtl/mtl_darwin_test.go @@ -144,7 +144,9 @@ func readPNG(name string) (image.Image, error) { if err != nil { return nil, err } - defer f.Close() + defer func() { + _ = f.Close() + }() return png.Decode(f) } diff --git a/internal/graphicsdriver/opengl/gl/.errcheck_excludes_windows b/internal/graphicsdriver/opengl/gl/.errcheck_excludes_windows new file mode 100644 index 000000000..1a756be1f --- /dev/null +++ b/internal/graphicsdriver/opengl/gl/.errcheck_excludes_windows @@ -0,0 +1,3 @@ +syscall.Syscall +syscall.Syscall6 +syscall.Syscall9 diff --git a/internal/png/.errcheck_excludes b/internal/png/.errcheck_excludes new file mode 100644 index 000000000..cc47ad88a --- /dev/null +++ b/internal/png/.errcheck_excludes @@ -0,0 +1,2 @@ +(io.ReadCloser).Close +(*compress/zlib.Writer).Close diff --git a/internal/ui/hideconsole_windows.go b/internal/ui/hideconsole_windows.go index b265a8394..0cc17789b 100644 --- a/internal/ui/hideconsole_windows.go +++ b/internal/ui/hideconsole_windows.go @@ -67,6 +67,6 @@ func hideConsoleWindowOnWindows() { if pid == cpid { // The current process created its own console. Hide this. // Ignore error. - freeConsole() + _ = freeConsole() } }