read contents of a file and convert to list + go

package main

import (
    "fmt"
    "io/ioutil"
    "strings"
)

func readFileToList(filename string) ([]string, error) {
    content, err := ioutil.ReadFile(filename)
    if err != nil {
        return nil, err
    }

    lines := strings.Split(string(content), "\n")
    return lines, nil
}

func main() {
    filename := "example.txt" // Replace with the actual file name
    lines, err := readFileToList(filename)
    if err != nil {
        fmt.Println("Error reading file:", err)
        return
    }

    fmt.Println("Contents of the file as a list:")
    for _, line := range lines {
        fmt.Println(line)
    }
}