chore: modernize Go 1.26, update deps, fix lint issues

- Update Go version from 1.19 to 1.26
- Update all dependencies to latest versions
- Fix staticcheck warnings (unused vars, types, functions)
- Remove unused svgToPng function
- Add GitHub Actions CI workflow
This commit is contained in:
2026-02-23 17:27:51 +00:00
parent b165dc219c
commit 8f8735d5a8
8 changed files with 160 additions and 355 deletions

View File

@@ -4,29 +4,17 @@ import (
"bufio"
"bytes"
"fmt"
"image"
"image/png"
"os"
"sync"
"time"
svg "github.com/ajstarks/svgo"
"github.com/srwiley/oksvg"
"github.com/srwiley/rasterx"
sc "github.com/taigrr/simplecolorpalettes/simplecolor"
"github.com/taigrr/gico/graph/common"
)
var (
colorsLoaded sync.Once
colorScheme []sc.SimpleColor
)
func GetWeekSVG(frequencies []int, shouldHighlight bool) bytes.Buffer {
squareColors := []sc.SimpleColor{}
min, max := common.MinMax(frequencies)
// fmt.Println(frequencies)
for _, f := range frequencies {
squareColors = append(squareColors, common.ColorForFrequency(f, min, max))
}
@@ -81,36 +69,7 @@ func drawYearImage(c []sc.SimpleColor, freq []int, shouldHighlight bool) bytes.B
}
canvas.Square(2*squareLength+width/(len(c)/7+1)*(i/7)+squareLength*2, squareLength/2+height/7*(i%7), squareLength, fmt.Sprintf("fill:%s; value:%d", s.ToHex(), freq[i]))
}
// canvas.Text(2*squareLength, squareLength*3, "Mon", fmt.Sprintf("text-anchor:middle;font-size:%dpx;fill:black", squareLength))
// canvas.Text(2*squareLength, int(float64(squareLength)*6.5), "Wed", fmt.Sprintf("text-anchor:middle;font-size:%dpx;fill:black", squareLength))
// canvas.Text(2*squareLength, int(float64(squareLength))*10, "Fri", fmt.Sprintf("text-anchor:middle;font-size:%dpx;fill:black", squareLength))
canvas.End()
sbw.Flush()
return sb
}
func svgToPng() {
w, h := 512, 512
in, err := os.Open("in.svg")
if err != nil {
panic(err)
}
defer in.Close()
icon, _ := oksvg.ReadIconStream(in)
icon.SetTarget(0, 0, float64(w), float64(h))
rgba := image.NewRGBA(image.Rect(0, 0, w, h))
icon.Draw(rasterx.NewDasher(w, h, rasterx.NewScannerGV(w, h, rgba, rgba.Bounds())), 1)
out, err := os.Create("out.png")
if err != nil {
panic(err)
}
defer out.Close()
err = png.Encode(out, rgba)
if err != nil {
panic(err)
}
}