mirror of
https://github.com/v2fly/domain-list-community.git
synced 2025-12-16 23:50:05 +07:00
Compare commits
1 Commits
2025121616
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d45b17cd8 |
15
main.go
15
main.go
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -107,7 +106,7 @@ func (l *ParsedList) toProto() (*router.GeoSite, error) {
|
||||
})
|
||||
|
||||
default:
|
||||
return nil, errors.New("unknown domain type: " + entry.Type)
|
||||
return nil, fmt.Errorf("unknown domain type: %s", entry.Type)
|
||||
}
|
||||
}
|
||||
return site, nil
|
||||
@@ -153,13 +152,13 @@ func parseDomain(domain string, entry *Entry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.New("Invalid format: " + domain)
|
||||
return fmt.Errorf("invalid format: %s", domain)
|
||||
}
|
||||
|
||||
func parseAttribute(attr string) (*router.Domain_Attribute, error) {
|
||||
var attribute router.Domain_Attribute
|
||||
if len(attr) == 0 || attr[0] != '@' {
|
||||
return &attribute, errors.New("invalid attribute: " + attr)
|
||||
return &attribute, fmt.Errorf("invalid attribute: %s", attr)
|
||||
}
|
||||
|
||||
// Trim attribute prefix `@` character
|
||||
@@ -172,7 +171,7 @@ func parseAttribute(attr string) (*router.Domain_Attribute, error) {
|
||||
attribute.Key = strings.ToLower(parts[0])
|
||||
intv, err := strconv.Atoi(parts[1])
|
||||
if err != nil {
|
||||
return &attribute, errors.New("invalid attribute: " + attr + ": " + err.Error())
|
||||
return &attribute, fmt.Errorf("invalid attribute: %s: %v", attr, err)
|
||||
}
|
||||
attribute.TypedValue = &router.Domain_Attribute_IntValue{IntValue: int64(intv)}
|
||||
}
|
||||
@@ -185,7 +184,7 @@ func parseEntry(line string) (Entry, error) {
|
||||
|
||||
var entry Entry
|
||||
if len(parts) == 0 {
|
||||
return entry, errors.New("empty entry")
|
||||
return entry, fmt.Errorf("empty entry")
|
||||
}
|
||||
|
||||
if err := parseDomain(parts[0], &entry); err != nil {
|
||||
@@ -291,7 +290,7 @@ func ParseList(list *List, ref map[string]*List) (*ParsedList, error) {
|
||||
|
||||
refList := ref[refName]
|
||||
if refList == nil {
|
||||
return nil, errors.New(entry.Value + " not found.")
|
||||
return nil, fmt.Errorf("list not found: %s", entry.Value)
|
||||
}
|
||||
attrEntrys := createIncludeAttrEntrys(refList, attr)
|
||||
if len(attrEntrys) != 0 {
|
||||
@@ -306,7 +305,7 @@ func ParseList(list *List, ref map[string]*List) (*ParsedList, error) {
|
||||
pl.Inclusion[InclusionName] = true
|
||||
refList := ref[refName]
|
||||
if refList == nil {
|
||||
return nil, errors.New(entry.Value + " not found.")
|
||||
return nil, fmt.Errorf("list not found: %s", entry.Value)
|
||||
}
|
||||
newEntryList = append(newEntryList, refList.Entry...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user