Some simple points that I think this code looks great:
-
Doesn't need any additional function(s)
-
Concise
if
case error handling, instead of:... if err != nil { return nil, err } // do the 13-rotation return l, nil
-
Only 2
switch
cases: lower and upper cases- Utilize mod (
%
) instead of dividing to 'A'-'M' and 'N'-'Z' additional cases
- Utilize mod (
-
Use the character representation (
'A'
,'Z'
,'a'
,'z'
) instead of others, such as65
(decimal ascii of 'A'),0x41
(hex ascii of 'A'), etc -
Arrange the range cases to looks like comparison chaining
'A' <= b[i] <= 'Z'
Another approaches: https://gist.github.com/flc/6439105