golang read content of file code example
Example 1: golang read file
dat, err := ioutil.ReadFile("/tmp/dat")
check(err)
fmt.Print(string(dat))
Example 2: read contents of a file and convert to list + go
content, err := ioutil.ReadFile(filename)
if err != nil {
//Do something
}
lines := strings.Split(string(content), "\n")