how to read file string golang code example
Example 1: golang read file
dat, err := ioutil.ReadFile("/tmp/dat")
check(err)
fmt.Print(string(dat))
Example 2: golang read file to string
contents, err := ioutil.ReadFile("file.txt")
dat, err := ioutil.ReadFile("/tmp/dat")
check(err)
fmt.Print(string(dat))
contents, err := ioutil.ReadFile("file.txt")