go: Modernize codebase with go fix
diff --git a/lib/go/test/tests/gotag_test.go b/lib/go/test/tests/gotag_test.go
index b7ad17b..f65362f 100644
--- a/lib/go/test/tests/gotag_test.go
+++ b/lib/go/test/tests/gotag_test.go
@@ -27,8 +27,7 @@
)
func TestDefaultTag(t *testing.T) {
- s := gotagtest.Tagged{}
- st := reflect.TypeOf(s)
+ st := reflect.TypeFor[gotagtest.Tagged]()
field, ok := st.FieldByName("StringThing")
if !ok || field.Tag.Get("json") != "string_thing" {
t.Error("Unexpected default tag value")
@@ -36,8 +35,7 @@
}
func TestCustomTag(t *testing.T) {
- s := gotagtest.Tagged{}
- st := reflect.TypeOf(s)
+ st := reflect.TypeFor[gotagtest.Tagged]()
field, ok := st.FieldByName("IntThing")
if !ok {
t.Error("Missing field IntThing")
@@ -53,8 +51,7 @@
}
func TestOptionalTag(t *testing.T) {
- s := gotagtest.Tagged{}
- st := reflect.TypeOf(s)
+ st := reflect.TypeFor[gotagtest.Tagged]()
field, ok := st.FieldByName("OptionalIntThing")
if !ok || field.Tag.Get("json") != "optional_int_thing,omitempty" {
t.Error("Unexpected default tag value for optional field")
@@ -62,8 +59,7 @@
}
func TestOptionalTagWithDefaultValue(t *testing.T) {
- s := gotagtest.Tagged{}
- st := reflect.TypeOf(s)
+ st := reflect.TypeFor[gotagtest.Tagged]()
field, ok := st.FieldByName("OptionalBoolThing")
if !ok || field.Tag.Get("json") != "optional_bool_thing" {
t.Error("Unexpected default tag value for optional field that has a default value")
diff --git a/lib/go/test/tests/ignoreinitialisms_test.go b/lib/go/test/tests/ignoreinitialisms_test.go
index c7012dd..5eacc2c 100644
--- a/lib/go/test/tests/ignoreinitialisms_test.go
+++ b/lib/go/test/tests/ignoreinitialisms_test.go
@@ -27,8 +27,7 @@
)
func TestIgnoreInitialismsFlagIsHonoured(t *testing.T) {
- s := ignoreinitialismstest.IgnoreInitialismsTest{}
- st := reflect.TypeOf(s)
+ st := reflect.TypeFor[ignoreinitialismstest.IgnoreInitialismsTest]()
_, ok := st.FieldByName("Id")
if !ok {
t.Error("Id attribute is missing!")
diff --git a/lib/go/test/tests/initialisms_test.go b/lib/go/test/tests/initialisms_test.go
index e6b4f63..fcf7a59 100644
--- a/lib/go/test/tests/initialisms_test.go
+++ b/lib/go/test/tests/initialisms_test.go
@@ -27,8 +27,7 @@
)
func TestThatCommonInitialismsAreFixed(t *testing.T) {
- s := initialismstest.InitialismsTest{}
- st := reflect.TypeOf(s)
+ st := reflect.TypeFor[initialismstest.InitialismsTest]()
_, ok := st.FieldByName("UserID")
if !ok {
t.Error("UserID attribute is missing!")
diff --git a/lib/go/test/tests/names_test.go b/lib/go/test/tests/names_test.go
index 5094bcb..ebf3559 100644
--- a/lib/go/test/tests/names_test.go
+++ b/lib/go/test/tests/names_test.go
@@ -27,8 +27,7 @@
)
func TestThatAttributeNameSubstituionDoesNotOccur(t *testing.T) {
- s := namestest.NamesTest{}
- st := reflect.TypeOf(s)
+ st := reflect.TypeFor[namestest.NamesTest]()
_, ok := st.FieldByName("Type")
if !ok {
t.Error("Type attribute is missing!")
diff --git a/lib/go/test/tests/processor_middleware_test.go b/lib/go/test/tests/processor_middleware_test.go
index aedd93f..c53aaeb 100644
--- a/lib/go/test/tests/processor_middleware_test.go
+++ b/lib/go/test/tests/processor_middleware_test.go
@@ -92,11 +92,9 @@
server.Stop()
})
var wg sync.WaitGroup
- wg.Add(1)
- go func() {
- defer wg.Done()
+ wg.Go(func() {
server.Serve()
- }()
+ })
time.Sleep(10 * time.Millisecond)
diff --git a/lib/go/test/tests/thrifttest_driver.go b/lib/go/test/tests/thrifttest_driver.go
index 29ccd53..0f0044a 100644
--- a/lib/go/test/tests/thrifttest_driver.go
+++ b/lib/go/test/tests/thrifttest_driver.go
@@ -150,7 +150,7 @@
}
mapout := make(map[int32]int32)
- for i := int32(0); i < 5; i++ {
+ for i := range int32(5) {
mapout[i] = i - 10
}
if r, err := client.TestMap(defaultCtx, mapout); !reflect.DeepEqual(r, mapout) || err != nil {
diff --git a/lib/go/test/tests/validate_test.go b/lib/go/test/tests/validate_test.go
index 52e059a..57c12f0 100644
--- a/lib/go/test/tests/validate_test.go
+++ b/lib/go/test/tests/validate_test.go
@@ -482,7 +482,7 @@
if err != nil {
t.Error(err)
}
- jsonMap := make(map[string]interface{})
+ jsonMap := make(map[string]any)
if err = json.Unmarshal(b, &jsonMap); err != nil {
t.Error(err)
}