A simple RESTful API built with Go, Gorilla Mux, GORM, and MySQL for managing user records.
- Go 1.23+
- Gorilla Mux
- GORM
- MySQL
- User CRUD (Create, Read, Update, Delete)
- Auto database migration
- REST API endpoints
Install dependencies:
go mod tidyIn user/ directory:
go mod init user
go mod tidyIn root:
go mod edit -replace user=./user
go mod tidyCreate a rahuldb database and update DB credentials in user/model.go:
const DbUrl = "root:test123@tcp(127.0.0.1:3306)/rahuldb?charset=utf8mb4&parseTime=True&loc=Local"go build -o go-rest.exe
go-rest.exeAPI runs at: http://localhost:8000
GET /usersGET /users/{id}POST /usersPUT /users/{id}DELETE /users/{id}