Go框架demo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.4 KiB

3 years ago
  1. #!/bin/sh
  2. # fetch_source.sh
  3. # This script for fetch source and packages.
  4. # @version 170227:1
  5. # @author zhangxuhong <zhangxuhong@xitu.io>
  6. #
  7. # [config]
  8. echo "-[config]-"
  9. # ----------------------------[manual config here]------------------------------
  10. # REPO_SRC=/data/repo/collection_set_api
  11. go_packages=(
  12. "github.com/astaxie/beego"
  13. "github.com/garyburd/redigo/redis"
  14. )
  15. #
  16. # http_proxy="http://localhost:8123"
  17. # ------------------------------------------------------------------------------
  18. # init env
  19. # $GOBIN
  20. export GOBIN="${REPO_SRC}/bin"
  21. echo -e "\033[34mGOBIN set to: ${GOBIN}\033[0m"
  22. # $GOPATH
  23. export GOPATH="${REPO_SRC}"
  24. echo -e "\033[34mGOPATH set to: ${GOPATH}\033[0m"
  25. # print package list
  26. echo "package list:"
  27. for pkg in ${go_packages[*]};
  28. do
  29. echo -e "\033[34m${pkg}\033[0m";
  30. done
  31. echo ""
  32. if [ "$http_proxy" != "" ]; then
  33. echo "http_proxy set to:"
  34. echo -e "\033[34m${http_proxy}\033[0m";
  35. echo "http_proxy location info:"
  36. proxyLocation=`http_proxy=${http_proxy} curl -s ip.gs`
  37. echo -e "\033[34m${proxyLocation}\033[0m";
  38. fi
  39. echo ""
  40. sleep 1
  41. # [fetch]
  42. echo "-[fetch package]-"
  43. for pkg in ${go_packages[*]};
  44. do
  45. if [ "$http_proxy" == "" ]; then
  46. echo "go get ${pkg}";
  47. go get $pkg;
  48. else
  49. echo "http_proxy=${http_proxy} go get ${pkg}";
  50. http_proxy=${http_proxy} go get $pkg;
  51. fi
  52. done
  53. echo "done."