mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 16:58:31 +02:00
refactor: modernize code with go fix
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -623,13 +624,7 @@ func TestAllFields(t *testing.T) {
|
||||
require.Len(t, AllFields, len(expectedFields), "Expected %d fields", len(expectedFields))
|
||||
|
||||
for _, expected := range expectedFields {
|
||||
found := false
|
||||
for _, actual := range AllFields {
|
||||
if actual == expected {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
found := slices.Contains(AllFields, expected)
|
||||
assert.True(t, found, "Expected field %s not found in AllFields", expected)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,9 +94,9 @@ var staticRespVarSubsMap = map[string]respVarGetter{
|
||||
}
|
||||
|
||||
func stripFragment(s string) string {
|
||||
idx := strings.IndexByte(s, '#')
|
||||
if idx == -1 {
|
||||
before, _, ok := strings.Cut(s, "#")
|
||||
if !ok {
|
||||
return s
|
||||
}
|
||||
return s[:idx]
|
||||
return before
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user