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

Java 8: Default Interface Implementations, The Diamond Problem, Multiple Inheritance, and Precedence

Tuning ext3 for performance without losing its data integrity potential