Update to gobook@4fdc3c0a831c14c716c2c013e42268f6d21a9a13
Change-Id: I63623453205b84eba5680e27f68e81e99e7bbeb9
This commit is contained in:
parent
b7e11892d0
commit
4f0ceb5e5d
|
@ -19,7 +19,7 @@ import (
|
||||||
// which requires the // Output comment to be at the end
|
// which requires the // Output comment to be at the end
|
||||||
// of the function.
|
// of the function.
|
||||||
|
|
||||||
func ExampleExpr() {
|
func Example_expr() {
|
||||||
e, _ := eval.Parse("sqrt(A / pi)")
|
e, _ := eval.Parse("sqrt(A / pi)")
|
||||||
Display("e", e)
|
Display("e", e)
|
||||||
// Output:
|
// Output:
|
||||||
|
@ -33,7 +33,7 @@ func ExampleExpr() {
|
||||||
// e.args[0].value.y.value = "pi"
|
// e.args[0].value.y.value = "pi"
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleSlice() {
|
func Example_slice() {
|
||||||
Display("slice", []*int{new(int), nil})
|
Display("slice", []*int{new(int), nil})
|
||||||
// Output:
|
// Output:
|
||||||
// Display slice ([]*int):
|
// Display slice ([]*int):
|
||||||
|
@ -41,7 +41,7 @@ func ExampleSlice() {
|
||||||
// slice[1] = nil
|
// slice[1] = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleNilInterface() {
|
func Example_nilInterface() {
|
||||||
var w io.Writer
|
var w io.Writer
|
||||||
Display("w", w)
|
Display("w", w)
|
||||||
// Output:
|
// Output:
|
||||||
|
@ -49,7 +49,7 @@ func ExampleNilInterface() {
|
||||||
// w = invalid
|
// w = invalid
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExamplePtrToInterface() {
|
func Example_ptrToInterface() {
|
||||||
var w io.Writer
|
var w io.Writer
|
||||||
Display("&w", &w)
|
Display("&w", &w)
|
||||||
// Output:
|
// Output:
|
||||||
|
@ -57,7 +57,7 @@ func ExamplePtrToInterface() {
|
||||||
// (*&w) = nil
|
// (*&w) = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleStruct() {
|
func Example_struct() {
|
||||||
Display("x", struct{ x interface{} }{3})
|
Display("x", struct{ x interface{} }{3})
|
||||||
// Output:
|
// Output:
|
||||||
// Display x (struct { x interface {} }):
|
// Display x (struct { x interface {} }):
|
||||||
|
@ -65,7 +65,7 @@ func ExampleStruct() {
|
||||||
// x.x.value = 3
|
// x.x.value = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleInterface() {
|
func Example_interface() {
|
||||||
var i interface{} = 3
|
var i interface{} = 3
|
||||||
Display("i", i)
|
Display("i", i)
|
||||||
// Output:
|
// Output:
|
||||||
|
@ -73,7 +73,7 @@ func ExampleInterface() {
|
||||||
// i = 3
|
// i = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExamplePtrToInterface2() {
|
func Example_ptrToInterface2() {
|
||||||
var i interface{} = 3
|
var i interface{} = 3
|
||||||
Display("&i", &i)
|
Display("&i", &i)
|
||||||
// Output:
|
// Output:
|
||||||
|
@ -82,7 +82,7 @@ func ExamplePtrToInterface2() {
|
||||||
// (*&i).value = 3
|
// (*&i).value = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleArray() {
|
func Example_array() {
|
||||||
Display("x", [1]interface{}{3})
|
Display("x", [1]interface{}{3})
|
||||||
// Output:
|
// Output:
|
||||||
// Display x ([1]interface {}):
|
// Display x ([1]interface {}):
|
||||||
|
@ -90,7 +90,7 @@ func ExampleArray() {
|
||||||
// x[0].value = 3
|
// x[0].value = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleMovie() {
|
func Example_movie() {
|
||||||
//!+movie
|
//!+movie
|
||||||
type Movie struct {
|
type Movie struct {
|
||||||
Title, Subtitle string
|
Title, Subtitle string
|
||||||
|
|
|
@ -93,7 +93,7 @@ func TestEqual(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleEqual() {
|
func Example_equal() {
|
||||||
//!+
|
//!+
|
||||||
fmt.Println(Equal([]int{1, 2, 3}, []int{1, 2, 3})) // "true"
|
fmt.Println(Equal([]int{1, 2, 3}, []int{1, 2, 3})) // "true"
|
||||||
fmt.Println(Equal([]string{"foo"}, []string{"bar"})) // "false"
|
fmt.Println(Equal([]string{"foo"}, []string{"bar"})) // "false"
|
||||||
|
@ -108,7 +108,7 @@ func ExampleEqual() {
|
||||||
// true
|
// true
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleEqualCycle() {
|
func Example_equalCycle() {
|
||||||
//!+cycle
|
//!+cycle
|
||||||
// Circular linked lists a -> b -> a and c -> c.
|
// Circular linked lists a -> b -> a and c -> c.
|
||||||
type link struct {
|
type link struct {
|
||||||
|
|
|
@ -5,7 +5,7 @@ package tempconv
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func Example1() {
|
func Example_one() {
|
||||||
{
|
{
|
||||||
//!+arith
|
//!+arith
|
||||||
fmt.Printf("%g\n", BoilingC-FreezingC) // "100" °C
|
fmt.Printf("%g\n", BoilingC-FreezingC) // "100" °C
|
||||||
|
@ -24,7 +24,7 @@ func Example1() {
|
||||||
// 180
|
// 180
|
||||||
}
|
}
|
||||||
|
|
||||||
func Example2() {
|
func Example_two() {
|
||||||
//!+printf
|
//!+printf
|
||||||
c := FToC(212.0)
|
c := FToC(212.0)
|
||||||
fmt.Println(c.String()) // "100°C"
|
fmt.Println(c.String()) // "100°C"
|
||||||
|
|
|
@ -18,6 +18,6 @@ func TestSort(t *testing.T) {
|
||||||
}
|
}
|
||||||
treesort.Sort(data)
|
treesort.Sort(data)
|
||||||
if !sort.IntsAreSorted(data) {
|
if !sort.IntsAreSorted(data) {
|
||||||
t.Errorf("not sorted: %s", data)
|
t.Errorf("not sorted: %v", data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ package intset
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func Example1() {
|
func Example_one() {
|
||||||
//!+main
|
//!+main
|
||||||
var x, y IntSet
|
var x, y IntSet
|
||||||
x.Add(1)
|
x.Add(1)
|
||||||
|
@ -30,7 +30,7 @@ func Example1() {
|
||||||
// true false
|
// true false
|
||||||
}
|
}
|
||||||
|
|
||||||
func Example2() {
|
func Example_two() {
|
||||||
var x IntSet
|
var x IntSet
|
||||||
x.Add(1)
|
x.Add(1)
|
||||||
x.Add(144)
|
x.Add(144)
|
||||||
|
|
|
@ -43,7 +43,7 @@ func TestEval(t *testing.T) {
|
||||||
got := fmt.Sprintf("%.6g", expr.Eval(test.env))
|
got := fmt.Sprintf("%.6g", expr.Eval(test.env))
|
||||||
fmt.Printf("\t%v => %s\n", test.env, got)
|
fmt.Printf("\t%v => %s\n", test.env, got)
|
||||||
if got != test.want {
|
if got != test.want {
|
||||||
t.Errorf("%s.Eval() in %s = %q, want %q\n",
|
t.Errorf("%s.Eval() in %v = %q, want %q\n",
|
||||||
test.expr, test.env, got, test.want)
|
test.expr, test.env, got, test.want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ func parsePrimary(lex *lexer) Expr {
|
||||||
lex.next() // consume ','
|
lex.next() // consume ','
|
||||||
}
|
}
|
||||||
if lex.token != ')' {
|
if lex.token != ')' {
|
||||||
msg := fmt.Sprintf("got %s, want ')'", lex.token)
|
msg := fmt.Sprintf("got %q, want ')'", lex.token)
|
||||||
panic(lexPanic(msg))
|
panic(lexPanic(msg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue