Google app engine Go Google应用程序引擎-can';找不到模板文件

Google app engine Go Google应用程序引擎-can';找不到模板文件,google-app-engine,go,go-gin,Google App Engine,Go,Go Gin,我使用Gin框架。 在当地发展模式:goapp服务 一切正常 func init() { route := gin.Default() route.LoadHTMLGlob("../*/views/**/*.html") ... } 但部署后: panic:html/template:pattern不匹配任何文件:。/*/views/***.html 嗯。我尝试: func init() { route := gin.Default() dir, _ :

我使用Gin框架。 在当地发展模式:goapp服务 一切正常

func init() {
    route := gin.Default()
    route.LoadHTMLGlob("../*/views/**/*.html")
    ...
}
但部署后:

panic:html/template:pattern不匹配任何文件:
。/*/views/***.html

嗯。我尝试:

func init() {
    route := gin.Default()
    dir, _ := filepath.Abs(filepath.Dir(os.Args[0]))
    route.LoadHTMLGlob(dir + "/../*/views/**/*.html")
    ...
}
同样的结果

我尝试获取目录:

...
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
    ...
}
c.String(http.StatusOK, "Dir: ", dir)

c.String(http.StatusOK, "\nOK")
res, err := filepath.Glob(dir + "/*")
c.String(http.StatusOK, fmt.Sprintf("%v | %v\n\n", res, err))

c.String(http.StatusOK, "Dirs:")
res, err = filepath.Glob(dir + "/**/*")
c.String(http.StatusOK, fmt.Sprintf("%v | %v", res, err))
...
结果:

目录:%!(额外字符串=/base/data/home/apps/tmp-LEIYJC/_-ah) OK[/base/data/home/apps/tmp LEIYJC/_ah/exe]|

目录:[]|

哎呀。我做错了什么

UPD:

应用程序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
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
我将app.yaml放在子目录中,因为没有这个问题,另一个问题是: [

文件夹结构

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

如果我没有弄错的话,您的所有目录都应该位于app.yaml所在的根目录中。因此,您可能希望这样。此外,当您希望应用程序访问静态文件目录时,您需要将
application\u readable:true
添加到该目录定义中。请参见下面的示例。希望这很有帮助

app/
    app.go
    app.yaml
    static/
        ...
    frontend/views/
        home/
        *.html
    anotherfolder/
        *.html
目录定义示例:

- url: /s
  static_dir: s/
  application_readable: true

如果我没有弄错的话,您的所有目录都应该位于app.yaml所在的根目录中。因此,您可能希望这样。此外,当您希望应用程序访问静态文件目录时,您需要将
application\u readable:true
添加到该目录定义中。请参见下面的示例。希望这很有帮助

app/
    app.go
    app.yaml
    static/
        ...
    frontend/views/
        home/
        *.html
    anotherfolder/
        *.html
目录定义示例:

- url: /s
  static_dir: s/
  application_readable: true
我找到了下一个解决办法

我重新调整结构:

app/
    static/
        ...
    frontend/
        views/
           home/
               *.html
           user/
               *.html
           anotherfolder/
               *.html
    backend/
        views/
            main/
                *.html
            anotherfolder/
                *.html
    app.go
    app.yaml

frontend/
    controllers/
        UserController.go
        ...
    models/
        UserModel.go
        ...
backend/
    controllers/
        MainController.go
    ...
    models/
        SomeModel.go
    ...
...
更改:

应用程序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
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
这真的很奇怪。我无法将app.yaml放入应用程序的根目录,因为我收到了复制导入的紧急消息。我也无法将模板放入根目录,因为它不在范围内,只在app.yaml的父目录下。我找到了下一个解决方案

我重新调整结构:

app/
    static/
        ...
    frontend/
        views/
           home/
               *.html
           user/
               *.html
           anotherfolder/
               *.html
    backend/
        views/
            main/
                *.html
            anotherfolder/
                *.html
    app.go
    app.yaml

frontend/
    controllers/
        UserController.go
        ...
    models/
        UserModel.go
        ...
backend/
    controllers/
        MainController.go
    ...
    models/
        SomeModel.go
    ...
...
更改:

应用程序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
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

这真的很奇怪。我不能把app.yaml放在应用程序的根目录下,因为我收到了复制导入的紧急消息。我不能把模板放在根目录下,因为它不在范围内,只在app.yaml的父目录下。yaml

你也可以共享你的app.yaml吗?@Sean我添加了app.yaml和一些文件夹结构,可以吗也共享你的app.yaml吗?@Sean我添加了app.yaml和一些文件夹结构以供响应!但是app/as子目录不是意外事件。还有另一个问题:()例如:()是的,我的响应问题与seanThanks相同!但是app/as子目录不是意外事件。还有另一个问题:()例如:()是的,我和肖恩有同样的问题