1 Star 0 Fork 7

Leron Gubler/engineercms

forked from 初学之人/engineercms 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.32 KB
一键复制 编辑 原始数据 按行查看 历史
package main
import (
_ "github.com/3xxx/engineercms/controllers/version"
_ "github.com/3xxx/engineercms/routers"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
// "github.com/astaxie/beego/plugins/cors"
"github.com/3xxx/engineercms/models"
// _ "github.com/mattn/go-sqlite3"
"fmt"
"io"
"log"
"net/http"
"os"
"os/exec"
"time"
)
func main() {
// beego.AddFuncMap("dict", dict)
_ = beego.AddFuncMap("loadTimes", loadTimes)
//开启orm调试模式
orm.Debug = true
//创建附件目录ModePerm FileMode = 0777 // 覆盖所有Unix权限位(用于通过&获取类型位)
_ = os.Mkdir("attachment", os.ModePerm)
//创建轮播图片存放目录
_ = os.Mkdir("attachment//carousel", os.ModePerm)
//自动建表
_ = orm.RunSyncdb("default", false, true)
models.InsertUser()
// insertGroup()
// models.InsertRole()
beego.Run()
}
//显示页面加载时间
func loadTimes(t time.Time) int {
return int(time.Now().Sub(t).Nanoseconds() / 1e6)
}
// GoLang 如何在网页显示当前环境的版本号
// func main() {
// server()
// }
func server() {
http.HandleFunc("/version", version)
http.ListenAndServe(":8080", nil)
}
func version(w http.ResponseWriter, r *http.Request) {
out, err := exec.Command("go", "version").Output()
if err != nil {
log.Fatal(err)
}
io.WriteString(w, fmt.Sprintf("%s", out))
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/nazha/engineercms.git
git@gitee.com:nazha/engineercms.git
nazha
engineercms
engineercms
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385