| name | go-based-tutors |
| description | Pattern for building interactive CLI tutors in Go with standardized colors, progress tracking, and pedagogical elements |
| version | 1.0.0 |
| author | Ormus |
| tags | ["go","cli","education","tutor","interactive","learning"] |
Go-Based Tutors Concoction
Pattern for creating interactive command-line educational tools in Go.
Core Components
1. Standardized Color System
const (
reset = "\033[0m"
bold = "\033[1m"
dim = "\033[2m"
cRed = "\033[31m"
cGreen = "\033[32m"
cYellow = "\033[33m"
cBlue = "\033[34m"
cMagenta = "\033[35m"
cCyan = "\033[36m"
cBrightGreen = "\033[92m"
)
func keyTerm(s string) string { return cYellow + bold + s + reset }
func do(s string) string { return cGreen + "DO: " + reset + s }
func dont(s string) string { return cRed + "DON'T: " + reset + s }
func tip(s string) string { return cCyan + "TIP: " + reset + s }
func cmd(s string) string { return cBlue + s + reset }
func correct(s string) string { return cBrightGreen + bold + s + reset }
func wrong(s string) string { return cRed + s + reset }
2. Interactive Elements
Three types of comprehension checks (keep simple for beginners):
func predictOutput(code, correctOutput, explanation string) bool
func fillBlank(instruction, code, answer, explanation string) bool
func fixBug(code string, options []string, correctIdx int, explanation string) bool
Key principle: Questions should be comprehension checks, not knowledge tests. Answers should be obvious from text just read.
3. Progress Tracking
type Progress struct {
CompletedLessons []int `json:"completed_lessons"`
QuizScores map[string]int `json:"quiz_scores"`
InteractiveAttempts int `json:"interactive_attempts"`
InteractiveCorrect int `json:"interactive_correct"`
LastAccess time.Time `json:"last_access"`
}
Persist to progress.json in working directory.
4. Lesson Structure
type Lesson struct {
ID int
Title string
Content func()
Quiz []QuizQuestion
}
5. Menu Patterns
- Cyan numbers for options
- Yellow for headers
- Magenta for section dividers
- Dim for "Back" options
- Green checkmarks for completed items
Existing Implementations
| Tutor | Location | Purpose |
|---|
| GoTutor | ~/projects/08-DEVELOPMENT/learning/boot.dev/projects/learn-go-pocket-projects/14-gotutor/ | Go language fundamentals |
| LinuxTutor | ~/projects/08-DEVELOPMENT/learning/boot.dev/projects/learn-go-pocket-projects/15-linuxtutor/ | Linux/LPI certification prep |
| VibeReader | ~/projects/08-DEVELOPMENT/learning/vibe-engineering-tutor/ | Interactive book reading (PDF→sections) |
Creating New Tutors
- Copy color constants and helpers from existing tutor
- Define lesson structure with
Content func() for dynamic rendering
- Add interactive checkpoints within lessons (simple comprehension)
- Implement progress persistence
- Follow menu color conventions for consistency
Interactive Book Reader Pattern (Gen-Z Boring-Proof)
For converting PDFs/books into interactive reading:
1. Extract & Split
pdftotext "book.pdf" "book.txt"
2. Section Structure
type Section struct {
ID string
Title string
Content string
KeyConcept string
Alternatives []string
Hint string
}
3. Key Concept Verification
- User must type the key concept to proceed
- Fuzzy matching (lowercase, ignore hyphens)
- Multiple alternatives accepted
- Hints available, skip option for emergencies
- Tracks first-try accuracy
4. Anti-Boring Features
- Can't just press Enter - must demonstrate comprehension
- Progress bars and completion tracking
- First-try accuracy gamification
Design Principles
- Simplicity: Interactive questions confirm reading, not test knowledge
- Consistency: Same colors across all tutors
- Progress: Visual feedback on completion status
- Encouragement: Positive feedback, helpful hints on wrong answers
- Engagement: Require input to proceed (no passive reading)