You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.4 KiB
Go
85 lines
2.4 KiB
Go
/**
|
|
* @Author: jager
|
|
* @Email: lhj168os@gmail.com
|
|
* @File: conf
|
|
* @Date: 2022/2/9 6:01 下午
|
|
* @package: conf
|
|
* @Version: v1.0.0
|
|
*
|
|
* @Description:
|
|
*
|
|
*/
|
|
|
|
package conf
|
|
|
|
import "github.com/jageros/hawox/flags"
|
|
|
|
const (
|
|
keySoupPath = "soup.path"
|
|
keyDatePath = "date.path"
|
|
keyDictPath = "dict.path"
|
|
keyMysqlAddr = "mysql.addr"
|
|
keyMysqlUser = "mysql.user"
|
|
keyMysqlPwd = "mysql.password"
|
|
keyMysqlDB = "mysql.database"
|
|
keyRedisAddrs = "redis.addrs"
|
|
keyRedisUser = "redis.user"
|
|
keyRedisPwd = "redis.password"
|
|
keyRedisDB = "redis.db"
|
|
keyListenIP = "listen.ip"
|
|
keyListenPort = "listen.port"
|
|
)
|
|
|
|
var (
|
|
SoupPath = "conf.d/soup.txt"
|
|
DatePath = "conf.d/date.json"
|
|
DictPath = "conf.d/dict.txt"
|
|
|
|
MysqlAddr = "127.0.0.1:3306"
|
|
MysqlUser = "root"
|
|
MysqlPwd = "QianYin@66"
|
|
MysqlDB = "hawox"
|
|
|
|
RedisAddrs = "127.0.0.1:6379"
|
|
RedisUser = ""
|
|
RedisPassword = ""
|
|
RedisDBNo = 0
|
|
|
|
ListenIP = ""
|
|
ListenPort = 8001
|
|
)
|
|
|
|
var (
|
|
Keys = map[string]*flags.ValInfo{
|
|
keySoupPath: {Val: SoupPath, Description: "soup path"},
|
|
keyDatePath: {Val: DatePath, Description: "date json path"},
|
|
keyDictPath: {Val: DictPath, Description: "dirty word txt path"},
|
|
keyMysqlAddr: {Val: MysqlAddr, Description: "mysql addr"},
|
|
keyMysqlUser: {Val: MysqlUser, Description: "mysql user"},
|
|
keyMysqlPwd: {Val: MysqlPwd, Description: "mysql password"},
|
|
keyMysqlDB: {Val: MysqlDB, Description: "mysql database"},
|
|
keyRedisAddrs: {Val: RedisAddrs, Description: "redis addrs"},
|
|
keyRedisUser: {Val: RedisUser, Description: "redis user"},
|
|
keyRedisPwd: {Val: RedisPassword, Description: "redis password"},
|
|
keyRedisDB: {Val: RedisDBNo, Description: "redis db No"},
|
|
keyListenIP: {Val: ListenIP, Description: "listen ip"},
|
|
keyListenPort: {Val: ListenPort, Description: "listen port"},
|
|
}
|
|
)
|
|
|
|
func ParseFromFlags() {
|
|
SoupPath = flags.GetString(keySoupPath)
|
|
DatePath = flags.GetString(keyDatePath)
|
|
DictPath = flags.GetString(keyDictPath)
|
|
MysqlAddr = flags.GetString(keyMysqlAddr)
|
|
MysqlUser = flags.GetString(keyMysqlUser)
|
|
MysqlPwd = flags.GetString(keyMysqlPwd)
|
|
MysqlDB = flags.GetString(keyMysqlDB)
|
|
RedisAddrs = flags.GetString(keyRedisAddrs)
|
|
RedisUser = flags.GetString(keyRedisUser)
|
|
RedisPassword = flags.GetString(keyRedisPwd)
|
|
RedisDBNo = flags.GetInt(keyRedisDB)
|
|
ListenIP = flags.GetString(keyListenIP)
|
|
ListenPort = flags.GetInt(keyListenPort)
|
|
}
|