On Sun, Feb 26, 2023 at 12:43 PM 'Dan Kortschak' via golang-nuts
<golang-nuts@googlegroups.com> wrote:
> The alternative is to
> replicate the image.Decode functionality, including registration which
> seems ugly.

It may seem ugly but that is what I'd recommend.
https://go.dev/src/image/format.go is only 110 lines of code.

In hindsight, I think the image.RegisterFormat API was a mistake,
being backed by global state that's modified by init functions you may
not be aware of (if in transitively imported packages).

These days, I'd create my own multiFormatImageDecoder that explicitly
listed its constituent single-format decoders. It would also be a
small amount of code, and could easily live outside of the stdlib.


> Would a change to
> image.RegisterFormat that did a replacement of existing registrations
> that are identical to a new registration rather than an append be
> entertained (I can see good reasons for a no here)?

I'd be unlikely to entertain it, due to https://www.hyrumslaw.com/

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOeFMNX6miKyca5Xp_v%2B4uvXft3fKxQmrk5Ab-LEveCtyYKDnA%40mail.gmail.com.

Reply via email to