Happy to help. If you’re coming from C, Go’s "type Symbol = byte" is 
directly equivalent to C’s "typedef unsigned char Symbol". It does *not* 
create a new type; it’s purely a type alias.

By contrast, "type Symbol byte" defines a *new* and distinct type.

On Saturday, December 20, 2025 at 1:47:25 PM UTC+7 [email protected] wrote:

> 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/ab2c2c38-41ca-4ca3-ac56-ade972c2e2fan%40googlegroups.com.

Reply via email to