Daniela Petruzalek

@danielapetruzalek

Getting Started with Go Development in the new Google Pixelbook

A couple of days ago I finally got the chance to acquire the latest Google Pixelbook. To be honest, I wasn’t planning on getting one as I had the idea that Chromebooks are limited to internet browsing and end-user applications, and what I expect from a computer, from a developer point of view, is to have way more control.

This is the first article I’ve written with the new Google Pixelbook.

I had a Dell with Windows 10 at home and I got a MacBook Pro at my work, so why bothering getting another piece of hardware? What made me change my mind was the fact that as one of the perks of the Google Developer Experts (GDE) program we got a very nice discount coupon that made the deal very attractive, making it really hard to miss.

I don’t like to accumulate a lot of hardware: we have this rule at home that there can’t be more notebooks than cats, and the cat count here is currently two, so buying the Pixelbook would mean getting rid of the Dell (getting a new cat was not an option at the moment).

Looking from the configuration aspect, the Pixelbook packs a very decent hardware, but it was inferior to the other notebook. What made me chose the Pixelbook was the fact that I was very unsatisfied with the Dell’s keyboard and touchpad. I was expecting Pixelbook’s quality to be closer to a MacBook than what we expect from other brands, especially considering Pixelbook’s price range without the discount.

Also, before committing to it I had to be sure I would still be able to use the Pixelbook for my basic needs, which nowadays include making presentations and writing code in VS Code.

I had no doubt I could do presentations, but to code I was not sure, so I’ve talked to some other GDEs (thanks Loiane!) and I found that it was possible by running some kind of VM. I was intrigued, but I chose to take a shot.

First impressions

The overall quality of the materials is pretty impressive. I would say it is at least on par with my MacBook Pro, or maybe better. I love the feeling of the keyboard, the layout and the touch is really comfortable.

I did find strange the absence of a Caps Lock key though. It took me a while to understand that the Caps Lock key was replaced by the Search key, and in order to enable Caps Lock functionality you must press the Alt+Search key. To exit Caps Lock mode you can either use this combination again or just press the Shift key.

The touchpad has a nice feeling to it as well, but I feel it’s not so responsive as the MacBook one, especially in regards to gestures. For the regular “mouse” needs it works just fine. Also, the first thing I did was to enable natural scrolling. Having that reversed was really confusing, so I decided to continue using Mac’s standard.

The screen is really nice looking and has a very decent resolution. I’m not an expert so I’ll skip the specifications, but I’m very satisfied on how high resolution movies run. The screen is also a touch screen, and you can flip it 360 degrees to enable a “tablet mode”. It’s the first time I have a piece of hardware like that and so far I’m liking the experience.

What feels most strange is booting directly to the Chrome browser. The boot is really fast, but I can’t help but feel a little limited by it. “Where is the explorer/finder” was my first though. Later I’ve learned there’s an app called “Files”. :)

Fun fact… I don’t know how many of you remember, but back in the 90’s Microsoft was sued for trying to merge the Internet Explorer with Windows. Back then it was considered a treat to the internet browser market. Now two decades later we have the exact same thing, but with Google brand on it.

I must say, it’s strange at first but I’m getting used very quickly.

The only downside so far is that I had two hangs already in less than 48 hours using it. One was during a firmware update and the other during video playback. I hope those were singular cases.

In regards to my requirements, for making presentations I’m already using Google Slides, so that’s covered. I also have a subscription of Office 365 and I can download all their apps from Google Play Store, so even if I want to stick with Power Point I’m still in the game.

What about coding? Now is the time to get the hands dirty.

Configuring the Pixelbook to run Linux

The first step to enable installing Linux applications (like VS Code) is to enable the Linux mode. Luckily it is a really easy process.

First step is to enable the developer channel (not developer mode!).

In order to do that, go to the Settings page (press the triple bar key on the keyboard or click on the clock, and then click on the gear icon), click on the triple bar icon and chose the About Chrome OS item on the menu.

