You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when some value is <tt:PTZPosition /> how can I check the value is nil when xml Unmarshal. I try use pointer.but the value is not nil(Zoom attributes is 0 I can not confirm 0 value is pass by xml value).
Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.
when some value is <tt:PTZPosition /> how can I check the value is nil when xml Unmarshal. I try use pointer.but the value is not nil(Zoom attributes is 0 I can not confirm 0 value is pass by xml value).
Example code:https://go.dev/play/p/BrgD4S--Rmf
code:
package main
import (
"encoding/xml"
"fmt"
)
type Vector1D struct {
X float64
xml:"x,attr"
}
type PTZVector struct {
Zoom Vector1D
xml:"Zoom"
}
type PTZPresetTourPresetDetailUnmarshal struct {
PTZPosition *PTZVector
xml:"PTZPosition"
}
func main() {
str :=
<tt:PresetDetail> <tt:PTZPosition /> </tt:PresetDetail>
var ans PTZPresetTourPresetDetailUnmarshal
err := xml.Unmarshal([]byte(str), &ans)
if err != nil {
panic(err)
}
fmt.Printf(
%#v
, ans.PTZPosition)}
result:
&main.PTZVector{Zoom:main.Vector1D{X:0}}
The text was updated successfully, but these errors were encountered: