Example #1
0
func DefaultUserData() (*UserData, error) {
	db := pg.Connect(&pg.Options{
		User: "******",
	})
	user := new(UserData)
	user.db = db
	err := user.Init()

	return user, err
}
Example #2
0
func Test_Init(t *testing.T) {
	db := pg.Connect(&pg.Options{
		User: "******",
	})
	user := new(UserData)
	user.db = db
	err = user.Init()
	if err != nil {
		t.Fatal(err.Error())
		return
	}
	testUserDB = user
}
Example #3
0
func openPg(config pgx.ConnPoolConfig) (*gopg.DB, error) {
	var options gopg.Options

	options.Host = config.Host
	_, err := os.Stat(options.Host)
	if err == nil {
		options.Network = "unix"
		if !strings.Contains(options.Host, "/.s.PGSQL.") {
			options.Host = filepath.Join(options.Host, ".s.PGSQL.5432")
		}
	}

	options.User = config.User
	options.Database = config.Database
	options.Password = config.Password

	return gopg.Connect(&options), nil
}