freeconf / yang

Standards-based management for Golang microservices
Apache License 2.0
38 stars 15 forks source link

[Question] Is Default() method syntax changed intentionally? Is this correct if leaf has value other than string. #72

Closed davidmat50 closed 1 year ago

davidmat50 commented 1 year ago

In the latest master chekout, i see the following changes.

The return type of Default() method for leafList is changed from []interface{} to []string . The return type of Default() method for leaf is changed from interface{} to string . Is this change intentional?????** The type of the leaf can be any type, it would not necessarilybe a string,

func (m *LeafList) Default() []string {
    return m.defaultVals
}
davidmat50 commented 1 year ago

ok. Now i see a new method DefaultValue() got introduced. i will use it.

dhubler commented 1 year ago

It was intentional. One can argue both cases, I thought string would make API more clear this is as it was defined in YANG. When it is pre-coerced to the surrounding type, you may have lost the original exact definition. "4.00" v.s. "4". The driver was serializing the YANG over grpc to support python and needing a stable value.

If you have a good use case for the interface{} we can always add "DefaultVal() interface{}"

On Wed, Aug 2, 2023 at 7:40 AM David Abraham Mathews < @.***> wrote:

In the latest master chekout, i see the following changes.

The return type of Default() method for leafList is changed from []interface{} to []string . The return type of Default() method for leafList is changed from interface{} to string . Is this change intentional?????** The type of the leaf can be any type, it would not necessarilybe a string,

func (m *LeafList) Default() []string { return m.defaultVals }

— Reply to this email directly, view it on GitHub https://github.com/freeconf/yang/issues/72, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACA7SJIEM4ONRYT5PJEVDXTI4BHANCNFSM6AAAAAA3BEL5MY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

dhubler commented 1 year ago

ah, i guess i forgot i already added that ;)