'commit'
continuous-integration/drone/push Build is passing Details

master
黄海 4 years ago
parent 3b0ed4584c
commit 6c83616612

@ -2,17 +2,17 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="19c8c37d-a056-451c-a29d-fb612b9a3e2f" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/Utils/FileUtil/FileUtil.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Config/Config.ini" beforeDir="false" afterPath="$PROJECT_DIR$/Config/Config.ini" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Router/CommonToolsRouter.go" beforeDir="false" afterPath="$PROJECT_DIR$/Router/CommonToolsRouter.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/WinBuild/Distribute.exe" beforeDir="false" afterPath="$PROJECT_DIR$/WinBuild/Distribute.exe" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Config/logo.txt" beforeDir="false" afterPath="$PROJECT_DIR$/Config/logo.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/main.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="GOROOT" url="file://C:/Go" />
<component name="GOROOT" url="file://C:/Program Files/Go" />
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
@ -32,31 +32,36 @@
<property name="go.import.settings.migrated" value="true" />
<property name="go.sdk.automatically.set" value="true" />
<property name="go.tried.to.enable.integration.vgo.integrator" value="true" />
<property name="last_opened_file_path" value="$USER_HOME$" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/Utils" />
</component>
<component name="RunManager" selected="Go Build.go build main.go">
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="E:\Work\dsMin\dsSzxy\Utils" />
</key>
</component>
<component name="RunManager" selected="Go Build.go build dsSzxy">
<configuration name="go build dsSzxy" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="dsSzxy" />
<working_directory value="$PROJECT_DIR$" />
<kind value="PACKAGE" />
<filePath value="$PROJECT_DIR$/main.go" />
<package value="dsSzxy" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$/main.go" />
<method v="2" />
</configuration>
<configuration name="go build main.go" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="dsSzxy" />
<working_directory value="$PROJECT_DIR$" />
<kind value="FILE" />
<filePath value="$PROJECT_DIR$/main.go" />
<package value="dsCommonTools" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$/main.go" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Go Build.go build main.go" />
<item itemvalue="Go Build.go build dsSzxy" />
<item itemvalue="Go Build.go build main.go" />
</list>
</recent_temporary>
</component>
@ -74,6 +79,7 @@
</entry>
</map>
</option>
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="VgoProject">
<integration-enabled>true</integration-enabled>

@ -5,4 +5,6 @@
| (_| \__ \____) / / > <| |_| |
\__,_|___/_____/___|/_/\_\\__, |
__/ |
|___/
|___/
Created By HuangHai 2021-08-05
http://patorjk.com/software/taag/#p=display&f=Big&t=dsSzxy

@ -0,0 +1,84 @@
package FileUtil
import (
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
)
/**
2019-12-31
*/
func ReadFileContent(filepath string) string {
file, err := os.Open(filepath)
if err != nil {
log.Print("文件打开失败:", err)
}
defer file.Close()
buf := make([]byte, 12) // 存放文件内容的缓存,相当于中转站
data := make([]byte, 0) // 用来存放文件内容buf读取的内容都会写到data里面去
for {
//无限循环,不断读取
n, err := file.Read(buf)
// 什么时候文件读完呢如果文件读完的话那么err不为nil而是io.EOF
// 所以我们可以进行判断
if err != nil {
//如果err != nil说明出错了但如果还等于io.EOF的话说明读完了因为文件读完err也不为nil。直接break
if err == io.EOF {
break
} else {
//如果错误不是io.EOF的话说明就真的在读取中出现了错误直接panic出来
panic(err)
}
}
//此时文件内容写到buf里面去了写了多少个呢写了n个那么我们再写到data里面去
data = append(data, buf[:n]...)
}
return string(data)
}
/**
2020-01-20
*/
func GetFileSize(filename string) int64 {
var result int64
filepath.Walk(filename, func(path string, f os.FileInfo, err error) error {
result = f.Size()
return nil
})
return result
}
/**
2020-05-16
*/
func WriteFileContent(filename string, content string) {
var d1 = []byte(content)
ioutil.WriteFile(filename, d1, 0666) //写入文件(字节数组)
}
/**
2020-05-20
*/
func PathExists(path string) bool {
_, err := os.Stat(path)
if err == nil {
return true
}
if os.IsNotExist(err) {
return false
}
return false
}

@ -3,13 +3,24 @@ package main
import (
"dsSzxy/Router"
"dsSzxy/Utils"
"dsSzxy/Utils/CommonUtil"
"dsSzxy/Utils/ConfigUtil"
"dsSzxy/Utils/FileUtil"
"fmt"
"github.com/gin-gonic/gin"
)
func main() {
// 发布模式
//gin.SetMode(gin.ReleaseMode)
// 显示Logo
configIniFile := "./Config/logo.txt"
if !CommonUtil.Exists(configIniFile) {
configIniFile = "/usr/local/dsMin/dsSzxy/Config/logo.txt"
}
var logo = FileUtil.ReadFileContent(configIniFile)
fmt.Print(logo)
// 开发模式
gin.SetMode(gin.DebugMode)
// 开启gin服务器
@ -18,6 +29,6 @@ func main() {
r.Use(Utils.Cors())
//主路由
Router.GinRouter(r)
// 监听并在 0.0.0.0:8002 上启动服务
// 监听并在 0.0.0.0:8006 上启动服务
r.Run(":" + ConfigUtil.ServerPort)
}

Loading…
Cancel
Save