From 47e70f25444d2e8a7550f7fc89ae12386a3565aa Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 15 Oct 2023 23:27:04 +0900 Subject: [PATCH] internal/ui: use errors.New instead of fmt.Errorf --- internal/ui/ui_darwin.go | 3 ++- internal/ui/ui_js.go | 6 +++--- internal/ui/ui_linbsd.go | 5 +++-- internal/ui/ui_nintendosdk.go | 6 +++--- internal/ui/ui_windows.go | 4 ++-- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/internal/ui/ui_darwin.go b/internal/ui/ui_darwin.go index ef51750b9..0525b3684 100644 --- a/internal/ui/ui_darwin.go +++ b/internal/ui/ui_darwin.go @@ -17,6 +17,7 @@ package ui import ( + "errors" "fmt" "reflect" "unsafe" @@ -185,7 +186,7 @@ func (*graphicsDriverCreatorImpl) newOpenGL() (graphicsdriver.Graphics, error) { } func (*graphicsDriverCreatorImpl) newDirectX() (graphicsdriver.Graphics, error) { - return nil, fmt.Errorf("ui: DirectX is not supported in this environment") + return nil, errors.New("ui: DirectX is not supported in this environment") } func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) { diff --git a/internal/ui/ui_js.go b/internal/ui/ui_js.go index f9f728e28..073cc3533 100644 --- a/internal/ui/ui_js.go +++ b/internal/ui/ui_js.go @@ -15,7 +15,7 @@ package ui import ( - "fmt" + "errors" "image" "math" "sync" @@ -43,11 +43,11 @@ func (g *graphicsDriverCreatorImpl) newOpenGL() (graphicsdriver.Graphics, error) } func (*graphicsDriverCreatorImpl) newDirectX() (graphicsdriver.Graphics, error) { - return nil, fmt.Errorf("ui: DirectX is not supported in this environment") + return nil, errors.New("ui: DirectX is not supported in this environment") } func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) { - return nil, fmt.Errorf("ui: Metal is not supported in this environment") + return nil, errors.New("ui: Metal is not supported in this environment") } var ( diff --git a/internal/ui/ui_linbsd.go b/internal/ui/ui_linbsd.go index dad836183..ba97c82c2 100644 --- a/internal/ui/ui_linbsd.go +++ b/internal/ui/ui_linbsd.go @@ -17,6 +17,7 @@ package ui import ( + "errors" "fmt" "runtime" @@ -47,11 +48,11 @@ func (*graphicsDriverCreatorImpl) newOpenGL() (graphicsdriver.Graphics, error) { } func (*graphicsDriverCreatorImpl) newDirectX() (graphicsdriver.Graphics, error) { - return nil, fmt.Errorf("ui: DirectX is not supported in this environment") + return nil, errors.New("ui: DirectX is not supported in this environment") } func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) { - return nil, fmt.Errorf("ui: Metal is not supported in this environment") + return nil, errors.New("ui: Metal is not supported in this environment") } // glfwMonitorSizeInGLFWPixels must be called from the main thread. diff --git a/internal/ui/ui_nintendosdk.go b/internal/ui/ui_nintendosdk.go index 0992c18a6..f80800e33 100644 --- a/internal/ui/ui_nintendosdk.go +++ b/internal/ui/ui_nintendosdk.go @@ -22,7 +22,7 @@ import "C" import ( stdcontext "context" - "fmt" + "errors" "image" "runtime" "sync" @@ -47,11 +47,11 @@ func (*graphicsDriverCreatorImpl) newOpenGL() (graphicsdriver.Graphics, error) { } func (*graphicsDriverCreatorImpl) newDirectX() (graphicsdriver.Graphics, error) { - return nil, fmt.Errorf("ui: DirectX is not supported in this environment") + return nil, errors.New("ui: DirectX is not supported in this environment") } func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) { - return nil, fmt.Errorf("ui: Metal is not supported in this environment") + return nil, errors.New("ui: Metal is not supported in this environment") } const deviceScaleFactor = 1 diff --git a/internal/ui/ui_windows.go b/internal/ui/ui_windows.go index 1f2aa7025..56aa24b48 100644 --- a/internal/ui/ui_windows.go +++ b/internal/ui/ui_windows.go @@ -80,13 +80,13 @@ func (*graphicsDriverCreatorImpl) newOpenGL() (graphicsdriver.Graphics, error) { func (g *graphicsDriverCreatorImpl) newDirectX() (graphicsdriver.Graphics, error) { if g.transparent { - return nil, fmt.Errorf("ui: DirectX is not available with a transparent window") + return nil, errors.New("ui: DirectX is not available with a transparent window") } return directx.NewGraphics() } func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) { - return nil, fmt.Errorf("ui: Metal is not supported in this environment") + return nil, errors.New("ui: Metal is not supported in this environment") } // glfwMonitorSizeInGLFWPixels must be called from the main thread.