Skip to content

Commit 00b9209

Browse files
authored
Replace CirrusCI; update dependencies; use unsafe.Slice (awnumar#16)
* Remove cirrus-CI * Add github actions * Upgrade dependencies and go version * Use modern go compile directives * Replace Windows slice conversion with unsafe.Slice * Remove unused func * Fix missing import
1 parent ba2f6d6 commit 00b9209

7 files changed

Lines changed: 72 additions & 80 deletions

File tree

.cirrus.yml

Lines changed: 0 additions & 69 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
linux:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up Go
15+
uses: actions/setup-go@v5
16+
with:
17+
go-version: 'stable'
18+
- name: Build
19+
run: |
20+
go version
21+
go get ./...
22+
go build -race -v ./...
23+
- name: Test
24+
run: go test -race -v ./...
25+
- name: Bench
26+
run: go test -run=XXX -bench=. ./...
27+
28+
macos:
29+
runs-on: macos-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
- name: Set up Go
33+
uses: actions/setup-go@v5
34+
with:
35+
go-version: 'stable'
36+
- name: Build
37+
run: |
38+
go version
39+
go get ./...
40+
go build -race -v ./...
41+
- name: Test
42+
run: go test -race -v ./...
43+
- name: Bench
44+
run: go test -run=XXX -bench=. ./...
45+
46+
windows:
47+
runs-on: windows-latest
48+
steps:
49+
- uses: actions/checkout@v4
50+
- name: Set up Go
51+
uses: actions/setup-go@v5
52+
with:
53+
go-version: 'stable'
54+
- name: Install MinGW (for gcc)
55+
run: choco install -y mingw
56+
- name: Build
57+
run: |
58+
go version
59+
go get ./...
60+
$env:CGO_ENABLED=1; go build -race -v ./...
61+
- name: Test
62+
run: |
63+
$env:CGO_ENABLED=1; go test -race -v ./...
64+
- name: Bench
65+
run: go test -run=XXX -bench=. ./...

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module github.com/awnumar/memcall
22

3-
go 1.18
3+
go 1.23.0
44

5-
require golang.org/x/sys v0.20.0
5+
require golang.org/x/sys v0.35.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
2-
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
1+
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
2+
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=

memcall.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package memcall
22

33
import (
4-
"reflect"
54
"runtime"
65
"unsafe"
76
)
@@ -56,8 +55,3 @@ func _getStartPtr(b []byte) unsafe.Pointer {
5655
func _getPtr(b []byte) uintptr {
5756
return uintptr(_getStartPtr(b))
5857
}
59-
60-
func _getBytes(ptr uintptr, len int, cap int) []byte {
61-
var sl = reflect.SliceHeader{Data: ptr, Len: len, Cap: cap}
62-
return *(*[]byte)(unsafe.Pointer(&sl))
63-
}

memcall_solaris.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//go:build solaris
2+
23
package memcall
34

45
import (

memcall_windows.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package memcall
55
import (
66
"errors"
77
"fmt"
8+
"unsafe"
89

910
"golang.org/x/sys/windows"
1011
)
@@ -36,7 +37,7 @@ func Alloc(n int) ([]byte, error) {
3637
}
3738

3839
// Convert this pointer to a slice.
39-
b := _getBytes(ptr, n, n)
40+
b := unsafe.Slice((*byte)(unsafe.Pointer(ptr)), n)
4041

4142
// Wipe it just in case there is some remnant data.
4243
wipe(b)

0 commit comments

Comments
 (0)