mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 05:33:04 +08:00
[Typo] Fix multiple wrong single and double quotation marks between 04.6 to 06.9
This commit is contained in:
@@ -56,8 +56,8 @@ str := "Beginning of the string " +
|
|||||||
拼接的简写形式 `+=` 也可以用于字符串:
|
拼接的简写形式 `+=` 也可以用于字符串:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
s := “hel” + “lo,”
|
s := "hel" + "lo,"
|
||||||
s += “world!”
|
s += "world!"
|
||||||
fmt.Println(s) //输出 “hello, world!”
|
fmt.Println(s) //输出 “hello, world!”
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@@ -94,7 +94,7 @@ return y
|
|||||||
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
. ..
|
. ..
|
||||||
} else { // Unix - li ke
|
} else { // Unix-like
|
||||||
. ..
|
. ..
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
```go
|
```go
|
||||||
for {
|
for {
|
||||||
i = i - 1
|
i = i - 1
|
||||||
fmt.Printf(“The variable i is now: %d\n”, i)
|
fmt.Printf("The variable i is now: %d\n", i)
|
||||||
if i < 0 {
|
if i < 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@@ -86,10 +86,10 @@ i := 0
|
|||||||
for { //since there are no checks, this is an infinite loop
|
for { //since there are no checks, this is an infinite loop
|
||||||
if i >= 3 { break }
|
if i >= 3 { break }
|
||||||
//break out of this for loop when this condition is met
|
//break out of this for loop when this condition is met
|
||||||
fmt.Println(“Value of i is:”, i)
|
fmt.Println("Value of i is:", i)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
fmt.Println(“A statement just after for loop.”)
|
fmt.Println("A statement just after for loop.")
|
||||||
```
|
```
|
||||||
|
|
||||||
2.
|
2.
|
||||||
@@ -97,7 +97,7 @@ fmt.Println(“A statement just after for loop.”)
|
|||||||
```go
|
```go
|
||||||
for i := 0; i<7 ; i++ {
|
for i := 0; i<7 ; i++ {
|
||||||
if i%2 == 0 { continue }
|
if i%2 == 0 { continue }
|
||||||
fmt.Println(“Odd:”, i)
|
fmt.Println("Odd:", i)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@@ -124,8 +124,8 @@ addJpeg := MakeAddSuffix(“.jpeg”)
|
|||||||
然后调用它们:
|
然后调用它们:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
addBmp(“file”) // returns: file.bmp
|
addBmp("file") // returns: file.bmp
|
||||||
addJpeg(“file”) // returns: file.jpeg
|
addJpeg("file") // returns: file.jpeg
|
||||||
```
|
```
|
||||||
|
|
||||||
可以返回其它函数的函数和接受其它函数作为参数的函数均被称之为高阶函数,是函数式语言的特点。我们已经在第 6.7 中得知函数也是一种值,因此很显然 Go 语言具有一些函数式语言的特性。闭包在 Go 语言中非常常见,常用于 goroutine 和管道操作(详见第 14.8-14.9 节)。在第 11.14 节的程序中,我们将会看到 Go 语言中的函数在处理混合对象时的强大能力。
|
可以返回其它函数的函数和接受其它函数作为参数的函数均被称之为高阶函数,是函数式语言的特点。我们已经在第 6.7 中得知函数也是一种值,因此很显然 Go 语言具有一些函数式语言的特性。闭包在 Go 语言中非常常见,常用于 goroutine 和管道操作(详见第 14.8-14.9 节)。在第 11.14 节的程序中,我们将会看到 Go 语言中的函数在处理混合对象时的强大能力。
|
||||||
|
Reference in New Issue
Block a user