Skip to content

Commit e509f3f

Browse files
committed
useragent: tweak from signature
1 parent 5a24a5b commit e509f3f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

useragent/from.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ import (
1717
// values which do not match the expected `{product}/{version} ({comment})`
1818
// pattern (where version and comment are optional) return a zero value struct.
1919
func FromSlice[T any](sl []T) config.UserAgentProducts {
20-
return slices.ApplyToAll(sl, func(v T) config.UserAgentProduct { return fromAny(v) })
20+
return slices.ApplyToAll(sl, func(v T) config.UserAgentProduct { return from(v) })
2121
}
2222

23-
func fromAny(v any) config.UserAgentProduct {
24-
if s, ok := v.(string); ok {
23+
func from[T any](v T) config.UserAgentProduct {
24+
if s, ok := any(v).(string); ok {
2525
parts := strings.Split(s, "/")
2626
switch len(parts) {
2727
case 1:

useragent/from_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func TestFromSlice(t *testing.T) {
6161
}
6262
}
6363

64-
func Test_fromAny(t *testing.T) {
64+
func Test_from(t *testing.T) {
6565
t.Parallel()
6666

6767
tests := []struct {
@@ -136,9 +136,9 @@ func Test_fromAny(t *testing.T) {
136136
for _, tt := range tests {
137137
t.Run(tt.name, func(t *testing.T) {
138138
t.Parallel()
139-
got := fromAny(tt.v)
139+
got := from(tt.v)
140140
if !reflect.DeepEqual(got, tt.want) {
141-
t.Errorf("fromAny() = %+v, want %+v", got, tt.want)
141+
t.Errorf("from() = %+v, want %+v", got, tt.want)
142142
}
143143
})
144144
}

0 commit comments

Comments
 (0)