|
|
@@ -2,7 +2,7 @@
|
|
|
|
|
|
## 11.9.1 概念
|
|
|
|
|
|
-**空接口或者最小接口**不包含任何方法,它对实现不做任何要求:
|
|
|
+**空接口或者最小接口** 不包含任何方法,它对实现不做任何要求:
|
|
|
|
|
|
```go
|
|
|
type Any interface {}
|
|
|
@@ -154,9 +154,9 @@ var dataSlice []myType = FuncReturnSlice()
|
|
|
var interfaceSlice []interface{} = dataSlice
|
|
|
```
|
|
|
|
|
|
-可惜不能这么做,编译时会出错:`cannot use dataSlice (type []myType) as type []interface { } in assignment`
|
|
|
+可惜不能这么做,编译时会出错:`cannot use dataSlice (type []myType) as type []interface { } in assignment`。
|
|
|
|
|
|
-原因是它们俩在内存中的布局是不一样的(参考[http://golang.org/doc/go_spec.html](http://golang.org/doc/go_spec.html))。
|
|
|
+原因是它们俩在内存中的布局是不一样的(参考 [官方说明](http://golang.org/doc/go_spec.html))。
|
|
|
|
|
|
必须使用 `for-range` 语句来一个一个显式地复制:
|
|
|
|
|
|
@@ -252,4 +252,4 @@ func f3(x myInterface) {
|
|
|
|
|
|
- [目录](directory.md)
|
|
|
- 上一节:[第二个例子:读和写](11.8.md)
|
|
|
-- 下一节:[反射包](11.10.md)
|
|
|
+- 下一节:[对结构进行反射](11.10.md)
|