aboutsummaryrefslogtreecommitdiff
path: root/type_test.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-30 20:40:17 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-30 20:40:17 +0100
commitf367d220ff99eaee7debb234c3234de6c781359c (patch)
tree49fda266aaf121e725780d2b7e2d6eb70710c74c /type_test.go
parent5426f3bcd1a5ae4fc4b3b831b41c0d667a17e525 (diff)
refactor types and documentation
Structured files a bit better, added more documentation, switched to pointers as default (unless specifically motivated not to do so), and encapsulated TLS (un)marshaling for the respective types that use it.
Diffstat (limited to 'type_test.go')
-rw-r--r--type_test.go14
1 files changed, 4 insertions, 10 deletions
diff --git a/type_test.go b/type_test.go
index f4e7b40..c6fa687 100644
--- a/type_test.go
+++ b/type_test.go
@@ -4,8 +4,6 @@ import (
"fmt"
"crypto/sha256"
-
- "github.com/google/certificate-transparency-go/tls"
)
func ExampleNewChecksumV1() {
@@ -21,9 +19,9 @@ func ExampleNewChecksumV1() {
func ExampleMarshalChecksumV1() {
item := NewChecksumV1([]byte("foobar-1.2.3"), make([]byte, 32))
- b, err := tls.Marshal(item)
+ b, err := item.Marshal()
if err != nil {
- fmt.Printf("tls.Marshal() failed: %v", err)
+ fmt.Printf("%v", err)
return
}
fmt.Printf("%v\n", b)
@@ -34,12 +32,8 @@ func ExampleUnmarshalChecksumV1() {
b := []byte{0, 5, 12, 102, 111, 111, 98, 97, 114, 45, 49, 46, 50, 46, 51, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
var item StItem
- extra, err := tls.Unmarshal(b, &item)
- if err != nil {
- fmt.Printf("tls.Unmarshal() failed: %v (%v)", err, extra)
- return
- } else if len(extra) > 0 {
- fmt.Printf("tls.Unmarshal() found extra data: %v", extra)
+ if err := item.Unmarshal(b); err != nil {
+ fmt.Printf("%v", err)
return
}
fmt.Printf("%v\n", item)