gojekfarm / xtools

XTools is a submodule based repo to host re-usable Golang code.
MIT License
5 stars 0 forks source link

xload: Detect collisions while working with reused nested structs #36

Closed ajatprabha closed 1 month ago

ajatprabha commented 4 months ago

Overview

xload, at the moment, does not detect any collisions when working with nested structs that are reused.

Example

```go type A struct { B D `env:",prefix=D_"` C D `env:",prefix=D_"` } type D struct { S string `env:"S"` } ``` When a loader returns `"D_S: "value"`, both `A.B.S` and `A.C.S` are assigned value "value", without any warning, potentially introducing uncaught behaviour exceptions.

Proposal

Add some mechanism to detect collisions in the overall state of a Load call on the root struct.