Skip to content

Commit 52de27c

Browse files
committed
add demo for go1.14-examples and upgrade go version to go1.14 for go.mod
1 parent e2ddc3d commit 52de27c

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/bigwhite/experiments
22

3-
go 1.12
3+
go 1.14
44

55
require (
66
github.com/bigwhite/gocmpp v0.0.0-20190917110902-55b5d3d9ff3b

go1.14-examples/compiler_checkptr1.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"unsafe"
6+
)
7+
8+
func main() {
9+
var byteArray = [10]byte{'a', 'b', 'c'}
10+
var p *int64 = (*int64)(unsafe.Pointer(&byteArray[1]))
11+
fmt.Println(*p)
12+
}

go1.14-examples/compiler_checkptr2.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package main
2+
3+
import (
4+
"unsafe"
5+
)
6+
7+
func main() {
8+
var n = 5
9+
b := make([]byte, n)
10+
end := unsafe.Pointer(uintptr(unsafe.Pointer(&b[0])) + uintptr(n+10))
11+
_ = end
12+
}

0 commit comments

Comments
 (0)