go - Dependency triangle -


dependencies issue go new:

  • application a directly dependent on libraries b , c
  • library b directly dependent on library c

if have in code of application a:

funcyinstance := &c.funcyobject{} b.cleverfunction(funcyinstance) 

when in lib b:

func cleverfunction(arg *c.funcyobject) {} 

it raises error:

cannot use funcyinstance (type "*a/vendor/github.com/c".funcyobject) type "*b/vendor/github.com/c".funcyobject in argument b.cleverfunction

i'm using glide dependency manager.

i understand configuration of dependencies causes existence of several types instead of single 1 (for library) , possibly anti pattern go. anyway... how solve issue?

i'd remove vendor folder below b, , put c in root vendor folder (for application a if getting structure correctly).

that way, end 1 place each type.

not sure why b have vendor folder in first place, since glide's recommendations clear on this:

http://glide.readthedocs.io/en/latest/vendor/

libraries (codebases without main package) should not store outside packages in vendor/ folder

and

in applications (codebases main package) there should 1 vendor/ directory @ top level


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -