💩👌 make lint happy

This commit is contained in:
fumiama
2021-08-06 18:47:52 +08:00
parent 3814d17926
commit 932abcbdb6
7 changed files with 141 additions and 57 deletions

View File

@@ -0,0 +1,44 @@
// Package convert 转换txt到pb
package main
import (
"bufio"
"os"
"github.com/FloatTech/ZeroBot-Plugin/plugin_diana/data"
)
var (
compo data.Composition
)
func init() {
compo.Array = make([]string, 0, 64)
}
// 参数txt文件位置 pb文件位置
func main() {
file, err := os.Open(os.Args[1])
if err != nil {
panic(err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
// optionally, resize scanner's capacity for lines over 64K, see next example
for scanner.Scan() {
//fmt.Println(scanner.Text())
compo.Array = append(compo.Array, scanner.Text())
}
if err := scanner.Err(); err != nil {
panic(err)
}
data, _ := compo.Marshal()
f, err1 := os.OpenFile(os.Args[2], os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
if err1 == nil {
defer f.Close()
f.Write(data)
}
}