go-stock-api
Connection String
Please use this connection string in your .env
file.
POSTGRES_URL="postgres://postgres:mysecretpassword@127.0.0.1:5432/stocksdb?sslmode=disable"
Start a docker container and create the stocks database.
docker pull postgres:latest
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres
docker exec -it some-postgres bash
su postgres
psql
CREATE DATABASE stocksdb;
Create Stock table.
CREATE TABLE stock (
id SERIAL PRIMARY KEY,
name TEXT,
price NUMERIC,
company TEXT
);
Running with hot reload using Air
- Install air
https://github.com/cosmtrek/air
- Run using cmd
air
- Make sure
air
is in PATH