From ad6f020bd8827b86887b83baf14e07a47fa3a6a3 Mon Sep 17 00:00:00 2001 From: Blake Mizerany Date: Thu, 4 Apr 2024 16:36:07 -0700 Subject: [PATCH] x/model: doc rule of thumb about valid vs. invalid Names --- x/model/name.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/x/model/name.go b/x/model/name.go index 309220c5..be2313b3 100644 --- a/x/model/name.go +++ b/x/model/name.go @@ -92,6 +92,12 @@ type Name struct { // "example.com/mistral:7b+Q4_0+" // "x/y/z/z:8n+I" // "" +// +// It returns the zero value if any part is invalid. +// +// As a rule of thumb, an valid name is one that can be round-tripped with +// the [Name.String] method. That means ("x+") is invalid because +// [Name.String] will not print a "+" if the build is empty. func ParseName(s string) Name { var r Name for kind, part := range NameParts(s) {