Skip to content

Conversation

sudo-bmitch
Copy link
Contributor

Fixes issue

Describe the change

Modernize Go to the 1.22 specs:

  • Use "any" instead of an empty interface.
  • Use range over an integer for for loops.
  • Remove shadow variables in loops now that Go no longer reuses the variable.
  • Use "slices.Contains", "slices.Delete", "slices.Equal", "slices.Index", "slices.SortFunc".
  • Use "cmp.Or", "min", and "max".
  • Use "fmt.Appendf" instead of "Sprintf" for generating a byte slice.
  • Use "errors.Join" or "fmt.Errorf" with multiple "%w" for multiple errors.

Additionally, use modern regclient features:

  • Use "ref.SetTag", "ref.SetDigest", and "ref.AddDigest".
  • Call "regclient.ManifestGet" using "WithManifestDesc" instead of setting the digest on the reference.

How to verify it

There are very few user visible changes (at most some error messages may be improved).

make test

Given the scope of the changes, there is potential for introducing bugs, but it's also likely quite a few other bugs have been resolved by using language built-in features.

Changelog text

  • Chore: Modernize Go to the 1.22 specs.
  • Feat: Add ref.AddDigest method that does not unset the tag.

Please verify and check that the pull request fulfills the following requirements

  • Tests have been added or not applicable
  • Documentation has been added, updated, or not applicable
  • Changes have been rebased to main
  • Multiple commits to the same code have been squashed

- Use "any" instead of an empty interface.
- Use range over an integer for for loops.
- Remove shadow variables in loops now that Go no longer reuses the variable.
- Use "slices.Contains", "slices.Delete", "slices.Equal", "slices.Index", "slices.SortFunc".
- Use "cmp.Or", "min", and "max".
- Use "fmt.Appendf" instead of "Sprintf" for generating a byte slice.
- Use "errors.Join" or "fmt.Errorf" with multiple "%w" for multiple errors.

Additionally, use modern regclient features:

- Use "ref.SetTag", "ref.SetDigest", and "ref.AddDigest".
- Call "regclient.ManifestGet" using "WithManifestDesc" instead of setting the digest on the reference.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
@sudo-bmitch sudo-bmitch merged commit a4aa2bd into regclient:main Feb 18, 2025
5 checks passed
@sudo-bmitch sudo-bmitch deleted the pr-go-1-22-modernize branch February 18, 2025 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant