From 4c33e488ba634c5bdf499e959364e8e265083e77 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sun, 21 Jan 2018 20:07:18 -0200 Subject: [PATCH] style: make context.Wrap public --- config/config.go | 1 + context/context.go | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/config/config.go b/config/config.go index 523c45696..5f4aa5f0d 100644 --- a/config/config.go +++ b/config/config.go @@ -291,6 +291,7 @@ func LoadReader(fd io.Reader) (config Project, err error) { return config, checkOverflows(config) } +// TODO: check if we can use UnmarshalStrict instead of the manual checkOverflow func checkOverflows(config Project) error { var overflow = &overflowChecker{} overflow.check(config.XXX, "") diff --git a/context/context.go b/context/context.go index 3423ee31b..adfc0b253 100644 --- a/context/context.go +++ b/context/context.go @@ -42,16 +42,17 @@ type Context struct { // New context func New(config config.Project) *Context { - return wrap(ctx.Background(), config) + return Wrap(ctx.Background(), config) } // NewWithTimeout new context with the given timeout func NewWithTimeout(config config.Project, timeout time.Duration) (*Context, ctx.CancelFunc) { ctx, cancel := ctx.WithTimeout(ctx.Background(), timeout) - return wrap(ctx, config), cancel + return Wrap(ctx, config), cancel } -func wrap(ctx ctx.Context, config config.Project) *Context { +// Wrap wraps an existing context +func Wrap(ctx ctx.Context, config config.Project) *Context { return &Context{ Context: ctx, Config: config,