Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ff946b
commit 7497e46
Showing
3 changed files
with
51 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// +build appengine | ||
|
||
package msgpack | ||
|
||
// bytesToString converts byte slice to string. | ||
func bytesToString(b []byte) string { | ||
return string(b) | ||
} | ||
|
||
// stringToBytes converts string to byte slice. | ||
func stringToBytes(s string) []byte { | ||
return []byte(s) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// +build !appengine | ||
|
||
package msgpack | ||
|
||
import ( | ||
"unsafe" | ||
) | ||
|
||
// bytesToString converts byte slice to string. | ||
func bytesToString(b []byte) string { | ||
return *(*string)(unsafe.Pointer(&b)) | ||
} | ||
|
||
// stringToBytes converts string to byte slice. | ||
func stringToBytes(s string) []byte { | ||
return *(*[]byte)(unsafe.Pointer( | ||
&struct { | ||
string | ||
Cap int | ||
}{s, len(s)}, | ||
)) | ||
} |