mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
@@ -13,11 +13,7 @@
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/mitchellh/hashstructure"
|
||||
)
|
||||
import "github.com/gohugoio/hugo/helpers"
|
||||
|
||||
// ResourceTransformationKey are provided by the different transformation implementations.
|
||||
// It identifies the transformation (name) and its configuration (elements).
|
||||
@@ -42,23 +38,6 @@ func (k ResourceTransformationKey) Value() string {
|
||||
return k.Name
|
||||
}
|
||||
|
||||
return k.Name + "_" + HashString(k.elements...)
|
||||
return k.Name + "_" + helpers.HashString(k.elements...)
|
||||
|
||||
}
|
||||
|
||||
// HashString returns a hash from the given elements.
|
||||
// It will panic if the hash cannot be calculated.
|
||||
func HashString(elements ...interface{}) string {
|
||||
var o interface{}
|
||||
if len(elements) == 1 {
|
||||
o = elements[0]
|
||||
} else {
|
||||
o = elements
|
||||
}
|
||||
|
||||
hash, err := hashstructure.Hash(o, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return strconv.FormatUint(hash, 10)
|
||||
}
|
||||
|
@@ -34,10 +34,3 @@ func TestResourceTransformationKey(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
c.Assert(key.Value(), qt.Equals, "testing_518996646957295636")
|
||||
}
|
||||
|
||||
func TestHashString(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
|
||||
c.Assert(HashString("a", "b"), qt.Equals, "2712570657419664240")
|
||||
c.Assert(HashString("ab"), qt.Equals, "590647783936702392")
|
||||
}
|
||||
|
Reference in New Issue
Block a user