Is there a way to transform
gin.Context
to context.Context
in Go?
What should be used in building a Go microservice?
The standard library's context.Context
type is an interface, with the following methods:
Deadline() (deadline time.Time, ok bool)
Done() <-chan struct{}
Err() error
Value(key interface{}) interface{}
So any type that has these methods is a context.Context
.
Looking at the gin documentation, we see that the gin.Context
type has all of these methods:
So it's already a context.Context
. No conversion or transformation necessary.