https://github.com/euclidstellar/crud-api-go
A Beginner friendly repo through which open-source people can understand CRUD operations in Golang
https://github.com/euclidstellar/crud-api-go
crud-api crud-application golang-backend golang-cli golang-crud golang-crud-examples
Last synced: 2 months ago
JSON representation
A Beginner friendly repo through which open-source people can understand CRUD operations in Golang
- Host: GitHub
- URL: https://github.com/euclidstellar/crud-api-go
- Owner: EuclidStellar
- Created: 2023-11-17T07:42:55.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-25T16:04:10.000Z (over 1 year ago)
- Last Synced: 2025-03-27T20:51:09.966Z (3 months ago)
- Topics: crud-api, crud-application, golang-backend, golang-cli, golang-crud, golang-crud-examples
- Language: Go
- Homepage:
- Size: 3.62 MB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
```markdown
# Golang CRUD Operations with Hardcoded DataThis repository demonstrates basic CRUD (Create, Read, Update, Delete) operations in Golang using hardcoded data.
It provides a simple example to understand how to implement these operations in a Golang application.## Project Structure
- `main.go`: The main Golang file containing the CRUD operations.
- `README.md`: Documentation explaining the purpose and usage of the project.## Prerequisites
Make sure you have Golang installed on your machine. If not, follow the instructions on the [official Golang website](https://golang.org/doc/install).
```
## Getting Started1. Clone the repository:
```bash
git clone https://github.com/EuclidStellar/CRUD-API-Go/
```2. Navigate to the project folder:
```bash
cd CRUD-API-Go
```3. Run the application:
```bash
go run main.go
```4. Open your web browser and access the following endpoints:
- List all movies: [http://localhost:8000/movies](http://localhost:8000/movies)
- Get a specific movie by ID: [http://localhost:8000/movies/{id}](http://localhost:8000/movies/{id})
- Create a new movie: Send a POST request to [http://localhost:8000/movies](http://localhost:8000/movies) with a JSON payload.
- Update a movie by ID: Send a PUT request to [http://localhost:8000/movies/{id}](http://localhost:8000/movies/{id}) with a JSON payload.
- Delete a movie by ID: Send a DELETE request to [http://localhost:8000/movies/{id}](http://localhost:8000/movies/{id}).### Create a new movie
```bash
curl -X POST -H "Content-Type: application/json" -d '{"id": "6", "title": "New Movie", "year": "2023", "director": {"firstname": "John", "lastname": "Doe", "age": 40}}' http://localhost:8000/movies
```### Update a movie
```bash
curl -X PUT -H "Content-Type: application/json" -d '{"id": "6", "title": "Updated Movie", "year": "2023", "director": {"firstname": "John", "lastname": "Doe", "age": 40}}' http://localhost:8000/movies/6
```### Delete a movie
```bash
curl -X DELETE http://localhost:8000/movies/6
```## Running Locally
To run the project locally, make sure you have Golang installed. Follow these steps:
1. Clone the repository:
```bash
git clone https://github.com/EuclidStellar/CRUD-API-Go/
```2. Navigate to the project folder:
```bash
cd CRUD-API-Go
```3. Run the application:
```bash
go run main.go
```4. Access the endpoints as described in the "Getting Started" section.
## Contributions
Contributions are welcome! If you have improvements, suggestions, or bug fixes, feel free to open an issue or create a pull request.
## License
This project is licensed under the [MIT License](LICENSE).
## Author
- [Gaurav](https://github.com/euclidstellar)
```Customize the content further based on your repository's specifics.
```