golang_install.sh 705 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env bash
  2. # linux下golang环境搭建自动脚本 by 蘭雅sRGB
  3. # 下载释放go语言安装包
  4. go_tar_gz="go1.11.2.linux-amd64.tar.gz"
  5. go_url="https://dl.google.com/go/${go_tar_gz}"
  6. wget --no-check-certificate -O ${go_tar_gz} ${go_url}
  7. tar -xvf ${go_tar_gz}
  8. rm ${go_tar_gz}
  9. # go语言 添加环境变量
  10. cat <<EOF >> ~/.profile
  11. export GOROOT=/root/go
  12. export GOPATH=/root/go/work
  13. export PATH=$PATH:/root/go/bin
  14. EOF
  15. source ~/.profile
  16. mkdir -p /root/go/work
  17. # 测试go语言安装
  18. mkdir -p ~/helloworld
  19. cd ~/helloworld
  20. cat <<EOF >> helloworld.go
  21. // Test that we can do page 1 of the C book.
  22. package main
  23. func main() {
  24. print("hello, world\n")
  25. }
  26. EOF
  27. go build
  28. ./helloworld