hyperjumptech / grule-rule-engine

Rule engine implementation in Golang
Other
2.18k stars 339 forks source link

Implement evaluation logic for pointer fact fields other than struct #264

Open mledezma-r7 opened 2 years ago

mledezma-r7 commented 2 years ago

Issue raised as result of the following inquiry...

Is there any workaround (or plan to support) for pointers to primitive types in the Fact struct

Something like this

type Fact struct {
  Foo *string
  Bar *bool
}

The nature of my data requires value distinction after unmarshalling the following two sample json docs 1) '{"Foo": "", "Bar": false}' 2) '{}'

With a Fact struct with no pointers
type Fact struct {
  Foo string
  Bar bool
}

the resulting struct would be equivalent to this for both case 1 and 2 Fact{Foo: "", Bar: false}

If we go with the struct with pointer we would get the following equivalents 1)

Foo := ""
Bar := false
Fact{Foo: &Foo, Bar: &Bar}

2) Fact{Foo: nil, Bar: nil}

Problem I'm facing is that I'm not able to pull (and evaluate) the values pointed by the pointers

Keep in mind I'm starting with go, so it might be a silly question Thank you

Originally posted by @mledezma-r7 in https://github.com/hyperjumptech/grule-rule-engine/discussions/263

yjagdale commented 1 year ago

any progress on this one?