-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config: add formatlist #1829
config: add formatlist #1829
Conversation
I like the idea and understand the motivation, but I feel that reusing the current The reason is that I would never expect |
Would it help if FWIW, I experimented with a much less powerful version of this (josharian@ed79154), but concluded that it was helpful to be able to mix lists and scalars and to have multiple lists. |
Ok, I've moved list-oriented formatting to |
@@ -11,8 +11,7 @@ import ( | |||
) | |||
|
|||
// InterpSplitDelim is the delimeter that is looked for to split when | |||
// it is returned. This is a comma right now but should eventually become | |||
// a value that a user is very unlikely to use (such as UUID). | |||
// it is returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot.
@josharian This looks good to me, so unless another maintainer jumps in here with a reason for not merging this, I will merge it. The last thing I'd ask you to do before merging though is to squash your commits. |
formatlist distributes formatting over lists. See the docs for details. As a colleague commented: "It happens all the time that we want a set of outputs, but in a slightly different way than just simple joining or concatting." formatlist (combined with join) makes it easy to satisfy those needs.
@radeksimko thanks. Squashed down to two commits and rebased. |
} | ||
|
||
if n == 0 { | ||
return nil, errors.New("no lists in arguments to formatlist") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I didn't notice this before, but why exactly don't you use fmt.Errorf()
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stupid question... the answer is because you don't need any formatting 👐
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
With this PR, format now distributes over lists. Please see the commit comment and doc changes in f2fb9e7 for motivation and details.