项目初始化
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user