perf(package static file): 去除打包静态文件到二进制文件的第三方工具

This commit is contained in:
vscode-server
2021-06-02 13:25:12 +00:00
parent 3ca5ce2a99
commit fbe7e48368
2 changed files with 4 additions and 14 deletions

View File

@@ -33,11 +33,8 @@ OpenVPN的管理端口详细介绍文章请参考https://openvpn.net/commu
```bash ```bash
git clone git clone
cd openvpn-manager cd openvpn-manager
go get github.com/rakyll/statik CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o target/openvpn-manager main.go
go install github.com/rakyll/statik nohup ./target/openvpn-manager -host openvpn服务端主机IP地址 -port openvpn管理端口 -admin-passwd OpenVPN Manager管理员admin的密码 -psw-file /etc/openvpn/server/psw-file > /var/log/openvpn-manager.log 2>&1 &
statik -src=$PWD/public
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o openvpn-manager main.go
nohup ./openvpn-manager -host openvpn服务端主机IP地址 -port openvpn管理端口 -admin-passwd OpenVPN Manager管理员admin的密码 -psw-file /etc/openvpn/server/psw-file >> /var/log/openvpn-manager.log 2>&1 &
``` ```
## 3、docker方式部署 ## 3、docker方式部署

11
main.go
View File

@@ -2,13 +2,11 @@
package main package main
import ( import (
_ "curiouser.com/openvpn-manager/statik"
"encoding/csv" "encoding/csv"
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/rakyll/statik/fs"
"io/ioutil" "io/ioutil"
"log" "log"
"net" "net"
@@ -93,19 +91,14 @@ func main() {
os.Exit(0) os.Exit(0)
} }
statikFS, err := fs.New()
if err != nil {
log.Fatal(err)
}
//根路由设置首页跳转到'/public'加载'index.html' //根路由设置首页跳转到'/public'加载'index.html'
router.GET("/", func(context *gin.Context) { router.GET("/", func(context *gin.Context) {
context.Request.URL.Path = "/public" context.Request.URL.Path = "/public"
router.HandleContext(context) router.HandleContext(context)
}) })
authorizedRoute.StaticFS("/public", statikFS) // authorizedRoute.StaticFS("/public", statikFS)
//authorizedRoute.StaticFS("/public",http.Dir("./public")) authorizedRoute.StaticFS("/public",http.Dir("./public"))
authorizedRoute.StaticFile("/favicon.ico", "./public/favicon.ico") authorizedRoute.StaticFile("/favicon.ico", "./public/favicon.ico")
authorizedRoute.GET("/getOnlineClients", func(context *gin.Context) { authorizedRoute.GET("/getOnlineClients", func(context *gin.Context) {