survey

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportSurvey

func ExportSurvey(s *Survey, exporter Exporter) error

func SaveSurvey

func SaveSurvey(survey *Survey, repo Repository) error

Decouple the SaveSurvey function from the concrete Repository implementation

func WriteSurvey

func WriteSurvey(s *Survey, writer io.Writer) (int, error)

Use generic io.Writer instead of a concrete struct/file/etc.

Types

type DropdownQuestion struct {
	Title   string
	Options []string
}
func (q *DropdownQuestion) AddOption(option string)
func (q *DropdownQuestion) SetTitle(title string)

type Exporter

type Exporter interface {
	Export(survey *Survey) error
}

type GCSExporter

type GCSExporter struct{}

func (*GCSExporter) Export

func (e *GCSExporter) Export(survey *Survey) error

type InMemoryRepository

type InMemoryRepository struct {
	// contains filtered or unexported fields
}

func (*InMemoryRepository) Save

func (r *InMemoryRepository) Save(survey *Survey) error

type Question

type Question interface {
	SetTitle()
}

Base interface

type QuestionWithOptions

type QuestionWithOptions interface {
	Question
	AddOption()
}

Has addtional method AddOption

type Repository

type Repository interface {
	Save(survey *Survey) error
}

Repository is an interface that defines the methods that a concrete repository must implement

type S3Exporter

type S3Exporter struct{}

func (*S3Exporter) Export

func (e *S3Exporter) Export(survey *Survey) error

type Survey

type Survey struct {
	Title     string
	Questions []string
}

func (*Survey) GetTitle

func (s *Survey) GetTitle() string

func (*Survey) Validate

func (s *Survey) Validate() bool

type SurveyManager

type SurveyManager struct {
	// contains filtered or unexported fields
}

func NewSurveyManager

func NewSurveyManager(store Repository) *SurveyManager

Pass the Repository interface instead of the concrete InMemoryRepository

func (*SurveyManager) Save

func (m *SurveyManager) Save(survey *Survey) error

type TextQuestion

type TextQuestion struct {
	Title string
}

func (*TextQuestion) SetTitle

func (q *TextQuestion) SetTitle(title string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL