Golang App with Hexagonal Architecture with logging middleware

I am developing an application in golang with hexagonal architecture. I required to print the requestId in the logs where ever I want to use logs.

To do this, I am generating a random request Id and attaching it with the GIN context. And suppose I want to log info at repository adapter. My problem is that, in this case to be able to log I need to pass the context object to each and every components(layers), adapter to ports to domain to repository and each methods where I want to log request Id. This will be not according to hexagonal architecture and clean code. So, I dont want to pass context to each components and methods to be able to get the information set in GIN Context Is there a way like we do in spring, we can get the principle object anywhere once it get set in spring security context.

two things:

  1. passing a context down form transport (adapter in Hexagonal Architecture) to Port and then Business rule is perfectly fine in Go,
  2. For the logging I prefer to build middlewares and apply to all layers (adapter logging middleware, port logging middleware, business logic log middleware, …).

An example on how extensively using logging middleware is how go-kit is designed; have a look to the examples to see what is the idea; the same principles are applicable to other frameworks