util: Handle negative values for NumToAlpha
This shouldn't be used often, but it makes writing some kinds of code easier.
This commit is contained in:
@@ -33,6 +33,9 @@ import (
|
||||
// you specify 0, you'll get `a`, 25 gives you `z`, and 26 gives you `aa` and so
|
||||
// on...
|
||||
func NumToAlpha(idx int) string {
|
||||
if idx < 0 {
|
||||
return "" // don't error or produce junk
|
||||
}
|
||||
var mod = idx % 26
|
||||
var div = idx / 26
|
||||
if div > 0 {
|
||||
|
||||
Reference in New Issue
Block a user