Documentation
¶
Overview ¶
Package convert is collections method to convert types.
Now we supported types: - string <-> bytes
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bytes2String ¶
Bytes2String converts byte slice to a string without memory allocation. See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .
Note it may break if string and/or slice header will change in the future go versions.
Example ¶
package main import ( "fmt" "github.com/jiusanzhou/knife-go/convert" ) func main() { fmt.Println(convert.Bytes2String([]byte{59})) }
Output:
func String2Bytes ¶
String2Bytes converts string to a byte slice without memory allocation.
Note it may break if string and/or slice header will change in the future go versions.
Example ¶
package main import ( "fmt" "github.com/jiusanzhou/knife-go/convert" ) func main() { fmt.Println(convert.String2Bytes("Hello knife-go!")) }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.