WithFlags changes the flags in the FmtCtx, runs the given function, then restores the old flags.
(flags FmtFlags, fn func())
| 307 | // WithFlags changes the flags in the FmtCtx, runs the given function, then |
| 308 | // restores the old flags. |
| 309 | func (ctx *FmtCtx) WithFlags(flags FmtFlags, fn func()) { |
| 310 | if ctx.ann == nil && flags&flagsRequiringAnnotations != 0 { |
| 311 | panic(errors.AssertionFailedf("no Annotations provided")) |
| 312 | } |
| 313 | oldFlags := ctx.flags |
| 314 | ctx.flags = flags |
| 315 | defer func() { ctx.flags = oldFlags }() |
| 316 | |
| 317 | fn() |
| 318 | } |
| 319 | |
| 320 | // HasFlags returns true iff the given flags are set in the formatter context. |
| 321 | func (ctx *FmtCtx) HasFlags(f FmtFlags) bool { |