Demofile.txt
Hello! Welcome to demofile.txt
This file is for testing purposes.
Good Luck!
package main
import (
"fmt"
"io/ioutil"
"strings"
)
func main() {
contents, err := ioutil.ReadFile("demofile.txt")
if err != nil {
fmt.Println("Error reading file")
}
words := strings.Split(string(contents)," ")
fmt.Println(len(words), words)
10 [Hello! Welcome to demofile.txt
This file is for testing purposes.
Good Luck!]