gomodifytags icon indicating copy to clipboard operation
gomodifytags copied to clipboard

[Feature request] Means for having different casing in tag name

Open shackra opened this issue 9 months ago • 1 comments

I encountered this edge case, say you have this struct transform with camelcase:

type Blog struct {
	ID     string `json:"id"`
	WebURL string `json:"webURL"`
}

Now, the API offers you its data like this:

GET example.com/api/blog

HTTP/1.1 200 OK
Content-type: application/json

{
  "value": [
    {
      "id": "blog-a",
      "webUrl": "https://example.com"
    },
    {
      "id": "blog-b",
      "webUrl": "https://example.com"
    }
  ]
}

So, the API returns the web's URL in a field called webUrl, but gomodifytags transforms the part of the field "URL" as URL and not as Url. That's okay.

Currently, this can be solved by, either:

  • manually modifying the tag name, with the downside that refreshing the tags will overwrite such manual change.
  • changing the name of the field in the struct, with the downside that I prefer WebURL, not WebUrl in my struct field.

shackra avatar Apr 08 '25 18:04 shackra

Unfortunately there is not much I can do here. Gomodifytags don't store any state anywhere. You can modify individual lines rather then whole struct and pass a different transform, or just leave it like that once transformed.

fatih avatar Apr 10 '25 13:04 fatih