github.com/zhouyu0/docker-note@v0.0.0-20190722021225-b8d3825084db/pkg/homedir/homedir_linux.go (about) 1 package homedir // import "github.com/docker/docker/pkg/homedir" 2 3 import ( 4 "os" 5 6 "github.com/docker/docker/pkg/idtools" 7 ) 8 9 // GetStatic returns the home directory for the current user without calling 10 // os/user.Current(). This is useful for static-linked binary on glibc-based 11 // system, because a call to os/user.Current() in a static binary leads to 12 // segfault due to a glibc issue that won't be fixed in a short term. 13 // (#29344, golang/go#13470, https://sourceware.org/bugzilla/show_bug.cgi?id=19341) 14 func GetStatic() (string, error) { 15 uid := os.Getuid() 16 usr, err := idtools.LookupUID(uid) 17 if err != nil { 18 return "", err 19 } 20 return usr.Home, nil 21 }