Go: Read / Print the content of files — the simplest way


The easiest way to get the content (as a string) of a file in Go is:

import "io/ioutil"
//[..]
content, err := ioutil.ReadFile("./myDirectory/myFile.txt")
fmt.Println(string(content))
fmt.Print(err)

Comments

Popular posts from this blog

Tuning ext4 for performance with emphasis on SSD usage

How to fix: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu