Tech Tips

  1. Uncategorized
  2. 391 view

[Go]Install Go language on ubuntu

Hello World

定番のHello Worldを作成してみる。 まず、プロジェクトを作成する。
$mkdir -p $GOPATH/src/example/hello
いよいよ、ソースの作成だ。
package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}
かなりシンプル。
次に実行。
$pwd
$HOME/go
$go install example/hello
$ls
bin src
$ls bin
hello
$bin/hello
Hello, World!
出来た!

Install

We can use apt to install go.
$ sudo apt-get install golang-go

Test Program

Making Workspace

It’s easy with managing to make work space . You can use only mkdir command to make workspace.
$mkdir ~/go
And then setting workspace.
$vim ~/.bashrc
export GOPATH=$HOME/go
$source ~/.bashrc

Hello World

Try to make hello world program. At first let’s make project.
$mkdir -p $GOPATH/src/example/hello
Finally programming.
package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}
So simple. And then run.
$pwd
$HOME/go
$go install example/hello
$ls
bin src
$ls bin
hello
$bin/hello
Hello, World!
Good!

Uncategorized recent post

  1. Run Amazon FreeRTOS on M5Stack Core2 for AWS …

  2. Udacity Self-Driving Car Engineer Nanodegree …

  3. Install sbt 1.0.0 and run sample template

  4. Visualization of Neural Network and its Train…

  5. [Machine Learning]Created docker image includ…

関連記事

PAGE TOP