Estimating the average size of a file in a Go project (or any software project) largely depends on the nature of the project, the coding style of the developer(s), and what libraries are being used. However, for a broad sense of what you might expect in a general context, we can make some assumptions.
Typically, Go projects are well-appreciated for their simplicity and readability, and developers often aim to keep their packages and files reasonably scoped. That said, in a typical side project that involves experimenting with libraries, you might expect a mixture of small utility files, possibly some larger files where complex logic is implemented, and test files.
Given a broad range of possible file sizes, a rough, very general average might be something like this:
- Small utility or library wrapper files: 100-500 lines
- Main application or complex logic files: 500-2000 lines
- Test files: Can vary widely, but often similar in size to the file they are testing
Translating lines of code to file size in bytes is imprecise without knowing more about the coding style (e.g., verbosity, use of comments) and the average line length. However, if we make a very rough approximation that an average line of Go code is around 40 characters long (which could translate roughly to 40 bytes assuming ASCII encoding and not accounting for potential Unicode characters), we can do some rough math.
Taking the examples above:
- Small files might then be approximately between 4 KB and 20 KB.
- Larger logic files might range from 20 KB up to 80 KB.
Considering an average across these types might lead us to estimate that an "average" file size might be in the realm of 10-50 KB for a Go side project, emphasizing that variation could be significant based on the project's nature and scope.
It's important to note this estimate leans on several simplifications and assumptions, and real-world projects can deviate substantially. For instance, a Go project that includes static assets or generated code files could have very different characteristics. Ultimately, inspecting a representative sample of files from similar projects could offer more precise insights for a given case.