{"id":37195871,"url":"https://github.com/antfroger/go-dynamic-questionnaire","last_synced_at":"2026-01-14T22:47:03.132Z","repository":{"id":304549673,"uuid":"1018669158","full_name":"antfroger/go-dynamic-questionnaire","owner":"antfroger","description":"Easily create dynamic questionnaires in Go and provide recommendations based on the answers","archived":false,"fork":false,"pushed_at":"2025-12-17T12:18:48.000Z","size":2755,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-21T00:00:28.005Z","etag":null,"topics":["dynamic-questioning","dynamic-questions","go","golang","golang-library","questionnaire","questionnaire-generator","questionnaire-web"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/antfroger/go-dynamic-questionnaire","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antfroger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-12T19:08:08.000Z","updated_at":"2025-12-17T12:18:45.000Z","dependencies_parsed_at":"2025-12-12T01:04:53.210Z","dependency_job_id":null,"html_url":"https://github.com/antfroger/go-dynamic-questionnaire","commit_stats":null,"previous_names":["antfroger/go-dynamic-questionnaire"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/antfroger/go-dynamic-questionnaire","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antfroger%2Fgo-dynamic-questionnaire","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antfroger%2Fgo-dynamic-questionnaire/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antfroger%2Fgo-dynamic-questionnaire/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antfroger%2Fgo-dynamic-questionnaire/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antfroger","download_url":"https://codeload.github.com/antfroger/go-dynamic-questionnaire/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antfroger%2Fgo-dynamic-questionnaire/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28436814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T22:37:52.437Z","status":"ssl_error","status_checked_at":"2026-01-14T22:37:31.496Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamic-questioning","dynamic-questions","go","golang","golang-library","questionnaire","questionnaire-generator","questionnaire-web"],"created_at":"2026-01-14T22:47:02.216Z","updated_at":"2026-01-14T22:47:03.114Z","avatar_url":"https://github.com/antfroger.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dynamic Questionnaire\n\nThe Go Dynamic Questionnaire is a Go library that creates dynamic questionnaires.  \nWant to create a questionnaire for your Go project that adapts the next questions based on previous answers?\nGo Dynamic Questionnaire is what you're looking for!\nYou can even provide recommendations or closing remarks based on the responses.\n\nDynamic Questionnaire requires Go \u003e= 1.23\n\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/antfroger/go-dynamic-questionnaire)](https://pkg.go.dev/github.com/antfroger/go-dynamic-questionnaire)\n[![CI](https://github.com/antfroger/go-dynamic-questionnaire/actions/workflows/go.yml/badge.svg)](https://github.com/antfroger/go-dynamic-questionnaire/actions/workflows/go.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/antfroger/go-dynamic-questionnaire)](https://goreportcard.com/report/github.com/antfroger/go-dynamic-questionnaire)\n[![Release](https://img.shields.io/github/release/antfroger/go-dynamic-questionnaire.svg?style=flat-square)](https://github.com/antfroger/go-dynamic-questionnaire/releases)\n\n## Installation\n\n```shell\ngo get \"github.com/antfroger/go-dynamic-questionnaire\"\n```\n\n## Basic Usage\n\nUse `questionnaire.New(\"config.yaml\")` to create and initialize the questionnaire based on your config.\n\n```go\nimport \"github.com/antfroger/go-dynamic-questionnaire\"\n\nfunc main() {\n    q, err := questionnaire.New(\"config.yaml\")\n    if err != nil {\n        // ...\n    }\n\n    answers := make(map[string]int)\n    for {\n        response, err := q.Next(answers)\n        if err != nil {\n            // ...\n        }\n\n        // When the questionnaire is completed, display closing remarks\n        if response.Completed {\n            displayClosingRemarks(response.ClosingRemarks)\n            break\n        }\n\n        // Display progress if available\n        if response.Progress != nil {\n            fmt.Printf(\"Progress: %d/%d questions answered\\n\", response.Progress.Current, response.Progress.Total)\n        }\n\n        // Ask the questions and get the answers from the user\n        for _, question := range response.Questions {\n            answer := getUserAnswer(question)\n            answers[question.Id] = answer\n        }\n    }\n}\n```\n\n## Configuration Format\n\nCreate questionnaires using YAML:\n\n```yaml\nquestions:\n  - id: \"satisfaction\"\n    text: \"How satisfied are you with our service?\"\n    answers:\n      - \"Very Satisfied\"\n      - \"Satisfied\"\n      - \"Neutral\"\n      - \"Dissatisfied\"\n      - \"Very Dissatisfied\"\n\n  - id: \"recommendation\"\n    text: \"Would you recommend us to others?\"\n    depends_on: [\"satisfaction\"]\n    condition: 'answers[\"satisfaction\"] in [1,2]'\n    answers:\n      - \"Definitely\"\n      - \"Probably\"\n      - \"Maybe\"\n\nclosing_remarks:\n  - id: \"thank_you\"\n    text: \"Thank you for your feedback!\"\n  - id: \"follow_up\"\n    text: \"We'll reach out to address your concerns.\"\n    condition: 'answers[\"satisfaction\"] \u003e= 4'\n```\n\n## Features\n\n### Unified API\n\nSingle `Next()` method returns everything you need:\n\n- Questions to display\n- Closing remarks (when completed)\n- Completion status\n- Progress tracking\n\nin a unified response:\n\n```go\ntype Response struct {\n    Questions      []Question      `json:\"questions\"`\n    ClosingRemarks []ClosingRemark `json:\"closing_remarks,omitempty\"`\n    Completed      bool            `json:\"completed\"`\n    Progress       *Progress       `json:\"progress,omitempty\"`\n}\n```\n\n### Closing Remarks\n\nShow personalized messages when questionnaire is completed:\n\n```go\ntype ClosingRemark struct {\n\t\tId   string `json:\"id\"`   // Unique identifier for the remark\n\t\tText string `json:\"text\"` // The message text to display\n\t}\n```\n\nConfigure closing remarks in your YAML:\n\n```yaml\nclosing_remarks:\n  - id: \"general\"\n    text: \"Thank you for completing the questionnaire!\"\n  - id: \"specific\"\n    text: \"Based on your answers, here's our recommendation...\"\n    condition: 'answers[\"interest\"] == 1'\n```\n\n### Progress Tracking\n\nTrack user progress through the questionnaire:\n\n```go\ntype Progress struct {\n    Current int `json:\"current\"`  // Questions answered\n    Total   int `json:\"total\"`    // Total questions in the current path\n}\n```\n\n### Conditional Logic\n\nDynamic question flow based on previous answers:\n\n```yaml\nquestions:\n  - id: \"experience\"\n    text: \"Do you have programming experience?\"\n    answers:\n      - \"Yes\"\n      - \"No\"\n  - id: \"language\"\n    text: \"Which language do you prefer?\"\n    condition: 'answers[\"experience\"] == 1'\n    answers:\n      - \"Go\"\n      - \"Python\"\n      - \"JavaScript\"\n```\n\n## Examples\n\n### CLI Application\n\nInteractive command-line questionnaire with progress display:\n\n```bash\ncd examples/cli\ngo run main.go tech.yaml\n```\n\n[More details in the dedicated README.](examples/cli/README.md)\n\n### REST API Server\n\nComplete web service with questionnaire endpoints:\n\n```bash\ncd examples/rest-api\ngo run main.go\n```\n\nAPI endpoints:\n\n- `GET /questionnaires` - List available questionnaires\n- `POST /questionnaires/{id}` - Get questions with progress and closing remarks\n\n[More details in the dedicated README.](examples/rest-api/README.md)\n\n## Advanced Features\n\n### Thread-Safe Design\n\nThe library is stateless and thread-safe by design. Each questionnaire instance can be safely used across multiple goroutines.\n\n### Expression Engine\n\nPowerful condition expressions using the [`expr`](https://github.com/expr-lang/expr) library:\n\n```yaml\ncondition: 'answers[\"age\"] \u003e= 18 and answers[\"country\"] == \"US\"'\ncondition: 'answers[\"score\"] in 1..5'\ncondition: 'len(answers) \u003e= 3'\n```\n\n### Flexible Input\n\nLoad questionnaires from files or byte arrays:\n\n```go\n// From file\nq, err := questionnaire.New(\"config.yaml\")\n\n// From bytes\nyamlData := []byte(`questions: ...`)\nq, err := questionnaire.New(yamlData)\n```\n\n## Areas for Improvement\n\n### Medium Term\n\n1. Question type system (text input, numbers, etc.)\n2. Question validation (required fields, formats)\n3. Performance optimizations for large questionnaires\n    - Pre-compute which questions are available\n    - Cache condition evaluation results\n\n### Long Term\n\n1. Internationalization support\n2. Advanced branching logic and survey flows\n3. Builder pattern for easier questionnaire construction\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantfroger%2Fgo-dynamic-questionnaire","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantfroger%2Fgo-dynamic-questionnaire","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantfroger%2Fgo-dynamic-questionnaire/lists"}