timshannon / badgerhold

BadgerHold is an embeddable NoSQL store for querying Go types built on Badger
MIT License
515 stars 52 forks source link

Ability to ignore struct properties #50

Closed dirtycajunrice closed 3 years ago

dirtycajunrice commented 3 years ago

It would be super helpful to be able to ignore properties with a tag similar to how json/yaml/glob etc do it.

type Example struct {
    Name string
    RuntimeInfo RuntimeInfo `badgerhold:"-"`
}
timshannon commented 3 years ago

You can! But you need to use the proper tag for whatever encoding you are using with Badgerhold. The default uses GOB encoding, but you can use JSON and use JSON tags.

type Example struct {
    Name string
    RuntimeInfo RuntimeInfo `json:"-"`
}

Alternately you can also just make them non-exported by starting the field name with a lower case letter.