summaryrefslogtreecommitdiffstats
path: root/test/unsafe_string.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/unsafe_string.go')
-rw-r--r--test/unsafe_string.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/unsafe_string.go b/test/unsafe_string.go
new file mode 100644
index 0000000..ceecc6f
--- /dev/null
+++ b/test/unsafe_string.go
@@ -0,0 +1,18 @@
+// run
+
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ "unsafe"
+)
+
+func main() {
+ hello := [5]byte{'m', 'o', 's', 'h', 'i'}
+ if unsafe.String(&hello[0], uint64(len(hello))) != "moshi" {
+ panic("unsafe.String convert error")
+ }
+}