The ability to read (and write) a text file into and out of a string array is I believe a fairly common requirement. It is also quite useful when starting with a language re
If the file isn't too large, this can be done with the ioutil.ReadFile and strings.Split functions like so:
ioutil.ReadFile
strings.Split
content, err := ioutil.ReadFile(filename) if err != nil { //Do something } lines := strings.Split(string(content), "\n")
You can read the documentation on ioutil and strings packages.