Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
import (
"fmt"
"os"
"os/user"
"syscall"
)
func fileUserName(filename string) (username string, err error) {
stat, err := os.Stat(filename)
if os.IsNotExist(err) {
return
}
uid := stat.Sys().(*syscall.Stat_t).Uid
User, _ := user.LookupId(fmt.Sprint(uid))
username = User.Username
return
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question