<div dir="ltr">Pranav,<div><br></div><div>If it really is the simplest solution, I would suggest that you move the LifeCycle into <a href="http://github.com/almighty/almighty-core/models/lifecycle">github.com/almighty/almighty-core/models/lifecycle</a> package if the struct is only used within the models package. </div><div><br></div><div>Regards,</div><div>Konrad</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 8, 2016 at 5:25 AM, Pranav Gore <span dir="ltr"><<a href="mailto:pgore@redhat.com" target="_blank">pgore@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>​Hi Team Core,<br><br><b>Context/Background:-</b><br>I am working on <a href="https://github.com/almighty/almighty-core/issues/244" target="_blank">#244</a>. The task is to do <span style="background-color:rgb(255,255,255)">`fields["system.creator"]=<wbr>currentLoggedInUser</span>`.<br><br>There, I want to call a method Locate from package "Token" which returns current logged in user.<br>While doing so I am facing cyclic import problem.<br><br><b>Reason:-</b> Work_item_repo is in package "models", it wants to call Locate method from package "token".<br>But "token" pachakge imports "account" package and "account" package imports "models".<br>Hence "models" package is unable to import "token" => cyclic dependency.<br><br><b>Debugging:-</b> When I was looking into "account" package, what exactly it needs from "models" package is ONLY "models.LifeCycle" and nothing else as of now.<br><br><b>Solutions:-</b> One quick possible/feasible solution is to put models.LifeCycle into different new package of its own, refactor and move on (IMO we should do this as first step).<br><br>Another is to write a middleware(as mentioned in <a href="https://github.com/almighty/almighty-core/issues/244" target="_blank">#244</a>) for injecting loggedInUser which will be in package "middleware" and avoid cyclic import, <br><br>Or redesigning to decouple models package into smaller chunks ?<br></div><div><br>PFA- I have attached output of `go list -f` on account, models, token packages.<br><br>Any input on this will be helpful :)<br></div><div><br><br></div>Thanks,<br></div>Pranav<br></div>
</blockquote></div><br></div>