MustBuild panics if Build() would return an error. Designed for init(): func init() { platform.Register(platform.NewPlugin(...).MustBuild()) } A panic in init runs before the framework's recover guard is installed and will crash the binary. That is the intended behaviour: a misconfigured plugin m
()
| 176 | // installed and will crash the binary. That is the intended |
| 177 | // behaviour: a misconfigured plugin must NOT be silently registered. |
| 178 | func (b *Builder) MustBuild() Plugin { |
| 179 | p, err := b.Build() |
| 180 | if err != nil { |
| 181 | panic(fmt.Sprintf("plugin %q: %v", b.name, err)) |
| 182 | } |
| 183 | return p |
| 184 | } |
| 185 | |
| 186 | // validateHookName checks the grammar and uniqueness; returns false |
| 187 | // when the name was rejected (caller skips the action). |