Go语言写入字符串到文件的方法
本文实例讲述了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")
}希望本文所述对大家的Go语言程序设计有所帮助。
相关推荐
wfs 2020-10-29
哈嘿Blog 2020-10-26
bearhoopIT之道 2020-11-11
小科的奋斗 2020-10-24
HELLOBOY 2020-10-23
专注前端开发 2020-10-12
哈嘿Blog 2020-09-08
qidiantianxia 2020-09-15
哈嘿Blog 2020-08-16