WithName returns ts wrapped so it advertises Name() == name. If ts (or any inner toolset reachable via Unwrap) already advertises a non-empty Name(), ts is returned unchanged so the original implementation wins. The returned wrapper participates in As[T]: every capability of ts remains reachable th
(ts ToolSet, name string)
| 31 | // The returned wrapper participates in As[T]: every capability of ts |
| 32 | // remains reachable through the wrapper. |
| 33 | func WithName(ts ToolSet, name string) ToolSet { |
| 34 | if ts == nil || name == "" { |
| 35 | return ts |
| 36 | } |
| 37 | if existing, ok := As[Named](ts); ok && existing.Name() != "" { |
| 38 | return ts |
| 39 | } |
| 40 | return &namedToolSet{ToolSet: ts, name: name} |
| 41 | } |
| 42 | |
| 43 | // namedToolSet decorates a ToolSet with a stable Name(). Every other |
| 44 | // capability is delegated to the inner toolset via the embedded ToolSet |