Go语言写入字符串到文件代码
package main
import "fmt"
import "os"
func main() {
fileName := "test.dat"
dstFile,err := os.Create(fileName)
if err!=nil{
fmt.Println(err.Error())
return
}
defer dstFile.Close()
s:="hello world"
dstFile.WriteString(s + "\n")
}
