Skip to content

Commit 5b8022f

Browse files
committed
*: fix modernise failures
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
1 parent 70fc5ee commit 5b8022f

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

cmd/umoci/utils_ux.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,10 @@ func uxImage(cmd cli.Command) cli.Command {
182182
if ctx.IsSet("image") {
183183
image := ctx.String("image")
184184

185-
var dir, tag string
186-
sep := strings.Index(image, ":")
187-
if sep == -1 {
185+
dir, tag, ok := strings.Cut(image, ":")
186+
if !ok {
188187
dir = image
189188
tag = "latest"
190-
} else {
191-
dir = image[:sep]
192-
tag = image[sep+1:]
193189
}
194190

195191
// Verify directory value.

oci/casext/map.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
// Used by walkState.mark() to determine which struct members are descriptors to
3232
// recurse into them. We aren't interested in struct members which are not
3333
// either a slice of ispec.Descriptor or ispec.Descriptor themselves.
34-
var descriptorType = reflect.TypeOf(ispec.Descriptor{})
34+
var descriptorType = reflect.TypeFor[ispec.Descriptor]()
3535

3636
// DescriptorMapFunc is a function that is used to provide a mapping between
3737
// different descriptor values with MapDescriptors. It will not be called

oci/casext/mediatype/compress.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ const (
4040
// should only be used for OCI media-types, where this behaviour is
4141
// well-defined.
4242
func SplitMediaTypeSuffix(mediaType string) (baseType, suffix string) {
43-
if suffixStart := strings.Index(mediaType, "+"); suffixStart >= 0 {
44-
return mediaType[:suffixStart], mediaType[suffixStart+1:]
45-
}
46-
return mediaType, ""
43+
baseType, suffix, _ = strings.Cut(mediaType, "+")
44+
return baseType, suffix
4745
}

0 commit comments

Comments
 (0)