完整的复现流程
Logger.
logger:
Path: "/tmp/log/gf-app"
Level: "all"
Stdout: true
Template.
viewer:
Path: "template"
DefaultFile: "index.html"
Delimiters: [ "${", "}" ]
Database.
database:
link: "mysql:root:12345678@tcp(127.0.0.1:3306)/test"
debug: true
Database logger.
database.logger:
Path: "/tmp/log/gf-app/sql"
Level: "all"
Stdout: true
- `cd ../ && gf pack etc,public,template,i18n packed/data.go -n packed`
- 修改 boot.go 的内容
package boot
import (
_ "s1/packed"
"github.com/gogf/gf/frame/g"
)
func init() {
_ = g.Cfg().SetPath("etc")
g.Cfg().SetFileName("config.yaml")
g.Res().Dump()
}
- `gf build`
- 将生成的 main 文件复制到虚拟机运行,报错
vagrant@homestead:~$ mv sail_code/test/s1/main s1
vagrant@homestead:~$ ./s1
2021-01-06T09:30:54+00:00 0.00B etc
2021-01-06T09:02:40+00:00 0.00B etc/.gitkeep
2021-01-06T09:27:30+00:00 492.00B etc/config.yaml
2021-01-06T09:30:54+00:00 0.00B i18n
2021-01-06T09:02:40+00:00 0.00B i18n/.gitkeep
2021-01-06T09:30:54+00:00 0.00B public
2021-01-06T09:02:40+00:00 0.00B public/html
2021-01-06T09:02:40+00:00 0.00B public/html/.gitkeep
2021-01-06T09:02:40+00:00 0.00B public/plugin
2021-01-06T09:02:40+00:00 0.00B public/plugin/.gitkeep
2021-01-06T09:02:40+00:00 0.00B public/resource
2021-01-06T09:02:40+00:00 0.00B public/resource/css
2021-01-06T09:02:40+00:00 0.00B public/resource/css/.gitkeep
2021-01-06T09:02:40+00:00 0.00B public/resource/image
2021-01-06T09:02:40+00:00 0.00B public/resource/image/.gitkeep
2021-01-06T09:02:40+00:00 0.00B public/resource/js
2021-01-06T09:02:40+00:00 0.00B public/resource/js/.gitkeep
2021-01-06T09:30:54+00:00 0.00B template
2021-01-06T09:02:40+00:00 0.00B template/.gitkeep
TOTAL FILES: 19
SERVER |
DOMAIN |
ADDRESS |
METHOD |
ROUTE |
HANDLER |
MIDDLEWARE |
default |
default |
:80 |
ALL |
/ |
s1/app/api/hello.Hello |
--------- |
--------- |
--------- |
-------- |
------- |
------------------------ |
------------ |
2021-01-06 09:31:52.734 [FATA] 4041: net.Listen error: listen tcp :80: bind: permission denied
Stack:
- github.com/gogf/gf/net/ghttp.(*Server).startServer.func1
/home/dabuge/go/pkg/mod/github.com/gogf/gf@v1.15.0/net/ghttp/ghttp_server.go:431
vagrant@homestead:~$
没有找到正确的配置文件,导致使用了默认的80端口,所以报错