x/model: doc Merge semantics when dst is not valid

This commit is contained in:
Blake Mizerany 2024-04-04 15:08:54 -07:00
parent cfe0bb6bb6
commit a4fd06d603

View File

@ -181,6 +181,8 @@ func ParseName(s string) Name {
// //
// Use this for merging a fully qualified ref with a partial ref, such as // Use this for merging a fully qualified ref with a partial ref, such as
// when filling in a missing parts with defaults. // when filling in a missing parts with defaults.
//
// The returned Name will only be valid if dst is valid.
func Merge(dst, src Name) Name { func Merge(dst, src Name) Name {
return Name{ return Name{
// name is left untouched // name is left untouched
@ -204,6 +206,9 @@ func (r Name) WithBuild(build string) Name {
// //
// It normalizes the input string by removing "http://" and "https://" only. // It normalizes the input string by removing "http://" and "https://" only.
// No other normalization is done. // No other normalization is done.
//
// As a special case, question marks are ignored so they may be used as
// placeholders for missing parts in string literals.
func NameParts(s string) iter.Seq2[NamePart, string] { func NameParts(s string) iter.Seq2[NamePart, string] {
return func(yield func(NamePart, string) bool) { return func(yield func(NamePart, string) bool) {
if strings.HasPrefix(s, "http://") { if strings.HasPrefix(s, "http://") {