简体   繁体   中英

What does the “imports on/off” switch do in golang tour?

I'm following the tutorial in https://tour.golang.org/

There are some options on the top right corner of the interactive window.

Golang 游览交互窗口选项

Syntax On is obvious which enables/disables syntax highlighting of the code inside the window.

The other one, Imports On , which I tried to switch on/off and run the code but it doesn't seem to make a difference.

What does this option do exactly?

Imports On/Off enables or disables goimports .

To test out an example, remove (or add, or modify) any of the import lines in one of the examples, then click Format . This will automatically add/remove imports based on the packages used in the code.

goimports is very convenient to have as a save hook in your editor to automatically set imports for you (and cleanup, which is something that can easily be forgotten).

automatically imports the package you have mentioned when you hit format

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM