Run Taskfiles from sub/child directories (#920)

This commit is contained in:
Pete Davison
2022-12-06 00:58:20 +00:00
committed by GitHub
parent 99d7338c29
commit b3627fcb18
12 changed files with 186 additions and 20 deletions

22
internal/sysinfo/uid.go Normal file
View File

@@ -0,0 +1,22 @@
//go:build !windows
package sysinfo
import (
"os"
"syscall"
)
func Owner(path string) (int, error) {
info, err := os.Stat(path)
if err != nil {
return 0, err
}
var uid int
if stat, ok := info.Sys().(*syscall.Stat_t); ok {
uid = int(stat.Uid)
} else {
uid = os.Getuid()
}
return uid, nil
}

View File

@@ -0,0 +1,9 @@
//go:build windows
package sysinfo
// NOTE: This always returns -1 since there is currently no easy way to get
// file owner information on Windows.
func Owner(path string) (int, error) {
return -1, nil
}