go-hexagonal-example

command module
v0.0.0-...-de196d9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
repository
serializer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL