Skip to content

harshbarnawa/Go-learn

Repository files navigation

Go Movies CRUD API

A simple RESTful CRUD API built with Go, Gorilla Mux, and JSON.

This project demonstrates how to build a backend API in Go without a database by storing data in memory using slices. It covers all basic CRUD operations:

  • Get All Movies
  • Get Movie By ID
  • Create Movie
  • Update Movie
  • Delete Movie

Tech Stack

  • Go
  • Gorilla Mux
  • REST API
  • JSON
  • Postman

Project Architecture

Architecture


Features

Get All Movies

Returns all available movies.

Endpoint

GET /movies

Postman Response

Get All Movies


Get Movie By ID

Returns a single movie using its ID.

Endpoint

GET /movies/{id}

Example:

GET /movies/1

Postman Response

Get Movie By ID


Create Movie

Creates a new movie.

Endpoint

POST /movies

Example Request Body:

{
  "isbn": "41299",
  "title": "Better Call Saul",
  "director": {
    "firstname": "Saul",
    "lastname": "Goodman"
  }
}

Postman Response

Create Movie


Update Movie

Updates an existing movie by ID.

Endpoint

PUT /movies/{id}

Example:

PUT /movies/54063039

Request Body:

{
  "isbn": "438227",
  "title": "Breaking Bad",
  "director": {
    "firstname": "Heisen",
    "lastname": "Berg"
  }
}

Postman Response

Update Movie


Delete Movie

Deletes a movie using its ID.

Endpoint

DELETE /movies/{id}

Example:

DELETE /movies/99099797

Postman Response

Delete Movie


Installation

Clone the repository:

git clone https://github.com/harshbarnawa/Go-learn.git

Navigate to the project directory:

cd Go-learn/Movie-Crud/src/go-movies-crud

Install dependencies:

go mod tidy

Run the server:

go run main.go

Server starts on:

http://localhost:8000

API Routes

Method Endpoint Description
GET /movies Get all movies
GET /movies/{id} Get movie by ID
POST /movies Create movie
PUT /movies/{id} Update movie
DELETE /movies/{id} Delete movie

Learning Outcomes

Through this project I learned:

  • Building REST APIs in Go
  • Working with Gorilla Mux
  • Handling HTTP Requests & Responses
  • JSON Encoding and Decoding
  • Route Parameters
  • CRUD Operations
  • Working with Structs and Pointers
  • Testing APIs using Postman

License

This project is licensed under the MIT License.

Author

Harsh Barnawa

About

Learning Go from scratch while building real stuff. From basic syntax to APIs, concurrency, and backend development — this repo is my journey of mastering Golang step by step.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors