I using Gin framework. At local development mode: goapp serve all works fine.
func init() {
route := gin.Default()
route.LoadHTMLGlob("../*/views/**/*.html")
...
}
But after deploy:
panic: html/template: pattern matches no files:
../*/views/**/*.html
OK. I try:
func init() {
route := gin.Default()
dir, _ := filepath.Abs(filepath.Dir(os.Args[0]))
route.LoadHTMLGlob(dir + "/../*/views/**/*.html")
...
}
Same result.
I try fetch dir:
...
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
...
}
c.String(http.StatusOK, "Dir: ", dir)
c.String(http.StatusOK, "
OK")
res, err := filepath.Glob(dir + "/*")
c.String(http.StatusOK, fmt.Sprintf("%v | %v
", res, err))
c.String(http.StatusOK, "Dirs:")
res, err = filepath.Glob(dir + "/**/*")
c.String(http.StatusOK, fmt.Sprintf("%v | %v", res, err))
...
Result:
Dir: %!(EXTRA string=/base/data/home/apps/tmp-LEIYJC/_ah) OK[/base/data/home/apps/tmp-LEIYJC/_ah/exe] |
Dirs:[] |
Ooops. What I done wrong?
UPD:
app.yaml
runtime: go
api_version: go1
handlers:
- url: /images
static_dir: ../static/images
- url: /css
static_dir: ../static/css
- url: /js
static_dir: ../static/js
- url: /fonts
static_dir: ../static/fonts
- url: /.*
script: _go_app
I put app.yaml to subdirectory, cause without that another problem: [https://groups.google.com/forum/#!topic/google-appengine-go/dNhqV6PBqVc
Folder structure:
app/
app.go
app.yaml
static/
...
frontend/
controllers/
UserController.go
...
models/
UserModel.go
...
views/
home/
*.html
user/
*.html
anotherfolder/
*.html
backend/
controllers/
MainController.go
...
models/
SomeModel.go
...
views/
main/
*.html
anotherfolder/
*.html
...