WithFlags changes the flags in the FmtCtx, runs the given function, then restores the old flags.
(flags FmtFlags, fn func())
| 244 | // WithFlags changes the flags in the FmtCtx, runs the given function, then |
| 245 | // restores the old flags. |
| 246 | func (ctx *FmtCtx) WithFlags(flags FmtFlags, fn func()) { |
| 247 | if ctx.ann == nil && flags&flagsRequiringAnnotations != 0 { |
| 248 | panic(errors.AssertionFailedf("no Annotations provided")) |
| 249 | } |
| 250 | oldFlags := ctx.flags |
| 251 | ctx.flags = flags |
| 252 | defer func() { ctx.flags = oldFlags }() |
| 253 | |
| 254 | fn() |
| 255 | } |
| 256 | |
| 257 | // HasFlags returns true iff the given flags are set in the formatter context. |
| 258 | func (ctx *FmtCtx) HasFlags(f FmtFlags) bool { |