Yes those I also use in init sometimes but then you are in control of your templates and regexes and things usually blow up quickly during development which makes you fix it promptly.
It is not quite the same though as I understood Peters question to be. The analogy would be the html/template to have an init function that would in turn panic. That seems much more sinister and hard to understand but maybe there are warranted cases, I don't know. ons 31 maj 2017 kl 21:41 skrev Pierre Durand <[email protected]>: > I use these functions in init(): > https://golang.org/pkg/html/template/#Must > https://golang.org/pkg/regexp/#MustCompile > > > Le mercredi 31 mai 2017 21:24:58 UTC+2, Peter Kleiweg a écrit : >> >> If a package can't be used because some precondition can't be fulfilled, >> you can use a panic. Then the whole program will crash at start-up. >> >> The alternative would be to not panic in the init, but have all function >> calls return an error. If the package is used in a large program, part of >> it may still be functional. >> >> Using panic in an init function of a package, do or don't? >> >> -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
