https://github.com/anjasfedo/go-postgre
RESTful API Golang with PostgreSQL
https://github.com/anjasfedo/go-postgre
golang learning-by-doing postgresql restful-api
Last synced: 10 months ago
JSON representation
RESTful API Golang with PostgreSQL
- Host: GitHub
- URL: https://github.com/anjasfedo/go-postgre
- Owner: Anjasfedo
- Created: 2024-01-14T03:52:10.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-14T06:59:42.000Z (almost 2 years ago)
- Last Synced: 2025-01-17T03:28:17.778Z (12 months ago)
- Topics: golang, learning-by-doing, postgresql, restful-api
- Language: Go
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go RESTful API with PostgreSQL 🚀
This project is a simple RESTful API built using GoLang with PostgreSQL.
## Getting Started🛠️
Follow these steps to run the project locally:
1. **Set Up Database:**
Make sure you have PostgreSQL installed and create a database named go_postgres. Update the .env file with your PostgreSQL connection URL.
2. **Set Up Database:**
```bash
go run main.go
```
The server will start at http://localhost:8000.
## API Endpoints🚪
### Get Stocks
- **Endpoint:** `GET /api/stock`
- **Description:** Retrieve a list of all Stocks.
### Get Stock by ID
- **Endpoint:** `GET /api/stock/:id`
- **Description:** Retrieve a specific stock by ID.
### Create Stock
- **Endpoint:** `POST /api/stock`
- **Description:** Create a new stock.
### Update Stock by ID
- **Endpoint:** `PUT /api/stock/:id`
- **Description:** Update a specific stock by ID.
### Delete Stock by ID
- **Endpoint:** `DELETE /api/stock/:id`
- **Description:** Delete a specific stock by ID.
The API Postman Collection is available in the /postman-collection/ directory.
## Dependencies 📦
- [gorilla/mux](https://github.com/gorilla/mux) v1.8.1: HTTP request router
- [joho/godotenv](https://github.com/joho/godotenv) v1.5.1: GoDotEnv for Go (loads environment variables from a .env file)
- [lib/pq](https://github.com/lib/pq) v1.10.9: PostgreSQL driver for Go (indirect)
## Closing Notes📝
If you find any issues or have suggestions for improvement, please feel free to open an issue or submit a pull request.
Happy coding!🚀👨💻