GO完全静态编译 | 您所在的位置:网站首页 › cgo静态编译死机 › GO完全静态编译 |
1
CGO_ENABLED=0 go build --ldflags "-extldflags -static" -o bin/frps-static ./cmd/frps
实际可以看到效果如下: 1 2 3 4 5 6 7 /go/src/github.com/fatedier/frp # go build --ldflags "-extldflags -static" -o bin/frps-static ./cmd/frps /go/src/github.com/fatedier/frp # ldd bin/frps-static /lib/ld-musl-x86_64.so.1 (0x7fb254e7f000) libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7fb254e7f000) /go/src/github.com/fatedier/frp # CGO_ENABLED=0 go build --ldflags "-extldflags -static" -o bin/frps-static ./cmd/frps /go/src/github.com/fatedier/frp # ldd bin/frps-static ldd: bin/frps-static: Not a valid dynamic programbin/frps-static 就是静态的文件,再不也不是动态的了。 参考链接: https://www.yryz.net/post/golang-docker-alpine-start-panic.html http://blog.wrouesnel.com/articles/Totally%20static%20Go%20builds/ http://blog.cloud66.com/how-to-create-the-smallest-possible-docker-image-for-your-golang-application/ |
CopyRight 2018-2019 实验室设备网 版权所有 |