Example 1:
$cat run readFile.go
package main
import(
"io/ioutil"
)
func main() {
contents,_ := ioutil.ReadFile("readFile.go")
println(string(contents))
}
Example 2:
$ cat fileRead.go
package main
import(
"io/ioutil"
)
func main() {
contents,_ := ioutil.ReadFile("/etc/passwd")
println(string(contents))
}
No comments:
Post a Comment