In Golang Posted May 17th, 2021
Golang has been popular lately as one of the easiest and powerful programming languages. While education regarding the language, its modules and best practises in the language is really important, it is also equally important to teach the proper use of the great tools for improving productivity. We are talking about Integrated Development Environments.
Integrated Development Environments are there for the single reason — to make your development time more productive and let you build reliable software fastly. Many people use IDEs but unfortunately, almost no one uses it for all their glory.
In this article, let us discuss 5 tips that you can use with either IntelliJ or Goland (both are developed by the same company Jetbrains!) to improve productivity while developing applications in Golang.
Everfound yourself in the need of writing to multiple places at the same time? Instead of going through each place manually and repeatedly typing, you can use multiple cursor feature of the IDE.
Here is how it works: Hold Alt + Shift (Option + Shift on Mac) and click on a place where you need an additional cursor and that’s it, you get a new cursor. You can do this for up to your requirement and after the work is over, just press escape and you will be left with the first cursors.
You can also have multiple selections of code, which might be adjacent or not at once! This gives you a lot of power in editing.
The same key combination you used for setting multiple cursors can also be used for multiple selections! Just hold the key combination and use your mouse as you would do normally to select multiple sections of text. Then, you can paste them at different cursor positions just by paste command.
There is another multiple selection feature in IntelliJ idea. In that, you can have multiple selections based on a word: just select a certain word and use Alt + J (Option + J for mac) to move forward and select symbols containing the same word and press Alt (Option) + Shift + J to go for backwards selection.
You can use live templates to insert certain common constructs which can include many things like conditions, declarations, loops or print statements right into your code. This saves a lot of development time.
To use it, just type the appropriate template abbreviation and press the “tab” button. Then, keep on pressing tap for jumping through one variable to another. You can also use Shift + tab for moving to the previous variable.
There are a lot of built in live templates for you to use. Some include forr for a for range loop and err for easy error handling. There are three kinds of live templates: single templates (only plaintext), parameterized templates (that have user input, for variables) and surround templates (wrap specified blocks with certain text).
You can create your live templates and inorder to access them quickly, just use the keyboard combination ctrl (or) command + j to bring up all available templates that are appropriate for the context.
Testing is very important for software development and you would be doing a lot of unit tests. For that, writing test cases for each unit might take a lot of time. With the handy Ctrl + n command, you can easily generate a test case for the unit you want! After hitting the command, you would get the Generate menu, from which you can select either test for function or test for file.
If you do not have a _test.go file, then the IDE would generate that for you along with the outline of table tests for the functions of your code!
Clipboard is a very handy feature for many things while working with computers, even for development of code. Here, we would like you to see two power options you have with clipboards on the IntelliJ IDEA iDE : comparing with clipboard and pasting from history.
IntelliJ idea provides diff views for different entities like code, revisions and also images! For comparing content with clipboard, just select the particular entity and then, choose the Compare with clipboard command in the view.
The IDE tracks everything you store in the clipboard. Instead of pressing ctrl(cmd) + v, if you press ctrl(cmd) + shift + v, you would paste just one of the previously copied items instead of everything in the clipboard!
So those are out tip 5 tips for improving your speed with Golang. Properly using IDE can be an art in itself and it might take a lot of time to get accustomed to the full features of the IDE. So, practise a lot!
Do you have a Project we can assist you with?
Use our Project Planner
We believe in integrating business and technology to greater heights through innovation and sheer creativity.
Discover Codism by reaching us at our offices in
New Jersey (USA)
230 N Maple Avenue Suite B-1-616 Marlton, NJ 08053 United States.
Phone: (973) 814-2525
Fax: (856) 988-7980