blob: fe529f56eb016732af3b44470ed5906320912333 [file] [log] [blame] [view]
Andrew Gerrand5bc444d2014-12-10 11:35:11 +11001# Introduction
Ali Yousefi Sabzevar00bfb642019-02-18 13:54:13 +01002#### EDIT: You don't need to compile from source in Developer mode, you can just use the [Chromebrew](https://github.com/skycocker/chromebrew)-provided version.
James Larrowefe2fdd92019-02-10 18:34:45 -05003#### EDIT2: If your Chromebook is relatively new, you can enable the Linux VM now built into ChromeOS to install Go without developer mode. Follow the steps from the following Google Support article to enable this feature- https://support.google.com/chromebook/answer/9145439. This has been tested on a Samsung Chromebook Plus on version 71.0.3578.127. If this feature is not available for you, you will need to enable Developer Mode.
gidoBOSSftw5731f88098c2018-08-09 04:55:47 -04004
James Larrowe63f5ac72019-02-10 18:34:29 -05005This tutorial will show you how to install, build, and run Go on Chrome OS.
6Please note this has only been tested on a 64GB LTE Pixel, however it should work on other Chromebooks. Note that enabling developer mode reduces the security guarantees offered by Chrome OS.
Andrew Gerrand5bc444d2014-12-10 11:35:11 +11007
8# Install Go
James Larrowe63f5ac72019-02-10 18:34:29 -05009First download the latest version of Go for Linux from the [Go Downloads page](http://golang.org/dl/).
James Larrowe1dd6c332019-02-10 18:35:54 -050010After that, open a shell by hitting (CTRL+ALT+T) and typing in `shell` then hit enter. Then extract it using the following command (when replacing `< Go Linux package >` with the name of the file you downloaded):
Dave Day0d6986a2014-12-10 15:02:18 +110011
12```
James Larrowe63f5ac72019-02-10 18:34:29 -050013sudo tar xpvf ~/Downloads/< Go Linux package > -C /usr/local
Dave Day0d6986a2014-12-10 15:02:18 +110014```
15
James Larrowe1dd6c332019-02-10 18:35:54 -050016Go should now be installed you can test this by typing `/usr/local/go/bin/go`. If it installed correctly, you should see the Go help prompt. Go is now installed.
Andrew Gerrand5bc444d2014-12-10 11:35:11 +110017
18# Create a Workspace
James Larrowe63f5ac72019-02-10 18:34:29 -050019To keep this simple just create a folder called `/usr/local/go/work`. Also, create a folder called `src` inside `/usr/local/go`.
Andrew Gerrand5bc444d2014-12-10 11:35:11 +110020
James Larrowe63f5ac72019-02-10 18:34:29 -050021# Set PATH
22Add the following to `~/.bashrc`:
Andrew Gerrand5bc444d2014-12-10 11:35:11 +110023```
James Larrowe63f5ac72019-02-10 18:34:29 -050024export GOPATH="/usr/local/go/work"
25export PATH="${PATH}:/usr/local/go/bin:${GOPATH}/bin"
Andrew Gerrand5bc444d2014-12-10 11:35:11 +110026```
James Larrowe63f5ac72019-02-10 18:34:29 -050027This will allow you to run your Go programs in your shell.
Andrew Gerrand5bc444d2014-12-10 11:35:11 +110028
James Larrowe63f5ac72019-02-10 18:34:29 -050029# Test if it worked
30First create a folder inside of your `/usr/local/go/src` folder. After that create a file in your folder called `hello.go` with the following in it:
Dave Day0d6986a2014-12-10 15:02:18 +110031```go
Andrew Gerrand5bc444d2014-12-10 11:35:11 +110032package main
33
34import "fmt"
35
36func main() {
James Larrowe63f5ac72019-02-10 18:34:29 -050037 fmt.Printf("Hello, Chrome OS!\n")
Dave Day0d6986a2014-12-10 15:02:18 +110038}
James Larrowe63f5ac72019-02-10 18:34:29 -050039```
James Larrowe1dd6c332019-02-10 18:35:54 -050040Now, run `go install hello`. Then, run `${GOPATH}/bin/hello` and you should see `Hello, Chrome OS!`.
James Larrowe63f5ac72019-02-10 18:34:29 -050041***
42
43# Reporting bugs
44Please go to [Issues](https://github.com/golang/go/issues) to report any issues you have.