Skip to content

Commit ecf5051

Browse files
committed
feat: update to go 1.21
1 parent d7dfce6 commit ecf5051

File tree

4 files changed

+14
-23
lines changed

4 files changed

+14
-23
lines changed

broadcaster/group.go

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

33
import (
4-
"golang.org/x/exp/slices"
4+
"slices"
55
"sync"
66
)
77

@@ -108,7 +108,7 @@ func (v *Group[V]) Join() *Member[V] {
108108
// Leave removes specific group member and stop listening
109109
func (v *Group[V]) Leave(m *Member[V]) {
110110
v.m.Lock()
111-
index := slices.Index[*Member[V]](v.members, m)
111+
index := slices.Index(v.members, m)
112112
if index == -1 {
113113
return
114114
}

go.mod

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

3-
go 1.19
3+
go 1.21
44

5-
require (
6-
github.com/segmentio/encoding v0.3.6
7-
golang.org/x/exp v0.0.0-20230202154922-04ff78cf6831
8-
)
5+
require github.com/segmentio/encoding v0.3.6
96

107
require (
118
github.com/segmentio/asm v1.2.0 // indirect

go.sum

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc=
21
github.com/segmentio/asm v1.1.3/go.mod h1:Ld3L4ZXGNcSLRg4JBsZ3//1+f/TjYl0Mzen/DQy1EJg=
32
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
43
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
5-
github.com/segmentio/encoding v0.3.5 h1:UZEiaZ55nlXGDL92scoVuw00RmiRCazIEmvPSbSvt8Y=
6-
github.com/segmentio/encoding v0.3.5/go.mod h1:n0JeuIqEQrQoPDGsjo8UNd1iA0U8d8+oHAA4E3G3OxM=
74
github.com/segmentio/encoding v0.3.6 h1:E6lVLyDPseWEulBmCmAKPanDd3jiyGDo5gMcugCRwZQ=
85
github.com/segmentio/encoding v0.3.6/go.mod h1:n0JeuIqEQrQoPDGsjo8UNd1iA0U8d8+oHAA4E3G3OxM=
9-
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
10-
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
11-
golang.org/x/exp v0.0.0-20230202154922-04ff78cf6831 h1:iZbF4xrtZo29Xw86Wtlw2HLUvLVLDvj0K+1tcvKrGEA=
12-
golang.org/x/exp v0.0.0-20230202154922-04ff78cf6831/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
136
golang.org/x/sys v0.0.0-20211110154304-99a53858aa08/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
14-
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
15-
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
167
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
178
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

ubytes/unsafe.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
package ubytes
22

33
import (
4-
"reflect"
54
"unsafe"
65
)
76

8-
func ToBytes(s string) []byte {
9-
return (*[0x7fff0000]byte)(unsafe.Pointer(
10-
(*reflect.StringHeader)(unsafe.Pointer(&s)).Data),
11-
)[:len(s):len(s)]
7+
func ToBytes(str string) []byte {
8+
if str == "" {
9+
return nil
10+
}
11+
return unsafe.Slice(unsafe.StringData(str), len(str))
1212
}
1313

14-
func ToString(b []byte) string {
15-
return *(*string)(unsafe.Pointer(&b))
14+
func ToString(bs []byte) string {
15+
if len(bs) == 0 {
16+
return ""
17+
}
18+
return unsafe.String(unsafe.SliceData(bs), len(bs))
1619
}

0 commit comments

Comments
 (0)