@@ -2072,7 +2072,8 @@ func (v Value) SetBool(x bool) {
2072
2072
}
2073
2073
2074
2074
// SetBytes sets v's underlying value.
2075
- // It panics if v's underlying value is not a slice of bytes.
2075
+ // It panics if v's underlying value is not a slice of bytes
2076
+ // or if [Value.CanSet] returns false.
2076
2077
func (v Value ) SetBytes (x []byte ) {
2077
2078
v .mustBeAssignable ()
2078
2079
v .mustBe (Slice )
@@ -2083,7 +2084,8 @@ func (v Value) SetBytes(x []byte) {
2083
2084
}
2084
2085
2085
2086
// setRunes sets v's underlying value.
2086
- // It panics if v's underlying value is not a slice of runes (int32s).
2087
+ // It panics if v's underlying value is not a slice of runes (int32s)
2088
+ // or if [Value.CanSet] returns false.
2087
2089
func (v Value ) setRunes (x []rune ) {
2088
2090
v .mustBeAssignable ()
2089
2091
v .mustBe (Slice )
@@ -2094,7 +2096,8 @@ func (v Value) setRunes(x []rune) {
2094
2096
}
2095
2097
2096
2098
// SetComplex sets v's underlying value to x.
2097
- // It panics if v's Kind is not [Complex64] or [Complex128], or if [Value.CanSet] returns false.
2099
+ // It panics if v's Kind is not [Complex64] or [Complex128],
2100
+ // or if [Value.CanSet] returns false.
2098
2101
func (v Value ) SetComplex (x complex128 ) {
2099
2102
v .mustBeAssignable ()
2100
2103
switch k := v .kind (); k {
@@ -2108,7 +2111,8 @@ func (v Value) SetComplex(x complex128) {
2108
2111
}
2109
2112
2110
2113
// SetFloat sets v's underlying value to x.
2111
- // It panics if v's Kind is not [Float32] or [Float64], or if [Value.CanSet] returns false.
2114
+ // It panics if v's Kind is not [Float32] or [Float64],
2115
+ // or if [Value.CanSet] returns false.
2112
2116
func (v Value ) SetFloat (x float64 ) {
2113
2117
v .mustBeAssignable ()
2114
2118
switch k := v .kind (); k {
@@ -2122,7 +2126,8 @@ func (v Value) SetFloat(x float64) {
2122
2126
}
2123
2127
2124
2128
// SetInt sets v's underlying value to x.
2125
- // It panics if v's Kind is not [Int], [Int8], [Int16], [Int32], or [Int64], or if [Value.CanSet] returns false.
2129
+ // It panics if v's Kind is not [Int], [Int8], [Int16], [Int32], or [Int64],
2130
+ // or if [Value.CanSet] returns false.
2126
2131
func (v Value ) SetInt (x int64 ) {
2127
2132
v .mustBeAssignable ()
2128
2133
switch k := v .kind (); k {
@@ -2142,8 +2147,9 @@ func (v Value) SetInt(x int64) {
2142
2147
}
2143
2148
2144
2149
// SetLen sets v's length to n.
2145
- // It panics if v's Kind is not [Slice] or if n is negative or
2146
- // greater than the capacity of the slice.
2150
+ // It panics if v's Kind is not [Slice], or if n is negative or
2151
+ // greater than the capacity of the slice,
2152
+ // or if [Value.CanSet] returns false.
2147
2153
func (v Value ) SetLen (n int ) {
2148
2154
v .mustBeAssignable ()
2149
2155
v .mustBe (Slice )
@@ -2155,8 +2161,9 @@ func (v Value) SetLen(n int) {
2155
2161
}
2156
2162
2157
2163
// SetCap sets v's capacity to n.
2158
- // It panics if v's Kind is not [Slice] or if n is smaller than the length or
2159
- // greater than the capacity of the slice.
2164
+ // It panics if v's Kind is not [Slice], or if n is smaller than the length or
2165
+ // greater than the capacity of the slice,
2166
+ // or if [Value.CanSet] returns false.
2160
2167
func (v Value ) SetCap (n int ) {
2161
2168
v .mustBeAssignable ()
2162
2169
v .mustBe (Slice )
@@ -2168,7 +2175,8 @@ func (v Value) SetCap(n int) {
2168
2175
}
2169
2176
2170
2177
// SetUint sets v's underlying value to x.
2171
- // It panics if v's Kind is not [Uint], [Uintptr], [Uint8], [Uint16], [Uint32], or [Uint64], or if [Value.CanSet] returns false.
2178
+ // It panics if v's Kind is not [Uint], [Uintptr], [Uint8], [Uint16], [Uint32], or [Uint64],
2179
+ // or if [Value.CanSet] returns false.
2172
2180
func (v Value ) SetUint (x uint64 ) {
2173
2181
v .mustBeAssignable ()
2174
2182
switch k := v .kind (); k {
@@ -2190,7 +2198,8 @@ func (v Value) SetUint(x uint64) {
2190
2198
}
2191
2199
2192
2200
// SetPointer sets the [unsafe.Pointer] value v to x.
2193
- // It panics if v's Kind is not [UnsafePointer].
2201
+ // It panics if v's Kind is not [UnsafePointer]
2202
+ // or if [Value.CanSet] returns false.
2194
2203
func (v Value ) SetPointer (x unsafe.Pointer ) {
2195
2204
v .mustBeAssignable ()
2196
2205
v .mustBe (UnsafePointer )
@@ -2558,8 +2567,8 @@ func arrayAt(p unsafe.Pointer, i int, eltSize uintptr, whySafe string) unsafe.Po
2558
2567
// another n elements. After Grow(n), at least n elements can be appended
2559
2568
// to the slice without another allocation.
2560
2569
//
2561
- // It panics if v's Kind is not a [Slice] or if n is negative or too large to
2562
- // allocate the memory.
2570
+ // It panics if v's Kind is not a [Slice], or if n is negative or too large to
2571
+ // allocate the memory, or if [Value.CanSet] returns false .
2563
2572
func (v Value ) Grow (n int ) {
2564
2573
v .mustBeAssignable ()
2565
2574
v .mustBe (Slice )
@@ -2647,6 +2656,7 @@ func AppendSlice(s, t Value) Value {
2647
2656
// It returns the number of elements copied.
2648
2657
// Dst and src each must have kind [Slice] or [Array], and
2649
2658
// dst and src must have the same element type.
2659
+ // It dst is an [Array], it panics if [Value.CanSet] returns false.
2650
2660
//
2651
2661
// As a special case, src can have kind [String] if the element type of dst is kind [Uint8].
2652
2662
func Copy (dst , src Value ) int {
0 commit comments