Playground imports x

On the Go playground there are five buttons in the toolbar across the top. Clicking on ‘Imports’ causes an X to appear in the check box. Other than that it doesn’t seem to have any effect. What is it supposed to do?

When checked, your imports are auto fixed (missing imports added, unnecessary ones removed) when you tap Format.

1 Like

Checking the goimports box means the code will be run through goimports, instead of the normal gofmt.

goimports does exactly what gofmt does, but also adds or removes any imports needed/not needed, like @calmh said. :slight_smile:

OK, but how do you know that? I looked for an explanation but I didn’t find one. Obviously I wasn’t looking in the right place, which begs the question, what is the right place?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.