Skip to content

Commit

Permalink
update framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Cookiery committed May 28, 2022
1 parent b7e170b commit 46b9656
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
"program": "${workspaceFolder}"
}
]
}
26 changes: 26 additions & 0 deletions bootstrap.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"fmt"

"github.com/BurntSushi/toml"
)

type Server struct {
AppMode string
HTTPPort string
}

// InitServer 初始化服务变量
func InitServer() *Server {
var server Server
if _, err := toml.DecodeFile("./conf/app.toml", &server); err != nil {
// 打日志
fmt.Println(err)
}
return &server
}

func initMySQL() {

}
7 changes: 4 additions & 3 deletions conf/app.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

[server]
# AppMode 服务模式
AppMode = "debug"
HttPPort = ":8080"

# 控制端口
HttPPort = ":8081"
5 changes: 5 additions & 0 deletions conf/mySQL.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[database]
Host = "localhost"
Port = 8808
User = "admin"
PassWord = "admin123"
Empty file added document/MySQL.md
Empty file.
8 changes: 8 additions & 0 deletions document/to_be_perfect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## to_be_perfect

初始化加载

- 日志服务
- 端口配置
- 数据库配置
- 后台配置
18 changes: 4 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
package main

import (
"fmt"

"github.com/BurntSushi/toml"
"github.com/gin-gonic/gin"
)

type Server struct {
AppMode string
HTTPPort string
}

func main() {
var app map[string]Server
if _, err := toml.DecodeFile("./conf/app.toml", &app); err != nil {
fmt.Println(app)
}
r := gin.Default()
server := InitServer()
// 启动服务
r := gin.Default() // Default 带有 Logger 和 Recovery 中间件
r.GET("/hello", func(c *gin.Context) {
c.JSON(200, gin.H{"msg": "hello"})
})
r.Run()
r.Run(server.HTTPPort)
}
22 changes: 22 additions & 0 deletions model/service/MySQL/mysql.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package MySQL

import (
"fmt"

"github.com/BurntSushi/toml"
)

type DataBase struct {
Host string
Port int
User string
PassWord string
}

func DB() {
var dataBase map[string]DataBase
if _, err := toml.DecodeFile("./conf/db.toml", &dataBase); err != nil {
fmt.Println(err)
}
fmt.Println(dataBase)
}
1 change: 0 additions & 1 deletion model/service/mysql.go

This file was deleted.

0 comments on commit 46b9656

Please sign in to comment.