继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

Golang 运维脚本

UYOU
关注TA
已关注
手记 295
粉丝 86
获赞 458

记录编译工具代码 Makefile
替换binary路径使用

BINARY={Path}
GOARCH=amd64

VERSION?=?
BUILD=`date +%FT%T%z`LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}".PHONY: help build linux darwin windows clean versionhelp:
    @echo "usage: make <option>"
    @echo "options and effects:"
    @echo "    help   : Show help"
    @echo "    build  : Build the binary of this project for current platform"
    @echo "    linux  : Build the linux binary of this project"
    @echo "    darwin : Build the darwin binary of this project"
    @echo "    windows: Build the windows binary of this project"
    @echo "    clean  : Remove binaries"
    @echo "    version: Display Go version"build:
    @go build ${LDFLAGS} -o ${BINARY}linux:
    @GOOS=linux GOARCH=${GOARCH} go build ${LDFLAGS} -o ${BINARY}-linux-${GOARCH}darwin:
    @GOOS=darwin GOARCH=${GOARCH} go build ${LDFLAGS} -o ${BINARY}-darwin-${GOARCH}windows:
    @GOOS=windows GOARCH=${GOARCH} go build ${LDFLAGS} -o ${BINARY}-windows-${GOARCH}.execlean:
    @rm -f ${BINARY}
    @rm -f ${BINARY}-*version:
    @go version%

记录上传测试环境工具代码

#!/usr/bin/env bashmake linux
rsync  -avzrC  Go-linux-amd64 config/test.yaml axdict@127.0.0.1:/home/axdict/go/

替换本地ip为远端ip 和 要同步的文件



作者:保儿洁
链接:https://www.jianshu.com/p/30379df1554a

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP