Skip to content

Commit

Permalink
Update to go1.21.1
Browse files Browse the repository at this point in the history
Signed-off-by: Allen Ray <[email protected]>
  • Loading branch information
dusk125 committed Sep 14, 2023
1 parent ead6b85 commit 2298525
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/failpoint_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "1.20.7"
go-version: "1.21.1"
- run: |
make gofail-enable
make test-failpoint
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "1.20.7"
go-version: "1.21.1"
- run: make fmt
- env:
TARGET: ${{ matrix.target }}
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "1.20.7"
go-version: "1.21.1"
- run: make fmt
- env:
TARGET: ${{ matrix.target }}
Expand Down Expand Up @@ -94,6 +94,6 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "1.20.7"
go-version: "1.21.1"
- run: make coverage

2 changes: 1 addition & 1 deletion cmd/bbolt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
```bash
$bbolt version
bbolt version: 1.3.7
Go Version: go1.20.7
Go Version: go1.21.1
Go OS/Arch: darwin/arm64
```

Expand Down
4 changes: 2 additions & 2 deletions freelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,13 @@ func (f *freelist) write(p *common.Page) error {
p.SetCount(uint16(l))
var ids []common.Pgid
data := common.UnsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p))
common.UnsafeSlice(unsafe.Pointer(&ids), data, l)
ids = unsafe.Slice((*common.Pgid)(data), l)
f.copyall(ids)
} else {
p.SetCount(0xFFFF)
var ids []common.Pgid
data := common.UnsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p))
common.UnsafeSlice(unsafe.Pointer(&ids), data, l+1)
ids = unsafe.Slice((*common.Pgid)(data), l+1)
ids[0] = common.Pgid(l)
f.copyall(ids[1:])
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.etcd.io/bbolt

go 1.20
go 1.21

require (
github.com/spf13/cobra v1.7.0
Expand Down
6 changes: 3 additions & 3 deletions internal/common/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (p *Page) LeafPageElements() []leafPageElement {
}
var elems []leafPageElement
data := UnsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p))
UnsafeSlice(unsafe.Pointer(&elems), data, int(p.count))
elems = unsafe.Slice((*leafPageElement)(data), int(p.count))
return elems
}

Expand All @@ -118,7 +118,7 @@ func (p *Page) BranchPageElements() []branchPageElement {
}
var elems []branchPageElement
data := UnsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p))
UnsafeSlice(unsafe.Pointer(&elems), data, int(p.count))
elems = unsafe.Slice((*branchPageElement)(data), int(p.count))
return elems
}

Expand Down Expand Up @@ -151,7 +151,7 @@ func (p *Page) FreelistPageIds() []Pgid {

var ids []Pgid
data := UnsafeIndex(unsafe.Pointer(p), unsafe.Sizeof(*p), unsafe.Sizeof(ids[0]), idx)
UnsafeSlice(unsafe.Pointer(&ids), data, count)
ids = unsafe.Slice((*Pgid)(data), count)

return ids
}
Expand Down
12 changes: 0 additions & 12 deletions internal/common/unsafe.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package common

import (
"reflect"
"unsafe"
)

Expand All @@ -26,14 +25,3 @@ func UnsafeByteSlice(base unsafe.Pointer, offset uintptr, i, j int) []byte {
// all), so this is believed to be correct.
return (*[pageMaxAllocSize]byte)(UnsafeAdd(base, offset))[i:j:j]
}

// UnsafeSlice modifies the data, len, and cap of a slice variable pointed to by
// the slice parameter. This helper should be used over other direct
// manipulation of reflect.SliceHeader to prevent misuse, namely, converting
// from reflect.SliceHeader to a Go slice type.
func UnsafeSlice(slice, data unsafe.Pointer, len int) {
s := (*reflect.SliceHeader)(slice)
s.Data = uintptr(data)
s.Cap = len
s.Len = len
}

0 comments on commit 2298525

Please sign in to comment.