You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
638 B

3 years ago
package main
import (
"os"
3 years ago
"github.com/gin-gonic/gin"
"github.com/spf13/viper"
"github.com/zggsong/gin-vue-demo/common"
3 years ago
"github.com/zggsong/gin-vue-demo/router"
3 years ago
)
func init() {
workDir, _ := os.Getwd()
viper.SetConfigName("application")
viper.SetConfigType("yml")
viper.AddConfigPath(workDir + "\\config")
err := viper.ReadInConfig()
if err != nil {
panic("读取配置文件失败, error=" + err.Error())
}
}
3 years ago
func main() {
common.InitDB()
3 years ago
r := gin.Default()
3 years ago
r = router.CollectRoute(r)
port := viper.GetString("server.port")
if port != "" {
panic(r.Run("127.0.0.1:" + port))
}
3 years ago
panic(r.Run("127.0.0.1:8080"))
}