go/statusz: do not crash on failure to resolve uid

This can happen if a binary is built statically and fails to load
libgcc/nsd libraries at runtime.

Change-Id: Ia76645471b83a6cc75fe6552e70e6a251b50129c
master
q3k 2020-10-30 14:05:04 +01:00
parent 99ce53c79a
commit 376f58720e
1 changed files with 5 additions and 2 deletions

View File

@ -38,6 +38,7 @@ import (
"html"
"html/template"
"io"
"log"
"net/http"
"os"
"os/user"
@ -197,9 +198,11 @@ func init() {
user, err := user.Current()
if err != nil {
glog.Fatalf("user.Current: %v", err)
log.Printf("user.Current: %v", err)
username = "UNKNOWN"
} else {
username = fmt.Sprintf("%s (%s)", user.Username, user.Uid)
}
username = fmt.Sprintf("%s (%s)", user.Username, user.Uid)
exec, err := os.Executable()
if err == nil {