Unclear about type assertion in pointer example

This commit is contained in:
Patrick Mylund Nielsen 2012-01-04 08:30:26 +01:00
parent c6060554ee
commit 88b75b4791
2 changed files with 4 additions and 4 deletions

4
README
View File

@ -61,13 +61,13 @@ Usage:
c.Set("foo", foo, 0)
...
x, _ := c.Get("foo")
foo := x.(MyStruct)
foo := x.(*MyStruct)
fmt.Println(foo.Num)
...
foo.Num++
...
x, _ := c.Get("foo")
foo := x.(MyStruct)
foo := x.(*MyStruct)
foo.Println(foo.Num)
// will print:

View File

@ -72,13 +72,13 @@ import (
// c.Set("foo", foo, 0)
// ...
// x, _ := c.Get("foo")
// foo := x.(MyStruct)
// foo := x.(*MyStruct)
// fmt.Println(foo.Num)
// ...
// foo.Num++
// ...
// x, _ := c.Get("foo")
// foo := x.(MyStruct)
// foo := x.(*MyStruct)
// foo.Println(foo.Num)
//
// will print: