New Upstream Release - golang-github-dustin-go-humanize

Ready changes

Summary

Merged new upstream version: 1.0.1 (was: 1.0.0).

Resulting package

Built on 2023-02-09T06:53 (took 2m10s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases golang-github-dustin-go-humanize-dev

Lintian Result

Diff

diff --git a/.travis.yml b/.travis.yml
index ba95cdd..ac12e48 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,12 +1,12 @@
 sudo: false
 language: go
+go_import_path: github.com/dustin/go-humanize
 go:
-  - 1.3.x
-  - 1.5.x
-  - 1.6.x
-  - 1.7.x
-  - 1.8.x
-  - 1.9.x
+  - 1.13.x
+  - 1.14.x
+  - 1.15.x
+  - 1.16.x
+  - stable
   - master
 matrix:
   allow_failures:
@@ -15,7 +15,7 @@ matrix:
 install:
   - # Do nothing. This is needed to prevent default install action "go get -t -v ./..." from happening here (we want it to happen inside script step).
 script:
-  - go get -t -v ./...
   - diff -u <(echo -n) <(gofmt -d -s .)
-  - go tool vet .
+  - go vet .
+  - go install -v -race ./...
   - go test -v -race ./...
diff --git a/README.markdown b/README.markdown
index 91b4ae5..7d0b16b 100644
--- a/README.markdown
+++ b/README.markdown
@@ -5,7 +5,7 @@ Just a few functions for helping humanize times and sizes.
 `go get` it as `github.com/dustin/go-humanize`, import it as
 `"github.com/dustin/go-humanize"`, use it as `humanize`.
 
-See [godoc](https://godoc.org/github.com/dustin/go-humanize) for
+See [godoc](https://pkg.go.dev/github.com/dustin/go-humanize) for
 complete documentation.
 
 ## Sizes
diff --git a/bigbytes.go b/bigbytes.go
index 1a2bf61..3b015fd 100644
--- a/bigbytes.go
+++ b/bigbytes.go
@@ -28,6 +28,10 @@ var (
 	BigZiByte = (&big.Int{}).Mul(BigEiByte, bigIECExp)
 	// BigYiByte is 1,024 z bytes in bit.Ints
 	BigYiByte = (&big.Int{}).Mul(BigZiByte, bigIECExp)
+	// BigRiByte is 1,024 y bytes in bit.Ints
+	BigRiByte = (&big.Int{}).Mul(BigYiByte, bigIECExp)
+	// BigQiByte is 1,024 r bytes in bit.Ints
+	BigQiByte = (&big.Int{}).Mul(BigRiByte, bigIECExp)
 )
 
 var (
@@ -51,6 +55,10 @@ var (
 	BigZByte = (&big.Int{}).Mul(BigEByte, bigSIExp)
 	// BigYByte is 1,000 SI z bytes in big.Ints
 	BigYByte = (&big.Int{}).Mul(BigZByte, bigSIExp)
+	// BigRByte is 1,000 SI y bytes in big.Ints
+	BigRByte = (&big.Int{}).Mul(BigYByte, bigSIExp)
+	// BigQByte is 1,000 SI r bytes in big.Ints
+	BigQByte = (&big.Int{}).Mul(BigRByte, bigSIExp)
 )
 
 var bigBytesSizeTable = map[string]*big.Int{
@@ -71,6 +79,10 @@ var bigBytesSizeTable = map[string]*big.Int{
 	"zb":  BigZByte,
 	"yib": BigYiByte,
 	"yb":  BigYByte,
+	"rib": BigRiByte,
+	"rb":  BigRByte,
+	"qib": BigQiByte,
+	"qb":  BigQByte,
 	// Without suffix
 	"":   BigByte,
 	"ki": BigKiByte,
@@ -89,6 +101,10 @@ var bigBytesSizeTable = map[string]*big.Int{
 	"zi": BigZiByte,
 	"y":  BigYByte,
 	"yi": BigYiByte,
+	"r":  BigRByte,
+	"ri": BigRiByte,
+	"q":  BigQByte,
+	"qi": BigQiByte,
 }
 
 var ten = big.NewInt(10)
@@ -115,7 +131,7 @@ func humanateBigBytes(s, base *big.Int, sizes []string) string {
 //
 // BigBytes(82854982) -> 83 MB
 func BigBytes(s *big.Int) string {
-	sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}
+	sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", "RB", "QB"}
 	return humanateBigBytes(s, bigSIExp, sizes)
 }
 
@@ -125,7 +141,7 @@ func BigBytes(s *big.Int) string {
 //
 // BigIBytes(82854982) -> 79 MiB
 func BigIBytes(s *big.Int) string {
-	sizes := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"}
+	sizes := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", "RiB", "QiB"}
 	return humanateBigBytes(s, bigIECExp, sizes)
 }
 
diff --git a/bigbytes_test.go b/bigbytes_test.go
index 236ad08..b613a73 100644
--- a/bigbytes_test.go
+++ b/bigbytes_test.go
@@ -66,7 +66,7 @@ func TestBigByteErrors(t *testing.T) {
 	if err == nil {
 		t.Errorf("Expected error, got %v", got)
 	}
-	got, err = ParseBigBytes("")
+	_, err = ParseBigBytes("")
 	if err == nil {
 		t.Errorf("Expected error parsing nothing")
 	}
@@ -161,12 +161,12 @@ func TestVeryBigBytes(t *testing.T) {
 func TestVeryVeryBigBytes(t *testing.T) {
 	b, _ := (&big.Int{}).SetString("16093220510709943573688614912", 10)
 	s := BigBytes(b)
-	if s != "16093 YB" {
-		t.Errorf("Expected 16093 YB, got %v", s)
+	if s != "16 RB" {
+		t.Errorf("Expected 16 RB, got %v", s)
 	}
 	s = BigIBytes(b)
-	if s != "13312 YiB" {
-		t.Errorf("Expected 13312 YiB, got %v", s)
+	if s != "13 RiB" {
+		t.Errorf("Expected 13 RiB, got %v", s)
 	}
 }
 
diff --git a/bytes_test.go b/bytes_test.go
index 0bb811c..83559e7 100644
--- a/bytes_test.go
+++ b/bytes_test.go
@@ -65,7 +65,7 @@ func TestByteErrors(t *testing.T) {
 	if err == nil {
 		t.Errorf("Expected error, got %v", got)
 	}
-	got, err = ParseBytes("")
+	_, err = ParseBytes("")
 	if err == nil {
 		t.Errorf("Expected error parsing nothing")
 	}
diff --git a/commaf.go b/commaf.go
index 620690d..2bc83a0 100644
--- a/commaf.go
+++ b/commaf.go
@@ -1,3 +1,4 @@
+//go:build go1.6
 // +build go1.6
 
 package humanize
diff --git a/commaf_test.go b/commaf_test.go
index 21f7f9e..d00bbc1 100644
--- a/commaf_test.go
+++ b/commaf_test.go
@@ -1,3 +1,4 @@
+//go:build go1.6
 // +build go1.6
 
 package humanize
diff --git a/debian/changelog b/debian/changelog
index a2a418a..10bc55f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+golang-github-dustin-go-humanize (1.0.1-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Thu, 09 Feb 2023 06:51:56 -0000
+
 golang-github-dustin-go-humanize (1.0.0-3) unstable; urgency=medium
 
   [ Debian Janitor ]
diff --git a/ftoa.go b/ftoa.go
index 1c62b64..bce923f 100644
--- a/ftoa.go
+++ b/ftoa.go
@@ -6,6 +6,9 @@ import (
 )
 
 func stripTrailingZeros(s string) string {
+	if !strings.ContainsRune(s, '.') {
+		return s
+	}
 	offset := len(s) - 1
 	for offset > 0 {
 		if s[offset] == '.' {
diff --git a/ftoa_test.go b/ftoa_test.go
index 45ef9c5..43c74d5 100644
--- a/ftoa_test.go
+++ b/ftoa_test.go
@@ -14,6 +14,7 @@ import (
 func TestFtoa(t *testing.T) {
 	testList{
 		{"200", Ftoa(200), "200"},
+		{"20", Ftoa(20.0), "20"},
 		{"2", Ftoa(2), "2"},
 		{"2.2", Ftoa(2.2), "2.2"},
 		{"2.02", Ftoa(2.02), "2.02"},
@@ -24,6 +25,7 @@ func TestFtoa(t *testing.T) {
 func TestFtoaWithDigits(t *testing.T) {
 	testList{
 		{"1.23, 0", FtoaWithDigits(1.23, 0), "1"},
+		{"20, 0", FtoaWithDigits(20.0, 0), "20"},
 		{"1.23, 1", FtoaWithDigits(1.23, 1), "1.2"},
 		{"1.23, 2", FtoaWithDigits(1.23, 2), "1.23"},
 		{"1.23, 3", FtoaWithDigits(1.23, 3), "1.23"},
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..b695cd8
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,3 @@
+module github.com/dustin/go-humanize
+
+go 1.16
diff --git a/number.go b/number.go
index dec6186..6470d0d 100644
--- a/number.go
+++ b/number.go
@@ -73,7 +73,7 @@ func FormatFloat(format string, n float64) string {
 	if n > math.MaxFloat64 {
 		return "Infinity"
 	}
-	if n < -math.MaxFloat64 {
+	if n < (0.0 - math.MaxFloat64) {
 		return "-Infinity"
 	}
 
diff --git a/ordinals_test.go b/ordinals_test.go
index 51d85ee..c478d5c 100644
--- a/ordinals_test.go
+++ b/ordinals_test.go
@@ -15,8 +15,14 @@ func TestOrdinals(t *testing.T) {
 		{"11", Ordinal(11), "11th"},
 		{"12", Ordinal(12), "12th"},
 		{"13", Ordinal(13), "13th"},
+		{"21", Ordinal(21), "21st"},
+		{"32", Ordinal(32), "32nd"},
+		{"43", Ordinal(43), "43rd"},
 		{"101", Ordinal(101), "101st"},
 		{"102", Ordinal(102), "102nd"},
 		{"103", Ordinal(103), "103rd"},
+		{"211", Ordinal(211), "211th"},
+		{"212", Ordinal(212), "212th"},
+		{"213", Ordinal(213), "213th"},
 	}.validate(t)
 }
diff --git a/si.go b/si.go
index ae659e0..8b85019 100644
--- a/si.go
+++ b/si.go
@@ -8,6 +8,8 @@ import (
 )
 
 var siPrefixTable = map[float64]string{
+	-30: "q", // quecto
+	-27: "r", // ronto
 	-24: "y", // yocto
 	-21: "z", // zepto
 	-18: "a", // atto
@@ -25,6 +27,8 @@ var siPrefixTable = map[float64]string{
 	18:  "E", // exa
 	21:  "Z", // zetta
 	24:  "Y", // yotta
+	27:  "R", // ronna
+	30:  "Q", // quetta
 }
 
 var revSIPrefixTable = revfmap(siPrefixTable)
diff --git a/si_test.go b/si_test.go
index e15fc69..3a129b4 100644
--- a/si_test.go
+++ b/si_test.go
@@ -11,6 +11,8 @@ func TestSI(t *testing.T) {
 		num       float64
 		formatted string
 	}{
+		{"e-30", 1e-30, "1 qF"},
+		{"e-27", 1e-27, "1 rF"},
 		{"e-24", 1e-24, "1 yF"},
 		{"e-21", 1e-21, "1 zF"},
 		{"e-18", 1e-18, "1 aF"},
@@ -54,6 +56,8 @@ func TestSI(t *testing.T) {
 		{"e+18", 2.2e+18, "2.2 EF"},
 		{"e+21", 2.2e+21, "2.2 ZF"},
 		{"e+24", 2.2e+24, "2.2 YF"},
+		{"e+27", 2.2e+27, "2.2 RF"},
+		{"e+30", 2.2e+30, "2.2 QF"},
 
 		// special case
 		{"1F", 1000 * 1000, "1 MF"},
@@ -122,3 +126,20 @@ func BenchmarkParseSI(b *testing.B) {
 		ParseSI("2.2346ZB")
 	}
 }
+
+// There was a report that zeroes were being truncated incorrectly
+func TestBug106(t *testing.T) {
+	tests := []struct{
+		in float64
+		want string
+	}{
+		{20.0, "20 U"},
+		{200.0, "200 U"},
+	}
+
+	for _, test := range tests {
+		if got :=SIWithDigits(test.in, 0, "U") ;  got != test.want {
+			t.Errorf("on %f got %v, want %v", test.in, got, test.want);
+		}
+	}
+}

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in second set of .debs but not in first

-rw-r--r--  root/root   /usr/share/gocode/src/github.com/dustin/go-humanize/go.mod

No differences were encountered in the control files

More details

Full run details