chore: upgrade golangci-lint configuration and optimize codebase (#4236)

This PR includes the following changes:

- **Upgrade `.golangci.yml`**: Updated the configuration file to align
with the latest golangci-lint version, ensuring compatibility and
leveraging new features.
- **Refactor GitHub Action workflow**: Modified `golangci-lint.yml` in
the GitHub Actions workflow to reflect the updated configuration and
improve CI performance.
- **Codebase optimization**: Refactored code to address issues and
warnings raised by the updated golangci-lint rules, including:
  - Improved function length and complexity.
  - Enhanced error handling and variable naming conventions.
- Fixed minor issues such as unused imports and formatting
inconsistencies.

These changes aim to maintain code quality, ensure compatibility with
the latest tools, and improve overall maintainability.
This commit is contained in:
houseme
2025-08-22 13:29:09 +08:00
committed by GitHub
parent 24083b865d
commit 7ffdff37e4
33 changed files with 290 additions and 425 deletions

View File

@ -67,7 +67,7 @@ func (m *Model) WithAll() *Model {
// doWithScanStruct handles model association operations feature for single struct.
func (m *Model) doWithScanStruct(pointer interface{}) error {
if len(m.withArray) == 0 && m.withAll == false {
if len(m.withArray) == 0 && !m.withAll {
return nil
}
var (
@ -190,7 +190,7 @@ func (m *Model) doWithScanStruct(pointer interface{}) error {
// doWithScanStructs handles model association operations feature for struct slice.
// Also see doWithScanStruct.
func (m *Model) doWithScanStructs(pointer interface{}) error {
if len(m.withArray) == 0 && m.withAll == false {
if len(m.withArray) == 0 && !m.withAll {
return nil
}
if v, ok := pointer.(reflect.Value); ok {