Skip to content

Commit 94885e2

Browse files
authored
Merge pull request #3 from arduino/runas-nonwindows
Allow runas to be imported on non-windows builds.
2 parents e681a11 + 8745e46 commit 94885e2

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

runas_others.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//go:build !windows
2+
3+
package runas
4+
5+
import "errors"
6+
7+
func RunElevated(executable, workingDir string, args []string, awaitProcCompletion bool) (int, error) {
8+
return 0, errors.New("RunElevated is only supported on Windows")
9+
}
10+
11+
func IsAdminProcess() (bool, error) {
12+
return false, errors.New("IsAdminProcess is only supported on Windows")
13+
}

runas.go renamed to runas_windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,6 @@ func RunElevated(executable, workingDir string, args []string, awaitProcCompleti
148148

149149
// IsAdminProcess returns true if the current process already
150150
// runs as admin.
151-
func IsAdminProcess() bool {
152-
return windows.GetCurrentProcessToken().IsElevated()
151+
func IsAdminProcess() (bool, error) {
152+
return windows.GetCurrentProcessToken().IsElevated(), nil
153153
}

0 commit comments

Comments
 (0)