DEV Community


VirtualBox for Learning a New Language

serverlessgolang profile image serverlessgolang Originally published at ・7 min read

Image of Mac OS X asking when to install updates

I always feel bad that my future self is gonna have to deal with this someday.

Why? This Helped Me Improve, It Might Be Helpful For You

  • Today, I can install a new programming language, in the future, this will be out of date, forcing me to upgrade 'something' on my system.
  • This has not always gone too well for me, exspecially if the amount of time is long between when I last worked on a given project.
  • Worse, probably subconsciously, the biggest reason I always click on 'remind me tomorrow' is because I know that when I upgrade my MacOS that this has a more than usual chance to mess something up on my machine which then prevents me from building or working on whatever project I'm working on. This has happened frequently enough, that I'm pretty sure I'm way, way behind on OS updates. I think one of my Mac's still have Yosemite as it's background. Whatever.

Ok - so, this causes me some pain initially, but my hope is that it will save me some pain in the future. This is very unlike me, which makes me think that this problem is actually worse than I'm imagining it to be. Oh well, here we go.

What Are The Steps?

Alt Text

The Five Steps to Setting up VirtualBox

Step 1. First step is to get VirtualBox installed. This software will allow you to start and run virtual machines. I don't really have a good description of what VirtualBox 'actually' does, but I think of it as this piece of software that sits between my machine and the virtual machines that I want to create and manages when they start, shutdown, etc.

Step 2. Get a the .iso distribution of Ubuntu 20. I just picked Ubuntu. I've heard about it, but honestly I'm not an expert here, so I kinda just went with what was familiar. Another choice that I've used is CentOS. I think both could work, but this article will focus on Ubuntu.

Step 3. This looks like it could be complex, but setting up the Linux distribution is actually kinda straightforward, I pretty much utilize all of the default steps and choices / options. I do make sure to check off the box about installing an SSH server, this is important and useful for later on.

The steps are pretty easy:

  • click on 'new', give the OS a name, I usually use something like 'ubuntu_test_golang", (using the name ubuntu will automatically switch the type to 'Linux'.
  • Take the default on the Memory size
  • opt to create a virtual hard disk now
  • choose to create a VDI, dynamically allocated and 10 GB is fine.

Now, we need to install the new OS on this VM:

  • Click Start and you'll need to find the .iso file you downloaded before
  • This'll probably take a little bit of time, you'll see a bunch of text scrolling by on the screen and then you'll be presented with a choice for your language.
  • One thing that always catches me up is when it asks (x) Use an entire disk - this is fine, it means to use the entire virtual disk that has been created.
  • You'll have to choose a name for the compurer as well as your own username and password. Important, when it asks if you want to install an SSH Server - Select Yes.

Step 4. So now you can boot up a fresh install of Linux - the best thing about this entire OS is that, in a heartbeat, you can delete it. If something gets screwed up in an installation where you have no freakin clue where files are copied to ... all good, delete and start from scratch. No one remembers any more but this is how we used to play video games and to prevent the Apple II from saving that our beloved character had died, we switch off the computer when we started to see the red light on the floppy disk drive come on - good times.

There is just one quick trick that we need to enable. We need to tell our computer how it should communicate with the new virtual machine. To do this we need to head into the settings and into networking. Were going to configure one port on our Host machine to automatically forward information to a port on the Guest machine. It's crazy easy: click on Settings >> Network >> Advanced (this has the blue triangle next to it) >> Port Forwarding. There is a small icon on the right, click to add, for Host port, I chose 3044, for Guest port, I chose 22. Here is a quick Video of the process:

video link

Step 5. Now, this is where things won't be as nice as they were before. You are probably used to having something nice like VS Code or otherwise to work in. In this approach, you kinda lose out on that, which is a bit of detractor, but there are always tradeoffs, so getting used to them isnt' the worst thing.

How Can I Use This?

Open up a terminal and what we are going to do is ssh into the machine that we just set up. We'll use the command

$ ssh username@localhost -p 3022

and the -p flag to make sure that we are hitting against the right port - it'll ask us for our password (we entered this during the installation) and away we go.

What I like about this approach is that it gives us the familiarity of ssh'ing into a remote computer. This is a skill that we'll likely need sometime in the future. Whether or not our server is hosted in AWS on an EC2 instance or colocated somewhere ... there's a good chance that at some point we'll need to work with it and doing that over ssh is just how it'll need to get done. Getting familiar with how to edit files on a remote machine is a good skill and one that, if we practice, yes, might make us slower now, but we'll be very, very glad about it later on when we have something actually live out there for the world to see and we need to fix or change something.

By the way, we often need to fix or change something under less-then-optimal circumstances, e.g. there is a lot of time pressure and stress. Practicing now will allow us to do that when there aren't any time pressures, we can take our time and actually understand what we are doing.

Hello, World! with Go Lang

Now that you have a completely brand new OS, you can install whatever programming language you want, whatever version you want. For us, let's install Go Lang. The instructions here are crazy simple ...

  • Download Go Lang from the distribution using the wget tool
$> wget
  • Unpack the files:
$> tar -C /usr/local -xzf go1.15.2.linux-amd64.tar.gz
  • Update your PATH by modifying $HOME/.profile:
export PATH=$PATH:/usr/local/go/bin
  • Validate with:
$> go version

Now, create a new file with the following Hello, World! program:

package main

import "fmt"

func main() {
  fmt.Println("Hello, World!")

and to run it from within VIM:

:! go run hello_world.go

and to rerun the same command:



Bare Minimum VIM Settings

So, here is where I may be introducing some heartache. I wanted to learn how to use Vim for quite some time now. Here is where I start to teach myself how to use vim in the most minimal of ways. Honestly, I don't want to spend 2 hours getting some ridiculous plugin that looks really cool in some video to work. I just want to create stuff. So, for me, there are literally three vim options that I use and here they are:

              :set softtabstop=2
              :set autoexpand
              :set expandtab
              :set linebreak

That's it. I know, that might not be your game, but this time around I want to focus on my productivity and I've found that researching all manner of different environment plugins and things that should 'help' me have, in reality, only distracted me from creating things I originally set out to create.

By the way, I've also taken that approach with this blog, I wrote the damn HTML page myself, you know what? I actually finished it! That, for me is totall success. In the past, I might've spent 2 hours or 2 weeks getting everything installed the way I wanted it. Now, this is all my fault, mind you. I would install one seemingly easy to use plugin, only to see in the documenation that the authored used some other plugin that looked cool or that this one depended on and down the effing rabit hole I would go. No more. I just want to write and create and so I'm limitiing myself to NOT do the things that prevent me from being productive.

I know, this isn't for everyone, but if you've ever had:

  • a fear of installing the latest Mac OS updates
  • A breaking change in your environment that was a dependency nightmare to fix
  • Had to ssh into your actual live server to fix something important and quickly
  • Spend (I would say wasted) too much time configuring a plugin

then this article might be helpful for you. Yeah, it isn't all too sexy .. and pretty much no one is ever going to watch a video of what I'm doign and ask the question ... oooh that looks cool, how'd you do that. But, I have completed writing THIS ARTICLE which is something that I've been trying, and failing, to do for a long time now.

I'm writing a series of articles specifically about how to build a SaaS app using Go, AWS services such as Lambda and DynamoDB. I'll be covering how to authenticate, signin, signup, email confirmation, password resets, and credit card integration. Please subscribe to my newsletter at

Discussion (0)

Editor guide