How are people structuring there pulumi Go project...
# golang
r
How are people structuring there pulumi Go project folders? What directories do you use? Go recommends folders like CMD, Internal.
c
That's a big big hot topic. I think the CONVENTION not due to any specific guidance from Go is you'll see
Copy code
project
/pkg
/internal
/cmd
go.mod/sum
However, I'll say that I've read that things like pkg for example are kinda redudant and it's really a matter of preference. I hate giving that answer, but I looked through a lot and found so much variance. The Go community tends to avoid "this is how you should do it" and instead focuses on some things you shouldn't do. My personal recommendation would be (in ascending order of complexity and code involved) • Small app, all in one level directory. • Next step: All packages that are for app and not meant to be imported in
internal
and others in main project if it's a Go repo and not a big monorepo, otherwise, move into
pkg
for importable. ◦ cmd is a convention that just makes it easy to discover and build stuff, so I stick with that. Last side note... I personally adhere to every project should have mage/make files for common tasks and this means the organization of the project can vary a little without being a big deal, just run
mage build
and be done even if structure changes. Highly recommend this. Been working on a template repo with Go based tasks as an example and can share that later once it's up if you are interested in seeing. • Next step: move all
r
Hi @chilly-plastic-75584 thank you for this! must useful. I would be interested to see a project you have done to see how this works. Also, not heard of
mage
, sounds similar to
make
.
c
Check this out. You inspired me to get the final push done. You can use as a template and try it out. https://github.com/sheldonhull/scripts-to-rule-them-all-go I don't write shell/powershell scripts much anymore. Go is just so much nicer to work with.
r
I'm with you on that, think Go is great. Thanks for taking the time to do this. Excited to take a look.