修改readme

This commit is contained in:
bjdgy
2024-01-29 00:09:48 +08:00
parent 13de601474
commit 911b96cc74
12 changed files with 205 additions and 91 deletions

View File

@@ -2,6 +2,12 @@ package base
const (
APP_NAME = "AnyLink"
// APP_VER app版本号
APP_VER = "0.10.2"
)
var (
// APP_VER app版本号
APP_VER = "0.0.1"
// 提交id
CommitId string
Date string
)

View File

@@ -1,7 +1,6 @@
package base
import (
"errors"
"fmt"
"io"
"os"
@@ -17,8 +16,6 @@ import (
)
var (
// 提交id
CommitId string
// pass明文
passwd string
// 生成otp
@@ -60,6 +57,15 @@ func execute() {
envs[rr.Key().String()] = rr.Value().Index(0).String()
}
//移动配置解析代码
conf := linkViper.GetString("conf")
linkViper.SetConfigFile(conf)
err = linkViper.ReadInConfig()
if err != nil {
// 没有配置文件,直接报错
panic("config file err:" + err.Error())
}
if !runSrv {
os.Exit(0)
}
@@ -106,19 +112,28 @@ func initCmd() {
cobra.OnInitialize(func() {
linkViper.AutomaticEnv()
conf := linkViper.GetString("conf")
_, err := os.Stat(conf)
if errors.Is(err, os.ErrNotExist) {
// 没有配置文件,不做处理
panic(err)
}
linkViper.SetConfigFile(conf)
err = linkViper.ReadInConfig()
if err != nil {
panic("config file err:" + err.Error())
}
//ver := linkViper.GetBool("version")
//if ver {
// printVersion()
// os.Exit(0)
//}
//
//return
//
//conf := linkViper.GetString("conf")
//_, err := os.Stat(conf)
//if errors.Is(err, os.ErrNotExist) {
// // 没有配置文件,不做处理
// panic("conf stat err:" + err.Error())
//}
//
//
//linkViper.SetConfigFile(conf)
//err = linkViper.ReadInConfig()
//if err != nil {
// panic("config file err:" + err.Error())
//}
})
}
@@ -164,6 +179,6 @@ func initToolCmd() *cobra.Command {
}
func printVersion() {
fmt.Printf("%s v%s build on %s [%s, %s] commit_id(%s) \n",
APP_NAME, APP_VER, runtime.Version(), runtime.GOOS, runtime.GOARCH, CommitId)
fmt.Printf("%s v%s build on %s [%s, %s] %s commit_id(%s)\n",
APP_NAME, APP_VER, runtime.Version(), runtime.GOOS, runtime.GOARCH, Date, CommitId)
}

View File

@@ -20,11 +20,17 @@ import (
var uiData embed.FS
// 程序版本
var CommitId string
var (
appVer string
commitId string
date string
)
func main() {
base.CommitId = CommitId
admin.UiData = uiData
base.APP_VER = appVer
base.CommitId = commitId
base.Date = date
base.Start()
handler.Start()