@@ -26,7 +26,7 @@ const (
2626)
2727
2828type Postgres struct {
29- CurrentBD string
29+ CurrentDB string
3030 Executor * Executor
3131 ForcePasswordPrompt bool
3232 NeverPasswordPrompt bool
@@ -37,7 +37,6 @@ type Postgres struct {
3737}
3838
3939func New (neverPasswordPrompt , forcePasswordPrompt bool , ctx context.Context , cfg config.Config ) * Postgres {
40-
4140 postgres := & Postgres {
4241 NeverPasswordPrompt : neverPasswordPrompt ,
4342 ForcePasswordPrompt : forcePasswordPrompt ,
@@ -49,7 +48,6 @@ func New(neverPasswordPrompt, forcePasswordPrompt bool, ctx context.Context, cfg
4948}
5049
5150func (p * Postgres ) Connect (host , user , password , database , dsn string , port uint16 ) error {
52-
5351 if user == "" {
5452 currentUser , err := osUser .Current ()
5553 if err != nil {
@@ -88,11 +86,10 @@ func (p *Postgres) Connect(host, user, password, database, dsn string, port uint
8886 return err
8987 }
9088 p .Executor = exec
91- p .CurrentBD = database
89+ p .CurrentDB = database
9290 logger .Log .Info ("Database connection established" , "database" , database , "user" , user )
9391
9492 return nil
95-
9693}
9794
9895func (p * Postgres ) ConnectDSN (dsn string ) error {
@@ -142,12 +139,11 @@ func (p *Postgres) ChangeDatabase(dbName string) error {
142139 "" ,
143140 p .ctx ,
144141 )
145-
146142 if err != nil {
147143 return err
148144 }
149145 p .Executor = exec
150- p .CurrentBD = dbName
146+ p .CurrentDB = dbName
151147 logger .Log .Info ("Database changed" , "database" , dbName )
152148
153149 return nil
@@ -189,7 +185,7 @@ func (p *Postgres) RunCli() error {
189185 repl .Print ("Previous connection kept" )
190186 }
191187 }
192- repl .Print (fmt .Sprintf ("You are now connected to database %q as user %q" , p .CurrentBD , p .Executor .User ))
188+ repl .Print (fmt .Sprintf ("You are now connected to database %q as user %q" , p .CurrentDB , p .Executor .User ))
193189 repl .PrintTime (time .Since (start ))
194190 continue
195191 }
@@ -203,7 +199,7 @@ func (p *Postgres) RunCli() error {
203199 }
204200 repl .Print (
205201 fmt .Sprintf ("You are connected to database %q as user %q on %s on port %d" ,
206- p .CurrentBD , p .Executor .User , host , p .Executor .Port ,
202+ p .CurrentDB , p .Executor .User , host , p .Executor .Port ,
207203 ),
208204 )
209205 continue
@@ -262,8 +258,8 @@ func (p *Postgres) getPrompt() string {
262258 str = strings .ReplaceAll (str , "\\ h" , "(nil)" )
263259 }
264260
265- if p .CurrentBD != "" {
266- str = strings .ReplaceAll (str , "\\ d" , p .CurrentBD )
261+ if p .CurrentDB != "" {
262+ str = strings .ReplaceAll (str , "\\ d" , p .CurrentDB )
267263 } else {
268264 str = strings .ReplaceAll (str , "\\ d" , "(nil)" )
269265 }
0 commit comments