If you are a Python developer, you probably heard of Google’s free online cloud-based Jupyter notebook environment known as Google Colab (https://colab.research.google.com/).
Google Colab is a service that allows you to write and execute Python in your browser, with zero configuration required and free access to GPUs. It’s a great service and if you are like me it’s the perfect place to store both your notes and your code. However, it does have a few limitations. One of these limitations is the fact that it is primarily meant for Python developers and it does not support other programming languages like Go.
So, how do we run our Golang code? Well, the answer is, we need to install the Go kernel for Jupyter and refresh the page. Here are the steps to do that.
Open the Golang Notebook example at https://colab.research.google.com/drive/1aoHKfyD2WT03Sjm0hHIdTPxa8z_ZiXly?usp=sharing.
Save a copy of the document to your Google Drive.
Once the document is in your Google Drive, open the document and run the first code cell, using the Python runtime.
This operation may take a few minutes.
After you’ve run the first code cell, refresh the page to use the Go kernel (gophernotes).
At this point, you can test that everything went well by running the Golang cells at the bottom of the page.
And there you have it. This is how you run Golang code in Google Colab. If you have any questions, please do not hesitate to leave a comment in the section down below.