Print error in function main
This commit is contained in:
parent
200d0a4788
commit
b1f09e11fc
20
main.go
20
main.go
@ -87,17 +87,17 @@ func parseEntry(line string) (Entry, error) {
|
||||
return Entry{}, errors.New("Invalid format: " + line)
|
||||
}
|
||||
|
||||
func DetectPath(path string) string {
|
||||
arrPath := strings.Split(path,":")
|
||||
for _,content := range arrPath {
|
||||
func DetectPath(path string) (string, error) {
|
||||
arrPath := strings.Split(path, string(filepath.ListSeparator))
|
||||
for _, content := range arrPath {
|
||||
fullPath := filepath.Join(content, "src", "github.com", "v2ray", "domain-list-community", "data")
|
||||
_, err := os.Stat(fullPath)
|
||||
if err == nil || os.IsExist(err) {
|
||||
return fullPath
|
||||
return fullPath, nil
|
||||
}
|
||||
}
|
||||
fmt.Println("Failed: No file found in GOPATH")
|
||||
return ""
|
||||
err := errors.New("No file found in GOPATH")
|
||||
return "", err
|
||||
}
|
||||
|
||||
func Load(path string) (*List, error) {
|
||||
@ -164,9 +164,13 @@ func ParseList(list *List, ref map[string]*List) (*ParsedList, error) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
dir := DetectPath(os.Getenv("GOPATH"))
|
||||
dir, err := DetectPath(os.Getenv("GOPATH"))
|
||||
if err != nil {
|
||||
fmt.Println("Failed: ", err)
|
||||
return
|
||||
}
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user