gobuffalo / packr

The simple and easy way to embed static files into Go binaries.
MIT License
3.41k stars 196 forks source link

Packr v2 Doesn't Work #145

Open moloch-- opened 5 years ago

moloch-- commented 5 years ago

packr (v1) works fine but packr2 fails, doesn't produce any -packr.go files

➜  server git:(master) packr2
ERRO[2019-01-21T19:39:17-05:00] /Users/user/go/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go: /Users/user/go/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
Error: /Users/moloch/go/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go: /Users/user/go/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'
lukasschlueter commented 5 years ago

Please add some more information when reporting issues, it helps a lot.

The file you're referring to seems to be https://github.com/golang/tools/blob/master/go/loader/testdata/badpkgdecl.go

Is there any real use case where you would like to pack a go file without any content and expect a generated packr file?

moloch-- commented 5 years ago

I'm not sure why it's complaining about the badpkgdecl.go file.

The directory structure is below, where the boxes are in the assets.go file and points to the assets directory:

├── server
│   ├── assets
│   │   ├── darwin
│   │   │   └── go.zip
│   │   ├── linux
│   │   │   └── go.zip
│   │   ├── protobuf.zip
│   │   └── windows
│   │       └── go.zip
│   ├── assets.go

When running packr (v1) it will generate a ./server/a_main-packr.go file, but packr2 simply emits the error I posted above with no other information.

Ryex commented 5 years ago

packr2 doesn't seem to traverse down the directory structure as packr1 did. I too am having an issue with this.

go run github.com/gobuffalo/packr/v2/packr2 -v
?[37mDEBU?[0m[2019-02-01T23:35:21-07:00] *parser.Parser#NewFromRoots ?[37moptions?[0m="{\"IgnoreImports\":false,\"Ignores\":null}" ?[37mroots?[0m="[\"D:\\\\Projects\\\\go-broadcaster\"]"
?[37mDEBU?[0m[2019-02-01T23:35:21-07:00] *parser.Parser#NewFromRoots ?[37mwalking?[0m="D:\\Projects\\go-broadcaster"
?[37mDEBU?[0m[2019-02-01T23:35:21-07:00] *parser.Parser#NewFromRoots ?[37mfound prospects?[0m=0
?[37mDEBU?[0m[2019-02-01T23:35:21-07:00] *parser.Parser#NewFromRoots ?[37moptions?[0m="{\"IgnoreImports\":false,\"Ignores\":null}" ?[37mroots?[0m="[\"D:\\\\Projects\\\\go-broadcaster\"]"

?[37mDEBU?[0m[2019-02-01T23:35:21-07:00] *parser.Parser#NewFromRoots ?[37mwalking?[0m="D:\\Projects\\go-broadcaster"
?[37mDEBU?[0m[2019-02-01T23:35:21-07:00] *parser.Parser#NewFromRoots ?[37mfound prospects?[0m=0
?[37mDEBU?[0m[2019-02-01T23:35:21-07:00] *parser.Parser#NewFromRoots ?[37moptions?[0m="{\"IgnoreImports\":false,\"Ignores\":null}" ?[37mroots?[0m="[\"D:\\\\Projects\\\\go-broadcaster\"]"
?[37mDEBU?[0m[2019-02-01T23:35:21-07:00] *parser.Parser#NewFromRoots ?[37mwalking?[0m="D:\\Projects\\go-broadcaster"
?[37mDEBU?[0m[2019-02-01T23:35:21-07:00] *parser.Parser#NewFromRoots ?[37mfound prospects?[0m=0
?[37mDEBU?[0m[2019-02-01T23:35:21-07:00] found 0 boxes
?[37mDEBU?[0m[2019-02-01T23:35:21-07:00] *store.Disk#Close
?[37mDEBU?[0m[2019-02-01T23:35:21-07:00] Step: d3cf180a
?[37mDEBU?[0m[2019-02-01T23:35:21-07:00] Chdir: D:\Projects\go-broadcaster
?[37mDEBU?[0m[2019-02-01T23:35:21-07:00] File: D:/Projects/go-broadcaster/packrd/packed-packr.go

when D:/Projects/go-broadcaster/web/server.go eixits with boxes

I could just cd web and run the command, it does find the boxes that way, but then I can't guarantee that my use of packr2 is vendored correctly via the go.mod in the top level directory.

moloch-- commented 5 years ago

Here's mine with the verbose flag:

➜  server git:(master) packr2 -v build .
...
...
...
DEBU[2019-02-02T21:04:35-06:00] *parser.Parser#Run parsing=/Users/moloch/go/src/github.com/AlecAivazis/survey/core/renderer.go
DEBU[2019-02-02T21:04:35-06:00] *parser.Parser#Run parsing=/Users/moloch/go/src/github.com/AlecAivazis/survey/tests/doubleSelect.go
DEBU[2019-02-02T21:04:35-06:00] *parser.Parser#Run parsing=/Users/moloch/go/src/gopkg.in/AlecAivazis/survey.v1/terminal/cursor_windows.go
DEBU[2019-02-02T21:04:35-06:00] *parser.Parser#Run parsing=/Users/moloch/go/src/golang.org/x/tools/go/buildutil/tags.go
DEBU[2019-02-02T21:04:35-06:00] *parser.Parser#Run parsing=/Users/moloch/go/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go
Error: /Users/moloch/go/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go: /Users/moloch/go/src/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'