I found a method how to read last line in file, but last line in my file is empty, I need to read the next-to-last line and I have no idea how to do it, please help a bit.
func ll(z string) string {
f, err := os.Open(z)
if err != nil {
log.Fatal(err)
}
bf := bufio.NewReader(f)
for {
switch line, err := bf.ReadString('
'); err {
case nil:
// valid line, echo it. note that line contains trailing
.
fmt.Println(line)
case io.EOF:
if line > "" {
// last line of file missing
, but still valid
fmt.Println(line, "in func")
}
return line
default:
log.Fatal(err)
}
}
}