代码拉取完成,页面将自动刷新
同步操作将从 好雨科技/go-demo 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package main
import (
"database/sql"
"fmt"
"net/url"
"os"
_ "github.com/go-sql-driver/mysql"
dbinfo_http "github.com/goodrain/go-demo/dbinfo/delivery/http"
dbinfo_repo "github.com/goodrain/go-demo/dbinfo/repository"
dbinfo_ucase "github.com/goodrain/go-demo/dbinfo/usecase"
foobar_http "github.com/goodrain/go-demo/foobar/delivery/http"
foobar_ucase "github.com/goodrain/go-demo/foobar/usecase"
"github.com/goodrain/go-demo/middleware"
proxy_http "github.com/goodrain/go-demo/proxy/delivery/http"
"github.com/labstack/echo"
"github.com/sirupsen/logrus"
)
func GetEnvDefault(key, defVal string) string {
val, ex := os.LookupEnv(key)
if !ex {
return defVal
}
return val
}
func main() {
logrus.SetLevel(logrus.DebugLevel)
dbuser := os.Getenv("MYSQL_USER")
dbpw := os.Getenv("MYSQL_PASS")
dbhost := os.Getenv("MYSQL_HOST")
dbport := os.Getenv("MYSQL_PORT")
dbname := os.Getenv("MYSQL_DATABASE")
port := GetEnvDefault("PORT", "5000")
conn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s", dbuser, dbpw, dbhost, dbport, dbname)
val := url.Values{}
val.Add("parseTime", "1")
val.Add("loc", "Asia/Shanghai")
dsn := fmt.Sprintf("%s?%s", conn, val.Encode())
dbconn, err := sql.Open(`mysql`, dsn)
if err != nil {
logrus.Warningf("error opening database: %v", err)
}
defer dbconn.Close()
dbinfoRepo := dbinfo_repo.NewMysqlDBInfoRepository(dbconn)
e := echo.New()
middL := middleware.InitMiddleware()
e.Use(middL.CORS)
e.Static("/", "public")
dbinfoUcaser := dbinfo_ucase.NewDBInfoUsecase(dbinfoRepo)
dbinfo_http.NewDBInfoHTTPHandler(e, dbinfoUcaser)
foobarUcaser := foobar_ucase.NewFoobarUsecase()
foobar_http.NewFoobarHandler(e, foobarUcaser)
proxy_http.NewProxyHandler(e, nil)
e.Logger.Fatal(e.Start(":" + port))
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。