Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToString ¶
BytesToString casts src to a string without extra memory allocation. The string returned by this function shares memory with "src".
Example ¶
package main
import (
"fmt"
"github.com/grailbio/base/unsafe"
)
func main() {
fmt.Println(unsafe.BytesToString([]byte{'A', 'b', 'C'}))
}
Output: AbC
func ExtendBytes ¶
ExtendBytes extends the given byte slice, without zero-initializing the new storage space. The caller must guarantee that cap(d) >= newLen (using e.g. a Grow() call on the parent buffer).
Example ¶
package main
import (
"fmt"
"github.com/grailbio/base/unsafe"
)
func main() {
d := []byte{'A', 'b', 'C'}
d = d[:1]
unsafe.ExtendBytes(&d, 2)
fmt.Println(d)
}
Output: [65 98]
func StringToBytes ¶
StringToBytes casts src to []byte without extra memory allocation. The data returned by this function shares memory with "src".
Example ¶
package main
import (
"fmt"
"github.com/grailbio/base/unsafe"
)
func main() {
fmt.Println(unsafe.StringToBytes("AbC"))
}
Output: [65 98 67]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.