charmbracelet / kancli

A tutorial for building a command line kanban board in Go
171 stars 30 forks source link

Modifying enum name breaks code functionality. #4

Closed zerovirus123 closed 1 year ago

zerovirus123 commented 1 year ago

I am refactoring the tutorial KanCLI project, placing the type definitions in a separate package. My goal is to refactor the Model and Form structs into separate packages. At the same time, there is a name clash between the Model and Form structs and a predefined Enum.

const (
    Model Status = iota
    Form
)

I then renamed the Enum values.

const (
    ModelEnum Status = iota
    FormEnum
)

But that broke the task addition feature.

Here is the repo before the enum modification.

Here is the repo after the enum modification.

muesli commented 1 year ago

When you say "broke", what does that exactly mean?

One thing that's definitely broken in your repository is the relative import of the typedef package. You need to use canonical import paths, e.g. import github.com/zerovirus123/cli_kanban/typedef.

zerovirus123 commented 1 year ago

@muesli The new tasks no longer shows up in the columns.

bashbunni commented 1 year ago

Ah so, you changed NewTask to return a *Task instead of a Task (which is fine). So all you need to do to fix this is to make sure that the case task.Task in your model.go is changed to case *task.Task. Made that change on my local copy and have it adding new tasks to the lists without issue. Lmk if you have any more questions!

zerovirus123 commented 1 year ago

Resolved the issue on my side. Thanks for the follow up!

On Fri, Oct 28, 2022 at 6:29 AM bashbunni @.***> wrote:

Closed #4 https://github.com/charmbracelet/kancli/issues/4 as completed.

— Reply to this email directly, view it on GitHub https://github.com/charmbracelet/kancli/issues/4#event-7686575464, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHXFN4JZMGH7EFUGQFMTF3WFMF4JANCNFSM6AAAAAARJC2J4U . You are receiving this because you authored the thread.Message ID: @.***>