12factors-workshop

command module
v0.0.0-...-9f731ea Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

12factors-workshop

Este repositorio é um código de exemplo criado com carinho e propositalmente tem muitas falhas de design pra que a gente possa refator-lo, usando as boas praticas citadas no 12factor.net.

Funcionalidades

WIP...

TODO

  • Adicionar um docker-compose para usar o PostgreSQL
  • Remover o db.go e usar o github.com/go-pg/pg
  • Criar o dockerfile e atualizar o docker-compose
  • Buildar dockerfile no actions do Github
  • Melhorar mensagens e usar logs

Usage

IMPORTANTE: Lembre de fazer o clone desse repositorio no diretório ~/go/src/github.com/golang-poa/12factors-workshop

set up

Go version: go1.13.6 darwin/amd64.

Instale:

go get -u github.com/gin-gonic/gin
go get -u github.com/cosmtrek/air

crie o arquivo de banco de dados:

echo '[]' > /tmp/db.json

inicie a app apenas depois de criar esse arquivo! senão vai ganhar um erro tipo esse:

12factors-workshop on  master [?] via 🐹 v1.13.6
➜ air

  __    _   ___
 / /\  | | | |_)
/_/--\ |_| |_| \_ // live reload for Go apps [v1.12.0]

watching .
!exclude tmp
building...
running...
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:	export GIN_MODE=release
 - using code:	gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /                         --> main.init.0.func1 (3 handlers)
[GIN-debug] GET    /api/v1/products/         --> main.init.0.func2 (3 handlers)
[GIN-debug] POST   /api/v1/products/:name    --> main.init.0.func3 (3 handlers)
carregando db file
panic: could not read the database file: open /tmp/db.json: no such file or directory

goroutine 1 [running]:
main.init.1()
	/Users/seba/projetos/pessoal/12factors-workshop/db.go:26 +0x44
run
<WORKSHOP_DB="path/to/file.json"> go run *.go

or run with the code live reload:

air
API Usage
  • GET /api/v1/products/
  • POST /api/v1/products/:name
CONFIG
CONFIG DESCRIPTION DEFAULT
WORKSHOP_DB Arquivo do banco de dados /tmp/db.json
WORKSHOP_LISTEN Listen do webserver :9090

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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