GolangNote

Golang笔记

Golang 应用多平台批量编译脚本并计算文件md5 值

Permalink

Golang 应用多平台批量编译脚本,Mac 环境,linux、darwin、freebsd、windows,amd64、386。

Bash: 多平台编译脚本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh

project_name="yourapp"
release_version="0.0.1"

release_dir=./release
rm -rf $release_dir/*
mkdir -p $release_dir

cd  $(dirname $0)

gofmt -w ./

for goos in "linux" "darwin" "freebsd" "windows"
do
    if [ "$goos" == "windows" ]; then
      obj_name=$project_name.exe
    else
      obj_name=$project_name
    fi
    
    GOOS=$goos GOARCH=amd64 go build
    zip $release_dir/$project_name-$goos-amd64.zip $obj_name
    GOOS=$goos GOARCH=386 go build
    zip $release_dir/$project_name-$goos-386.zip $obj_name
    rm -f $obj_name
done

cd $release_dir
for file in ./*
do
    md5 -r $file >> sha1sum.txt
done

本文网址: https://golangnote.com/topic/215.html 转摘请注明来源

Related articles

golang snappy 的使用场合

google 自家的 snappy 压缩优点是非常高的速度和合理的压缩率。压缩率比 gzip 小,CPU 占用小。...

Write a Comment to "Golang 应用多平台批量编译脚本并计算文件md5 值"

Submit Comment Login
Based on Golang + fastHTTP + sdb | go1.17 Processed in 0ms