Skip to content

Commit

Permalink
feat(fate): change sqlite3 to default db
Browse files Browse the repository at this point in the history
  • Loading branch information
godcong committed Dec 2, 2022
1 parent b2f6bc6 commit 4c78bd2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@ Github上第一个开源的中文取名项目(The first chinese name create tool

除非稳定版本会单独出release,以后每次提交都会生成二进制文件的pre_release提供下载.
最新版使用Sqlite3数据库,不在需要导入数据库文件了. 直接下载下面的Sqlite3数据库到本地就能使用.
[v3.5.2下载](https://github.com/babyname/fate/releases/tag/v3.5.2)
[v3.5.4下载](https://github.com/babyname/fate/releases/tag/v3.5.4)
[Sqlite3数据库](https://github.com/babyname/fate/releases/download/auto_build/fate_sqlite3_database.zip)

[最新自编译版本](https://github.com/babyname/fate/releases/tag/auto_build)
[SQL数据库文件:20200331](https://github.com/babyname/fate/releases/download/v3.5.1/fate_db_200331.7z)
[旧版SQL数据库文件:20200331](https://github.com/babyname/fate/releases/download/v3.5.1/fate_db_200331.7z)

### 使用方法

1. 编写运行go代码,接口调用生成姓名

```go
使用前请导入database的数据(测试字库已基本完善, 保险起见生成姓名后可以去一些测名网站验证下)
//使用前请导入database的数据(测试字库已基本完善, 保险起见生成姓名后可以去一些测名网站验证下)
//加载配置(具体参数参考example/create_a_name)
cfg := config.Default()
//生日:
Expand All @@ -54,10 +55,10 @@ Github上第一个开源的中文取名项目(The first chinese name create tool
2. 使用预编译二进制文件生成姓名

```shell
//没有安装go环境的请下载master下的zoneinfo文件和fate二进制文件放一起
//生成配置文件(可修改数据库, 及一些基本参数):
#没有安装go环境的请下载master下的zoneinfo文件和fate二进制文件放一起
#生成配置文件, 可修改数据库, 及一些基本参数
fate.exe init
//输出姓名
#输出姓名
fate.exe name -l 张 -b "2020/02/06 15:04"
```

Expand Down
13 changes: 3 additions & 10 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package config

import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
)
Expand Down Expand Up @@ -67,7 +66,7 @@ func LoadConfig() (c *Config) {
c = &Config{}
def := DefaultConfig()
f := filepath.Join(DefaultJSONPath, JSONName)
bys, e := ioutil.ReadFile(f)
bys, e := os.ReadFile(f)
if e != nil {
return def
}
Expand All @@ -84,7 +83,7 @@ func OutputConfig(config *Config) error {
return e
}

return ioutil.WriteFile(filepath.Join(DefaultJSONPath, JSONName), bys, 0755)
return os.WriteFile(filepath.Join(DefaultJSONPath, JSONName), bys, 0755)
}

func DefaultConfig() *Config {
Expand All @@ -100,16 +99,10 @@ func DefaultConfig() *Config {
BaguaFilter: true,
Regular: true,
Database: Database{
Host: "127.0.0.1",
Port: "3306",
User: "root",
Pwd: "111111",
Name: "fate",
MaxIdleCon: 0,
MaxOpenCon: 0,
Driver: "mysql",
File: "",
Dsn: "",
Driver: "sqlite3",
ShowSQL: false,
ShowExecTime: false,
},
Expand Down

0 comments on commit 4c78bd2

Please sign in to comment.