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