[exp] event: replace deprecated reflect.StringHeader

1 view
Skip to first unread message

Florian Lehner (Gerrit)

unread,
5:02 AM (10 hours ago) 5:02 AM
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Florian Lehner has uploaded the change for review

Commit message

event: replace deprecated reflect.StringHeader

reflect.StringHeader was declared deprecated with Go 1.21. Replace its
use with functionality from package unsafe.
Change-Id: I7007de5d850c4f38eb1f7904ba55009e5a223745

Change diff

diff --git a/event/label.go b/event/label.go
index 57307cc..1237c3d 100644
--- a/event/label.go
+++ b/event/label.go
@@ -103,8 +103,7 @@

// String returns a new Value for a string.
func String(name string, s string) Label {
- hdr := (*reflect.StringHeader)(unsafe.Pointer(&s))
- return Label{Name: name, packed: uint64(hdr.Len), untyped: stringptr(hdr.Data)}
+ return Label{Name: name, packed: uint64(len(s)), untyped: stringptr(unsafe.StringData(s))}
}

// String returns the value as a string.
@@ -112,11 +111,7 @@
// representation of the value in all cases.
func (v Label) String() string {
if sp, ok := v.untyped.(stringptr); ok {
- var s string
- hdr := (*reflect.StringHeader)(unsafe.Pointer(&s))
- hdr.Data = uintptr(sp)
- hdr.Len = int(v.packed)
- return s
+ return unsafe.String((*byte)(unsafe.Pointer(sp)), int(v.packed))
}
// not a string, convert to one
switch {

Change information

Files:
  • M event/label.go
Change size: XS
Delta: 1 file changed, 2 insertions(+), 7 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: exp
Gerrit-Branch: master
Gerrit-Change-Id: I7007de5d850c4f38eb1f7904ba55009e5a223745
Gerrit-Change-Number: 743001
Gerrit-PatchSet: 1
Gerrit-Owner: Florian Lehner <lehner.f...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Sean Liao (Gerrit)

unread,
7:50 AM (7 hours ago) 7:50 AM
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Florian Lehner

Sean Liao voted

Auto-Submit+1
Code-Review+2
Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Florian Lehner
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: exp
Gerrit-Branch: master
Gerrit-Change-Id: I7007de5d850c4f38eb1f7904ba55009e5a223745
Gerrit-Change-Number: 743001
Gerrit-PatchSet: 1
Gerrit-Owner: Florian Lehner <lehner.f...@gmail.com>
Gerrit-Reviewer: Sean Liao <se...@liao.dev>
Gerrit-Attention: Florian Lehner <lehner.f...@gmail.com>
Gerrit-Comment-Date: Sat, 07 Feb 2026 12:50:38 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages