x/model: more doc updates
This commit is contained in:
parent
fb0782b7a9
commit
5e76860c47
@ -91,8 +91,8 @@ type Name struct {
|
|||||||
build string
|
build string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseName parses s into a Name. The input string must be a valid form of
|
// ParseName parses s into a Name. The input string must be a valid string
|
||||||
// a model name in the form:
|
// representation of a model name in the form:
|
||||||
//
|
//
|
||||||
// <host>/<namespace>/<model>:<tag>+<build>
|
// <host>/<namespace>/<model>:<tag>+<build>
|
||||||
//
|
//
|
||||||
@ -191,10 +191,11 @@ func (r Name) DisplayModel() string {
|
|||||||
return r.model
|
return r.model
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisplayFullest returns the most specific display string of the composed
|
// DisplayFullest returns the fullest possible display string in form:
|
||||||
// of all parts leading up to, but not including, the build.
|
|
||||||
//
|
//
|
||||||
// For a display string representation with the build, use [Name.String].
|
// <host>/<namespace>/<model>:<tag>
|
||||||
|
//
|
||||||
|
// If any part is missing, it is omitted from the display string.
|
||||||
func (r Name) DisplayFullest() string {
|
func (r Name) DisplayFullest() string {
|
||||||
return (Name{
|
return (Name{
|
||||||
host: r.host,
|
host: r.host,
|
||||||
@ -204,22 +205,11 @@ func (r Name) DisplayFullest() string {
|
|||||||
}).String()
|
}).String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GoString implements fmt.GoStringer. It returns a string suitable for
|
// DisplayShort returns the fullest possible display string in form:
|
||||||
// debugging and logging. It is similar to [Name.String] but it always
|
//
|
||||||
// returns a string that includes all parts of the Name, with missing parts
|
// <model>:<tag>
|
||||||
// replaced with a ("?").
|
//
|
||||||
func (r Name) GoString() string {
|
// If any part is missing, it is omitted from the display string.
|
||||||
return (Name{
|
|
||||||
host: cmp.Or(r.host, "?"),
|
|
||||||
namespace: cmp.Or(r.namespace, "?"),
|
|
||||||
model: cmp.Or(r.model, "?"),
|
|
||||||
tag: cmp.Or(r.tag, "?"),
|
|
||||||
build: cmp.Or(r.build, "?"),
|
|
||||||
}).String()
|
|
||||||
}
|
|
||||||
|
|
||||||
// DisplayShort returns a short display string composed of the model and
|
|
||||||
// tag.
|
|
||||||
func (r Name) DisplayShort() string {
|
func (r Name) DisplayShort() string {
|
||||||
return (Name{
|
return (Name{
|
||||||
model: r.model,
|
model: r.model,
|
||||||
@ -227,8 +217,11 @@ func (r Name) DisplayShort() string {
|
|||||||
}).String()
|
}).String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisplayLong returns a long display string composed of the namespace,
|
// DisplayLong returns the fullest possible display string in form:
|
||||||
// mode, and tag.
|
//
|
||||||
|
// <namespace>/<model>:<tag>
|
||||||
|
//
|
||||||
|
// If any part is missing, it is omitted from the display string.
|
||||||
func (r Name) DisplayLong() string {
|
func (r Name) DisplayLong() string {
|
||||||
return (Name{
|
return (Name{
|
||||||
namespace: r.namespace,
|
namespace: r.namespace,
|
||||||
@ -237,10 +230,14 @@ func (r Name) DisplayLong() string {
|
|||||||
}).String()
|
}).String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns the fullest string respresentation of the Name.
|
// String returns the fullest possible display string in form:
|
||||||
//
|
//
|
||||||
// It includes the build, if any. For a string representation without the
|
// <host>/<namespace>/<model>:<tag>+<build>
|
||||||
// build, use [Name.DisplayFullest].
|
//
|
||||||
|
// If any part is missing, it is omitted from the display string.
|
||||||
|
//
|
||||||
|
// For the fullest possible display string without the build, use
|
||||||
|
// [Name.DisplayFullest].
|
||||||
func (r Name) String() string {
|
func (r Name) String() string {
|
||||||
var b strings.Builder
|
var b strings.Builder
|
||||||
if r.host != "" {
|
if r.host != "" {
|
||||||
@ -263,6 +260,20 @@ func (r Name) String() string {
|
|||||||
return b.String()
|
return b.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GoString implements fmt.GoStringer. It returns a string suitable for
|
||||||
|
// debugging and logging. It is similar to [Name.String] but it always
|
||||||
|
// returns a string that includes all parts of the Name, with missing parts
|
||||||
|
// replaced with a ("?").
|
||||||
|
func (r Name) GoString() string {
|
||||||
|
return (Name{
|
||||||
|
host: cmp.Or(r.host, "?"),
|
||||||
|
namespace: cmp.Or(r.namespace, "?"),
|
||||||
|
model: cmp.Or(r.model, "?"),
|
||||||
|
tag: cmp.Or(r.tag, "?"),
|
||||||
|
build: cmp.Or(r.build, "?"),
|
||||||
|
}).String()
|
||||||
|
}
|
||||||
|
|
||||||
// LogValue implements slog.Valuer.
|
// LogValue implements slog.Valuer.
|
||||||
func (r Name) LogValue() slog.Value {
|
func (r Name) LogValue() slog.Value {
|
||||||
return slog.StringValue(r.GoString())
|
return slog.StringValue(r.GoString())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user