Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialise read only store #135

Open
dpajkovic opened this issue Jan 7, 2022 · 2 comments
Open

Initialise read only store #135

dpajkovic opened this issue Jan 7, 2022 · 2 comments
Assignees
Labels

Comments

@dpajkovic
Copy link

Hello,

I'm certain I'm doing something stupid since this is turning up with error, but I'm trying to open a read only store by passing the options to the bolthold.Open function:

var bho bolthold.Options
bho.ReadOnly = true

store, err := bolthold.Open(dbFilename, fs.FileMode(os.O_RDONLY), &bho)

And it always errors out on the second line with "runtime error: invalid memory address or nil pointer dereference". Please help this newb 😄

TIA

@timshannon timshannon added the bug label Jan 7, 2022
@timshannon timshannon self-assigned this Jan 7, 2022
@timshannon
Copy link
Owner

I can replicate. It may be a bug, as this is something I've never attempted and I may be making some assumptions how index handling.

Thanks for the reporting.

@timshannon
Copy link
Owner

So the issue has nothing to do with ReadOnly or not, it has to do with the fact that I'm (likely incorrectly) using a pointer to the bbolt options inside my BoltHold options.

It's probably more correct to not structurally inherit the field values as a pointer for this very reason, however changing it now would require a major semver change since these options are a exported struct.

You can work around it for now by instantiating the internal bolt.Options:

	bho := &bolthold.Options{
		Options: &bolt.Options{
			ReadOnly: true,
		},
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants