summaryrefslogtreecommitdiffstats
path: root/modules/packages
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2023-07-04 20:36:08 +0200
committerGitHub <noreply@github.com>2023-07-04 20:36:08 +0200
commit88f835192d1a554d233b0ec4daa33276b7eb2910 (patch)
tree438140c295791e64a3b78dcfeae57701bcf296c3 /modules/packages
parentSeveral fixes for mobile UI (#25634) (diff)
downloadforgejo-88f835192d1a554d233b0ec4daa33276b7eb2910.tar.xz
forgejo-88f835192d1a554d233b0ec4daa33276b7eb2910.zip
Replace `interface{}` with `any` (#25686)
Result of running `perl -p -i -e 's#interface\{\}#any#g' **/*` and `make fmt`. Basically the same [as golang did](https://github.com/golang/go/commit/2580d0e08d5e9f979b943758d3c49877fb2324cb).
Diffstat (limited to 'modules/packages')
-rw-r--r--modules/packages/composer/metadata.go24
-rw-r--r--modules/packages/helm/metadata.go16
-rw-r--r--modules/packages/pub/metadata.go14
-rw-r--r--modules/packages/rubygems/marshal.go10
-rw-r--r--modules/packages/rubygems/marshal_test.go4
-rw-r--r--modules/packages/rubygems/metadata.go52
6 files changed, 60 insertions, 60 deletions
diff --git a/modules/packages/composer/metadata.go b/modules/packages/composer/metadata.go
index 36b0b8e421..1d0f025648 100644
--- a/modules/packages/composer/metadata.go
+++ b/modules/packages/composer/metadata.go
@@ -38,18 +38,18 @@ type Package struct {
// Metadata represents the metadata of a Composer package
type Metadata struct {
- Description string `json:"description,omitempty"`
- Keywords []string `json:"keywords,omitempty"`
- Homepage string `json:"homepage,omitempty"`
- License Licenses `json:"license,omitempty"`
- Authors []Author `json:"authors,omitempty"`
- Autoload map[string]interface{} `json:"autoload,omitempty"`
- AutoloadDev map[string]interface{} `json:"autoload-dev,omitempty"`
- Extra map[string]interface{} `json:"extra,omitempty"`
- Require map[string]string `json:"require,omitempty"`
- RequireDev map[string]string `json:"require-dev,omitempty"`
- Suggest map[string]string `json:"suggest,omitempty"`
- Provide map[string]string `json:"provide,omitempty"`
+ Description string `json:"description,omitempty"`
+ Keywords []string `json:"keywords,omitempty"`
+ Homepage string `json:"homepage,omitempty"`
+ License Licenses `json:"license,omitempty"`
+ Authors []Author `json:"authors,omitempty"`
+ Autoload map[string]any `json:"autoload,omitempty"`
+ AutoloadDev map[string]any `json:"autoload-dev,omitempty"`
+ Extra map[string]any `json:"extra,omitempty"`
+ Require map[string]string `json:"require,omitempty"`
+ RequireDev map[string]string `json:"require-dev,omitempty"`
+ Suggest map[string]string `json:"suggest,omitempty"`
+ Provide map[string]string `json:"provide,omitempty"`
}
// Licenses represents the licenses of a Composer package
diff --git a/modules/packages/helm/metadata.go b/modules/packages/helm/metadata.go
index fdbd9003b8..421fc5e725 100644
--- a/modules/packages/helm/metadata.go
+++ b/modules/packages/helm/metadata.go
@@ -55,14 +55,14 @@ type Maintainer struct {
}
type Dependency struct {
- Name string `json:"name" yaml:"name"`
- Version string `json:"version,omitempty" yaml:"version,omitempty"`
- Repository string `json:"repository" yaml:"repository"`
- Condition string `json:"condition,omitempty" yaml:"condition,omitempty"`
- Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
- Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
- ImportValues []interface{} `json:"import_values,omitempty" yaml:"import-values,omitempty"`
- Alias string `json:"alias,omitempty" yaml:"alias,omitempty"`
+ Name string `json:"name" yaml:"name"`
+ Version string `json:"version,omitempty" yaml:"version,omitempty"`
+ Repository string `json:"repository" yaml:"repository"`
+ Condition string `json:"condition,omitempty" yaml:"condition,omitempty"`
+ Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
+ Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
+ ImportValues []any `json:"import_values,omitempty" yaml:"import-values,omitempty"`
+ Alias string `json:"alias,omitempty" yaml:"alias,omitempty"`
}
// ParseChartArchive parses the metadata of a Helm archive
diff --git a/modules/packages/pub/metadata.go b/modules/packages/pub/metadata.go
index 13a066afac..afb464e462 100644
--- a/modules/packages/pub/metadata.go
+++ b/modules/packages/pub/metadata.go
@@ -38,12 +38,12 @@ type Package struct {
// Metadata represents the metadata of a Pub package
type Metadata struct {
- Description string `json:"description,omitempty"`
- ProjectURL string `json:"project_url,omitempty"`
- RepositoryURL string `json:"repository_url,omitempty"`
- DocumentationURL string `json:"documentation_url,omitempty"`
- Readme string `json:"readme,omitempty"`
- Pubspec interface{} `json:"pubspec"`
+ Description string `json:"description,omitempty"`
+ ProjectURL string `json:"project_url,omitempty"`
+ RepositoryURL string `json:"repository_url,omitempty"`
+ DocumentationURL string `json:"documentation_url,omitempty"`
+ Readme string `json:"readme,omitempty"`
+ Pubspec any `json:"pubspec"`
}
type pubspecPackage struct {
@@ -134,7 +134,7 @@ func ParsePubspecMetadata(r io.Reader) (*Package, error) {
p.Repository = ""
}
- var pubspec interface{}
+ var pubspec any
if err := yaml.Unmarshal(buf, &pubspec); err != nil {
return nil, err
}
diff --git a/modules/packages/rubygems/marshal.go b/modules/packages/rubygems/marshal.go
index efb2ba34a4..8878dcf973 100644
--- a/modules/packages/rubygems/marshal.go
+++ b/modules/packages/rubygems/marshal.go
@@ -40,19 +40,19 @@ var (
// RubyUserMarshal is a Ruby object that has a marshal_load function.
type RubyUserMarshal struct {
Name string
- Value interface{}
+ Value any
}
// RubyUserDef is a Ruby object that has a _load function.
type RubyUserDef struct {
Name string
- Value interface{}
+ Value any
}
// RubyObject is a default Ruby object.
type RubyObject struct {
Name string
- Member map[string]interface{}
+ Member map[string]any
}
// MarshalEncoder mimics Rubys Marshal class.
@@ -71,7 +71,7 @@ func NewMarshalEncoder(w io.Writer) *MarshalEncoder {
}
// Encode encodes the given type
-func (e *MarshalEncoder) Encode(v interface{}) error {
+func (e *MarshalEncoder) Encode(v any) error {
if _, err := e.w.Write([]byte{majorVersion, minorVersion}); err != nil {
return err
}
@@ -83,7 +83,7 @@ func (e *MarshalEncoder) Encode(v interface{}) error {
return e.w.Flush()
}
-func (e *MarshalEncoder) marshal(v interface{}) error {
+func (e *MarshalEncoder) marshal(v any) error {
if v == nil {
return e.marshalNil()
}
diff --git a/modules/packages/rubygems/marshal_test.go b/modules/packages/rubygems/marshal_test.go
index 501757bfed..6d2354cd87 100644
--- a/modules/packages/rubygems/marshal_test.go
+++ b/modules/packages/rubygems/marshal_test.go
@@ -12,7 +12,7 @@ import (
func TestMinimalEncoder(t *testing.T) {
cases := []struct {
- Value interface{}
+ Value any
Expected []byte
Error error
}{
@@ -73,7 +73,7 @@ func TestMinimalEncoder(t *testing.T) {
{
Value: &RubyObject{
Name: "Test",
- Member: map[string]interface{}{
+ Member: map[string]any{
"test": 4,
},
},
diff --git a/modules/packages/rubygems/metadata.go b/modules/packages/rubygems/metadata.go
index adc1c05808..8a9794860e 100644
--- a/modules/packages/rubygems/metadata.go
+++ b/modules/packages/rubygems/metadata.go
@@ -65,12 +65,12 @@ type gemspec struct {
Version struct {
Version string `yaml:"version"`
} `yaml:"version"`
- Platform string `yaml:"platform"`
- Authors []string `yaml:"authors"`
- Autorequire interface{} `yaml:"autorequire"`
- Bindir string `yaml:"bindir"`
- CertChain []interface{} `yaml:"cert_chain"`
- Date string `yaml:"date"`
+ Platform string `yaml:"platform"`
+ Authors []string `yaml:"authors"`
+ Autorequire any `yaml:"autorequire"`
+ Bindir string `yaml:"bindir"`
+ CertChain []any `yaml:"cert_chain"`
+ Date string `yaml:"date"`
Dependencies []struct {
Name string `yaml:"name"`
Requirement requirement `yaml:"requirement"`
@@ -78,34 +78,34 @@ type gemspec struct {
Prerelease bool `yaml:"prerelease"`
VersionRequirements requirement `yaml:"version_requirements"`
} `yaml:"dependencies"`
- Description string `yaml:"description"`
- Executables []string `yaml:"executables"`
- Extensions []interface{} `yaml:"extensions"`
- ExtraRdocFiles []string `yaml:"extra_rdoc_files"`
- Files []string `yaml:"files"`
- Homepage string `yaml:"homepage"`
- Licenses []string `yaml:"licenses"`
+ Description string `yaml:"description"`
+ Executables []string `yaml:"executables"`
+ Extensions []any `yaml:"extensions"`
+ ExtraRdocFiles []string `yaml:"extra_rdoc_files"`
+ Files []string `yaml:"files"`
+ Homepage string `yaml:"homepage"`
+ Licenses []string `yaml:"licenses"`
Metadata struct {
BugTrackerURI string `yaml:"bug_tracker_uri"`
ChangelogURI string `yaml:"changelog_uri"`
DocumentationURI string `yaml:"documentation_uri"`
SourceCodeURI string `yaml:"source_code_uri"`
} `yaml:"metadata"`
- PostInstallMessage interface{} `yaml:"post_install_message"`
- RdocOptions []interface{} `yaml:"rdoc_options"`
- RequirePaths []string `yaml:"require_paths"`
- RequiredRubyVersion requirement `yaml:"required_ruby_version"`
- RequiredRubygemsVersion requirement `yaml:"required_rubygems_version"`
- Requirements []interface{} `yaml:"requirements"`
- RubygemsVersion string `yaml:"rubygems_version"`
- SigningKey interface{} `yaml:"signing_key"`
- SpecificationVersion int `yaml:"specification_version"`
- Summary string `yaml:"summary"`
- TestFiles []interface{} `yaml:"test_files"`
+ PostInstallMessage any `yaml:"post_install_message"`
+ RdocOptions []any `yaml:"rdoc_options"`
+ RequirePaths []string `yaml:"require_paths"`
+ RequiredRubyVersion requirement `yaml:"required_ruby_version"`
+ RequiredRubygemsVersion requirement `yaml:"required_rubygems_version"`
+ Requirements []any `yaml:"requirements"`
+ RubygemsVersion string `yaml:"rubygems_version"`
+ SigningKey any `yaml:"signing_key"`
+ SpecificationVersion int `yaml:"specification_version"`
+ Summary string `yaml:"summary"`
+ TestFiles []any `yaml:"test_files"`
}
type requirement struct {
- Requirements [][]interface{} `yaml:"requirements"`
+ Requirements [][]any `yaml:"requirements"`
}
// AsVersionRequirement converts into []VersionRequirement
@@ -119,7 +119,7 @@ func (r requirement) AsVersionRequirement() []VersionRequirement {
if !ok {
continue
}
- vm, ok := req[1].(map[string]interface{})
+ vm, ok := req[1].(map[string]any)
if !ok {
continue
}