How to force package users to use struct composite literals with field names ? #golang #tips #shorts

preview_player
Показать описание
How to force package users to use struct composite literals with field names?

Package developers can put a non-exported zero-size field in a struct type definition, so that compilers will forbid package users using composite literals with some field items but without field names to create values of the struct type.

#golang #golanguage #tips #tipsandtricks #programming #backend #backenddeveloper #backenddevelopment
Рекомендации по теме
visit shbcf.ru