Skip to content

chore: Refactor: extract business logic to internal packages and upda…#6

Open
alexbednarczyk wants to merge 2 commits intomainfrom
gemini-3-pro-preview
Open

chore: Refactor: extract business logic to internal packages and upda…#6
alexbednarczyk wants to merge 2 commits intomainfrom
gemini-3-pro-preview

Conversation

@alexbednarczyk
Copy link
Copy Markdown
Owner

Summary of Changes

  1. Dependencies & Environment:

    • Go Version: Updated go.mod to Go 1.24.0 (from 1.20).
    • Dependencies: Updated all dependencies to their latest versions, including cobra, viper, and spg.
  2. Architecture Refactoring:

    • Separation of Concerns: Adopting best practices, I moved business logic out of the cmd/ directory (which should only
      handle CLI interaction) into a new internal/ directory.
    • New Packages: Created the following internal packages:
      • internal/count: Logic for the counting command.
      • internal/date: Logic for date command execution (abstracting OS commands).
      • internal/environment: Logic for environment variable handling and formatting.
      • internal/password: Logic for password/pin generation.
      • internal/config: Logic for configuration retrieval.
      • internal/version: Centralized version definition.
  3. Code Quality & Cleanup:

    • Linting: Ran go vet and fixed issues (e.g., unused variables, structure initialization).
    • Formatting: Applied go fmt and goimports to ensure standard Go styling.
    • Dead Code Removal: Removed unused variables like theDate map in cmd/date.go and the local environment struct in
      cmd/environment.go.
  4. Testing:

    • Unit Tests: Added unit tests for the extracted logic in:
      • internal/count
      • internal/environment
      • internal/password
    • Verification: Verified that go test ./... passes and the project builds successfully with go build.

The codebase is now cleaner, modular, easier to test, and uses modern Go versions and dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant