splitfile aims to improve Go code readability by reducing the lines of code per file and ultimately improving the focus of files in a package.
splitfile identifies partitions of packages via the following method. First, a weighted directed graph is constructed, where nodes are type
, var
, const,
or func
declarations and weighted directed edges define the relationships between declarations and their uses.
splitfile identifies partitions by assigning configurable weights to edges (i.e., type -> method edges should probably be of a higher weight than type -> usage edges, but this is ultimately up to the user). Next, these weights are used by the distance function. After calculating the distance of all paths, partitions are identified by comparing the distance to a configurable epsilon value. Paths with a distance greater than epsilon will be partitioned, leaving path with a distance less than epsilon "clustered".
configurable: edge weights and epsilon can be configured via cli flags or a .splitfile.yml
file.