How should your Go project source be organized?

What are others doing?

Here are some big Go projects on GitHub (found via the search string “language:go size:>=100000”). The line counts are reported with cloc, I’ve made an effort to exclude vendored code embedded in the project repo, and I’m not looking at non-Go files.

Here are some medium-sized projects:

Smaller projects, at least Go-code wise:

Lots of code in package main

There are no modules or classes or other namespace systems in Go, outside of packages, so there’s a temptation to make packages just to create namespaces. But it feels like packages that aren’t reusable subsystems aren’t really packages.

One answer is to just have lots of code in package main. There’s always a ton of code that is unique to your program; for example, the specific command-line processing that you have.

Other notes

Excellent Open Source Go Projects

Go Report Card

Go Projects index

Architecture for a Golang Web App

Generic programming in Go using “go generate”

I assume you’ve read at least these

  • http://blog.golang.org/organizing-go-code
  • http://blog.golang.org/godoc-documenting-go-code