Skip to content

Relax acceptable XS-Go-Import-Path syntax - #305

Open
rhansen wants to merge 3 commits into
Debian:masterfrom
rhansen:go-import-path-syntax
Open

Relax acceptable XS-Go-Import-Path syntax#305
rhansen wants to merge 3 commits into
Debian:masterfrom
rhansen:go-import-path-syntax

Conversation

@rhansen

@rhansen rhansen commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

This PR relaxes how XS-Go-Import-Path values are parsed to improve maintainer friendliness:

  • Filter out empty string values in XS-Go-Import-Path (in particular, ignore a trailing comma).
  • Allow values to be separated by spaces and/or commas.

@rhansen
rhansen force-pushed the go-import-path-syntax branch from cf5f502 to ef5dd77 Compare February 26, 2026 22:03
@rhansen
rhansen force-pushed the go-import-path-syntax branch 3 times, most recently from 60ecc55 to e5b8257 Compare March 13, 2026 03:31
@rhansen
rhansen force-pushed the go-import-path-syntax branch from e5b8257 to 605982a Compare March 13, 2026 22:26
rhansen added 3 commits March 29, 2026 01:52
This should have been part of commit
9f00e05 but I forgot that `With*` is
the idiomatic way to name functions that return options.
Explicitly allow maintainers to add a trailing comma for VC-friendly
multiline values:

    XS-Go-Import-Path:
     example.com/foo,
     example.com/bar,

Currently all code that consumes the map returned from
`getGolangBinaries` ignores the empty string entry, so this commit
should not change behavior at all.  However, this commit improves
readability by making it easy to see what happens in this corner case;
developers don't need to look at every caller of `getGolangBinaries`
to see how the empty string entry is handled.  It is also defensive;
it avoids surprises for any future consumers of `getGolangBinaries`.
For example:

    XS-Go-Import-Path:
     example.com/foo
     example.com/bar

This avoids forcing package maintainers to look up whether a trailing
comma after the final item is allowed or not.  (Separating by
whitespace or permitting a trailing comma makes it easier to construct
a readable and VC-friendly multiline list of values.)  Spaces cannot
exist in a module path, so there is no risk of parsing ambiguity.

The `make` subcommand doesn't produce space-separated lists, and
`dh-golang` doesn't yet support it, so this is just a step towards
generally allowing it everywhere.
@rhansen
rhansen force-pushed the go-import-path-syntax branch from 605982a to 180330a Compare March 29, 2026 05:54
@ottok

ottok commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Do we really need the field to support both using commas or space as separator?

    XS-Go-Import-Path:
     example.com/foo
     example.com/bar

In debian/control files most fields use either comma or space as separator, but never both. Allowing multiple formats sets the stage for having inconsistent formatting, which I am personally not a fan of.

@rhansen

rhansen commented Apr 11, 2026

Copy link
Copy Markdown
Contributor Author

Do we really need the field to support both using commas or space as separator?

Do you mean a mix of space- and comma-separated items within a single XS-Go-Import-Path field? For example:

XS-Go-Import-Path:
  example.com/foo
  example.com/bar,
  example.com/baz

If that's what you mean, then no, we don't need to support that. But:

  • I don't expect a mix like that to happen in practice, at least not often enough to be a concern.
  • Asserting consistent separators within a particular XS-Go-Import-Path field adds code complexity.
  • We can add a lintian check to encourage consistency.

@Maytha8

Maytha8 commented May 8, 2026

Copy link
Copy Markdown
Contributor

In practise, I've only seen them comma-separated. I'm pretty sure that's how the ftp-master API parses them.

@guillemj

Copy link
Copy Markdown
Contributor

While I think I might have preferred to have this field be separated by spaces instead of commas, this seems too late now to switch, and not worth the potential fallout.

A brief check on dak, seems to imply it does not care about the shape of the field's value.

I also stumbled over this recently when making dh-golang more robust when parsing this field, and ended up making sure spaces are not considered separators, but final commas are accepted.

I don't know what else might be parsing this field, either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants