fix: coding style and file format for all example.

This commit is contained in:
Bo-Yi Wu
2017-02-11 12:34:46 +08:00
parent f215102638
commit 416e29d95a
206 changed files with 5531 additions and 5451 deletions

View File

@@ -1,34 +1,34 @@
package main
import (
"bufio"
"fmt"
"io"
"os"
)
func main() {
// var inputFile *os.File
// var inputError, readerError os.Error
// var inputReader *bufio.Reader
// var inputString string
inputFile, inputError := os.Open("input.dat")
if inputError != nil {
fmt.Printf("An error occurred on opening the inputfile\n" +
"Does the file exist?\n" +
"Have you got acces to it?\n")
return // exit the function on error
}
defer inputFile.Close()
inputReader := bufio.NewReader(inputFile)
for {
inputString, readerError := inputReader.ReadString('\n')
if readerError == io.EOF {
return // error or EOF
}
fmt.Printf("The input was: %s", inputString)
}
}
package main
import (
"bufio"
"fmt"
"io"
"os"
)
func main() {
// var inputFile *os.File
// var inputError, readerError os.Error
// var inputReader *bufio.Reader
// var inputString string
inputFile, inputError := os.Open("input.dat")
if inputError != nil {
fmt.Printf("An error occurred on opening the inputfile\n" +
"Does the file exist?\n" +
"Have you got acces to it?\n")
return // exit the function on error
}
defer inputFile.Close()
inputReader := bufio.NewReader(inputFile)
for {
inputString, readerError := inputReader.ReadString('\n')
if readerError == io.EOF {
return // error or EOF
}
fmt.Printf("The input was: %s", inputString)
}
}