Skip to content

Package restructuring: move core to internal/mycli and extract sub-packages #495

@apstndb

Description

@apstndb

Overview

Root directory has 97 .go files all in package main (~40K LOC). Project config (Makefile, go.mod, README, etc.) and Go source are mixed together, making navigation difficult.

Goal: Reduce root .go files to just main.go, move core code to internal/mycli/, then incrementally extract independent subsystems into focused sub-packages.

Phases

Phase 1: Move core to internal/mycli/

Move all Go sources except main.go to internal/mycli/ package. Root main.go becomes a thin wrapper calling mycli.Main().

  • Root .go files: 97 → 1
  • go install path unchanged (zero user impact)
  • goreleaser binary name unchanged

Phase 2: Extract independent sub-packages

Extract files with zero or minimal internal dependencies into focused sub-packages under internal/mycli/:

Target package Files Dependencies
internal/mycli/stream/ StreamManager (~5 files) pure stdlib + golang.org/x/term
internal/mycli/metrics/ ExecutionMetrics (~2 files) pure stdlib
internal/mycli/filesafety/ file_safety (~2 files) pure stdlib
internal/mycli/sysvar/ VarHandler, VarErrors (~4 files) pure stdlib

Effect: internal/mycli/ ~96 → ~83 files + 4 focused packages

Phase 3: Extract formatters via interface boundary

Define a minimal FormatConfig struct to decouple formatters from *Result and *systemVariables direct references, then extract to sub-package.

Effect: internal/mycli/ ~83 → ~75 files

Phase 4: Statement/Session separation (future consideration)

Would require a SessionExecutor interface. Session has ~30+ methods, so interface bloat risk is high. May be better addressed through file naming conventions rather than package separation.

Non-goals

  • enums/ stays at root (no change needed)
  • internal/proto*/ stays as-is

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions