test-definitions/blob/master/auto-test/go-bindata/go-bindata.sh
2018-01-19 08:58
447 查看
#!/bin/bash #回显执行的命令和参数 set -x cd ../../utils . ./sys_info.sh . ./sh-test-lib cd - #检查是否安装go,没有安装的话,就安装go go version if [ $? -ne 0 ];then print_info 1 golang-install else yum install go print_info $? golang-install fi #为centos和fedora安装go-bindata case "${distro}" in centos|fedora) sudo wget -O /etc/yum.repos.d/estuary.repo https://raw.githubusercontent.com/open-estuary/distro-repo/master/estuaryftp.repo sudo chmod +r /etc/yum.repos.d/estuary.repo sudo rpm --import ftp://repoftp:repopushez7411@117.78.41.188/releases/ESTUARY-GPG-KEY yum clean dbcache print_info $? setup-estuary-repository pkgs="go-bindata" install_deps "${pkgs}" print_info $? install-go-bindata ;; *) error_msg "Unsupported distribution!" esac #得到并输出go-bindata的版本信息 go-bindata -version print_info $? go-bindata-version #set a go project dir dir="my-project" mkdir $dir cd $dir #src --source code #bin --execute #vender --Third party Library #pkg --Static library mkdir src mkdir bin mkdir vender mkdir pkg print_info $? set-specific-dir export GOPATH=`pwd` print_info $? set-GOPATH mkdir -p src/view #生成一个html文件 cat > src/view/index.html <<EOF Hello, Welcome to go web programming... EOF #使用go-bindata生成asset.go 文件 go-bindata -o=./asset/asset.go -pkg=asset view/... print_info $? go-bindata-run #检查是否生成asset.go 文件 ls src/asset/asset.go print_info $? generate-binary-go mkdir -p src/main #生成一个go文件,这个文件会输出asset.go 中的内容 cat > src/main/main.go <<EOF package main import ( //"net/http" "asset" ) func main() { dirs := []string{"view"} for _, dir := range dirs { if err := asset.RestoreAssets("./", dir); err != nil { break } } } EOF #编译go文件 go build main print_info $? build-release-go #执行go文件 ./main 检查生成的html文件是否相等 diff view/html/index.html src/view/html/index.html print_info $? release-file #删除目录 cd .. rm -rf $dir #删除包 yum remove -y go-bindata print_info $? remove-go-bindata
相关文章推荐
- test-definitions/blob/master/auto-test/bigdata/bigdata.sh
- test-definitions/blob/master/auto-test/cyclictest/cyclictest.sh
- test-definitions/blob/master/auto-test/dhcp/dhcp.sh
- test-definitions/blob/master/auto-test/24h-stress-test/24h-stress-test.sh
- test-definitions/blob/master/auto-test/disk-partitioning/disk-partitioning.sh
- test-definitions/blob/master/auto-test/dsdbench/dsdbench.sh
- test-definitions/blob/master/auto-test/dsdbench/dsdbench.sh
- test-definitions/blob/master/auto-test/docker/docker.sh
- test-definitions/blob/master/auto-test/dstat/dstat.sh
- test-definitions/blob/master/auto-test/alisql/alisql.sh
- test-definitions/blob/master/auto-test/etcd/etcd.sh
- test-definitions/blob/master/auto-test/bazel/bazel.sh
- test-definitions/blob/master/auto-test/ftp/ftp.sh
- test-definitions/blob/master/auto-test/golang/golang.sh
- test-definitions/blob/master/auto-test/gprof/gprof.sh
- test-definitions/blob/master/auto-test/httperf-client/httperf.sh
- /test-definitions/blob/master/auto-test/blktrace/blktrace.sh
- test-definitions/blob/master/auto-test/hhvm/hhvm.sh
- test-definitions/blob/master/auto-test/iostat/iostat.sh
- test-definitions/blob/master/auto-test/kernel-compilation/kernel-compilation.sh