You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a previous commit in this PR we replaced the Combine() function
in our custom "errors" package with a Join() function that passes
its arguments through to the Join() function of the Go standard
library's "errors" package. Both these Join() functions and our
earlier Combine() function serve to concatenate multiple error
values into a single error value, with the individual error messages
separated by newline characters when the error is converted to a
string value for output.
In a number of instances we perform the same concatenation of error
messages using loops and assembling the final error message by
explicitly appending each individual error message along with the
newline separator characters.
We can now simplify all these instances where we need to concatenate
error messages by making use of the Join() function in our "errors"
package. In almost all of these cases, this means we are able to
eliminate the conditional logic used to check if a newline separator
character is required because more than one error has been encountered.
(The exception is in the Fill() method of the CredentialHelpers
structure of our "creds" package where we previously concatenated
the error messages using the Join() method of the "strings" package
from the Go standard library.)
Note that we could also have used the Combine() function from our
"errors" package to simplify these use cases; however, the Join()
function is more convenient in most instances because it accepts
variadic arguments rather than requiring an array of errors as input.
0 commit comments