LoginSignup
3
5

More than 5 years have passed since last update.

Go言語のインストール

Last updated at Posted at 2016-02-18

vagrantのboxに追加

vagrant box add https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box --name centos7
vagrant init
vi Vagrantfile

localのdir
/Users/test/workspace/golang

仮想マシンのdir
/home/vagrant/golang

Vagrant.configure(2) do |config|
  config.vm.define "host" do |node|
    node.vm.box = "centos7"
    node.vm.hostname = "golang"
    node.vm.network :private_network, ip: "192.168.43.55"
    node.vm.synced_folder "/Users/test/workspace/golang", "/home/vagrant/golang", mount_options: ['dmode=777','fmode=777']
  end 
end
vagrant up
vagrant ssh

仮想マシン上
パスワードはvagrant

sudo yum instlall golang

Hello World

hello.go
package main
import "fmt"

func main() {
  fmt.Println("hello world")
}

動かし方

go run hello.go

もしくは

go build hello.go 
./hello

Go言語をブラウザで試したい時
https://play.golang.org/

Go言語のドキュメント
https://golang.org/doc/

3
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
5