Skip to content

Commit

Permalink
update 2023年 9月11日 星期一 17时48分52秒 CST
Browse files Browse the repository at this point in the history
  • Loading branch information
No-Github committed Sep 11, 2023
1 parent 9aea74a commit 1a19679
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
push.sh
.idea
dist/
main
40 changes: 30 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"bufio"
"embed"
"fmt"
"log"
"os"
Expand All @@ -13,6 +14,10 @@ import (
var Lines []string
var Lines2 []string
var Lines3 []string
var TempSlice []string

//go:embed mimetype.txt
var local embed.FS

func main() {

Expand All @@ -22,17 +27,10 @@ func main() {
}
defer file.Close()

mimetypeFile, err := os.Open("mimetype.txt")
if err != nil {
log.Fatal(err)
}
defer mimetypeFile.Close()

mimetypeScanner := bufio.NewScanner(mimetypeFile)
TempSlice = embedread("mimetype.txt")
mimetypeLines := make(map[string]bool)
for mimetypeScanner.Scan() {
line := mimetypeScanner.Text()
mimetypeLines[line] = true
for _, v1 := range TempSlice {
mimetypeLines[v1] = true
}

scanner := bufio.NewScanner(file)
Expand Down Expand Up @@ -120,3 +118,25 @@ func TodoTxt(filename string, dic []string) {
fmt.Println("txt 格式文件已输出到: ", filePath)

}

func embedread(filePath string) []string {
var resp5 []string

f, err := local.Open(filePath)
if err != nil {
log.Fatal(err)
}
defer f.Close()
scanner := bufio.NewScanner(f)
for scanner.Scan() {
// do something with a line
resp5 = append(resp5, scanner.Text())
}

if err := scanner.Err(); err != nil {
log.Fatal(err)
}

return resp5

}

0 comments on commit 1a19679

Please sign in to comment.