A simple task management API built with Go (Golang) that demonstrates how to create a RESTful service with auto-generated Swagger/OpenAPI documentation.
- RESTful API endpoints for task management
- Auto-generated Swagger documentation
- Go 1.21 or higher
- Git
-
Clone the repository:
git clone <your-repo-url> cd go-hello-world
-
Install dependencies:
go mod download
Start the server:
go run main.go
The server will start at http://localhost:8080
Swagger UI is available at: http://localhost:8080/swagger/index.html
GET /api/v1/tasks
- List all tasksGET /api/v1/tasks/{id}
- Get a specific taskPOST /api/v1/tasks/{id}/complete
- Mark a task as complete
go test -v
main.go
- Main application file with API handlers and task definitionsmain_test.go
- API endpoint testsdocs/
- Auto-generated Swagger documentationgo.mod
- Go module definition and dependencies
To regenerate Swagger documentation after making API changes:
swag init
This project serves as a demonstration of:
- Building a RESTful API in Go
- Implementing Swagger documentation using swag
- Writing testable Go code
- Using the Gin web framework
- Proper project structure and organization