osv: add omitempty to published and modified fields
The modified field is required (published is not), but it's useful
for us to be able to store partial OSV entries without a modification
time. Set the omitempty json tag on these fields so they don't
show up with the zero Time.
Change-Id: Id044c84f67ad89bec29ed9f0d1cec1fd3c53105c
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/431435
Reviewed-by: Tatiana Bradley <tatiana@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/osv/json.go b/osv/json.go
index 3160fda..d3bc865 100644
--- a/osv/json.go
+++ b/osv/json.go
@@ -182,8 +182,8 @@
// entry
type Entry struct {
ID string `json:"id"`
- Published time.Time `json:"published"`
- Modified time.Time `json:"modified"`
+ Published time.Time `json:"published,omitempty"`
+ Modified time.Time `json:"modified,omitempty"`
Withdrawn *time.Time `json:"withdrawn,omitempty"`
Aliases []string `json:"aliases,omitempty"`
Details string `json:"details"`