Skip to content

Instantly share code, notes, and snippets.

@pm-kartik-sura
Created June 11, 2015 07:59
Show Gist options
  • Select an option

  • Save pm-kartik-sura/c940714de93ed6fb54b4 to your computer and use it in GitHub Desktop.

Select an option

Save pm-kartik-sura/c940714de93ed6fb54b4 to your computer and use it in GitHub Desktop.
Read file into string
package main
import (
"fmt"
"io/ioutil"
)
func main() {
file, err := ioutil.ReadFile("testfile.txt")
if err != nil {
fmt.Println(err)
return
}
// out the file content
fmt.Println(string(file))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment