go-mux-postgreSQL
Dependencies
- Download and install PostgreSQL following this link
- Download and install Go following this link
- Install Go modules required
$ go get -u github.com/gorilla/mux
$ go get -u github.com/lib/pq
Setting db
- Creation db and products table
$ psql -U postgres -W
$ create database go_project
$ \c go_project
$ CREATE TABLE products
(
id SERIAL,
name TEXT NOT NULL,
price NUMERIC(10,2) NOT NULL DEFAULT 0.00,
CONSTRAINT products_pkey PRIMARY KEY (id)
);
Server Set Up
$ export APP_DB_USERNAME=postgres
$ export APP_DB_PASSWORD=
$ export APP_DB_NAME=go_project
Running the tests
In the project directory:
go test -v
Starting the server
In the project directory:
$ go build
$ ./go-mux-postgerSQL.git
Test APIs
A full documentation of Api is available at the following link