Skip to content

roman-wb/crud-products

Repository files navigation

codecov Build Status Go Report Repository Top Language GitHub go.mod Go version Github Repository Size Lines of code License GitHub last commit Simply the best ;)

Test project - CRUD Products

Feature Overview

  • REST API
  • PostgreSQL
  • Migrations
  • Logger
  • Tests
  • Docker
  • GolangCI-lint
  • Development with Hot-Reload

Get Started

Development

cp .env.sample .env
make docker-dev-up # default listen on localhost:8080

Test

make docker-test-up
make test

API

Method URL Description
GET /products Return all products
POST /products Create new product (use JSON body)
GET /products/{id} Get product by id
POST /products/{id} Update product by id (use JSON body)
DELETE /products/{id} Delete product by id

Makefile commands

  • make server-run - Run server with .env config
  • make docker-dev-up - Run development environment and hot reload server
  • make docker-test-up - Run test environment
  • make create-migration name={your_name} - Create migration in dir /migrations
  • make generate - Generate mocks interfaces
  • make code - Run code-style && code-lint
  • make code-style - Run goimports
  • make code-lint - Run golangci-lint
  • make test - Run unit + integrations tests (with docker)
  • make unit-test - Run unit tests
  • make cover - Open test coverage.out (use after make test)
  • make psql - Open postgres command line with development db

Packages

  • github.com/joho/godotenv
  • github.com/gorilla/mux
  • github.com/jackc/pgx/v4
  • go.uber.org/zap
  • github.com/stretchr/testify
  • github.com/golang/mock

Todo

  • Cache
  • Auth
  • Tests with Postman
  • Metrics (go / pgx)

License

MIT

About

Sample CRUD Products

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published