Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToBytes ¶
ToBytes will quickly return a []byte representation of a string without allocating new memory or having to copy data. Converting a string -> []byte will result in an immutable byte slice. Editing will cause a panic.
Example ¶
var s = "Hello Planet" b := ToBytes(s) fmt.Printf("%s\n", "J"+string(b[1:]))
Output: Jello Planet
func ToString ¶
ToString will quickly return a string representation of a []byte without allocating new memory or having to copy data. Converting a []byte -> string will result in a mutable string. Editing the originial bytes will change the string too.
Example ¶
var b = []byte("Hello Planet") s := ToString(b) b[0] = 'J' fmt.Printf("%s\n", s)
Output: Jello Planet
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.