diff options
author | Dmitry Ilvokhin <d@ilvokhin.com> | 2025-03-15 20:44:38 +0000 |
---|---|---|
committer | Dmitry Ilvokhin <d@ilvokhin.com> | 2025-03-15 20:44:38 +0000 |
commit | bbf5d9d99aa6131dccada8908b770ac10f52be59 (patch) | |
tree | 9497ef07375a0cefc7a5814df5f1e2078cc8e4c9 | |
parent | 5e1371457efa7f36913413eb4bc2cd045123f4de (diff) | |
download | flatbot-bbf5d9d99aa6131dccada8908b770ac10f52be59.tar.gz flatbot-bbf5d9d99aa6131dccada8908b770ac10f52be59.tar.bz2 flatbot-bbf5d9d99aa6131dccada8908b770ac10f52be59.zip |
Annotate `flat` fileds for JSON
-rw-r--r-- | flat.go | 4 | ||||
-rw-r--r-- | sent_test.go | 6 |
2 files changed, 5 insertions, 5 deletions
@@ -6,8 +6,8 @@ import ( ) type flat struct { - ID int - Price string + ID int `json:"id"` + Price string `json:"price"` } func (f *flat) URL() string { diff --git a/sent_test.go b/sent_test.go index 5232832..f8a72f0 100644 --- a/sent_test.go +++ b/sent_test.go @@ -22,7 +22,7 @@ func TestReadSentNew(t *testing.T) { func TestReadSent(t *testing.T) { tmp := t.TempDir() filename := filepath.Join(tmp, "sent.json") - data := []byte(`[{"ID":156522206,"Price":"£2,500"}]`) + data := []byte(`[{"id":156522206,"price":"£2,500"}]`) os.WriteFile(filename, data, 0644) got, err := readSent(filename) @@ -105,7 +105,7 @@ func TestWriteSentNew(t *testing.T) { if err != nil { t.Fatal(err) } - want := []byte(`[{"ID":156522206,"Price":"£2,500"}]`) + want := []byte(`[{"id":156522206,"price":"£2,500"}]`) if !reflect.DeepEqual(got, want) { t.Errorf("writeSent failed: got: %v, want: %v", got, want) } @@ -128,7 +128,7 @@ func TestWriteSentOverride(t *testing.T) { if err != nil { t.Fatal(err) } - want := []byte(`[{"ID":156522206,"Price":"£2,500"}]`) + want := []byte(`[{"id":156522206,"price":"£2,500"}]`) if !reflect.DeepEqual(got, want) { t.Errorf("writeSent failed: got: %v, want: %v", got, want) } |