All contributions

mkideal/cli

mkideal/cli

A Go package for building command line apps, where flags are described with struct field tags.

Language
Go
GitHub stars
723
Merged changes
1

What we changed

Map flags with a separator longer than one character, set with the sep tag, now split the key and value using the separator's full length.

What this work shows

  • Command line argument parsing
  • Struct tags and reflection in Go
  • Byte offsets in string slicing
What was broken

The separator's tail leaked into the value

A map flag with the tag sep:"=>" given -mkey=>val stored >val under key instead of val. splitKeyVal sliced the value from the separator's position plus one byte, so it only worked for the default = separator.

How we fixed it

Skipping the separator's full length

splitKeyVal now skips len(sep) instead of one byte. A test covers the function itself and a map flag parsed through parseArgv with the => separator.

#75

Merged change

1 6 September 2026

What it taught us

A separator longer than one character needs an offset of its full length, or part of it stays in the value. We test such bugs at two levels: in the helper function and through the public API, the way a user calls it.

More about this technology: Golang

Other projects we write code for

Describe your project.

A free quote comes back within an hour during working hours.