google app engine - Subfolders and packages when using Appengine and Go -


when deploying and/or testing go project appengine, appcfg.py , dev_appserver.py tools used compile project

that works fine when *.go files in 1 folder, how can project be compiled when code divided subfolders- yet need access functions , constants eachother?

in go- subfolders definition package boundaries, , can't see way allow appengine tools compile multiple packages before testing or deploying, 1 project.

advice on how tackle this- other keeping in 1 folder, appreciated. if solution approach 1 package (folder) @ time, advice on how structure quick iteration on 1 project uses packages appreciated. thanks!

there no magic here. make sure each of go files placed in folder , not in root of appengine project.

for example:

-[project root]     app.yaml     -[packagea]         packagea.go         -[packageab]             packageab.go     -[packageb]             packageb.go 

in example above, package declarations should follows:

  • packagea.go:

    package packagea 
  • packageab.go

    package packageab 
  • packageb.go

    package packageb 

and example if packageb uses both packagea , packageab, import them as:

  • packageb.go:

    import (     "packagea"     "packagea/packageab" ) 

note:

note cannot create import cycle (e.g. packagea imports packageb, , packageb imports packagea):

spec: import declarations

an import declaration declares dependency relation between importing , imported package. illegal package import itself, directly or indirectly.

you have structure code , packages avoid import cycles or code not compile.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -