diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..3c190d7 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @charmbracelet/everyone diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..0fe1440 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,29 @@ +version: 2 +updates: + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "daily" + labels: + - "dependencies" + commit-message: + prefix: "chore" + include: "scope" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + labels: + - "dependencies" + commit-message: + prefix: "chore" + include: "scope" + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "daily" + labels: + - "dependencies" + commit-message: + prefix: "chore" + include: "scope" diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 4927f09..2a6065a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -14,10 +14,10 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '1.21' diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index 536c46a..97115bc 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -1,3 +1,5 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + name: goreleaser on: @@ -21,6 +23,11 @@ jobs: fury_token: ${{ secrets.FURY_TOKEN }} nfpm_gpg_key: ${{ secrets.NFPM_GPG_KEY }} nfpm_passphrase: ${{ secrets.NFPM_PASSPHRASE }} + macos_sign_p12: ${{ secrets.MACOS_SIGN_P12 }} + macos_sign_password: ${{ secrets.MACOS_SIGN_PASSWORD }} + macos_notary_issuer_id: ${{ secrets.MACOS_NOTARY_ISSUER_ID }} + macos_notary_key_id: ${{ secrets.MACOS_NOTARY_KEY_ID }} + macos_notary_key: ${{ secrets.MACOS_NOTARY_KEY }} homebrew: name: Bump Homebrew formula runs-on: ubuntu-latest diff --git a/.github/workflows/lint-soft.yml b/.github/workflows/lint-soft.yml new file mode 100644 index 0000000..87d1e1f --- /dev/null +++ b/.github/workflows/lint-soft.yml @@ -0,0 +1,28 @@ +name: lint-soft +on: + push: + pull_request: + +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + pull-requests: read + +jobs: + golangci: + name: lint-soft + runs-on: ubuntu-latest + steps: + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: ^1 + + - uses: actions/checkout@v4 + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + # Optional: golangci-lint command line arguments. + args: --config .golangci-soft.yml --issues-exit-code=0 + # Optional: show only new issues if it's a pull request. The default value is `false`. + only-new-issues: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..f617a5a --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,28 @@ +name: lint +on: + push: + pull_request: + +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + pull-requests: read + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: ^1 + + - uses: actions/checkout@v4 + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + # Optional: golangci-lint command line arguments. + #args: + # Optional: show only new issues if it's a pull request. The default value is `false`. + only-new-issues: true diff --git a/.golangci-soft.yml b/.golangci-soft.yml new file mode 100644 index 0000000..a723f45 --- /dev/null +++ b/.golangci-soft.yml @@ -0,0 +1,39 @@ +run: + tests: false + +issues: + include: + - EXC0001 + - EXC0005 + - EXC0011 + - EXC0012 + - EXC0013 + + max-issues-per-linter: 0 + max-same-issues: 0 + +linters: + enable: + - exhaustive + - goconst + - godot + - godox + - gomoddirectives + - goprintffuncname + - misspell + - nakedret + - nestif + - noctx + - nolintlint + - prealloc + - wrapcheck + + # disable default linters, they are already enabled in .golangci.yml + disable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - typecheck + - unused diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..684d54b --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,28 @@ +run: + tests: false + +issues: + include: + - EXC0001 + - EXC0005 + - EXC0011 + - EXC0012 + - EXC0013 + + max-issues-per-linter: 0 + max-same-issues: 0 + +linters: + enable: + - bodyclose + - goimports + - gosec + - nilerr + - predeclared + - revive + - rowserrcheck + - sqlclosecheck + - tparallel + - unconvert + - unparam + - whitespace diff --git a/ansi.go b/ansi.go index 6c0d2b3..5e625e5 100644 --- a/ansi.go +++ b/ansi.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/beevik/etree" - "github.com/charmbracelet/x/exp/term/ansi" + "github.com/charmbracelet/x/ansi" "github.com/mattn/go-runewidth" ) diff --git a/config.go b/config.go index f597b0a..df583ab 100644 --- a/config.go +++ b/config.go @@ -85,7 +85,6 @@ func expandPadding(p []float64, scale float64) []float64 { return []float64{p[top] * scale, p[right] * scale, p[bottom] * scale, p[left] * scale} default: return []float64{0, 0, 0, 0} - } } @@ -103,7 +102,7 @@ const ( var userConfigPath = filepath.Join(xdg.ConfigHome, "freeze", "user.json") func loadUserConfig() (fs.File, error) { - return os.Open(userConfigPath) + return os.Open(userConfigPath) //nolint: wrapcheck } func saveUserConfig(config Config) error { @@ -113,19 +112,19 @@ func saveUserConfig(config Config) error { err := os.MkdirAll(filepath.Dir(userConfigPath), os.ModePerm) if err != nil { - return err + return err //nolint: wrapcheck } f, err := os.Create(userConfigPath) if err != nil { - return err + return err //nolint: wrapcheck } b, err := json.Marshal(config) if err != nil { - return err + return err //nolint: wrapcheck } _, err = f.Write(b) printFilenameOutput(userConfigPath) - return err + return err //nolint: wrapcheck } diff --git a/cut_test.go b/cut_test.go index a493d08..497b0c2 100644 --- a/cut_test.go +++ b/cut_test.go @@ -46,5 +46,4 @@ func TestCut(t *testing.T) { t.Errorf("cut(%s, %v)", test.input, test.lines) } } - } diff --git a/error.go b/error.go index 4bf7fd0..82b96d9 100644 --- a/error.go +++ b/error.go @@ -7,8 +7,10 @@ import ( "github.com/charmbracelet/lipgloss" ) -var errorHeader = lipgloss.NewStyle().Foreground(lipgloss.Color("#F1F1F1")).Background(lipgloss.Color("#FF5F87")).Bold(true).Padding(0, 1).Margin(1).MarginLeft(2).SetString("ERROR") -var errorDetails = lipgloss.NewStyle().Foreground(lipgloss.Color("#757575")).Margin(0, 0, 1, 2) +var ( + errorHeader = lipgloss.NewStyle().Foreground(lipgloss.Color("#F1F1F1")).Background(lipgloss.Color("#FF5F87")).Bold(true).Padding(0, 1).Margin(1).MarginLeft(2).SetString("ERROR") + errorDetails = lipgloss.NewStyle().Foreground(lipgloss.Color("#757575")).Margin(0, 0, 1, 2) +) func printError(title string, err error) { fmt.Printf("%s\n", lipgloss.JoinHorizontal(lipgloss.Center, errorHeader.String(), title)) diff --git a/font/font.go b/font/font.go index aaa4035..5f2b465 100644 --- a/font/font.go +++ b/font/font.go @@ -105,5 +105,10 @@ var JetBrainsMonoTTF []byte //go:embed JetBrainsMonoNL-Regular.ttf var JetBrainsMonoNLTTF []byte -var JetBrainsMono string = base64.StdEncoding.EncodeToString(JetBrainsMonoTTF) -var JetBrainsMonoNL string = base64.StdEncoding.EncodeToString(JetBrainsMonoNLTTF) +var ( + // JetBrainsMono font. + JetBrainsMono = base64.StdEncoding.EncodeToString(JetBrainsMonoTTF) + + // JetBrainsMonoNL font. + JetBrainsMonoNL = base64.StdEncoding.EncodeToString(JetBrainsMonoNLTTF) +) diff --git a/freeze_test.go b/freeze_test.go index 06b4e43..0443255 100644 --- a/freeze_test.go +++ b/freeze_test.go @@ -14,8 +14,10 @@ import ( const binary = "./test/freeze-test" -var update = flag.Bool("update", false, "update golden files") -var png = flag.Bool("png", false, "update pngs") +var ( + update = flag.Bool("update", false, "update golden files") + png = flag.Bool("png", false, "update pngs") +) func TestMain(m *testing.M) { flag.Parse() @@ -264,15 +266,15 @@ func TestFreezeConfigurations(t *testing.T) { if err != nil { t.Fatal("unable to remove output files") } - err = os.MkdirAll("test/output/svg", 0755) + err = os.MkdirAll("test/output/svg", 0o755) if err != nil { t.Fatal("unable to create output directory") } - err = os.MkdirAll("test/golden/svg", 0755) + err = os.MkdirAll("test/golden/svg", 0o755) if err != nil { t.Fatal("unable to create output directory") } - err = os.MkdirAll("test/output/png", 0755) + err = os.MkdirAll("test/output/png", 0o755) if err != nil { t.Fatal("unable to create output directory") } @@ -299,7 +301,7 @@ func TestFreezeConfigurations(t *testing.T) { } goldenfile := "test/golden/svg/" + tc.output + ".svg" if *update { - if err := os.WriteFile(goldenfile, got, 0644); err != nil { + if err := os.WriteFile(goldenfile, got, 0o644); err != nil { t.Log(err) t.Fatal("unexpected error") } diff --git a/go.mod b/go.mod index 405bfb2..c1327d8 100644 --- a/go.mod +++ b/go.mod @@ -1,47 +1,51 @@ module github.com/charmbracelet/freeze -go 1.21 +go 1.21.0 + +toolchain go1.22.5 require ( - github.com/adrg/xdg v0.4.0 - github.com/alecthomas/chroma/v2 v2.13.0 + github.com/adrg/xdg v0.5.0 + github.com/alecthomas/chroma/v2 v2.14.0 github.com/alecthomas/kong v0.9.0 github.com/aymanbagabas/go-udiff v0.2.0 - github.com/beevik/etree v1.3.0 + github.com/beevik/etree v1.4.1 github.com/caarlos0/go-shellwords v1.0.12 - github.com/charmbracelet/huh v0.3.1-0.20240327025511-ec643317aa10 - github.com/charmbracelet/lipgloss v0.10.1-0.20240325130315-f16ea2bdcb88 + github.com/charmbracelet/huh v0.6.0 + github.com/charmbracelet/lipgloss v0.13.0 github.com/charmbracelet/log v0.4.0 + github.com/charmbracelet/x/ansi v0.2.3 github.com/charmbracelet/x/exp/term v0.0.0-20240403043919-dea9035a27d4 - github.com/creack/pty v1.1.21 + github.com/creack/pty v1.1.23 github.com/kanrichan/resvg-go v0.0.2-0.20231001163256-63db194ca9f5 github.com/mattn/go-isatty v0.0.20 - github.com/mattn/go-runewidth v0.0.15 - golang.org/x/sys v0.18.0 + github.com/mattn/go-runewidth v0.0.16 + github.com/muesli/reflow v0.3.0 + golang.org/x/sys v0.25.0 ) require ( github.com/atotto/clipboard v0.1.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/catppuccin/go v0.2.0 // indirect - github.com/charmbracelet/bubbles v0.18.0 // indirect - github.com/charmbracelet/bubbletea v0.25.0 // indirect - github.com/charmbracelet/x/errors v0.0.0-20240117030013-d31dba354651 // indirect - github.com/charmbracelet/x/exp/strings v0.0.0-20240327191656-1e1cd98f30d4 // indirect - github.com/containerd/console v1.0.4 // indirect - github.com/dlclark/regexp2 v1.11.0 // indirect + github.com/charmbracelet/bubbles v0.20.0 // indirect + github.com/charmbracelet/bubbletea v1.1.0 // indirect + github.com/charmbracelet/x/errors v0.0.0-20240906161213-162f3037fef5 // indirect + github.com/charmbracelet/x/exp/strings v0.0.0-20240906161213-162f3037fef5 // indirect + github.com/charmbracelet/x/term v0.2.0 // indirect + github.com/dlclark/regexp2 v1.11.4 // indirect github.com/dustin/go-humanize v1.0.1 // indirect + github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mattn/go-localereader v0.0.1 // indirect + github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect - github.com/muesli/reflow v0.3.0 // indirect - github.com/muesli/termenv v0.15.2 // indirect + github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a // indirect github.com/rivo/uniseg v0.4.7 // indirect - github.com/tetratelabs/wazero v1.7.0 // indirect - golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/term v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect + github.com/tetratelabs/wazero v1.8.0 // indirect + golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/text v0.18.0 // indirect ) diff --git a/go.sum b/go.sum index 56f5052..eb3ded8 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,11 @@ -github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls= -github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E= -github.com/alecthomas/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU= -github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/chroma/v2 v2.13.0 h1:VP72+99Fb2zEcYM0MeaWJmV+xQvz5v5cxRHd+ooU1lI= -github.com/alecthomas/chroma/v2 v2.13.0/go.mod h1:BUGjjsD+ndS6eX37YgTchSEG+Jg9Jv1GiZs9sqPqztk= +github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= +github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= +github.com/adrg/xdg v0.5.0 h1:dDaZvhMXatArP1NPHhnfaQUqWBLBsmx1h1HXQdMoFCY= +github.com/adrg/xdg v0.5.0/go.mod h1:dDdY4M4DF9Rjy4kHPeNL+ilVF+p2lK8IdM9/rTSGcI4= +github.com/alecthomas/assert/v2 v2.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE= +github.com/alecthomas/assert/v2 v2.7.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= +github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= +github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= github.com/alecthomas/kong v0.9.0 h1:G5diXxc85KvoV2f0ZRVuMsi45IrBgx9zDNGNj165aPA= github.com/alecthomas/kong v0.9.0/go.mod h1:Y47y5gKfHp1hDc7CH7OeXgLIpp+Q2m1Ni0L5s3bI8Os= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= @@ -14,39 +16,42 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA= -github.com/beevik/etree v1.3.0 h1:hQTc+pylzIKDb23yYprodCWWTt+ojFfUZyzU09a/hmU= -github.com/beevik/etree v1.3.0/go.mod h1:aiPf89g/1k3AShMVAzriilpcE4R/Vuor90y83zVZWFc= +github.com/beevik/etree v1.4.1 h1:PmQJDDYahBGNKDcpdX8uPy1xRCwoCGVUiW669MEirVI= +github.com/beevik/etree v1.4.1/go.mod h1:gPNJNaBGVZ9AwsidazFZyygnd+0pAU38N4D+WemwKNs= github.com/caarlos0/go-shellwords v1.0.12 h1:HWrUnu6lGbWfrDcFiHcZiwOLzHWjjrPVehULaTFgPp8= github.com/caarlos0/go-shellwords v1.0.12/go.mod h1:bYeeX1GrTLPl5cAMYEzdm272qdsQAZiaHgeF0KTk1Gw= github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= -github.com/charmbracelet/bubbles v0.18.0 h1:PYv1A036luoBGroX6VWjQIE9Syf2Wby2oOl/39KLfy0= -github.com/charmbracelet/bubbles v0.18.0/go.mod h1:08qhZhtIwzgrtBjAcJnij1t1H0ZRjwHyGsy6AL11PSw= -github.com/charmbracelet/bubbletea v0.25.0 h1:bAfwk7jRz7FKFl9RzlIULPkStffg5k6pNt5dywy4TcM= -github.com/charmbracelet/bubbletea v0.25.0/go.mod h1:EN3QDR1T5ZdWmdfDzYcqOCAps45+QIJbLOBxmVNWNNg= -github.com/charmbracelet/huh v0.3.1-0.20240327025511-ec643317aa10 h1:779PmXc9Zt/Hxa0yg4I8sQk/1Nfa5TQisXaHZEW60Yk= -github.com/charmbracelet/huh v0.3.1-0.20240327025511-ec643317aa10/go.mod h1:x0rYoA1kpsaefXhRJZuxLM+qP4CYyEFE67T3ZGl7zPU= -github.com/charmbracelet/lipgloss v0.10.1-0.20240325130315-f16ea2bdcb88 h1:mgadly2fIPH9F/hNYi9dXckOXljERkHK1Ohtf4MD5kc= -github.com/charmbracelet/lipgloss v0.10.1-0.20240325130315-f16ea2bdcb88/go.mod h1:7V+J+a41Lz/77Nsya9Srb7WFRj02LvdMcAXZtc4zroQ= +github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= +github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= +github.com/charmbracelet/bubbletea v1.1.0 h1:FjAl9eAL3HBCHenhz/ZPjkKdScmaS5SK69JAK2YJK9c= +github.com/charmbracelet/bubbletea v1.1.0/go.mod h1:9Ogk0HrdbHolIKHdjfFpyXJmiCzGwy+FesYkZr7hYU4= +github.com/charmbracelet/huh v0.6.0 h1:mZM8VvZGuE0hoDXq6XLxRtgfWyTI3b2jZNKh0xWmax8= +github.com/charmbracelet/huh v0.6.0/go.mod h1:GGNKeWCeNzKpEOh/OJD8WBwTQjV3prFAtQPpLv+AVwU= +github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw= +github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= -github.com/charmbracelet/x/errors v0.0.0-20240117030013-d31dba354651 h1:3RXpZWGWTOeVXCTv0Dnzxdv/MhNUkBfEcbaTY0zrTQI= -github.com/charmbracelet/x/errors v0.0.0-20240117030013-d31dba354651/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0= -github.com/charmbracelet/x/exp/strings v0.0.0-20240327191656-1e1cd98f30d4 h1:E3qdydPjQJIGnT6t6lY0P70sou+Vmh+VcQHAYR4qTtA= -github.com/charmbracelet/x/exp/strings v0.0.0-20240327191656-1e1cd98f30d4/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ= +github.com/charmbracelet/x/ansi v0.2.3 h1:VfFN0NUpcjBRd4DnKfRaIRo53KRgey/nhOoEqosGDEY= +github.com/charmbracelet/x/ansi v0.2.3/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/errors v0.0.0-20240906161213-162f3037fef5 h1:rIt3LGU1yOC7U48eZjaAtjdzuSjH6Y0GA1KsRN7wqn8= +github.com/charmbracelet/x/errors v0.0.0-20240906161213-162f3037fef5/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0= +github.com/charmbracelet/x/exp/strings v0.0.0-20240906161213-162f3037fef5 h1:73C9VsX8PMlXxVMKjg7ix67cZWg+zySdyzWRaXS239A= +github.com/charmbracelet/x/exp/strings v0.0.0-20240906161213-162f3037fef5/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ= github.com/charmbracelet/x/exp/term v0.0.0-20240403043919-dea9035a27d4 h1:LewLBFkff+bCxgMZn1m8xNYQbUksWaY71d1QARHA11s= github.com/charmbracelet/x/exp/term v0.0.0-20240403043919-dea9035a27d4/go.mod h1:6GZ13FjIP6eOCqWU4lqgveGnYxQo9c3qBzHPeFu4HBE= -github.com/containerd/console v1.0.4 h1:F2g4+oChYvBTsASRTz8NP6iIAi97J3TtSAsLbIFn4ro= -github.com/containerd/console v1.0.4/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= -github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0= -github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0= +github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0= +github.com/creack/pty v1.1.23 h1:4M6+isWdcStXEf15G/RbrMPOQj1dZ7HPZCGwE4kOeP0= +github.com/creack/pty v1.1.23/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= -github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= +github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yAo= +github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= +github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= @@ -60,42 +65,37 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= +github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo= github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA= github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= -github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo= -github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8= +github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a h1:2MaM6YC3mGu54x+RKAA6JiFFHlHDY1UbkxqppT7wYOg= +github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a/go.mod h1:hxSnBBYLK21Vtq/PHd0S2FYCxBXzBua8ov5s1RobyRQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/tetratelabs/wazero v1.7.0 h1:jg5qPydno59wqjpGrHph81lbtHzTrWzwwtD4cD88+hQ= -github.com/tetratelabs/wazero v1.7.0/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= -golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw= -golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +github.com/tetratelabs/wazero v1.8.0 h1:iEKu0d4c2Pd+QSRieYbnQC9yiFlMS9D+Jr0LsRmcF4g= +github.com/tetratelabs/wazero v1.8.0/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs= +golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e h1:I88y4caeGeuDQxgdoFPUq097j7kNfw6uvuiNxUBfcBk= +golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/help.go b/help.go index d01affa..9695737 100644 --- a/help.go +++ b/help.go @@ -92,7 +92,6 @@ func printFlag(f *kong.Flag) { fmt.Print(" ", dashStyle.Render(" "), " ") fmt.Print(dashStyle.Render("--"), f.Name) fmt.Print(strings.Repeat(" ", space-len(f.Name))) - } help := highlighter.ReplaceAllString(f.Help, keywordStyle.Render("$1")+"\x1b[38;5;"+helpForeground+"m") fmt.Println(helpStyle.Render(help)) diff --git a/interactive.go b/interactive.go index e7916cf..094e517 100644 --- a/interactive.go +++ b/interactive.go @@ -29,18 +29,18 @@ func runForm(config *Config) (*Config, error) { theme := huh.ThemeCharm() theme.FieldSeparator = lipgloss.NewStyle() - theme.Blurred.TextInput.Text = theme.Blurred.TextInput.Text.Copy().Foreground(lipgloss.Color("243")) + theme.Blurred.TextInput.Text = theme.Blurred.TextInput.Text.Foreground(lipgloss.Color("243")) theme.Blurred.BlurredButton = lipgloss.NewStyle().Foreground(lipgloss.Color("8")).PaddingRight(1) theme.Blurred.FocusedButton = lipgloss.NewStyle().Foreground(lipgloss.Color("7")).PaddingRight(1) theme.Focused.BlurredButton = lipgloss.NewStyle().Foreground(lipgloss.Color("8")).PaddingRight(1) theme.Focused.FocusedButton = lipgloss.NewStyle().Foreground(lipgloss.Color("15")).PaddingRight(1) - theme.Focused.NoteTitle = theme.Focused.NoteTitle.Copy().Margin(1, 0) - theme.Blurred.NoteTitle = theme.Blurred.NoteTitle.Copy().Margin(1, 0) - theme.Blurred.Description = theme.Blurred.Description.Copy().Foreground(lipgloss.Color("0")) - theme.Focused.Description = theme.Focused.Description.Copy().Foreground(lipgloss.Color("7")) - theme.Blurred.Title = theme.Blurred.Title.Copy().Width(18).Foreground(lipgloss.Color("7")) - theme.Focused.Title = theme.Focused.Title.Copy().Width(18).Foreground(green).Bold(true) - theme.Blurred.SelectedOption = theme.Blurred.SelectedOption.Copy().Foreground(lipgloss.Color("243")) + theme.Focused.NoteTitle = theme.Focused.NoteTitle.Margin(1, 0) + theme.Blurred.NoteTitle = theme.Blurred.NoteTitle.Margin(1, 0) + theme.Blurred.Description = theme.Blurred.Description.Foreground(lipgloss.Color("0")) + theme.Focused.Description = theme.Focused.Description.Foreground(lipgloss.Color("7")) + theme.Blurred.Title = theme.Blurred.Title.Width(18).Foreground(lipgloss.Color("7")) + theme.Focused.Title = theme.Focused.Title.Width(18).Foreground(green).Bold(true) + theme.Blurred.SelectedOption = theme.Blurred.SelectedOption.Foreground(lipgloss.Color("243")) theme.Focused.SelectedOption = lipgloss.NewStyle().Foreground(green) theme.Focused.Base.BorderForeground(green) @@ -197,7 +197,7 @@ func runForm(config *Config) (*Config, error) { config.Shadow.Blur, _ = strconv.ParseFloat(shadowBlur, 64) config.Shadow.X, _ = strconv.ParseFloat(shadowX, 64) config.Shadow.Y, _ = strconv.ParseFloat(shadowY, 64) - return config, err + return config, err //nolint: wrapcheck } func validateMargin(s string) error { @@ -256,6 +256,7 @@ func validateColor(s string) error { } func parsePadding(v string) []float64 { + //nolint: prealloc var values []float64 for _, p := range strings.Fields(v) { pi, _ := strconv.ParseFloat(p, 64) // already validated diff --git a/main.go b/main.go index 50c7a7f..22a7a06 100644 --- a/main.go +++ b/main.go @@ -19,8 +19,8 @@ import ( "github.com/charmbracelet/freeze/svg" "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/log" - "github.com/charmbracelet/x/exp/term/ansi" - "github.com/charmbracelet/x/exp/term/ansi/parser" + "github.com/charmbracelet/x/ansi" + "github.com/charmbracelet/x/ansi/parser" "github.com/mattn/go-isatty" "github.com/muesli/reflow/wordwrap" ) @@ -60,11 +60,12 @@ func main() { printErrorFatal("Invalid Usage", err) } + //nolint: nestif if config.Version { if Version == "" { Version = "latest (built from source)" if info, ok := debug.ReadBuildInfo(); ok && (info.Main.Version != "" && info.Main.Version != "(devel)") { - Version = info.Main.Version + Version = info.Main.Version } } version := fmt.Sprintf("freeze version: %s", Version) diff --git a/png.go b/png.go index af0348f..b7d0184 100644 --- a/png.go +++ b/png.go @@ -11,15 +11,15 @@ import ( "github.com/kanrichan/resvg-go" ) -func libsvgConvert(doc *etree.Document, w, h float64, output string) error { +func libsvgConvert(doc *etree.Document, _, _ float64, output string) error { _, err := exec.LookPath("rsvg-convert") if err != nil { - return err + return err //nolint: wrapcheck } svg, err := doc.WriteToBytes() if err != nil { - return err + return err //nolint: wrapcheck } // rsvg-convert is installed use that to convert the SVG to PNG, @@ -27,26 +27,26 @@ func libsvgConvert(doc *etree.Document, w, h float64, output string) error { rsvgConvert := exec.Command("rsvg-convert", "-o", output) rsvgConvert.Stdin = bytes.NewReader(svg) err = rsvgConvert.Run() - return err + return err //nolint: wrapcheck } func resvgConvert(doc *etree.Document, w, h float64, output string) error { svg, err := doc.WriteToBytes() if err != nil { - return err + return err //nolint: wrapcheck } worker, err := resvg.NewDefaultWorker(context.Background()) if err != nil { printErrorFatal("Unable to write output", err) } - defer worker.Close() + defer worker.Close() //nolint: errcheck fontdb, err := worker.NewFontDBDefault() if err != nil { printErrorFatal("Unable to write output", err) } - defer fontdb.Close() + defer fontdb.Close() //nolint: errcheck err = fontdb.LoadFontData(font.JetBrainsMonoTTF) if err != nil { printErrorFatal("Unable to load font", err) @@ -61,7 +61,7 @@ func resvgConvert(doc *etree.Document, w, h float64, output string) error { printError("Unable to write output", err) os.Exit(1) } - defer pixmap.Close() + defer pixmap.Close() //nolint: errcheck tree, err := worker.NewTreeFromData(svg, &resvg.Options{ Dpi: 192, @@ -75,24 +75,24 @@ func resvgConvert(doc *etree.Document, w, h float64, output string) error { printError("Unable to write output", err) os.Exit(1) } - defer tree.Close() + defer tree.Close() //nolint: errcheck err = tree.ConvertText(fontdb) if err != nil { - return err + return err //nolint: wrapcheck } err = tree.Render(resvg.TransformIdentity(), pixmap) if err != nil { - return err + return err //nolint: wrapcheck } png, err := pixmap.EncodePNG() if err != nil { - return err + return err //nolint: wrapcheck } - err = os.WriteFile(output, png, 0644) + err = os.WriteFile(output, png, 0o600) if err != nil { - return err + return err //nolint: wrapcheck } - return err + return err //nolint: wrapcheck } diff --git a/pty.go b/pty.go index 7c782b8..42fd0fd 100644 --- a/pty.go +++ b/pty.go @@ -19,6 +19,7 @@ import ( // The returned file is the pty's file descriptor and must be closed by the // caller. func (cfg Config) runInPty(c *exec.Cmd) (*os.File, error) { + //nolint: wrapcheck return pty.StartWithAttrs(c, &pty.Winsize{ Cols: 80, Rows: 10, @@ -29,17 +30,17 @@ func (cfg Config) runInPty(c *exec.Cmd) (*os.File, error) { func executeCommand(config Config) (string, error) { args, err := shellwords.Parse(config.Execute) if err != nil { - return "", err + return "", err //nolint: wrapcheck } ctx, cancel := context.WithTimeout(context.Background(), config.ExecuteTimeout) defer cancel() - cmd := exec.CommandContext(ctx, args[0], args[1:]...) + cmd := exec.CommandContext(ctx, args[0], args[1:]...) //nolint: gosec pty, err := config.runInPty(cmd) if err != nil { return "", err } - defer pty.Close() + defer pty.Close() //nolint: errcheck var out bytes.Buffer go func() { _, _ = io.Copy(&out, pty) @@ -47,7 +48,7 @@ func executeCommand(config Config) (string, error) { err = cmd.Wait() if err != nil { - return "", err + return "", err //nolint: wrapcheck } return out.String(), nil } diff --git a/svg/svg.go b/svg/svg.go index a12f9cb..729aece 100644 --- a/svg/svg.go +++ b/svg/svg.go @@ -63,7 +63,7 @@ func AddCornerRadius(e *etree.Element, radius float64) { e.CreateAttr("ry", fmt.Sprintf("%.2f", radius)) } -// Move moves the given element to the (x, y) position +// Move moves the given element to the (x, y) position. func Move(e *etree.Element, x, y float64) { e.CreateAttr("x", fmt.Sprintf("%.2fpx", x)) e.CreateAttr("y", fmt.Sprintf("%.2fpx", y)) @@ -113,7 +113,7 @@ func GetDimensions(element *etree.Element) (int, int) { } // dimensionToInt takes a string and returns the integer value. -// e.g. "500px" -> 500 +// e.g. "500px" -> 500. func dimensionToInt(px string) int { d := strings.TrimSuffix(px, "px") v, _ := strconv.ParseInt(d, 10, 64) diff --git a/test/golden/svg/tab.svg b/test/golden/svg/tab.svg index 20c4292..c44874f 100644 --- a/test/golden/svg/tab.svg +++ b/test/golden/svg/tab.svg @@ -1,6 +1,6 @@ - + + package main // freeze/issues/50 -type Config struct { -    Telegram struct { +type Config struct { //nolint: revive +    Telegram struct {         Token   string `env:"TG_TOKEN"`         ChatID  string `env:"TG_CHAT"`         OwnerID string `env:"TG_ADMIN"` @@ -32,8 +32,8 @@     Debug bool } -func Load() (*Config, error) { -    var c Config +func Load() (*Config, error) { //nolint: revive +    var c Config     var err error     return &c, err } diff --git a/test/input/tab.go b/test/input/tab.go index b46679a..ab4bdb9 100644 --- a/test/input/tab.go +++ b/test/input/tab.go @@ -2,7 +2,7 @@ package main // freeze/issues/50 -type Config struct { +type Config struct { //nolint: revive Telegram struct { Token string `env:"TG_TOKEN"` ChatID string `env:"TG_CHAT"` @@ -20,7 +20,7 @@ type Config struct { Debug bool } -func Load() (*Config, error) { +func Load() (*Config, error) { //nolint: revive var c Config var err error return &c, err