Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,9 @@ q, err := questionnaire.New(yamlData)

### Medium Term

1. Add loaders for different configuration formats
Introduce a loader interface to handle different config types. These loaders would be responsible for reading from files, parsing YAML/JSON, etc.
- read the configuration from a JSON file
- read the configuration from JSON bytes
- pass pre-configured questions
2. Question type system (text input, numbers, etc.)
3. Question validation (required fields, formats)
4. Performance optimizations for large questionnaires
1. Question type system (text input, numbers, etc.)
2. Question validation (required fields, formats)
3. Performance optimizations for large questionnaires
- Pre-compute which questions are available
- Cache condition evaluation results

Expand Down
6 changes: 2 additions & 4 deletions examples/cli/go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
module github.com/antfroger/go-dynamic-questionnaire/examples/cli

go 1.23.0

toolchain go1.23.4
go 1.24.0

replace github.com/antfroger/go-dynamic-questionnaire => ../../

require github.com/antfroger/go-dynamic-questionnaire v0.0.0

require (
github.com/expr-lang/expr v1.17.5 // indirect
github.com/expr-lang/expr v1.17.6 // indirect
github.com/goccy/go-yaml v1.18.0 // indirect
)
42 changes: 24 additions & 18 deletions examples/cli/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/expr-lang/expr v1.17.5 h1:i1WrMvcdLF249nSNlpQZN1S6NXuW9WaOfF5tPi3aw3k=
github.com/expr-lang/expr v1.17.5/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4=
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/expr-lang/expr v1.17.6 h1:1h6i8ONk9cexhDmowO/A64VPxHScu7qfSl2k8OlINec=
github.com/expr-lang/expr v1.17.6/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
Expand All @@ -8,21 +10,25 @@ github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5 h1:xhMrHhTJ6zxu3gA4enFM9MLn9AY7613teCdFnlUVbSQ=
github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5/go.mod h1:5hDyRhoBCxViHszMt12TnOpEI4VVi+U8Gm9iphldiMA=
github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus=
github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8=
github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y=
github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0=
github.com/google/pprof v0.0.0-20250820193118-f64d9cf942d6 h1:EEHtgt9IwisQ2AZ4pIsMjahcegHh6rmhqxzIRQIyepY=
github.com/google/pprof v0.0.0-20250820193118-f64d9cf942d6/go.mod h1:I6V7YzU0XDpsHqbsyrghnFZLO1gwK6NPTNvmetQIk9U=
github.com/onsi/ginkgo/v2 v2.26.0 h1:1J4Wut1IlYZNEAWIV3ALrT9NfiaGW2cDCJQSFQMs/gE=
github.com/onsi/ginkgo/v2 v2.26.0/go.mod h1:qhEywmzWTBUY88kfO0BRvX4py7scov9yR+Az2oavUzw=
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=
github.com/onsi/gomega v1.38.2/go.mod h1:W2MJcYxRGV63b418Ai34Ud0hEdTVXq9NW9+Sx6uXf3k=
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0=
golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ=
golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc=
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=
2 changes: 1 addition & 1 deletion examples/rest-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ The API provides clear error responses:

```go
var questionnaires = map[string]string{
"survey": "survey.yaml",
"survey": "survey.json",
"your-questionnaire": "your-file.yaml",
}
```
Expand Down
2 changes: 1 addition & 1 deletion examples/rest-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

// Available questionnaires
var questionnaires = map[string]string{
"survey": "survey.yaml",
"survey": "survey.json",
}

// Response structures
Expand Down
159 changes: 159 additions & 0 deletions examples/rest-api/survey.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"questions": [
{
"id": "satisfaction",
"text": "How satisfied are you with our service overall?",
"answers": [
"Very Satisfied",
"Satisfied",
"Neutral",
"Dissatisfied",
"Very Dissatisfied"
]
},
{
"id": "support_quality",
"text": "How would you rate the quality of our customer support?",
"answers": [
"Excellent",
"Good",
"Average",
"Poor",
"Very Poor"
]
},
{
"id": "recommend",
"text": "Would you recommend our service to others?",
"answers": [
"Definitely",
"Probably",
"Maybe",
"Probably Not",
"Definitely Not"
],
"depends_on": [
"satisfaction"
],
"condition": "answers[\"satisfaction\"] in [1,2]"
},
{
"id": "improvement_areas",
"text": "What areas do you think we need to improve the most?",
"answers": [
"Product Features",
"Customer Support",
"Pricing",
"User Experience",
"Documentation"
],
"depends_on": [
"satisfaction"
],
"condition": "answers[\"satisfaction\"] >= 3"
},
{
"id": "feature_priority",
"text": "Which new feature would be most valuable to you?",
"answers": [
"Mobile App",
"Advanced Analytics",
"Integration Options",
"Automation Tools",
"Collaboration Features"
],
"depends_on": [
"improvement_areas"
],
"condition": "answers[\"improvement_areas\"] == 1"
},
{
"id": "support_channel",
"text": "What is your preferred way to get customer support?",
"answers": [
"Live Chat",
"Email Support",
"Phone Support",
"Self-Service Portal",
"Video Call"
],
"depends_on": [
"improvement_areas",
"support_quality"
],
"condition": "answers[\"improvement_areas\"] == 2 or answers[\"support_quality\"] >= 3"
},
{
"id": "price_perception",
"text": "How do you feel about our current pricing?",
"answers": [
"Great Value",
"Fair Price",
"Slightly Expensive",
"Too Expensive",
"Way Too Expensive"
],
"depends_on": [
"improvement_areas"
],
"condition": "answers[\"improvement_areas\"] == 3"
},
{
"id": "usage_frequency",
"text": "How often do you use our service?",
"answers": [
"Daily",
"Several times a week",
"Weekly",
"Monthly",
"Rarely"
]
},
{
"id": "business_impact",
"text": "How much impact has our service had on your business/work?",
"answers": [
"Transformational",
"Significant Improvement",
"Moderate Improvement",
"Minor Improvement",
"No Noticeable Impact"
],
"depends_on": [
"usage_frequency"
],
"condition": "answers[\"usage_frequency\"] in 1..3"
},
{
"id": "alternative_consideration",
"text": "Have you considered switching to a competitor?",
"answers": [
"Never",
"Rarely Think About It",
"Sometimes",
"Often",
"Actively Looking"
],
"depends_on": [
"satisfaction",
"recommend"
],
"condition": "answers[\"satisfaction\"] >= 4 or answers[\"recommend\"] >= 4"
},
{
"id": "loyalty_factor",
"text": "What keeps you as our customer?",
"answers": [
"Superior Product",
"Great Support",
"Fair Pricing",
"Easy to Use",
"Integration Dependencies"
],
"depends_on": [
"alternative_consideration"
],
"condition": "answers[\"alternative_consideration\"] in [1,2]"
}
]
}
115 changes: 0 additions & 115 deletions examples/rest-api/survey.yaml

This file was deleted.

Loading
Loading