Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: run examples in source order, not name order
Add Order field to doc.Example and write doc comments there. Fixes #4662. R=golang-dev, iant CC=golang-dev https://golang.org/cl/7229071
- Loading branch information
Showing
5 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2013 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// Make sure that go test runs Example_Z before Example_A, preserving source order. | ||
|
||
package p | ||
|
||
import "fmt" | ||
|
||
var n int | ||
|
||
func Example_Z() { | ||
n++ | ||
fmt.Println(n) | ||
// Output: 1 | ||
} | ||
|
||
func Example_A() { | ||
n++ | ||
fmt.Println(n) | ||
// Output: 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2013 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// Make sure that go test runs Example_Y before Example_B, preserving source order. | ||
|
||
package p | ||
|
||
import "fmt" | ||
|
||
func Example_Y() { | ||
n++ | ||
fmt.Println(n) | ||
// Output: 3 | ||
} | ||
|
||
func Example_B() { | ||
n++ | ||
fmt.Println(n) | ||
// Output: 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters