Memo of Golang Part 1
Based on Go v1.15
In the recent practice of Golang, there’re many trivial knowledges that worthy to be memorized in daily coding. So I came up with the idea to have this series basicly for my own memorization. if it helps anyone else, it would be great.
Comments and error messages convention
The convention has been defined in Effective Go, but there’re something that might be hard to notice.
-
A comment for packages or functions, etc should be ended with a period. Using such punctuations increases the readablity of comments.
//Repeat returns a string that repeats given string N times.
-
An error message shouldn’t have the initial letter upper case unless there’s certain acronym and use any ending punctuation.
errors.New("oops, there're something wrong