简体   繁体   中英

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

I'm working with someone to build a Buffalo app. They are on Windows and I'm on Linux. After generating a model, they get a 500 error when visiting the list route: 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. 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. This fails in both MinGW and Powershell. I'm using Go modules ( GO111MODULE=on ) and have cleaned the modules cache, rebuilt buffalo and buffalo-pop .

Can someone confirm this works/fails on Windows? Besides having them migrate to Linux, what else can I try?

$ 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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