decho

module
v0.0.0-...-1fc5a78 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2020 License: MIT

README

DECHO

Goal

The goal is to accelerate the process of bootstrapping an Restfull API base golang application

How

Docker is used to accelerate local setup for Echo framework and also you can generate a scratch image with a minimum footprint that can be used in production.

Setup local environment variables

cp .env.example .env

The command script

./app {cmd}

Build local dev

# build local docker container and download required libs
./app build

Run local dev

# run local docker container
./app run

Dev server URL

http://127.0.0.1:3000

Production docker image

# creates a docker production image
./app prd

Full list of commands:

Commands:

 build         Build local docker container and download required libs
 run           Run local docker container
 stop          Stop your local docker container
 remove        Remove local containers and everything related to them
 test          Run unit tests
 cover         Run unit tests and generate coverage file
 fmt           Format the code with go standards
 vet           Check and report likely mistakes in packages
 mod [COMMAND] Commands for go module maintenance
 bash          Enter dockers bash interface
 prd           Build scratch production image
 rprd          Run production image
 codegen       Generate code from the open api documentation

Re-run on the fly

The app uses Reflex for re-running your app when you change your code

Project Layout

The app follows the Standard Go Project Layout so the directory structure includes folders like cmd, internal, pkg and build. Standard Go Project Layout is an emerging project layout base on the Go ecosystem.

API-First approach

Edit file apidoc.yaml and generate code using OAPI-Codegen

# generate code from open api yaml file
./app codegen

The codegen command reads apidoc.yaml and generates two files server.go and types.go under internal/codegen. types.go has the data structures deffined on apidoc.yaml and the server.go file has the server side setup for the API.

Directories

Path Synopsis
cmd
internal
codegen
Package codegen provides primitives to interact the openapi HTTP API.
Package codegen provides primitives to interact the openapi HTTP API.
pkg

Jump to

Keyboard shortcuts

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