refactor: replace interface{} to any #21973
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request replaces all instances of the
interface{}type with theanytype across the codebase for improved readability and alignment with Go 1.18+ conventions. The changes span multiple files and functions, including core utilities, APIs, and test files.Type Replacement:
interface{}toanyCore API and Utility Functions:
src/common/api/base.goto useanyinstead ofinterface{}for methods likeDecodeJSONReq,Validate, andDecodeJSONReqAndValidate. [1] [2] [3]src/common/utils/utils.gosuch asConvertMapToStruct,SafeCastString, andSafeCastIntto replaceinterface{}withany. [1] [2] [3]Data Structures and Models:
interface{}withanyin type definitions likeParametersandMessageinsrc/common/job/models/models.go. [1] [2]defaultConfig) to usemap[string]anyinstead ofmap[string]interface{}. [1] [2]HTTP Client and Logging:
Get,Post,Put) insrc/common/http/client.goto useany. [1] [2] [3]src/common/dao/base.goto useany.Test Files:
interface{}withanyin files likesrc/common/utils/utils_test.goandsrc/controller/artifact/annotation/v1alpha1_test.go. [1] [2]These updates enhance code clarity and leverage Go's modern type system, making the codebase more idiomatic and easier to maintain.Thank you for contributing to Harbor!
Comprehensive Summary of your change
Issue being fixed
Fixes #(issue)
Please indicate you've done the following: