mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 01:55:35 +08:00
fix: coding style and file format for all example.
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
// read_write_file.go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
inputFile := "products.txt"
|
||||
outputFile := "products_copy.txt"
|
||||
buf, err := ioutil.ReadFile(inputFile)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
fmt.Printf("%s\n", string(buf))
|
||||
err = ioutil.WriteFile(outputFile, buf, 0644) // oct, not hex
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
||||
// read_write_file.go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
inputFile := "products.txt"
|
||||
outputFile := "products_copy.txt"
|
||||
buf, err := ioutil.ReadFile(inputFile)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
fmt.Printf("%s\n", string(buf))
|
||||
err = ioutil.WriteFile(outputFile, buf, 0644) // oct, not hex
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user