Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rawsashimi1604/go-stock-api

Learning golang by creating stock api
https://github.com/rawsashimi1604/go-stock-api

Last synced: 2 days ago
JSON representation

Learning golang by creating stock api

Awesome Lists containing this project

README

        

# go-stock-api

## Connection String

Please use this connection string in your `.env` file.
```
POSTGRES_URL="postgres://postgres:[email protected]: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
1. Install air `https://github.com/cosmtrek/air`
2. Run using cmd `air`
3. Make sure `air` is in `PATH`