summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2019-12-03 21:24:47 +0000
committerMatthew Lemon <lemon@matthewlemon.com>2019-12-03 21:24:47 +0000
commit27aee57258f81ef6b381f45bbd4c0f337a201f67 (patch)
tree12dbe08033673153308351f81e4e66566548a9cf
parentf39a87827136188197ab34576d2d9b2d533505c0 (diff)
making colstream unexported and re-exporting the two funcs
-rw-r--r--coords.go14
-rw-r--r--coords_test.go12
2 files changed, 13 insertions, 13 deletions
diff --git a/coords.go b/coords.go
index 6dcff92..ee13dba 100644
--- a/coords.go
+++ b/coords.go
@@ -15,23 +15,23 @@ const (
// ColAlpha returns an alpha representation of a column index.
// index is an integer - ColAlpha(0) returns "A", etc.
-func colIndexToAlpha(index int) (string, error) {
- max := len(Colstream) - 1
+func ColIndexToAlpha(index int) (string, error) {
+ max := len(colstream) - 1
if index <= max {
- return Colstream[index], nil
+ return colstream[index], nil
} else {
msg := fmt.Sprintf("cannot have more than %d columns", max)
return "", errors.New(msg)
}
}
-var Colstream = cols(maxAlphabets)
+var colstream = cols(maxAlphabets)
// ColLettersToIndex converts an alpha column
// reference to a zero-based numeric column identifier.
-func colAlphaToIndex(letters string) (int, error) {
- max := len(Colstream) - 1
- for i, v := range Colstream {
+func ColAlphaToIndex(letters string) (int, error) {
+ max := len(colstream) - 1
+ for i, v := range colstream {
if i > max {
msg := fmt.Sprintf("Cannot exceed maximum of %d", max)
return 0, errors.New(msg)
diff --git a/coords_test.go b/coords_test.go
index 1d69ef1..8f8f865 100644
--- a/coords_test.go
+++ b/coords_test.go
@@ -5,12 +5,12 @@ import (
)
func TestAlphaStream(t *testing.T) {
- if Colstream[26] != "AA" {
- t.Errorf("The test expected AA, got %v.", Colstream[26])
+ if colstream[26] != "AA" {
+ t.Errorf("The test expected AA, got %v.", colstream[26])
}
- if len(Colstream) > maxCols {
+ if len(colstream) > maxCols {
t.Errorf(`Number of columns in alphastream exceeds Excel maximum.
- alphastream contains %d, maxCols is %d`, len(Colstream), maxCols)
+ alphastream contains %d, maxCols is %d`, len(colstream), maxCols)
}
}
@@ -66,7 +66,7 @@ func TestCollectLetters(t *testing.T) {
{"AA", 26},
}
for _, c := range cases {
- s, err := colAlphaToIndex(c.alpha)
+ s, err := ColAlphaToIndex(c.alpha)
if err != nil {
t.Fatal(err)
}
@@ -88,7 +88,7 @@ func TestGetColApha(t *testing.T) {
{16377, "XEX"},
}
for _, c := range cases {
- s, err := colIndexToAlpha(c.index)
+ s, err := ColIndexToAlpha(c.index)
if err != nil {
t.Fatal(err)
}