Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToByteSlice ¶
ToByteSlice returns the string s as a []byte. Note that cap in bs is set to the length of s. WARNING! bs uses the same memory as s and has therefore broken the immutability of the string s. This can lead to serious bugs, vulnerabilities or other errors if used incorrectly.
Example ¶
package main
import (
typehack "."
"fmt"
)
func main() {
s := "Hello, Gophers!"
fmt.Println("ToByteSlice:", typehack.ToByteSlice(s))
fmt.Println("Raw s:", s)
}
Output: ToByteSlice: [72 101 108 108 111 44 32 71 111 112 104 101 114 115 33] Raw s: Hello, Gophers!
func ToString ¶
ToString returns the []byte bs as a string. Note that the cap value from bs is discarded. WARNING! s uses the same memory as bs and is therfor not Immutable. This can lead to serious bugs, vulnerabilities or other errors if used incorrectly.
Example ¶
package main
import (
typehack "."
"fmt"
)
func main() {
bs := []byte("Hello, Gophers!")
fmt.Println("ToString:", typehack.ToString(bs))
fmt.Println("Raw bs:", bs)
}
Output: ToString: Hello, Gophers! Raw bs: [72 101 108 108 111 44 32 71 111 112 104 101 114 115 33]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.