Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
👋
As promised, here's a very small first step on refactoring memgator. I've intentionally kept the changes very light, as we don't have a test suite in place.
This PR refactors the
dataCh
argument toserializeLinks
, changing it's type fromdataCh chan string
todataCh chan fmt.Stringer
. All processes that read fromdataCh
now call.String()
on the result to get the string they would previously output.Which may seem like a small change, it opens up a number of improvements down the road, (which we can make with incremental PRs). Instead of the channel needing to accept an explicit string, it now accepts anything that can produce a string, we end up using this new feature immediately in the
serializeLinks
func, passing back raw buffers (bytes.Buffer
has a built-inString() string
method). And this sets the stage for returning one or more custom structs, each with a string method that cleans up the code inside the formatting switch ofserializeLinks
.I'd recommend checking extensively on your end to make sure I haven't broken anything☺️ , but if you're into this PR there are a number of change we can make from here as a team. Feedback of all kinds welcomed.