Created
March 20, 2020 11:59
-
-
Save TrinhTrungDung/6c928121da2331080234c9dae48583d3 to your computer and use it in GitHub Desktop.
Connect to the database created by docker container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/jinzhu/gorm" | |
_ "github.com/jinzhu/gorm/dialects/postgres" | |
) | |
func main() { | |
db, err := gorm.Open("postgres", "host=localhost port=5432 user=testuser dbname=testdb password=123456 sslmode=disable") | |
if err != nil { | |
fmt.Println(err) | |
} | |
defer db.Close() | |
fmt.Println("Successfully connect to new database") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment