Skip to content

Commit

Permalink
cache: fix build failure on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
charlievieth committed Nov 10, 2021
1 parent 535c3a4 commit da7aa6a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
12 changes: 0 additions & 12 deletions cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import (
"encoding/json"
"os"
"path/filepath"
"runtime"
"sort"
"strings"
"sync"
"syscall"
"time"
)

Expand All @@ -26,16 +24,6 @@ var projectTombstonesUncommon = [...]string{
".hg",
}

func fileExists(name string) bool {
if runtime.GOOS != "windows" {
var stat syscall.Stat_t
return syscall.Lstat(name, &stat) == nil
} else {
_, err := os.Lstat(name)
return err == nil
}
}

func projectDir(dir string) string {
dir = filepath.Clean(dir)
orig := dir
Expand Down
11 changes: 11 additions & 0 deletions file_exist_portable.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build windows || plan9
// +build windows plan9

package imports

import "os"

func fileExists(name string) bool {
_, err := os.Lstat(name)
return err == nil
}
11 changes: 11 additions & 0 deletions file_exist_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build !windows && !plan9
// +build !windows,!plan9

package imports

import "syscall"

func fileExists(name string) bool {
var stat syscall.Stat_t
return syscall.Lstat(name, &stat) == nil
}

0 comments on commit da7aa6a

Please sign in to comment.