netutil: for better backtraces use named function.

Per feedback on https://camlistore-review.googlesource.com/507

Change-Id: Id6c0e4f66d221e6677167aaf590dc3cc696e5391
This commit is contained in:
Bill Thiede 2013-08-18 11:31:56 -07:00
parent f665ca05d3
commit c5434e293d
1 changed files with 4 additions and 2 deletions

View File

@ -128,8 +128,10 @@ func (p maybeBrackets) String() string {
return s
}
// Store in a var so we can override for testing.
var uidFromUsername = func(username string) (uid int, err error) {
// Changed by tests.
var uidFromUsername = uidFromUsernameFn
func uidFromUsernameFn(username string) (uid int, err error) {
if uid := os.Getuid(); uid != 0 && username == os.Getenv("USER") {
return uid, nil
}