mirror of https://github.com/golang/go.git
spec: fixed various example code snippets
Per suggestions by Peter Olsen (https://github.com/pto). Fixes #11964. Change-Id: Iae261ac14f75abf848f5601f59d7fe6e95b6805a Reviewed-on: https://go-review.googlesource.com/13006 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
384789e82b
commit
02d74485e4
|
|
@ -1,6 +1,6 @@
|
||||||
<!--{
|
<!--{
|
||||||
"Title": "The Go Programming Language Specification",
|
"Title": "The Go Programming Language Specification",
|
||||||
"Subtitle": "Version of July 30, 2015",
|
"Subtitle": "Version of July 31, 2015",
|
||||||
"Path": "/ref/spec"
|
"Path": "/ref/spec"
|
||||||
}-->
|
}-->
|
||||||
|
|
||||||
|
|
@ -1918,7 +1918,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (tz TimeZone) String() string {
|
func (tz TimeZone) String() string {
|
||||||
return fmt.Sprintf("GMT+%dh", tz)
|
return fmt.Sprintf("GMT%+dh", tz)
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
@ -2050,13 +2050,13 @@ a <a href="#Terminating_statements">terminating statement</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
func findMarker(c <-chan int) int {
|
func IndexRune(s string, r rune) int {
|
||||||
for i := range c {
|
for i, c := range s {
|
||||||
if x := <-c; isMarker(x) {
|
if c == r {
|
||||||
return x
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// invalid: missing return statement.
|
// invalid: missing return statement
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
@ -2598,9 +2598,10 @@ p.x // (*(*p).T0).x
|
||||||
|
|
||||||
q.x // (*(*q).T0).x (*q).x is a valid field selector
|
q.x // (*(*q).T0).x (*q).x is a valid field selector
|
||||||
|
|
||||||
p.M2() // p.M2() M2 expects *T2 receiver
|
p.M0() // ((*p).T0).M0() M0 expects *T0 receiver
|
||||||
p.M1() // ((*p).T1).M1() M1 expects T1 receiver
|
p.M1() // ((*p).T1).M1() M1 expects T1 receiver
|
||||||
p.M0() // ((&(*p).T0)).M0() M0 expects *T0 receiver, see section on Calls
|
p.M2() // p.M2() M2 expects *T2 receiver
|
||||||
|
t.M2() // (&t).M2() M2 expects *T2 receiver, see section on Calls
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue