Sunday, June 28, 2020

IntelliJ Keymap


I started using IntelliJ recently. Here is the key map that can be useful:




References:
https://resources.jetbrains.com/storage/products/intellij-idea/docs/IntelliJIDEA_ReferenceCard.pdf

Setting up a Go project in Vscode

  

Here are the steps I followed to setup a Go project in Vscode:
1) Install Vscode Go plugin.
2) Create a project
3) I still had this error:
4) To fix this, I downloaded the go 1.15 separately.  
5) Set GOPATH - export PATH=$PATH:/usr/local/go/bin/go 

Even after this, I am still not able to run my go program directly from UI. I could only the go program from the terminal.

One of my friends who uses Vscode helped me run go programs from vscode. He suggested these additional steps:

1) Open settings in vscode

 


2) Search for "gopath" & open "settings.json"


 

3) Set goroot & gopath in this file

 


4) After this, I had to restart vscode. After restart, vscode threw some pop ups to install a few things & I proceeded with those:

 

Tools environment: GOPATH=/Users/babuneelam/Projects/GoProjects/go_path
Installing 1 tool at /Users/babuneelam/Projects/GoProjects/go_path/bin in module mode.
gopls  
Installing github.com/mdempsky/gocode SUCCEEDED
Installing github.com/uudashr/gopkgs/v2/cmd/gopkgs SUCCEEDED
Installing github.com/ramya-rao-a/go-outline SUCCEEDED
Installing golang.org/x/tools/gopls SUCCEEDED
All tools successfully installed. You are ready to Go :).
Installing github.com/acroca/go-symbols SUCCEEDED
Installing golang.org/x/tools/cmd/guru SUCCEEDED
Installing golang.org/x/tools/cmd/gorename SUCCEEDED
Installing github.com/cweill/gotests/... SUCCEEDED
Installing github.com/fatih/gomodifytags SUCCEEDED
Installing github.com/josharian/impl SUCCEEDED
Installing github.com/davidrjenni/reftools/cmd/fillstruct SUCCEEDED
Installing github.com/haya14busa/goplay/cmd/goplay SUCCEEDED
Installing github.com/godoctor/godoctor SUCCEEDED
Installing github.com/go-delve/delve/cmd/dlv SUCCEEDED
Installing github.com/stamblerre/gocode SUCCEEDED
Installing github.com/rogpeppe/godef SUCCEEDED
Installing github.com/sqs/goreturns SUCCEEDED
Installing golang.org/x/lint/golint SUCCEEDED
All tools successfully installed. You are ready to Go :).

Tools environment: GOPATH=/Users/babuneelam/Projects/GoProjects/go_path
Installing 1 tool at /Users/babuneelam/Projects/GoProjects/go_path/bin in module mode.
goimports
Installing golang.org/x/tools/cmd/goimports SUCCEEDED
All tools successfully installed. You are ready to Go :).

5) Run & Launch. We can also set breakpoints too now.


 

By setting up vscode, I could avoid paying for Goland/IntelliJ, atleasr for now :)

Hope this helps.



IntelliJ & Go Plugin

  

In the recent times, I have been using IntelliJ Ultimate edition at work and community edition on my personal laptop. 

Tried to create some sample go projects in my personal laptop for my own testing. I thought it would be quite an easy step to create a Go project in IntelliJ. Here are some things I tried:

1) Tried to look for a Go plugin in IntelliJ Plugins, couldn't find it. 
2) Downloaded Go plugin from IntelliJ Go Plugins and followed instructions as provided at "Install Plugins from disk". But, the installation threw these errors:



So, IntelliJ Community edition doesn't allow Go plugins. As per this article from Jetbrains:

it was always in the plan to have Go plugin functionality available as part of the GoLand IDE. If you want Go functionality combined with other technologies, then IntelliJ IDEA Ultimate is the right choice for you

Lack of this information wasted some time for me today. The cost for ultimate edition seems to $249 for individual use. 


Sunday, June 7, 2020

JShell Overview


JShell helps developers to quickly test java code snippets in an interactive shell. Many other languages (Python, ..) also have such interactive shells. Java introduced JShell in as part of JDK 9.

Here is a sample JShell session I tried:




I haven't read and tried everything thats possible in JShell, gave a cursory read of https://docs.oracle.com/javase/9/jshell/toc.htm. I felt this resource was quite useful and covers JShell capabilities reasonably.


References:
https://docs.oracle.com/javase/9/jshell/toc.htm
https://developers.redhat.com/blog/2017/10/03/use-jshell-command-line-tool-introduced-jdk-9/

Getting Started with Java in IntelliJ IDE


I have been using 
VSCode IDE a bit. However, my team at Salesforce uses IntelliJ IDE (Ultimate Edition). So, I decided to give it a try. Here are the steps to get started with a sample project (say, the usual "Hello World !!") in Java.


1) Install Java JDK for Mac: I think it was already installed earlier. So, didn't have to do this step in my case.


2) Install IntelliJ Community Edition: https://www.jetbrains.com/idea/download/#section=mac. I am using MAC. But, if your OS is different, choose the platform appropriately.


3) Install. Move IntelliJ to Applications folder. This created an icon like this in Mac's Launchpad:

                                                           










4) Create a new project in IntelliJ: 








I created and named my Project "HelloWorld". I think the project name should start with an upper case letter?




5) I then created a new class named "HelloWorld" and filled in a few lines of code (some of it getting auto-filled). 
When I clicked "Run", the program output "Hello World !!" on the console pane.







Hope this helps.

UA-48797665-1