Skip to content

Remove need for consumer replace directive on urfave/sflags fork #17

Closed

Description

@patdowney

Problem

dioad/cli imports github.com/urfave/sflags, and consumers pick up a patched fork through a replace directive in their own go.mod. dioad/connect does this:

replace github.com/urfave/sflags => github.com/patdowney/sflags v0.4.2-patdowney

The fork's go.mod still declares module github.com/urfave/sflags, so the fork can't be required under its own path, and every consumer has to carry the replace. This causes two problems:

  • go install stops working. replace directives are ignored in dependencies and refused by go install module@version, so a consumer that needs the fix can't be installed with go install github.com/dioad/connect@latest.
  • Builds can silently differ. A consumer that forgets the replace builds against upstream urfave/sflags without the patch, with no error.

This was found in the dioad/connect architecture review, finding 82 in doc/claude-review-architecture.md. connect's other replace, emersion/go-smtp pointing to dioad/go-smtp, has the same shape but is connect's own concern.

Proposal

Pick one:

  1. Upstream the patch to urfave/sflags and drop the fork. This is best if it's acceptable upstream.
  2. Give the fork its own module path. Change the fork's go.mod to module github.com/patdowney/sflags (or move it under github.com/dioad/), tag it, and import that path from dioad/cli (command.go: sflags, sflags/gen/gpflag). Consumers can then delete their replace.

Either way, document in the cli README which sflags behaviour dioad/cli depends on, so the reason for the fork isn't lost.

Follow-up in consumers

Once released, bump dioad/cli in dioad/connect and remove the sflags replace from its go.mod.

Activity

  1. patdowney commented on Nov 4, 2026

    @patdowney
    ContributorAuthor

    Approach taken: upstream pseudo-version, no fork

    The fork's only change (the InheritHidden() / InheritDeprecated() options) was merged upstream as urfave/sflags@b88b11ddd16a, with the same API. Upstream main hasn't been tagged since v0.4.1.

    Commit 92fee7b on branch fix/sflags-upstream (local, not pushed):

    • Requires github.com/urfave/sflags v0.4.2-0.20250718033027-b88b11ddd16a and drops the replace. The pseudo-version sorts above v0.4.1, so consumers get the fix through normal version selection with no replace of their own.
    • Pins b88b11d rather than main HEAD. HEAD also includes the later strings.SplitN value-splitting change (Use SplitN for map flags to support values containing separators urfave/sflags#45), which should be adopted deliberately rather than as a side effect.
    • Adds TestNewCommand_NestedFlagsInheritParentTags. It pins the behaviour consumers depend on: a hidden or deprecated tag on a struct field applies to every flag generated from its fields. Nothing tested this before.
    • make verify passes with GOWORK=off.

    Remaining steps

    1. Merge and tag a dioad/cli release.
    2. In dioad/connect: bump dioad/cli and delete the sflags replace from go.mod.
    3. Optional: once upstream tags v0.4.2, move from the pseudo-version to the tag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions