1.初始化项目 :在项目根目录下运行go mod init formhandler。
go mod init formhandler
2.编写代码:将上述代码保存到对应的文件中
3.整理依赖:运行go mod tidy命令,该命令会自动添加缺失的依赖,移除不再使用的依赖。
go mod tidy formhandler
4.使用xcaddy编译
/root/go/bin/xcaddy build --with github.com/yourusername/formhandler --replace github.com/yourusername/formhandler=.
5.模拟递交
shcurl -X POST -d "name=John Doe&email=johndoe@example.com&message=This is a test message" https://yoursite.antihaway.com/submit
6.缺失支持
CGO_ENABLED=1 /root/go/bin/xcaddy build --with github.com/yourusername/formhandler --replace github.com/yourusername/formhandler=.
# 必须设置
go env -w GO111MODULE=on
# 推荐设置(国内用户建议)
go env -w GOPROXY=https://goproxy.cn,direct

最低0.47元/天 解锁文章
343

被折叠的 条评论
为什么被折叠?



