注释掉mac不兼容的代码

pull/30/head
taoshihan1991 4 years ago
parent d170b372ef
commit 4fb0823d60

@ -6,10 +6,8 @@ import (
ginSwagger "github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
"github.com/taoshihan1991/imaptool/config"
"github.com/taoshihan1991/imaptool/controller"
"github.com/taoshihan1991/imaptool/docs"
"github.com/taoshihan1991/imaptool/router"
"github.com/taoshihan1991/imaptool/tools"
"log"
"os"
"os/exec"
@ -50,7 +48,7 @@ func run(){
}
baseServer := "0.0.0.0:"+port
tcpBaseServer := "0.0.0.0:"+tcpport
//tcpBaseServer := "0.0.0.0:"+tcpport
log.Println("start server...\r\ngohttp://" + baseServer)
engine := gin.Default()
engine.LoadHTMLGlob("static/html/*")
@ -69,10 +67,10 @@ func run(){
//docs.SwaggerInfo.Schemes = []string{"http"}
engine.GET("/docs/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
logFile, _ := os.OpenFile("./fatal.log", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0660)
tools.RedirectStderr(logFile)
//logFile, _ := os.OpenFile("./fatal.log", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0660)
//tools.RedirectStderr(logFile)
//tcp服务
go controller.NewTcpServer(tcpBaseServer)
//go controller.NewTcpServer(tcpBaseServer)
engine.Run(baseServer)
}

@ -1,40 +0,0 @@
//+build !linux
package controller
import (
"github.com/taoshihan1991/imaptool/config"
"os"
"path/filepath"
"runtime"
"syscall"
"time"
)
var osType = runtime.GOOS
const expireTime = 30 * 60
//检测权限文件是否过期,超过30分钟删除掉
func TimerSessFile() {
go func() {
for {
time.Sleep(time.Second * 10)
files, _ := filepath.Glob(config.Dir + "sess_*")
for _, file := range files {
fileInfo, _ := os.Stat(file)
var createTime int64
now := time.Now().Unix()
if osType == "windows" {
wFileSys := fileInfo.Sys().(*syscall.Win32FileAttributeData)
tNanSeconds := wFileSys.CreationTime.Nanoseconds() /// 返回的是纳秒
createTime = tNanSeconds / 1e9 ///秒
}
diffTime := now - createTime
if diffTime > expireTime {
os.Remove(file)
}
}
}
}()
}
Loading…
Cancel
Save