Skip to content

Instantly share code, notes, and snippets.

@d1y
Created April 3, 2020 02:28
Show Gist options
  • Select an option

  • Save d1y/fe6fc23880061ec97968352bdcb0eb7b to your computer and use it in GitHub Desktop.

Select an option

Save d1y/fe6fc23880061ec97968352bdcb0eb7b to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io/ioutil"
"log"
)
func main() {
// Read entire file content, giving us little control but
// making it very simple. No need to close the file.
content, err := ioutil.ReadFile("golangcode.txt")
if err != nil {
log.Fatal(err)
}
// Convert []byte to string and print to screen
text := string(content)
fmt.Println(text)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment