From 16d569c457fb201865279e2e42ed32e9b2e2e1fc Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Fri, 5 Apr 2024 20:25:44 +0200 Subject: [PATCH] Code cleanup --- icons/ghicons.go | 8 ++++---- icons/icons.go | 6 +++--- icons/idicons.go | 2 +- icons/idicons_test.go | 8 ++++---- idicon_test.go | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/icons/ghicons.go b/icons/ghicons.go index 61235a2..6a79695 100644 --- a/icons/ghicons.go +++ b/icons/ghicons.go @@ -87,10 +87,10 @@ func hslToRgba(hue float32, sat float32, lum float32) color.RGBA { t1 := lum*2.0 - t2 return color.RGBA{ - uint8(hueToRgb(t1, t2, hue+1.0/3.0) * 255), - uint8(hueToRgb(t1, t2, hue) * 255), - uint8(hueToRgb(t1, t2, hue-1.0/3.0) * 255), - 0xff, + R: uint8(hueToRgb(t1, t2, hue+1.0/3.0) * 255), + G: uint8(hueToRgb(t1, t2, hue) * 255), + B: uint8(hueToRgb(t1, t2, hue-1.0/3.0) * 255), + A: 0xff, } } diff --git a/icons/icons.go b/icons/icons.go index 755975d..4b857fc 100644 --- a/icons/icons.go +++ b/icons/icons.go @@ -31,10 +31,10 @@ func HashBytes(id string) [16]byte { func mirrorData(data []bool, blocks int) []bool { for x := 0; x < blocks; x++ { - min := x*blocks + 1 + minBlock := x*blocks + 1 for y := 0; y < blocks; y++ { a := ((blocks - x - 1) * blocks) + y - b := min + y - 1 + b := minBlock + y - 1 if data[a] { data[b] = true } @@ -46,7 +46,7 @@ func mirrorData(data []bool, blocks int) []bool { func drawImage(data []bool, blocks int, size int, c color.Color) *image.NRGBA { img := image.NewNRGBA(image.Rect(0, 0, size, size)) - draw.Draw(img, img.Bounds(), &image.Uniform{color.Gray{240}}, image.Point{0, 0}, draw.Src) + draw.Draw(img, img.Bounds(), &image.Uniform{C: color.Gray{Y: 240}}, image.Point{X: 0, Y: 0}, draw.Src) blockSize := size / (blocks + 1) border := (size - (blocks * blockSize)) / 2 diff --git a/icons/idicons.go b/icons/idicons.go index 9d8ab0d..c3f9bc8 100644 --- a/icons/idicons.go +++ b/icons/idicons.go @@ -46,7 +46,7 @@ func ColorV1(hash [16]byte) color.RGBA { } else if b > r && b > g { b += 48 } - return color.RGBA{r, g, b, 255} + return color.RGBA{R: r, G: g, B: b, A: 255} } func ColorV2(hash [16]byte) color.RGBA { diff --git a/icons/idicons_test.go b/icons/idicons_test.go index 30e8f4c..0482d07 100644 --- a/icons/idicons_test.go +++ b/icons/idicons_test.go @@ -9,11 +9,11 @@ import ( func TestIgnoreCase(t *testing.T) { w1 := bytes.NewBuffer([]byte{}) ig1 := NewIdIconGenerator().WithColorGenerator(ColorV1) - png.Encode(w1, ig1.GenIcon("example", 80)) + _ = png.Encode(w1, ig1.GenIcon("example", 80)) w2 := bytes.NewBuffer([]byte{}) ig2 := NewIdIconGenerator().WithColorGenerator(ColorV1) - png.Encode(w2, ig2.GenIcon("Example", 80)) + _ = png.Encode(w2, ig2.GenIcon("Example", 80)) if bytes.Compare(w1.Bytes(), w2.Bytes()) != 0 { t.Errorf("resulting images do not match") @@ -24,11 +24,11 @@ func TestStringMatchesHash(t *testing.T) { w1 := bytes.NewBuffer([]byte{}) ig1 := NewIdIconGenerator().WithColorGenerator(ColorV2) // MD5 of lowercase 'example' - png.Encode(w1, ig1.GenIcon("1a79a4d60de6718e8e5b326e338ae533", 80)) + _ = png.Encode(w1, ig1.GenIcon("1a79a4d60de6718e8e5b326e338ae533", 80)) w2 := bytes.NewBuffer([]byte{}) ig2 := NewIdIconGenerator().WithColorGenerator(ColorV2) - png.Encode(w2, ig2.GenIcon("Example", 80)) + _ = png.Encode(w2, ig2.GenIcon("Example", 80)) if bytes.Compare(w1.Bytes(), w2.Bytes()) != 0 { t.Errorf("resulting images do not match") diff --git a/idicon_test.go b/idicon_test.go index e8c2d31..08e182f 100644 --- a/idicon_test.go +++ b/idicon_test.go @@ -112,8 +112,8 @@ func TestUsesConfig(t *testing.T) { } func TestUsesConfigWithEnvVar(t *testing.T) { - os.Setenv("COLORSCHEME", "v1") - os.Setenv("PATTERN", "default") + _ = os.Setenv("COLORSCHEME", "v1") + _ = os.Setenv("PATTERN", "default") configure("./testdata/testconfig.toml")