Production Level Knowledge & Tips

  1. 未分類
  2. 5 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!

未分類 recent post

  1. Install sbt 1.0.0 and run sample template

  2. Visualization of Neural Network and its Train…

  3. [Machine Learning]Created docker image includ…

  4. [Node.js]How to write batch script with Node.…

  5. [Hive]Get top n items for each category

関連記事

PAGE TOP