Skip to content

Instantly share code, notes, and snippets.

@AseemWangoo
Created October 19, 2022 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AseemWangoo/1e7ff631dd1ba2acd47b0a8c4c4f99ac to your computer and use it in GitHub Desktop.
Save AseemWangoo/1e7ff631dd1ba2acd47b0a8c4c4f99ac to your computer and use it in GitHub Desktop.
connect with postgres
host := "127.0.0.1"
port := "5432"
user := "user"
password := "password"
dbname := "dbname"
psqlInfo := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=disable", host, port, user, password, dbname)
result, err := sql.Open("postgres", psqlInfo)
if err != nil {
log.Fatalf("Error in connection : %s", err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment