Created
April 3, 2020 02:28
-
-
Save d1y/fe6fc23880061ec97968352bdcb0eb7b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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