re: How I Built an API with Mux, Go, PostgreSQL, and GORM VIEW POST

VIEW PARENT COMMENT VIEW FULL DISCUSSION
 

In this case, I think os.ExpandEnv is a better solution:

db, err = gorm.Open(
        "postgres",
        os.ExpandEnv("host=${HOST} user=${USER} dbname=${DBNAME} sslmode=disable password=${PASSWORD}"))
 

If you're defining the environment variables, yeah, sure.

 

Oh awesome, didn't know about this -- will definitely try it!

code of conduct - report abuse