Make getCurrentUser method private

This commit is contained in:
Dan Sosedoff 2022-11-22 14:39:06 -06:00
parent 0a7de05892
commit fa0efb1597
No known key found for this signature in database
GPG Key ID: 26186197D282B164

View File

@ -67,7 +67,7 @@ func ParseOptions(args []string) (Options, error) {
// Handle edge case where pgweb is started with a default host `localhost` and no user.
// When user is not set the `lib/pq` connection will fail and cause pgweb's termination.
if (opts.Host == "localhost" || opts.Host == "127.0.0.1") && opts.User == "" {
if username := GetCurrentUser(); username != "" {
if username := getCurrentUser(); username != "" {
opts.User = username
} else {
opts.Host = ""
@ -131,8 +131,8 @@ func SetDefaultOptions() error {
return nil
}
// GetCurrentUser returns a current user name
func GetCurrentUser() string {
// getCurrentUser returns a current user name
func getCurrentUser() string {
u, _ := user.Current()
if u != nil {
return u.Username