App Structure :
- app -> all logic of application requirement
- background -> background service app handler
- request -> to collect all data request
- presents -> to create struct of response
- middleware -> middleware of the app
- models -> model of database
- repositories -> repository to encapsulation query or fetch data
- ucase -> to build specific logic and generate response formatted to consume by route
- config -> configuration app
- pkg -> package usage in app
- provider -> bootstraping behavior app needed
- route -> app route api
- Run HTTP server
example :
<your-app> http serve
my_app http server
- Run HTTP server on Development/Local Machine
go run main.go http serve
Get and install tools from github repo
go install github.com/dienggo/diego/cmd/[email protected]
Check your GOPATH location, windows -> skip this step
go env GOPATH
$ <your-location-gopath>
Copy path and make alias installed diego, example on macos with zsh
alias diego="/<your-location-gopath>/bin/diego"
Example :
alias diego="/usr/development/go/bin/diego"
Use diego
diego -h
Update Diego (beta - available at version >= v1.2.0)
diego update
-
awesome_project -> your project name & module
diego build awesome_project
-
generate all template of
use case
[delete.go][detail.go][list.go][upsert.go]exampleCase -> yourdiego generate ucase example
use case
&use case
stored toapp/ucase/exampleCase
-
custom -> your
diego generate ucase custom exampleCase
use case
&use case
stored toapp/ucase/exampleCase/custom.go
-
example_case -> your middleware & middleware stored to
diego generate middleware example_case
app/middleware/example_case.go
-
example_task -> your background service & background service stored to
diego generate bg-task example_task
app/background/example_task.go
-
example_case -> your command & command stored to
diego generate cmd example_case
cmd/example_case.go
& also registered on provider/cmd.go automatically.
run your command on development/local :example :go run main.go <your-command-name-or-alias>
go run main.go my-command
Cause this framework depends on goose
, install goose
first ---> https://github.com/pressly/goose
- Get help usage
diego migration -h
- Migrate the DB to the most recent version available
diego migration up
- Migrate the DB up by 1
diego migration up-by-one
- Migrate the DB to a specific VERSION
diego migration up-to VERSION
- Roll back the version by 1
diego migration down
- Roll back to a specific VERSION
example :
diego migration down-to VERSION
migration down-to 123
- Re-run the latest migration
diego migration redo
- Roll back all migrations
diego migration reset
- Dump the migration status for the current DB
diego migration status
- Print the current version of the database
diego migration version
- Creates new migration file with the current timestamp
example :
diego migration create NAME [sql|go]
diego migration create your_table sql
- Apply sequential ordering to migrations
diego migration fix
- Check migration files without running them
diego migration validate
github.com/go-playground/validator/v10 v10.11.1
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
github.com/gorilla/schema v1.2.0
github.com/joho/godotenv v1.4.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.2
github.com/urfave/cli/v2 v2.25.7
golang.org/x/text v0.8.0
gopkg.in/yaml.v2 v2.4.0
gorm.io/driver/mysql v1.3.4
gorm.io/gorm v1.23.7