Skip to content

This is an example illustrating how to structure code in go using hexagonal architecture

License

Notifications You must be signed in to change notification settings

kmjayadeep/go-hexagonal-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go hexagonal architecture example

This is an example illustrating how to structure code in go using hexagonal architecture

Reference : https://youtu.be/rQnTtQZGpg8

Here are some articles about hexagonal architecture

Folder structure

  • api -> contains api handler logic
  • repository -> logic to intact with different storage mechanisms (mongo, redis etc)
    • memory -> implementation of repository logic using in-memory store (hashmap)
  • serializer -> logic to encode/decode objects to bytes
    • json -> serializer implementation using json
    • msgpack -> serializer implementation using msgpack
  • shortner -> app and domain logic for shortner
    • logic.go -> business logic written as a service
    • model.go -> struct
    • repository.go -> interface to deal with repository
    • serializer.go -> interface to encode/decode Redirect struct
    • service.go -> interface for business logic

Build and run

Run the following command to run the app

./run.sh

Run the following to test the app

./scripts/test.sh

The script will create a new short link and print the output

About

This is an example illustrating how to structure code in go using hexagonal architecture

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published