package sprigx import ( `os` `os/user` `strconv` `strings` ) /* osGroupById returns os/user.LookupGroupId. Can accept either a string (`"1000"`) or any numeric type (`1000`, `-1000`, `1000.0`, `MyCustomType(1000)`, etc.) */ func osGroupById(gid any) (g *user.Group, err error) { var i int var NaN bool var gidStr string if i, NaN, err = toPosInt(gid); err != nil { if NaN { err = nil if gidStr, err = toString(gid); err != nil { return } } else { return } } else { gidStr = strconv.Itoa(i) } g, err = user.LookupGroupId(gidStr) return } /* osFQDN (tries to) return the FQDN of this host. Currently it just calls os.Hostname() but may be extended to "try harder" in the future. */ func osFQDN() (fqdn string, err error) { fqdn, err = os.Hostname() return } /* osHost returns the system's "host shortname". Currently it just calls os.Hostname() and takes the first "host label" (as RFCs refer to it), but it may be extended in the future. */ func osHost() (hostNm string, err error) { hostNm, err = os.Hostname() if hostNm == "" { return } hostNm = strings.Split(hostNm, ".")[0] return } /* osUserById returns an os/user.LookupId. Can accept either a string (`"1000"`) or any numeric type (`1000`, `-1000`, `1000.0`, `MyCustomType(1000)`, etc.) */ func osUserById(uid any) (u *user.User, err error) { var i int var NaN bool var uidStr string if i, NaN, err = toPosInt(uid); err != nil { if NaN { err = nil if uidStr, err = toString(uid); err != nil { return } } else { return } } else { uidStr = strconv.Itoa(i) } u, err = user.LookupId(uidStr) return }