Follow VictoriaRaymond
This commit is contained in:
parent
cc90b4ea10
commit
200d0a4788
18
main.go
18
main.go
@ -87,23 +87,17 @@ func parseEntry(line string) (Entry, error) {
|
|||||||
return Entry{}, errors.New("Invalid format: " + line)
|
return Entry{}, errors.New("Invalid format: " + line)
|
||||||
}
|
}
|
||||||
|
|
||||||
func split(r rune) bool {
|
func DetectPath(path string) string {
|
||||||
if r == ':' {
|
arrPath := strings.Split(path,":")
|
||||||
return true
|
for _,content := range arrPath {
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
func DetectionPath(gopath string) string {
|
|
||||||
path := os.Getenv(gopath)
|
|
||||||
arrPath := strings.FieldsFunc(path, split)
|
|
||||||
for _, content := range arrPath {
|
|
||||||
fullPath := filepath.Join(content, "src", "github.com", "v2ray", "domain-list-community", "data")
|
fullPath := filepath.Join(content, "src", "github.com", "v2ray", "domain-list-community", "data")
|
||||||
_, err := os.Stat(fullPath)
|
_, err := os.Stat(fullPath)
|
||||||
if err == nil || os.IsExist(err) {
|
if err == nil || os.IsExist(err) {
|
||||||
return fullPath
|
return fullPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
panic("No File found in GOPATH")
|
fmt.Println("Failed: No file found in GOPATH")
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func Load(path string) (*List, error) {
|
func Load(path string) (*List, error) {
|
||||||
@ -170,7 +164,7 @@ func ParseList(list *List, ref map[string]*List) (*ParsedList, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
dir := DetectionPath("GOPATH")
|
dir := DetectPath(os.Getenv("GOPATH"))
|
||||||
ref := make(map[string]*List)
|
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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user