Config Questionnaire





A Go module for dynamically generating and running questionnaires based on the struct fields of provided config models.
Overview
This module leverages reflection to inspect struct fields of any given config model and generates a questionnaire accordingly. It supports fields of type string, int (and its variants), and bool. The questionnaire is interactive and runs in the terminal using the huh library for form generation and input handling.
Installation
To use this module in your Go project, ensure you have Go 1.22.1 or later, then run:
go get github.com/STRockefeller/config-questionnaire
Usage
- Define a config model as a Go struct. You can use the
questionnaire tag to customize the field name in the questionnaire.
package example
type Example struct {
Name string `questionnaire:"title:What's your name;"`
Age int
HasPet bool
}
- Use the
GenerateAndRunQuestionnaire function to generate and run the questionnaire based on your model.
package main
import (
"fmt"
questionnaire "github.com/STRockefeller/config-questionnaire"
"github.com/STRockefeller/config-questionnaire/example"
)
func main() {
e, err := questionnaire.GenerateAndRunQuestionnaire[example.Example]()
if err != nil {
panic(err)
}
fmt.Println(e)
}
- the generated questionnaire will be run in the terminal and the user will be prompted to enter values for each field. The values will be returned as a struct of the same type as the model.

Dependencies
This module relies on several external libraries for its functionality:
License
This module is licensed under the MIT License - see the LICENSE file for details.