Run the postgres server on local

pg_ctl -D /usr/local/var/postgres start

Creating the database structure

    id SERIAL,
    name TEXT NOT NULL,
    price NUMERIC(10,2) NOT NULL DEFAULT 0.00,
    CONSTRAINT products_pkey PRIMARY KEY (id)

Get the required files

go get -u 
go get -u

Runing the application

source .env

go build -o go-mux.bin


Running the test

go test

Output :

PASS ok 0.038s

DIY Exercise

* Add a store table with store containing products
    store_id , product_id , is_available

Add the following apis

GET /store/:id/products

 - Given store id, get the list of products

POST /store/:id

 - Given list of products add in the store

Add test cases for the above apis.


View Github