You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd prefer to not expose two ways of doing the same thing in the API. Is there a particular reason why you want the maps?
One big advantage with the method we chose is that it uses widespread interfaces (https://pkg.go.dev/fmt#Stringer and https://pkg.go.dev/flag#Value), so a multicodec.Code will work out of the box with fmt.Println and flag.Var. Another advantage is that methods are tied to the type, whereas global maps aren't - and they could be modified as well, since Go doesn't have read-only maps.
So, overall, I'd ask if there's a good reason that what we have right now isn't enough :) It's true that "string to code" is one more line now, but you could also draw lines in the opposite direction, such as fmt.Println(cid.CodecToStr[code]) now being just fmt.Println(code) thanks to the String method.
https://github.com/ipfs/go-cid/pull/137/files is removing hardcoded mapping tables from
go-cid
,and we need a replacement for people who will be migrating to
go-multicodec
I want to document the best way way of doing string → code and code → string
My understanding is that:
Old way (go-cid)
New way (go-multicodec)
@mvdan any thoughts if this is good enough?
Should we add
StrToCodec
andCodecToStr
maps to go-multicodec, or is it not worth it?The text was updated successfully, but these errors were encountered: