1 Star 1 Fork 0

湖底观景 / GolangTraining

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 582 Bytes
一键复制 编辑 原始数据 按行查看 历史
GoesToEleven 提交于 2016-04-20 17:45 . changes dir structure
package main
import (
"io"
"log"
"os"
)
func main() {
f, err := os.Create("hello.txt")
if err != nil {
log.Fatalln("my program broke", err.Error())
}
defer f.Close()
str := "Put some phrase here."
// bs := []byte(str)
_, err = io.WriteString(f, str)
// _, err = f.Write(bs)
if err != nil {
log.Fatalln("error writing to file: ", err.Error())
}
}
/*
func WriteString(w Writer, s string) (n int, err error)
WriteString writes the contents of the string s to w,
which accepts a slice of bytes. If w implements a WriteString method, it is invoked directly.
*/
1
https://gitee.com/zhangjianGood/GolangTraining.git
git@gitee.com:zhangjianGood/GolangTraining.git
zhangjianGood
GolangTraining
GolangTraining
afa19f5c43f3

搜索帮助