Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String containing consecutive uppercase letters #19

Open
GotoRen opened this issue May 17, 2023 · 2 comments
Open

String containing consecutive uppercase letters #19

GotoRen opened this issue May 17, 2023 · 2 comments
Labels
enhancement New feature or request stale

Comments

@GotoRen
Copy link

GotoRen commented May 17, 2023

Prepare a structure like this:

type AddressInformation struct {
    ID            int       `json:"id"`
    VirtualIPv4   string    `json:"virtual_ipv4"`
    VirtualIPv6   string    `json:"virtual_ipv6"`
    IsVirtualIPv6 bool      `json:"is_virtual_ipv6"`
    MacAddress    string    `json:"mac_address"`
}

golangci-lint prints an error like this:

Error: ${ROOT_DIR}/address_information.go:14:26: [golangci] json(snake): got 'virtual_ipv4' want 'virtual_i_pv4' (tagliatelle)
Error: ${ROOT_DIR}/address_information.go:15:26: [golangci] json(snake): got 'virtual_ipv6' want 'virtual_i_pv6' (tagliatelle)
Error: ${ROOT_DIR}/address_information.go:16:26: [golangci] json(snake): got 'is_virtual_ipv6' want 'is_virtual_i_pv6' (tagliatelle)

The desired snake case is "virtual_ipv4" in this case.

However, as you can see, tagliatelle is requesting to separate the "i" and "p" as "virtual_i_pv4".

In this case, it is desirable to output as "virtual_ipv4".

Or is "IPv4" "Ipv4" ?!

@GotoRen GotoRen changed the title Special characters with consecutive upper case. String containing consecutive uppercase letters May 17, 2023
@ldez
Copy link
Owner

ldez commented May 17, 2023

Hello,

It's related to the lib that I use to create the expected case: https://github.com/ettle/strcase

https://go.dev/play/p/ZqJmqNNyNkW

Related to #2

@ldez
Copy link
Owner

ldez commented Dec 8, 2024

There is a PR on strcase (ettle/strcase#13) about this topic but it doesn't fix the problem with all cases (ex: VirtualIPv4 in kebab or snake case result in virtual-i-pv4 or virtual_i_pv4).

But I added an option (ignored-fields) to ignore fields https://github.com/ldez/tagliatelle?tab=readme-ov-file#as-a-golangci-lint-linter

@ldez ldez added enhancement New feature or request stale labels Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale
Projects
None yet
Development

No branches or pull requests

2 participants