-
Ensure that you have Golang installed:
go version -
Ensure that you have psql installed:
<Windows key> + <type 'psql'> -
Pull a copy of the source code using:
git clone git@github.com:nseah21/go-rest-api.gitviassh,- or
git clone https://github.com/nseah21/go-rest-api.gitviahttps, - or manually by downloding the ZIP file
-
In a terminal window, make sure you are inside the root directory
go-rest-api/ -
To test the server:
- Modify the
.envfile with your credentials forpsql - Start up your
psqlshell using<Windows key> + <type 'psql'> + <Enter key>and key in your credentials as in the previous step - Create a database by entering
CREATE DATABASE <database-name>; - Change into your database by entering
\c <database-name> - Copy and paste the definitions block from
./internal/db/init.sqlinto yourpsqlshell - Optionally, you can also copy and paste the seed data block from
./internal/db/init.sqlinto yourpsqlshell - In a terminal, verify that you are still in the root directory
go-rest-api/ - Run
go mod tidyfollowed bygo run ./cmd/server - Verify that the server is running on
localhost:8080
- Modify the
-
To run unit tests, run
go test -v ./...in the root directorygo-rest-api/ -
Alternatively, you can run
go test ./...for an overview of the test packages
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|