Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/rawsashimi1604/go-stock-api
- Owner: rawsashimi1604
- Created: 2023-08-08T17:35:25.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-08-10T12:36:42.000Z (over 1 year ago)
- Last Synced: 2024-06-21T06:44:37.821Z (6 months ago)
- Language: Go
- Size: 9.18 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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`