File tree Expand file tree Collapse file tree 4 files changed +14
-23
lines changed Expand file tree Collapse file tree 4 files changed +14
-23
lines changed Original file line number Diff line number Diff line change 1
1
package broadcaster
2
2
3
3
import (
4
- "golang.org/x/exp/ slices"
4
+ "slices"
5
5
"sync"
6
6
)
7
7
@@ -108,7 +108,7 @@ func (v *Group[V]) Join() *Member[V] {
108
108
// Leave removes specific group member and stop listening
109
109
func (v * Group [V ]) Leave (m * Member [V ]) {
110
110
v .m .Lock ()
111
- index := slices .Index [ * Member [ V ]] (v .members , m )
111
+ index := slices .Index (v .members , m )
112
112
if index == - 1 {
113
113
return
114
114
}
Original file line number Diff line number Diff line change 1
1
module github.com/BOOMfinity/go-utils
2
2
3
- go 1.19
3
+ go 1.21
4
4
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
9
6
10
7
require (
11
8
github.com/segmentio/asm v1.2.0 // indirect
Original file line number Diff line number Diff line change 1
- github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc =
2
1
github.com/segmentio/asm v1.1.3 /go.mod h1:Ld3L4ZXGNcSLRg4JBsZ3//1+f/TjYl0Mzen/DQy1EJg =
3
2
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys =
4
3
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 =
7
4
github.com/segmentio/encoding v0.3.6 h1:E6lVLyDPseWEulBmCmAKPanDd3jiyGDo5gMcugCRwZQ =
8
5
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 =
13
6
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 =
16
7
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18 =
17
8
golang.org/x/sys v0.4.0 /go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg =
Original file line number Diff line number Diff line change 1
1
package ubytes
2
2
3
3
import (
4
- "reflect"
5
4
"unsafe"
6
5
)
7
6
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 ))
12
12
}
13
13
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 ))
16
19
}
You can’t perform that action at this time.
0 commit comments