| 1 |
rsc.io/[email protected] |
| 2 |
|
| 3 |
-- .mod -- |
| 4 |
module "rsc.io/quote" |
| 5 |
|
| 6 |
require "rsc.io/sampler" v1.0.0 |
| 7 |
-- .info -- |
| 8 |
{"Version":"v1.4.0","Name":"19e8b977bd2f437798c2cc2dcfe8a1c0f169481b","Short":"19e8b977bd2f","Time":"2018-02-14T00:56:05Z"} |
| 9 |
-- go.mod -- |
| 10 |
module "rsc.io/quote" |
| 11 |
|
| 12 |
require "rsc.io/sampler" v1.0.0 |
| 13 |
-- quote.go -- |
| 14 |
// Copyright 2018 The Go Authors. All rights reserved. |
| 15 |
// Use of this source code is governed by a BSD-style |
| 16 |
// license that can be found in the LICENSE file. |
| 17 |
|
| 18 |
// Package quote collects pithy sayings. |
| 19 |
package quote // import "rsc.io/quote" |
| 20 |
|
| 21 |
import "rsc.io/sampler" |
| 22 |
|
| 23 |
// Hello returns a greeting. |
| 24 |
func Hello() string { |
| 25 |
return sampler.Hello() |
| 26 |
} |
| 27 |
|
| 28 |
// Glass returns a useful phrase for world travelers. |
| 29 |
func Glass() string { |
| 30 |
// See http://www.oocities.org/nodotus/hbglass.html. |
| 31 |
return "I can eat glass and it doesn't hurt me." |
| 32 |
} |
| 33 |
|
| 34 |
// Go returns a Go proverb. |
| 35 |
func Go() string { |
| 36 |
return "Don't communicate by sharing memory, share memory by communicating." |
| 37 |
} |
| 38 |
|
| 39 |
// Opt returns an optimization truth. |
| 40 |
func Opt() string { |
| 41 |
// Wisdom from ken. |
| 42 |
return "If a program is too slow, it must have a loop." |
| 43 |
} |
| 44 |
-- quote_test.go -- |
| 45 |
// Copyright 2018 The Go Authors. All rights reserved. |
| 46 |
// Use of this source code is governed by a BSD-style |
| 47 |
// license that can be found in the LICENSE file. |
| 48 |
|
| 49 |
package quote |
| 50 |
|
| 51 |
import "testing" |
| 52 |
|
| 53 |
func TestHello(t *testing.T) { |
| 54 |
hello := "Hello, world." |
| 55 |
if out := Hello(); out != hello { |
| 56 |
t.Errorf("Hello() = %q, want %q", out, hello) |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
func TestGlass(t *testing.T) { |
| 61 |
glass := "I can eat glass and it doesn't hurt me." |
| 62 |
if out := Glass(); out != glass { |
| 63 |
t.Errorf("Glass() = %q, want %q", out, glass) |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
func TestGo(t *testing.T) { |
| 68 |
go1 := "Don't communicate by sharing memory, share memory by communicating." |
| 69 |
if out := Go(); out != go1 { |
| 70 |
t.Errorf("Go() = %q, want %q", out, go1) |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
func TestOpt(t *testing.T) { |
| 75 |
opt := "If a program is too slow, it must have a loop." |
| 76 |
if out := Opt(); out != opt { |
| 77 |
t.Errorf("Opt() = %q, want %q", out, opt) |
| 78 |
} |
| 79 |
} |