admin icon indicating copy to clipboard operation
admin copied to clipboard

Error when build assets (templates,etc) into the binary

Open BERA opened this issue 7 years ago • 2 comments

Hi I'm following the instructions here https://doc.getqor.com/guides/bindatafs.html with a project with the layout below selection_040

I initialized bindata as a following

bindatafs config/bindatafs

Initializing BindataFS... copy from /home/user/go/src/github.com/qor/bindatafs/templates to config/bindatafs

After I changed the source code as requested.

selection_041

selection_041

And when I tried to compile the templates into the binary I got the error below

~/go/src/github.com/user/CtrlCollectors$ go run -tags 'bindatafs' main.go

github.com/user/CtrlCollectors/config/bindatafs

config/bindatafs/bindatafs.go:80: undefined: _bindata config/bindatafs/bindatafs.go:81: undefined: Asset config/bindatafs/bindatafs.go:87: undefined: _bindata config/bindatafs/bindatafs.go:88: undefined: _bindata config/bindatafs/bindatafs.go:224: undefined: _bindata config/bindatafs/bindatafs.go:225: undefined: Asset config/bindatafs/bindatafs.go:231: undefined: _bindata config/bindatafs/bindatafs.go:233: undefined: _bindata

after running without tags I received the message below go run main.go Compiling templates...

I got my final project structure/files

selection_044

Then build the project

go build -tags enterprise main.go

OR

go build main.go

But when running I get the message below ./main Compiling templates...

Before my error message was similar to the following issues

#56 #87 #33 #88

Also, the approach informed by @fengde didn't work either @jaytaylor

Guys, QOR is really nice framework but the documentation about deployment could be improved, this kind of error is a pain in the ass and could be easier to define a project structure and make EXPLICIT commands and instructions for build binary with the assets.

Or I really missing an obvious step

Thanks a lot.

BERA avatar Feb 09 '18 10:02 BERA

The two steps to make bindatafs work should be:

  1. trigger the Compile() function. In qor-example this is done with the --compile-templates flag.

This should create new go code under config/admin/bindatafs with the embedded files.

  1. build your server with the bindata tag.

cryptix avatar Feb 09 '18 19:02 cryptix

The binary created still doesn't work standalone. Atleast when I run on nginx. EDIT: It will work if $uri exactly matches the $uri the admin is mounted on. You can't proxy pass with an ending slash.

MohitKS5 avatar May 15 '20 03:05 MohitKS5