crud-products

module
v0.0.0-...-acbba05 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: MIT

README

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

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

Directories

Path Synopsis
cli
internal
server/handlers/mock_handlers
Package mock_handlers is a generated GoMock package.
Package mock_handlers is a generated GoMock package.
pkg

Jump to

Keyboard shortcuts

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