You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2022/06/23 19:03:36 UTC
[pulsar-client-go] branch master updated: [github ci] add go 1.18 to the test matrix (#790)
This is an automated email from the ASF dual-hosted git repository.
mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-go.git
The following commit(s) were added to refs/heads/master by this push:
new cac144a [github ci] add go 1.18 to the test matrix (#790)
cac144a is described below
commit cac144a804be99d642c18973f3e743570b2a3dd6
Author: Paul Gier <pa...@datastax.com>
AuthorDate: Thu Jun 23 14:03:32 2022 -0500
[github ci] add go 1.18 to the test matrix (#790)
* add go 1.18 to the test matrix
Also upgrades the version of golint used, and upgrade the linters config to match
Signed-off-by: Paul Gier <pa...@datastax.com>
* lint: rename local map variable
Rename variable so the linter is happy
Signed-off-by: Paul Gier <pa...@datastax.com>
* lint: remove usage of unsafe ptr
Simplify code and remove lint warning regarding unsafe pointer usage
Signed-off-by: Paul Gier <pa...@datastax.com>
---
.github/workflows/go.yml | 2 +-
.github/workflows/project.yml | 4 ++--
.golangci.yml | 3 +--
pulsar/consumer_partition.go | 6 +++---
pulsar/schema.go | 10 +++-------
5 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index a3c4c60..1819b53 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- go-version: [1.15, 1.16, 1.17]
+ go-version: [1.15, 1.16, 1.17, 1.18]
steps:
- name: clean docker cache
run: |
diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml
index 810979a..ce8545b 100644
--- a/.github/workflows/project.yml
+++ b/.github/workflows/project.yml
@@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- go-version: [1.15, 1.16, 1.17]
+ go-version: [1.15, 1.16, 1.17, 1.18]
steps:
- name: Set up Go
uses: actions/setup-go@v1
@@ -19,7 +19,7 @@ jobs:
- name: InstallTool
run: |
- wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.18.0
+ wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.46.2
./bin/golangci-lint --version
- name: Build
diff --git a/.golangci.yml b/.golangci.yml
index e87841b..525d34c 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -10,10 +10,9 @@ linters:
- bodyclose
- deadcode
- goimports
- - golint
+ - revive
- gosimple
- govet
- - interfacer
- misspell
- structcheck
- stylecheck
diff --git a/pulsar/consumer_partition.go b/pulsar/consumer_partition.go
index b7c2c8e..1ddcc39 100644
--- a/pulsar/consumer_partition.go
+++ b/pulsar/consumer_partition.go
@@ -756,20 +756,20 @@ func createEncryptionContext(msgMeta *pb.MessageMetadata) *EncryptionContext {
encCtx.CompressionType = CompressionType(*msgMeta.Compression)
}
- kMap := map[string]EncryptionKey{}
+ keyMap := map[string]EncryptionKey{}
for _, k := range msgMeta.GetEncryptionKeys() {
metaMap := map[string]string{}
for _, m := range k.GetMetadata() {
metaMap[*m.Key] = *m.Value
}
- kMap[*k.Key] = EncryptionKey{
+ keyMap[*k.Key] = EncryptionKey{
KeyValue: k.GetValue(),
Metadata: metaMap,
}
}
- encCtx.Keys = kMap
+ encCtx.Keys = keyMap
return &encCtx
}
diff --git a/pulsar/schema.go b/pulsar/schema.go
index 2f18fad..42499ad 100644
--- a/pulsar/schema.go
+++ b/pulsar/schema.go
@@ -268,14 +268,10 @@ func (ss *StringSchema) Encode(v interface{}) ([]byte, error) {
return []byte(v.(string)), nil
}
+// Decode convert from byte slice to string without allocating a new string
func (ss *StringSchema) Decode(data []byte, v interface{}) error {
- bh := (*reflect.SliceHeader)(unsafe.Pointer(&data))
- sh := reflect.StringHeader{
- Data: bh.Data,
- Len: bh.Len,
- }
- shPtr := (*string)(unsafe.Pointer(&sh))
- reflect.ValueOf(v).Elem().Set(reflect.ValueOf(shPtr))
+ strPtr := (*string)(unsafe.Pointer(&data))
+ reflect.ValueOf(v).Elem().Set(reflect.ValueOf(strPtr))
return nil
}