mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 05:33:04 +08:00
update 12.2.md (#510)
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
```go
|
```go
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -28,7 +29,7 @@ func main() {
|
|||||||
inputReader := bufio.NewReader(inputFile)
|
inputReader := bufio.NewReader(inputFile)
|
||||||
for {
|
for {
|
||||||
inputString, readerError := inputReader.ReadString('\n')
|
inputString, readerError := inputReader.ReadString('\n')
|
||||||
fmt.Printf("The input was: %s", inputString)
|
fmt.Printf("The input was: %s", inputString)
|
||||||
if readerError == io.EOF {
|
if readerError == io.EOF {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -71,7 +72,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "File Error: %s\n", err)
|
fmt.Fprintf(os.Stderr, "File Error: %s\n", err)
|
||||||
// panic(err.Error())
|
// panic(err.Error())
|
||||||
}
|
}
|
||||||
fmt.Printf("%s\n", string(buf))
|
fmt.Printf("%s\n", string(buf))
|
||||||
err = ioutil.WriteFile(outputFile, buf, 0644) // oct, not hex
|
err = ioutil.WriteFile(outputFile, buf, 0644) // oct, not hex
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user