chore: change interface{} to any (#2818)

* chore: change interface{} to any

* chore: update goctl version to 1.5.0

* chore: update goctl deps
This commit is contained in:
Kevin Wan
2023-01-24 16:32:02 +08:00
committed by GitHub
parent 7e0ac77139
commit ae87114282
221 changed files with 1910 additions and 2207 deletions

View File

@@ -17,14 +17,14 @@ const (
// Set is not thread-safe, for concurrent use, make sure to use it with synchronization.
type Set struct {
data map[interface{}]lang.PlaceholderType
data map[any]lang.PlaceholderType
tp int
}
// NewSet returns a managed Set, can only put the values with the same type.
func NewSet() *Set {
return &Set{
data: make(map[interface{}]lang.PlaceholderType),
data: make(map[any]lang.PlaceholderType),
tp: untyped,
}
}
@@ -32,13 +32,13 @@ func NewSet() *Set {
// NewUnmanagedSet returns an unmanaged Set, which can put values with different types.
func NewUnmanagedSet() *Set {
return &Set{
data: make(map[interface{}]lang.PlaceholderType),
data: make(map[any]lang.PlaceholderType),
tp: unmanaged,
}
}
// Add adds i into s.
func (s *Set) Add(i ...interface{}) {
func (s *Set) Add(i ...any) {
for _, each := range i {
s.add(each)
}
@@ -80,7 +80,7 @@ func (s *Set) AddStr(ss ...string) {
}
// Contains checks if i is in s.
func (s *Set) Contains(i interface{}) bool {
func (s *Set) Contains(i any) bool {
if len(s.data) == 0 {
return false
}
@@ -91,8 +91,8 @@ func (s *Set) Contains(i interface{}) bool {
}
// Keys returns the keys in s.
func (s *Set) Keys() []interface{} {
var keys []interface{}
func (s *Set) Keys() []any {
var keys []any
for key := range s.data {
keys = append(keys, key)
@@ -167,7 +167,7 @@ func (s *Set) KeysStr() []string {
}
// Remove removes i from s.
func (s *Set) Remove(i interface{}) {
func (s *Set) Remove(i any) {
s.validate(i)
delete(s.data, i)
}
@@ -177,7 +177,7 @@ func (s *Set) Count() int {
return len(s.data)
}
func (s *Set) add(i interface{}) {
func (s *Set) add(i any) {
switch s.tp {
case unmanaged:
// do nothing
@@ -189,7 +189,7 @@ func (s *Set) add(i interface{}) {
s.data[i] = lang.Placeholder
}
func (s *Set) setType(i interface{}) {
func (s *Set) setType(i any) {
// s.tp can only be untyped here
switch i.(type) {
case int:
@@ -205,7 +205,7 @@ func (s *Set) setType(i interface{}) {
}
}
func (s *Set) validate(i interface{}) {
func (s *Set) validate(i any) {
if s.tp == unmanaged {
return
}