Skip to content

Commit

Permalink
Remove console-window code
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnewhall committed May 26, 2023
1 parent f5294f6 commit 7c56873
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 45 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -36,6 +36,7 @@ documentation support. This project succeeds because of them. Thank you!
[![Docker Cloud](https://docs.golift.io/integrations/docker.png "Docker Cloud")](https://cloud.docker.com)
[![Homebrew](https://docs.golift.io/integrations/homebrew.png "Homebrew")](https://brew.sh)
[![Go Lift](https://docs.golift.io/integrations/golift.png "Go Lift")](https://golift.io)
[![CloudFlare](https://docs.golift.io/integrations/cloudflare.png "CloudFlare")](https://cloudflare.com)

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion examples/MANUAL.md
Expand Up @@ -64,4 +64,4 @@ AUTHOR

LOCATION
---
* [github.com/Unpackerr/unpackerr](https://github.com/Unpackerr/unpackerr)
* [unpackerr.zip](https://unpackerr.zip)
2 changes: 0 additions & 2 deletions go.mod
Expand Up @@ -6,8 +6,6 @@ require (
github.com/fsnotify/fsnotify v1.6.0
github.com/gen2brain/dlgs v0.0.0-20220603100644-40c77870fa8d
github.com/getlantern/systray v1.2.2
github.com/gonutz/w32 v1.0.0
github.com/gonutz/w32/v2 v2.9.0
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b
github.com/julienschmidt/httprouter v1.3.0
github.com/lestrrat-go/apache-logformat/v2 v2.0.6
Expand Down
5 changes: 0 additions & 5 deletions go.sum
Expand Up @@ -99,9 +99,6 @@ github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaW
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/gonutz/w32 v1.0.0 h1:3t1z6ZfkFvirjFYBx9pHeHBuKoN/VBVk9yHb/m2Ll/k=
github.com/gonutz/w32 v1.0.0/go.mod h1:Rc/YP5K9gv0FW4p6X9qL3E7Y56lfMflEol1fLElfMW4=
github.com/gonutz/w32/v2 v2.9.0/go.mod h1:MgtHx0AScDVNKyB+kjyPder4xIi3XAcHS6LDDU2DmdE=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
Expand Down Expand Up @@ -183,8 +180,6 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk=
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog=
github.com/spf13/pflag v1.0.6-0.20201009195203-85dd5c8bc61c h1:zqmyTlQyufRC65JnImJ6H1Sf7BDj8bG31EV919NVEQc=
github.com/spf13/pflag v1.0.6-0.20201009195203-85dd5c8bc61c/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace h1:9PNP1jnUjRhfmGMlkXHjYPishpcw4jpSt/V/xYY3FMA=
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
3 changes: 0 additions & 3 deletions main.go
Expand Up @@ -10,11 +10,8 @@ import (

// Keep it simple.
func main() {
ui.HideConsoleWindow()

defer func() {
if r := recover(); r != nil {
ui.ShowConsoleWindow()
log.Printf("[PANIC] %v\n%s", r, string(debug.Stack()))
}
}()
Expand Down
6 changes: 0 additions & 6 deletions pkg/ui/ui_darwin.go
Expand Up @@ -16,12 +16,6 @@ func HasGUI() bool {
return hasGUI
}

// HideConsoleWindow does nothing on OSes besides Windows.
func HideConsoleWindow() {}

// ShowConsoleWindow does nothing on OSes besides Windows.
func ShowConsoleWindow() {}

// StartCmd starts a command.
func StartCmd(c string, v ...string) error {
cmd := exec.Command(c, v...)
Expand Down
6 changes: 0 additions & 6 deletions pkg/ui/ui_other.go
Expand Up @@ -17,12 +17,6 @@ func HasGUI() bool {
return false
}

// HideConsoleWindow does nothing on OSes besides Windows.
func HideConsoleWindow() {}

// ShowConsoleWindow does nothing on OSes besides Windows.
func ShowConsoleWindow() {}

// StartCmd starts a command.
func StartCmd(c string, v ...string) error {
cmd := exec.Command(c, v...)
Expand Down
22 changes: 0 additions & 22 deletions pkg/ui/ui_windows.go
Expand Up @@ -7,8 +7,6 @@ import (
"os/exec"
"strings"
"syscall"

"github.com/gonutz/w32"
)

// SystrayIcon is the icon in the system tray or task bar.
Expand All @@ -20,26 +18,6 @@ func HasGUI() bool {
return hasGUI
}

// HideConsoleWindow hides the windows console window.
func HideConsoleWindow() {
if console := w32.GetConsoleWindow(); console != 0 {
_, consoleProcID := w32.GetWindowThreadProcessId(console)
if w32.GetCurrentProcessId() == consoleProcID {
w32.ShowWindowAsync(console, w32.SW_HIDE)
}
}
}

// ShowConsoleWindow does nothing on OSes besides Windows.
func ShowConsoleWindow() {
if console := w32.GetConsoleWindow(); console != 0 {
_, consoleProcID := w32.GetWindowThreadProcessId(console)
if w32.GetCurrentProcessId() == consoleProcID {
w32.ShowWindowAsync(console, w32.SW_SHOW)
}
}
}

// StartCmd starts a command.
func StartCmd(c string, v ...string) error {
cmd := exec.Command(c, v...)
Expand Down

0 comments on commit 7c56873

Please sign in to comment.