4 ms·
Organizing a golang-based project is also something that, while documented, is not front of mind for most new golang users, nor does the "beginning go" posts ou
by brodouevencode 4y ago
Organizing a golang-based project is also something that, while documented, is not front of mind for most new golang users, nor does the "beginning go" posts out there do a good job of how to lay out a project for success.
- morelisp 4y agoIs Python significantly better in this regard? I don't think so, especially with the differentiation between modules which are directories with an __init__.py and modules which are files you import directly but if not in the same directory also still need an __init__.py which has tripped up probably 80% of the people I try to teach Python to. In Go you can at least get pretty far with a totally flat namespace and there's nothing wrong with that, up to at least 50kloc or so. That's less true in any language where files become a unit of modularization.
- Scarblac 4y ago> modules which are files you import directly but if not in the same directory also still need an __init__.py which has tripped up probably 80% of the people I try to teach Python to. Not necessary anymore since Python 3.3 (released in 2012).
- kccqzy 4y agoWith python you can also go pretty far without __init__.py IMO. Just put everything in a single directory.
- morelisp 4y agoBeginners trying this are still liable to make import cycles, which... sort of work? Depending on what you do with them? I feel like Go and Java have much better (and different) answers here; I wonder what a Python equivalent of the Java style would look like.
- DandyDev 4y agoDirectories with an __init__.py are not modules, they are packages. Modules are .py files
- jamal-kumar 4y agoI always felt that the official documentation is pretty excellent (Worth a re-read if you haven't in a while): Code organization: https://go.dev/doc/code https://go.dev/doc/code Pretty much everything else you should know: https://go.dev/doc/effective_go https://go.dev/doc/effective_go There's one thing I think that people getting started with this language should know and that's in the pursuit of getting the stuff you mentioned right, is making sure the reference material (blog post, book, whatever it is) you're reading is something written within the past two or three years. The official site really has enough that you need to know in order to have good knowledge coverage, but the module system beyond version 1.16 especially is something you need to get right and which a ton of old information is out of date on: https://go.dev/doc/modules/developing https://go.dev/doc/modules/developing