From f6894448bdd0da08624489a4f12b7b6850b9e861 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Thu, 18 Feb 2021 18:00:20 +0800 Subject: [PATCH] fix golint issues in core/contextx (#477) --- core/contextx/deadline.go | 2 ++ core/contextx/unmarshaler.go | 1 + core/contextx/valueonlycontext.go | 1 + 3 files changed, 4 insertions(+) diff --git a/core/contextx/deadline.go b/core/contextx/deadline.go index 24bb2bac..a97388bb 100644 --- a/core/contextx/deadline.go +++ b/core/contextx/deadline.go @@ -5,6 +5,8 @@ import ( "time" ) +// ShrinkDeadline returns a new Context with proper deadline base on the given ctx and timeout. +// And returns a cancel function as well. func ShrinkDeadline(ctx context.Context, timeout time.Duration) (context.Context, func()) { if deadline, ok := ctx.Deadline(); ok { leftTime := time.Until(deadline) diff --git a/core/contextx/unmarshaler.go b/core/contextx/unmarshaler.go index e8de69f7..ab1e884d 100644 --- a/core/contextx/unmarshaler.go +++ b/core/contextx/unmarshaler.go @@ -19,6 +19,7 @@ func (cv contextValuer) Value(key string) (interface{}, bool) { return v, v != nil } +// For unmarshals ctx into v. func For(ctx context.Context, v interface{}) error { return unmarshaler.UnmarshalValuer(contextValuer{ Context: ctx, diff --git a/core/contextx/valueonlycontext.go b/core/contextx/valueonlycontext.go index 627697e1..40170b29 100644 --- a/core/contextx/valueonlycontext.go +++ b/core/contextx/valueonlycontext.go @@ -21,6 +21,7 @@ func (valueOnlyContext) Err() error { return nil } +// ValueOnlyFrom takes all values from the given ctx, without deadline and error control. func ValueOnlyFrom(ctx context.Context) context.Context { return valueOnlyContext{ Context: ctx,