简体   繁体   English

Windows 上的新 buffalo 项目:找不到模板 items/index.html

[英]New buffalo project on Windows: could not find template items/index.html

I'm working with someone to build a Buffalo app.我正在与某人合作构建 Buffalo 应用程序。 They are on Windows and I'm on Linux.他们在 Windows 上,我在 Linux 上。 After generating a model, they get a 500 error when visiting the list route: http://localhost:3000/items/ .生成模型后,访问列表路由时出现 500 错误: http://localhost:3000/items/ The problem is very similar to issue 1757 except the issue is fixed and the exact same source works on Linux and Mac.该问题与问题 1757非常相似,但问题已得到修复,并且完全相同的源代码适用于 Linux 和 Mac。 I suspect it's due to backslashes instead of forward slashes but can't confirm.我怀疑这是由于反斜杠而不是正斜杠造成的,但无法确认。 I was able to reproduce this on my Windows by creating a new buffalo project, configuring the database, generating a model and then visiting the route.通过创建新的 buffalo 项目、配置数据库、生成模型然后访问路线,我能够在我的 Windows 上重现这一点。 This fails in both MinGW and Powershell.这在 MinGW 和 Powershell 中都失败了。 I'm using Go modules ( GO111MODULE=on ) and have cleaned the modules cache, rebuilt buffalo and buffalo-pop .我正在使用 Go 模块( GO111MODULE=on )并清理了模块缓存,重建了buffalobuffalo-pop

Can someone confirm this works/fails on Windows?有人可以确认这在 Windows 上有效/失败吗? Besides having them migrate to Linux, what else can I try?除了让他们迁移到 Linux,我还能尝试什么?

$ buffalo version
time="2019-12-16T17:55:24-05:00" level=info msg="Buffalo version is: v0.15.3"
$ buffalo-pop pop --version
v4.13.0

Stack trace堆栈跟踪

T: %!s(i18n.TranslateFunc=0xaf30e0)

app: &{{/items 127.0.0.1:3000 http://127.0.0.1:3000 development  debug {%!s(*logrus.Logger=&{0xc0000a2008 map[] 0xc00035fa90 false 5 {{0 0} false} {{} 0xc0002f1d00 2 <nil> 0 <nil>} 0x4ebeb0})} %!s(http.HandlerFunc=0xab0c00) %!s(*sessions.CookieStore=&{[0xc000261950] 0xc000347c00}) _demo_session %!s(*worker.Simple=&{{0xc00023d810} 0xc0003d7500 0x590830 map[] 0xc00035fab0}) %!s(bool=false) [] [] /items/{item_id} context.Background.WithCancel.WithCancel %!s(context.CancelFunc=0x590830)} github.com/gobuffalo/buffalo.*App.defaultErrorMiddleware
github.com/gobuffalo/buffalo.*App.PanicHandler
github.com/gobuffalo/buffalo.RequestLoggerFunc
github.com/gobuffalo/buffalo.sessionSaver
github.com/gobuffalo/mw-forcessl.Middleware.func1
github.com/gobuffalo/mw-paramlogger.ParameterLogger
github.com/gobuffalo/mw-csrf.glob..func1
github.com/gobuffalo/buffalo-pop/pop/popmw.Transaction.func2
github.com/gobuffalo/mw-i18n.*Translator.Middleware.func1 map[%!s(int=404):%!s(buffalo.ErrorHandler=0xaaebf0) %!s(int=500):%!s(buffalo.ErrorHandler=0xaaebf0)] %!s(*mux.Router=&{0xaba2c0 0xaba2c0 [0xc00029b180 0xc00029b360 0xc00029b540 0xc00029b720 0xc00029ba40 0xc00029bd60 0xc00029bf40 0xc0001fc6e0 0xc0001fce60 0xc0001fd220 0xc0001fd5e0 0xc0001fdb80 0xc0001fdea0 0xc0003ee0a0 0xc0003ee3c0 0xc0003ee6e0 0xc0003ee8c0 0xc0003eeaa0 0xc0003eedc0 0xc0003ef0e0 0xc0003ef2c0 0xc0003ef5e0 0xc0003ef900 0xc0003efae0 0xc0003efcc0 0xc000410000 0xc000410320 0xc000410500 0xc000410820 0xc000410b40 0xc000410d20 0xc000410f00 0xc000411220 0xc000411540 0xc000411720 0xc000411a40 0xc000411d60] map[] false [] {false false false {<nil> <nil> []} []  <nil>}}) %!s(*sync.RWMutex=&{{0 0} 0 0 0 0}) [] %!s(*buffalo.App=&{{/ 127.0.0.1:3000 http://127.0.0.1:3000 development  5 {0xc00023d810} 0xab0c00 0xc00035ca00 _demo_session 0xc000347c80 false [] []  0xc000347bc0 0x590830} 0xc00035ca20 map[404:0xaaebf0 500:0xaaebf0] 0xc0002703c0 0xc000380360 [0xc00030d680 0xc0003f6300 0xc0003f6500 0xc0003f6380 0xc0003f6400 0xc0003f6580 0xc0003f6600 0xc0003f6480 0xc00030db00 0xc00030de00 0xc00030dc80 0xc00030de80 0xc00030df00 0xc00030dd00 0xc00030dd80 0xc0003f6180 0xc00030df80 0xc0003f6000 0xc0003f6200 0xc0003f6280 0xc0003f6080 0xc0003f6100 0xc0003f6680 0xc0003f6880 0xc0003f6700 0xc0003f6780 0xc0003f6900 0xc0003f6980 0xc0003f6800 0xc00030d780 0xc00030d980 0xc00030d800 0xc00030d880 0xc00030da00 0xc00030da80 0xc00030d900] <nil> [0xc000334a80 0xc000335380 0xc0003f4180 0xc0003f4900 0xc0003f5380] [/]}) [] []}

Yes, I confirm this behavior.是的,我确认了这种行为。 What you should do is substitute你应该做的是替代

    return c.Render(200, r.HTML("domain/view.html"))

with

    return c.Render(200, r.HTML("domain" + string(os.PathSeparator) + "view.html"))

It should work on all platforms.它应该适用于所有平台。 For some reason, path.Join() is not working either.出于某种原因, path.Join() 也不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM