Invalidate context.setFlags cache on modification.

This commit is contained in:
Péter Szilágyi
2017-01-11 14:38:54 +02:00
parent 8ef3805c9d
commit acc622e5fb
2 changed files with 6 additions and 0 deletions

View File

@@ -39,11 +39,13 @@ func (c *Context) NumFlags() int {
// Set sets a context flag to a value.
func (c *Context) Set(name, value string) error {
c.setFlags = nil
return c.flagSet.Set(name, value)
}
// GlobalSet sets a context flag to a value on the global flagset
func (c *Context) GlobalSet(name, value string) error {
globalContext(c).setFlags = nil
return globalContext(c).flagSet.Set(name, value)
}