Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
godebug
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
godebug
Commits
e41382cf
Commit
e41382cf
authored
Jan 06, 2013
by
Kyle Lemons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Compare example
parent
0ce6b6c8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
pretty/examples_test.go
pretty/examples_test.go
+46
-0
No files found.
pretty/examples_test.go
View file @
e41382cf
...
@@ -90,3 +90,49 @@ func ExamplePrint() {
...
@@ -90,3 +90,49 @@ func ExamplePrint() {
// Androids: 1,
// Androids: 1,
// Stolen: true}
// Stolen: true}
}
}
func
ExampleCompare
()
{
type
ShipManifest
struct
{
Name
string
Crew
map
[
string
]
string
Androids
int
Stolen
bool
}
reported
:=
&
ShipManifest
{
Name
:
"Spaceship Heart of Gold"
,
Crew
:
map
[
string
]
string
{
"Zaphod Beeblebrox"
:
"Galactic President"
,
"Trillian"
:
"Human"
,
"Ford Prefect"
:
"A Hoopy Frood"
,
"Arthur Dent"
:
"Along for the Ride"
,
},
Androids
:
1
,
Stolen
:
true
,
}
expected
:=
&
ShipManifest
{
Name
:
"Spaceship Heart of Gold"
,
Crew
:
map
[
string
]
string
{
"Rowan Artosok"
:
"Captain"
,
},
Androids
:
1
,
Stolen
:
false
,
}
fmt
.
Println
(
pretty
.
Compare
(
reported
,
expected
))
// Output:
// {
// Name: "Spaceship Heart of Gold",
// Crew: {
// - Arthur Dent: "Along for the Ride",
// - Ford Prefect: "A Hoopy Frood",
// - Trillian: "Human",
// - Zaphod Beeblebrox: "Galactic President",
// + Rowan Artosok: "Captain",
// },
// Androids: 1,
// - Stolen: true,
// + Stolen: false,
// }
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment