aboutsummaryrefslogtreecommitdiffstats
path: root/util/hash.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-08-13 15:28:16 +0200
committerMichael Muré <batolettre@gmail.com>2018-08-13 15:28:47 +0200
commitdf144e727a858ed07e3c9328d91efe052c4781e1 (patch)
treebfbfeea70f97ab3d4274c8e5add2c3aeeac1423b /util/hash.go
parentf2f779c5a8b4efe67317bbffe110a9880c1f529a (diff)
downloadgit-bug-df144e727a858ed07e3c9328d91efe052c4781e1.tar.gz
fix some linting trouble
Diffstat (limited to 'util/hash.go')
-rw-r--r--util/hash.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/util/hash.go b/util/hash.go
index df0a83b8..0a3964a0 100644
--- a/util/hash.go
+++ b/util/hash.go
@@ -5,12 +5,14 @@ import (
"io"
)
+// Hash is a git hash
type Hash string
func (h Hash) String() string {
return string(h)
}
+// UnmarshalGQL implement the Unmarshaler interface for gqlgen
func (h *Hash) UnmarshalGQL(v interface{}) error {
_, ok := v.(string)
if !ok {
@@ -26,10 +28,12 @@ func (h *Hash) UnmarshalGQL(v interface{}) error {
return nil
}
+// MarshalGQL implement the Marshaler interface for gqlgen
func (h Hash) MarshalGQL(w io.Writer) {
w.Write([]byte(`"` + h.String() + `"`))
}
+// IsValid tell if the hash is valid
func (h *Hash) IsValid() bool {
if len(*h) != 40 {
return false