To read or write in a file, you can use the package io/ioutil which contains méthods like ReadFile orWriteFile
Example :
package main
import ("fmt";"io/ioutil")
func main() {
fmt.Print("Lecture \n");
contents,_ := ioutil.ReadFile("/home/damikde/tmp/server.log")
println(string(contents))
fmt.Print("Ecriture \n");
ioutil.WriteFile("/home/damikde/tmp/toto", contents, 0x777)
}
No comments:
Post a Comment