Click on the gear icon to open the Settings page.
Then click on the triple bar icon at the upper left corner to expand the menu.
Click in “About Chrome OS”

That will bring to the screen the about page. Click on “detailed build information” to open another pop up. Look for the “Change channel” button and click on it, then chose the “developer — unstable” channel.

Click in “Detailed build information” …
… and on “Channel” click “Change channel” and chose “Developer — unstable”.

This will start a download that may take a while to finish. Once it’s finished it will ask you for a restart. Do it now.

By the way, this is when I got my first hang: on the reboot it got stuck into an “updating touchpad firmware” message. It said it was supposed to last 2 minutes, but I’ve awaited for one hour before deciding to force a reboot. It booted normally afterwards.

Now that you are in developer channel open the page chrome://flags/#enable-experimental-crostini-ui on your browser and enable it. (Note: You may or may not need a reboot afterwards, in my case I enabled this flag before enabling the developer channel so I’m not sure.)

Once you are in developer channel you should be able to see the “Linux (Beta)” item on the Settings page:

Linux (Beta) should appear between the Search and Assistant and Google Play Store settings.

Enable it to activate the Terminal. You are good to go!

Installing VS Code

Run the Terminal by pressing the Search key and typing “term”. The terminal icon should be the first one:

The following instructions I’ve got from a post on Reddit, put I’ll place then here for convenience.

Run on the terminal the following commands:

$ sudo apt-get update
$ sudo apt-get install x11-apps

Then test it by running xclock. A small clock should appear on screen. Close it.

Next run:

$ sudo apt-get install -y gpg
$ curl https://packages.microsoft.com/keys/microsoft.asc | gpg - dearmor > microsoft.gpg
$ sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
$ sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
$ sudo apt-get update
$ sudo apt-get install -y code

The original article mentions the need to install manually curl, libxss1 and libasound2, but in my case they were already installed. In case you run into a different scenario, you may try (re)installing them.

VS Code is now installed. You may run it from the command line with the code command. You may also launch it by the Search key, typing code in the search bar or looking for the application launcher on the expanded list.

Installing Go

My main purpose for using VS Code is writing Go code, so I was eager to install it on the Pixelbook.

I’ve used the instructions available on golang.org for installing Go on Linux. First I downloaded the Linux binaries. You may notice when you click download that with Linux (beta) enabled there is a new “Linux files” download target.

After downloading it, just decompress the package running the following command on the terminal:

tar -C /usr/local -xzf go1.10.3.linux-amd64.tar.gz

You will also need to update your path to add the go binaries. Edit .profile and add the following snippet at the end of the file. Don’t forget to save! :)

# add golang to PATH
if [ -d "/usr/local/go/bin" ] ; then
PATH="$PATH:/usr/local/go/bin"
fi

You may use vi or even code to do so:

code ~/.profile

Next you should reload the .profile by either exiting and starting a new terminal or by running:

source ~/.profile

Type go . You should see the Go command line help. All set!

Trying an example

It was more or less surprising that git was already installed, but I wanted to try a smaller example before getting to some serious development. Why not writing a “hello world” application?

At the terminal:

$ mkdir -p ~/go/src/hello
$ cd ~/go/src/hello
$ code .

Create a main.go file and put the following content:

package main
import "fmt"
func main() {
fmt.Println("Hello Pixelbook!")
}

Now save and run it with either:

go run main.go

Or:

go build
./hello

You should see something like:

Please note that I’m using the VS Code terminal to run (Ctrl+`), but you could just run it at the regular terminal as well.

Next I’ll try writing some code and pushing it to Github, but I don’t expect to encounter any kind of trouble, as everything so far seems to be running pretty smoothly. What about you, what are you planning to do with your Pixelbook?

UPDATE: I’ve written a follow up article on how to contribute to Go using the Pixelbook. If you liked this article you may want to check it out.

More by Daniela Petruzalek

Topics of interest

More Related Stories