{"repo":"moznion/gonstructor","free":true,"listed":false,"github":"https://github.com/moznion/gonstructor","clone":"git clone https://github.com/moznion/gonstructor.git","description":"A command-line tool to generate a constructor for the struct.","language":"Go","stars":94,"topics":["golang","code-generation"],"license":"BSD-3-Clause","category":"dev-tools","readme_excerpt":"gonstructor A command-line tool to generate a constructor for the struct. Installation Also, you can get the pre-built binaries on Releases. Or get it with gobinaries.com: Dependencies gonstructor depends on goimports for fixing import paths and formatting code, you need to install it: Usage Motivation Data encapsulation is a good practice to make software, and it is necessary to clearly indicate the boundary of the structure by controlling the accessibility of the data fields (i.e. private or public) for that. Basically keeping the data fields be private and immutable would be good to make software be robust because it can avoid unexpected field changing. Golang has a simple way to do that by choosing the initial character's type: upper case or lower case. Once it has decided to use a field as private, it needs to make something like a constructor function, but golang doesn't have a mechanism to support constructor now. Therefore this project aims to automatically generate constructors to use structures with private and immutable, easily. Pre requirements to run - goimports Synopsis Generate all args constructor 1. write a struct type with go:generate e.g. 2. execute go generate ./... 3. then gonstructor generates a constructor code e.g. Generate builder (builder means GoF pattern's one) 1. write a struct type with go:generate e.g. 2. execute go generate ./... 3. then gonstructor generates a buildr code e.g. Call a initializer 1. write a struct type with go:generate 2. write","default_branch":null,"files":null,"tree":[],"storefront":"/r/moznion","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/moznion/gonstructor/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}