-
-
Notifications
You must be signed in to change notification settings - Fork 176
Closed
Labels
Description
I have a product struct when to make it to json using Marshal, It takes too time around 10s-20s to convert. Is there any problem with my code or its a bug?
fmt.Println("Data is: ", products)
fmt.Println("Marshal start at: ", time.Now())
data, dataErr := gojson.Marshal(products)
fmt.Println("Marshal end at: ", time.Now())
if dataErr != nil {
fmt.Println(dataErr)
}
fmt.Println("data is: ",fmt.Sprintf("%s",data))
Data is: [SellerProduct(id=1, name=samsung, slug=samsung, selling_price=40000, product_price=0, quantity=0, active=false, offer_price=0, created_a
t=Mon Jan 1 00:00:00 0001, updated_at=Mon Jan 1 00:00:00 0001) SellerProduct(id=2, name=samsung s10, slug=samsung-s10, selling_price=40000, produ
ct_price=0, quantity=0, active=false, offer_price=0, created_at=Mon Jan 1 00:00:00 0001, updated_at=Mon Jan 1 00:00:00 0001) SellerProduct(id=3,
name=samsung s10, slug=samsung-s10-7943, selling_price=50000, product_price=0, quantity=0, active=false, offer_price=50, offer_price_start=Tue Feb
1 06:00:00 2022, offer_price_end=Mon Feb 7 06:00:00 2022, created_at=Mon Jan 1 00:00:00 0001, updated_at=Mon Jan 1 00:00:00 0001) SellerProduct
(id=4, name=nokia 7, slug=nokia-7, selling_price=50000, product_price=0, quantity=0, active=false, offer_price=50, offer_price_start=Tue Feb 1 06:
00:00 2022, offer_price_end=Mon Feb 7 06:00:00 2022, created_at=Mon Jan 1 00:00:00 0001, updated_at=Mon Jan 1 00:00:00 0001)]
**Marshal start at: 2022-02-01 13:46:41.6443916 +0600 +06 m=+11.061040001**
13:46:41 | 200 | 5ms | 127.0.0.1 | GET | /api/user/cart/count
13:46:41 | 200 | 84ms | 127.0.0.1 | GET | /api/nonuser/all/main/categories
**Marshal end at: 2022-02-01 13:46:54.1005208 +0600 +06 m=+23.517169201**
data is: [{"id":1,"name":"samsung","slug":"samsung","selling_price":"40000","product_price":"0","created_at":"0001-01-01T00:00:00Z","updated_at":"
0001-01-01T00:00:00Z","edges":{"seller_product_images":[{"id":1,"display":true,"image":"e8f49d7d15c54bd0b2d05f8c4bc4ab9a.jpeg","created_at":"0001-0
1-01T00:00:00Z","updated_at":"0001-01-01T00:00:00Z","edges":{}}]}},{"id":2,"name":"samsung s10","slug":"samsung-s10","selling_price":"40000","produ
ct_price":"0","created_at":"0001-01-01T00:00:00Z","updated_at":"0001-01-01T00:00:00Z","edges":{"seller_product_images":[{"id":4,"display":true,"ima
ge":"ac013a294da14320a8f991ed91db1d5f.jpg","created_at":"0001-01-01T00:00:00Z","updated_at":"0001-01-01T00:00:00Z","edges":{}}]}},{"id":3,"name":"s
amsung s10","slug":"samsung-s10-7943","selling_price":"50000","product_price":"0","offer_price":50,"offer_price_start":"2022-02-01T06:00:00+06:00",
"offer_price_end":"2022-02-07T06:00:00+06:00","created_at":"0001-01-01T00:00:00Z","updated_at":"0001-01-01T00:00:00Z","edges":{"seller_product_imag
es":[{"id":7,"display":true,"image":"fb5d1fa7e2834d2fbe2f725b509a7bf2.jpg","created_at":"0001-01-01T00:00:00Z","updated_at":"0001-01-01T00:00:00Z",
"edges":{}}]}},{"id":4,"name":"nokia 7","slug":"nokia-7","selling_price":"50000","product_price":"0","offer_price":50,"offer_price_start":"2022-02-
01T06:00:00+06:00","offer_price_end":"2022-02-07T06:00:00+06:00","created_at":"0001-01-01T00:00:00Z","updated_at":"0001-01-01T00:00:00Z","edges":{"
seller_product_images":[{"id":10,"display":true,"image":"65cd5529119640e09d85acf76f88ebaa.jpg","created_at":"0001-01-01T00:00:00Z","updated_at":"00
01-01-01T00:00:00Z","edges":{}}]}}]