finds.dev← search

// the find

fatih/gomodifytags

★ 2,397 · Go · BSD-3-Clause · updated Apr 2025

Go tool to modify struct field tags

gomodifytags is a Go command-line tool and library that adds, removes, and edits struct field tags such as json, xml, and validate, along with their options such as omitempty. It is aimed at Go developers who want tag edits driven from their editor, and it backs the Add Tags and Remove Tags commands in several editors.

The selection model is the strongest part. -line, -offset, -struct, and -all cover everything from a cursor position to a whole file, and -format json returns the exact start and end lines to replace, so an editor can swap a buffer without reparsing. Changes print to stdout unless you pass -w, which is the right default for a tool that rewrites source. The -modified flag takes an archive of unsaved buffers on stdin. The golden-file tests cover the cases that tend to break: partial line ranges, existing tags, options containing equals signs, and embedded fields.

The last push was 23 April 2025, about eighteen months before today, and the README still says Go 1.11 is the minimum. Nothing in the README says how the project is maintained now, so check the Go toolchain and dependencies before adopting it. The test fixtures are split between a root test-fixtures directory and modifytags/test-fixtures, with near-duplicate names like all_structs and clear_all_tags next to struct_clear_tags, which makes it unclear where a new case belongs. The library API gets one paragraph with no signature or example, so Apply() is hard to use without reading the source. The editor list is long and mostly third-party plugins, and the README does not say which of them track the current flags.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →