From b5b0827c4b46ae01e90ffb0c9dd03f21c522cb33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CMichael?= Date: Thu, 25 Oct 2018 15:42:53 -0500 Subject: [PATCH] fixed go lint concerns in code no logic chages --- shape/circle.go | 3 +++ shape/rectangle.go | 3 +++ shape/triangle.go | 2 ++ shape_test.go | 10 +++++----- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/shape/circle.go b/shape/circle.go index 81ced9e..4788b4a 100644 --- a/shape/circle.go +++ b/shape/circle.go @@ -2,14 +2,17 @@ package shape import "math" +// Circle is a round thing type Circle struct { Radius float64 } +//CalculateArea is a function to calculate ... hmm let's see Area func (circle Circle) CalculateArea() float64 { return math.Pi * circle.Radius } +// CalculatePerimeter is a function that does the geometric math for a permiter func (circle Circle) CalculatePerimeter() float64 { return 2 * math.Pi * circle.Radius } diff --git a/shape/rectangle.go b/shape/rectangle.go index e469567..0848862 100644 --- a/shape/rectangle.go +++ b/shape/rectangle.go @@ -1,14 +1,17 @@ package shape +// Rectangle is a sqaure like thingy type Rectangle struct { Width float64 Height float64 } +//CalculateArea is a function to calculate ... hmm let's see Area func (rectangle Rectangle) CalculateArea() float64 { return rectangle.Width * rectangle.Height } +// CalculatePerimeter is a function that does the geometric math for a permiter func (rectangle Rectangle) CalculatePerimeter() float64 { return rectangle.Width*2 + rectangle.Height*2 } diff --git a/shape/triangle.go b/shape/triangle.go index 1bb1a98..5262c32 100644 --- a/shape/triangle.go +++ b/shape/triangle.go @@ -1,10 +1,12 @@ package shape +// Triangle has three points of fun type Triangle struct { Base float64 Height float64 } +// CalculateArea is a function to calculate ... hmm let's see Area func (triangle Triangle) CalculateArea() float64 { return triangle.Height * triangle.Base / 2.0 } diff --git a/shape_test.go b/shape_test.go index 47d6993..a48e7a9 100644 --- a/shape_test.go +++ b/shape_test.go @@ -15,12 +15,12 @@ func TestPerimeter(t *testing.T) { } t.Run("rectangles", func(t *testing.T) { - rectangle := shape.Rectangle{10.0, 10.0} + rectangle := shape.Rectangle{Width: 10.0, Height:10.0} checkPerimeter(t, rectangle, 40.0) }) t.Run("circles", func(t *testing.T) { - circle := shape.Circle{10.0} + circle := shape.Circle{Radius: 10.0} checkPerimeter(t, circle, 62.83185307179586) }) } @@ -35,17 +35,17 @@ func TestArea(t *testing.T) { } t.Run("rectangles", func(t *testing.T) { - rectangle := shape.Rectangle{12, 6} + rectangle := shape.Rectangle{Width:12, Height:6} checkArea(t, rectangle, 72.0) }) t.Run("circles", func(t *testing.T) { - circle := shape.Circle{10.0} + circle := shape.Circle{Radius:10.0} checkArea(t, circle, 31.41592653589793) }) t.Run("triangles", func(t *testing.T) { - triangle := shape.Triangle{10.0, 10.0} + triangle := shape.Triangle{Base:10.0, Height:10.0} checkArea(t, triangle, 50) }) }