golang_install.sh 665 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. mv go /usr/local/.
  9. rm ${go_tar_gz}
  10. # go语言 添加环境变量
  11. cat <<EOF >> /etc/profile
  12. export PATH="$PATH:/usr/local/go/bin"
  13. EOF
  14. source /etc/profile
  15. # 测试go语言安装
  16. mkdir -p ~/helloworld
  17. cd ~/helloworld
  18. cat <<EOF >> helloworld.go
  19. // Test that we can do page 1 of the C book.
  20. package main
  21. func main() {
  22. print("hello, world\n")
  23. }
  24. EOF
  25. go build
  26. ./helloworld