Write API for a vendor with non-persistent and persistent database. this was one of the internet engineering lecture homeworks. Link to Homework Description
you can use Intellij IDE or [].exe files to run the project. the default of project is non-persistent.
do the followings:
- Uncomment line 6
var Database = CreateListDB()
in db/DBLayer.go - Comment line 5
var Database = CreatePostgresDB()
in db/DBLayer.go - Run the API using one of the ways:
- Using Intellij IDE.
- Execute
go build -o api.exe main.go
in project directory and run the api.exe
for the persistent version, you need a postgres server. after running your database, do the followings:
- Configure gorm dsn such as host, user, pass and... information in db/PostgresDB.go.
- Comment line 6
var Database = CreateListDB()
in db/DBLayer.go - Uncomment line 5
var Database = CreatePostgresDB()
in db/DBLayer.go - Run the API using one of the ways:
- Using Intellij IDE.
- Execute
go build -o api.exe main.go
in project directory and run the api.exe
default configuration for postgres database is:
- host = "localhost"
- user = "postgres"
- pass = "admin"
- dbname = "customers"
- port = "5432"