1 回答

TA貢獻(xiàn)1811條經(jīng)驗(yàn) 獲得超6個(gè)贊
您如何看待這樣重寫您的代碼(https://play.golang.org/p/Kf5VpQeuThx):
package main
import (
"encoding/xml"
"fmt"
"os"
)
type s2 struct {
XMLName xml.Name `xml:"q3:WMLS_AddToStore"`
XMLAttr string `xml:"xmlns:q3,attr"`
WMLtypeIn string `xml:"WMLtypeIn,omitempty" json:"WMLtypeIn,omitempty" yaml:"WMLtypeIn,omitempty"`
XMLin string `xml:"XMLin,omitempty" json:"XMLin,omitempty" yaml:"XMLin,omitempty"`
OptionsIn string `xml:"OptionsIn,omitempty" json:"OptionsIn,omitempty" yaml:"OptionsIn,omitempty"`
CapabilitiesIn string `xml:"CapabilitiesIn,omitempty" json:"CapabilitiesIn,omitempty" yaml:"CapabilitiesIn,omitempty"`
}
type s1 struct {
XMLName xml.Name `xml:"SOAP-ENV:Body"`
S2 s2
}
func main() {
x := &s1{
S2: s2{
XMLAttr: "http://www.foo.abr/message/120",
WMLtypeIn: "WMLtypeIn",
XMLin: "XMLin",
OptionsIn: "OptionsIn",
CapabilitiesIn: "CapabilitiesIn",
},
}
enc := xml.NewEncoder(os.Stdout)
enc.Indent("", " ")
if err := enc.Encode(x); err != nil {
fmt.Printf("error: %v\n", err)
}
}
- 1 回答
- 0 關(guān)注
- 152 瀏覽
添加回答
舉報(bào)