From 6a7be8879bd7a33017c181018780bf5f4915b056 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Sun, 16 Feb 2014 12:11:10 -0700 Subject: [PATCH] Add Stringer support. --- Makefile | 2 +- db.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a6ad051..b89032d 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ BENCH=. COVERPROFILE=/tmp/c.out bench: benchpreq - go test -v -test.bench=$(BENCH) ./.bench + go test -v -test.bench=$(BENCH) cover: fmt go test -coverprofile=$(COVERPROFILE) -test.run=$(TEST) . diff --git a/db.go b/db.go index 99cc9ca..3955152 100644 --- a/db.go +++ b/db.go @@ -1,6 +1,7 @@ package bolt import ( + "fmt" "io" "os" "sync" @@ -42,6 +43,16 @@ func (db *DB) Path() string { return db.path } +// GoString returns the Go string representation of the database. +func (db *DB) GoString() string { + return fmt.Sprintf("bolt.DB{path:%q}", db.path) +} + +// String returns the string representation of the database. +func (db *DB) String() string { + return fmt.Sprintf("DB<%q>", db.path) +} + // Open opens a data file at the given path and initializes the database. // If the file does not exist then it will be created automatically. func (db *DB) Open(path string, mode os.FileMode) error {