Skip to content

Commit

Permalink
Always expose the error to compare it, and do not build on unsupporte…
Browse files Browse the repository at this point in the history
…d arch

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>
  • Loading branch information
AnomalRoil committed Aug 31, 2023
1 parent b87d318 commit 3e604f0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 5 additions & 0 deletions screenshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion screenshot_supported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !darwin && !windows && (linux || freebsd || openbsd || netbsd)
//go:build !s390x && !ppc64le && !darwin && !windows && (linux || freebsd || openbsd || netbsd)

package screenshot

Expand Down
5 changes: 1 addition & 4 deletions screenshot_unsupported.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit 3e604f0

Please sign in to comment.