Compare commits

..

2 Commits

Author SHA1 Message Date
深鸣
6dee1594d4 Add more cn domains (#3166) 2026-01-12 12:59:26 +08:00
深鸣
49cbfc60e5 Add more ad domains (#3168) 2026-01-12 12:23:58 +08:00
8 changed files with 276 additions and 308 deletions

View File

@@ -202,3 +202,7 @@ zhugeio.com
# 车来了 # 车来了
atrace.chelaile.net.cn atrace.chelaile.net.cn
logs.chelaile.net.cn logs.chelaile.net.cn
# 航旅纵横
analytics.umetrip.com
sensors.umetrip.com.cn

View File

@@ -1,43 +1,37 @@
# 远程桌面/远程组网 # 远程桌面/远程组网
## 连连控
asklink.com
## EasyTier
easytier.cn
## Oray ## Oray
oray.com oray.com
oray.net oray.net
orayer.com orayer.com
orayimg.com orayimg.com
sunlogin.net sunlogin.net
## 叮当猫脚本管理系统 懒人精灵远程调试
privateapi.xyz
## ToDesk ## ToDesk
todesk.cn todesk.cn
todesk.com todesk.com
## xEdge干将互联
## 连连控
asklink.com
## 叮当猫脚本管理系统 懒人精灵远程调试
privateapi.xyz
# xEdge干将互联
include:xedge include:xedge
# 文档协作 # 文档协作
## Tower 团队协作 ## 语雀
tower.im nlark.com
yuque.com
## 秀米编辑器
tritoninfo.net
xiumi.us
xiumius.com
## 石墨文档 ## 石墨文档
shimo.im shimo.im
shimonote.com shimonote.com
smgv.cn smgv.cn
## Tower 团队协作
## 语雀 tower.im
nlark.com ## 秀米编辑器
yuque.com tritoninfo.net
xiumi.us
xiumius.com
## 吾道 ## 吾道
woodo.cn woodo.cn

View File

@@ -109,6 +109,9 @@ zhulang.com
zongheng.com zongheng.com
# 娱乐资讯媒体 # 娱乐资讯媒体
# 该部分参考了中文维基百科的「来源考量」:
# - https://zh.wikipedia.org/wiki/WikiProject:电子游戏/来源考量
# - https://zh.wikipedia.org/wiki/WikiProject:ACG/來源考量
include:tgbus include:tgbus
include:vgtime include:vgtime
@@ -143,11 +146,15 @@ ign.com.cn
nadianshi.com nadianshi.com
## 游戏日报 ## 游戏日报
news.yxrb.net news.yxrb.net
## 手谈姬
shoutanjjj.com
## 游戏机实用技术 ## 游戏机实用技术
ucg.cn ucg.cn
## 游戏茶馆 ## 游戏茶馆
youxichaguan.com youxichaguan.com
## 游戏葡萄 ## 游戏葡萄
youxiputao.com youxiputao.com
## 游戏陀螺
youxituoluo.com
## 游研社 ## 游研社
yystv.cn yystv.cn

View File

@@ -230,6 +230,8 @@ xiamenair.com # 厦门航空
12306.cn 12306.cn
95306.cn 95306.cn
ccrgt.com ccrgt.com
## 北京市政交通一卡通
bmac.com.cn
## 车来了 ## 车来了
chelaile.net.cn chelaile.net.cn
## 跨境巴士 ## 跨境巴士

View File

@@ -1,3 +1,4 @@
c.sayhi.360.cn @ads
fenxi.360.cn @ads fenxi.360.cn @ads
fenxi.com @ads fenxi.com @ads
lianmeng.360.cn @ads lianmeng.360.cn @ads

View File

@@ -79,3 +79,14 @@ fymallqa3.com
fymallqa4.com fymallqa4.com
fymallqa7.com fymallqa7.com
fymallqa9.com fymallqa9.com
tdnsdl1.cn
tdnsdl1.com.cn
tdnsdl2.cn
tdnsdl2.com.cn
tdnsdl3.cn
tdnsdl3.com.cn
tdnsdl4.cn
tdnsdl4.com.cn
tdnsdl5.cn
tdnsdl5.com.cn

View File

@@ -1,6 +1,7 @@
ad.browser.qq.com @ads ad.browser.qq.com @ads
ad.qq.com @ads ad.qq.com @ads
ad.qun.qq.com @ads ad.qun.qq.com @ads
ad.tencentmusic.com @ads
ad.weixin.qq.com @ads ad.weixin.qq.com @ads
adfilter.imtt.qq.com @ads adfilter.imtt.qq.com @ads
adnet.qq.com @ads adnet.qq.com @ads
@@ -42,6 +43,7 @@ pmir.3g.qq.com @ads
push.qq.com @ads push.qq.com @ads
qqdata.ab.qq.com @ads qqdata.ab.qq.com @ads
report.qqweb.qq.com @ads report.qqweb.qq.com @ads
report.tencentmusic.com @ads
rmonitor.qq.com @ads rmonitor.qq.com @ads
sngmta.qq.com @ads sngmta.qq.com @ads
stat.y.qq.com @ads stat.y.qq.com @ads

505
main.go
View File

@@ -29,31 +29,10 @@ const (
RuleTypeInclude string = "include" RuleTypeInclude string = "include"
) )
var (
TypeChecker = regexp.MustCompile(`^(domain|full|keyword|regexp|include)$`)
ValueChecker = regexp.MustCompile(`^[a-z0-9!\.-]+$`)
AttrChecker = regexp.MustCompile(`^[a-z0-9!-]+$`)
SiteChecker = regexp.MustCompile(`^[A-Z0-9!-]+$`)
)
var (
refMap = make(map[string]*List)
plMap = make(map[string]*ParsedList)
finalMap = make(map[string][]Entry)
cirIncMap = make(map[string]bool) // Used for circular inclusion detection
)
type Entry struct { type Entry struct {
Type string Type string
Value string Value string
Attrs []string Attrs []*router.Domain_Attribute
Affs []string
}
type Inclusion struct {
Source string
MustAttrs []string
BanAttrs []string
} }
type List struct { type List struct {
@@ -63,115 +42,149 @@ type List struct {
type ParsedList struct { type ParsedList struct {
Name string Name string
Inclusions []Inclusion Inclusion map[string]bool
Entry []Entry Entry []Entry
} }
func makeProtoList(listName string, entries *[]Entry) (*router.GeoSite, error) { func (l *ParsedList) toPlainText(listName string) error {
site := &router.GeoSite{ var entryBytes []byte
CountryCode: listName, for _, entry := range l.Entry {
Domain: make([]*router.Domain, 0, len(*entries)), var attrString string
} if entry.Attrs != nil {
for _, entry := range *entries {
pdomain := &router.Domain{Value: entry.Value}
for _, attr := range entry.Attrs { for _, attr := range entry.Attrs {
pdomain.Attribute = append(pdomain.Attribute, &router.Domain_Attribute{ attrString += "@" + attr.GetKey() + ","
Key: attr, }
TypedValue: &router.Domain_Attribute_BoolValue{BoolValue: true}, attrString = strings.TrimRight(":"+attrString, ",")
}) }
// Entry output format is: type:domain.tld:@attr1,@attr2
entryBytes = append(entryBytes, []byte(entry.Type+":"+entry.Value+attrString+"\n")...)
}
if err := os.WriteFile(filepath.Join(*outputDir, listName+".txt"), entryBytes, 0644); err != nil {
return err
}
return nil
} }
func (l *ParsedList) toProto() (*router.GeoSite, error) {
site := &router.GeoSite{
CountryCode: l.Name,
}
for _, entry := range l.Entry {
switch entry.Type { switch entry.Type {
case RuleTypeDomain: case RuleTypeDomain:
pdomain.Type = router.Domain_RootDomain site.Domain = append(site.Domain, &router.Domain{
Type: router.Domain_RootDomain,
Value: entry.Value,
Attribute: entry.Attrs,
})
case RuleTypeRegexp: case RuleTypeRegexp:
pdomain.Type = router.Domain_Regex // check regexp validity to avoid runtime error
case RuleTypeKeyword: _, err := regexp.Compile(entry.Value)
pdomain.Type = router.Domain_Plain if err != nil {
case RuleTypeFullDomain: return nil, fmt.Errorf("invalid regexp in list %s: %s", l.Name, entry.Value)
pdomain.Type = router.Domain_Full }
site.Domain = append(site.Domain, &router.Domain{
Type: router.Domain_Regex,
Value: entry.Value,
Attribute: entry.Attrs,
})
case RuleTypeKeyword:
site.Domain = append(site.Domain, &router.Domain{
Type: router.Domain_Plain,
Value: entry.Value,
Attribute: entry.Attrs,
})
case RuleTypeFullDomain:
site.Domain = append(site.Domain, &router.Domain{
Type: router.Domain_Full,
Value: entry.Value,
Attribute: entry.Attrs,
})
default:
return nil, fmt.Errorf("unknown domain type: %s", entry.Type)
} }
site.Domain = append(site.Domain, pdomain)
} }
return site, nil return site, nil
} }
func writePlainList(exportedName string) error { func exportPlainTextList(list []string, refName string, pl *ParsedList) {
targetList, exist := finalMap[strings.ToUpper(exportedName)] for _, listName := range list {
if !exist || len(targetList) == 0 { if strings.EqualFold(refName, listName) {
return fmt.Errorf("'%s' list does not exist or is empty.", exportedName) if err := pl.toPlainText(strings.ToLower(refName)); err != nil {
fmt.Println("Failed:", err)
continue
} }
file, err := os.Create(filepath.Join(*outputDir, strings.ToLower(exportedName) + ".txt")) fmt.Printf("'%s' has been generated successfully.\n", listName)
if err != nil {
return err
} }
defer file.Close()
w := bufio.NewWriter(file)
for _, entry := range targetList {
// Entry output format is: type:domain.tld:@attr1,@attr2
var attrString string
if entry.Attrs != nil {
attrString = ":@" + strings.Join(entry.Attrs, ",@")
} }
fmt.Fprintln(w, entry.Type + ":" + entry.Value + attrString)
}
return w.Flush()
} }
func parseEntry(line string) (Entry, error) { func removeComment(line string) string {
var entry Entry idx := strings.Index(line, "#")
parts := strings.Fields(line) if idx == -1 {
return line
}
return strings.TrimSpace(line[:idx])
}
// Parse type and value func parseDomain(domain string, entry *Entry) error {
rawTypeVal := parts[0] kv := strings.Split(domain, ":")
kv := strings.Split(rawTypeVal, ":")
if len(kv) == 1 { if len(kv) == 1 {
entry.Type = RuleTypeDomain // Default type entry.Type = RuleTypeDomain
entry.Value = strings.ToLower(rawTypeVal) entry.Value = strings.ToLower(kv[0])
} else if len(kv) == 2 { return nil
}
if len(kv) == 2 {
entry.Type = strings.ToLower(kv[0]) entry.Type = strings.ToLower(kv[0])
if entry.Type == RuleTypeRegexp {
if strings.EqualFold(entry.Type, RuleTypeRegexp) {
entry.Value = kv[1] entry.Value = kv[1]
} else { } else {
entry.Value = strings.ToLower(kv[1]) entry.Value = strings.ToLower(kv[1])
} }
} else {
return entry, fmt.Errorf("invalid format: %s", line) return nil
}
// Check type and value
if !TypeChecker.MatchString(entry.Type) {
return entry, fmt.Errorf("invalid type: %s", entry.Type)
}
if entry.Type == RuleTypeRegexp {
if _, err := regexp.Compile(entry.Value); err != nil {
return entry, fmt.Errorf("invalid regexp: %s", entry.Value)
}
} else if !ValueChecker.MatchString(entry.Value) {
return entry, fmt.Errorf("invalid value: %s", entry.Value)
} }
// Parse/Check attributes and affiliations return fmt.Errorf("invalid format: %s", domain)
for _, part := range parts[1:] { }
if strings.HasPrefix(part, "@") {
attr := strings.ToLower(part[1:]) // Trim attribute prefix `@` character func parseAttribute(attr string) (*router.Domain_Attribute, error) {
if !AttrChecker.MatchString(attr) { var attribute router.Domain_Attribute
return entry, fmt.Errorf("invalid attribute key: %s", attr) if len(attr) == 0 || attr[0] != '@' {
return &attribute, fmt.Errorf("invalid attribute: %s", attr)
}
attribute.Key = strings.ToLower(attr[1:]) // Trim attribute prefix `@` character
attribute.TypedValue = &router.Domain_Attribute_BoolValue{BoolValue: true}
return &attribute, nil
}
func parseEntry(line string) (Entry, error) {
line = strings.TrimSpace(line)
parts := strings.Split(line, " ")
var entry Entry
if len(parts) == 0 {
return entry, fmt.Errorf("empty entry")
}
if err := parseDomain(parts[0], &entry); err != nil {
return entry, err
}
for i := 1; i < len(parts); i++ {
attr, err := parseAttribute(parts[i])
if err != nil {
return entry, err
} }
entry.Attrs = append(entry.Attrs, attr) entry.Attrs = append(entry.Attrs, attr)
} else if strings.HasPrefix(part, "&") {
aff := strings.ToUpper(part[1:]) // Trim affiliation prefix `&` character
if !SiteChecker.MatchString(aff) {
return entry, fmt.Errorf("invalid affiliation key: %s", aff)
} }
entry.Affs = append(entry.Affs, aff)
} else {
return entry, fmt.Errorf("invalid attribute/affiliation: %s", part)
}
}
// Sort attributes
sort.Slice(entry.Attrs, func(i, j int) bool {
return entry.Attrs[i] < entry.Attrs[j]
})
return entry, nil return entry, nil
} }
@@ -183,20 +196,14 @@ func Load(path string) (*List, error) {
} }
defer file.Close() defer file.Close()
listName := strings.ToUpper(filepath.Base(path)) list := &List{
if !SiteChecker.MatchString(listName) { Name: strings.ToUpper(filepath.Base(path)),
return nil, fmt.Errorf("invalid list name: %s", listName)
} }
list := &List{Name: listName}
scanner := bufio.NewScanner(file) scanner := bufio.NewScanner(file)
for scanner.Scan() { for scanner.Scan() {
line := scanner.Text() line := strings.TrimSpace(scanner.Text())
// Remove comments line = removeComment(line)
if idx := strings.Index(line, "#"); idx != -1 { if len(line) == 0 {
line = line[:idx]
}
line = strings.TrimSpace(line)
if line == "" {
continue continue
} }
entry, err := parseEntry(line) entry, err := parseEntry(line)
@@ -209,158 +216,99 @@ func Load(path string) (*List, error) {
return list, nil return list, nil
} }
func ParseList(refList *List) error { func isMatchAttr(Attrs []*router.Domain_Attribute, includeKey string) bool {
pl := plMap[refList.Name] isMatch := false
if pl == nil { mustMatch := true
pl = &ParsedList{Name: refList.Name} matchName := includeKey
plMap[refList.Name] = pl if strings.HasPrefix(includeKey, "!") {
} isMatch = true
for _, entry := range refList.Entry { mustMatch = false
if entry.Type == RuleTypeInclude { matchName = strings.TrimLeft(includeKey, "!")
if len(entry.Affs) != 0 {
return fmt.Errorf("affiliation is not allowed for include:%s", entry.Value)
}
inc := Inclusion{Source: strings.ToUpper(entry.Value)}
for _, attr := range entry.Attrs {
if strings.HasPrefix(attr, "-") {
inc.BanAttrs = append(inc.BanAttrs, attr[1:]) // Trim attribute prefix `-` character
} else {
inc.MustAttrs = append(inc.MustAttrs, attr)
}
}
pl.Inclusions = append(pl.Inclusions, inc)
} else {
if len(entry.Affs) != 0 {
for _, aff := range entry.Affs {
apl := plMap[aff]
if apl == nil {
apl = &ParsedList{Name: aff}
plMap[aff] = apl
}
apl.Entry = append(apl.Entry, entry)
}
}
pl.Entry = append(pl.Entry, entry)
}
}
return nil
} }
func polishList(rl *[]Entry) []Entry { for _, Attr := range Attrs {
// Remove basic duplicates attrName := Attr.Key
pendingList := make([]Entry, 0, len(*rl)) // Exactly same entries removed if mustMatch {
entry2String := func(e Entry) string { // Attributes already sorted if matchName == attrName {
return e.Type + ":" + e.Value + "@" + strings.Join(e.Attrs, "@") isMatch = true
break
} }
bscDupMap := make(map[string]bool)
for _, entry := range *rl {
if estring := entry2String(entry); !bscDupMap[estring] {
bscDupMap[estring] = true
pendingList = append(pendingList, entry)
}
}
finalList := make([]Entry, 0, len(pendingList))
queuingList := make([]Entry, 0, len(pendingList)) // Domain/full entries without attr
domainsMap := make(map[string]bool)
for _, entry := range pendingList {
switch entry.Type { // Bypass regexp, keyword and "full/domain with attr"
case RuleTypeRegexp:
finalList = append(finalList, entry)
case RuleTypeKeyword:
finalList = append(finalList, entry)
case RuleTypeDomain:
domainsMap[entry.Value] = true
if len(entry.Attrs) != 0 {
finalList = append(finalList, entry)
} else { } else {
queuingList = append(queuingList, entry) if matchName == attrName {
} isMatch = false
case RuleTypeFullDomain:
if len(entry.Attrs) != 0 {
finalList = append(finalList, entry)
} else {
queuingList = append(queuingList, entry)
}
}
}
// Remove redundant subdomains for full/domain without attr
for _, qentry := range queuingList {
parts := strings.Split(qentry.Value, ".")
isRedundant := false
for i := 1; i < len(parts) - 1 ; i++ {
// Not check parent for level2 "name.tld" domain / tld will not become a parent
parentdomain := strings.Join(parts[i:], ".")
if domainsMap[parentdomain] {
isRedundant = true
break break
} }
} }
if !isRedundant {
finalList = append(finalList, qentry)
} }
return isMatch
} }
// Sort final entries func createIncludeAttrEntrys(list *List, matchAttr *router.Domain_Attribute) []Entry {
sort.Slice(finalList, func(i, j int) bool { newEntryList := make([]Entry, 0, len(list.Entry))
if finalList[i].Type != finalList[j].Type { matchName := matchAttr.Key
return finalList[i].Type < finalList[j].Type for _, entry := range list.Entry {
matched := isMatchAttr(entry.Attrs, matchName)
if matched {
newEntryList = append(newEntryList, entry)
} }
if finalList[i].Value != finalList[j].Value {
return finalList[i].Value < finalList[j].Value
} }
// Ideally, the comparison here will not be triggered by source data return newEntryList
return strings.Join(finalList[i].Attrs, ",") < strings.Join(finalList[j].Attrs, ",")
})
return finalList
} }
func ResolveList(pl *ParsedList) error { func ParseList(list *List, ref map[string]*List) (*ParsedList, error) {
if _, pldone := finalMap[pl.Name]; pldone { return nil } pl := &ParsedList{
Name: list.Name,
if cirIncMap[pl.Name] { Inclusion: make(map[string]bool),
return fmt.Errorf("circular inclusion in: %s", pl.Name)
} }
cirIncMap[pl.Name] = true entryList := list.Entry
defer delete(cirIncMap, pl.Name) for {
newEntryList := make([]Entry, 0, len(entryList))
isMatchAttrFilters := func(entry Entry, incFilter Inclusion) bool { hasInclude := false
if len(incFilter.MustAttrs) == 0 && len(incFilter.BanAttrs) == 0 { return true } for _, entry := range entryList {
if len(entry.Attrs) == 0 { return len(incFilter.MustAttrs) == 0 } if entry.Type == RuleTypeInclude {
refName := strings.ToUpper(entry.Value)
attrMap := make(map[string]bool) if entry.Attrs != nil {
for _, attr := range entry.Attrs { for _, attr := range entry.Attrs {
attrMap[attr] = true InclusionName := strings.ToUpper(refName + "@" + attr.Key)
} if pl.Inclusion[InclusionName] {
for _, m := range incFilter.MustAttrs { continue
if !attrMap[m] { return false }
}
for _, b := range incFilter.BanAttrs {
if attrMap[b] { return false }
}
return true
} }
pl.Inclusion[InclusionName] = true
var roughList []Entry refList := ref[refName]
roughList = append(roughList, pl.Entry...) if refList == nil {
return nil, fmt.Errorf("list not found: %s", entry.Value)
}
attrEntrys := createIncludeAttrEntrys(refList, attr)
if len(attrEntrys) != 0 {
newEntryList = append(newEntryList, attrEntrys...)
}
}
} else {
InclusionName := refName
if pl.Inclusion[InclusionName] {
continue
}
pl.Inclusion[InclusionName] = true
refList := ref[refName]
if refList == nil {
return nil, fmt.Errorf("list not found: %s", entry.Value)
}
newEntryList = append(newEntryList, refList.Entry...)
}
hasInclude = true
} else {
newEntryList = append(newEntryList, entry)
}
}
entryList = newEntryList
if !hasInclude {
break
}
}
pl.Entry = entryList
for _, inc := range pl.Inclusions { return pl, nil
incPl, exist := plMap[inc.Source]
if !exist {
return fmt.Errorf("list '%s' includes a non-existent list: '%s'", pl.Name, inc.Source)
}
if err := ResolveList(incPl); err != nil {
return err
}
for _, ientry := range finalMap[inc.Source] {
if isMatchAttrFilters(ientry, inc) {
roughList = append(roughList, ientry)
}
}
}
finalMap[pl.Name] = polishList(&roughList)
return nil
} }
func main() { func main() {
@@ -369,7 +317,7 @@ func main() {
dir := *dataPath dir := *dataPath
fmt.Println("Use domain lists in", dir) fmt.Println("Use domain lists in", dir)
// Generate refMap ref := make(map[string]*List)
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil { if err != nil {
return err return err
@@ -381,7 +329,7 @@ func main() {
if err != nil { if err != nil {
return err return err
} }
refMap[list.Name] = list ref[list.Name] = list
return nil return nil
}) })
if err != nil { if err != nil {
@@ -389,22 +337,6 @@ func main() {
os.Exit(1) os.Exit(1)
} }
// Generate plMap
for _, refList := range refMap {
if err := ParseList(refList); err != nil {
fmt.Println("Failed to ParseList:", err)
os.Exit(1)
}
}
// Generate finalMap
for _, pl := range plMap {
if err := ResolveList(pl); err != nil {
fmt.Println("Failed to ResolveList:", err)
os.Exit(1)
}
}
// Create output directory if not exist // Create output directory if not exist
if _, err := os.Stat(*outputDir); os.IsNotExist(err) { if _, err := os.Stat(*outputDir); os.IsNotExist(err) {
if mkErr := os.MkdirAll(*outputDir, 0755); mkErr != nil { if mkErr := os.MkdirAll(*outputDir, 0755); mkErr != nil {
@@ -413,28 +345,43 @@ func main() {
} }
} }
// Export plaintext list
if *exportLists != "" {
exportedListSlice := strings.Split(*exportLists, ",")
for _, exportedList := range exportedListSlice {
if err := writePlainList(exportedList); err != nil {
fmt.Println("Failed to write list:", err)
continue
}
fmt.Printf("list: '%s' has been generated successfully.\n", exportedList)
}
}
// Generate dat file
protoList := new(router.GeoSiteList) protoList := new(router.GeoSiteList)
for siteName, siteEntries := range finalMap { var existList []string
site, err := makeProtoList(siteName, &siteEntries) for refName, list := range ref {
pl, err := ParseList(list, ref)
if err != nil {
fmt.Println("Failed:", err)
os.Exit(1)
}
site, err := pl.toProto()
if err != nil { if err != nil {
fmt.Println("Failed:", err) fmt.Println("Failed:", err)
os.Exit(1) os.Exit(1)
} }
protoList.Entry = append(protoList.Entry, site) protoList.Entry = append(protoList.Entry, site)
// Flatten and export plaintext list
if *exportLists != "" {
if existList != nil {
exportPlainTextList(existList, refName, pl)
} else {
exportedListSlice := strings.Split(*exportLists, ",")
for _, exportedListName := range exportedListSlice {
fileName := filepath.Join(dir, exportedListName)
_, err := os.Stat(fileName)
if err == nil || os.IsExist(err) {
existList = append(existList, exportedListName)
} else {
fmt.Printf("'%s' list does not exist in '%s' directory.\n", exportedListName, dir)
} }
}
if existList != nil {
exportPlainTextList(existList, refName, pl)
}
}
}
}
// Sort protoList so the marshaled list is reproducible // Sort protoList so the marshaled list is reproducible
sort.SliceStable(protoList.Entry, func(i, j int) bool { sort.SliceStable(protoList.Entry, func(i, j int) bool {
return protoList.Entry[i].CountryCode < protoList.Entry[j].CountryCode return protoList.Entry[i].CountryCode < protoList.Entry[j].CountryCode
@@ -442,11 +389,11 @@ func main() {
protoBytes, err := proto.Marshal(protoList) protoBytes, err := proto.Marshal(protoList)
if err != nil { if err != nil {
fmt.Println("Failed to marshal:", err) fmt.Println("Failed:", err)
os.Exit(1) os.Exit(1)
} }
if err := os.WriteFile(filepath.Join(*outputDir, *outputName), protoBytes, 0644); err != nil { if err := os.WriteFile(filepath.Join(*outputDir, *outputName), protoBytes, 0644); err != nil {
fmt.Println("Failed to write output:", err) fmt.Println("Failed:", err)
os.Exit(1) os.Exit(1)
} else { } else {
fmt.Println(*outputName, "has been generated successfully.") fmt.Println(*outputName, "has been generated successfully.")