mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-11 23:08:34 +08:00
修改标点错误 (#494)
This commit is contained in:
@@ -117,8 +117,8 @@ func MakeAddSuffix(suffix string) func(string) string {
|
||||
现在,我们可以生成如下函数:
|
||||
|
||||
```go
|
||||
addBmp := MakeAddSuffix(“.bmp”)
|
||||
addJpeg := MakeAddSuffix(“.jpeg”)
|
||||
addBmp := MakeAddSuffix(".bmp")
|
||||
addJpeg := MakeAddSuffix(".jpeg")
|
||||
```
|
||||
|
||||
然后调用它们:
|
||||
|
@@ -65,7 +65,7 @@ func main() {
|
||||
下面的代码试图访问一个未引用的变量或者函数,甚至没有编译。将会返回一个错误:
|
||||
|
||||
```go
|
||||
fmt.Printf(“Float from package1: %f\n”, pack1.pack1Float)
|
||||
fmt.Printf("Float from package1: %f\n", pack1.pack1Float)
|
||||
```
|
||||
|
||||
错误:
|
||||
|
@@ -22,7 +22,7 @@ Go 是怎么处理普通错误的呢?通过在函数和方法中返回错误
|
||||
|
||||
```go
|
||||
if value, err := pack1.Func1(param1); err != nil {
|
||||
fmt.Printf(“Error %s in pack1.Func1 with parameter %v”, err.Error(), param1)
|
||||
fmt.Printf("Error %s in pack1.Func1 with parameter %v", err.Error(), param1)
|
||||
return // or: return err
|
||||
} else {
|
||||
// Process(value)
|
||||
|
@@ -35,7 +35,7 @@ func errorHandler(fn fType1) fType1 {
|
||||
return func(a type1, b type2) {
|
||||
defer func() {
|
||||
if err, ok := recover().(error); ok {
|
||||
log.Printf(“run time panic: %v”, err)
|
||||
log.Printf("run time panic: %v", err)
|
||||
}
|
||||
}()
|
||||
fn(a, b)
|
||||
|
@@ -101,7 +101,7 @@ include $(GOROOT)/src/Make.pkg
|
||||
```go
|
||||
func TestEven(t *testing.T) {
|
||||
if Even(10) {
|
||||
t.Log(“Everything OK: 10 is even, just a test to see failed output!”)
|
||||
t.Log("Everything OK: 10 is even, just a test to see failed output!")
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
@@ -12,9 +12,9 @@ var tests = []struct{ // Test table
|
||||
out string
|
||||
|
||||
}{
|
||||
{“in1”, “exp1”},
|
||||
{“in2”, “exp2”},
|
||||
{“in3”, “exp3”},
|
||||
{"in1", "exp1"},
|
||||
{"in2", "exp2"},
|
||||
{"in3", "exp3"},
|
||||
...
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ func TestFunction(t *testing.T) {
|
||||
for i, tt := range tests {
|
||||
s := FuncToBeTested(tt.in)
|
||||
if s != tt.out {
|
||||
t.Errorf(“%d. %q => %q, wanted: %q”, i, tt.in, s, tt.out)
|
||||
t.Errorf("%d. %q => %q, wanted: %q", i, tt.in, s, tt.out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user