-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change execution.hash type to []byte
- Loading branch information
Showing
11 changed files
with
42 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
package xstructhash | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cnf/structhash" | ||
) | ||
|
||
// Hash takes a data structure and returns a hash string of that data structure | ||
// Hash takes a data structure and returns a hash of that data structure | ||
// at the version asked. | ||
// | ||
// This function uses md5 hashing function and default formatter. See also Dump() | ||
// This function uses sha1 hashing function and default formatter. See also Dump() | ||
// function. | ||
func Hash(c interface{}, version int) string { | ||
return fmt.Sprintf("%x", structhash.Sha1(c, version)) | ||
func Hash(c interface{}, version int) []byte { | ||
return structhash.Sha1(c, version) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,12 @@ | ||
package xstructhash | ||
|
||
import ( | ||
"crypto/sha1" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/cnf/structhash" | ||
) | ||
|
||
func TestHash(t *testing.T) { | ||
s := struct{}{} | ||
v := 1 | ||
got := Hash(s, v) | ||
want := fmt.Sprintf("%x", sha1.Sum(structhash.Dump(s, v))) | ||
if got != want { | ||
t.Errorf("invalid hash") | ||
if got := fmt.Sprintf("%x", Hash(struct{}{}, 1)); got != "bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f" { | ||
t.Errorf("hash dosen't match - got: %s", got) | ||
} | ||
} |