Skip to content

Commit

Permalink
fix: platform error difference
Browse files Browse the repository at this point in the history
  • Loading branch information
Licoy committed Jun 17, 2022
1 parent 32d9619 commit 950ec1e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion util.go
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"os"
"runtime"
"strings"
"syscall"
)

Expand Down Expand Up @@ -50,7 +51,12 @@ func GetSystemHostsPath() string {
func PreCheckHasHostsRWPermission() (yes bool, err error) {
_, err = syscall.Open(GetSystemHostsPath(), syscall.O_RDWR, 0655)
if err != nil {
if errors.Is(err, syscall.ERROR_ACCESS_DENIED) {
if runtime.GOOS == Windows {
if errors.Is(err, syscall.ERROR_ACCESS_DENIED) {
err = nil
}
}
if strings.Contains(err.Error(), "Access is denied") {
err = nil
}
return
Expand Down

0 comments on commit 950ec1e

Please sign in to comment.