From f367d220ff99eaee7debb234c3234de6c781359c Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Fri, 30 Oct 2020 20:40:17 +0100 Subject: 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. --- type_test.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'type_test.go') 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) -- cgit v1.2.3