minimum

command module
v0.0.0-...-3beaeaf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2024 License: MIT Imports: 2 Imported by: 0

README

Go API Boilerplates - chi/minimum

MIT license Tests Go Report Card


This is a minimum example of Go API with Chi router.

A full list of libraries used can be found in Dependencies section.

Table of Contents

Development

This project can be booted up either

  • natively with Go installed locally (assuming dependencies like PostgresSQL, Redis, etc. also exist)
  • or by Docker Compose (PostgreSQL, Redis, etc. are included out of the box)

Please refer to Makefile or docker-compose.yml for details.

By default, the server will run at http://localhost:3333, but everything is configurable via .env file.

Tools

Some common development tools are introduced for better local development experience.

go install github.com/cosmtrek/air@latest
go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
go install github.com/swaggo/swag/cmd/swag@latest

Alternatively, use make install to install the required Go tooling locally.

Documentation

This service has integrated swaggo/swag to create OpenAPI documentation automatically.

Use command make generate/api or swag init to run the generation.

Then navigate to http://localhost:3333/swagger/index.html to view the API documentation.

Dependencies

API

  • go-chi/chi - lightweight, idiomatic and composable router for building Go HTTP services
    • go-chi/cors - CORS net/http middleware for Go
    • go-chi/render - easily manage HTTP request / response payloads of Go HTTP services
  • joho/godotenv - A Go port of Ruby's dotenv library (Loads environment variables from .env files)
  • sethvargo/go-envconfig - A Go library for parsing struct tags from environment variables.
  • uber-go/zap - Blazing fast, structured, leveled logging in Go.
  • go-ozzo/ozzo-validation - An idiomatic Go (golang) validation package. Supports configurable and extensible validation rules (validators) using normal language constructs instead of error-prone struct tags.
  • swaggo/http-swagger - Default net/http wrapper to automatically generate RESTful API documentation with Swagger 2.0.

Testing

  • stretchr/testify - A toolkit with common assertions and mocks that plays nicely with the standard library

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
app
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
internal
api

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL