Skip to content

Latest commit

 

History

History
12 lines (7 loc) · 317 Bytes

golang-read-entire-file.md

File metadata and controls

12 lines (7 loc) · 317 Bytes

Title: Golang: Read an entire file Tags: golang, golang-io

You need to import the 'io/ioutil' package for this.

	fileBytes, err := ioutil.ReadFile("/path/to/your/file")

This will return a slice of bytes as the first return argument, not a string.

You can convert it easily:

	fileAsString := string(fileBytes)