Hi Axel Thanks for the two improvements above that enhances the safety of the `unsafe` approach. Fortunately, the `type T = U` captures my intention sufficiently, and the main motivation for posting this discussion was to solicit suggestions to help me remove my uses of `unsafe`. (to this end this post has fulfilled its mission, and many thanks for everyone chiming in : ) )
Perhaps the Go team has indeed made the correct decision in rejected issue 71183, and it is really my problem coming from a C background. I was perhaps too glued to C's type alias syntax `type T U`, and haven't truly internalized Go's way of doing things. Nonetheless, I believe raising awareness to the `type T = U` trick is indeed necessary, as the decade old way of doing this conversion has always been `unsafe`. In fact, the situation has now deteriorated to point where both Chatgpt and Gemini are now parroting the `unsafe` way of doing things. p.s. Axel, sorry for mistyping your name in my previous post, I strive to spell it correctly in the future On Saturday, December 20, 2025 at 2:34:00 PM UTC+8 Axel Wagner wrote: > > I believe at least for most cases, Henry's approach above is the correct > solution, and this truly needs to be documented somewhere for further > reference. > > I thought about suggesting that, but I was assuming you where using a type > definition because you wanted the types to be different (e.g. to put > methods on it, or just for safety). > -- 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]. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/e68a2402-de63-495b-829f-a2b490083bc6n%40googlegroups.com.
