Skip to content

titikterang/hexagonal-arch-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Setup & Development


  1. Package structure
  2. Define Primary Ports, Secondary Ports
  3. Define Models & Data Structure
  4. Proto Contract
  5. Generate Proto File
  6. Define Ports & Models
  7. Implement Primary & Secondary Adapter
  8. Implement Core Business Logic
  9. Testing

Cara Generate Protobuf


  1. Di repo ini, menggunakan libprotoc 26.1, untuk cek versi protoc yang terinstall bisa menggunakan command berikut
    protoc --version
  2. Definisikan spec proto di folder lib/protos/v1/xxxx/xxx.proto
  3. Misal untuk wallet di lib/protos/v1/wallet/wallet.proto
  4. Lalu jalankan command berikut
     protoc -I . --proto_path=. \
            --go_out=paths=source_relative:. \
            --go-http_out=paths=source_relative:. \
            --go-grpc_out=paths=source_relative:. \
            --openapiv2_out ./lib/protos/openapiv2 --openapiv2_opt logtostderr=true \
     		./lib/protos/v1/wallet/wallet.proto
  5. File *.go akan tergenerate sesuai lokasi folder proto yang kita define, dan akan melakukan generate ke spec open API di folder lib/protos/openapiv2/lib/protos/v1/wallet/wallet.swagger.json
  6. Isi dari makefile, pada dasarnya merupakan command di atas yang lebih di rapikan
  7. Untuk generate melalui makefile, misal untuk proto wallet yang ada di folder lib/protos/v1/wallet/wallet.proto bisa menggunakan command berikut
       MODULE=v1/wallet make generate
  8. Untuk generate file go di semua proto, bisa langsung jalankan command berikut
    make generate

About

an example project for hexagonal architecture with golang monorepo

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published