Skip to content

contrib/drivers/pgsql: Connection fails when password is empty #3899

@wlynxg

Description

@wlynxg

Go version

go version go1.22.4 windows/amd64

GoFrame version

v2.7.4

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

package main

import (
	pg "github.com/gogf/gf/contrib/drivers/pgsql/v2"
	"github.com/gogf/gf/v2/database/gdb"
)

func main() {
	d := &pg.Driver{}
	db, err := d.Open(&gdb.ConfigNode{
		Host: "192.168.0.1",
		Port: "5432",
		Pass: "test",
		Type: "pgsql",
		User: "postgres",
		Name: "test",
	})
	if err != nil {
		panic(err)
	}

	err = db.Ping()
	if err != nil {
		panic(err)
	}
}

What did you see happen?

panic: dial tcp [::1]:5432: connectex: No connection could be made because the target machine actively refused it.

What did you expect to see?

No error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIt is confirmed a bug, but don't worry, we'll handle it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions