aboutsummaryrefslogtreecommitdiff
path: root/lib/git/git_example_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-01-05 21:47:09 +0700
committerShulhan <ms@kilabit.info>2026-01-06 14:56:07 +0700
commitf9567f0d4fc5cf6d0e1cea2d22289250c6b1cb2b (patch)
tree452d58882f84b694f56ff3bd9de1fdea2c55c246 /lib/git/git_example_test.go
parent18be916ab6f8911fd23d8f0a91f5a26f3c07f636 (diff)
downloadpakakeh.go-f9567f0d4fc5cf6d0e1cea2d22289250c6b1cb2b.tar.xz
lib/git: implement Equaler interface on Git
The Equaler interface provide the method Equal that when implemented can be used to compare two instances of struct.
Diffstat (limited to 'lib/git/git_example_test.go')
-rw-r--r--lib/git/git_example_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/git/git_example_test.go b/lib/git/git_example_test.go
index 0b55a251..968d4431 100644
--- a/lib/git/git_example_test.go
+++ b/lib/git/git_example_test.go
@@ -40,3 +40,34 @@ func ExampleGit_IsIgnored() {
// "hello.go": false
// "foo/hello.go": false
}
+
+func ExampleGit_Equal() {
+ var agit *git.Git
+ var err error
+ agit, err = git.New(`testdata/Equal`)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ var vgit *git.Git
+ var dir = `testdata/IsIgnored`
+
+ vgit, err = git.New(dir)
+ if err != nil {
+ log.Fatal(err)
+ }
+ var got = agit.Equal(vgit)
+ fmt.Printf("On git %s: Equal is %t\n", dir, got)
+
+ dir = `testdata/Equal`
+ vgit, err = git.New(dir)
+ if err != nil {
+ log.Fatal(err)
+ }
+ got = agit.Equal(vgit)
+ fmt.Printf("On git %s: Equal is %t\n", dir, got)
+
+ // Output:
+ // On git testdata/IsIgnored: Equal is false
+ // On git testdata/Equal: Equal is true
+}