Repository: amzn/ion-go
Pull request #123 (2020-07-31 15:59:42)

update UnmarshaStr and NewReaderStr to UnmarshalString and NewReaderString
update ```UnmarshaStr``` and ```NewReaderStr``` to ```UnmarshalString``` and ```NewReaderString```.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.




Patch:
diff --git a/ion/catalog.go b/ion/catalog.go
index 099320b..f2fa672 100644
--- a/ion/catalog.go
+++ b/ion/catalog.go
@@ -78,8 +78,8 @@ func (s System) NewReader(in io.Reader) Reader {
 	return NewReaderCat(in, s.Catalog)
 }
 
-// NewReaderStr creates a new reader using this system's catalog.
-func (s System) NewReaderStr(in string) Reader {
+// NewReaderString creates a new reader using this system's catalog.
+func (s System) NewReaderString(in string) Reader {
 	return NewReaderCat(strings.NewReader(in), s.Catalog)
 }
 
@@ -95,9 +95,9 @@ func (s System) Unmarshal(data []byte, v interface{}) error {
 	return d.DecodeTo(v)
 }
 
-// UnmarshalStr unmarshals Ion data using this system's catalog.
-func (s System) UnmarshalStr(data string, v interface{}) error {
-	r := s.NewReaderStr(data)
+// UnmarshalString unmarshals Ion data using this system's catalog.
+func (s System) UnmarshalString(data string, v interface{}) error {
+	r := s.NewReaderString(data)
 	d := NewDecoder(r)
 	return d.DecodeTo(v)
 }
diff --git a/ion/reader.go b/ion/reader.go
index 47f0d5d..e5cfdee 100644
--- a/ion/reader.go
+++ b/ion/reader.go
@@ -171,8 +171,8 @@ func NewReader(in io.Reader) Reader {
 	return NewReaderCat(in, nil)
 }
 
-// NewReaderStr creates a new reader from a string.
-func NewReaderStr(str string) Reader {
+// NewReaderString creates a new reader from a string.
+func NewReaderString(str string) Reader {
 	return NewReader(strings.NewReader(str))
 }
 
diff --git a/ion/unmarshal.go b/ion/unmarshal.go
index 991a37d..864074b 100644
--- a/ion/unmarshal.go
+++ b/ion/unmarshal.go
@@ -35,8 +35,8 @@ func Unmarshal(data []byte, v interface{}) error {
 	return NewDecoder(NewReader(bytes.NewReader(data))).DecodeTo(v)
 }
 
-// UnmarshalStr unmarshals Ion data from a string to the given object.
-func UnmarshalStr(data string, v interface{}) error {
+// UnmarshalString unmarshals Ion data from a string to the given object.
+func UnmarshalString(data string, v interface{}) error {
 	return Unmarshal([]byte(data), v)
 }
 


Test patch:
diff --git a/ion/integration_test.go b/ion/integration_test.go
index 9f59dbc..f49dfd5 100644
--- a/ion/integration_test.go
+++ b/ion/integration_test.go
@@ -403,7 +403,7 @@ func handleEmbeddedDoc(t *testing.T, r Reader) []ionItem {
 		if err != nil {
 			t.Error("Must be string value.")
 		}
-		newReader := NewReaderStr(str)
+		newReader := NewReaderString(str)
 		for newReader.Next() {
 			values = append(values, readCurrentValue(t, newReader))
 		}
diff --git a/ion/textreader_test.go b/ion/textreader_test.go
index ecf0dee..eec88a7 100644
--- a/ion/textreader_test.go
+++ b/ion/textreader_test.go
@@ -24,7 +24,7 @@ import (
 )
 
 func TestIgnoreValues(t *testing.T) {
-	r := NewReaderStr("(skip ++ me / please) {skip: me, please: 0}\n[skip, me, please]\nfoo")
+	r := NewReaderString("(skip ++ me / please) {skip: me, please: 0}\n[skip, me, please]\nfoo")
 
 	_next(t, r, SexpType)
 	_next(t, r, StructType)
@@ -37,7 +37,7 @@ func TestIgnoreValues(t *testing.T) {
 func TestReadSexps(t *testing.T) {
 	test := func(str string, f containerhandler) {
 		t.Run(str, func(t *testing.T) {
-			r := NewReaderStr(str)
+			r := NewReaderString(str)
 			_sexp(t, r, f)
 			_eof(t, r)
 		})
@@ -66,7 +66,7 @@ func TestReadSexps(t *testing.T) {
 func TestStructs(t *testing.T) {
 	test := func(str string, f containerhandler) {
 		t.Run(str, func(t *testing.T) {
-			r := NewReaderStr(str)
+			r := NewReaderString(str)
 			_struct(t, r, f)
 			_eof(t, r)
 		})
@@ -95,7 +95,7 @@ func TestStructs(t *testing.T) {
 }
 
 func TestMultipleStructs(t *testing.T) {
-	r := NewReaderStr("{} {} {}")
+	r := NewReaderString("{} {} {}")
 
 	for i := 0; i < 3; i++ {
 		_struct(t, r, func(t *testing.T, r Reader) {
@@ -107,7 +107,7 @@ func TestMultipleStructs(t *testing.T) {
 }
 
 func TestNullStructs(t *testing.T) {
-	r := NewReaderStr("null.struct 'null'::{foo:bar}")
+	r := NewReaderString("null.struct 'null'::{foo:bar}")
 
 	_null(t, r, StructType)
 	_nextAF(t, r, StructType, nil, []string{"null"})
@@ -117,7 +117,7 @@ func TestNullStructs(t *testing.T) {
 func TestLists(t *testing.T) {
 	test := func(str string, f containerhandler) {
 		t.Run(str, func(t *testing.T) {
-			r := NewReaderStr(str)
+			r := NewReaderString(str)
 			_list(t, r, f)
 			_eof(t, r)
 		})
@@ -145,7 +145,7 @@ func TestReadNestedLists(t *testing.T) {
 		_eof(t, r)
 	}
 
-	r := NewReaderStr("[[], [[]]]")
+	r := NewReaderString("[[], [[]]]")
 
 	_list(t, r, func(t *testing.T, r Reader) {
 		_list(t, r, empty)
@@ -163,7 +163,7 @@ func TestReadNestedLists(t *testing.T) {
 func TestClobs(t *testing.T) {
 	test := func(str string, eval []byte) {
 		t.Run(str, func(t *testing.T) {
-			r := NewReaderStr(str)
+			r := NewReaderString(str)
 			_next(t, r, ClobType)
 
 			val, err := r.ByteValue()
@@ -187,7 +187,7 @@ func TestClobs(t *testing.T) {
 func TestBlobs(t *testing.T) {
 	test := func(str string, eval []byte) {
 		t.Run(str, func(t *testing.T) {
-			r := NewReaderStr(str)
+			r := NewReaderString(str)
 			_next(t, r, BlobType)
 
 			val, err := r.ByteValue()
@@ -210,7 +210,7 @@ func TestBlobs(t *testing.T) {
 func TestTimestamps(t *testing.T) {
 	testA := func(str string, etas []string, eval Timestamp) {
 		t.Run(str, func(t *testing.T) {
-			r := NewReaderStr(str)
+			r := NewReaderString(str)
 			_nextAF(t, r, TimestampType, nil, etas)
 
 			val, err := r.TimestampValue()
@@ -253,7 +253,7 @@ func TestDecimals(t *testing.T) {
 		t.Run(str, func(t *testing.T) {
 			ee := MustParseDecimal(eval)
 
-			r := NewReaderStr(str)
+			r := NewReaderString(str)
 			_nextAF(t, r, DecimalType, nil, etas)
 
 			val, err := r.DecimalValue()
@@ -285,7 +285,7 @@ func TestDecimals(t *testing.T) {
 func TestFloats(t *testing.T) {
 	testA := func(str string, etas []string, eval float64) {
 		t.Run(str, func(t *testing.T) {
-			r := NewReaderStr(str)
+			r := NewReaderString(str)
 			_floatAF(t, r, nil, etas, eval)
 			_eof(t, r)
 		})
@@ -307,7 +307,7 @@ func TestFloats(t *testing.T) {
 func TestInts(t *testing.T) {
 	test := func(str string, f func(*testing.T, Reader)) {
 		t.Run(str, func(t *testing.T) {
-			r := NewReaderStr(str)
+			r := NewReaderString(str)
 			_next(t, r, IntType)
 
 			f(t, r)
@@ -377,7 +377,7 @@ func TestInts(t *testing.T) {
 }
 
 func TestStrings(t *testing.T) {
-	r := NewReaderStr(`foo::"bar" "baz" 'a'::'b'::'''beep''' '''boop''' null.string`)
+	r := NewReaderString(`foo::"bar" "baz" 'a'::'b'::'''beep''' '''boop''' null.string`)
 
 	_stringAF(t, r, nil, []string{"foo"}, "bar")
 	_string(t, r, "baz")
@@ -388,7 +388,7 @@ func TestStrings(t *testing.T) {
 }
 
 func TestSymbols(t *testing.T) {
-	r := NewReaderStr("'null'::foo bar a::b::'baz' null.symbol")
+	r := NewReaderString("'null'::foo bar a::b::'baz' null.symbol")
 
 	_symbolAF(t, r, nil, []string{"null"}, "foo")
 	_symbol(t, r, "bar")
@@ -399,7 +399,7 @@ func TestSymbols(t *testing.T) {
 }
 
 func TestSpecialSymbols(t *testing.T) {
-	r := NewReaderStr("null\nnull.struct\ntrue\nfalse\nnan")
+	r := NewReaderString("null\nnull.struct\ntrue\nfalse\nnan")
 
 	_null(t, r, NullType)
 	_null(t, r, StructType)
@@ -411,7 +411,7 @@ func TestSpecialSymbols(t *testing.T) {
 }
 
 func TestOperators(t *testing.T) {
-	r := NewReaderStr("(a*(b+c))")
+	r := NewReaderString("(a*(b+c))")
 
 	_sexp(t, r, func(t *testing.T, r Reader) {
 		_symbol(t, r, "a")
@@ -427,7 +427,7 @@ func TestOperators(t *testing.T) {
 }
 
 func TestTopLevelOperators(t *testing.T) {
-	r := NewReaderStr("a + b")
+	r := NewReaderString("a + b")
 
 	_symbol(t, r, "a")
 
@@ -449,7 +449,7 @@ func TestTrsToString(t *testing.T) {
 }
 
 func TestInStruct(t *testing.T) {
-	r := NewReaderStr("[ { a:() } ]")
+	r := NewReaderString("[ { a:() } ]")
 
 	r.Next()
 	r.StepIn() // In the list, before the struct
diff --git a/ion/unmarshal_test.go b/ion/unmarshal_test.go
index 2ac2e34..b8ac798 100644
--- a/ion/unmarshal_test.go
+++ b/ion/unmarshal_test.go
@@ -28,7 +28,7 @@ func TestUnmarshalBool(t *testing.T) {
 	test := func(str string, eval bool) {
 		t.Run(str, func(t *testing.T) {
 			var val bool
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -49,7 +49,7 @@ func TestUnmarshalBoolPtr(t *testing.T) {
 		t.Run(str, func(t *testing.T) {
 			var bval bool
 			val := &bval
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -79,7 +79,7 @@ func TestUnmarshalInt(t *testing.T) {
 	testInt8 := func(str string, eval int8) {
 		t.Run(str, func(t *testing.T) {
 			var val int8
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -97,7 +97,7 @@ func TestUnmarshalInt(t *testing.T) {
 	testInt16 := func(str string, eval int16) {
 		t.Run(str, func(t *testing.T) {
 			var val int16
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -115,7 +115,7 @@ func TestUnmarshalInt(t *testing.T) {
 	testInt32 := func(str string, eval int32) {
 		t.Run(str, func(t *testing.T) {
 			var val int32
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -133,7 +133,7 @@ func TestUnmarshalInt(t *testing.T) {
 	testInt := func(str string, eval int) {
 		t.Run(str, func(t *testing.T) {
 			var val int
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -151,7 +151,7 @@ func TestUnmarshalInt(t *testing.T) {
 	testInt64 := func(str string, eval int64) {
 		t.Run(str, func(t *testing.T) {
 			var val int64
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -171,7 +171,7 @@ func TestUnmarshalUint(t *testing.T) {
 	testUint8 := func(str string, eval uint8) {
 		t.Run(str, func(t *testing.T) {
 			var val uint8
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -188,7 +188,7 @@ func TestUnmarshalUint(t *testing.T) {
 	testUint16 := func(str string, eval uint16) {
 		t.Run(str, func(t *testing.T) {
 			var val uint16
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -204,7 +204,7 @@ func TestUnmarshalUint(t *testing.T) {
 	testUint32 := func(str string, eval uint32) {
 		t.Run(str, func(t *testing.T) {
 			var val uint32
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -220,7 +220,7 @@ func TestUnmarshalUint(t *testing.T) {
 	testUint := func(str string, eval uint) {
 		t.Run(str, func(t *testing.T) {
 			var val uint
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -236,7 +236,7 @@ func TestUnmarshalUint(t *testing.T) {
 	testUintptr := func(str string, eval uintptr) {
 		t.Run(str, func(t *testing.T) {
 			var val uintptr
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -252,7 +252,7 @@ func TestUnmarshalUint(t *testing.T) {
 	testUint64 := func(str string, eval uint64) {
 		t.Run(str, func(t *testing.T) {
 			var val uint64
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -270,7 +270,7 @@ func TestUnmarshalBigInt(t *testing.T) {
 	test := func(str string, eval *big.Int) {
 		t.Run(str, func(t *testing.T) {
 			var val big.Int
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -415,7 +415,7 @@ func TestUnmarshalListSexpBinary(t *testing.T) {
 func TestDecodeFloat(t *testing.T) {
 	test32 := func(str string, eval float32) {
 		t.Run(str, func(t *testing.T) {
-			d := NewDecoder(NewReaderStr(str))
+			d := NewDecoder(NewReaderString(str))
 
 			var val float32
 			err := d.DecodeTo(&val)
@@ -435,7 +435,7 @@ func TestDecodeFloat(t *testing.T) {
 
 	test64 := func(str string, eval float64) {
 		t.Run(str, func(t *testing.T) {
-			d := NewDecoder(NewReaderStr(str))
+			d := NewDecoder(NewReaderString(str))
 
 			var val float64
 			err := d.DecodeTo(&val)
@@ -456,7 +456,7 @@ func TestDecodeFloat(t *testing.T) {
 func TestDecodeDecimal(t *testing.T) {
 	test := func(str string, eval *Decimal) {
 		t.Run(str, func(t *testing.T) {
-			d := NewDecoder(NewReaderStr(str))
+			d := NewDecoder(NewReaderString(str))
 
 			var val *Decimal
 			err := d.DecodeTo(&val)
@@ -477,7 +477,7 @@ func TestDecodeDecimal(t *testing.T) {
 func TestDecodeTimestampTo(t *testing.T) {
 	test := func(str string, eval Timestamp) {
 		t.Run(str, func(t *testing.T) {
-			d := NewDecoder(NewReaderStr(str))
+			d := NewDecoder(NewReaderString(str))
 
 			var val Timestamp
 			err := d.DecodeTo(&val)
@@ -497,7 +497,7 @@ func TestDecodeTimestampTo(t *testing.T) {
 func TestDecodeStringTo(t *testing.T) {
 	test := func(str string, eval string) {
 		t.Run(str, func(t *testing.T) {
-			d := NewDecoder(NewReaderStr(str))
+			d := NewDecoder(NewReaderString(str))
 
 			var val string
 			err := d.DecodeTo(&val)
@@ -519,7 +519,7 @@ func TestDecodeStringTo(t *testing.T) {
 func TestDecodeLobTo(t *testing.T) {
 	testSlice := func(str string, eval []byte) {
 		t.Run(str, func(t *testing.T) {
-			d := NewDecoder(NewReaderStr(str))
+			d := NewDecoder(NewReaderString(str))
 
 			var val []byte
 			err := d.DecodeTo(&val)
@@ -539,7 +539,7 @@ func TestDecodeLobTo(t *testing.T) {
 
 	testArray := func(str string, eval []byte) {
 		t.Run(str, func(t *testing.T) {
-			d := NewDecoder(NewReaderStr(str))
+			d := NewDecoder(NewReaderString(str))
 
 			var val [8]byte
 			err := d.DecodeTo(&val)
@@ -559,7 +559,7 @@ func TestDecodeLobTo(t *testing.T) {
 func TestDecodeStructTo(t *testing.T) {
 	test := func(str string, val, eval interface{}) {
 		t.Run(str, func(t *testing.T) {
-			d := NewDecoder(NewReaderStr(str))
+			d := NewDecoder(NewReaderString(str))
 			err := d.DecodeTo(val)
 			if err != nil {
 				t.Fatal(err)
@@ -589,7 +589,7 @@ func TestDecodeStructTo(t *testing.T) {
 func TestDecodeListTo(t *testing.T) {
 	test := func(str string, val, eval interface{}) {
 		t.Run(str, func(t *testing.T) {
-			d := NewDecoder(NewReaderStr(str))
+			d := NewDecoder(NewReaderString(str))
 			err := d.DecodeTo(val)
 			if err != nil {
 				t.Fatal(err)
@@ -621,7 +621,7 @@ func TestDecodeListTo(t *testing.T) {
 func TestDecode(t *testing.T) {
 	test := func(data string, eval interface{}) {
 		t.Run(data, func(t *testing.T) {
-			d := NewDecoder(NewReaderStr(data))
+			d := NewDecoder(NewReaderString(data))
 			val, err := d.Decode()
 			if err != nil {
 				t.Fatal(err)
@@ -723,7 +723,7 @@ func TestUnmarshalWithAnnotation(t *testing.T) {
 	test := func(str, testName string, eval foo) {
 		t.Run(testName, func(t *testing.T) {
 			var val foo
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -757,7 +757,7 @@ func TestUnmarshalContainersWithAnnotation(t *testing.T) {
 	test := func(str, testName string, eval interface{}) {
 		t.Run(testName, func(t *testing.T) {
 			var val foo
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}
@@ -791,7 +791,7 @@ func TestUnmarshalNestedStructsWithAnnotation(t *testing.T) {
 	test := func(str, testName string, eval interface{}) {
 		t.Run(testName, func(t *testing.T) {
 			var val topLevelStruct
-			err := UnmarshalStr(str, &val)
+			err := UnmarshalString(str, &val)
 			if err != nil {
 				t.Fatal(err)
 			}