From 3e604f0f372aef4345fc0a51c49b4cc171876e0e Mon Sep 17 00:00:00 2001 From: Yolan Romailler Date: Thu, 31 Aug 2023 10:49:53 +0200 Subject: [PATCH] Always expose the error to compare it, and do not build on unsupported arch Signed-off-by: Yolan Romailler --- screenshot.go | 5 +++++ screenshot_supported.go | 2 +- screenshot_unsupported.go | 5 +---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/screenshot.go b/screenshot.go index b796e17..79c7063 100644 --- a/screenshot.go +++ b/screenshot.go @@ -3,9 +3,14 @@ package screenshot import ( + "errors" "image" ) +// ErrUnsupported is returned when the platform or architecture used to compile the program +// does not support screenshot, e.g. if you're compiling without CGO on Darwin +var ErrUnsupported = errors.New("screenshot does not support your platform") + // CaptureDisplay captures whole region of displayIndex'th display, starts at 0 for primary display. func CaptureDisplay(displayIndex int) (*image.RGBA, error) { rect := GetDisplayBounds(displayIndex) diff --git a/screenshot_supported.go b/screenshot_supported.go index aaadd89..6952cb6 100644 --- a/screenshot_supported.go +++ b/screenshot_supported.go @@ -1,4 +1,4 @@ -//go:build !darwin && !windows && (linux || freebsd || openbsd || netbsd) +//go:build !s390x && !ppc64le && !darwin && !windows && (linux || freebsd || openbsd || netbsd) package screenshot diff --git a/screenshot_unsupported.go b/screenshot_unsupported.go index fdf82d4..ab938c2 100644 --- a/screenshot_unsupported.go +++ b/screenshot_unsupported.go @@ -1,14 +1,11 @@ -//go:build !(cgo && darwin) && !windows && !linux && !freebsd && !openbsd && !netbsd +//go:build s390x || ppc64le || (!(cgo && darwin) && !windows && !linux && !freebsd && !openbsd && !netbsd) package screenshot import ( - "errors" "image" ) -var ErrUnsupported = errors.New("screenshot does not support your platform") - // Capture returns screen capture of specified desktop region. // x and y represent distance from the upper-left corner of primary display. // Y-axis is downward direction. This means coordinates system is similar to Windows OS.