aboutsummaryrefslogtreecommitdiff
path: root/type_test.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-23 11:46:58 +0200
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-23 11:46:58 +0200
commitbf521e82e0128a2cc31a51f866fd5a86dc677a87 (patch)
tree9eaeb0dbb8eda2c22a7c48027796c2400ef15f51 /type_test.go
parent6bd17ab810ec1eaa1f93ef7136ee4008337a2f14 (diff)
refactored type.go
Moved structures for in/out HTTP data into reqres.go and added basic doc comments. A few minor edits as well to make things consistent.
Diffstat (limited to 'type_test.go')
-rw-r--r--type_test.go19
1 files changed, 5 insertions, 14 deletions
diff --git a/type_test.go b/type_test.go
index bcd66e6..f4e7b40 100644
--- a/type_test.go
+++ b/type_test.go
@@ -9,27 +9,18 @@ import (
)
func ExampleNewChecksumV1() {
- name := "foobar-1.2.3"
+ name := []byte("foobar-1.2.3")
hasher := sha256.New()
hasher.Write([]byte(name))
checksum := hasher.Sum(nil) // hash of package name
- item, err := NewChecksumV1(name, checksum)
- if err != nil {
- fmt.Printf("failed creating checksum item: %v", err)
- return
- }
+ item := NewChecksumV1(name, checksum)
fmt.Printf("%s\n", item)
- // Output: checksum_v1 foobar-1.2.3 UOeWe84malBvj2FLtQlr66WA0gUEa5GPR9I7LsYm114=
+ // Output: Format(checksum_v1): Package(foobar-1.2.3) Checksum(UOeWe84malBvj2FLtQlr66WA0gUEa5GPR9I7LsYm114=)
}
func ExampleMarshalChecksumV1() {
- item, err := NewChecksumV1("foobar-1.2.3", make([]byte, 32))
- if err != nil {
- fmt.Printf("failed creating checksum item: %v", err)
- return
- }
-
+ item := NewChecksumV1([]byte("foobar-1.2.3"), make([]byte, 32))
b, err := tls.Marshal(item)
if err != nil {
fmt.Printf("tls.Marshal() failed: %v", err)
@@ -52,5 +43,5 @@ func ExampleUnmarshalChecksumV1() {
return
}
fmt.Printf("%v\n", item)
- // Output: checksum_v1 foobar-1.2.3 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
+ // Output: Format(checksum_v1): Package(foobar-1.2.3) Checksum(AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=)
}