Skip to content

Conversation

@dolfje
Copy link

@dolfje dolfje commented Oct 5, 2021

No description provided.

@muesli
Copy link
Owner

muesli commented Oct 5, 2021

Thanks for this! General recommendation when getting started with Go: make sure your IDE/editor uses gofmt (comes with Go!) to automatically format the code for you. This fixes several indentation issues for you and makes coding in Go a lot more fun, promised. Check out vim-go for vim or the Go extension for VSCode! Using another editor? Let me know and I'll point you in the right direction.

Alternatively you can also run this manually on the command line:

gofmt -w *.go

deck.go Outdated
select {
case event := <-watcher.Events:
if currentDeck == path {
fmt.Println("Change: %s: %s", event.Op, event.Name)
Copy link
Owner

Choose a reason for hiding this comment

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

Careful, Println doesn't expect formatting directives like %s. You'll have to use Printf here and finish it with a \n for a newline.

d.Widgets = append(d.Widgets, w)
}

watcher, err := fsnotify.NewWatcher()
Copy link
Owner

Choose a reason for hiding this comment

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

Make sure to check the error assignments for this line and the one below. Two options here:

  1. Consider this feature optional, and if an error occurs while setting up the file-watcher, we continue without config monitoring
  2. Propagate the error, so we can display an error to the user:
if err != nil {
    return nil, err
}

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants