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/