Thanks for the comments! I really should be passing in just the string as you've pointed out, there is no reason to use the pointer. My thinking in making this a function on its own was to be able to write tests for it later, which I suppose means I had better be checking for that pointer. I'm not sure just wrapping reading a file into a function is worth it just to be able to write a test down the road though so it might be worth doing it away with it entirely.
Definitely, something for me to consider. Thanks again!
Worth considering as well that using a Reader rather than a concrete file here will make testing this easier later anyway, since you'll be able to use anyReader. not just a file, you can mock your input using buffers or any old strings.NewReader("thing")!
Thanks for the comments! I really should be passing in just the string as you've pointed out, there is no reason to use the pointer. My thinking in making this a function on its own was to be able to write tests for it later, which I suppose means I had better be checking for that pointer. I'm not sure just wrapping reading a file into a function is worth it just to be able to write a test down the road though so it might be worth doing it away with it entirely.
Definitely, something for me to consider. Thanks again!
Worth considering as well that using a
Reader
rather than a concrete file here will make testing this easier later anyway, since you'll be able to use anyReader
. not just a file, you can mock your input using buffers or any oldstrings.NewReader("thing")
!Thanks for taking the time to respond.
That is a fantastic point! I think using a
Reader
is going to be the way I go.