panic: gzip: invalid header
FalcoSuessgott opened this issue · comments
I think Im too stupid, to get a basic example working:
This is project-tree:
$ tree
.
├── go.mod
├── go.sum
├── main.go
└── public
└── index.html
with a main.go
having this function:
package main
import (
"fmt"
"io"
"os"
"github.com/markbates/pkger"
)
func main() {
err := run()
if err != nil {
fmt.Println(err.Error())
}
}
func run() error {
f, err := pkger.Open("/public/index.html")
if err != nil {
return err
}
defer f.Close()
info, err := f.Stat()
if err != nil {
return err
}
fmt.Println("Name: ", info.Name())
fmt.Println("Size: ", info.Size())
fmt.Println("Mode: ", info.Mode())
fmt.Println("ModTime: ", info.ModTime())
if _, err := io.Copy(os.Stdout, f); err != nil {
return err
}
return nil
}
running go run main.go
seems to work:
$ go run main.go
Name: index.html
Size: 3
Mode: -rw-rw-r--
ModTime: 2020-05-08 13:39:46.670307305 +0200 CEST
Ok
However, when Im trying to build the binary with
$ pkger list
github.com/FalcoSuessgott/pkger_example
> github.com/FalcoSuessgott/pkger_example:/public/index.html
$ pkger
$ go build -o pgker_example
and execute it, I receive always this error message:
$ ./pkger_example
panic: gzip: invalid header
goroutine 1 [running]:
github.com/markbates/pkger.Apply(0x7b5580, 0x0, 0x7ade80, 0xc0000126c0, 0x0, 0x0)
/home/morelly_t1/go/pkg/mod/github.com/markbates/pkger@v0.15.1/apply.go:12 +0x13a
main.init.ializers()
/tmp/pkger-example/pkged.go:12 +0x9c
The created pkged.go
-file looks like this:
$ cat pkged.go
// Code generated by pkger; DO NOT EDIT.
// +build !skippkger
package main
import (
"github.com/markbates/pkger"
"github.com/markbates/pkger/pkging/mem"
)
var _ = pkger.Apply(mem.UnmarshalEmbed([]byte(`24474f524f4f541f24474f524f4f548b24474f524f4f540824474f524f4f540024474f524f4f540024474f524f4f540024474f524f4f540024474f524f4f540024474f524f4f540024474f524f4f54ff24474f524f4f54ec24474f524f4f545724474f524f4f545f24474f524f4f548f244.[....]
Am I missing something?
Thanks alot
Ok WTF, I found the mistake:
I had to remove the pkged.go
-file and just execute go build -o pkger_example
...
Closing Issue