Эх сурвалжийг харах

12.9md (#349)

* Update 11.9.md

修正166行一个错误,ix 改为i

* Update 11.14.md

34-43行代码错误,会造成无法运行

* 修改一处权限bug,否则会造成linux下生成的文件为空
风子 9 жил өмнө
parent
commit
1177b673b4
4 өөрчлөгдсөн 8 нэмэгдсэн , 7 устгасан
  1. 1 0
      .gitignore
  2. 4 4
      eBook/11.14.md
  3. 2 2
      eBook/11.9.md
  4. 1 1
      eBook/12.9.md

+ 1 - 0
.gitignore

@@ -6,6 +6,7 @@
 # Folders
 _obj
 _test
+.idea
 
 # Architecture specific extensions/prefixes
 *.[568vq]

+ 4 - 4
eBook/11.14.md

@@ -35,10 +35,10 @@ func (cs Cars) FindAll(f func(car *Car) bool) Cars {
 
 	cars := make([]*Car, 0)
 	cs.Process(func(c *Car) {
-			if f(c) {
-                append(cars,c)
-            }
-    )
+		if f(c) {
+			cars = append(cars, c)
+		}
+	})
 	return cars
 }
 ```

+ 2 - 2
eBook/11.9.md

@@ -163,8 +163,8 @@ var interfaceSlice []interface{} = dataSlice
 ```go
 var dataSlice []myType = FuncReturnSlice()
 var interfaceSlice []interface{} = make([]interface{}, len(dataSlice))
-for ix, d := range dataSlice {
-    interfaceSlice[ix] = d
+for i, d := range dataSlice {
+    interfaceSlice[i] = d
 }
 ```
 

+ 1 - 1
eBook/12.9.md

@@ -69,7 +69,7 @@ func main() {
 	js, _ := json.Marshal(vc)
 	fmt.Printf("JSON format: %s", js)
 	// using an encoder:
-	file, _ := os.OpenFile("vcard.json", os.O_CREATE|os.O_WRONLY, 0)
+	file, _ := os.OpenFile("vcard.json", os.O_CREATE|os.O_WRONLY, 0666)
 	defer file.Close()
 	enc := json.NewEncoder(file)
 	err := enc.Encode(vc)