Use strings.CutSuffix

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač 2024-03-09 22:51:50 +01:00
parent 4a43163fba
commit a75ed81668

View File

@ -268,8 +268,8 @@ func decompressDir(t *testing.T, dir string) {
rawLayer["size"] = uncompressedSize
var mimeType string
getRawMapField(t, rawLayer, "mediaType", &mimeType)
if strings.HasSuffix(mimeType, ".gzip") { // This should use CutSuffix with Go ≥1.20
rawLayer["mediaType"] = strings.TrimSuffix(mimeType, ".gzip")
if uncompressedMIMEType, ok := strings.CutSuffix(mimeType, ".gzip"); ok {
rawLayer["mediaType"] = uncompressedMIMEType
}
rawLayers[i] = rawLayer