From bdcb20acb2ceb2a4944f806ca4b99061a6be1aa4 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sat, 28 Mar 2020 18:03:49 -0500 Subject: [PATCH] returning a pointer is not necessary --- color.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/color.go b/color.go index e458c51..3339cf8 100644 --- a/color.go +++ b/color.go @@ -77,12 +77,13 @@ var ( } ) -func NewRGBColor(r, g, b uint8) (*RGBColor, error) { +func NewRGBColor(r, g, b uint8) (RGBColor, error) { + var c RGBColor if (r < 0 || r > 255) && (g < 0 || r > 255) && (b < 0 || b > 255) { - return nil, errors.New("values must be between 0-255") + return c, errors.New("values must be between 0-255") } - return &RGBColor{R: r, G: g, B: b}, nil + return RGBColor{R: r, G: g, B: b}, nil } func NewHSColor(h, s float32) (HSBKColor, error) {