From e2cf17ff804d7e5604269de82724ed3025cdccea Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Tue, 27 Jul 2021 18:00:35 -0500 Subject: [PATCH] Rename model conversion functions --- internal/haberdasherserver/server.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/haberdasherserver/server.go b/internal/haberdasherserver/server.go index a9238e1..0063cf0 100644 --- a/internal/haberdasherserver/server.go +++ b/internal/haberdasherserver/server.go @@ -34,7 +34,7 @@ type Store struct { db *bolt.DB } -func HatToHatModel(h *pb.Hat) Hat { +func PbToHatModel(h *pb.Hat) Hat { return Hat{ Inches: h.Inches, Color: h.Color, @@ -42,7 +42,7 @@ func HatToHatModel(h *pb.Hat) Hat { } } -func HatModelToHat(h Hat) *pb.Hat { +func HatModelToPb(h Hat) *pb.Hat { return &pb.Hat{ Inches: h.Inches, Color: h.Color, @@ -50,16 +50,16 @@ func HatModelToHat(h Hat) *pb.Hat { } } -func HatsModelToHats(hs []Hat) (hats *pb.Hats) { +func HatsModelToPb(hs []Hat) (hats *pb.Hats) { hats = &pb.Hats{} for _, h := range hs { - hat := HatModelToHat(h) + hat := HatModelToPb(h) hats.Hats = append(hats.Hats, hat) } return hats } -func HatQueryToHatQueryModel(q *pb.HatQuery) HatQuery { +func PbToHatQueryModel(q *pb.HatQuery) HatQuery { return HatQuery{ Limit: q.Limit, } @@ -86,16 +86,16 @@ func (s *Server) MakeHat(ctx context.Context, size *pb.Size) (hat *pb.Hat, err e st.SaveHat(h) - return HatModelToHat(h), nil + return HatModelToPb(h), nil } func (s *Server) ListHats(ctx context.Context, q *pb.HatQuery) (hats *pb.Hats, err error) { st, _ := NewStore(s.DBPath, 0600, nil) defer st.Close() - hs, err := st.ListHats(HatQueryToHatQueryModel(q)) + hs, err := st.ListHats(PbToHatQueryModel(q)) - return HatsModelToHats(hs), nil + return HatsModelToPb(hs), nil } func itob(v uint64) []byte {