Skip to content

refactor: use type switch for checking color type#43

Merged
Delta456 merged 3 commits intobox-cli-maker:masterfrom
davesaah:master
Dec 13, 2023
Merged

refactor: use type switch for checking color type#43
Delta456 merged 3 commits intobox-cli-maker:masterfrom
davesaah:master

Conversation

@davesaah
Copy link
Copy Markdown
Contributor

@davesaah davesaah commented Dec 11, 2023

Addresses #35

Changes

  • Break if statements for color type checking into switch cases.

    switch v := b.TitleColor.(type) {
        case string:
        ...
        case uint:
        ...
        case [3]uint:
        ...
        default:
        ...
    }
  • Replace hard coded boolean expression with a variable.

    titleContainsNewLine := strings.Contains(title, "\n")

@davesaah davesaah requested a review from Delta456 as a code owner December 11, 2023 21:07
Copy link
Copy Markdown
Collaborator

@Delta456 Delta456 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I appreciate it. It would help if you also changed the functions obtainContentColor and obtainBoxColor.

@davesaah
Copy link
Copy Markdown
Contributor Author

Alright, noted ✅️

@davesaah
Copy link
Copy Markdown
Contributor Author

  • refactor obtainContentColor
  • refactor obtainBoxColor

Copy link
Copy Markdown
Collaborator

@Delta456 Delta456 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work!

@Delta456 Delta456 merged commit 1ac023b into box-cli-maker:master Dec 13, 2023
Delta456 added a commit that referenced this pull request Jun 20, 2024
* Updated the dependencies in go.mod  (#40)

* updated dependencies

* removed the extra folder

* README.md: use simpler words (#41)

* all: use type switch for checking color type (#43)

---------

Co-authored-by: sanvi <[email protected]>
Co-authored-by: David Saah <[email protected]>
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.

2 participants