项目初始化

This commit is contained in:
2024-05-23 01:23:28 +08:00
commit f0cb950bc2
8 changed files with 173 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
package main
import (
"fmt"
"os"
"path/filepath"
"regexp"
)
func main() {
dir := C.Dir
match := C.Match
url := C.Url
key := C.Key
info := C.Info
regex := regexp.MustCompile(match)
dirs, err := os.ReadDir(dir)
if err != nil {
fmt.Println(err)
return
}
for _, item := range dirs {
if regex.MatchString(item.Name()) {
file, err := os.Open(filepath.Join(dir, item.Name()))
if err != nil {
continue
}
var logTexts []string
ReadAfterSeq(file, 0, '\n', func(bytes []byte) {
logTexts = append(logTexts, string(bytes))
})
file.Close()
for _, text := range logTexts {
err := requestDingApi(url, message{
Text: text,
Filename: item.Name(),
Key: key,
Info: info,
})
fmt.Println(err)
}
}
}
}