Backend Test Code IMP (PT Informatika Media Pratama)
├── api
│ └── swagger.yml # swagger spec file
├── build # executable file build
├── cmd
│ └── server # main application folder
├── config.yaml # main application config
├── gen # go-swagger generated folders
│ ├── models
│ └── restapi
├── generate.go
├── go.mod
├── go.sum
├── internal
│ ├── app # private application code
│ │ ├── handlers # handler layer
│ │ ├── rest # route layer
│ │ └── server.go # main server code
│ ├── app.go # # main application code
│ └── pkg
│ │ ├── constant.go # internal pkg constant
│ │ ├── errors # internal pkg error
│ │ └── migrations # internal pkg migration
│ └── utils # internal utils
├── Makefile
├── migrations # migrations file
├── pkg # shared pkg application
│ ├── config # application config
│ ├── db # db config
│ └── log # application log
- Install Go on your device
- Clone repository
- Setup application config
- Running Project
- Edit swagger.yml File in api/swagger.yml. If you need help with swagger docs use the Editor and read the Documentation.
- To Generate Routes and Validation from Swagger API run
make generate
.
$ make help
it will show all option to running app
$ make all
$ make run # for running binary file
$ make run-local # for running main.go file
- run app
make run
||make run-local
- go to
http://localhost:8080/docs
- run command
migrate create -ext sql -dir migrations/schema create_tablename_table
- write sql code in migration file
- run migration
make migrate-up
it will run migration automatically
- install godoc
$ go get golang.org/x/tools/cmd/godoc
- add comment on the package, reference : https://tip.golang.org/doc/comment
- run godoc
godoc -http:=6060
- open
localhost:6060
or127.0.0.1:6060
. it will show go documentation - access on
http://localhost:6060/pkg/test-be-IMP/internal/app/usecases/?m=all
-
Install docker, reference : https://docs.docker.com/engine/install/ubuntu/
-
Run this command
sudo docker build -t server .
sudo docker run --network='host' server
-
access on 127.0.0.1:3000
*note server = image name