Skip to content

tagliatelle: extraInitialisms case issue #5955

@erane-opti

Description

@erane-opti

Welcome

  • Yes, I'm using a binary release within 2 latest releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've read the typecheck section of the FAQ.
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.).
  • I agree to follow this project's Code of Conduct

How did you install golangci-lint?

Official binary

Description of the problem

Configuring tagliatelle.extended-rules initialisms overrides has 2 issues:

  1. Mostly docs issue but TagliatelleExtendedRule struct doesn't have mapstructure tags on both ExtraInitialisms and InitialismOverrides making the docs mismatching the actual keys needed in config.yaml . This hold both to v1 and v2:
          # Adds 'AMQP', 'DB', 'GID', 'RTP', 'SIP', 'TS' to initialisms,
          # and removes 'LHS', 'RHS' from initialisms.
          # Default: false
          extra-initialisms: true
          # Defines initialism additions and overrides.
          # Default: empty
          initialism-overrides:
            DB: true # add a new initialism
            LHS: false # disable a default initialism.
            # ...
  1. The main issue: viper's loader converts all map keys to lower case [Loading a YAML file makes all keys lowercase, but YAML keys are case sensitive. spf13/viper#260] so when loading InitialismOverrides all keys are lowered. OTOH, tagliatelle uses github.com/ettle/strcase which expects initialisms map keys to be all uppercase: convert.go

I think toExtendedRules should probably fix this (or maybe @ldez think its tagliatelle job?)

I don't see any obvious quick workaround without changing some code

Version of golangci-lint

$ golangci-lint --version
golangci-lint --version
golangci-lint has version 1.64.8 built with go1.24.1 from 8b37f141 on 2025-03-17T20:41:53Z

Configuration

run:
  allow-parallel-runners: true

output:
  formats: colored-line-number

linters-settings:
  tagliatelle:
    case:
      rules:
        json: goCamel
      extended-rules:
        json:
          case: goCamel
          ExtraInitialisms: true
          InitialismOverrides:
            'AWS': true
linters:
  enable:
    - tagliatelle

Go environment

$ go version && go env
go version go1.24.4 linux/amd64
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE='on'
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='<my user's cache folder>'
GOCACHEPROG=''
GODEBUG=''
GOENV='<my user's .config/go/env''
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1996663955=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='<this example path>''
GOMODCACHE='<my user's go/pkg/mod folder> '
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='<my user's go folder> '
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='<my user's  telemetry dir>'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.4'
GOWORK=''
PKG_CONFIG='pkg-config'

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
tagfail/tag.go:5:23: json(goCamel): got 'thisIdError' want 'thisIDError' (tagliatelle)
        ThisIDError   string `json:"thisIdError"`
                             ^
tagfail/tag.go:6:23: json(goCamel): got 'thisHttp' want 'thisHTTP' (tagliatelle)
        ThisHttpError string `json:"thisHttp"`
                             ^

A minimal reproducible example or link to a public repository

package tagfail

type Example struct {
	SomeAWSKey    string `json:"someAwsKey"`
	ThisIDError   string `json:"thisIdError"`
	ThisHttpError string `json:"thisHttp"`
}

Validation

  • Yes, I've included all information above (version, config, etc.).

Supporter

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions