mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-12 02:00:24 +00:00
💩👌 make lint happy
This commit is contained in:
44
plugin_diana/tools/convert.go
Normal file
44
plugin_diana/tools/convert.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user