From 2a24912a064e5e817133fa6b2a90785bd03d692c Mon Sep 17 00:00:00 2001 From: Zakaria Date: Tue, 15 Sep 2026 14:06:38 -0400 Subject: [PATCH] tags in struct, conversion and comparability --- struct/main.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/struct/main.go b/struct/main.go index 815ae97..ab5d4ec 100644 --- a/struct/main.go +++ b/struct/main.go @@ -1,23 +1,19 @@ package main import ( + "encoding/json" "fmt" - "time" ) -type Employee struct { - Name string - EID int - Boss *Employee - Hired time.Time +type Response struct { + Page int `json:"page"` + Words []string `json:"words, omitempty"` } func main() { - e := Employee{ - Name: "Zack", - EID: 1, - Hired: time.Now(), - } + r := &Response{Page: 1, Words: []string{"Leena", "Sami", "Sara", "Zaki"}} - fmt.Println(e.Name, e.Hired.Format(time.RFC1123)) + j, _ := json.MarshalIndent(r, "", " ") + + fmt.Println(string(j)) }