Skip to content

Commit 0a919bd

Browse files
authored
ci(lint): update golangci (#13)
1 parent e245e6b commit 0a919bd

File tree

12 files changed

+122
-133
lines changed

12 files changed

+122
-133
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,24 @@ permissions:
1313
contents: read
1414

1515
jobs:
16-
golangci:
17-
name: lint
16+
test:
17+
name: Test
1818
runs-on: ubuntu-latest
1919
steps:
2020
- uses: actions/checkout@v4
21+
- uses: actions/setup-go@v5
2122
with:
22-
fetch-depth: 0
23+
go-version-file: go.mod
24+
- name: go mod tidy
25+
run: |
26+
go mod tidy
27+
if [ -n "$(git status --porcelain)" ]; then
28+
echo "Run 'go mod tidy' and push it"
29+
exit 1
30+
fi
2331
- name: golangci-lint
24-
uses: golangci/golangci-lint-action@v2
25-
26-
test:
27-
runs-on: ubuntu-latest
28-
steps:
29-
- name: Checkout source
30-
uses: actions/checkout@v4
31-
with:
32-
fetch-depth: 0
33-
34-
- name: Setup go
35-
uses: actions/setup-go@v4
32+
uses: golangci/golangci-lint-action@v8
3633
with:
37-
go-version: '>=1.17'
38-
39-
- name: Run tests
40-
run: go test -v ./...
34+
version: latest
35+
- name: Run unit tests
36+
run: go test -v ./...

.golangci.yml

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
version: "2"
2+
3+
formatters:
4+
enable:
5+
- goimports
6+
- gci
7+
- gofumpt
8+
19
linters:
210
enable:
311
- asciicheck
@@ -12,32 +20,34 @@ linters:
1220
- errname
1321
- errorlint
1422
- funlen
15-
- goimports
16-
- gci
1723
- goconst
18-
- gofumpt
1924
- gosec
2025
- lll
2126
- misspell
2227
- revive
2328
- unconvert
2429
- gosec
25-
26-
linters-settings:
27-
errcheck:
28-
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`.
29-
check-blank: true
30-
gosimple:
31-
# Select the Go version to target.
32-
go: "1.17"
33-
# https://staticcheck.io/docs/options#checks
34-
checks: ["all"]
35-
govet:
36-
check-shadowing: true
37-
staticcheck:
38-
go: "1.17"
39-
# https://staticcheck.io/docs/options#checks
40-
checks: ["all"]
41-
decorder:
42-
disable-dec-order-check: false
43-
disable-init-func-first-check: false
30+
exclusions:
31+
rules:
32+
- linters:
33+
- revive
34+
text: "exported (type|function|const|method) .* should have comment"
35+
- linters:
36+
- revive
37+
text: "should have a package comment"
38+
- linters:
39+
- govet
40+
text: "declaration of \"err\" shadows"
41+
settings:
42+
errcheck:
43+
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`.
44+
check-blank: true
45+
govet:
46+
enable:
47+
- shadow
48+
staticcheck:
49+
# https://staticcheck.io/docs/options#checks
50+
checks: ["all", "-ST1000"]
51+
decorder:
52+
disable-dec-order-check: false
53+
disable-init-func-first-check: false

cmd/termsvg/export/export.go

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package export
33
import (
44
"bytes"
55
"os"
6+
"path/filepath"
67

78
"github.com/mrmarble/termsvg/internal/svg"
89
"github.com/mrmarble/termsvg/pkg/asciicast"
@@ -37,7 +38,7 @@ func (cmd *Cmd) Run() error {
3738
}
3839

3940
func export(input, output string, mini bool, bgColor, textColor string, noWindow bool) error {
40-
inputFile, err := os.ReadFile(input)
41+
inputFile, err := os.ReadFile(filepath.Clean(input))
4142
if err != nil {
4243
return err
4344
}
@@ -47,31 +48,31 @@ func export(input, output string, mini bool, bgColor, textColor string, noWindow
4748
return err
4849
}
4950

50-
outputFile, err := os.Create(output)
51-
if err != nil {
52-
return err
53-
}
54-
defer outputFile.Close()
51+
out := new(bytes.Buffer)
52+
var data []byte
5553

54+
svg.Export(*cast, out, bgColor, textColor, noWindow)
5655
if mini {
57-
out := new(bytes.Buffer)
58-
svg.Export(*cast, out, bgColor, textColor, noWindow)
59-
6056
m := minify.New()
6157
m.AddFunc("image/svg+xml", msvg.Minify)
62-
6358
b, err := m.Bytes("image/svg+xml", out.Bytes())
6459
if err != nil {
6560
return err
6661
}
67-
68-
_, err = outputFile.Write(b)
69-
if err != nil {
70-
return err
71-
}
62+
data = b
7263
} else {
73-
svg.Export(*cast, outputFile, bgColor, textColor, noWindow)
64+
data = out.Bytes()
65+
}
66+
outputFile, err := os.Create(output)
67+
if err != nil {
68+
return err
69+
}
70+
_, err = outputFile.Write(data)
71+
if err != nil {
72+
//nolint:gosec,errcheck
73+
outputFile.Close()
74+
return err
7475
}
7576

76-
return nil
77+
return outputFile.Close()
7778
}

cmd/termsvg/play/play.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package play
33
import (
44
"fmt"
55
"os"
6+
"path/filepath"
67
"time"
78

89
"github.com/mrmarble/termsvg/pkg/asciicast"
@@ -19,7 +20,7 @@ func (cmd *Cmd) Run() error {
1920
}
2021

2122
func play(path string, idleCap, speed float64) error {
22-
file, err := os.ReadFile(path)
23+
file, err := os.ReadFile(filepath.Clean(path))
2324
if err != nil {
2425
return err
2526
}

cmd/termsvg/rec/rec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func rec(file, command string, skipFirstLine bool) error {
6666
return err
6767
}
6868

69-
err = os.WriteFile(file, js, os.ModePerm)
69+
err = os.WriteFile(file, js, 0o600)
7070
if err != nil {
7171
return err
7272
}

go.mod

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
module github.com/mrmarble/termsvg
22

3-
go 1.17
3+
go 1.23.0
4+
5+
toolchain go1.24.5
46

57
require (
68
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b
7-
github.com/creack/pty v1.1.21
9+
github.com/alecthomas/kong v1.12.0
10+
github.com/creack/pty v1.1.24
11+
github.com/google/go-cmp v0.7.0
812
github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02
9-
github.com/sebdah/goldie/v2 v2.5.3
10-
github.com/tdewolff/minify/v2 v2.20.16
11-
golang.org/x/term v0.17.0
13+
github.com/rs/zerolog v1.34.0
14+
github.com/sebdah/goldie/v2 v2.7.1
15+
github.com/tdewolff/minify/v2 v2.23.8
16+
golang.org/x/term v0.33.0
1217
)
1318

1419
require (
1520
github.com/mattn/go-colorable v0.1.13 // indirect
1621
github.com/mattn/go-isatty v0.0.19 // indirect
1722
github.com/pmezard/go-difflib v1.0.0 // indirect
18-
github.com/sergi/go-diff v1.3.1 // indirect
19-
github.com/tdewolff/parse/v2 v2.7.11 // indirect
20-
)
21-
22-
require (
23-
github.com/alecthomas/kong v0.8.1
24-
github.com/google/go-cmp v0.6.0
25-
github.com/rs/zerolog v1.32.0
26-
golang.org/x/sys v0.17.0 // indirect
23+
github.com/sergi/go-diff v1.0.0 // indirect
24+
github.com/tdewolff/parse/v2 v2.8.1 // indirect
25+
golang.org/x/sys v0.34.0 // indirect
2726
)

go.sum

Lines changed: 28 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,25 @@ github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm
33
github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk=
44
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b h1:slYM766cy2nI3BwyRiyQj/Ud48djTMtMebDqepE95rw=
55
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b/go.mod h1:1KcenG0jGWcpt8ov532z81sp/kMMUG485J2InIOyADM=
6-
github.com/alecthomas/assert/v2 v2.1.0 h1:tbredtNcQnoSd3QBhQWI7QZ3XHOVkw1Moklp2ojoH/0=
7-
github.com/alecthomas/assert/v2 v2.1.0/go.mod h1:b/+1DI2Q6NckYi+3mXyH3wFb8qG37K/DuK80n7WefXA=
8-
github.com/alecthomas/kong v0.8.1 h1:acZdn3m4lLRobeh3Zi2S2EpnXTd1mOL6U7xVml+vfkY=
9-
github.com/alecthomas/kong v0.8.1/go.mod h1:n1iCIO2xS46oE8ZfYCNDqdR0b0wZNrXAIAqro/2132U=
10-
github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE=
11-
github.com/alecthomas/repr v0.1.0/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
12-
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U=
6+
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
7+
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
8+
github.com/alecthomas/kong v1.12.0 h1:oKd/0fHSdajj5PfGDd3ScvEvpVJf9mT2mb5r9xYadYM=
9+
github.com/alecthomas/kong v1.12.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU=
10+
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
11+
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
1312
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
14-
github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0=
15-
github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
13+
github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
14+
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
15+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
1616
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
17-
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
18-
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
19-
github.com/djherbis/atime v1.1.0/go.mod h1:28OF6Y8s3NQWwacXc5eZTsEsiMzp7LF8MbXE+XJPdBE=
20-
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
21-
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
2217
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
23-
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
24-
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
18+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
19+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
2520
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
2621
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
2722
github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02 h1:AgcIVYPa6XJnU3phs104wLj8l5GEththEw6+F79YsIY=
2823
github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
2924
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
30-
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
31-
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
32-
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
33-
github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs=
3425
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
3526
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
3627
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
@@ -40,27 +31,22 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
4031
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
4132
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4233
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
43-
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
44-
github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
45-
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
46-
github.com/sebdah/goldie/v2 v2.5.3 h1:9ES/mNN+HNUbNWpVAlrzuZ7jE+Nrczbj8uFRjM7624Y=
47-
github.com/sebdah/goldie/v2 v2.5.3/go.mod h1:oZ9fp0+se1eapSRjfYbsV/0Hqhbuu3bJVvKI/NNtssI=
34+
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
35+
github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=
36+
github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
37+
github.com/sebdah/goldie/v2 v2.7.1 h1:PkBHymaYdtvEkZV7TmyqKxdmn5/Vcj+8TpATWZjnG5E=
38+
github.com/sebdah/goldie/v2 v2.7.1/go.mod h1:oZ9fp0+se1eapSRjfYbsV/0Hqhbuu3bJVvKI/NNtssI=
39+
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
4840
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
49-
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
50-
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
5141
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
42+
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
5243
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
53-
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
54-
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
55-
github.com/tdewolff/argp v0.0.0-20240126212256-acdb2fb50090/go.mod h1:fF+gnKbmf3iMG+ErLiF+orMU/InyZIEnKVVigUjfriw=
56-
github.com/tdewolff/minify/v2 v2.20.16 h1:/C8dtRkxLTIyUlKlBz46gDiktCrE8a6+c1gTrnPFz+U=
57-
github.com/tdewolff/minify/v2 v2.20.16/go.mod h1:/FvxV9KaTrFu35J9I2FhRvWSBxcHj8sDSdwBFh5voxM=
58-
github.com/tdewolff/parse/v2 v2.7.11 h1:v+W45LnzmjndVlfqPCT5gGjAAZKd1GJGOPJveTIkBY8=
59-
github.com/tdewolff/parse/v2 v2.7.11/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
60-
github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
61-
github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
62-
github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739 h1:IkjBCtQOOjIn03u/dMQK9g+Iw9ewps4mCl1nB8Sscbo=
63-
github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8=
44+
github.com/tdewolff/minify/v2 v2.23.8 h1:tvjHzRer46kwOfpdCBCWsDblCw3QtnLJRd61pTVkyZ8=
45+
github.com/tdewolff/minify/v2 v2.23.8/go.mod h1:VW3ISUd3gDOZuQ/jwZr4sCzsuX+Qvsx87FDMjk6Rvno=
46+
github.com/tdewolff/parse/v2 v2.8.1 h1:J5GSHru6o3jF1uLlEKVXkDxxcVx6yzOlIVIotK4w2po=
47+
github.com/tdewolff/parse/v2 v2.8.1/go.mod h1:Hwlni2tiVNKyzR1o6nUs4FOF07URA+JLBLd6dlIXYqo=
48+
github.com/tdewolff/test v1.0.11 h1:FdLbwQVHxqG16SlkGveC0JVyrJN62COWTRyUFzfbtBE=
49+
github.com/tdewolff/test v1.0.11/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8=
6450
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
6551
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
6652
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
@@ -76,14 +62,12 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
7662
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
7763
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
7864
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
79-
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
8065
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
8166
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
82-
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
83-
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
84-
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
85-
golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U=
86-
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
67+
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
68+
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
69+
golang.org/x/term v0.33.0 h1:NuFncQrRcaRvVmgRkvM3j/F00gWIAlcmlB8ACEKmGIg=
70+
golang.org/x/term v0.33.0/go.mod h1:s18+ql9tYWp1IfpV9DmCtQDDSRBUjKaw9M1eAv5UeF0=
8771
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
8872
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
8973
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -92,9 +76,4 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
9276
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
9377
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
9478
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
95-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
96-
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
97-
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
98-
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
99-
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
10079
honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=

internal/svg/svg.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ func createCanvas(svg *svg.SVG, cast asciicast.Cast, noWindow bool) {
6565
} else {
6666
canvas.Rect(0, 0, canvas.paddedWidth(), canvas.paddedHeight(), "fill:"+backgroundColorOverride)
6767
}
68-
//nolint:gomnd
6968
canvas.Group(fmt.Sprintf(`transform="translate(%d,%d)"`, padding, int(padding*1.5)))
7069
}
7170
canvas.addStyles()
@@ -152,7 +151,7 @@ func (c *Canvas) addStyles() {
152151
colors = append(colors, css.Block{Selector: fmt.Sprintf(".%s", class), Rules: css.Rules{"fill": color}})
153152
}
154153

155-
styles := generateKeyframes(c.Cast, int32(c.paddedWidth()))
154+
styles := generateKeyframes(c.Cast, c.paddedWidth())
156155
// If custom colors have been provided, use them instead
157156
if foregroundColorOverride != "" {
158157
styles += fmt.Sprintf(".a{fill:%s}", foregroundColorOverride)
@@ -234,17 +233,17 @@ func (c *Canvas) applyBG(bg vt10x.Color) string {
234233
return ""
235234
}
236235

237-
func generateKeyframes(cast asciicast.Cast, width int32) string {
236+
func generateKeyframes(cast asciicast.Cast, width int) string {
238237
css := "@keyframes k {"
239238
for i, frame := range cast.Events {
240-
css += generateKeyframe(float32(frame.Time*100/cast.Header.Duration), width*int32(i))
239+
css += generateKeyframe(float32(frame.Time*100/cast.Header.Duration), width*i)
241240
}
242241

243242
css += "}"
244243

245244
return css
246245
}
247246

248-
func generateKeyframe(percent float32, translate int32) string {
247+
func generateKeyframe(percent float32, translate int) string {
249248
return fmt.Sprintf("%.3f%%{transform:translateX(-%dpx)}", percent, translate)
250249
}

0 commit comments

Comments
 (0)