Skip to content

Commit

Permalink
chore(build): Bump dependency, golangci-lint, and use unsafe.Slice (
Browse files Browse the repository at this point in the history
#105)

Signed-off-by: Rajiv Singh <rajivperfect007@gmail.com>
  • Loading branch information
iamrajiv authored Aug 27, 2024
1 parent 5fa86be commit f6ad619
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ concurrency:

env:
# renovate: datasource=go depName=github.com/golangci/golangci-lint
GOLANGCI_LINT_VERSION: v1.52.2
GOLANGCI_LINT_VERSION: v1.60

jobs:
spellcheck:
name: Spell Check
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Check spelling of Go files
uses: crate-ci/typos@master
Expand All @@ -36,17 +36,17 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version-file: .go-version
check-latest: true
cache: true

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
args: --timeout 5m
Expand All @@ -55,10 +55,10 @@ jobs:
name: Go Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version-file: .go-version
check-latest: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version-file: .go-version
# More assembly might be required: Docker logins, GPG, etc. It all depends
# on your needs.
- uses: goreleaser/goreleaser-action@v4
- uses: goreleaser/goreleaser-action@v6
with:
# either 'goreleaser' (default) or 'goreleaser-pro':
distribution: goreleaser
Expand Down
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.20.4
1.22
11 changes: 7 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
run:
deadline: 7m
timeout: 5m
go: '1.20'
go: '1.22'

linters:
enable:
Expand All @@ -19,9 +19,12 @@ issues:

linters-settings:
depguard:
list-type: blacklist
include-go-root: true
packages-with-error-message: []
rules:
main:
list-mode: lax
deny:
- pkg: github.com/pkg/errors
desc: 'Use errors or fmt instead of github.com/pkg/errors'
errcheck:
goimports:
local-prefixes: github.com/stealthrocket/wzprof
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ builds:
- amd64
- arm64
ldflags:
- -X main.version={{.Version}}
- -X main.version={{.Version}}

release:
github:
Expand Down
4 changes: 1 addition & 3 deletions memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package wzprof

import (
"fmt"
"reflect"
"unsafe"
)

Expand Down Expand Up @@ -85,8 +84,7 @@ func derefArray[T any](r vmem, p ptr, n uint32) []T {
// 64-bits.
func derefGoSlice[T any](r vmem, s []T) []T {
count := len(s)
sh := (*reflect.SliceHeader)(unsafe.Pointer(&s))
dp := ptr64(sh.Data)
dp := ptr64(uintptr(unsafe.Pointer(unsafe.SliceData(s)))) // Convert to uintptr first, then to ptr64
res := make([]T, count)
for i := 0; i < count; i++ {
res[i] = derefArrayIndex[T](r, dp, int32(i))
Expand Down

0 comments on commit f6ad619

Please sign in to comment.