Hey, nice post series. I always learn something new from it.
What would you think of renaming some functions to make them more unambiguous? I know, Go is known for making names as short as possible, but ... 🤔
For example
func getContents(f *string) ([]byte, error) {}
The code within explains itself, as it is short enough, but if you read only the function signature, it is not quit clear. Does it get the content of a string and returns it as a byte slice? What, if the function gets longer? I would have to skim a lot more code to understand it.
How about
func getFileContent(f string)
or
func getContent(file string)
And why do you use a reference to the ˋfileˋ string instead of a simple value?
Another one would be
func parseFM()
Abbreviations are hard to follow, it not within the closed context of a function. Maybe
Thanks for the comment! It would definitely make it clearer. I always go back and forth on names, I've been thinking about learning more toward descriptive functions like getFileContent(f string) especially for stuff I'm going to be posting. Now, is probably a good time to try and commit to that. I can't remember why I wrote it that way and didn't just send in a string. It's not like we're memory constrained it doesn't need to be that way and the passed in string would just be garbage collected eventually.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey, nice post series. I always learn something new from it.
What would you think of renaming some functions to make them more unambiguous? I know, Go is known for making names as short as possible, but ... 🤔
For example
The code within explains itself, as it is short enough, but if you read only the function signature, it is not quit clear. Does it get the content of a string and returns it as a byte slice? What, if the function gets longer? I would have to skim a lot more code to understand it.
How about
or
And why do you use a reference to the ˋfileˋ string instead of a simple value?
Another one would be
Abbreviations are hard to follow, it not within the closed context of a function. Maybe
would make it instantly clear?!
Looking forward to your next post.
Thanks for the comment! It would definitely make it clearer. I always go back and forth on names, I've been thinking about learning more toward descriptive functions like
getFileContent(f string)
especially for stuff I'm going to be posting. Now, is probably a good time to try and commit to that. I can't remember why I wrote it that way and didn't just send in a string. It's not like we're memory constrained it doesn't need to be that way and the passed in string would just be garbage collected eventually.