From a35901b976571409d7ad57460aa41ee379d4025c Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Tue, 27 Jul 2021 00:34:53 -0500 Subject: [PATCH] Make hat selection a variable --- internal/haberdasherserver/server.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/haberdasherserver/server.go b/internal/haberdasherserver/server.go index 5df7aca..a9238e1 100644 --- a/internal/haberdasherserver/server.go +++ b/internal/haberdasherserver/server.go @@ -66,6 +66,9 @@ func HatQueryToHatQueryModel(q *pb.HatQuery) HatQuery { } func (s *Server) MakeHat(ctx context.Context, size *pb.Size) (hat *pb.Hat, err error) { + var colors []string = []string{"white", "black", "red", "blue", "white"} + var names []string = []string{"bowler", "baseball cap", "top hat", "derby", "tricorne"} + st, _ := NewStore(s.DBPath, 0600, nil) defer st.Close() @@ -75,8 +78,8 @@ func (s *Server) MakeHat(ctx context.Context, size *pb.Size) (hat *pb.Hat, err e h := Hat{ Inches: size.Inches, - Color: []string{"white", "black", "red", "blue"}[rand.Intn(4)], - Name: []string{"bowler", "baseball cap", "top hat", "derby"}[rand.Intn(3)], + Color: colors[rand.Intn(len(colors))], + Name: names[rand.Intn(len(names))], } fmt.Printf("made hat: %+v\n", h)