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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/34100c93-63d9-43b9-a36c-bf2aaf324c21n%40googlegroups.com.