From 25e54c0eff18dc01bf8a88982a0bd591b0fffe87 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 26 Sep 2021 19:13:50 +0200 Subject: [PATCH] Go 1.17 --- .github/workflows/build.yml | 2 +- .github/workflows/gosum.yml | 2 +- app/utils/cmd/cmd.go | 7 ++++--- app/utils/windows/windows.go | 9 +++++---- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eb982b36..601788e4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,7 +52,7 @@ jobs: name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.16 + go-version: 1.17 - name: Mage build uses: magefile/mage-action@v1 diff --git a/.github/workflows/gosum.yml b/.github/workflows/gosum.yml index bb57f79f..8bd86c16 100644 --- a/.github/workflows/gosum.yml +++ b/.github/workflows/gosum.yml @@ -20,7 +20,7 @@ jobs: name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.16 + go-version: 1.17 - name: Tidy run: | diff --git a/app/utils/cmd/cmd.go b/app/utils/cmd/cmd.go index 7974f77e..3215128c 100644 --- a/app/utils/cmd/cmd.go +++ b/app/utils/cmd/cmd.go @@ -4,7 +4,8 @@ import ( "bytes" "os/exec" "strings" - "syscall" + + "golang.org/x/sys/windows" ) // Options of command @@ -32,7 +33,7 @@ func Exec(options Options) (Result, error) { command.Stdout = commandStdout commandStderr := &bytes.Buffer{} command.Stderr = commandStderr - command.SysProcAttr = &syscall.SysProcAttr{HideWindow: options.HideWindow} + command.SysProcAttr = &windows.SysProcAttr{HideWindow: options.HideWindow} if options.WorkingDir != "" { command.Dir = options.WorkingDir @@ -43,7 +44,7 @@ func Exec(options Options) (Result, error) { } command.Wait() - waitStatus := command.ProcessState.Sys().(syscall.WaitStatus) + waitStatus := command.ProcessState.Sys().(windows.WaitStatus) result.ExitCode = waitStatus.ExitCode result.Stdout = strings.TrimSpace(commandStdout.String()) diff --git a/app/utils/windows/windows.go b/app/utils/windows/windows.go index 9a584118..e76fef25 100644 --- a/app/utils/windows/windows.go +++ b/app/utils/windows/windows.go @@ -9,6 +9,7 @@ import ( "github.com/akyoto/color" "github.com/crazy-max/WindowsSpyBlocker/app/utils/print" + "golang.org/x/sys/windows" "golang.org/x/sys/windows/registry" ) @@ -63,20 +64,20 @@ func SetRegString(key registry.Key, name string, value string) error { // SetConsoleTitle sets windows console title func SetConsoleTitle(title string) (int, error) { - handle, err := syscall.LoadLibrary("kernel32.dll") + handle, err := windows.LoadLibrary("kernel32.dll") if err != nil { print.Error(err) return 0, err } - defer syscall.FreeLibrary(handle) + defer windows.FreeLibrary(handle) - proc, err := syscall.GetProcAddress(handle, "SetConsoleTitleW") + proc, err := windows.GetProcAddress(handle, "SetConsoleTitleW") if err != nil { print.Error(err) return 0, err } - rTitle, err := syscall.UTF16PtrFromString(title) + rTitle, err := windows.UTF16PtrFromString(title) if err != nil { print.Error(err) return 0, err