On Mon, Jun 14, 2021 at 11:42 AM peterGo <
go.pe...@gmail.com> wrote:
>
> Amit,
>
> Compilers implement a specification:
>
> The Go Programming Language Specification
>
https://golang.org/ref/spec
>
> Conversions
>
> A conversion changes the type of an expression to the type specified by the conversion. A conversion may appear literally in the source, or it may be implied by the context in which an expression appears.
>
> Conversions to and from a string type
>
> 4. Converting a value of a string type to a slice of bytes type yields a slice whose successive elements are the bytes of the string.
>
> []byte("hellø") // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'}
> []byte("") // []byte{}
>
> MyBytes("hellø") // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'}
>
> Peter
>
> On Sunday, June 13, 2021 at 8:24:57 PM UTC-4
amits...@gmail.com wrote:
>>
>> Hi - My main motivation to understand this is i always had to google
>> this - how to convert a string to a byte slice.
>>
>> Is []byte a type that has been defined in the compiler?
>>
>> Or, is that an internal level detail that an earlier stage (parsing)
>> takes care of when the compiler sees that statement?
>>
>> Thanks,
>> Amit
>
> --
> 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...@googlegroups.com.