git.iko.soy
/
crush
readme
files
commits
refs
on
main
help
sign in
feat: add `fsext` function to get owner of directory
897796e
Andrey Nering
1 year ago
internal/fsext/owner_others.go
new file
+24
compare with main
unified
split
@@ -0,0 +1,24 @@
1
+
//go:build !windows
2
+
3
+
package
fsext
4
+
5
+
import
(
6
+
"os"
7
+
"syscall"
8
+
)
9
+
10
+
// Owner retrieves the user ID of the owner of the file or directory at the
11
+
// specified path.
12
+
func
Owner(path string) (int, error) {
13
+
info, err := os.Stat(path)
14
+
if
err !=
nil
{
15
+
return
0
, err
16
+
}
17
+
var
uid int
18
+
if
stat, ok := info.Sys().(*syscall.Stat_t); ok {
19
+
uid = int(stat.Uid)
20
+
}
else
{
21
+
uid = os.Getuid()
22
+
}
23
+
return
uid,
nil
24
+
}
internal/fsext/owner_windows.go
new file
+9
@@ -0,0 +1,9 @@
1
+
//go:build windows
2
+
3
+
package
fsext
4
+
5
+
// Owner retrieves the user ID of the owner of the file or directory at the
6
+
// specified path.
7
+
func
Owner(path string) (int, error) {
8
+
return
-
1
,
nil
9
+
}
keys
esc to close
j k
move down, up
enter
open
esc
back, or up a level
1 2 3 4
readme, files, commits, refs
/
filter
y
copy the clone command
c
compare the chosen commit with another (or shift-click both)
?
show or hide this list