From f4fb2153b840be2732f5c3706525121304e4d65c Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Fri, 2 Mar 2018 14:59:27 +0000 Subject: [PATCH] protoio: Use keyed fields in composite literal In the protoio tests, we were using unkeyed fields in some composite literals. This can cause confusion and makes the code more brittle wrt. future changes. go vet also complains about this. This patch fixes the issue by adding the field names to the struct initializations. --- internal/protoio/protoio_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/protoio/protoio_test.go b/internal/protoio/protoio_test.go index c827a84..f917ffb 100644 --- a/internal/protoio/protoio_test.go +++ b/internal/protoio/protoio_test.go @@ -11,7 +11,7 @@ import ( func TestBin(t *testing.T) { dir := testlib.MustTempDir(t) defer testlib.RemoveIfOk(t, dir) - pb := &testpb.M{"hola"} + pb := &testpb.M{Content: "hola"} if err := WriteMessage("f", pb, 0600); err != nil { t.Error(err) @@ -29,7 +29,7 @@ func TestBin(t *testing.T) { func TestText(t *testing.T) { dir := testlib.MustTempDir(t) defer testlib.RemoveIfOk(t, dir) - pb := &testpb.M{"hola"} + pb := &testpb.M{Content: "hola"} if err := WriteTextMessage("f", pb, 0600); err != nil { t.Error(err) @@ -56,7 +56,7 @@ func TestStore(t *testing.T) { t.Errorf("expected no ids, got %v - %v", ids, err) } - pb := &testpb.M{"hola"} + pb := &testpb.M{Content: "hola"} if err := st.Put("f", pb); err != nil { t.Error(err)