Get the App
SLTechnology News&Howtos  ›  Development  › 

How golang uses private fields

Shulou Source: shulou.com Published: 2022-06-01 04:10:33 11月12日 Update

Editor to share with you how golang uses private fields, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!

Use private fields

Go's standard library supports only public's field. Jsoniter has additional support for private's field. Use SupportPrivateFields () to turn on the switch.

Import "github.com/json-iterator/go/extra" extra.SupportPrivateFields () type TestObject struct {field1 string} obj: = TestObject {} jsoniter.UnmarshalFromString (`{"field1": "Hello"}`, & obj) should.Equal ("Hello", obj.field1) these are all the contents of the article "how golang uses private fields". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Fields private articles content support not much most more standards knowledge industry information information channels channels references learning help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Technology Shulou Information Docker Redmi