Skip to content

Commit a02c6d7

Browse files
authored
handle error from osuser.Current (#503)
1 parent bd4012d commit a02c6d7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/sqlcmd/sqlcmd.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,10 @@ func (s *Sqlcmd) ConnectDb(connect *ConnectSettings, nopw bool) error {
295295
s.vars.Set(SQLCMDUSER, connect.UserName)
296296
} else {
297297
u, e := osuser.Current()
298-
if e != nil {
299-
panic("Unable to get user name")
298+
// osuser.Current() returns an error in some restricted environments
299+
if e == nil {
300+
s.vars.Set(SQLCMDUSER, u.Username)
300301
}
301-
s.vars.Set(SQLCMDUSER, u.Username)
302302
}
303303
if newConnection {
304304
s.Connect = connect

0 commit comments

Comments
 (0)