-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
70 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
|
||
[server] | ||
# AppMode 服务模式 | ||
AppMode = "debug" | ||
HttPPort = ":8080" | ||
|
||
# 控制端口 | ||
HttPPort = ":8081" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## to_be_perfect | ||
|
||
初始化加载 | ||
|
||
- 日志服务 | ||
- 端口配置 | ||
- 数据库配置 | ||
- 后台配置 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file was deleted.
Oops, something went wrong.