听起来您只想要ioutil.WriteFile标准库中的函数。https://golang.org/pkg/io/ioutil/#WriteFile它看起来像这样:permissions := 0644 // or whatever you needbyteArray := []byte("to be written to a file\n")err := ioutil.WriteFile("file.txt", byteArray, permissions)if err != nil { // handle error}