Skip to content

Commit

Permalink
Make code compatible with golang 1.20 to support armv7-2.6 and x86-2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
maksimkurb committed Nov 17, 2024
1 parent b7f6f41 commit d7b1507
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module maksimkurb/keenetic-pbr

go 1.22
go 1.20

require github.com/BurntSushi/toml v1.4.0
21 changes: 18 additions & 3 deletions lib/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"
"path/filepath"
"regexp"
"slices"
"sort"
"strings"
)

Expand Down Expand Up @@ -118,8 +118,7 @@ func ApplyLists(config *Config) error {
}
defer f.Close()

slices.Sort(domains)
domains = slices.Compact(domains)
domains = removeDuplicates(domains)

writer := bufio.NewWriter(f)
for _, domain := range domains {
Expand All @@ -134,3 +133,19 @@ func ApplyLists(config *Config) error {
log.Print("Configuration applied successfully")
return nil
}

func removeDuplicates(strings []string) []string {
sort.Strings(strings)
// Remove duplicates
if len(strings) > 0 {
j := 1
for i := 1; i < len(strings); i++ {
if strings[i] != strings[i-1] {
strings[j] = strings[i]
j++
}
}
strings = strings[:j]
}
return strings
}

0 comments on commit d7b1507

Please sign in to comment.