package main
import fmt "fmt"
import os "os"
import strings "strings"
import strconv "strconv"
func GetTrimmedFileLines(fileName string) ([]string, error) {
fileContent, err := os.ReadFile(fileName)
if err != nil {
return nil, err
}
fileContentStrVersion := string(fileContent)
trimmedLines := strings.Split(strings.TrimSpace(fileContentStrVersion), "\n")
// Eliminates any 'unused variable' errors
_, _, _, _ = err, fileContent, fileContentStrVersion, trimmedLines
return trimmedLines, nil
}
func main() {
a := 1
lines, err := GetTrimmedFileLines("example.txt")
if err != nil {
panic(err)
}
properWord := (func() string {
if len(lines) > 1 {
return "lines"
}
return "line"
})()
stringLength := strconv.Itoa(len(lines))
fmt.Println("There are " + stringLength + " " + properWord + ".")
fmt.Println("Here they are:")
for i, line := range lines {
fmt.Println("Line " + strconv.Itoa(i+1) + " is:")
fmt.Println(line)
// Eliminates any 'unused variable' errors
_, _ = i, line
}
// Eliminates any 'unused variable' errors
_, _, _, _, _ = a, err, lines, properWord, stringLength
}
.png)


