diff options
author | Laria Carolin Chabowski <laria@laria.me> | 2017-09-14 07:42:50 +0200 |
---|---|---|
committer | Laria Carolin Chabowski <laria@laria.me> | 2017-09-26 21:35:41 +0200 |
commit | b2742dc28d1ff9001cd784455bbdf9cf29539c30 (patch) | |
tree | 2cac9dff572edbfc05588c33cce76a3dbb406d15 /objects/id.go | |
parent | 9ddda1c317dbeaab1380e46ebf48eba9566a90e2 (diff) | |
download | petrific-b2742dc28d1ff9001cd784455bbdf9cf29539c30.tar.gz petrific-b2742dc28d1ff9001cd784455bbdf9cf29539c30.tar.bz2 petrific-b2742dc28d1ff9001cd784455bbdf9cf29539c30.zip |
Implement remaining subcommands
Diffstat (limited to 'objects/id.go')
-rw-r--r-- | objects/id.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/objects/id.go b/objects/id.go index 224b3cd..047fada 100644 --- a/objects/id.go +++ b/objects/id.go @@ -39,7 +39,7 @@ type ObjectId struct { Sum []byte } -func (oid ObjectId) wellformed() bool { +func (oid ObjectId) Wellformed() bool { return oid.Algo.checkAlgo() && len(oid.Sum) == oid.Algo.sumLength() } @@ -61,13 +61,19 @@ func ParseObjectId(s string) (oid ObjectId, err error) { return } - if !oid.wellformed() { + if !oid.Wellformed() { err = errors.New("Object ID is malformed") } return } +// Set implements flag.Value for ObjectId +func (oid *ObjectId) Set(s string) (err error) { + *oid, err = ParseObjectId(s) + return +} + func MustParseObjectId(s string) ObjectId { id, err := ParseObjectId(s) if err != nil { |