$ gf build
2020-12-31 00:35:25.562 start building...
2020-12-31 00:35:25.562 go build -o ./bin/darwin_amd64/gf main.go
2020-12-31 00:35:28.381 go build -o ./bin/freebsd_386/gf main.go
2020-12-31 00:35:30.650 go build -o ./bin/freebsd_amd64/gf main.go
2020-12-31 00:35:32.957 go build -o ./bin/freebsd_arm/gf main.go
2020-12-31 00:35:35.824 go build -o ./bin/linux_386/gf main.go
2020-12-31 00:35:38.082 go build -o ./bin/linux_amd64/gf main.go
2020-12-31 00:35:41.076 go build -o ./bin/linux_arm/gf main.go
2020-12-31 00:35:44.369 go build -o ./bin/linux_arm64/gf main.go
2020-12-31 00:35:47.352 go build -o ./bin/linux_ppc64/gf main.go
2020-12-31 00:35:50.293 go build -o ./bin/linux_ppc64le/gf main.go
2020-12-31 00:35:53.166 go build -o ./bin/linux_mips/gf main.go
2020-12-31 00:35:55.840 go build -o ./bin/linux_mipsle/gf main.go
2020-12-31 00:35:58.423 go build -o ./bin/linux_mips64/gf main.go
2020-12-31 00:36:01.062 go build -o ./bin/linux_mips64le/gf main.go
2020-12-31 00:36:03.502 go build -o ./bin/netbsd_386/gf main.go
2020-12-31 00:36:06.280 go build -o ./bin/netbsd_amd64/gf main.go
2020-12-31 00:36:09.332 go build -o ./bin/netbsd_arm/gf main.go
2020-12-31 00:36:11.811 go build -o ./bin/openbsd_386/gf main.go
2020-12-31 00:36:14.140 go build -o ./bin/openbsd_amd64/gf main.go
2020-12-31 00:36:17.859 go build -o ./bin/openbsd_arm/gf main.go
2020-12-31 00:36:20.327 go build -o ./bin/windows_386/gf.exe main.go
2020-12-31 00:36:22.994 go build -o ./bin/windows_amd64/gf.exe main.go
2020-12-31 00:36:25.795 done!
41 Comments
kkstun
-ldflags="-s -w" 这样的参数可以加吗
郭强
是支持的,但是不建议加,编译后的二进制减少不了多少容量,这样会去掉一些符号和编译信息。
kkstun
好的。谢谢。
fy
怎么加两个参数?比如-ldflags="-s -w"和-trimpath,双引号需要用"\"吗?
张伟
gf build main.go -a amd64 -s linux n main -e "-trimpath -ldflags '-w -s'"
杨率帅
2.0.0 版本 build 出现如下信息:
PS C:\Users\Desktop\Codes\001_lc\LC-XQH-Go-Test> gf build --gf.gcfg.file=./_tmp/build.toml -v None
2021-12-28 15:54:24.154 [FATA] Error: exit status 128
PS C:\Users\Desktop\Codes\001_lc\LC-XQH-Go-Test> gf build --gf.gcfg.file=./_tmp/build.toml
2021-12-28 15:54:27.977 [FATA] Error: exit status 128
PS C:\Users\刘爽\Desktop\Codes\001_lc\LC-XQH-Go-Test> gf build
2021-12-28 15:54:49.041 [FATA] Error: exit status 128
PS C:\Users\刘爽\Desktop\Codes\001_lc\LC-XQH-Go-Test> gf build main.go
2021-12-28 15:55:05.031 [FATA] Error: exit status 128
测试平台是 windows 11
配置文件为:
main.go 就是简单的 hello world 程序
sudden3
解决了吗 我也遇到了
杨率帅
换了老版本.
beautiful
2022-01-23已修复,重新下载gf安装再试~
tryCatch
gf build
2021-12-28 23:28:44.219 [FATA] Error: exit status 128
王一飞
请问,我的项目有多个入口文件需要编译,我应该怎么配置
智刚
走不通的入口文件
李肖肖
在mac中明明已经关闭CGO了,但还是报以下错误
`2022-02-27 04:39:14.498 failed to build, os:linux, arch:amd64, error:
# runtime/cgo
linux_syscall.c:67:13: error: implicit declaration of function 'setresgid' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
linux_syscall.c:67:13: note: did you mean 'setregid'?
`
以下我的配置文件:
`
`
李肖肖
当我直接使用go build的时候,可以正常编译,但使用gf 就会出现以上报错
郭强
使用最新版本,然后
gf build xxx --debug=true
看看调试输出的语句是什么?李肖肖
解决了,是因为通过gf-cli配置文件设置cgo关闭不管用,无论设置什么,都为true,然后我重编译了一下gf-cli工具,把Cgo所在的结构体tag的orphan:设为false就可以了
李肖肖
配置文件中不需指定关闭cgo,golang中boolean类型默认false,gf-cli中的cgo带有标签`orphan:"true"`,如果指定此选项,那么无论指定的是0或者1都为true,不知道这样理解对不对
牛二哥
在mac中直接使用 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go 命令编译是可以在linux上运行的,但是端口不是我在config中定义的端口,于是想使用gf build 但是抛出以下错误
以下是我的配置:
牛二哥
已解决,用的楼上的方法,我把gf卸载了,下载源码包把gf-cli中的cgo带有标签`orphan:"true" 改为false
白夜
郭强 gf build得到的二进制文件运行时,报错
resource/i18n是我的i18n文件,另外还有一些静态文件放在 resource/public.
我的配置文件是:
并且我在main.go文件已经引入了pack
我的gf版本是:
是不是gf出了bug ?
echo
大佬这个问题搞定了吗,我也遇到这个问题
白夜
的确是gf的bug。 build出来的二进制文件没有包含 pack指定的目录。gf build 生成linux二进制文件没有打包resource和config · Issue #1799 · gogf/gf (github.com) 我提了issue,最新版本还没有尝试,你可以再试下
echo
最新的2.1版本,pack改成了packSrc和packDst,但是仍然有问题
白夜
可以在github上提issue。
echo
早就提过了
白夜
echo 搞定了。2.1版本gf build命令没有进行pack打包 · Issue #1971 · gogf/gf (github.com)
echo
这个issue就是我提的,demozx就是我
白夜
【笑哭】
linngc
谢谢大佬,gf build编译后,资源文件一直无法加载问题困扰了我好几天,终于解决了。特意来感谢
盖聂
使用gf build编译linux端的包,可以正常运行,但运行后的服务端口是随机的,而不是配置中的8199,在Windows上正常。编译成exe, 在Windows上运行,通过g.Cfg().Get(ctx, "server")可以读取到配置,编译到linux平台读取不到,是空字符串的输出
gfcli版本:GoFrame CLI Tool v2.1.0-rc4 (3月份的2.0.x版本也不行)
gf版本: 2.0.6
配置:
盖聂
原来是我部署到linux上没有放配置文件,只需要把2.0项目里面的manifest文件夹整个放到gf同目录就行了,配置文件就在里面
刘欣
能否编译成arm64+windows?
dengao
$ gf build main.go
2022-07-28 10:56:00.916 start building...
2022-07-28 10:56:00.916 go build -o main main.go
2022-07-28 10:56:02.712 failed to build, os:ios, arch:amd64, error:
no required module provides package main.go; to add it:
go get main.go
you may use command option "--debug" to enable debug info and check the details
yidashi
这文档参数一会儿pack一会儿packSrc,坑死人
saner.qu
我的项目有多个入口文件,使用gf build的时候报[FATA] Error: exit status 128 ,boot下面是有多个文件夹,对应多个入口。
多个项目是共用service,logic,api,model这些的,boot下面的每个文件夹,都有对应的main.go,以及cmd和controller
gf build ./boot/admin/main.go
这个地方该如何处理哦??
saner.qu
我下载了示例工程focus-single,使用gf build也是同样报错,go run main.go是正常的,
PS E:\work\saner\focus-single> go version
go version go1.19.2 windows/amd64
PS E:\work\saner\focus-single> gf -v
GoFrame CLI Tool v2.0.0, https://goframe.org
GoFrame Version: v2.2.1 in current go.mod
CLI Installed At: D:\gopath\bin\gf.exe
Current is a custom installed version, no installation information.
PS E:\work\saner\focus-single>
郭强
请自查。
︿( ̄︶ ̄)︿
最新版本编译是把指定配置文件的参数删掉了吗
vSpear
建议增加每次编译后的运行前置/后置命令行
比如配置个 cmd:"md5sum {file} >> {file}.md5" 其中{file为编译文件}
这样的话可以让我每次编译后生成对应的md5
或者执行upx等操作
小景
2.4.4后又不能交叉编译了,编译了后配置文件老师引不进来,之前都不是这样的
小陈
谁知道用这个怎么提升win系统的UAC权限