Skip to content

Conversation

@panperla
Copy link

@panperla panperla commented Aug 26, 2025

Upgrade to golang 1.25.0
Upgrade golangcilint to 2.4.0
Migration of linter config
Update bullseye to trixie
Removed building libvips from source in favour of using version available in trixie distro (8.16)
Resolved all problems rised by linter
Replaced io/ioutil with io

@h2non h2non requested a review from Copilot November 8, 2025 19:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modernizes the codebase by updating dependencies, replacing deprecated APIs, and migrating to newer Go versions. However, it contains several critical issues that will prevent the code from compiling and running correctly.

Key Changes:

  • Replaces deprecated io/ioutil package with io and os equivalents
  • Updates Go version and dependencies
  • Fixes a logical bug in HTTP status code validation
  • Improves error handling in server shutdown

Reviewed Changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
source_http.go Replaces ioutil with io package and fixes HTTP status code logic bug
source_fs_test.go Removes unused ioutil import and simplifies test setup
source_fs.go Replaces ioutil.ReadFile with os.ReadFile and fixes spacing
source_body.go Replaces ioutil.ReadAll with io.ReadAll
server.go Improves graceful shutdown by using log.Printf instead of log.Fatalf
placeholder.go Replaces ioutil.ReadAll with io.ReadAll
options.go Adds new Palette field to ImageOptions
middleware.go Adds duplicate variable declaration (bug) and modernizes string replacement
imaginary.go Replaces ioutil.ReadFile with os.ReadFile
image.go Replaces ioutil.ReadAll with io.ReadAll
go.sum Updates dependency checksums
go.mod Updates Go version to 1.25.0 (non-existent) and dependency versions
error.go Modernizes string operations using ReplaceAll and fmt.Fprintf
Dockerfile Updates base images, Go version, and module paths with mismatches
.golangci.toml Updates linter configuration with incorrect section names

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +23 to +43
[linters.settings]
[linters.settings.depguard]
[linters.settings.depguard.rules.main]
allow = [
"$gostd",
"github.com/h2non/bimg",
"github.com/rs/cors",
"github.com/throttled/throttled/v2",
"github.com/throttled/throttled/v2/store/memstore",
"github.com/h2non/filetype",
]

[linters-settings.misspell]
locale = "US"
[linters.settings.goconst]
min-len = 2
min-occurrences = 2

[linters]
# White-listing, to be more CI safe.
disable-all = true

# @see https://github.com/golangci/golangci-lint#enabled-by-default-linters
enable = [
"staticcheck",
"gosimple",
"ineffassign",
"typecheck",
"govet",
# "errcheck",
"unused",
"structcheck",
"varcheck",
"deadcode",

"stylecheck",
"gosec",
"interfacer",
"unconvert",
# "goconst",
"gocyclo",
# "maligned",
"depguard",
"misspell",
"unparam",
"scopelint", # Would like to ignore *_test.go files, but can't atm.
"gocritic",
]
[linters.settings.gocyclo]
min-complexity = 20

[linters.settings.misspell]
locale = 'US'
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration section [linters.settings] is incorrect. In golangci-lint, linter settings should be under [linters-settings] (with a hyphen), not [linters.settings] (with a dot). This will prevent all linter-specific settings (depguard, goconst, gocyclo, misspell) from being applied correctly.

Copilot uses AI. Check for mistakes.

# Cache go modules
ENV GO111MODULE=on
WORKDIR ${GOPATH}/src/github.com/panperla/imaginary
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The WORKDIR path has been changed to github.com/panperla/imaginary, but the module name in go.mod remains github.com/h2non/imaginary. This mismatch will cause build issues. Either update go.mod to match this path, or revert this change to github.com/h2non/imaginary.

Suggested change
WORKDIR ${GOPATH}/src/github.com/panperla/imaginary
WORKDIR ${GOPATH}/src/github.com/h2non/imaginary

Copilot uses AI. Check for mistakes.
wrappedStore := throttled.WrapStoreWithContext(store)

quota := throttled.RateQuota{MaxRate: throttled.PerSec(o.Concurrency), MaxBurst: o.Burst}
wrappedStore := throttled.WrapStoreWithContext(store)
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate variable declaration. wrappedStore is already declared on line 73. This will cause a compilation error.

Suggested change
wrappedStore := throttled.WrapStoreWithContext(store)
wrappedStore = throttled.WrapStoreWithContext(store)

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +66
[linters.exclusions]
generated = 'lax'
presets = [
'comments',
'common-false-positives',
'legacy',
'std-error-handling'
]
paths = [
'third_party$',
'builtin$',
'examples$'
]

[formatters]
[formatters.exclusions]
generated = 'lax'
paths = [
'third_party$',
'builtin$',
'examples$'
]
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration section linters.exclusions is incorrect. In golangci-lint v2, issue exclusions should be configured under the issues section (e.g., issues.exclude-rules), not linters.exclusions.

Suggested change
[linters.exclusions]
generated = 'lax'
presets = [
'comments',
'common-false-positives',
'legacy',
'std-error-handling'
]
paths = [
'third_party$',
'builtin$',
'examples$'
]
[formatters]
[formatters.exclusions]
generated = 'lax'
paths = [
'third_party$',
'builtin$',
'examples$'
]
[issues]
# Exclude generated files (default in golangci-lint v2, but can be set explicitly)
exclude-generated = true
# Exclude issues matching these regular expressions
exclude = [
# Add patterns for comments, common false positives, legacy, std-error-handling if needed
# Example: "error return value not checked.*",
]
# Exclude issues in these paths
exclude-paths = [
'third_party$',
'builtin$',
'examples$'
]
[formatters]

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +66
[formatters]
[formatters.exclusions]
generated = 'lax'
paths = [
'third_party$',
'builtin$',
'examples$'
]
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatters section is not a valid top-level configuration section in golangci-lint. This configuration will have no effect.

Suggested change
[formatters]
[formatters.exclusions]
generated = 'lax'
paths = [
'third_party$',
'builtin$',
'examples$'
]

Copilot uses AI. Check for mistakes.
-o ${GOPATH}/bin/imaginary \
-ldflags="-s -w -h -X main.Version=${IMAGINARY_VERSION}" \
github.com/h2non/imaginary
github.com/panperla/imaginary
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build path has been changed to github.com/panperla/imaginary, but the module name in go.mod remains github.com/h2non/imaginary. This mismatch will cause the build to fail. Either update go.mod to match this path, or revert this change to github.com/h2non/imaginary.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants