HasState returns true if the state for the provided type is present in the context
(ctx context.Context)
| 202 | |
| 203 | // HasState returns true if the state for the provided type is present in the context |
| 204 | func HasState[S WithState](ctx context.Context) bool { |
| 205 | p := ctx.Value(persistedEnv) |
| 206 | if p == nil { |
| 207 | return false |
| 208 | } |
| 209 | |
| 210 | newS := *new(S) |
| 211 | key := persistedKey(newS) |
| 212 | |
| 213 | store := *p.(*map[string]any) |
| 214 | |
| 215 | state := store[key] |
| 216 | return state != nil |
| 217 | } |
| 218 | |
| 219 | // NoColorOutput returns true if the output produced should not contain colors, which is |
| 220 | // useful when a terminal or medium can't interpret ANSI colors |
nothing calls this directly
no test coverage detected