From b62fb9916a9c092b121082c899c5ec10c00a5e3e Mon Sep 17 00:00:00 2001 From: Nicholas Jones Date: Fri, 6 Dec 2024 15:55:42 +0000 Subject: [PATCH] Use accessor functions --- cmd/client/main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/client/main.go b/cmd/client/main.go index 4a88a51..82d15ac 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -118,11 +118,13 @@ func run(ctx context.Context, cfg config, message string) error { return err } - fmt.Printf("response from server: %s\n", res.Message) + fmt.Printf("response from server: %s\n", res.GetMessage()) - fmt.Println("metadata from server:") - for _, item := range res.Metadata.Items { - fmt.Printf("%s: %s\n", item.Key, strings.Join(item.Values, ", ")) + if metadata := res.GetMetadata(); metadata != nil { + fmt.Println("metadata from server:") + for _, item := range metadata.GetItems() { + fmt.Printf("%s: %s\n", item.Key, strings.Join(item.Values, ", ")) + } } return nil