Skip to content

Commit

Permalink
Add v0 compatibility functions
Browse files Browse the repository at this point in the history
bunch of dependants still use a version before generics
this will help migration to be done progressively
  • Loading branch information
cesartw committed Aug 22, 2024
1 parent ea51bfb commit 788c6ad
Show file tree
Hide file tree
Showing 2 changed files with 444 additions and 0 deletions.
71 changes: 71 additions & 0 deletions sliceutil/compatibility.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package sliceutil

// Deprecated: use Join

Check warning on line 3 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function JoinInt should be of the form "JoinInt ..." (revive)

Check warning on line 3 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function JoinInt should be of the form "JoinInt ..." (revive)
func JoinInt(ints []int64) string {
return Join(ints)
}

// Deprecated: use Unique

Check warning on line 8 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function UniqInt64 should be of the form "UniqInt64 ..." (revive)

Check warning on line 8 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function UniqInt64 should be of the form "UniqInt64 ..." (revive)
func UniqInt64(list []int64) []int64 {
return Unique(list)
}

// Deprecated: use Unique

Check warning on line 13 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function UniqString should be of the form "UniqString ..." (revive)

Check warning on line 13 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function UniqString should be of the form "UniqString ..." (revive)
func UniqString(list []string) []string {
return Unique(list)
}

// Deprecated: use MergeUnique

Check warning on line 18 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function UniqueMergeSlices should be of the form "UniqueMergeSlices ..." (revive)

Check warning on line 18 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function UniqueMergeSlices should be of the form "UniqueMergeSlices ..." (revive)
func UniqueMergeSlices(s [][]int64) (result []int64) {
return MergeUnique(s)
}

// Deprecated: use Contains

Check warning on line 23 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function InStringSlice should be of the form "InStringSlice ..." (revive)

Check warning on line 23 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function InStringSlice should be of the form "InStringSlice ..." (revive)
func InStringSlice(list []string, str string) bool {
return Contains(list, str)
}

// Deprecated: use Contains

Check warning on line 28 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function InIntSlice should be of the form "InIntSlice ..." (revive)

Check warning on line 28 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function InIntSlice should be of the form "InIntSlice ..." (revive)
func InIntSlice(list []int, i int) bool {
return Contains(list, i)
}

// Deprecated: use Contains

Check warning on line 33 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function InInt64Slice should be of the form "InInt64Slice ..." (revive)

Check warning on line 33 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function InInt64Slice should be of the form "InInt64Slice ..." (revive)
func InInt64Slice(list []int64, i int64) bool {
return Contains(list, i)
}

// Deprecated: use Repeat

Check warning on line 38 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function RepeatString should be of the form "RepeatString ..." (revive)
func RepeatString(s string, n int) (r []string) {
return Repeat(s, n)
}

// Deprecated: use Choose

Check warning on line 43 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function ChooseString should be of the form "ChooseString ..." (revive)
func ChooseString(l []string) string {
return Choose(l)
}

// Deprecated: use Filter

Check warning on line 48 in sliceutil/compatibility.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported function FilterString should be of the form "FilterString ..." (revive)
func FilterString(list []string, fun func(string) bool) []string {
return Filter(list, fun)
}

// Deprecated: use Remove
func RemoveString(list []string, s string) (out []string) {
return Remove(list, s)
}

// Deprecated: use FilterEmpty
func FilterStringEmpty(e string) bool {
return FilterEmpty(e)
}

// Deprecated: use Filter
func FilterInt(list []int64, fun func(int64) bool) []int64 {
return Filter(list, fun)
}

// Deprecated: use Map
func StringMap(list []string, f func(string) string) []string {
return Map(list, f)
}
Loading

0 comments on commit 788c6ad

Please sign in to comment.