mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 03:34:15 +08:00
fix: coding style and file format for all example.
This commit is contained in:
@@ -1,28 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"bufio"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main () {
|
||||
// var outputWriter *bufio.Writer
|
||||
// var outputFile *os.File
|
||||
// var outputError os.Error
|
||||
// var outputString string
|
||||
outputFile, outputError := os.OpenFile("output.dat", os.O_WRONLY|os.O_CREATE, 0666)
|
||||
if outputError != nil {
|
||||
fmt.Printf("An error occurred with file opening or creation\n")
|
||||
return
|
||||
}
|
||||
defer outputFile.Close()
|
||||
|
||||
outputWriter := bufio.NewWriter(outputFile)
|
||||
outputString := "hello world!\n"
|
||||
|
||||
for i:=0; i<10; i++ {
|
||||
outputWriter.WriteString(outputString)
|
||||
}
|
||||
outputWriter.Flush()
|
||||
}
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// var outputWriter *bufio.Writer
|
||||
// var outputFile *os.File
|
||||
// var outputError os.Error
|
||||
// var outputString string
|
||||
outputFile, outputError := os.OpenFile("output.dat", os.O_WRONLY|os.O_CREATE, 0666)
|
||||
if outputError != nil {
|
||||
fmt.Printf("An error occurred with file opening or creation\n")
|
||||
return
|
||||
}
|
||||
defer outputFile.Close()
|
||||
|
||||
outputWriter := bufio.NewWriter(outputFile)
|
||||
outputString := "hello world!\n"
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
outputWriter.WriteString(outputString)
|
||||
}
|
||||
outputWriter.Flush()
|
||||
}
|
||||
|
Reference in New Issue
Block a user