Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Packages may not circularly reference each other.

Actually possible with go:linkname.



Fair, but I think we can classify that under "unsafe" and ignore it under normal circumstances. I can also say things like "Go doesn't have pointer arithmetic" with a straight face, even though unsafe permits pointer arithmetic just fine. If you're programming with that routinely, you're out of the bounds of my advice for architecture anyhow. Whether for good or bad reasons would be left as an exercise for the architect in question.


Looking at the diagram for the SQLite VFS page I didn't think I was going overboard with designing my driver around 3 packages: https://sqlite.org/vfs.html

One layer wraps SQLite C API, below it lives a pure Go VFS, and above all that database/sql driver.

Even this coarse split (with a collection internal packages, the bigger one of them “utils”) is enough to need various band-aids to accommodate the impossibility of circular dependencies.

I honestly don't think it helps much.

At the module level, there are obvious benefits from the impossibility. Just like all the pain around v2 modules can be justified, even if I find it annoying.

When packages are also the only layer at which you can enforce visibility, it becomes worse.


See the last case of how to handle circular dependencies.

Ports are special cases. Always are.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: