Go Strcture

Go lang guideline #

Clean architecture #

Applicaiton structure #

cmd/
    worker/       <-- Worker runner
    http/         <-- RESTFull API runner
etc/              <-- misc files
  pre-commit      <-- pre commit rules
  gcp.key         <-- gcp key
  ..
internal/
  adapters/           <-- connections to 3rd party services (dwolla, sendgrid, north capital)
    adapter.go        <-- interfaces for adapters
    sendgrid/         <-- intergration with sendgrid
      requests.go     <-- Sendgrid requests structures with validation rules
      responses.go    <-- Sendgrid responses structures
      config.go       <-- Sendgrid config
      errors.go       <-- Sendgrid errors
      sendgrid.go     <-- implementation
      ....
  app/                <-- application layer
    app.go            <-- main app functions
    <object_name>.go  <-- example investment.go all functions connected to investments
  domain/             <-- business related objects
    dto/              <-- data transfer objects
      investment.go     <-- investmentdto
      offer.go
      validation.go  <-- validation rules
    requests.go     <-- HTTP and Worker incoming requests structures with validation rules
    responses.go    <-- HTTP and Worker responses structures
  ports/              <-- incoming data connections (http/pubsub/protobuf)
    http/ 
      config.go       <-- config
      errors.go       <-- errors
      routers.go      <-- routers
      http.go         <-- implementation
    pubsub
      config.go       <-- config
      errors.go
      pubsub.go
      listeners.go
pkg/
  services/           <--- shared services
    north_capital/
      requests.go     <-- Service requests structures with validation rules
      responses.go    <-- Service responses structures
      errors.go       <-- Service errors
      config.go       <-- Service config
      nc.go           <-- Service implementation

.air.toml             <--- air config to with life reload
.gitignore      
.golangci.yml         <--- golang linter config
make.sh               <--- helper functions