Skip to content

Commit 8846571

Browse files
authored
fix(security): hide console window only in Windows (#94)
* fix(security): hide console window only in Windows * update
1 parent 35bd244 commit 8846571

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

security.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"runtime"
2424
"sort"
2525
"strings"
26-
"syscall"
2726
"time"
2827

2928
"go.mozilla.org/pkcs7"
@@ -489,7 +488,7 @@ func loadSystemRoots() (*x509.CertPool, error) {
489488
// Use certutil to download all the root certs.
490489
if needSync {
491490
cmd := exec.Command("certutil", "-syncWithWU", dir)
492-
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
491+
hideWindow(cmd)
493492
out, err := cmd.Output()
494493
if err != nil {
495494
return roots, err

security_linux_mac.go

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build !windows
2+
// +build !windows
3+
4+
package pe
5+
6+
import "os/exec"
7+
8+
func hideWindow(cmd *exec.Cmd) {
9+
}

security_windows.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//go:build windows
2+
// +build windows
3+
4+
package pe
5+
6+
import (
7+
"os/exec"
8+
"syscall"
9+
)
10+
11+
func hideWindow(cmd *exec.Cmd) {
12+
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
13+
}

0 commit comments

Comments
 (0)