You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 22, 2022. It is now read-only.
I was trying to run pkger to bundle my files and getting a "runtime error: invalid memory address or nil pointer dereference".
I had the file names stored in constants for the pkger.Open() calls. I changed all pkger.Open() calls to use a string literal and no longer get the error.
Is this due to the parser not being able to reference constants as noted in issue #46 ?
The text was updated successfully, but these errors were encountered:
tl;dr: Use primitives or constants defined in the same file: static analysis can't run the code; just read it.
Assuming a program consisting of two source files a.go which defines a constant and b.go which uses the constant as a name for pkger.Open, a nil reference will be generated:
a.go
package p
const path = "/files"
b.go
package p
import "github.com/markbates/pkger"
func init() {
pkger.Open(path)
}
An informative error would be better than a nil pointer reference, but I am not sure the best place to put that check, nor of the best wording, or I would submit a PR.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I was trying to run pkger to bundle my files and getting a "runtime error: invalid memory address or nil pointer dereference".
I had the file names stored in constants for the
pkger.Open()
calls. I changed allpkger.Open()
calls to use a string literal and no longer get the error.Is this due to the parser not being able to reference constants as noted in issue #46 ?
The text was updated successfully, but these errors were encountered: