This commit is contained in:
2024-12-01 06:12:25 +02:00
parent c82ee691a1
commit b1816dcbf8
6 changed files with 66 additions and 20 deletions

View File

@@ -1,32 +1,24 @@
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {
filePath := os.Args[1]
readFile, err := os.Open(filePath)
lines := parse()
if err != nil {
fmt.Println(err)
}
fileScanner := bufio.NewScanner(readFile)
fileScanner.Split(bufio.ScanLines)
var fileLines []string
for fileScanner.Scan() {
fileLines = append(fileLines, fileScanner.Text())
}
readFile.Close()
for _, line := range fileLines {
for _, line := range lines {
fmt.Println(line)
}
fmt.Println(fileLines)
}
func parse() []string {
filePath := os.Args[1]
data, _ := os.ReadFile(filePath)
chunks := strings.Split(string(data), "\n")
return chunks
}