Rebased upstream - Fixed NPE
This commit is contained in:
parent
5dafdb1de6
commit
615e70ef22
@ -114,7 +114,7 @@ func (c *Context) Lineage() []*Context {
|
||||
return lineage
|
||||
}
|
||||
|
||||
// value returns the value of the flag corresponding to `name`
|
||||
// Value returns the value of the flag corresponding to `name`
|
||||
func (c *Context) Value(name string) interface{} {
|
||||
return c.flagSet.Lookup(name).Value.(flag.Getter).Get()
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package cli
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"sort"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@ -328,7 +328,7 @@ func TestContextPropagation(t *testing.T) {
|
||||
parent := NewContext(nil, nil, nil)
|
||||
parent.Context = context.WithValue(context.Background(), "key", "val")
|
||||
ctx := NewContext(nil, nil, parent)
|
||||
val := ctx.Value("key")
|
||||
val := ctx.Context.Value("key")
|
||||
if val == nil {
|
||||
t.Fatal("expected a parent context to be inherited but got nil")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user