New Upstream Release - golang-github-kolo-xmlrpc

Ready changes

Summary

Merged new upstream version: 0.0~git20220921.a4b6fa1 (was: 0.0~git20200310.e035052).

Resulting package

Built on 2023-05-29T06:05 (took 4m22s)

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-kolo-xmlrpc-dev

Lintian Result

Diff

diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
new file mode 100644
index 0000000..8860de6
--- /dev/null
+++ b/.github/workflows/go.yml
@@ -0,0 +1,25 @@
+name: Go
+
+on:
+  push:
+    branches: [ "master" ]
+  pull_request:
+    branches: [ "master" ]
+
+jobs:
+
+  build:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v3
+
+    - name: Set up Go
+      uses: actions/setup-go@v3
+      with:
+        go-version: 1.18
+
+    - name: Build
+      run: go build -v ./...
+
+    - name: Test
+      run: go test -v ./...
diff --git a/README.md b/README.md
index fecfcd8..03ff0b1 100644
--- a/README.md
+++ b/README.md
@@ -50,6 +50,7 @@ Structs encoded to struct by following rules:
 * field name become member name;
 * if field has xmlrpc tag, its value become member name.
 * for fields tagged with `",omitempty"`, empty values are omitted;
+* fields tagged with `"-"` are omitted.
 
 Server method can accept few arguments, to handle this case there is
 special approach to handle slice of empty interfaces (`[]interface{}`).
diff --git a/debian/changelog b/debian/changelog
index 08257f8..38c6779 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,9 @@
-golang-github-kolo-xmlrpc (0.0~git20200310.e035052-3) UNRELEASED; urgency=medium
+golang-github-kolo-xmlrpc (0.0~git20220921.a4b6fa1-1) UNRELEASED; urgency=medium
 
   * Wrap long lines in changelog entries: 0.0~git20200310.e035052-2.
+  * New upstream snapshot.
 
- -- Debian Janitor <janitor@jelmer.uk>  Sat, 07 Jan 2023 23:44:22 -0000
+ -- Debian Janitor <janitor@jelmer.uk>  Mon, 29 May 2023 06:01:42 -0000
 
 golang-github-kolo-xmlrpc (0.0~git20200310.e035052-2) unstable; urgency=medium
 
diff --git a/decoder.go b/decoder.go
index d4dcb19..d5a70b2 100644
--- a/decoder.go
+++ b/decoder.go
@@ -149,11 +149,15 @@ func (dec *decoder) decodeValue(val reflect.Value) error {
 				fieldVal := val.FieldByName(field.Name)
 
 				if fieldVal.CanSet() {
-					if fn := field.Tag.Get("xmlrpc"); fn != "" {
-						fields[fn] = fieldVal
-					} else {
-						fields[field.Name] = fieldVal
+					name := field.Tag.Get("xmlrpc")
+					name = strings.TrimSuffix(name, ",omitempty")
+					if name == "-" {
+						continue
 					}
+					if name == "" {
+						name = field.Name
+					}
+					fields[name] = fieldVal
 				}
 			}
 		} else {
diff --git a/encoder.go b/encoder.go
index 7ab271a..84de817 100644
--- a/encoder.go
+++ b/encoder.go
@@ -95,8 +95,12 @@ func encodeStruct(structVal reflect.Value) ([]byte, error) {
 		fieldType := structType.Field(i)
 
 		name := fieldType.Tag.Get("xmlrpc")
+		// skip ignored fields.
+		if name == "-" {
+			continue
+		}
 		// if the tag has the omitempty property, skip it
-		if strings.HasSuffix(name, ",omitempty") && isZero(fieldVal) {
+		if strings.HasSuffix(name, ",omitempty") && fieldVal.IsZero() {
 			continue
 		}
 		name = strings.TrimSuffix(name, ",omitempty")
diff --git a/encoder_test.go b/encoder_test.go
index be66a4d..c786d88 100644
--- a/encoder_test.go
+++ b/encoder_test.go
@@ -55,6 +55,12 @@ var marshalTests = []struct {
 	}, "<value><struct><member><name>Title</name><value><string>War and Piece</string></value></member><member><name>Amount</name><value><int>20</int></value></member><member><name>author</name><value><string>Leo Tolstoy</string></value></member></struct></value>"},
 	{&struct {
 	}{}, "<value><struct></struct></value>"},
+	{&struct {
+		ID   int    `xmlrpc:"id"`
+		Name string `xmlrpc:"-"`
+	}{
+		ID: 123, Name: "kolo",
+	}, "<value><struct><member><name>id</name><value><int>123</int></value></member></struct></value>"},
 }
 
 func Test_marshal(t *testing.T) {
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..42e7acd
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,5 @@
+module github.com/kolo/xmlrpc
+
+go 1.14
+
+require golang.org/x/text v0.3.3
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..fd5b10f
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,3 @@
+golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
diff --git a/is_zero.go b/is_zero.go
deleted file mode 100644
index 65276d0..0000000
--- a/is_zero.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package xmlrpc
-
-import (
-	"math"
-	. "reflect"
-)
-
-func isZero(v Value) bool {
-	switch v.Kind() {
-	case Bool:
-		return !v.Bool()
-	case Int, Int8, Int16, Int32, Int64:
-		return v.Int() == 0
-	case Uint, Uint8, Uint16, Uint32, Uint64, Uintptr:
-		return v.Uint() == 0
-	case Float32, Float64:
-		return math.Float64bits(v.Float()) == 0
-	case Complex64, Complex128:
-		c := v.Complex()
-		return math.Float64bits(real(c)) == 0 && math.Float64bits(imag(c)) == 0
-	case Array:
-		for i := 0; i < v.Len(); i++ {
-			if !isZero(v.Index(i)) {
-				return false
-			}
-		}
-		return true
-	case Chan, Func, Interface, Map, Ptr, Slice, UnsafePointer:
-		return v.IsNil()
-	case String:
-		return v.Len() == 0
-	case Struct:
-		for i := 0; i < v.NumField(); i++ {
-			if !isZero(v.Field(i)) {
-				return false
-			}
-		}
-		return true
-	default:
-		// This should never happens, but will act as a safeguard for
-		// later, as a default value doesn't makes sense here.
-		panic(&ValueError{"reflect.Value.IsZero", v.Kind()})
-	}
-}

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/kolo/xmlrpc/go.mod
-rw-r--r--  root/root   /usr/share/gocode/src/github.com/kolo/xmlrpc/go.sum

Files in first set of .debs but not in second

-rw-r--r--  root/root   /usr/share/gocode/src/github.com/kolo/xmlrpc/is_zero.go

No differences were encountered in the control files

More details

Full run details