mirror of
https://github.com/v2fly/domain-list-community.git
synced 2024-11-16 17:14:52 +02:00
Feat: add --datapath flag for custom data folder
This commit is contained in:
parent
440aef863b
commit
1271c8c4e2
15
main.go
15
main.go
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@ -14,6 +15,8 @@ import (
|
||||
"v2ray.com/core/app/router"
|
||||
)
|
||||
|
||||
var dataPath = flag.String("datapath", "", "Path to the data folder")
|
||||
|
||||
type Entry struct {
|
||||
Type string
|
||||
Value string
|
||||
@ -216,7 +219,15 @@ func ParseList(list *List, ref map[string]*List) (*ParsedList, error) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
dir, err := DetectPath(os.Getenv("GOPATH"))
|
||||
flag.Parse()
|
||||
|
||||
var dir string
|
||||
var err error
|
||||
if *dataPath != "" {
|
||||
dir = *dataPath
|
||||
} else {
|
||||
dir, err = DetectPath(os.Getenv("GOPATH"))
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Println("Failed: ", err)
|
||||
return
|
||||
@ -263,5 +274,7 @@ func main() {
|
||||
}
|
||||
if err := ioutil.WriteFile("dlc.dat", protoBytes, 0777); err != nil {
|
||||
fmt.Println("Failed: ", err)
|
||||
} else {
|
||||
fmt.Println("dlc.dat has been generated successfully.")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user