{"repo":"kazhuravlev/options-gen","free":true,"listed":false,"github":"https://github.com/kazhuravlev/options-gen","clone":"git clone https://github.com/kazhuravlev/options-gen.git","description":"Codegen for functional options in go projects","language":"Go","stars":110,"topics":["configuration","go","golang","lib","options","codegen","go-generate","go-lib","tool"],"license":"MIT","category":"dev-tools","readme_excerpt":"options-gen Eliminate boilerplate when implementing the functional options pattern in Go. options-gen is a code generator that automatically creates type-safe constructors, setter functions, and validation logic for your structs using the functional options pattern. What problem does this solve? - Writing functional options by hand is tedious and error-prone - Manually managing required vs optional parameters leads to constructor overload - Validating options and providing defaults requires repetitive boilerplate What you get: - Type-safe constructors with mandatory parameters - Generated WithX() setter functions for optional fields - Built-in validation using struct tags - Flexible default values (tags, variables, or functions) - Support for Go generics Installation Quick Start 1. Define your options struct with a generate directive: 2. Generate the code: 3. Use the generated constructor: That's it! The tool generates type-safe constructors, setter functions, and validation logic. Usage Step 1: Define Your Options Struct Step 2: Generate Code Step 3: What Gets Generated This generates options generated.go with: Step 4: Use in Your Code Usage in main.go: Understanding Tags Tag Purpose Effect ----------------------- ---------------------------------------------- ------------------------------------------------------------------------------------------------------------------------ option:\"mandatory\" Makes field a required constructor parameter Field must be provided when calli","default_branch":null,"files":null,"tree":[],"storefront":"/r/kazhuravlev","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/kazhuravlev/options-gen/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."}