зеркало из https://github.com/Azure/ARO-RP.git
require Go 1.13
This commit is contained in:
Родитель
63392814b8
Коммит
4ab541182f
|
@ -4,7 +4,7 @@
|
|||
|
||||
1. Install the following:
|
||||
|
||||
* go 1.12 or later
|
||||
* go 1.13 or later
|
||||
* az client
|
||||
|
||||
1. Log in to Azure:
|
||||
|
|
|
@ -3,7 +3,6 @@ package arm
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
|
||||
uuid "github.com/satori/go.uuid"
|
||||
|
@ -95,7 +94,7 @@ func (r *Resource) MarshalJSON() ([]byte, error) {
|
|||
if idx, found := indexes[field.Name]; found {
|
||||
field.Type = emptyInterfaceType
|
||||
fields[idx] = field
|
||||
if !isZero(outer.Field(i)) {
|
||||
if !outer.Field(i).IsZero() {
|
||||
values[idx] = outer.Field(i)
|
||||
}
|
||||
} else {
|
||||
|
@ -210,7 +209,7 @@ func _shadowCopy(v reflect.Value) reflect.Value {
|
|||
|
||||
s := reflect.New(t).Elem()
|
||||
for i, v := range values {
|
||||
if !isZero(v) {
|
||||
if !v.IsZero() {
|
||||
s.Field(i).Set(v)
|
||||
}
|
||||
}
|
||||
|
@ -220,43 +219,3 @@ func _shadowCopy(v reflect.Value) reflect.Value {
|
|||
return v
|
||||
}
|
||||
}
|
||||
|
||||
// isZero is a copy of `func (v reflect.Value) IsZero() bool`, which is built-in
|
||||
// in from Go 1.13
|
||||
func isZero(v reflect.Value) bool {
|
||||
switch v.Kind() {
|
||||
case reflect.Bool:
|
||||
return !v.Bool()
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
return v.Int() == 0
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||
return v.Uint() == 0
|
||||
case reflect.Float32, reflect.Float64:
|
||||
return math.Float64bits(v.Float()) == 0
|
||||
case reflect.Complex64, reflect.Complex128:
|
||||
c := v.Complex()
|
||||
return math.Float64bits(real(c)) == 0 && math.Float64bits(imag(c)) == 0
|
||||
case reflect.Array:
|
||||
for i := 0; i < v.Len(); i++ {
|
||||
if !isZero(v.Index(i)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice, reflect.UnsafePointer:
|
||||
return v.IsNil()
|
||||
case reflect.String:
|
||||
return v.Len() == 0
|
||||
case reflect.Struct:
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
if !isZero(v.Field(i)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
default:
|
||||
// This should never happen, but will act as a safeguard for
|
||||
// later, as a default value doesn't makes sense here.
|
||||
panic(&reflect.ValueError{Method: "reflect.Value.IsZero", Kind: v.Kind()})
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче