deps: update images to 0.94

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
This commit is contained in:
Simon de Vlieger 2024-10-25 09:00:38 +02:00 committed by Sanne Raymaekers
parent 4f90a757dc
commit bccd1639af
1096 changed files with 411794 additions and 11488 deletions

View file

@ -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{}`).

View file

@ -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 {

View file

@ -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")

View file

@ -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()})
}
}