gpt-4.1-mini-2025-04-14· OpenAI
WildChat-4.8M (AI2)
go 中使用 embed 打包 static 文件夹后,访问服务必须要加上 static 才会打开 index.html 主页文件
- User
go 中使用 embed 打包 static 文件夹后,访问服务必须要加上 static 才会打开 index.html 主页文件
- Assistant
你描述的问题是在 Go 语言中使用
embed打包static文件夹后,访问服务时必须带上/static路径才能访问,例如浏览器访问http://localhost:8080/static/才能打开index.html,而访问http://localhost:8080/不能正确访问主页。这是一个常见的问题,原因是: