Skip to content

playground: goimports can delete what user has typed #6947

@cznic

Description

@cznic
1.
Imagine yourself coming to play.golang.org for the first time.

2.
Trying to experiment with something from package time, you edit the imports to include
"time": http://play.golang.org/p/CZpUiGyVho

3.
Noticing the "Format" button, you press it.

What is the expected output?
http://play.golang.org/p/-oPFe90KmG


What do you see instead?
http://play.golang.org/p/duRF5gXJEP


Please provide any additional information below.

The intent of goimports is good and everything - but only in the hands of a well
informed hacker who welcomes what goimports do (I don't). For a newbie coming to
playground, it's inexplicable why the "Format" button "eats" her
edits so far.

- There's no information and/or warning about this behavior available to the
playground's user.

- Moreover, "Format" is probably rightfully expected to change only the white
space of a program, not its semantics.

I have missed the change on the dev-list and was thus genuinely surprised the same as
any dev-list non reader could/would possibly be.

Suggestions:

- Remove the goimports functionality.
- Or make it a standalone button.
- Or disable/enable goimports by a check box.
- Avoid the confusion by providing a prominently visible information that
"Format" will remove your unused imports (and insert missing used ones, but
that's a welcome "surprise").

----
I personally avoid any automatic source changing "on save" for good (for me)
reasons. It's just my personal preference and no one is pushing such thing on me, so no
problem; neither for me nor anyone else. However, at the playground we are now forcing
such thing on the playground users in a potentially quite confusing way, which I believe
is a good intended mistake.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions