1 Star 0 Fork 0

ichub/go-factroy2024

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.05 KB
一键复制 编辑 原始数据 按行查看 历史
leijmdas 提交于 2024-02-01 12:27 . add
package main
import (
"fmt"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
"github.com/spf13/viper"
"gitee.com/ichub/go-factroy2024/common/dbcontent"
"gitee.com/ichub/go-factroy2024/common/shop/router"
"os"
"time"
)
type JsonResult1 struct {
Code int
Msg string
Data string
}
//InitConfig() fmt.Println(viper.AllSettings())
func main() {
db := dbcontent.InitDB()
defer db.Close()
engine := router.InitRouter()
port := viper.GetString("publisher.port")
//h := gin.H{"code": 200} uuid,_:= uuid.NewUUID() s:=uuid.String()
if port == "" {
port = "2028"
}
gin.SetMode(gin.ReleaseMode)
if port != "" {
panic(engine.Run(":" + port))
}
panic(engine.Run())
}
func init() {
workDir, _ := os.Getwd()
viper.SetConfigName("application")
viper.SetConfigType("yml")
viper.AddConfigPath(workDir + "/config")
err := viper.ReadInConfig()
if err != nil {
fmt.Println(err)
}
//else {
// fmt.Println(viper.AllSettings())
//}
return
}
func tm() {
now := time.Now()
timeStr := now.Format("2006-01-02 15:04:05")
fmt.Println(timeStr)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/ichub/go-factroy2024.git
git@gitee.com:ichub/go-factroy2024.git
ichub
go-factroy2024
go-factroy2024
v1.2.0

搜索帮助