Remove 07.5.md spaces

This commit is contained in:
vCaesar
2017-06-09 22:34:08 +08:00
parent 6d0e2d8907
commit ddf9eb7082

View File

@@ -24,22 +24,22 @@ In Go, most of the file operation functions are located in the `os` package. Her
Code sample: Code sample:
```Go ```Go
package main package main
import ( import (
"fmt" "fmt"
"os" "os"
) )
func main() { func main() {
os.Mkdir("astaxie", 0777) os.Mkdir("astaxie", 0777)
os.MkdirAll("astaxie/test1/test2", 0777) os.MkdirAll("astaxie/test1/test2", 0777)
err := os.Remove("astaxie") err := os.Remove("astaxie")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
}
os.RemoveAll("astaxie")
} }
os.RemoveAll("astaxie")
}
``` ```
## Files ## Files
@@ -84,26 +84,26 @@ Functions for writing files:
Code sample: Code sample:
```Go ```Go
package main package main
import ( import (
"fmt" "fmt"
"os" "os"
) )
func main() { func main() {
userFile := "astaxie.txt" userFile := "astaxie.txt"
fout, err := os.Create(userFile) fout, err := os.Create(userFile)
if err != nil { if err != nil {
fmt.Println(userFile, err) fmt.Println(userFile, err)
return return
}
defer fout.Close()
for i := 0; i < 10; i++ {
fout.WriteString("Just a test!\r\n")
fout.Write([]byte("Just a test!\r\n"))
}
} }
defer fout.Close()
for i := 0; i < 10; i++ {
fout.WriteString("Just a test!\r\n")
fout.Write([]byte("Just a test!\r\n"))
}
}
``` ```
### Read files ### Read files
@@ -119,30 +119,30 @@ Functions for reading files:
Code sample: Code sample:
```Go ```Go
package main package main
import ( import (
"fmt" "fmt"
"os" "os"
) )
func main() { func main() {
userFile := "asatxie.txt" userFile := "asatxie.txt"
fl, err := os.Open(userFile) fl, err := os.Open(userFile)
if err != nil { if err != nil {
fmt.Println(userFile, err) fmt.Println(userFile, err)
return return
}
defer fl.Close()
buf := make([]byte, 1024)
for {
n, _ := fl.Read(buf)
if 0 == n {
break
}
os.Stdout.Write(buf[:n])
}
} }
defer fl.Close()
buf := make([]byte, 1024)
for {
n, _ := fl.Read(buf)
if 0 == n {
break
}
os.Stdout.Write(buf[:n])
}
}
``` ```
### Delete files ### Delete files