allow set config file path

This commit is contained in:
wjc 2020-12-26 13:06:02 +08:00
parent d70b774326
commit 601994a372

View File

@ -2,6 +2,7 @@ package main
import ( import (
"encoding/json" "encoding/json"
"flag"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log" "log"
@ -36,8 +37,11 @@ type IpJson struct {
func main() { func main() {
configPath := "./config.json" configPath := flag.String("config", "./config.json", "path to config file")
configJson, err := ioutil.ReadFile(configPath) flag.Parse()
fmt.Println(*configPath)
configJson, err := ioutil.ReadFile(*configPath)
if err != nil { if err != nil {
log.Fatal(err.Error()) log.Fatal(err.Error())
} }