forked from FloatTech/ZeroBot-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
141 additions
and
57 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
syntax = "proto3"; | ||
package diana; | ||
package data; | ||
|
||
message composition { | ||
repeated string array = 1; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.