ires 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -45
- data/ext/Gopkg.lock +31 -1
- data/ext/ires/image.go +227 -0
- data/ext/ires/ires.go +47 -59
- data/ext/ires/uri.go +143 -0
- data/ext/main.go +18 -9
- data/ext/vendor/github.com/PuerkitoBio/purell/LICENSE +12 -0
- data/ext/vendor/github.com/PuerkitoBio/purell/README.md +187 -0
- data/ext/vendor/github.com/PuerkitoBio/purell/bench_test.go +57 -0
- data/ext/vendor/github.com/PuerkitoBio/purell/benchmarks/v0.1.0 +9 -0
- data/ext/vendor/github.com/PuerkitoBio/purell/example_test.go +35 -0
- data/ext/vendor/github.com/PuerkitoBio/purell/purell.go +379 -0
- data/ext/vendor/github.com/PuerkitoBio/purell/purell_test.go +768 -0
- data/ext/vendor/github.com/PuerkitoBio/purell/urlnorm_test.go +53 -0
- data/ext/vendor/github.com/PuerkitoBio/urlesc/LICENSE +27 -0
- data/ext/vendor/github.com/PuerkitoBio/urlesc/README.md +16 -0
- data/ext/vendor/github.com/PuerkitoBio/urlesc/urlesc.go +180 -0
- data/ext/vendor/github.com/PuerkitoBio/urlesc/urlesc_test.go +641 -0
- data/ext/vendor/github.com/{satori/go.uuid → goware/urlx}/LICENSE +3 -1
- data/ext/vendor/github.com/goware/urlx/README.md +172 -0
- data/ext/vendor/github.com/goware/urlx/urlx.go +196 -0
- data/ext/vendor/github.com/goware/urlx/urlx_test.go +232 -0
- data/ext/vendor/golang.org/x/net/AUTHORS +3 -0
- data/ext/vendor/golang.org/x/net/CONTRIBUTING.md +31 -0
- data/ext/vendor/golang.org/x/net/CONTRIBUTORS +3 -0
- data/ext/vendor/golang.org/x/net/LICENSE +27 -0
- data/ext/vendor/golang.org/x/net/PATENTS +22 -0
- data/ext/vendor/golang.org/x/net/README.md +16 -0
- data/ext/vendor/golang.org/x/net/bpf/asm.go +41 -0
- data/ext/vendor/golang.org/x/net/bpf/constants.go +218 -0
- data/ext/vendor/golang.org/x/net/bpf/doc.go +82 -0
- data/ext/vendor/golang.org/x/net/bpf/instructions.go +704 -0
- data/ext/vendor/golang.org/x/net/bpf/instructions_test.go +525 -0
- data/ext/vendor/golang.org/x/net/bpf/setter.go +10 -0
- data/ext/vendor/golang.org/x/net/bpf/testdata/all_instructions.bpf +1 -0
- data/ext/vendor/golang.org/x/net/bpf/testdata/all_instructions.txt +79 -0
- data/ext/vendor/golang.org/x/net/bpf/vm.go +140 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_aluop_test.go +512 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_bpf_test.go +192 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_extension_test.go +49 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_instructions.go +174 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_jump_test.go +380 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_load_test.go +246 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_ret_test.go +115 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_scratch_test.go +247 -0
- data/ext/vendor/golang.org/x/net/bpf/vm_test.go +144 -0
- data/ext/vendor/golang.org/x/net/codereview.cfg +1 -0
- data/ext/vendor/golang.org/x/net/context/context.go +54 -0
- data/ext/vendor/golang.org/x/net/context/context_test.go +583 -0
- data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go +74 -0
- data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_17_test.go +29 -0
- data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go +147 -0
- data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17_test.go +79 -0
- data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_test.go +105 -0
- data/ext/vendor/golang.org/x/net/context/go17.go +72 -0
- data/ext/vendor/golang.org/x/net/context/go19.go +20 -0
- data/ext/vendor/golang.org/x/net/context/pre_go17.go +300 -0
- data/ext/vendor/golang.org/x/net/context/pre_go19.go +109 -0
- data/ext/vendor/golang.org/x/net/context/withtimeout_test.go +31 -0
- data/ext/vendor/golang.org/x/net/dict/dict.go +210 -0
- data/ext/vendor/golang.org/x/net/dns/dnsmessage/example_test.go +132 -0
- data/ext/vendor/golang.org/x/net/dns/dnsmessage/message.go +1997 -0
- data/ext/vendor/golang.org/x/net/dns/dnsmessage/message_test.go +1116 -0
- data/ext/vendor/golang.org/x/net/html/atom/atom.go +78 -0
- data/ext/vendor/golang.org/x/net/html/atom/atom_test.go +109 -0
- data/ext/vendor/golang.org/x/net/html/atom/gen.go +709 -0
- data/ext/vendor/golang.org/x/net/html/atom/table.go +777 -0
- data/ext/vendor/golang.org/x/net/html/atom/table_test.go +373 -0
- data/ext/vendor/golang.org/x/net/html/charset/charset.go +257 -0
- data/ext/vendor/golang.org/x/net/html/charset/charset_test.go +237 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/HTTP-charset.html +48 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-UTF-8-BOM.html +48 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-charset.html +49 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-content.html +49 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/No-encoding-declaration.html +47 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/README +9 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/UTF-16BE-BOM.html +0 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/UTF-16LE-BOM.html +0 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-charset.html +49 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-content.html +48 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/meta-charset-attribute.html +48 -0
- data/ext/vendor/golang.org/x/net/html/charset/testdata/meta-content-attribute.html +48 -0
- data/ext/vendor/golang.org/x/net/html/const.go +104 -0
- data/ext/vendor/golang.org/x/net/html/doc.go +106 -0
- data/ext/vendor/golang.org/x/net/html/doctype.go +156 -0
- data/ext/vendor/golang.org/x/net/html/entity.go +2253 -0
- data/ext/vendor/golang.org/x/net/html/entity_test.go +29 -0
- data/ext/vendor/golang.org/x/net/html/escape.go +258 -0
- data/ext/vendor/golang.org/x/net/html/escape_test.go +97 -0
- data/ext/vendor/golang.org/x/net/html/example_test.go +40 -0
- data/ext/vendor/golang.org/x/net/html/foreign.go +226 -0
- data/ext/vendor/golang.org/x/net/html/node.go +193 -0
- data/ext/vendor/golang.org/x/net/html/node_test.go +146 -0
- data/ext/vendor/golang.org/x/net/html/parse.go +2094 -0
- data/ext/vendor/golang.org/x/net/html/parse_test.go +388 -0
- data/ext/vendor/golang.org/x/net/html/render.go +271 -0
- data/ext/vendor/golang.org/x/net/html/render_test.go +156 -0
- data/ext/vendor/golang.org/x/net/html/testdata/go1.html +2237 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/README +28 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/adoption01.dat +194 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/adoption02.dat +31 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/comments01.dat +135 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/doctype01.dat +370 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/entities01.dat +603 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/entities02.dat +249 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/html5test-com.dat +246 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/inbody01.dat +43 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/isindex.dat +40 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/pending-spec-changes-plain-text-unsafe.dat +0 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/pending-spec-changes.dat +52 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/plain-text-unsafe.dat +0 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/scriptdata01.dat +308 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/scripted/adoption01.dat +15 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/scripted/webkit01.dat +28 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tables01.dat +212 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests1.dat +1952 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests10.dat +799 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests11.dat +482 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests12.dat +62 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests14.dat +74 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests15.dat +208 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests16.dat +2299 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests17.dat +153 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests18.dat +269 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests19.dat +1237 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests2.dat +763 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests20.dat +455 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests21.dat +221 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests22.dat +157 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests23.dat +155 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests24.dat +79 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests25.dat +219 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests26.dat +313 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests3.dat +305 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests4.dat +59 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests5.dat +191 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests6.dat +663 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests7.dat +390 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests8.dat +148 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests9.dat +457 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests_innerHTML_1.dat +741 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/tricky01.dat +261 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/webkit01.dat +610 -0
- data/ext/vendor/golang.org/x/net/html/testdata/webkit/webkit02.dat +159 -0
- data/ext/vendor/golang.org/x/net/html/token.go +1219 -0
- data/ext/vendor/golang.org/x/net/html/token_test.go +748 -0
- data/ext/vendor/golang.org/x/net/http2/Dockerfile +51 -0
- data/ext/vendor/golang.org/x/net/http2/Makefile +3 -0
- data/ext/vendor/golang.org/x/net/http2/README +20 -0
- data/ext/vendor/golang.org/x/net/http2/ciphers.go +641 -0
- data/ext/vendor/golang.org/x/net/http2/ciphers_test.go +309 -0
- data/ext/vendor/golang.org/x/net/http2/client_conn_pool.go +256 -0
- data/ext/vendor/golang.org/x/net/http2/configure_transport.go +80 -0
- data/ext/vendor/golang.org/x/net/http2/databuffer.go +146 -0
- data/ext/vendor/golang.org/x/net/http2/databuffer_test.go +157 -0
- data/ext/vendor/golang.org/x/net/http2/errors.go +133 -0
- data/ext/vendor/golang.org/x/net/http2/errors_test.go +24 -0
- data/ext/vendor/golang.org/x/net/http2/flow.go +50 -0
- data/ext/vendor/golang.org/x/net/http2/flow_test.go +53 -0
- data/ext/vendor/golang.org/x/net/http2/frame.go +1579 -0
- data/ext/vendor/golang.org/x/net/http2/frame_test.go +1191 -0
- data/ext/vendor/golang.org/x/net/http2/go16.go +16 -0
- data/ext/vendor/golang.org/x/net/http2/go17.go +106 -0
- data/ext/vendor/golang.org/x/net/http2/go17_not18.go +36 -0
- data/ext/vendor/golang.org/x/net/http2/go18.go +56 -0
- data/ext/vendor/golang.org/x/net/http2/go18_test.go +79 -0
- data/ext/vendor/golang.org/x/net/http2/go19.go +16 -0
- data/ext/vendor/golang.org/x/net/http2/go19_test.go +60 -0
- data/ext/vendor/golang.org/x/net/http2/gotrack.go +170 -0
- data/ext/vendor/golang.org/x/net/http2/gotrack_test.go +33 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/Makefile +8 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/README +16 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/h2demo.go +538 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/launch.go +302 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/rootCA.key +27 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/rootCA.pem +26 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/rootCA.srl +1 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/server.crt +20 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/server.key +27 -0
- data/ext/vendor/golang.org/x/net/http2/h2demo/tmpl.go +1991 -0
- data/ext/vendor/golang.org/x/net/http2/h2i/README.md +97 -0
- data/ext/vendor/golang.org/x/net/http2/h2i/h2i.go +522 -0
- data/ext/vendor/golang.org/x/net/http2/headermap.go +78 -0
- data/ext/vendor/golang.org/x/net/http2/hpack/encode.go +240 -0
- data/ext/vendor/golang.org/x/net/http2/hpack/encode_test.go +386 -0
- data/ext/vendor/golang.org/x/net/http2/hpack/hpack.go +490 -0
- data/ext/vendor/golang.org/x/net/http2/hpack/hpack_test.go +722 -0
- data/ext/vendor/golang.org/x/net/http2/hpack/huffman.go +212 -0
- data/ext/vendor/golang.org/x/net/http2/hpack/tables.go +479 -0
- data/ext/vendor/golang.org/x/net/http2/hpack/tables_test.go +214 -0
- data/ext/vendor/golang.org/x/net/http2/http2.go +391 -0
- data/ext/vendor/golang.org/x/net/http2/http2_test.go +199 -0
- data/ext/vendor/golang.org/x/net/http2/not_go16.go +21 -0
- data/ext/vendor/golang.org/x/net/http2/not_go17.go +87 -0
- data/ext/vendor/golang.org/x/net/http2/not_go18.go +29 -0
- data/ext/vendor/golang.org/x/net/http2/not_go19.go +16 -0
- data/ext/vendor/golang.org/x/net/http2/pipe.go +163 -0
- data/ext/vendor/golang.org/x/net/http2/pipe_test.go +130 -0
- data/ext/vendor/golang.org/x/net/http2/server.go +2857 -0
- data/ext/vendor/golang.org/x/net/http2/server_push_test.go +521 -0
- data/ext/vendor/golang.org/x/net/http2/server_test.go +3721 -0
- data/ext/vendor/golang.org/x/net/http2/testdata/draft-ietf-httpbis-http2.xml +5021 -0
- data/ext/vendor/golang.org/x/net/http2/transport.go +2285 -0
- data/ext/vendor/golang.org/x/net/http2/transport_test.go +3714 -0
- data/ext/vendor/golang.org/x/net/http2/write.go +370 -0
- data/ext/vendor/golang.org/x/net/http2/writesched.go +242 -0
- data/ext/vendor/golang.org/x/net/http2/writesched_priority.go +452 -0
- data/ext/vendor/golang.org/x/net/http2/writesched_priority_test.go +541 -0
- data/ext/vendor/golang.org/x/net/http2/writesched_random.go +72 -0
- data/ext/vendor/golang.org/x/net/http2/writesched_random_test.go +44 -0
- data/ext/vendor/golang.org/x/net/http2/writesched_test.go +125 -0
- data/ext/vendor/golang.org/x/net/http2/z_spec_test.go +356 -0
- data/ext/vendor/golang.org/x/net/icmp/dstunreach.go +41 -0
- data/ext/vendor/golang.org/x/net/icmp/echo.go +45 -0
- data/ext/vendor/golang.org/x/net/icmp/endpoint.go +113 -0
- data/ext/vendor/golang.org/x/net/icmp/example_test.go +63 -0
- data/ext/vendor/golang.org/x/net/icmp/extension.go +89 -0
- data/ext/vendor/golang.org/x/net/icmp/extension_test.go +259 -0
- data/ext/vendor/golang.org/x/net/icmp/helper_posix.go +75 -0
- data/ext/vendor/golang.org/x/net/icmp/interface.go +236 -0
- data/ext/vendor/golang.org/x/net/icmp/ipv4.go +61 -0
- data/ext/vendor/golang.org/x/net/icmp/ipv4_test.go +83 -0
- data/ext/vendor/golang.org/x/net/icmp/ipv6.go +23 -0
- data/ext/vendor/golang.org/x/net/icmp/listen_posix.go +100 -0
- data/ext/vendor/golang.org/x/net/icmp/listen_stub.go +33 -0
- data/ext/vendor/golang.org/x/net/icmp/message.go +152 -0
- data/ext/vendor/golang.org/x/net/icmp/message_test.go +134 -0
- data/ext/vendor/golang.org/x/net/icmp/messagebody.go +41 -0
- data/ext/vendor/golang.org/x/net/icmp/mpls.go +77 -0
- data/ext/vendor/golang.org/x/net/icmp/multipart.go +109 -0
- data/ext/vendor/golang.org/x/net/icmp/multipart_test.go +442 -0
- data/ext/vendor/golang.org/x/net/icmp/packettoobig.go +43 -0
- data/ext/vendor/golang.org/x/net/icmp/paramprob.go +63 -0
- data/ext/vendor/golang.org/x/net/icmp/ping_test.go +200 -0
- data/ext/vendor/golang.org/x/net/icmp/sys_freebsd.go +11 -0
- data/ext/vendor/golang.org/x/net/icmp/timeexceeded.go +39 -0
- data/ext/vendor/golang.org/x/net/idna/example_test.go +70 -0
- data/ext/vendor/golang.org/x/net/idna/idna.go +680 -0
- data/ext/vendor/golang.org/x/net/idna/idna_test.go +108 -0
- data/ext/vendor/golang.org/x/net/idna/punycode.go +203 -0
- data/ext/vendor/golang.org/x/net/idna/punycode_test.go +198 -0
- data/ext/vendor/golang.org/x/net/idna/tables.go +4477 -0
- data/ext/vendor/golang.org/x/net/idna/trie.go +72 -0
- data/ext/vendor/golang.org/x/net/idna/trieval.go +114 -0
- data/ext/vendor/golang.org/x/net/internal/iana/const.go +180 -0
- data/ext/vendor/golang.org/x/net/internal/iana/gen.go +293 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/helper_bsd.go +53 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/helper_nobsd.go +15 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/helper_posix.go +31 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/helper_stub.go +32 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/helper_unix.go +29 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/helper_windows.go +42 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/interface.go +94 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/rlimit.go +11 -0
- data/ext/vendor/golang.org/x/net/internal/nettest/stack.go +147 -0
- data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr.go +11 -0
- data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_bsd.go +13 -0
- data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_32bit.go +14 -0
- data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_64bit.go +14 -0
- data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_solaris_64bit.go +14 -0
- data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_stub.go +17 -0
- data/ext/vendor/golang.org/x/net/internal/socket/defs_darwin.go +44 -0
- data/ext/vendor/golang.org/x/net/internal/socket/defs_dragonfly.go +44 -0
- data/ext/vendor/golang.org/x/net/internal/socket/defs_freebsd.go +44 -0
- data/ext/vendor/golang.org/x/net/internal/socket/defs_linux.go +49 -0
- data/ext/vendor/golang.org/x/net/internal/socket/defs_netbsd.go +47 -0
- data/ext/vendor/golang.org/x/net/internal/socket/defs_openbsd.go +44 -0
- data/ext/vendor/golang.org/x/net/internal/socket/defs_solaris.go +44 -0
- data/ext/vendor/golang.org/x/net/internal/socket/error_unix.go +31 -0
- data/ext/vendor/golang.org/x/net/internal/socket/error_windows.go +26 -0
- data/ext/vendor/golang.org/x/net/internal/socket/iovec_32bit.go +19 -0
- data/ext/vendor/golang.org/x/net/internal/socket/iovec_64bit.go +19 -0
- data/ext/vendor/golang.org/x/net/internal/socket/iovec_solaris_64bit.go +19 -0
- data/ext/vendor/golang.org/x/net/internal/socket/iovec_stub.go +11 -0
- data/ext/vendor/golang.org/x/net/internal/socket/mmsghdr_stub.go +21 -0
- data/ext/vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go +42 -0
- data/ext/vendor/golang.org/x/net/internal/socket/msghdr_bsd.go +39 -0
- data/ext/vendor/golang.org/x/net/internal/socket/msghdr_bsdvar.go +16 -0
- data/ext/vendor/golang.org/x/net/internal/socket/msghdr_linux.go +36 -0
- data/ext/vendor/golang.org/x/net/internal/socket/msghdr_linux_32bit.go +24 -0
- data/ext/vendor/golang.org/x/net/internal/socket/msghdr_linux_64bit.go +24 -0
- data/ext/vendor/golang.org/x/net/internal/socket/msghdr_openbsd.go +14 -0
- data/ext/vendor/golang.org/x/net/internal/socket/msghdr_solaris_64bit.go +36 -0
- data/ext/vendor/golang.org/x/net/internal/socket/msghdr_stub.go +14 -0
- data/ext/vendor/golang.org/x/net/internal/socket/rawconn.go +66 -0
- data/ext/vendor/golang.org/x/net/internal/socket/rawconn_mmsg.go +74 -0
- data/ext/vendor/golang.org/x/net/internal/socket/rawconn_msg.go +77 -0
- data/ext/vendor/golang.org/x/net/internal/socket/rawconn_nommsg.go +18 -0
- data/ext/vendor/golang.org/x/net/internal/socket/rawconn_nomsg.go +18 -0
- data/ext/vendor/golang.org/x/net/internal/socket/rawconn_stub.go +25 -0
- data/ext/vendor/golang.org/x/net/internal/socket/reflect.go +62 -0
- data/ext/vendor/golang.org/x/net/internal/socket/socket.go +285 -0
- data/ext/vendor/golang.org/x/net/internal/socket/socket_go1_9_test.go +259 -0
- data/ext/vendor/golang.org/x/net/internal/socket/socket_test.go +46 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys.go +33 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_bsd.go +17 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_bsdvar.go +14 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_darwin.go +7 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_dragonfly.go +7 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux.go +27 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_386.go +55 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_386.s +11 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_amd64.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_arm.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_arm64.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_mips.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_mips64.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_mips64le.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_mipsle.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_ppc64.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_ppc64le.go +10 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_s390x.go +55 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_s390x.s +11 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_netbsd.go +25 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_posix.go +168 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_solaris.go +71 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_solaris_amd64.s +11 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_stub.go +64 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_unix.go +33 -0
- data/ext/vendor/golang.org/x/net/internal/socket/sys_windows.go +70 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_darwin_386.go +59 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_darwin_amd64.go +61 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_darwin_arm.go +59 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_dragonfly_amd64.go +61 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_freebsd_386.go +59 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_freebsd_amd64.go +61 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_freebsd_arm.go +59 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_386.go +63 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_amd64.go +66 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_arm.go +63 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_arm64.go +66 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_mips.go +63 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_mips64.go +66 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_mips64le.go +66 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_mipsle.go +63 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64.go +66 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64le.go +66 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_s390x.go +66 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_netbsd_386.go +65 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_netbsd_amd64.go +68 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_netbsd_arm.go +59 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_openbsd_386.go +59 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_openbsd_amd64.go +61 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_openbsd_arm.go +59 -0
- data/ext/vendor/golang.org/x/net/internal/socket/zsys_solaris_amd64.go +60 -0
- data/ext/vendor/golang.org/x/net/internal/timeseries/timeseries.go +525 -0
- data/ext/vendor/golang.org/x/net/internal/timeseries/timeseries_test.go +170 -0
- data/ext/vendor/golang.org/x/net/ipv4/batch.go +191 -0
- data/ext/vendor/golang.org/x/net/ipv4/bpf_test.go +93 -0
- data/ext/vendor/golang.org/x/net/ipv4/control.go +144 -0
- data/ext/vendor/golang.org/x/net/ipv4/control_bsd.go +40 -0
- data/ext/vendor/golang.org/x/net/ipv4/control_pktinfo.go +39 -0
- data/ext/vendor/golang.org/x/net/ipv4/control_stub.go +13 -0
- data/ext/vendor/golang.org/x/net/ipv4/control_test.go +21 -0
- data/ext/vendor/golang.org/x/net/ipv4/control_unix.go +73 -0
- data/ext/vendor/golang.org/x/net/ipv4/control_windows.go +16 -0
- data/ext/vendor/golang.org/x/net/ipv4/defs_darwin.go +77 -0
- data/ext/vendor/golang.org/x/net/ipv4/defs_dragonfly.go +38 -0
- data/ext/vendor/golang.org/x/net/ipv4/defs_freebsd.go +75 -0
- data/ext/vendor/golang.org/x/net/ipv4/defs_linux.go +122 -0
- data/ext/vendor/golang.org/x/net/ipv4/defs_netbsd.go +37 -0
- data/ext/vendor/golang.org/x/net/ipv4/defs_openbsd.go +37 -0
- data/ext/vendor/golang.org/x/net/ipv4/defs_solaris.go +84 -0
- data/ext/vendor/golang.org/x/net/ipv4/dgramopt.go +265 -0
- data/ext/vendor/golang.org/x/net/ipv4/doc.go +244 -0
- data/ext/vendor/golang.org/x/net/ipv4/endpoint.go +187 -0
- data/ext/vendor/golang.org/x/net/ipv4/example_test.go +224 -0
- data/ext/vendor/golang.org/x/net/ipv4/gen.go +199 -0
- data/ext/vendor/golang.org/x/net/ipv4/genericopt.go +57 -0
- data/ext/vendor/golang.org/x/net/ipv4/header.go +159 -0
- data/ext/vendor/golang.org/x/net/ipv4/header_test.go +228 -0
- data/ext/vendor/golang.org/x/net/ipv4/helper.go +63 -0
- data/ext/vendor/golang.org/x/net/ipv4/iana.go +34 -0
- data/ext/vendor/golang.org/x/net/ipv4/icmp.go +57 -0
- data/ext/vendor/golang.org/x/net/ipv4/icmp_linux.go +25 -0
- data/ext/vendor/golang.org/x/net/ipv4/icmp_stub.go +25 -0
- data/ext/vendor/golang.org/x/net/ipv4/icmp_test.go +95 -0
- data/ext/vendor/golang.org/x/net/ipv4/multicast_test.go +334 -0
- data/ext/vendor/golang.org/x/net/ipv4/multicastlistener_test.go +265 -0
- data/ext/vendor/golang.org/x/net/ipv4/multicastsockopt_test.go +195 -0
- data/ext/vendor/golang.org/x/net/ipv4/packet.go +69 -0
- data/ext/vendor/golang.org/x/net/ipv4/packet_go1_8.go +56 -0
- data/ext/vendor/golang.org/x/net/ipv4/packet_go1_9.go +67 -0
- data/ext/vendor/golang.org/x/net/ipv4/payload.go +23 -0
- data/ext/vendor/golang.org/x/net/ipv4/payload_cmsg.go +36 -0
- data/ext/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_8.go +59 -0
- data/ext/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_9.go +67 -0
- data/ext/vendor/golang.org/x/net/ipv4/payload_nocmsg.go +42 -0
- data/ext/vendor/golang.org/x/net/ipv4/readwrite_go1_8_test.go +248 -0
- data/ext/vendor/golang.org/x/net/ipv4/readwrite_go1_9_test.go +388 -0
- data/ext/vendor/golang.org/x/net/ipv4/readwrite_test.go +140 -0
- data/ext/vendor/golang.org/x/net/ipv4/sockopt.go +44 -0
- data/ext/vendor/golang.org/x/net/ipv4/sockopt_posix.go +71 -0
- data/ext/vendor/golang.org/x/net/ipv4/sockopt_stub.go +42 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_asmreq.go +119 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_asmreq_stub.go +25 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_asmreqn.go +42 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_asmreqn_stub.go +21 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_bpf.go +23 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_bpf_stub.go +16 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_bsd.go +37 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_darwin.go +93 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_dragonfly.go +35 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_freebsd.go +76 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_linux.go +59 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_solaris.go +57 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_ssmreq.go +54 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_ssmreq_stub.go +21 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_stub.go +13 -0
- data/ext/vendor/golang.org/x/net/ipv4/sys_windows.go +67 -0
- data/ext/vendor/golang.org/x/net/ipv4/unicast_test.go +247 -0
- data/ext/vendor/golang.org/x/net/ipv4/unicastsockopt_test.go +148 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_darwin.go +99 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go +31 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go +93 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go +95 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go +95 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_386.go +148 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go +150 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go +148 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go +150 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_mips.go +148 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go +150 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go +150 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_mipsle.go +148 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_ppc.go +148 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go +150 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go +150 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go +150 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_netbsd.go +30 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_openbsd.go +30 -0
- data/ext/vendor/golang.org/x/net/ipv4/zsys_solaris.go +100 -0
- data/ext/vendor/golang.org/x/net/ipv6/batch.go +119 -0
- data/ext/vendor/golang.org/x/net/ipv6/bpf_test.go +96 -0
- data/ext/vendor/golang.org/x/net/ipv6/control.go +187 -0
- data/ext/vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go +48 -0
- data/ext/vendor/golang.org/x/net/ipv6/control_rfc3542_unix.go +94 -0
- data/ext/vendor/golang.org/x/net/ipv6/control_stub.go +13 -0
- data/ext/vendor/golang.org/x/net/ipv6/control_test.go +21 -0
- data/ext/vendor/golang.org/x/net/ipv6/control_unix.go +55 -0
- data/ext/vendor/golang.org/x/net/ipv6/control_windows.go +16 -0
- data/ext/vendor/golang.org/x/net/ipv6/defs_darwin.go +112 -0
- data/ext/vendor/golang.org/x/net/ipv6/defs_dragonfly.go +84 -0
- data/ext/vendor/golang.org/x/net/ipv6/defs_freebsd.go +105 -0
- data/ext/vendor/golang.org/x/net/ipv6/defs_linux.go +147 -0
- data/ext/vendor/golang.org/x/net/ipv6/defs_netbsd.go +80 -0
- data/ext/vendor/golang.org/x/net/ipv6/defs_openbsd.go +89 -0
- data/ext/vendor/golang.org/x/net/ipv6/defs_solaris.go +114 -0
- data/ext/vendor/golang.org/x/net/ipv6/dgramopt.go +302 -0
- data/ext/vendor/golang.org/x/net/ipv6/doc.go +243 -0
- data/ext/vendor/golang.org/x/net/ipv6/endpoint.go +128 -0
- data/ext/vendor/golang.org/x/net/ipv6/example_test.go +216 -0
- data/ext/vendor/golang.org/x/net/ipv6/gen.go +199 -0
- data/ext/vendor/golang.org/x/net/ipv6/genericopt.go +58 -0
- data/ext/vendor/golang.org/x/net/ipv6/header.go +55 -0
- data/ext/vendor/golang.org/x/net/ipv6/header_test.go +55 -0
- data/ext/vendor/golang.org/x/net/ipv6/helper.go +57 -0
- data/ext/vendor/golang.org/x/net/ipv6/iana.go +82 -0
- data/ext/vendor/golang.org/x/net/ipv6/icmp.go +60 -0
- data/ext/vendor/golang.org/x/net/ipv6/icmp_bsd.go +29 -0
- data/ext/vendor/golang.org/x/net/ipv6/icmp_linux.go +27 -0
- data/ext/vendor/golang.org/x/net/ipv6/icmp_solaris.go +27 -0
- data/ext/vendor/golang.org/x/net/ipv6/icmp_stub.go +23 -0
- data/ext/vendor/golang.org/x/net/ipv6/icmp_test.go +96 -0
- data/ext/vendor/golang.org/x/net/ipv6/icmp_windows.go +22 -0
- data/ext/vendor/golang.org/x/net/ipv6/mocktransponder_test.go +32 -0
- data/ext/vendor/golang.org/x/net/ipv6/multicast_test.go +264 -0
- data/ext/vendor/golang.org/x/net/ipv6/multicastlistener_test.go +261 -0
- data/ext/vendor/golang.org/x/net/ipv6/multicastsockopt_test.go +157 -0
- data/ext/vendor/golang.org/x/net/ipv6/payload.go +23 -0
- data/ext/vendor/golang.org/x/net/ipv6/payload_cmsg.go +35 -0
- data/ext/vendor/golang.org/x/net/ipv6/payload_cmsg_go1_8.go +55 -0
- data/ext/vendor/golang.org/x/net/ipv6/payload_cmsg_go1_9.go +57 -0
- data/ext/vendor/golang.org/x/net/ipv6/payload_nocmsg.go +41 -0
- data/ext/vendor/golang.org/x/net/ipv6/readwrite_go1_8_test.go +242 -0
- data/ext/vendor/golang.org/x/net/ipv6/readwrite_go1_9_test.go +373 -0
- data/ext/vendor/golang.org/x/net/ipv6/readwrite_test.go +148 -0
- data/ext/vendor/golang.org/x/net/ipv6/sockopt.go +43 -0
- data/ext/vendor/golang.org/x/net/ipv6/sockopt_posix.go +87 -0
- data/ext/vendor/golang.org/x/net/ipv6/sockopt_stub.go +46 -0
- data/ext/vendor/golang.org/x/net/ipv6/sockopt_test.go +133 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_asmreq.go +24 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_asmreq_stub.go +17 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_bpf.go +23 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_bpf_stub.go +16 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_bsd.go +57 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_darwin.go +106 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_freebsd.go +92 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_linux.go +74 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_solaris.go +74 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_ssmreq.go +54 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_ssmreq_stub.go +21 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_stub.go +13 -0
- data/ext/vendor/golang.org/x/net/ipv6/sys_windows.go +75 -0
- data/ext/vendor/golang.org/x/net/ipv6/unicast_test.go +184 -0
- data/ext/vendor/golang.org/x/net/ipv6/unicastsockopt_test.go +120 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_darwin.go +131 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_dragonfly.go +88 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_freebsd_386.go +122 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_freebsd_amd64.go +124 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm.go +124 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_386.go +170 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_amd64.go +172 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_arm.go +170 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_arm64.go +172 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_mips.go +170 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_mips64.go +172 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_mips64le.go +172 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_mipsle.go +170 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_ppc.go +170 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64.go +172 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64le.go +172 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_s390x.go +172 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_netbsd.go +84 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_openbsd.go +93 -0
- data/ext/vendor/golang.org/x/net/ipv6/zsys_solaris.go +131 -0
- data/ext/vendor/golang.org/x/net/lex/httplex/httplex.go +351 -0
- data/ext/vendor/golang.org/x/net/lex/httplex/httplex_test.go +119 -0
- data/ext/vendor/golang.org/x/net/lif/address.go +105 -0
- data/ext/vendor/golang.org/x/net/lif/address_test.go +123 -0
- data/ext/vendor/golang.org/x/net/lif/binary.go +115 -0
- data/ext/vendor/golang.org/x/net/lif/defs_solaris.go +90 -0
- data/ext/vendor/golang.org/x/net/lif/lif.go +43 -0
- data/ext/vendor/golang.org/x/net/lif/link.go +126 -0
- data/ext/vendor/golang.org/x/net/lif/link_test.go +63 -0
- data/ext/vendor/golang.org/x/net/lif/sys.go +21 -0
- data/ext/vendor/golang.org/x/net/lif/sys_solaris_amd64.s +8 -0
- data/ext/vendor/golang.org/x/net/lif/syscall.go +28 -0
- data/ext/vendor/golang.org/x/net/lif/zsys_solaris_amd64.go +103 -0
- data/ext/vendor/golang.org/x/net/nettest/conntest.go +456 -0
- data/ext/vendor/golang.org/x/net/nettest/conntest_go16.go +24 -0
- data/ext/vendor/golang.org/x/net/nettest/conntest_go17.go +24 -0
- data/ext/vendor/golang.org/x/net/nettest/conntest_test.go +76 -0
- data/ext/vendor/golang.org/x/net/netutil/listen.go +48 -0
- data/ext/vendor/golang.org/x/net/netutil/listen_test.go +101 -0
- data/ext/vendor/golang.org/x/net/proxy/direct.go +18 -0
- data/ext/vendor/golang.org/x/net/proxy/per_host.go +140 -0
- data/ext/vendor/golang.org/x/net/proxy/per_host_test.go +55 -0
- data/ext/vendor/golang.org/x/net/proxy/proxy.go +134 -0
- data/ext/vendor/golang.org/x/net/proxy/proxy_test.go +215 -0
- data/ext/vendor/golang.org/x/net/proxy/socks5.go +214 -0
- data/ext/vendor/golang.org/x/net/publicsuffix/gen.go +713 -0
- data/ext/vendor/golang.org/x/net/publicsuffix/list.go +135 -0
- data/ext/vendor/golang.org/x/net/publicsuffix/list_test.go +416 -0
- data/ext/vendor/golang.org/x/net/publicsuffix/table.go +9419 -0
- data/ext/vendor/golang.org/x/net/publicsuffix/table_test.go +16756 -0
- data/ext/vendor/golang.org/x/net/route/address.go +425 -0
- data/ext/vendor/golang.org/x/net/route/address_darwin_test.go +63 -0
- data/ext/vendor/golang.org/x/net/route/address_test.go +103 -0
- data/ext/vendor/golang.org/x/net/route/binary.go +90 -0
- data/ext/vendor/golang.org/x/net/route/defs_darwin.go +114 -0
- data/ext/vendor/golang.org/x/net/route/defs_dragonfly.go +113 -0
- data/ext/vendor/golang.org/x/net/route/defs_freebsd.go +337 -0
- data/ext/vendor/golang.org/x/net/route/defs_netbsd.go +112 -0
- data/ext/vendor/golang.org/x/net/route/defs_openbsd.go +116 -0
- data/ext/vendor/golang.org/x/net/route/interface.go +64 -0
- data/ext/vendor/golang.org/x/net/route/interface_announce.go +32 -0
- data/ext/vendor/golang.org/x/net/route/interface_classic.go +66 -0
- data/ext/vendor/golang.org/x/net/route/interface_freebsd.go +78 -0
- data/ext/vendor/golang.org/x/net/route/interface_multicast.go +30 -0
- data/ext/vendor/golang.org/x/net/route/interface_openbsd.go +90 -0
- data/ext/vendor/golang.org/x/net/route/message.go +72 -0
- data/ext/vendor/golang.org/x/net/route/message_darwin_test.go +34 -0
- data/ext/vendor/golang.org/x/net/route/message_freebsd_test.go +92 -0
- data/ext/vendor/golang.org/x/net/route/message_test.go +239 -0
- data/ext/vendor/golang.org/x/net/route/route.go +123 -0
- data/ext/vendor/golang.org/x/net/route/route_classic.go +67 -0
- data/ext/vendor/golang.org/x/net/route/route_openbsd.go +65 -0
- data/ext/vendor/golang.org/x/net/route/route_test.go +390 -0
- data/ext/vendor/golang.org/x/net/route/sys.go +39 -0
- data/ext/vendor/golang.org/x/net/route/sys_darwin.go +87 -0
- data/ext/vendor/golang.org/x/net/route/sys_dragonfly.go +76 -0
- data/ext/vendor/golang.org/x/net/route/sys_freebsd.go +155 -0
- data/ext/vendor/golang.org/x/net/route/sys_netbsd.go +71 -0
- data/ext/vendor/golang.org/x/net/route/sys_openbsd.go +80 -0
- data/ext/vendor/golang.org/x/net/route/syscall.go +28 -0
- data/ext/vendor/golang.org/x/net/route/zsys_darwin.go +99 -0
- data/ext/vendor/golang.org/x/net/route/zsys_dragonfly.go +98 -0
- data/ext/vendor/golang.org/x/net/route/zsys_freebsd_386.go +126 -0
- data/ext/vendor/golang.org/x/net/route/zsys_freebsd_amd64.go +123 -0
- data/ext/vendor/golang.org/x/net/route/zsys_freebsd_arm.go +123 -0
- data/ext/vendor/golang.org/x/net/route/zsys_netbsd.go +97 -0
- data/ext/vendor/golang.org/x/net/route/zsys_openbsd.go +101 -0
- data/ext/vendor/golang.org/x/net/trace/events.go +532 -0
- data/ext/vendor/golang.org/x/net/trace/histogram.go +365 -0
- data/ext/vendor/golang.org/x/net/trace/histogram_test.go +325 -0
- data/ext/vendor/golang.org/x/net/trace/trace.go +1082 -0
- data/ext/vendor/golang.org/x/net/trace/trace_go16.go +21 -0
- data/ext/vendor/golang.org/x/net/trace/trace_go17.go +21 -0
- data/ext/vendor/golang.org/x/net/trace/trace_test.go +178 -0
- data/ext/vendor/golang.org/x/net/webdav/file.go +796 -0
- data/ext/vendor/golang.org/x/net/webdav/file_go1.6.go +17 -0
- data/ext/vendor/golang.org/x/net/webdav/file_go1.7.go +16 -0
- data/ext/vendor/golang.org/x/net/webdav/file_test.go +1184 -0
- data/ext/vendor/golang.org/x/net/webdav/if.go +173 -0
- data/ext/vendor/golang.org/x/net/webdav/if_test.go +322 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/README +11 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/atom_test.go +56 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/example_test.go +151 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/marshal.go +1223 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/marshal_test.go +1939 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/read.go +692 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/read_test.go +744 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/typeinfo.go +371 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/xml.go +1998 -0
- data/ext/vendor/golang.org/x/net/webdav/internal/xml/xml_test.go +752 -0
- data/ext/vendor/golang.org/x/net/webdav/litmus_test_server.go +94 -0
- data/ext/vendor/golang.org/x/net/webdav/lock.go +445 -0
- data/ext/vendor/golang.org/x/net/webdav/lock_test.go +731 -0
- data/ext/vendor/golang.org/x/net/webdav/prop.go +418 -0
- data/ext/vendor/golang.org/x/net/webdav/prop_test.go +613 -0
- data/ext/vendor/golang.org/x/net/webdav/webdav.go +702 -0
- data/ext/vendor/golang.org/x/net/webdav/webdav_test.go +344 -0
- data/ext/vendor/golang.org/x/net/webdav/xml.go +519 -0
- data/ext/vendor/golang.org/x/net/webdav/xml_test.go +906 -0
- data/ext/vendor/golang.org/x/net/websocket/client.go +106 -0
- data/ext/vendor/golang.org/x/net/websocket/dial.go +24 -0
- data/ext/vendor/golang.org/x/net/websocket/dial_test.go +43 -0
- data/ext/vendor/golang.org/x/net/websocket/exampledial_test.go +31 -0
- data/ext/vendor/golang.org/x/net/websocket/examplehandler_test.go +26 -0
- data/ext/vendor/golang.org/x/net/websocket/hybi.go +583 -0
- data/ext/vendor/golang.org/x/net/websocket/hybi_test.go +608 -0
- data/ext/vendor/golang.org/x/net/websocket/server.go +113 -0
- data/ext/vendor/golang.org/x/net/websocket/websocket.go +448 -0
- data/ext/vendor/golang.org/x/net/websocket/websocket_test.go +665 -0
- data/ext/vendor/golang.org/x/net/xsrftoken/xsrf.go +94 -0
- data/ext/vendor/golang.org/x/net/xsrftoken/xsrf_test.go +83 -0
- data/ext/vendor/golang.org/x/text/AUTHORS +3 -0
- data/ext/vendor/golang.org/x/text/CONTRIBUTING.md +31 -0
- data/ext/vendor/golang.org/x/text/CONTRIBUTORS +3 -0
- data/ext/vendor/golang.org/x/text/LICENSE +27 -0
- data/ext/vendor/golang.org/x/text/PATENTS +22 -0
- data/ext/vendor/golang.org/x/text/README.md +91 -0
- data/ext/vendor/golang.org/x/text/cases/cases.go +162 -0
- data/ext/vendor/golang.org/x/text/cases/context.go +376 -0
- data/ext/vendor/golang.org/x/text/cases/context_test.go +438 -0
- data/ext/vendor/golang.org/x/text/cases/example_test.go +53 -0
- data/ext/vendor/golang.org/x/text/cases/fold.go +34 -0
- data/ext/vendor/golang.org/x/text/cases/fold_test.go +51 -0
- data/ext/vendor/golang.org/x/text/cases/gen.go +839 -0
- data/ext/vendor/golang.org/x/text/cases/gen_trieval.go +219 -0
- data/ext/vendor/golang.org/x/text/cases/icu.go +61 -0
- data/ext/vendor/golang.org/x/text/cases/icu_test.go +210 -0
- data/ext/vendor/golang.org/x/text/cases/info.go +82 -0
- data/ext/vendor/golang.org/x/text/cases/map.go +816 -0
- data/ext/vendor/golang.org/x/text/cases/map_test.go +950 -0
- data/ext/vendor/golang.org/x/text/cases/tables.go +2251 -0
- data/ext/vendor/golang.org/x/text/cases/tables_test.go +1158 -0
- data/ext/vendor/golang.org/x/text/cases/trieval.go +215 -0
- data/ext/vendor/golang.org/x/text/cmd/gotext/doc.go +35 -0
- data/ext/vendor/golang.org/x/text/cmd/gotext/extract.go +195 -0
- data/ext/vendor/golang.org/x/text/cmd/gotext/main.go +356 -0
- data/ext/vendor/golang.org/x/text/cmd/gotext/message.go +127 -0
- data/ext/vendor/golang.org/x/text/codereview.cfg +1 -0
- data/ext/vendor/golang.org/x/text/collate/build/builder.go +702 -0
- data/ext/vendor/golang.org/x/text/collate/build/builder_test.go +290 -0
- data/ext/vendor/golang.org/x/text/collate/build/colelem.go +294 -0
- data/ext/vendor/golang.org/x/text/collate/build/colelem_test.go +215 -0
- data/ext/vendor/golang.org/x/text/collate/build/contract.go +309 -0
- data/ext/vendor/golang.org/x/text/collate/build/contract_test.go +266 -0
- data/ext/vendor/golang.org/x/text/collate/build/order.go +393 -0
- data/ext/vendor/golang.org/x/text/collate/build/order_test.go +229 -0
- data/ext/vendor/golang.org/x/text/collate/build/table.go +81 -0
- data/ext/vendor/golang.org/x/text/collate/build/trie.go +290 -0
- data/ext/vendor/golang.org/x/text/collate/build/trie_test.go +107 -0
- data/ext/vendor/golang.org/x/text/collate/collate.go +403 -0
- data/ext/vendor/golang.org/x/text/collate/collate_test.go +482 -0
- data/ext/vendor/golang.org/x/text/collate/export_test.go +51 -0
- data/ext/vendor/golang.org/x/text/collate/index.go +32 -0
- data/ext/vendor/golang.org/x/text/collate/maketables.go +553 -0
- data/ext/vendor/golang.org/x/text/collate/option.go +239 -0
- data/ext/vendor/golang.org/x/text/collate/option_test.go +209 -0
- data/ext/vendor/golang.org/x/text/collate/reg_test.go +230 -0
- data/ext/vendor/golang.org/x/text/collate/sort.go +81 -0
- data/ext/vendor/golang.org/x/text/collate/sort_test.go +55 -0
- data/ext/vendor/golang.org/x/text/collate/table_test.go +291 -0
- data/ext/vendor/golang.org/x/text/collate/tables.go +73789 -0
- data/ext/vendor/golang.org/x/text/collate/tools/colcmp/Makefile +7 -0
- data/ext/vendor/golang.org/x/text/collate/tools/colcmp/chars.go +1156 -0
- data/ext/vendor/golang.org/x/text/collate/tools/colcmp/col.go +97 -0
- data/ext/vendor/golang.org/x/text/collate/tools/colcmp/colcmp.go +529 -0
- data/ext/vendor/golang.org/x/text/collate/tools/colcmp/darwin.go +111 -0
- data/ext/vendor/golang.org/x/text/collate/tools/colcmp/gen.go +183 -0
- data/ext/vendor/golang.org/x/text/collate/tools/colcmp/icu.go +209 -0
- data/ext/vendor/golang.org/x/text/currency/common.go +66 -0
- data/ext/vendor/golang.org/x/text/currency/currency.go +185 -0
- data/ext/vendor/golang.org/x/text/currency/currency_test.go +171 -0
- data/ext/vendor/golang.org/x/text/currency/example_test.go +27 -0
- data/ext/vendor/golang.org/x/text/currency/format.go +215 -0
- data/ext/vendor/golang.org/x/text/currency/format_test.go +70 -0
- data/ext/vendor/golang.org/x/text/currency/gen.go +400 -0
- data/ext/vendor/golang.org/x/text/currency/gen_common.go +70 -0
- data/ext/vendor/golang.org/x/text/currency/query.go +152 -0
- data/ext/vendor/golang.org/x/text/currency/query_test.go +107 -0
- data/ext/vendor/golang.org/x/text/currency/tables.go +2574 -0
- data/ext/vendor/golang.org/x/text/currency/tables_test.go +93 -0
- data/ext/vendor/golang.org/x/text/doc.go +13 -0
- data/ext/vendor/golang.org/x/text/encoding/charmap/charmap.go +249 -0
- data/ext/vendor/golang.org/x/text/encoding/charmap/charmap_test.go +258 -0
- data/ext/vendor/golang.org/x/text/encoding/charmap/maketables.go +556 -0
- data/ext/vendor/golang.org/x/text/encoding/charmap/tables.go +7410 -0
- data/ext/vendor/golang.org/x/text/encoding/encoding.go +335 -0
- data/ext/vendor/golang.org/x/text/encoding/encoding_test.go +290 -0
- data/ext/vendor/golang.org/x/text/encoding/example_test.go +42 -0
- data/ext/vendor/golang.org/x/text/encoding/htmlindex/gen.go +173 -0
- data/ext/vendor/golang.org/x/text/encoding/htmlindex/htmlindex.go +86 -0
- data/ext/vendor/golang.org/x/text/encoding/htmlindex/htmlindex_test.go +144 -0
- data/ext/vendor/golang.org/x/text/encoding/htmlindex/map.go +105 -0
- data/ext/vendor/golang.org/x/text/encoding/htmlindex/tables.go +352 -0
- data/ext/vendor/golang.org/x/text/encoding/ianaindex/example_test.go +27 -0
- data/ext/vendor/golang.org/x/text/encoding/ianaindex/gen.go +192 -0
- data/ext/vendor/golang.org/x/text/encoding/ianaindex/ianaindex.go +209 -0
- data/ext/vendor/golang.org/x/text/encoding/ianaindex/ianaindex_test.go +192 -0
- data/ext/vendor/golang.org/x/text/encoding/ianaindex/tables.go +2348 -0
- data/ext/vendor/golang.org/x/text/encoding/internal/enctest/enctest.go +180 -0
- data/ext/vendor/golang.org/x/text/encoding/internal/identifier/gen.go +137 -0
- data/ext/vendor/golang.org/x/text/encoding/internal/identifier/identifier.go +81 -0
- data/ext/vendor/golang.org/x/text/encoding/internal/identifier/mib.go +1621 -0
- data/ext/vendor/golang.org/x/text/encoding/internal/internal.go +75 -0
- data/ext/vendor/golang.org/x/text/encoding/japanese/all.go +12 -0
- data/ext/vendor/golang.org/x/text/encoding/japanese/all_test.go +248 -0
- data/ext/vendor/golang.org/x/text/encoding/japanese/eucjp.go +225 -0
- data/ext/vendor/golang.org/x/text/encoding/japanese/iso2022jp.go +299 -0
- data/ext/vendor/golang.org/x/text/encoding/japanese/maketables.go +161 -0
- data/ext/vendor/golang.org/x/text/encoding/japanese/shiftjis.go +189 -0
- data/ext/vendor/golang.org/x/text/encoding/japanese/tables.go +26971 -0
- data/ext/vendor/golang.org/x/text/encoding/korean/all_test.go +94 -0
- data/ext/vendor/golang.org/x/text/encoding/korean/euckr.go +177 -0
- data/ext/vendor/golang.org/x/text/encoding/korean/maketables.go +143 -0
- data/ext/vendor/golang.org/x/text/encoding/korean/tables.go +34152 -0
- data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/all.go +12 -0
- data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/all_test.go +143 -0
- data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/gbk.go +269 -0
- data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/hzgb2312.go +245 -0
- data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/maketables.go +161 -0
- data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/tables.go +43999 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/candide-gb18030.txt +510 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/candide-utf-16le.txt +0 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/candide-utf-32be.txt +0 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/candide-utf-8.txt +510 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/candide-windows-1252.txt +510 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/rashomon-euc-jp.txt +178 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/rashomon-iso-2022-jp.txt +178 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/rashomon-shift-jis.txt +178 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/rashomon-utf-8.txt +178 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-gb-levels-1-and-2-hz-gb2312.txt +107 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-gb-levels-1-and-2-utf-8.txt +107 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-simplified-gbk.txt +107 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-simplified-utf-8.txt +107 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-traditional-big5.txt +106 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-traditional-utf-8.txt +106 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/unsu-joh-eun-nal-euc-kr.txt +175 -0
- data/ext/vendor/golang.org/x/text/encoding/testdata/unsu-joh-eun-nal-utf-8.txt +175 -0
- data/ext/vendor/golang.org/x/text/encoding/traditionalchinese/all_test.go +114 -0
- data/ext/vendor/golang.org/x/text/encoding/traditionalchinese/big5.go +199 -0
- data/ext/vendor/golang.org/x/text/encoding/traditionalchinese/maketables.go +140 -0
- data/ext/vendor/golang.org/x/text/encoding/traditionalchinese/tables.go +37142 -0
- data/ext/vendor/golang.org/x/text/encoding/unicode/override.go +82 -0
- data/ext/vendor/golang.org/x/text/encoding/unicode/unicode.go +434 -0
- data/ext/vendor/golang.org/x/text/encoding/unicode/unicode_test.go +499 -0
- data/ext/vendor/golang.org/x/text/encoding/unicode/utf32/utf32.go +296 -0
- data/ext/vendor/golang.org/x/text/encoding/unicode/utf32/utf32_test.go +248 -0
- data/ext/vendor/golang.org/x/text/feature/plural/common.go +70 -0
- data/ext/vendor/golang.org/x/text/feature/plural/data_test.go +190 -0
- data/ext/vendor/golang.org/x/text/feature/plural/example_test.go +46 -0
- data/ext/vendor/golang.org/x/text/feature/plural/gen.go +513 -0
- data/ext/vendor/golang.org/x/text/feature/plural/gen_common.go +74 -0
- data/ext/vendor/golang.org/x/text/feature/plural/message.go +244 -0
- data/ext/vendor/golang.org/x/text/feature/plural/message_test.go +197 -0
- data/ext/vendor/golang.org/x/text/feature/plural/plural.go +258 -0
- data/ext/vendor/golang.org/x/text/feature/plural/plural_test.go +216 -0
- data/ext/vendor/golang.org/x/text/feature/plural/tables.go +540 -0
- data/ext/vendor/golang.org/x/text/gen.go +318 -0
- data/ext/vendor/golang.org/x/text/internal/catmsg/catmsg.go +366 -0
- data/ext/vendor/golang.org/x/text/internal/catmsg/catmsg_test.go +316 -0
- data/ext/vendor/golang.org/x/text/internal/catmsg/codec.go +407 -0
- data/ext/vendor/golang.org/x/text/internal/catmsg/varint.go +62 -0
- data/ext/vendor/golang.org/x/text/internal/catmsg/varint_test.go +123 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/collate_test.go +121 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/collelem.go +371 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/collelem_test.go +183 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/colltab.go +105 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/colltab_test.go +64 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/contract.go +145 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/contract_test.go +131 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/iter.go +178 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/iter_test.go +63 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/numeric.go +236 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/numeric_test.go +159 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/table.go +275 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/trie.go +159 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/trie_test.go +106 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/weighter.go +31 -0
- data/ext/vendor/golang.org/x/text/internal/colltab/weighter_test.go +42 -0
- data/ext/vendor/golang.org/x/text/internal/export/README +4 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/common_test.go +55 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/example_test.go +68 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/gen.go +276 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/gen_common.go +59 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/gen_test.go +91 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/gen_trieval.go +123 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/idna.go +717 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/idna_test.go +308 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/punycode.go +201 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/punycode_test.go +198 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/tables.go +4557 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/trie.go +70 -0
- data/ext/vendor/golang.org/x/text/internal/export/idna/trieval.go +119 -0
- data/ext/vendor/golang.org/x/text/internal/format/format.go +41 -0
- data/ext/vendor/golang.org/x/text/internal/gen.go +52 -0
- data/ext/vendor/golang.org/x/text/internal/gen/code.go +351 -0
- data/ext/vendor/golang.org/x/text/internal/gen/gen.go +281 -0
- data/ext/vendor/golang.org/x/text/internal/gen_test.go +38 -0
- data/ext/vendor/golang.org/x/text/internal/internal.go +51 -0
- data/ext/vendor/golang.org/x/text/internal/internal_test.go +38 -0
- data/ext/vendor/golang.org/x/text/internal/match.go +67 -0
- data/ext/vendor/golang.org/x/text/internal/match_test.go +56 -0
- data/ext/vendor/golang.org/x/text/internal/number/common.go +40 -0
- data/ext/vendor/golang.org/x/text/internal/number/decimal.go +498 -0
- data/ext/vendor/golang.org/x/text/internal/number/decimal_test.go +329 -0
- data/ext/vendor/golang.org/x/text/internal/number/format.go +540 -0
- data/ext/vendor/golang.org/x/text/internal/number/format_test.go +522 -0
- data/ext/vendor/golang.org/x/text/internal/number/gen.go +458 -0
- data/ext/vendor/golang.org/x/text/internal/number/gen_common.go +44 -0
- data/ext/vendor/golang.org/x/text/internal/number/number.go +154 -0
- data/ext/vendor/golang.org/x/text/internal/number/number_test.go +100 -0
- data/ext/vendor/golang.org/x/text/internal/number/pattern.go +485 -0
- data/ext/vendor/golang.org/x/text/internal/number/pattern_test.go +438 -0
- data/ext/vendor/golang.org/x/text/internal/number/roundingmode_string.go +16 -0
- data/ext/vendor/golang.org/x/text/internal/number/tables.go +1154 -0
- data/ext/vendor/golang.org/x/text/internal/number/tables_test.go +125 -0
- data/ext/vendor/golang.org/x/text/internal/stringset/set.go +86 -0
- data/ext/vendor/golang.org/x/text/internal/stringset/set_test.go +53 -0
- data/ext/vendor/golang.org/x/text/internal/tables.go +117 -0
- data/ext/vendor/golang.org/x/text/internal/tag/tag.go +100 -0
- data/ext/vendor/golang.org/x/text/internal/tag/tag_test.go +67 -0
- data/ext/vendor/golang.org/x/text/internal/testtext/codesize.go +53 -0
- data/ext/vendor/golang.org/x/text/internal/testtext/flag.go +22 -0
- data/ext/vendor/golang.org/x/text/internal/testtext/gc.go +14 -0
- data/ext/vendor/golang.org/x/text/internal/testtext/gccgo.go +11 -0
- data/ext/vendor/golang.org/x/text/internal/testtext/go1_6.go +23 -0
- data/ext/vendor/golang.org/x/text/internal/testtext/go1_7.go +17 -0
- data/ext/vendor/golang.org/x/text/internal/testtext/text.go +105 -0
- data/ext/vendor/golang.org/x/text/internal/triegen/compact.go +58 -0
- data/ext/vendor/golang.org/x/text/internal/triegen/data_test.go +875 -0
- data/ext/vendor/golang.org/x/text/internal/triegen/example_compact_test.go +71 -0
- data/ext/vendor/golang.org/x/text/internal/triegen/example_test.go +148 -0
- data/ext/vendor/golang.org/x/text/internal/triegen/gen_test.go +68 -0
- data/ext/vendor/golang.org/x/text/internal/triegen/print.go +251 -0
- data/ext/vendor/golang.org/x/text/internal/triegen/triegen.go +494 -0
- data/ext/vendor/golang.org/x/text/internal/ucd/example_test.go +81 -0
- data/ext/vendor/golang.org/x/text/internal/ucd/ucd.go +371 -0
- data/ext/vendor/golang.org/x/text/internal/ucd/ucd_test.go +105 -0
- data/ext/vendor/golang.org/x/text/internal/utf8internal/utf8internal.go +87 -0
- data/ext/vendor/golang.org/x/text/language/Makefile +16 -0
- data/ext/vendor/golang.org/x/text/language/common.go +16 -0
- data/ext/vendor/golang.org/x/text/language/coverage.go +197 -0
- data/ext/vendor/golang.org/x/text/language/coverage_test.go +154 -0
- data/ext/vendor/golang.org/x/text/language/display/dict.go +92 -0
- data/ext/vendor/golang.org/x/text/language/display/dict_test.go +39 -0
- data/ext/vendor/golang.org/x/text/language/display/display.go +420 -0
- data/ext/vendor/golang.org/x/text/language/display/display_test.go +705 -0
- data/ext/vendor/golang.org/x/text/language/display/examples_test.go +116 -0
- data/ext/vendor/golang.org/x/text/language/display/lookup.go +251 -0
- data/ext/vendor/golang.org/x/text/language/display/maketables.go +602 -0
- data/ext/vendor/golang.org/x/text/language/display/tables.go +50344 -0
- data/ext/vendor/golang.org/x/text/language/doc.go +102 -0
- data/ext/vendor/golang.org/x/text/language/examples_test.go +413 -0
- data/ext/vendor/golang.org/x/text/language/gen.go +1706 -0
- data/ext/vendor/golang.org/x/text/language/gen_common.go +20 -0
- data/ext/vendor/golang.org/x/text/language/gen_index.go +162 -0
- data/ext/vendor/golang.org/x/text/language/go1_1.go +38 -0
- data/ext/vendor/golang.org/x/text/language/go1_2.go +11 -0
- data/ext/vendor/golang.org/x/text/language/httpexample_test.go +48 -0
- data/ext/vendor/golang.org/x/text/language/index.go +769 -0
- data/ext/vendor/golang.org/x/text/language/language.go +887 -0
- data/ext/vendor/golang.org/x/text/language/language_test.go +878 -0
- data/ext/vendor/golang.org/x/text/language/lookup.go +396 -0
- data/ext/vendor/golang.org/x/text/language/lookup_test.go +457 -0
- data/ext/vendor/golang.org/x/text/language/match.go +933 -0
- data/ext/vendor/golang.org/x/text/language/match_test.go +505 -0
- data/ext/vendor/golang.org/x/text/language/parse.go +859 -0
- data/ext/vendor/golang.org/x/text/language/parse_test.go +517 -0
- data/ext/vendor/golang.org/x/text/language/tables.go +3675 -0
- data/ext/vendor/golang.org/x/text/language/tags.go +143 -0
- data/ext/vendor/golang.org/x/text/language/testdata/CLDRLocaleMatcherTest.txt +389 -0
- data/ext/vendor/golang.org/x/text/language/testdata/GoLocaleMatcherTest.txt +226 -0
- data/ext/vendor/golang.org/x/text/message/catalog.go +28 -0
- data/ext/vendor/golang.org/x/text/message/catalog/catalog.go +292 -0
- data/ext/vendor/golang.org/x/text/message/catalog/catalog_test.go +194 -0
- data/ext/vendor/golang.org/x/text/message/catalog/dict.go +90 -0
- data/ext/vendor/golang.org/x/text/message/doc.go +100 -0
- data/ext/vendor/golang.org/x/text/message/examples_test.go +42 -0
- data/ext/vendor/golang.org/x/text/message/fmt_test.go +1889 -0
- data/ext/vendor/golang.org/x/text/message/format.go +532 -0
- data/ext/vendor/golang.org/x/text/message/message.go +169 -0
- data/ext/vendor/golang.org/x/text/message/message_test.go +181 -0
- data/ext/vendor/golang.org/x/text/message/print.go +1194 -0
- data/ext/vendor/golang.org/x/text/number/doc.go +28 -0
- data/ext/vendor/golang.org/x/text/number/examples_test.go +28 -0
- data/ext/vendor/golang.org/x/text/number/format.go +122 -0
- data/ext/vendor/golang.org/x/text/number/format_test.go +107 -0
- data/ext/vendor/golang.org/x/text/number/number.go +77 -0
- data/ext/vendor/golang.org/x/text/number/number_test.go +190 -0
- data/ext/vendor/golang.org/x/text/number/option.go +177 -0
- data/ext/vendor/golang.org/x/text/runes/cond.go +187 -0
- data/ext/vendor/golang.org/x/text/runes/cond_test.go +282 -0
- data/ext/vendor/golang.org/x/text/runes/example_test.go +60 -0
- data/ext/vendor/golang.org/x/text/runes/runes.go +355 -0
- data/ext/vendor/golang.org/x/text/runes/runes_test.go +664 -0
- data/ext/vendor/golang.org/x/text/search/index.go +35 -0
- data/ext/vendor/golang.org/x/text/search/pattern.go +155 -0
- data/ext/vendor/golang.org/x/text/search/pattern_test.go +357 -0
- data/ext/vendor/golang.org/x/text/search/search.go +237 -0
- data/ext/vendor/golang.org/x/text/search/tables.go +12448 -0
- data/ext/vendor/golang.org/x/text/secure/bidirule/bench_test.go +54 -0
- data/ext/vendor/golang.org/x/text/secure/bidirule/bidirule.go +340 -0
- data/ext/vendor/golang.org/x/text/secure/bidirule/bidirule_test.go +851 -0
- data/ext/vendor/golang.org/x/text/secure/doc.go +6 -0
- data/ext/vendor/golang.org/x/text/secure/precis/benchmark_test.go +82 -0
- data/ext/vendor/golang.org/x/text/secure/precis/class.go +36 -0
- data/ext/vendor/golang.org/x/text/secure/precis/class_test.go +50 -0
- data/ext/vendor/golang.org/x/text/secure/precis/context.go +139 -0
- data/ext/vendor/golang.org/x/text/secure/precis/doc.go +14 -0
- data/ext/vendor/golang.org/x/text/secure/precis/enforce_test.go +396 -0
- data/ext/vendor/golang.org/x/text/secure/precis/gen.go +310 -0
- data/ext/vendor/golang.org/x/text/secure/precis/gen_trieval.go +68 -0
- data/ext/vendor/golang.org/x/text/secure/precis/nickname.go +72 -0
- data/ext/vendor/golang.org/x/text/secure/precis/options.go +157 -0
- data/ext/vendor/golang.org/x/text/secure/precis/profile.go +402 -0
- data/ext/vendor/golang.org/x/text/secure/precis/profile_test.go +149 -0
- data/ext/vendor/golang.org/x/text/secure/precis/profiles.go +78 -0
- data/ext/vendor/golang.org/x/text/secure/precis/tables.go +3887 -0
- data/ext/vendor/golang.org/x/text/secure/precis/tables_test.go +69 -0
- data/ext/vendor/golang.org/x/text/secure/precis/transformer.go +32 -0
- data/ext/vendor/golang.org/x/text/secure/precis/trieval.go +64 -0
- data/ext/vendor/golang.org/x/text/transform/examples_test.go +37 -0
- data/ext/vendor/golang.org/x/text/transform/transform.go +705 -0
- data/ext/vendor/golang.org/x/text/transform/transform_test.go +1317 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/bidi.go +198 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/bracket.go +335 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/core.go +1058 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/core_test.go +224 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/gen.go +133 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/gen_ranges.go +57 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/gen_trieval.go +64 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/prop.go +206 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/ranges_test.go +53 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/tables.go +1813 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/tables_test.go +82 -0
- data/ext/vendor/golang.org/x/text/unicode/bidi/trieval.go +60 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/base.go +100 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/cldr.go +130 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/cldr_test.go +27 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/collate.go +359 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/collate_test.go +275 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/data_test.go +186 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/decode.go +171 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/examples_test.go +21 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/makexml.go +400 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/resolve.go +602 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/resolve_test.go +368 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/slice.go +144 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/slice_test.go +175 -0
- data/ext/vendor/golang.org/x/text/unicode/cldr/xml.go +1487 -0
- data/ext/vendor/golang.org/x/text/unicode/doc.go +8 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/composition.go +508 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/composition_test.go +130 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/example_iter_test.go +82 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/example_test.go +27 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/forminfo.go +259 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/forminfo_test.go +54 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/input.go +109 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/iter.go +457 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/iter_test.go +98 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/maketables.go +976 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/norm_test.go +14 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/normalize.go +609 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/normalize_test.go +1287 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/readwriter.go +125 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/readwriter_test.go +56 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/tables.go +7651 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/transform.go +88 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/transform_test.go +101 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/trie.go +54 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/triegen.go +117 -0
- data/ext/vendor/golang.org/x/text/unicode/norm/ucd_test.go +275 -0
- data/ext/vendor/golang.org/x/text/unicode/rangetable/gen.go +115 -0
- data/ext/vendor/golang.org/x/text/unicode/rangetable/merge.go +260 -0
- data/ext/vendor/golang.org/x/text/unicode/rangetable/merge_test.go +184 -0
- data/ext/vendor/golang.org/x/text/unicode/rangetable/rangetable.go +70 -0
- data/ext/vendor/golang.org/x/text/unicode/rangetable/rangetable_test.go +55 -0
- data/ext/vendor/golang.org/x/text/unicode/rangetable/tables.go +6376 -0
- data/ext/vendor/golang.org/x/text/unicode/runenames/bits.go +59 -0
- data/ext/vendor/golang.org/x/text/unicode/runenames/example_test.go +118 -0
- data/ext/vendor/golang.org/x/text/unicode/runenames/gen.go +195 -0
- data/ext/vendor/golang.org/x/text/unicode/runenames/gen_bits.go +63 -0
- data/ext/vendor/golang.org/x/text/unicode/runenames/runenames.go +48 -0
- data/ext/vendor/golang.org/x/text/unicode/runenames/runenames_test.go +46 -0
- data/ext/vendor/golang.org/x/text/unicode/runenames/tables.go +15514 -0
- data/ext/vendor/golang.org/x/text/width/common_test.go +92 -0
- data/ext/vendor/golang.org/x/text/width/example_test.go +52 -0
- data/ext/vendor/golang.org/x/text/width/gen.go +115 -0
- data/ext/vendor/golang.org/x/text/width/gen_common.go +96 -0
- data/ext/vendor/golang.org/x/text/width/gen_trieval.go +34 -0
- data/ext/vendor/golang.org/x/text/width/kind_string.go +16 -0
- data/ext/vendor/golang.org/x/text/width/runes_test.go +461 -0
- data/ext/vendor/golang.org/x/text/width/tables.go +1316 -0
- data/ext/vendor/golang.org/x/text/width/tables_test.go +59 -0
- data/ext/vendor/golang.org/x/text/width/transform.go +239 -0
- data/ext/vendor/golang.org/x/text/width/transform_test.go +701 -0
- data/ext/vendor/golang.org/x/text/width/trieval.go +30 -0
- data/ext/vendor/golang.org/x/text/width/width.go +206 -0
- data/lib/ires/version.rb +1 -1
- data/shared/darwin/ires.so +0 -0
- data/shared/linux/ires.so +0 -0
- metadata +1011 -23
- data/ext/operate/image.go +0 -176
- data/ext/util/uri/uri.go +0 -105
- data/ext/vendor/github.com/satori/go.uuid/README.md +0 -65
- data/ext/vendor/github.com/satori/go.uuid/benchmarks_test.go +0 -121
- data/ext/vendor/github.com/satori/go.uuid/uuid.go +0 -488
- data/ext/vendor/github.com/satori/go.uuid/uuid_test.go +0 -633
@@ -0,0 +1,1939 @@
|
|
1
|
+
// Copyright 2011 The Go Authors. All rights reserved.
|
2
|
+
// Use of this source code is governed by a BSD-style
|
3
|
+
// license that can be found in the LICENSE file.
|
4
|
+
|
5
|
+
package xml
|
6
|
+
|
7
|
+
import (
|
8
|
+
"bytes"
|
9
|
+
"errors"
|
10
|
+
"fmt"
|
11
|
+
"io"
|
12
|
+
"reflect"
|
13
|
+
"strconv"
|
14
|
+
"strings"
|
15
|
+
"sync"
|
16
|
+
"testing"
|
17
|
+
"time"
|
18
|
+
)
|
19
|
+
|
20
|
+
type DriveType int
|
21
|
+
|
22
|
+
const (
|
23
|
+
HyperDrive DriveType = iota
|
24
|
+
ImprobabilityDrive
|
25
|
+
)
|
26
|
+
|
27
|
+
type Passenger struct {
|
28
|
+
Name []string `xml:"name"`
|
29
|
+
Weight float32 `xml:"weight"`
|
30
|
+
}
|
31
|
+
|
32
|
+
type Ship struct {
|
33
|
+
XMLName struct{} `xml:"spaceship"`
|
34
|
+
|
35
|
+
Name string `xml:"name,attr"`
|
36
|
+
Pilot string `xml:"pilot,attr"`
|
37
|
+
Drive DriveType `xml:"drive"`
|
38
|
+
Age uint `xml:"age"`
|
39
|
+
Passenger []*Passenger `xml:"passenger"`
|
40
|
+
secret string
|
41
|
+
}
|
42
|
+
|
43
|
+
type NamedType string
|
44
|
+
|
45
|
+
type Port struct {
|
46
|
+
XMLName struct{} `xml:"port"`
|
47
|
+
Type string `xml:"type,attr,omitempty"`
|
48
|
+
Comment string `xml:",comment"`
|
49
|
+
Number string `xml:",chardata"`
|
50
|
+
}
|
51
|
+
|
52
|
+
type Domain struct {
|
53
|
+
XMLName struct{} `xml:"domain"`
|
54
|
+
Country string `xml:",attr,omitempty"`
|
55
|
+
Name []byte `xml:",chardata"`
|
56
|
+
Comment []byte `xml:",comment"`
|
57
|
+
}
|
58
|
+
|
59
|
+
type Book struct {
|
60
|
+
XMLName struct{} `xml:"book"`
|
61
|
+
Title string `xml:",chardata"`
|
62
|
+
}
|
63
|
+
|
64
|
+
type Event struct {
|
65
|
+
XMLName struct{} `xml:"event"`
|
66
|
+
Year int `xml:",chardata"`
|
67
|
+
}
|
68
|
+
|
69
|
+
type Movie struct {
|
70
|
+
XMLName struct{} `xml:"movie"`
|
71
|
+
Length uint `xml:",chardata"`
|
72
|
+
}
|
73
|
+
|
74
|
+
type Pi struct {
|
75
|
+
XMLName struct{} `xml:"pi"`
|
76
|
+
Approximation float32 `xml:",chardata"`
|
77
|
+
}
|
78
|
+
|
79
|
+
type Universe struct {
|
80
|
+
XMLName struct{} `xml:"universe"`
|
81
|
+
Visible float64 `xml:",chardata"`
|
82
|
+
}
|
83
|
+
|
84
|
+
type Particle struct {
|
85
|
+
XMLName struct{} `xml:"particle"`
|
86
|
+
HasMass bool `xml:",chardata"`
|
87
|
+
}
|
88
|
+
|
89
|
+
type Departure struct {
|
90
|
+
XMLName struct{} `xml:"departure"`
|
91
|
+
When time.Time `xml:",chardata"`
|
92
|
+
}
|
93
|
+
|
94
|
+
type SecretAgent struct {
|
95
|
+
XMLName struct{} `xml:"agent"`
|
96
|
+
Handle string `xml:"handle,attr"`
|
97
|
+
Identity string
|
98
|
+
Obfuscate string `xml:",innerxml"`
|
99
|
+
}
|
100
|
+
|
101
|
+
type NestedItems struct {
|
102
|
+
XMLName struct{} `xml:"result"`
|
103
|
+
Items []string `xml:">item"`
|
104
|
+
Item1 []string `xml:"Items>item1"`
|
105
|
+
}
|
106
|
+
|
107
|
+
type NestedOrder struct {
|
108
|
+
XMLName struct{} `xml:"result"`
|
109
|
+
Field1 string `xml:"parent>c"`
|
110
|
+
Field2 string `xml:"parent>b"`
|
111
|
+
Field3 string `xml:"parent>a"`
|
112
|
+
}
|
113
|
+
|
114
|
+
type MixedNested struct {
|
115
|
+
XMLName struct{} `xml:"result"`
|
116
|
+
A string `xml:"parent1>a"`
|
117
|
+
B string `xml:"b"`
|
118
|
+
C string `xml:"parent1>parent2>c"`
|
119
|
+
D string `xml:"parent1>d"`
|
120
|
+
}
|
121
|
+
|
122
|
+
type NilTest struct {
|
123
|
+
A interface{} `xml:"parent1>parent2>a"`
|
124
|
+
B interface{} `xml:"parent1>b"`
|
125
|
+
C interface{} `xml:"parent1>parent2>c"`
|
126
|
+
}
|
127
|
+
|
128
|
+
type Service struct {
|
129
|
+
XMLName struct{} `xml:"service"`
|
130
|
+
Domain *Domain `xml:"host>domain"`
|
131
|
+
Port *Port `xml:"host>port"`
|
132
|
+
Extra1 interface{}
|
133
|
+
Extra2 interface{} `xml:"host>extra2"`
|
134
|
+
}
|
135
|
+
|
136
|
+
var nilStruct *Ship
|
137
|
+
|
138
|
+
type EmbedA struct {
|
139
|
+
EmbedC
|
140
|
+
EmbedB EmbedB
|
141
|
+
FieldA string
|
142
|
+
}
|
143
|
+
|
144
|
+
type EmbedB struct {
|
145
|
+
FieldB string
|
146
|
+
*EmbedC
|
147
|
+
}
|
148
|
+
|
149
|
+
type EmbedC struct {
|
150
|
+
FieldA1 string `xml:"FieldA>A1"`
|
151
|
+
FieldA2 string `xml:"FieldA>A2"`
|
152
|
+
FieldB string
|
153
|
+
FieldC string
|
154
|
+
}
|
155
|
+
|
156
|
+
type NameCasing struct {
|
157
|
+
XMLName struct{} `xml:"casing"`
|
158
|
+
Xy string
|
159
|
+
XY string
|
160
|
+
XyA string `xml:"Xy,attr"`
|
161
|
+
XYA string `xml:"XY,attr"`
|
162
|
+
}
|
163
|
+
|
164
|
+
type NamePrecedence struct {
|
165
|
+
XMLName Name `xml:"Parent"`
|
166
|
+
FromTag XMLNameWithoutTag `xml:"InTag"`
|
167
|
+
FromNameVal XMLNameWithoutTag
|
168
|
+
FromNameTag XMLNameWithTag
|
169
|
+
InFieldName string
|
170
|
+
}
|
171
|
+
|
172
|
+
type XMLNameWithTag struct {
|
173
|
+
XMLName Name `xml:"InXMLNameTag"`
|
174
|
+
Value string `xml:",chardata"`
|
175
|
+
}
|
176
|
+
|
177
|
+
type XMLNameWithNSTag struct {
|
178
|
+
XMLName Name `xml:"ns InXMLNameWithNSTag"`
|
179
|
+
Value string `xml:",chardata"`
|
180
|
+
}
|
181
|
+
|
182
|
+
type XMLNameWithoutTag struct {
|
183
|
+
XMLName Name
|
184
|
+
Value string `xml:",chardata"`
|
185
|
+
}
|
186
|
+
|
187
|
+
type NameInField struct {
|
188
|
+
Foo Name `xml:"ns foo"`
|
189
|
+
}
|
190
|
+
|
191
|
+
type AttrTest struct {
|
192
|
+
Int int `xml:",attr"`
|
193
|
+
Named int `xml:"int,attr"`
|
194
|
+
Float float64 `xml:",attr"`
|
195
|
+
Uint8 uint8 `xml:",attr"`
|
196
|
+
Bool bool `xml:",attr"`
|
197
|
+
Str string `xml:",attr"`
|
198
|
+
Bytes []byte `xml:",attr"`
|
199
|
+
}
|
200
|
+
|
201
|
+
type OmitAttrTest struct {
|
202
|
+
Int int `xml:",attr,omitempty"`
|
203
|
+
Named int `xml:"int,attr,omitempty"`
|
204
|
+
Float float64 `xml:",attr,omitempty"`
|
205
|
+
Uint8 uint8 `xml:",attr,omitempty"`
|
206
|
+
Bool bool `xml:",attr,omitempty"`
|
207
|
+
Str string `xml:",attr,omitempty"`
|
208
|
+
Bytes []byte `xml:",attr,omitempty"`
|
209
|
+
}
|
210
|
+
|
211
|
+
type OmitFieldTest struct {
|
212
|
+
Int int `xml:",omitempty"`
|
213
|
+
Named int `xml:"int,omitempty"`
|
214
|
+
Float float64 `xml:",omitempty"`
|
215
|
+
Uint8 uint8 `xml:",omitempty"`
|
216
|
+
Bool bool `xml:",omitempty"`
|
217
|
+
Str string `xml:",omitempty"`
|
218
|
+
Bytes []byte `xml:",omitempty"`
|
219
|
+
Ptr *PresenceTest `xml:",omitempty"`
|
220
|
+
}
|
221
|
+
|
222
|
+
type AnyTest struct {
|
223
|
+
XMLName struct{} `xml:"a"`
|
224
|
+
Nested string `xml:"nested>value"`
|
225
|
+
AnyField AnyHolder `xml:",any"`
|
226
|
+
}
|
227
|
+
|
228
|
+
type AnyOmitTest struct {
|
229
|
+
XMLName struct{} `xml:"a"`
|
230
|
+
Nested string `xml:"nested>value"`
|
231
|
+
AnyField *AnyHolder `xml:",any,omitempty"`
|
232
|
+
}
|
233
|
+
|
234
|
+
type AnySliceTest struct {
|
235
|
+
XMLName struct{} `xml:"a"`
|
236
|
+
Nested string `xml:"nested>value"`
|
237
|
+
AnyField []AnyHolder `xml:",any"`
|
238
|
+
}
|
239
|
+
|
240
|
+
type AnyHolder struct {
|
241
|
+
XMLName Name
|
242
|
+
XML string `xml:",innerxml"`
|
243
|
+
}
|
244
|
+
|
245
|
+
type RecurseA struct {
|
246
|
+
A string
|
247
|
+
B *RecurseB
|
248
|
+
}
|
249
|
+
|
250
|
+
type RecurseB struct {
|
251
|
+
A *RecurseA
|
252
|
+
B string
|
253
|
+
}
|
254
|
+
|
255
|
+
type PresenceTest struct {
|
256
|
+
Exists *struct{}
|
257
|
+
}
|
258
|
+
|
259
|
+
type IgnoreTest struct {
|
260
|
+
PublicSecret string `xml:"-"`
|
261
|
+
}
|
262
|
+
|
263
|
+
type MyBytes []byte
|
264
|
+
|
265
|
+
type Data struct {
|
266
|
+
Bytes []byte
|
267
|
+
Attr []byte `xml:",attr"`
|
268
|
+
Custom MyBytes
|
269
|
+
}
|
270
|
+
|
271
|
+
type Plain struct {
|
272
|
+
V interface{}
|
273
|
+
}
|
274
|
+
|
275
|
+
type MyInt int
|
276
|
+
|
277
|
+
type EmbedInt struct {
|
278
|
+
MyInt
|
279
|
+
}
|
280
|
+
|
281
|
+
type Strings struct {
|
282
|
+
X []string `xml:"A>B,omitempty"`
|
283
|
+
}
|
284
|
+
|
285
|
+
type PointerFieldsTest struct {
|
286
|
+
XMLName Name `xml:"dummy"`
|
287
|
+
Name *string `xml:"name,attr"`
|
288
|
+
Age *uint `xml:"age,attr"`
|
289
|
+
Empty *string `xml:"empty,attr"`
|
290
|
+
Contents *string `xml:",chardata"`
|
291
|
+
}
|
292
|
+
|
293
|
+
type ChardataEmptyTest struct {
|
294
|
+
XMLName Name `xml:"test"`
|
295
|
+
Contents *string `xml:",chardata"`
|
296
|
+
}
|
297
|
+
|
298
|
+
type MyMarshalerTest struct {
|
299
|
+
}
|
300
|
+
|
301
|
+
var _ Marshaler = (*MyMarshalerTest)(nil)
|
302
|
+
|
303
|
+
func (m *MyMarshalerTest) MarshalXML(e *Encoder, start StartElement) error {
|
304
|
+
e.EncodeToken(start)
|
305
|
+
e.EncodeToken(CharData([]byte("hello world")))
|
306
|
+
e.EncodeToken(EndElement{start.Name})
|
307
|
+
return nil
|
308
|
+
}
|
309
|
+
|
310
|
+
type MyMarshalerAttrTest struct{}
|
311
|
+
|
312
|
+
var _ MarshalerAttr = (*MyMarshalerAttrTest)(nil)
|
313
|
+
|
314
|
+
func (m *MyMarshalerAttrTest) MarshalXMLAttr(name Name) (Attr, error) {
|
315
|
+
return Attr{name, "hello world"}, nil
|
316
|
+
}
|
317
|
+
|
318
|
+
type MyMarshalerValueAttrTest struct{}
|
319
|
+
|
320
|
+
var _ MarshalerAttr = MyMarshalerValueAttrTest{}
|
321
|
+
|
322
|
+
func (m MyMarshalerValueAttrTest) MarshalXMLAttr(name Name) (Attr, error) {
|
323
|
+
return Attr{name, "hello world"}, nil
|
324
|
+
}
|
325
|
+
|
326
|
+
type MarshalerStruct struct {
|
327
|
+
Foo MyMarshalerAttrTest `xml:",attr"`
|
328
|
+
}
|
329
|
+
|
330
|
+
type MarshalerValueStruct struct {
|
331
|
+
Foo MyMarshalerValueAttrTest `xml:",attr"`
|
332
|
+
}
|
333
|
+
|
334
|
+
type InnerStruct struct {
|
335
|
+
XMLName Name `xml:"testns outer"`
|
336
|
+
}
|
337
|
+
|
338
|
+
type OuterStruct struct {
|
339
|
+
InnerStruct
|
340
|
+
IntAttr int `xml:"int,attr"`
|
341
|
+
}
|
342
|
+
|
343
|
+
type OuterNamedStruct struct {
|
344
|
+
InnerStruct
|
345
|
+
XMLName Name `xml:"outerns test"`
|
346
|
+
IntAttr int `xml:"int,attr"`
|
347
|
+
}
|
348
|
+
|
349
|
+
type OuterNamedOrderedStruct struct {
|
350
|
+
XMLName Name `xml:"outerns test"`
|
351
|
+
InnerStruct
|
352
|
+
IntAttr int `xml:"int,attr"`
|
353
|
+
}
|
354
|
+
|
355
|
+
type OuterOuterStruct struct {
|
356
|
+
OuterStruct
|
357
|
+
}
|
358
|
+
|
359
|
+
type NestedAndChardata struct {
|
360
|
+
AB []string `xml:"A>B"`
|
361
|
+
Chardata string `xml:",chardata"`
|
362
|
+
}
|
363
|
+
|
364
|
+
type NestedAndComment struct {
|
365
|
+
AB []string `xml:"A>B"`
|
366
|
+
Comment string `xml:",comment"`
|
367
|
+
}
|
368
|
+
|
369
|
+
type XMLNSFieldStruct struct {
|
370
|
+
Ns string `xml:"xmlns,attr"`
|
371
|
+
Body string
|
372
|
+
}
|
373
|
+
|
374
|
+
type NamedXMLNSFieldStruct struct {
|
375
|
+
XMLName struct{} `xml:"testns test"`
|
376
|
+
Ns string `xml:"xmlns,attr"`
|
377
|
+
Body string
|
378
|
+
}
|
379
|
+
|
380
|
+
type XMLNSFieldStructWithOmitEmpty struct {
|
381
|
+
Ns string `xml:"xmlns,attr,omitempty"`
|
382
|
+
Body string
|
383
|
+
}
|
384
|
+
|
385
|
+
type NamedXMLNSFieldStructWithEmptyNamespace struct {
|
386
|
+
XMLName struct{} `xml:"test"`
|
387
|
+
Ns string `xml:"xmlns,attr"`
|
388
|
+
Body string
|
389
|
+
}
|
390
|
+
|
391
|
+
type RecursiveXMLNSFieldStruct struct {
|
392
|
+
Ns string `xml:"xmlns,attr"`
|
393
|
+
Body *RecursiveXMLNSFieldStruct `xml:",omitempty"`
|
394
|
+
Text string `xml:",omitempty"`
|
395
|
+
}
|
396
|
+
|
397
|
+
func ifaceptr(x interface{}) interface{} {
|
398
|
+
return &x
|
399
|
+
}
|
400
|
+
|
401
|
+
var (
|
402
|
+
nameAttr = "Sarah"
|
403
|
+
ageAttr = uint(12)
|
404
|
+
contentsAttr = "lorem ipsum"
|
405
|
+
)
|
406
|
+
|
407
|
+
// Unless explicitly stated as such (or *Plain), all of the
|
408
|
+
// tests below are two-way tests. When introducing new tests,
|
409
|
+
// please try to make them two-way as well to ensure that
|
410
|
+
// marshalling and unmarshalling are as symmetrical as feasible.
|
411
|
+
var marshalTests = []struct {
|
412
|
+
Value interface{}
|
413
|
+
ExpectXML string
|
414
|
+
MarshalOnly bool
|
415
|
+
UnmarshalOnly bool
|
416
|
+
}{
|
417
|
+
// Test nil marshals to nothing
|
418
|
+
{Value: nil, ExpectXML: ``, MarshalOnly: true},
|
419
|
+
{Value: nilStruct, ExpectXML: ``, MarshalOnly: true},
|
420
|
+
|
421
|
+
// Test value types
|
422
|
+
{Value: &Plain{true}, ExpectXML: `<Plain><V>true</V></Plain>`},
|
423
|
+
{Value: &Plain{false}, ExpectXML: `<Plain><V>false</V></Plain>`},
|
424
|
+
{Value: &Plain{int(42)}, ExpectXML: `<Plain><V>42</V></Plain>`},
|
425
|
+
{Value: &Plain{int8(42)}, ExpectXML: `<Plain><V>42</V></Plain>`},
|
426
|
+
{Value: &Plain{int16(42)}, ExpectXML: `<Plain><V>42</V></Plain>`},
|
427
|
+
{Value: &Plain{int32(42)}, ExpectXML: `<Plain><V>42</V></Plain>`},
|
428
|
+
{Value: &Plain{uint(42)}, ExpectXML: `<Plain><V>42</V></Plain>`},
|
429
|
+
{Value: &Plain{uint8(42)}, ExpectXML: `<Plain><V>42</V></Plain>`},
|
430
|
+
{Value: &Plain{uint16(42)}, ExpectXML: `<Plain><V>42</V></Plain>`},
|
431
|
+
{Value: &Plain{uint32(42)}, ExpectXML: `<Plain><V>42</V></Plain>`},
|
432
|
+
{Value: &Plain{float32(1.25)}, ExpectXML: `<Plain><V>1.25</V></Plain>`},
|
433
|
+
{Value: &Plain{float64(1.25)}, ExpectXML: `<Plain><V>1.25</V></Plain>`},
|
434
|
+
{Value: &Plain{uintptr(0xFFDD)}, ExpectXML: `<Plain><V>65501</V></Plain>`},
|
435
|
+
{Value: &Plain{"gopher"}, ExpectXML: `<Plain><V>gopher</V></Plain>`},
|
436
|
+
{Value: &Plain{[]byte("gopher")}, ExpectXML: `<Plain><V>gopher</V></Plain>`},
|
437
|
+
{Value: &Plain{"</>"}, ExpectXML: `<Plain><V></></V></Plain>`},
|
438
|
+
{Value: &Plain{[]byte("</>")}, ExpectXML: `<Plain><V></></V></Plain>`},
|
439
|
+
{Value: &Plain{[3]byte{'<', '/', '>'}}, ExpectXML: `<Plain><V></></V></Plain>`},
|
440
|
+
{Value: &Plain{NamedType("potato")}, ExpectXML: `<Plain><V>potato</V></Plain>`},
|
441
|
+
{Value: &Plain{[]int{1, 2, 3}}, ExpectXML: `<Plain><V>1</V><V>2</V><V>3</V></Plain>`},
|
442
|
+
{Value: &Plain{[3]int{1, 2, 3}}, ExpectXML: `<Plain><V>1</V><V>2</V><V>3</V></Plain>`},
|
443
|
+
{Value: ifaceptr(true), MarshalOnly: true, ExpectXML: `<bool>true</bool>`},
|
444
|
+
|
445
|
+
// Test time.
|
446
|
+
{
|
447
|
+
Value: &Plain{time.Unix(1e9, 123456789).UTC()},
|
448
|
+
ExpectXML: `<Plain><V>2001-09-09T01:46:40.123456789Z</V></Plain>`,
|
449
|
+
},
|
450
|
+
|
451
|
+
// A pointer to struct{} may be used to test for an element's presence.
|
452
|
+
{
|
453
|
+
Value: &PresenceTest{new(struct{})},
|
454
|
+
ExpectXML: `<PresenceTest><Exists></Exists></PresenceTest>`,
|
455
|
+
},
|
456
|
+
{
|
457
|
+
Value: &PresenceTest{},
|
458
|
+
ExpectXML: `<PresenceTest></PresenceTest>`,
|
459
|
+
},
|
460
|
+
|
461
|
+
// A pointer to struct{} may be used to test for an element's presence.
|
462
|
+
{
|
463
|
+
Value: &PresenceTest{new(struct{})},
|
464
|
+
ExpectXML: `<PresenceTest><Exists></Exists></PresenceTest>`,
|
465
|
+
},
|
466
|
+
{
|
467
|
+
Value: &PresenceTest{},
|
468
|
+
ExpectXML: `<PresenceTest></PresenceTest>`,
|
469
|
+
},
|
470
|
+
|
471
|
+
// A []byte field is only nil if the element was not found.
|
472
|
+
{
|
473
|
+
Value: &Data{},
|
474
|
+
ExpectXML: `<Data></Data>`,
|
475
|
+
UnmarshalOnly: true,
|
476
|
+
},
|
477
|
+
{
|
478
|
+
Value: &Data{Bytes: []byte{}, Custom: MyBytes{}, Attr: []byte{}},
|
479
|
+
ExpectXML: `<Data Attr=""><Bytes></Bytes><Custom></Custom></Data>`,
|
480
|
+
UnmarshalOnly: true,
|
481
|
+
},
|
482
|
+
|
483
|
+
// Check that []byte works, including named []byte types.
|
484
|
+
{
|
485
|
+
Value: &Data{Bytes: []byte("ab"), Custom: MyBytes("cd"), Attr: []byte{'v'}},
|
486
|
+
ExpectXML: `<Data Attr="v"><Bytes>ab</Bytes><Custom>cd</Custom></Data>`,
|
487
|
+
},
|
488
|
+
|
489
|
+
// Test innerxml
|
490
|
+
{
|
491
|
+
Value: &SecretAgent{
|
492
|
+
Handle: "007",
|
493
|
+
Identity: "James Bond",
|
494
|
+
Obfuscate: "<redacted/>",
|
495
|
+
},
|
496
|
+
ExpectXML: `<agent handle="007"><Identity>James Bond</Identity><redacted/></agent>`,
|
497
|
+
MarshalOnly: true,
|
498
|
+
},
|
499
|
+
{
|
500
|
+
Value: &SecretAgent{
|
501
|
+
Handle: "007",
|
502
|
+
Identity: "James Bond",
|
503
|
+
Obfuscate: "<Identity>James Bond</Identity><redacted/>",
|
504
|
+
},
|
505
|
+
ExpectXML: `<agent handle="007"><Identity>James Bond</Identity><redacted/></agent>`,
|
506
|
+
UnmarshalOnly: true,
|
507
|
+
},
|
508
|
+
|
509
|
+
// Test structs
|
510
|
+
{Value: &Port{Type: "ssl", Number: "443"}, ExpectXML: `<port type="ssl">443</port>`},
|
511
|
+
{Value: &Port{Number: "443"}, ExpectXML: `<port>443</port>`},
|
512
|
+
{Value: &Port{Type: "<unix>"}, ExpectXML: `<port type="<unix>"></port>`},
|
513
|
+
{Value: &Port{Number: "443", Comment: "https"}, ExpectXML: `<port><!--https-->443</port>`},
|
514
|
+
{Value: &Port{Number: "443", Comment: "add space-"}, ExpectXML: `<port><!--add space- -->443</port>`, MarshalOnly: true},
|
515
|
+
{Value: &Domain{Name: []byte("google.com&friends")}, ExpectXML: `<domain>google.com&friends</domain>`},
|
516
|
+
{Value: &Domain{Name: []byte("google.com"), Comment: []byte(" &friends ")}, ExpectXML: `<domain>google.com<!-- &friends --></domain>`},
|
517
|
+
{Value: &Book{Title: "Pride & Prejudice"}, ExpectXML: `<book>Pride & Prejudice</book>`},
|
518
|
+
{Value: &Event{Year: -3114}, ExpectXML: `<event>-3114</event>`},
|
519
|
+
{Value: &Movie{Length: 13440}, ExpectXML: `<movie>13440</movie>`},
|
520
|
+
{Value: &Pi{Approximation: 3.14159265}, ExpectXML: `<pi>3.1415927</pi>`},
|
521
|
+
{Value: &Universe{Visible: 9.3e13}, ExpectXML: `<universe>9.3e+13</universe>`},
|
522
|
+
{Value: &Particle{HasMass: true}, ExpectXML: `<particle>true</particle>`},
|
523
|
+
{Value: &Departure{When: ParseTime("2013-01-09T00:15:00-09:00")}, ExpectXML: `<departure>2013-01-09T00:15:00-09:00</departure>`},
|
524
|
+
{Value: atomValue, ExpectXML: atomXml},
|
525
|
+
{
|
526
|
+
Value: &Ship{
|
527
|
+
Name: "Heart of Gold",
|
528
|
+
Pilot: "Computer",
|
529
|
+
Age: 1,
|
530
|
+
Drive: ImprobabilityDrive,
|
531
|
+
Passenger: []*Passenger{
|
532
|
+
{
|
533
|
+
Name: []string{"Zaphod", "Beeblebrox"},
|
534
|
+
Weight: 7.25,
|
535
|
+
},
|
536
|
+
{
|
537
|
+
Name: []string{"Trisha", "McMillen"},
|
538
|
+
Weight: 5.5,
|
539
|
+
},
|
540
|
+
{
|
541
|
+
Name: []string{"Ford", "Prefect"},
|
542
|
+
Weight: 7,
|
543
|
+
},
|
544
|
+
{
|
545
|
+
Name: []string{"Arthur", "Dent"},
|
546
|
+
Weight: 6.75,
|
547
|
+
},
|
548
|
+
},
|
549
|
+
},
|
550
|
+
ExpectXML: `<spaceship name="Heart of Gold" pilot="Computer">` +
|
551
|
+
`<drive>` + strconv.Itoa(int(ImprobabilityDrive)) + `</drive>` +
|
552
|
+
`<age>1</age>` +
|
553
|
+
`<passenger>` +
|
554
|
+
`<name>Zaphod</name>` +
|
555
|
+
`<name>Beeblebrox</name>` +
|
556
|
+
`<weight>7.25</weight>` +
|
557
|
+
`</passenger>` +
|
558
|
+
`<passenger>` +
|
559
|
+
`<name>Trisha</name>` +
|
560
|
+
`<name>McMillen</name>` +
|
561
|
+
`<weight>5.5</weight>` +
|
562
|
+
`</passenger>` +
|
563
|
+
`<passenger>` +
|
564
|
+
`<name>Ford</name>` +
|
565
|
+
`<name>Prefect</name>` +
|
566
|
+
`<weight>7</weight>` +
|
567
|
+
`</passenger>` +
|
568
|
+
`<passenger>` +
|
569
|
+
`<name>Arthur</name>` +
|
570
|
+
`<name>Dent</name>` +
|
571
|
+
`<weight>6.75</weight>` +
|
572
|
+
`</passenger>` +
|
573
|
+
`</spaceship>`,
|
574
|
+
},
|
575
|
+
|
576
|
+
// Test a>b
|
577
|
+
{
|
578
|
+
Value: &NestedItems{Items: nil, Item1: nil},
|
579
|
+
ExpectXML: `<result>` +
|
580
|
+
`<Items>` +
|
581
|
+
`</Items>` +
|
582
|
+
`</result>`,
|
583
|
+
},
|
584
|
+
{
|
585
|
+
Value: &NestedItems{Items: []string{}, Item1: []string{}},
|
586
|
+
ExpectXML: `<result>` +
|
587
|
+
`<Items>` +
|
588
|
+
`</Items>` +
|
589
|
+
`</result>`,
|
590
|
+
MarshalOnly: true,
|
591
|
+
},
|
592
|
+
{
|
593
|
+
Value: &NestedItems{Items: nil, Item1: []string{"A"}},
|
594
|
+
ExpectXML: `<result>` +
|
595
|
+
`<Items>` +
|
596
|
+
`<item1>A</item1>` +
|
597
|
+
`</Items>` +
|
598
|
+
`</result>`,
|
599
|
+
},
|
600
|
+
{
|
601
|
+
Value: &NestedItems{Items: []string{"A", "B"}, Item1: nil},
|
602
|
+
ExpectXML: `<result>` +
|
603
|
+
`<Items>` +
|
604
|
+
`<item>A</item>` +
|
605
|
+
`<item>B</item>` +
|
606
|
+
`</Items>` +
|
607
|
+
`</result>`,
|
608
|
+
},
|
609
|
+
{
|
610
|
+
Value: &NestedItems{Items: []string{"A", "B"}, Item1: []string{"C"}},
|
611
|
+
ExpectXML: `<result>` +
|
612
|
+
`<Items>` +
|
613
|
+
`<item>A</item>` +
|
614
|
+
`<item>B</item>` +
|
615
|
+
`<item1>C</item1>` +
|
616
|
+
`</Items>` +
|
617
|
+
`</result>`,
|
618
|
+
},
|
619
|
+
{
|
620
|
+
Value: &NestedOrder{Field1: "C", Field2: "B", Field3: "A"},
|
621
|
+
ExpectXML: `<result>` +
|
622
|
+
`<parent>` +
|
623
|
+
`<c>C</c>` +
|
624
|
+
`<b>B</b>` +
|
625
|
+
`<a>A</a>` +
|
626
|
+
`</parent>` +
|
627
|
+
`</result>`,
|
628
|
+
},
|
629
|
+
{
|
630
|
+
Value: &NilTest{A: "A", B: nil, C: "C"},
|
631
|
+
ExpectXML: `<NilTest>` +
|
632
|
+
`<parent1>` +
|
633
|
+
`<parent2><a>A</a></parent2>` +
|
634
|
+
`<parent2><c>C</c></parent2>` +
|
635
|
+
`</parent1>` +
|
636
|
+
`</NilTest>`,
|
637
|
+
MarshalOnly: true, // Uses interface{}
|
638
|
+
},
|
639
|
+
{
|
640
|
+
Value: &MixedNested{A: "A", B: "B", C: "C", D: "D"},
|
641
|
+
ExpectXML: `<result>` +
|
642
|
+
`<parent1><a>A</a></parent1>` +
|
643
|
+
`<b>B</b>` +
|
644
|
+
`<parent1>` +
|
645
|
+
`<parent2><c>C</c></parent2>` +
|
646
|
+
`<d>D</d>` +
|
647
|
+
`</parent1>` +
|
648
|
+
`</result>`,
|
649
|
+
},
|
650
|
+
{
|
651
|
+
Value: &Service{Port: &Port{Number: "80"}},
|
652
|
+
ExpectXML: `<service><host><port>80</port></host></service>`,
|
653
|
+
},
|
654
|
+
{
|
655
|
+
Value: &Service{},
|
656
|
+
ExpectXML: `<service></service>`,
|
657
|
+
},
|
658
|
+
{
|
659
|
+
Value: &Service{Port: &Port{Number: "80"}, Extra1: "A", Extra2: "B"},
|
660
|
+
ExpectXML: `<service>` +
|
661
|
+
`<host><port>80</port></host>` +
|
662
|
+
`<Extra1>A</Extra1>` +
|
663
|
+
`<host><extra2>B</extra2></host>` +
|
664
|
+
`</service>`,
|
665
|
+
MarshalOnly: true,
|
666
|
+
},
|
667
|
+
{
|
668
|
+
Value: &Service{Port: &Port{Number: "80"}, Extra2: "example"},
|
669
|
+
ExpectXML: `<service>` +
|
670
|
+
`<host><port>80</port></host>` +
|
671
|
+
`<host><extra2>example</extra2></host>` +
|
672
|
+
`</service>`,
|
673
|
+
MarshalOnly: true,
|
674
|
+
},
|
675
|
+
{
|
676
|
+
Value: &struct {
|
677
|
+
XMLName struct{} `xml:"space top"`
|
678
|
+
A string `xml:"x>a"`
|
679
|
+
B string `xml:"x>b"`
|
680
|
+
C string `xml:"space x>c"`
|
681
|
+
C1 string `xml:"space1 x>c"`
|
682
|
+
D1 string `xml:"space1 x>d"`
|
683
|
+
E1 string `xml:"x>e"`
|
684
|
+
}{
|
685
|
+
A: "a",
|
686
|
+
B: "b",
|
687
|
+
C: "c",
|
688
|
+
C1: "c1",
|
689
|
+
D1: "d1",
|
690
|
+
E1: "e1",
|
691
|
+
},
|
692
|
+
ExpectXML: `<top xmlns="space">` +
|
693
|
+
`<x><a>a</a><b>b</b><c>c</c></x>` +
|
694
|
+
`<x xmlns="space1">` +
|
695
|
+
`<c>c1</c>` +
|
696
|
+
`<d>d1</d>` +
|
697
|
+
`</x>` +
|
698
|
+
`<x>` +
|
699
|
+
`<e>e1</e>` +
|
700
|
+
`</x>` +
|
701
|
+
`</top>`,
|
702
|
+
},
|
703
|
+
{
|
704
|
+
Value: &struct {
|
705
|
+
XMLName Name
|
706
|
+
A string `xml:"x>a"`
|
707
|
+
B string `xml:"x>b"`
|
708
|
+
C string `xml:"space x>c"`
|
709
|
+
C1 string `xml:"space1 x>c"`
|
710
|
+
D1 string `xml:"space1 x>d"`
|
711
|
+
}{
|
712
|
+
XMLName: Name{
|
713
|
+
Space: "space0",
|
714
|
+
Local: "top",
|
715
|
+
},
|
716
|
+
A: "a",
|
717
|
+
B: "b",
|
718
|
+
C: "c",
|
719
|
+
C1: "c1",
|
720
|
+
D1: "d1",
|
721
|
+
},
|
722
|
+
ExpectXML: `<top xmlns="space0">` +
|
723
|
+
`<x><a>a</a><b>b</b></x>` +
|
724
|
+
`<x xmlns="space"><c>c</c></x>` +
|
725
|
+
`<x xmlns="space1">` +
|
726
|
+
`<c>c1</c>` +
|
727
|
+
`<d>d1</d>` +
|
728
|
+
`</x>` +
|
729
|
+
`</top>`,
|
730
|
+
},
|
731
|
+
{
|
732
|
+
Value: &struct {
|
733
|
+
XMLName struct{} `xml:"top"`
|
734
|
+
B string `xml:"space x>b"`
|
735
|
+
B1 string `xml:"space1 x>b"`
|
736
|
+
}{
|
737
|
+
B: "b",
|
738
|
+
B1: "b1",
|
739
|
+
},
|
740
|
+
ExpectXML: `<top>` +
|
741
|
+
`<x xmlns="space"><b>b</b></x>` +
|
742
|
+
`<x xmlns="space1"><b>b1</b></x>` +
|
743
|
+
`</top>`,
|
744
|
+
},
|
745
|
+
|
746
|
+
// Test struct embedding
|
747
|
+
{
|
748
|
+
Value: &EmbedA{
|
749
|
+
EmbedC: EmbedC{
|
750
|
+
FieldA1: "", // Shadowed by A.A
|
751
|
+
FieldA2: "", // Shadowed by A.A
|
752
|
+
FieldB: "A.C.B",
|
753
|
+
FieldC: "A.C.C",
|
754
|
+
},
|
755
|
+
EmbedB: EmbedB{
|
756
|
+
FieldB: "A.B.B",
|
757
|
+
EmbedC: &EmbedC{
|
758
|
+
FieldA1: "A.B.C.A1",
|
759
|
+
FieldA2: "A.B.C.A2",
|
760
|
+
FieldB: "", // Shadowed by A.B.B
|
761
|
+
FieldC: "A.B.C.C",
|
762
|
+
},
|
763
|
+
},
|
764
|
+
FieldA: "A.A",
|
765
|
+
},
|
766
|
+
ExpectXML: `<EmbedA>` +
|
767
|
+
`<FieldB>A.C.B</FieldB>` +
|
768
|
+
`<FieldC>A.C.C</FieldC>` +
|
769
|
+
`<EmbedB>` +
|
770
|
+
`<FieldB>A.B.B</FieldB>` +
|
771
|
+
`<FieldA>` +
|
772
|
+
`<A1>A.B.C.A1</A1>` +
|
773
|
+
`<A2>A.B.C.A2</A2>` +
|
774
|
+
`</FieldA>` +
|
775
|
+
`<FieldC>A.B.C.C</FieldC>` +
|
776
|
+
`</EmbedB>` +
|
777
|
+
`<FieldA>A.A</FieldA>` +
|
778
|
+
`</EmbedA>`,
|
779
|
+
},
|
780
|
+
|
781
|
+
// Test that name casing matters
|
782
|
+
{
|
783
|
+
Value: &NameCasing{Xy: "mixed", XY: "upper", XyA: "mixedA", XYA: "upperA"},
|
784
|
+
ExpectXML: `<casing Xy="mixedA" XY="upperA"><Xy>mixed</Xy><XY>upper</XY></casing>`,
|
785
|
+
},
|
786
|
+
|
787
|
+
// Test the order in which the XML element name is chosen
|
788
|
+
{
|
789
|
+
Value: &NamePrecedence{
|
790
|
+
FromTag: XMLNameWithoutTag{Value: "A"},
|
791
|
+
FromNameVal: XMLNameWithoutTag{XMLName: Name{Local: "InXMLName"}, Value: "B"},
|
792
|
+
FromNameTag: XMLNameWithTag{Value: "C"},
|
793
|
+
InFieldName: "D",
|
794
|
+
},
|
795
|
+
ExpectXML: `<Parent>` +
|
796
|
+
`<InTag>A</InTag>` +
|
797
|
+
`<InXMLName>B</InXMLName>` +
|
798
|
+
`<InXMLNameTag>C</InXMLNameTag>` +
|
799
|
+
`<InFieldName>D</InFieldName>` +
|
800
|
+
`</Parent>`,
|
801
|
+
MarshalOnly: true,
|
802
|
+
},
|
803
|
+
{
|
804
|
+
Value: &NamePrecedence{
|
805
|
+
XMLName: Name{Local: "Parent"},
|
806
|
+
FromTag: XMLNameWithoutTag{XMLName: Name{Local: "InTag"}, Value: "A"},
|
807
|
+
FromNameVal: XMLNameWithoutTag{XMLName: Name{Local: "FromNameVal"}, Value: "B"},
|
808
|
+
FromNameTag: XMLNameWithTag{XMLName: Name{Local: "InXMLNameTag"}, Value: "C"},
|
809
|
+
InFieldName: "D",
|
810
|
+
},
|
811
|
+
ExpectXML: `<Parent>` +
|
812
|
+
`<InTag>A</InTag>` +
|
813
|
+
`<FromNameVal>B</FromNameVal>` +
|
814
|
+
`<InXMLNameTag>C</InXMLNameTag>` +
|
815
|
+
`<InFieldName>D</InFieldName>` +
|
816
|
+
`</Parent>`,
|
817
|
+
UnmarshalOnly: true,
|
818
|
+
},
|
819
|
+
|
820
|
+
// xml.Name works in a plain field as well.
|
821
|
+
{
|
822
|
+
Value: &NameInField{Name{Space: "ns", Local: "foo"}},
|
823
|
+
ExpectXML: `<NameInField><foo xmlns="ns"></foo></NameInField>`,
|
824
|
+
},
|
825
|
+
{
|
826
|
+
Value: &NameInField{Name{Space: "ns", Local: "foo"}},
|
827
|
+
ExpectXML: `<NameInField><foo xmlns="ns"><ignore></ignore></foo></NameInField>`,
|
828
|
+
UnmarshalOnly: true,
|
829
|
+
},
|
830
|
+
|
831
|
+
// Marshaling zero xml.Name uses the tag or field name.
|
832
|
+
{
|
833
|
+
Value: &NameInField{},
|
834
|
+
ExpectXML: `<NameInField><foo xmlns="ns"></foo></NameInField>`,
|
835
|
+
MarshalOnly: true,
|
836
|
+
},
|
837
|
+
|
838
|
+
// Test attributes
|
839
|
+
{
|
840
|
+
Value: &AttrTest{
|
841
|
+
Int: 8,
|
842
|
+
Named: 9,
|
843
|
+
Float: 23.5,
|
844
|
+
Uint8: 255,
|
845
|
+
Bool: true,
|
846
|
+
Str: "str",
|
847
|
+
Bytes: []byte("byt"),
|
848
|
+
},
|
849
|
+
ExpectXML: `<AttrTest Int="8" int="9" Float="23.5" Uint8="255"` +
|
850
|
+
` Bool="true" Str="str" Bytes="byt"></AttrTest>`,
|
851
|
+
},
|
852
|
+
{
|
853
|
+
Value: &AttrTest{Bytes: []byte{}},
|
854
|
+
ExpectXML: `<AttrTest Int="0" int="0" Float="0" Uint8="0"` +
|
855
|
+
` Bool="false" Str="" Bytes=""></AttrTest>`,
|
856
|
+
},
|
857
|
+
{
|
858
|
+
Value: &OmitAttrTest{
|
859
|
+
Int: 8,
|
860
|
+
Named: 9,
|
861
|
+
Float: 23.5,
|
862
|
+
Uint8: 255,
|
863
|
+
Bool: true,
|
864
|
+
Str: "str",
|
865
|
+
Bytes: []byte("byt"),
|
866
|
+
},
|
867
|
+
ExpectXML: `<OmitAttrTest Int="8" int="9" Float="23.5" Uint8="255"` +
|
868
|
+
` Bool="true" Str="str" Bytes="byt"></OmitAttrTest>`,
|
869
|
+
},
|
870
|
+
{
|
871
|
+
Value: &OmitAttrTest{},
|
872
|
+
ExpectXML: `<OmitAttrTest></OmitAttrTest>`,
|
873
|
+
},
|
874
|
+
|
875
|
+
// pointer fields
|
876
|
+
{
|
877
|
+
Value: &PointerFieldsTest{Name: &nameAttr, Age: &ageAttr, Contents: &contentsAttr},
|
878
|
+
ExpectXML: `<dummy name="Sarah" age="12">lorem ipsum</dummy>`,
|
879
|
+
MarshalOnly: true,
|
880
|
+
},
|
881
|
+
|
882
|
+
// empty chardata pointer field
|
883
|
+
{
|
884
|
+
Value: &ChardataEmptyTest{},
|
885
|
+
ExpectXML: `<test></test>`,
|
886
|
+
MarshalOnly: true,
|
887
|
+
},
|
888
|
+
|
889
|
+
// omitempty on fields
|
890
|
+
{
|
891
|
+
Value: &OmitFieldTest{
|
892
|
+
Int: 8,
|
893
|
+
Named: 9,
|
894
|
+
Float: 23.5,
|
895
|
+
Uint8: 255,
|
896
|
+
Bool: true,
|
897
|
+
Str: "str",
|
898
|
+
Bytes: []byte("byt"),
|
899
|
+
Ptr: &PresenceTest{},
|
900
|
+
},
|
901
|
+
ExpectXML: `<OmitFieldTest>` +
|
902
|
+
`<Int>8</Int>` +
|
903
|
+
`<int>9</int>` +
|
904
|
+
`<Float>23.5</Float>` +
|
905
|
+
`<Uint8>255</Uint8>` +
|
906
|
+
`<Bool>true</Bool>` +
|
907
|
+
`<Str>str</Str>` +
|
908
|
+
`<Bytes>byt</Bytes>` +
|
909
|
+
`<Ptr></Ptr>` +
|
910
|
+
`</OmitFieldTest>`,
|
911
|
+
},
|
912
|
+
{
|
913
|
+
Value: &OmitFieldTest{},
|
914
|
+
ExpectXML: `<OmitFieldTest></OmitFieldTest>`,
|
915
|
+
},
|
916
|
+
|
917
|
+
// Test ",any"
|
918
|
+
{
|
919
|
+
ExpectXML: `<a><nested><value>known</value></nested><other><sub>unknown</sub></other></a>`,
|
920
|
+
Value: &AnyTest{
|
921
|
+
Nested: "known",
|
922
|
+
AnyField: AnyHolder{
|
923
|
+
XMLName: Name{Local: "other"},
|
924
|
+
XML: "<sub>unknown</sub>",
|
925
|
+
},
|
926
|
+
},
|
927
|
+
},
|
928
|
+
{
|
929
|
+
Value: &AnyTest{Nested: "known",
|
930
|
+
AnyField: AnyHolder{
|
931
|
+
XML: "<unknown/>",
|
932
|
+
XMLName: Name{Local: "AnyField"},
|
933
|
+
},
|
934
|
+
},
|
935
|
+
ExpectXML: `<a><nested><value>known</value></nested><AnyField><unknown/></AnyField></a>`,
|
936
|
+
},
|
937
|
+
{
|
938
|
+
ExpectXML: `<a><nested><value>b</value></nested></a>`,
|
939
|
+
Value: &AnyOmitTest{
|
940
|
+
Nested: "b",
|
941
|
+
},
|
942
|
+
},
|
943
|
+
{
|
944
|
+
ExpectXML: `<a><nested><value>b</value></nested><c><d>e</d></c><g xmlns="f"><h>i</h></g></a>`,
|
945
|
+
Value: &AnySliceTest{
|
946
|
+
Nested: "b",
|
947
|
+
AnyField: []AnyHolder{
|
948
|
+
{
|
949
|
+
XMLName: Name{Local: "c"},
|
950
|
+
XML: "<d>e</d>",
|
951
|
+
},
|
952
|
+
{
|
953
|
+
XMLName: Name{Space: "f", Local: "g"},
|
954
|
+
XML: "<h>i</h>",
|
955
|
+
},
|
956
|
+
},
|
957
|
+
},
|
958
|
+
},
|
959
|
+
{
|
960
|
+
ExpectXML: `<a><nested><value>b</value></nested></a>`,
|
961
|
+
Value: &AnySliceTest{
|
962
|
+
Nested: "b",
|
963
|
+
},
|
964
|
+
},
|
965
|
+
|
966
|
+
// Test recursive types.
|
967
|
+
{
|
968
|
+
Value: &RecurseA{
|
969
|
+
A: "a1",
|
970
|
+
B: &RecurseB{
|
971
|
+
A: &RecurseA{"a2", nil},
|
972
|
+
B: "b1",
|
973
|
+
},
|
974
|
+
},
|
975
|
+
ExpectXML: `<RecurseA><A>a1</A><B><A><A>a2</A></A><B>b1</B></B></RecurseA>`,
|
976
|
+
},
|
977
|
+
|
978
|
+
// Test ignoring fields via "-" tag
|
979
|
+
{
|
980
|
+
ExpectXML: `<IgnoreTest></IgnoreTest>`,
|
981
|
+
Value: &IgnoreTest{},
|
982
|
+
},
|
983
|
+
{
|
984
|
+
ExpectXML: `<IgnoreTest></IgnoreTest>`,
|
985
|
+
Value: &IgnoreTest{PublicSecret: "can't tell"},
|
986
|
+
MarshalOnly: true,
|
987
|
+
},
|
988
|
+
{
|
989
|
+
ExpectXML: `<IgnoreTest><PublicSecret>ignore me</PublicSecret></IgnoreTest>`,
|
990
|
+
Value: &IgnoreTest{},
|
991
|
+
UnmarshalOnly: true,
|
992
|
+
},
|
993
|
+
|
994
|
+
// Test escaping.
|
995
|
+
{
|
996
|
+
ExpectXML: `<a><nested><value>dquote: "; squote: '; ampersand: &; less: <; greater: >;</value></nested><empty></empty></a>`,
|
997
|
+
Value: &AnyTest{
|
998
|
+
Nested: `dquote: "; squote: '; ampersand: &; less: <; greater: >;`,
|
999
|
+
AnyField: AnyHolder{XMLName: Name{Local: "empty"}},
|
1000
|
+
},
|
1001
|
+
},
|
1002
|
+
{
|
1003
|
+
ExpectXML: `<a><nested><value>newline: 
; cr: 
; tab: 	;</value></nested><AnyField></AnyField></a>`,
|
1004
|
+
Value: &AnyTest{
|
1005
|
+
Nested: "newline: \n; cr: \r; tab: \t;",
|
1006
|
+
AnyField: AnyHolder{XMLName: Name{Local: "AnyField"}},
|
1007
|
+
},
|
1008
|
+
},
|
1009
|
+
{
|
1010
|
+
ExpectXML: "<a><nested><value>1\r2\r\n3\n\r4\n5</value></nested></a>",
|
1011
|
+
Value: &AnyTest{
|
1012
|
+
Nested: "1\n2\n3\n\n4\n5",
|
1013
|
+
},
|
1014
|
+
UnmarshalOnly: true,
|
1015
|
+
},
|
1016
|
+
{
|
1017
|
+
ExpectXML: `<EmbedInt><MyInt>42</MyInt></EmbedInt>`,
|
1018
|
+
Value: &EmbedInt{
|
1019
|
+
MyInt: 42,
|
1020
|
+
},
|
1021
|
+
},
|
1022
|
+
// Test omitempty with parent chain; see golang.org/issue/4168.
|
1023
|
+
{
|
1024
|
+
ExpectXML: `<Strings><A></A></Strings>`,
|
1025
|
+
Value: &Strings{},
|
1026
|
+
},
|
1027
|
+
// Custom marshalers.
|
1028
|
+
{
|
1029
|
+
ExpectXML: `<MyMarshalerTest>hello world</MyMarshalerTest>`,
|
1030
|
+
Value: &MyMarshalerTest{},
|
1031
|
+
},
|
1032
|
+
{
|
1033
|
+
ExpectXML: `<MarshalerStruct Foo="hello world"></MarshalerStruct>`,
|
1034
|
+
Value: &MarshalerStruct{},
|
1035
|
+
},
|
1036
|
+
{
|
1037
|
+
ExpectXML: `<MarshalerValueStruct Foo="hello world"></MarshalerValueStruct>`,
|
1038
|
+
Value: &MarshalerValueStruct{},
|
1039
|
+
},
|
1040
|
+
{
|
1041
|
+
ExpectXML: `<outer xmlns="testns" int="10"></outer>`,
|
1042
|
+
Value: &OuterStruct{IntAttr: 10},
|
1043
|
+
},
|
1044
|
+
{
|
1045
|
+
ExpectXML: `<test xmlns="outerns" int="10"></test>`,
|
1046
|
+
Value: &OuterNamedStruct{XMLName: Name{Space: "outerns", Local: "test"}, IntAttr: 10},
|
1047
|
+
},
|
1048
|
+
{
|
1049
|
+
ExpectXML: `<test xmlns="outerns" int="10"></test>`,
|
1050
|
+
Value: &OuterNamedOrderedStruct{XMLName: Name{Space: "outerns", Local: "test"}, IntAttr: 10},
|
1051
|
+
},
|
1052
|
+
{
|
1053
|
+
ExpectXML: `<outer xmlns="testns" int="10"></outer>`,
|
1054
|
+
Value: &OuterOuterStruct{OuterStruct{IntAttr: 10}},
|
1055
|
+
},
|
1056
|
+
{
|
1057
|
+
ExpectXML: `<NestedAndChardata><A><B></B><B></B></A>test</NestedAndChardata>`,
|
1058
|
+
Value: &NestedAndChardata{AB: make([]string, 2), Chardata: "test"},
|
1059
|
+
},
|
1060
|
+
{
|
1061
|
+
ExpectXML: `<NestedAndComment><A><B></B><B></B></A><!--test--></NestedAndComment>`,
|
1062
|
+
Value: &NestedAndComment{AB: make([]string, 2), Comment: "test"},
|
1063
|
+
},
|
1064
|
+
{
|
1065
|
+
ExpectXML: `<XMLNSFieldStruct xmlns="http://example.com/ns"><Body>hello world</Body></XMLNSFieldStruct>`,
|
1066
|
+
Value: &XMLNSFieldStruct{Ns: "http://example.com/ns", Body: "hello world"},
|
1067
|
+
},
|
1068
|
+
{
|
1069
|
+
ExpectXML: `<testns:test xmlns:testns="testns" xmlns="http://example.com/ns"><Body>hello world</Body></testns:test>`,
|
1070
|
+
Value: &NamedXMLNSFieldStruct{Ns: "http://example.com/ns", Body: "hello world"},
|
1071
|
+
},
|
1072
|
+
{
|
1073
|
+
ExpectXML: `<testns:test xmlns:testns="testns"><Body>hello world</Body></testns:test>`,
|
1074
|
+
Value: &NamedXMLNSFieldStruct{Ns: "", Body: "hello world"},
|
1075
|
+
},
|
1076
|
+
{
|
1077
|
+
ExpectXML: `<XMLNSFieldStructWithOmitEmpty><Body>hello world</Body></XMLNSFieldStructWithOmitEmpty>`,
|
1078
|
+
Value: &XMLNSFieldStructWithOmitEmpty{Body: "hello world"},
|
1079
|
+
},
|
1080
|
+
{
|
1081
|
+
// The xmlns attribute must be ignored because the <test>
|
1082
|
+
// element is in the empty namespace, so it's not possible
|
1083
|
+
// to set the default namespace to something non-empty.
|
1084
|
+
ExpectXML: `<test><Body>hello world</Body></test>`,
|
1085
|
+
Value: &NamedXMLNSFieldStructWithEmptyNamespace{Ns: "foo", Body: "hello world"},
|
1086
|
+
MarshalOnly: true,
|
1087
|
+
},
|
1088
|
+
{
|
1089
|
+
ExpectXML: `<RecursiveXMLNSFieldStruct xmlns="foo"><Body xmlns=""><Text>hello world</Text></Body></RecursiveXMLNSFieldStruct>`,
|
1090
|
+
Value: &RecursiveXMLNSFieldStruct{
|
1091
|
+
Ns: "foo",
|
1092
|
+
Body: &RecursiveXMLNSFieldStruct{
|
1093
|
+
Text: "hello world",
|
1094
|
+
},
|
1095
|
+
},
|
1096
|
+
},
|
1097
|
+
}
|
1098
|
+
|
1099
|
+
func TestMarshal(t *testing.T) {
|
1100
|
+
for idx, test := range marshalTests {
|
1101
|
+
if test.UnmarshalOnly {
|
1102
|
+
continue
|
1103
|
+
}
|
1104
|
+
data, err := Marshal(test.Value)
|
1105
|
+
if err != nil {
|
1106
|
+
t.Errorf("#%d: marshal(%#v): %s", idx, test.Value, err)
|
1107
|
+
continue
|
1108
|
+
}
|
1109
|
+
if got, want := string(data), test.ExpectXML; got != want {
|
1110
|
+
if strings.Contains(want, "\n") {
|
1111
|
+
t.Errorf("#%d: marshal(%#v):\nHAVE:\n%s\nWANT:\n%s", idx, test.Value, got, want)
|
1112
|
+
} else {
|
1113
|
+
t.Errorf("#%d: marshal(%#v):\nhave %#q\nwant %#q", idx, test.Value, got, want)
|
1114
|
+
}
|
1115
|
+
}
|
1116
|
+
}
|
1117
|
+
}
|
1118
|
+
|
1119
|
+
type AttrParent struct {
|
1120
|
+
X string `xml:"X>Y,attr"`
|
1121
|
+
}
|
1122
|
+
|
1123
|
+
type BadAttr struct {
|
1124
|
+
Name []string `xml:"name,attr"`
|
1125
|
+
}
|
1126
|
+
|
1127
|
+
var marshalErrorTests = []struct {
|
1128
|
+
Value interface{}
|
1129
|
+
Err string
|
1130
|
+
Kind reflect.Kind
|
1131
|
+
}{
|
1132
|
+
{
|
1133
|
+
Value: make(chan bool),
|
1134
|
+
Err: "xml: unsupported type: chan bool",
|
1135
|
+
Kind: reflect.Chan,
|
1136
|
+
},
|
1137
|
+
{
|
1138
|
+
Value: map[string]string{
|
1139
|
+
"question": "What do you get when you multiply six by nine?",
|
1140
|
+
"answer": "42",
|
1141
|
+
},
|
1142
|
+
Err: "xml: unsupported type: map[string]string",
|
1143
|
+
Kind: reflect.Map,
|
1144
|
+
},
|
1145
|
+
{
|
1146
|
+
Value: map[*Ship]bool{nil: false},
|
1147
|
+
Err: "xml: unsupported type: map[*xml.Ship]bool",
|
1148
|
+
Kind: reflect.Map,
|
1149
|
+
},
|
1150
|
+
{
|
1151
|
+
Value: &Domain{Comment: []byte("f--bar")},
|
1152
|
+
Err: `xml: comments must not contain "--"`,
|
1153
|
+
},
|
1154
|
+
// Reject parent chain with attr, never worked; see golang.org/issue/5033.
|
1155
|
+
{
|
1156
|
+
Value: &AttrParent{},
|
1157
|
+
Err: `xml: X>Y chain not valid with attr flag`,
|
1158
|
+
},
|
1159
|
+
{
|
1160
|
+
Value: BadAttr{[]string{"X", "Y"}},
|
1161
|
+
Err: `xml: unsupported type: []string`,
|
1162
|
+
},
|
1163
|
+
}
|
1164
|
+
|
1165
|
+
var marshalIndentTests = []struct {
|
1166
|
+
Value interface{}
|
1167
|
+
Prefix string
|
1168
|
+
Indent string
|
1169
|
+
ExpectXML string
|
1170
|
+
}{
|
1171
|
+
{
|
1172
|
+
Value: &SecretAgent{
|
1173
|
+
Handle: "007",
|
1174
|
+
Identity: "James Bond",
|
1175
|
+
Obfuscate: "<redacted/>",
|
1176
|
+
},
|
1177
|
+
Prefix: "",
|
1178
|
+
Indent: "\t",
|
1179
|
+
ExpectXML: fmt.Sprintf("<agent handle=\"007\">\n\t<Identity>James Bond</Identity><redacted/>\n</agent>"),
|
1180
|
+
},
|
1181
|
+
}
|
1182
|
+
|
1183
|
+
func TestMarshalErrors(t *testing.T) {
|
1184
|
+
for idx, test := range marshalErrorTests {
|
1185
|
+
data, err := Marshal(test.Value)
|
1186
|
+
if err == nil {
|
1187
|
+
t.Errorf("#%d: marshal(%#v) = [success] %q, want error %v", idx, test.Value, data, test.Err)
|
1188
|
+
continue
|
1189
|
+
}
|
1190
|
+
if err.Error() != test.Err {
|
1191
|
+
t.Errorf("#%d: marshal(%#v) = [error] %v, want %v", idx, test.Value, err, test.Err)
|
1192
|
+
}
|
1193
|
+
if test.Kind != reflect.Invalid {
|
1194
|
+
if kind := err.(*UnsupportedTypeError).Type.Kind(); kind != test.Kind {
|
1195
|
+
t.Errorf("#%d: marshal(%#v) = [error kind] %s, want %s", idx, test.Value, kind, test.Kind)
|
1196
|
+
}
|
1197
|
+
}
|
1198
|
+
}
|
1199
|
+
}
|
1200
|
+
|
1201
|
+
// Do invertibility testing on the various structures that we test
|
1202
|
+
func TestUnmarshal(t *testing.T) {
|
1203
|
+
for i, test := range marshalTests {
|
1204
|
+
if test.MarshalOnly {
|
1205
|
+
continue
|
1206
|
+
}
|
1207
|
+
if _, ok := test.Value.(*Plain); ok {
|
1208
|
+
continue
|
1209
|
+
}
|
1210
|
+
vt := reflect.TypeOf(test.Value)
|
1211
|
+
dest := reflect.New(vt.Elem()).Interface()
|
1212
|
+
err := Unmarshal([]byte(test.ExpectXML), dest)
|
1213
|
+
|
1214
|
+
switch fix := dest.(type) {
|
1215
|
+
case *Feed:
|
1216
|
+
fix.Author.InnerXML = ""
|
1217
|
+
for i := range fix.Entry {
|
1218
|
+
fix.Entry[i].Author.InnerXML = ""
|
1219
|
+
}
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
if err != nil {
|
1223
|
+
t.Errorf("#%d: unexpected error: %#v", i, err)
|
1224
|
+
} else if got, want := dest, test.Value; !reflect.DeepEqual(got, want) {
|
1225
|
+
t.Errorf("#%d: unmarshal(%q):\nhave %#v\nwant %#v", i, test.ExpectXML, got, want)
|
1226
|
+
}
|
1227
|
+
}
|
1228
|
+
}
|
1229
|
+
|
1230
|
+
func TestMarshalIndent(t *testing.T) {
|
1231
|
+
for i, test := range marshalIndentTests {
|
1232
|
+
data, err := MarshalIndent(test.Value, test.Prefix, test.Indent)
|
1233
|
+
if err != nil {
|
1234
|
+
t.Errorf("#%d: Error: %s", i, err)
|
1235
|
+
continue
|
1236
|
+
}
|
1237
|
+
if got, want := string(data), test.ExpectXML; got != want {
|
1238
|
+
t.Errorf("#%d: MarshalIndent:\nGot:%s\nWant:\n%s", i, got, want)
|
1239
|
+
}
|
1240
|
+
}
|
1241
|
+
}
|
1242
|
+
|
1243
|
+
type limitedBytesWriter struct {
|
1244
|
+
w io.Writer
|
1245
|
+
remain int // until writes fail
|
1246
|
+
}
|
1247
|
+
|
1248
|
+
func (lw *limitedBytesWriter) Write(p []byte) (n int, err error) {
|
1249
|
+
if lw.remain <= 0 {
|
1250
|
+
println("error")
|
1251
|
+
return 0, errors.New("write limit hit")
|
1252
|
+
}
|
1253
|
+
if len(p) > lw.remain {
|
1254
|
+
p = p[:lw.remain]
|
1255
|
+
n, _ = lw.w.Write(p)
|
1256
|
+
lw.remain = 0
|
1257
|
+
return n, errors.New("write limit hit")
|
1258
|
+
}
|
1259
|
+
n, err = lw.w.Write(p)
|
1260
|
+
lw.remain -= n
|
1261
|
+
return n, err
|
1262
|
+
}
|
1263
|
+
|
1264
|
+
func TestMarshalWriteErrors(t *testing.T) {
|
1265
|
+
var buf bytes.Buffer
|
1266
|
+
const writeCap = 1024
|
1267
|
+
w := &limitedBytesWriter{&buf, writeCap}
|
1268
|
+
enc := NewEncoder(w)
|
1269
|
+
var err error
|
1270
|
+
var i int
|
1271
|
+
const n = 4000
|
1272
|
+
for i = 1; i <= n; i++ {
|
1273
|
+
err = enc.Encode(&Passenger{
|
1274
|
+
Name: []string{"Alice", "Bob"},
|
1275
|
+
Weight: 5,
|
1276
|
+
})
|
1277
|
+
if err != nil {
|
1278
|
+
break
|
1279
|
+
}
|
1280
|
+
}
|
1281
|
+
if err == nil {
|
1282
|
+
t.Error("expected an error")
|
1283
|
+
}
|
1284
|
+
if i == n {
|
1285
|
+
t.Errorf("expected to fail before the end")
|
1286
|
+
}
|
1287
|
+
if buf.Len() != writeCap {
|
1288
|
+
t.Errorf("buf.Len() = %d; want %d", buf.Len(), writeCap)
|
1289
|
+
}
|
1290
|
+
}
|
1291
|
+
|
1292
|
+
func TestMarshalWriteIOErrors(t *testing.T) {
|
1293
|
+
enc := NewEncoder(errWriter{})
|
1294
|
+
|
1295
|
+
expectErr := "unwritable"
|
1296
|
+
err := enc.Encode(&Passenger{})
|
1297
|
+
if err == nil || err.Error() != expectErr {
|
1298
|
+
t.Errorf("EscapeTest = [error] %v, want %v", err, expectErr)
|
1299
|
+
}
|
1300
|
+
}
|
1301
|
+
|
1302
|
+
func TestMarshalFlush(t *testing.T) {
|
1303
|
+
var buf bytes.Buffer
|
1304
|
+
enc := NewEncoder(&buf)
|
1305
|
+
if err := enc.EncodeToken(CharData("hello world")); err != nil {
|
1306
|
+
t.Fatalf("enc.EncodeToken: %v", err)
|
1307
|
+
}
|
1308
|
+
if buf.Len() > 0 {
|
1309
|
+
t.Fatalf("enc.EncodeToken caused actual write: %q", buf.Bytes())
|
1310
|
+
}
|
1311
|
+
if err := enc.Flush(); err != nil {
|
1312
|
+
t.Fatalf("enc.Flush: %v", err)
|
1313
|
+
}
|
1314
|
+
if buf.String() != "hello world" {
|
1315
|
+
t.Fatalf("after enc.Flush, buf.String() = %q, want %q", buf.String(), "hello world")
|
1316
|
+
}
|
1317
|
+
}
|
1318
|
+
|
1319
|
+
var encodeElementTests = []struct {
|
1320
|
+
desc string
|
1321
|
+
value interface{}
|
1322
|
+
start StartElement
|
1323
|
+
expectXML string
|
1324
|
+
}{{
|
1325
|
+
desc: "simple string",
|
1326
|
+
value: "hello",
|
1327
|
+
start: StartElement{
|
1328
|
+
Name: Name{Local: "a"},
|
1329
|
+
},
|
1330
|
+
expectXML: `<a>hello</a>`,
|
1331
|
+
}, {
|
1332
|
+
desc: "string with added attributes",
|
1333
|
+
value: "hello",
|
1334
|
+
start: StartElement{
|
1335
|
+
Name: Name{Local: "a"},
|
1336
|
+
Attr: []Attr{{
|
1337
|
+
Name: Name{Local: "x"},
|
1338
|
+
Value: "y",
|
1339
|
+
}, {
|
1340
|
+
Name: Name{Local: "foo"},
|
1341
|
+
Value: "bar",
|
1342
|
+
}},
|
1343
|
+
},
|
1344
|
+
expectXML: `<a x="y" foo="bar">hello</a>`,
|
1345
|
+
}, {
|
1346
|
+
desc: "start element with default name space",
|
1347
|
+
value: struct {
|
1348
|
+
Foo XMLNameWithNSTag
|
1349
|
+
}{
|
1350
|
+
Foo: XMLNameWithNSTag{
|
1351
|
+
Value: "hello",
|
1352
|
+
},
|
1353
|
+
},
|
1354
|
+
start: StartElement{
|
1355
|
+
Name: Name{Space: "ns", Local: "a"},
|
1356
|
+
Attr: []Attr{{
|
1357
|
+
Name: Name{Local: "xmlns"},
|
1358
|
+
// "ns" is the name space defined in XMLNameWithNSTag
|
1359
|
+
Value: "ns",
|
1360
|
+
}},
|
1361
|
+
},
|
1362
|
+
expectXML: `<a xmlns="ns"><InXMLNameWithNSTag>hello</InXMLNameWithNSTag></a>`,
|
1363
|
+
}, {
|
1364
|
+
desc: "start element in name space with different default name space",
|
1365
|
+
value: struct {
|
1366
|
+
Foo XMLNameWithNSTag
|
1367
|
+
}{
|
1368
|
+
Foo: XMLNameWithNSTag{
|
1369
|
+
Value: "hello",
|
1370
|
+
},
|
1371
|
+
},
|
1372
|
+
start: StartElement{
|
1373
|
+
Name: Name{Space: "ns2", Local: "a"},
|
1374
|
+
Attr: []Attr{{
|
1375
|
+
Name: Name{Local: "xmlns"},
|
1376
|
+
// "ns" is the name space defined in XMLNameWithNSTag
|
1377
|
+
Value: "ns",
|
1378
|
+
}},
|
1379
|
+
},
|
1380
|
+
expectXML: `<ns2:a xmlns:ns2="ns2" xmlns="ns"><InXMLNameWithNSTag>hello</InXMLNameWithNSTag></ns2:a>`,
|
1381
|
+
}, {
|
1382
|
+
desc: "XMLMarshaler with start element with default name space",
|
1383
|
+
value: &MyMarshalerTest{},
|
1384
|
+
start: StartElement{
|
1385
|
+
Name: Name{Space: "ns2", Local: "a"},
|
1386
|
+
Attr: []Attr{{
|
1387
|
+
Name: Name{Local: "xmlns"},
|
1388
|
+
// "ns" is the name space defined in XMLNameWithNSTag
|
1389
|
+
Value: "ns",
|
1390
|
+
}},
|
1391
|
+
},
|
1392
|
+
expectXML: `<ns2:a xmlns:ns2="ns2" xmlns="ns">hello world</ns2:a>`,
|
1393
|
+
}}
|
1394
|
+
|
1395
|
+
func TestEncodeElement(t *testing.T) {
|
1396
|
+
for idx, test := range encodeElementTests {
|
1397
|
+
var buf bytes.Buffer
|
1398
|
+
enc := NewEncoder(&buf)
|
1399
|
+
err := enc.EncodeElement(test.value, test.start)
|
1400
|
+
if err != nil {
|
1401
|
+
t.Fatalf("enc.EncodeElement: %v", err)
|
1402
|
+
}
|
1403
|
+
err = enc.Flush()
|
1404
|
+
if err != nil {
|
1405
|
+
t.Fatalf("enc.Flush: %v", err)
|
1406
|
+
}
|
1407
|
+
if got, want := buf.String(), test.expectXML; got != want {
|
1408
|
+
t.Errorf("#%d(%s): EncodeElement(%#v, %#v):\nhave %#q\nwant %#q", idx, test.desc, test.value, test.start, got, want)
|
1409
|
+
}
|
1410
|
+
}
|
1411
|
+
}
|
1412
|
+
|
1413
|
+
func BenchmarkMarshal(b *testing.B) {
|
1414
|
+
b.ReportAllocs()
|
1415
|
+
for i := 0; i < b.N; i++ {
|
1416
|
+
Marshal(atomValue)
|
1417
|
+
}
|
1418
|
+
}
|
1419
|
+
|
1420
|
+
func BenchmarkUnmarshal(b *testing.B) {
|
1421
|
+
b.ReportAllocs()
|
1422
|
+
xml := []byte(atomXml)
|
1423
|
+
for i := 0; i < b.N; i++ {
|
1424
|
+
Unmarshal(xml, &Feed{})
|
1425
|
+
}
|
1426
|
+
}
|
1427
|
+
|
1428
|
+
// golang.org/issue/6556
|
1429
|
+
func TestStructPointerMarshal(t *testing.T) {
|
1430
|
+
type A struct {
|
1431
|
+
XMLName string `xml:"a"`
|
1432
|
+
B []interface{}
|
1433
|
+
}
|
1434
|
+
type C struct {
|
1435
|
+
XMLName Name
|
1436
|
+
Value string `xml:"value"`
|
1437
|
+
}
|
1438
|
+
|
1439
|
+
a := new(A)
|
1440
|
+
a.B = append(a.B, &C{
|
1441
|
+
XMLName: Name{Local: "c"},
|
1442
|
+
Value: "x",
|
1443
|
+
})
|
1444
|
+
|
1445
|
+
b, err := Marshal(a)
|
1446
|
+
if err != nil {
|
1447
|
+
t.Fatal(err)
|
1448
|
+
}
|
1449
|
+
if x := string(b); x != "<a><c><value>x</value></c></a>" {
|
1450
|
+
t.Fatal(x)
|
1451
|
+
}
|
1452
|
+
var v A
|
1453
|
+
err = Unmarshal(b, &v)
|
1454
|
+
if err != nil {
|
1455
|
+
t.Fatal(err)
|
1456
|
+
}
|
1457
|
+
}
|
1458
|
+
|
1459
|
+
var encodeTokenTests = []struct {
|
1460
|
+
desc string
|
1461
|
+
toks []Token
|
1462
|
+
want string
|
1463
|
+
err string
|
1464
|
+
}{{
|
1465
|
+
desc: "start element with name space",
|
1466
|
+
toks: []Token{
|
1467
|
+
StartElement{Name{"space", "local"}, nil},
|
1468
|
+
},
|
1469
|
+
want: `<space:local xmlns:space="space">`,
|
1470
|
+
}, {
|
1471
|
+
desc: "start element with no name",
|
1472
|
+
toks: []Token{
|
1473
|
+
StartElement{Name{"space", ""}, nil},
|
1474
|
+
},
|
1475
|
+
err: "xml: start tag with no name",
|
1476
|
+
}, {
|
1477
|
+
desc: "end element with no name",
|
1478
|
+
toks: []Token{
|
1479
|
+
EndElement{Name{"space", ""}},
|
1480
|
+
},
|
1481
|
+
err: "xml: end tag with no name",
|
1482
|
+
}, {
|
1483
|
+
desc: "char data",
|
1484
|
+
toks: []Token{
|
1485
|
+
CharData("foo"),
|
1486
|
+
},
|
1487
|
+
want: `foo`,
|
1488
|
+
}, {
|
1489
|
+
desc: "char data with escaped chars",
|
1490
|
+
toks: []Token{
|
1491
|
+
CharData(" \t\n"),
|
1492
|
+
},
|
1493
|
+
want: " 	\n",
|
1494
|
+
}, {
|
1495
|
+
desc: "comment",
|
1496
|
+
toks: []Token{
|
1497
|
+
Comment("foo"),
|
1498
|
+
},
|
1499
|
+
want: `<!--foo-->`,
|
1500
|
+
}, {
|
1501
|
+
desc: "comment with invalid content",
|
1502
|
+
toks: []Token{
|
1503
|
+
Comment("foo-->"),
|
1504
|
+
},
|
1505
|
+
err: "xml: EncodeToken of Comment containing --> marker",
|
1506
|
+
}, {
|
1507
|
+
desc: "proc instruction",
|
1508
|
+
toks: []Token{
|
1509
|
+
ProcInst{"Target", []byte("Instruction")},
|
1510
|
+
},
|
1511
|
+
want: `<?Target Instruction?>`,
|
1512
|
+
}, {
|
1513
|
+
desc: "proc instruction with empty target",
|
1514
|
+
toks: []Token{
|
1515
|
+
ProcInst{"", []byte("Instruction")},
|
1516
|
+
},
|
1517
|
+
err: "xml: EncodeToken of ProcInst with invalid Target",
|
1518
|
+
}, {
|
1519
|
+
desc: "proc instruction with bad content",
|
1520
|
+
toks: []Token{
|
1521
|
+
ProcInst{"", []byte("Instruction?>")},
|
1522
|
+
},
|
1523
|
+
err: "xml: EncodeToken of ProcInst with invalid Target",
|
1524
|
+
}, {
|
1525
|
+
desc: "directive",
|
1526
|
+
toks: []Token{
|
1527
|
+
Directive("foo"),
|
1528
|
+
},
|
1529
|
+
want: `<!foo>`,
|
1530
|
+
}, {
|
1531
|
+
desc: "more complex directive",
|
1532
|
+
toks: []Token{
|
1533
|
+
Directive("DOCTYPE doc [ <!ELEMENT doc '>'> <!-- com>ment --> ]"),
|
1534
|
+
},
|
1535
|
+
want: `<!DOCTYPE doc [ <!ELEMENT doc '>'> <!-- com>ment --> ]>`,
|
1536
|
+
}, {
|
1537
|
+
desc: "directive instruction with bad name",
|
1538
|
+
toks: []Token{
|
1539
|
+
Directive("foo>"),
|
1540
|
+
},
|
1541
|
+
err: "xml: EncodeToken of Directive containing wrong < or > markers",
|
1542
|
+
}, {
|
1543
|
+
desc: "end tag without start tag",
|
1544
|
+
toks: []Token{
|
1545
|
+
EndElement{Name{"foo", "bar"}},
|
1546
|
+
},
|
1547
|
+
err: "xml: end tag </bar> without start tag",
|
1548
|
+
}, {
|
1549
|
+
desc: "mismatching end tag local name",
|
1550
|
+
toks: []Token{
|
1551
|
+
StartElement{Name{"", "foo"}, nil},
|
1552
|
+
EndElement{Name{"", "bar"}},
|
1553
|
+
},
|
1554
|
+
err: "xml: end tag </bar> does not match start tag <foo>",
|
1555
|
+
want: `<foo>`,
|
1556
|
+
}, {
|
1557
|
+
desc: "mismatching end tag namespace",
|
1558
|
+
toks: []Token{
|
1559
|
+
StartElement{Name{"space", "foo"}, nil},
|
1560
|
+
EndElement{Name{"another", "foo"}},
|
1561
|
+
},
|
1562
|
+
err: "xml: end tag </foo> in namespace another does not match start tag <foo> in namespace space",
|
1563
|
+
want: `<space:foo xmlns:space="space">`,
|
1564
|
+
}, {
|
1565
|
+
desc: "start element with explicit namespace",
|
1566
|
+
toks: []Token{
|
1567
|
+
StartElement{Name{"space", "local"}, []Attr{
|
1568
|
+
{Name{"xmlns", "x"}, "space"},
|
1569
|
+
{Name{"space", "foo"}, "value"},
|
1570
|
+
}},
|
1571
|
+
},
|
1572
|
+
want: `<x:local xmlns:x="space" x:foo="value">`,
|
1573
|
+
}, {
|
1574
|
+
desc: "start element with explicit namespace and colliding prefix",
|
1575
|
+
toks: []Token{
|
1576
|
+
StartElement{Name{"space", "local"}, []Attr{
|
1577
|
+
{Name{"xmlns", "x"}, "space"},
|
1578
|
+
{Name{"space", "foo"}, "value"},
|
1579
|
+
{Name{"x", "bar"}, "other"},
|
1580
|
+
}},
|
1581
|
+
},
|
1582
|
+
want: `<x:local xmlns:x_1="x" xmlns:x="space" x:foo="value" x_1:bar="other">`,
|
1583
|
+
}, {
|
1584
|
+
desc: "start element using previously defined namespace",
|
1585
|
+
toks: []Token{
|
1586
|
+
StartElement{Name{"", "local"}, []Attr{
|
1587
|
+
{Name{"xmlns", "x"}, "space"},
|
1588
|
+
}},
|
1589
|
+
StartElement{Name{"space", "foo"}, []Attr{
|
1590
|
+
{Name{"space", "x"}, "y"},
|
1591
|
+
}},
|
1592
|
+
},
|
1593
|
+
want: `<local xmlns:x="space"><x:foo x:x="y">`,
|
1594
|
+
}, {
|
1595
|
+
desc: "nested name space with same prefix",
|
1596
|
+
toks: []Token{
|
1597
|
+
StartElement{Name{"", "foo"}, []Attr{
|
1598
|
+
{Name{"xmlns", "x"}, "space1"},
|
1599
|
+
}},
|
1600
|
+
StartElement{Name{"", "foo"}, []Attr{
|
1601
|
+
{Name{"xmlns", "x"}, "space2"},
|
1602
|
+
}},
|
1603
|
+
StartElement{Name{"", "foo"}, []Attr{
|
1604
|
+
{Name{"space1", "a"}, "space1 value"},
|
1605
|
+
{Name{"space2", "b"}, "space2 value"},
|
1606
|
+
}},
|
1607
|
+
EndElement{Name{"", "foo"}},
|
1608
|
+
EndElement{Name{"", "foo"}},
|
1609
|
+
StartElement{Name{"", "foo"}, []Attr{
|
1610
|
+
{Name{"space1", "a"}, "space1 value"},
|
1611
|
+
{Name{"space2", "b"}, "space2 value"},
|
1612
|
+
}},
|
1613
|
+
},
|
1614
|
+
want: `<foo xmlns:x="space1"><foo xmlns:x="space2"><foo xmlns:space1="space1" space1:a="space1 value" x:b="space2 value"></foo></foo><foo xmlns:space2="space2" x:a="space1 value" space2:b="space2 value">`,
|
1615
|
+
}, {
|
1616
|
+
desc: "start element defining several prefixes for the same name space",
|
1617
|
+
toks: []Token{
|
1618
|
+
StartElement{Name{"space", "foo"}, []Attr{
|
1619
|
+
{Name{"xmlns", "a"}, "space"},
|
1620
|
+
{Name{"xmlns", "b"}, "space"},
|
1621
|
+
{Name{"space", "x"}, "value"},
|
1622
|
+
}},
|
1623
|
+
},
|
1624
|
+
want: `<a:foo xmlns:a="space" a:x="value">`,
|
1625
|
+
}, {
|
1626
|
+
desc: "nested element redefines name space",
|
1627
|
+
toks: []Token{
|
1628
|
+
StartElement{Name{"", "foo"}, []Attr{
|
1629
|
+
{Name{"xmlns", "x"}, "space"},
|
1630
|
+
}},
|
1631
|
+
StartElement{Name{"space", "foo"}, []Attr{
|
1632
|
+
{Name{"xmlns", "y"}, "space"},
|
1633
|
+
{Name{"space", "a"}, "value"},
|
1634
|
+
}},
|
1635
|
+
},
|
1636
|
+
want: `<foo xmlns:x="space"><x:foo x:a="value">`,
|
1637
|
+
}, {
|
1638
|
+
desc: "nested element creates alias for default name space",
|
1639
|
+
toks: []Token{
|
1640
|
+
StartElement{Name{"space", "foo"}, []Attr{
|
1641
|
+
{Name{"", "xmlns"}, "space"},
|
1642
|
+
}},
|
1643
|
+
StartElement{Name{"space", "foo"}, []Attr{
|
1644
|
+
{Name{"xmlns", "y"}, "space"},
|
1645
|
+
{Name{"space", "a"}, "value"},
|
1646
|
+
}},
|
1647
|
+
},
|
1648
|
+
want: `<foo xmlns="space"><foo xmlns:y="space" y:a="value">`,
|
1649
|
+
}, {
|
1650
|
+
desc: "nested element defines default name space with existing prefix",
|
1651
|
+
toks: []Token{
|
1652
|
+
StartElement{Name{"", "foo"}, []Attr{
|
1653
|
+
{Name{"xmlns", "x"}, "space"},
|
1654
|
+
}},
|
1655
|
+
StartElement{Name{"space", "foo"}, []Attr{
|
1656
|
+
{Name{"", "xmlns"}, "space"},
|
1657
|
+
{Name{"space", "a"}, "value"},
|
1658
|
+
}},
|
1659
|
+
},
|
1660
|
+
want: `<foo xmlns:x="space"><foo xmlns="space" x:a="value">`,
|
1661
|
+
}, {
|
1662
|
+
desc: "nested element uses empty attribute name space when default ns defined",
|
1663
|
+
toks: []Token{
|
1664
|
+
StartElement{Name{"space", "foo"}, []Attr{
|
1665
|
+
{Name{"", "xmlns"}, "space"},
|
1666
|
+
}},
|
1667
|
+
StartElement{Name{"space", "foo"}, []Attr{
|
1668
|
+
{Name{"", "attr"}, "value"},
|
1669
|
+
}},
|
1670
|
+
},
|
1671
|
+
want: `<foo xmlns="space"><foo attr="value">`,
|
1672
|
+
}, {
|
1673
|
+
desc: "redefine xmlns",
|
1674
|
+
toks: []Token{
|
1675
|
+
StartElement{Name{"", "foo"}, []Attr{
|
1676
|
+
{Name{"foo", "xmlns"}, "space"},
|
1677
|
+
}},
|
1678
|
+
},
|
1679
|
+
err: `xml: cannot redefine xmlns attribute prefix`,
|
1680
|
+
}, {
|
1681
|
+
desc: "xmlns with explicit name space #1",
|
1682
|
+
toks: []Token{
|
1683
|
+
StartElement{Name{"space", "foo"}, []Attr{
|
1684
|
+
{Name{"xml", "xmlns"}, "space"},
|
1685
|
+
}},
|
1686
|
+
},
|
1687
|
+
want: `<foo xmlns="space">`,
|
1688
|
+
}, {
|
1689
|
+
desc: "xmlns with explicit name space #2",
|
1690
|
+
toks: []Token{
|
1691
|
+
StartElement{Name{"space", "foo"}, []Attr{
|
1692
|
+
{Name{xmlURL, "xmlns"}, "space"},
|
1693
|
+
}},
|
1694
|
+
},
|
1695
|
+
want: `<foo xmlns="space">`,
|
1696
|
+
}, {
|
1697
|
+
desc: "empty name space declaration is ignored",
|
1698
|
+
toks: []Token{
|
1699
|
+
StartElement{Name{"", "foo"}, []Attr{
|
1700
|
+
{Name{"xmlns", "foo"}, ""},
|
1701
|
+
}},
|
1702
|
+
},
|
1703
|
+
want: `<foo>`,
|
1704
|
+
}, {
|
1705
|
+
desc: "attribute with no name is ignored",
|
1706
|
+
toks: []Token{
|
1707
|
+
StartElement{Name{"", "foo"}, []Attr{
|
1708
|
+
{Name{"", ""}, "value"},
|
1709
|
+
}},
|
1710
|
+
},
|
1711
|
+
want: `<foo>`,
|
1712
|
+
}, {
|
1713
|
+
desc: "namespace URL with non-valid name",
|
1714
|
+
toks: []Token{
|
1715
|
+
StartElement{Name{"/34", "foo"}, []Attr{
|
1716
|
+
{Name{"/34", "x"}, "value"},
|
1717
|
+
}},
|
1718
|
+
},
|
1719
|
+
want: `<_:foo xmlns:_="/34" _:x="value">`,
|
1720
|
+
}, {
|
1721
|
+
desc: "nested element resets default namespace to empty",
|
1722
|
+
toks: []Token{
|
1723
|
+
StartElement{Name{"space", "foo"}, []Attr{
|
1724
|
+
{Name{"", "xmlns"}, "space"},
|
1725
|
+
}},
|
1726
|
+
StartElement{Name{"", "foo"}, []Attr{
|
1727
|
+
{Name{"", "xmlns"}, ""},
|
1728
|
+
{Name{"", "x"}, "value"},
|
1729
|
+
{Name{"space", "x"}, "value"},
|
1730
|
+
}},
|
1731
|
+
},
|
1732
|
+
want: `<foo xmlns="space"><foo xmlns:space="space" xmlns="" x="value" space:x="value">`,
|
1733
|
+
}, {
|
1734
|
+
desc: "nested element requires empty default name space",
|
1735
|
+
toks: []Token{
|
1736
|
+
StartElement{Name{"space", "foo"}, []Attr{
|
1737
|
+
{Name{"", "xmlns"}, "space"},
|
1738
|
+
}},
|
1739
|
+
StartElement{Name{"", "foo"}, nil},
|
1740
|
+
},
|
1741
|
+
want: `<foo xmlns="space"><foo xmlns="">`,
|
1742
|
+
}, {
|
1743
|
+
desc: "attribute uses name space from xmlns",
|
1744
|
+
toks: []Token{
|
1745
|
+
StartElement{Name{"some/space", "foo"}, []Attr{
|
1746
|
+
{Name{"", "attr"}, "value"},
|
1747
|
+
{Name{"some/space", "other"}, "other value"},
|
1748
|
+
}},
|
1749
|
+
},
|
1750
|
+
want: `<space:foo xmlns:space="some/space" attr="value" space:other="other value">`,
|
1751
|
+
}, {
|
1752
|
+
desc: "default name space should not be used by attributes",
|
1753
|
+
toks: []Token{
|
1754
|
+
StartElement{Name{"space", "foo"}, []Attr{
|
1755
|
+
{Name{"", "xmlns"}, "space"},
|
1756
|
+
{Name{"xmlns", "bar"}, "space"},
|
1757
|
+
{Name{"space", "baz"}, "foo"},
|
1758
|
+
}},
|
1759
|
+
StartElement{Name{"space", "baz"}, nil},
|
1760
|
+
EndElement{Name{"space", "baz"}},
|
1761
|
+
EndElement{Name{"space", "foo"}},
|
1762
|
+
},
|
1763
|
+
want: `<foo xmlns:bar="space" xmlns="space" bar:baz="foo"><baz></baz></foo>`,
|
1764
|
+
}, {
|
1765
|
+
desc: "default name space not used by attributes, not explicitly defined",
|
1766
|
+
toks: []Token{
|
1767
|
+
StartElement{Name{"space", "foo"}, []Attr{
|
1768
|
+
{Name{"", "xmlns"}, "space"},
|
1769
|
+
{Name{"space", "baz"}, "foo"},
|
1770
|
+
}},
|
1771
|
+
StartElement{Name{"space", "baz"}, nil},
|
1772
|
+
EndElement{Name{"space", "baz"}},
|
1773
|
+
EndElement{Name{"space", "foo"}},
|
1774
|
+
},
|
1775
|
+
want: `<foo xmlns:space="space" xmlns="space" space:baz="foo"><baz></baz></foo>`,
|
1776
|
+
}, {
|
1777
|
+
desc: "impossible xmlns declaration",
|
1778
|
+
toks: []Token{
|
1779
|
+
StartElement{Name{"", "foo"}, []Attr{
|
1780
|
+
{Name{"", "xmlns"}, "space"},
|
1781
|
+
}},
|
1782
|
+
StartElement{Name{"space", "bar"}, []Attr{
|
1783
|
+
{Name{"space", "attr"}, "value"},
|
1784
|
+
}},
|
1785
|
+
},
|
1786
|
+
want: `<foo><space:bar xmlns:space="space" space:attr="value">`,
|
1787
|
+
}}
|
1788
|
+
|
1789
|
+
func TestEncodeToken(t *testing.T) {
|
1790
|
+
loop:
|
1791
|
+
for i, tt := range encodeTokenTests {
|
1792
|
+
var buf bytes.Buffer
|
1793
|
+
enc := NewEncoder(&buf)
|
1794
|
+
var err error
|
1795
|
+
for j, tok := range tt.toks {
|
1796
|
+
err = enc.EncodeToken(tok)
|
1797
|
+
if err != nil && j < len(tt.toks)-1 {
|
1798
|
+
t.Errorf("#%d %s token #%d: %v", i, tt.desc, j, err)
|
1799
|
+
continue loop
|
1800
|
+
}
|
1801
|
+
}
|
1802
|
+
errorf := func(f string, a ...interface{}) {
|
1803
|
+
t.Errorf("#%d %s token #%d:%s", i, tt.desc, len(tt.toks)-1, fmt.Sprintf(f, a...))
|
1804
|
+
}
|
1805
|
+
switch {
|
1806
|
+
case tt.err != "" && err == nil:
|
1807
|
+
errorf(" expected error; got none")
|
1808
|
+
continue
|
1809
|
+
case tt.err == "" && err != nil:
|
1810
|
+
errorf(" got error: %v", err)
|
1811
|
+
continue
|
1812
|
+
case tt.err != "" && err != nil && tt.err != err.Error():
|
1813
|
+
errorf(" error mismatch; got %v, want %v", err, tt.err)
|
1814
|
+
continue
|
1815
|
+
}
|
1816
|
+
if err := enc.Flush(); err != nil {
|
1817
|
+
errorf(" %v", err)
|
1818
|
+
continue
|
1819
|
+
}
|
1820
|
+
if got := buf.String(); got != tt.want {
|
1821
|
+
errorf("\ngot %v\nwant %v", got, tt.want)
|
1822
|
+
continue
|
1823
|
+
}
|
1824
|
+
}
|
1825
|
+
}
|
1826
|
+
|
1827
|
+
func TestProcInstEncodeToken(t *testing.T) {
|
1828
|
+
var buf bytes.Buffer
|
1829
|
+
enc := NewEncoder(&buf)
|
1830
|
+
|
1831
|
+
if err := enc.EncodeToken(ProcInst{"xml", []byte("Instruction")}); err != nil {
|
1832
|
+
t.Fatalf("enc.EncodeToken: expected to be able to encode xml target ProcInst as first token, %s", err)
|
1833
|
+
}
|
1834
|
+
|
1835
|
+
if err := enc.EncodeToken(ProcInst{"Target", []byte("Instruction")}); err != nil {
|
1836
|
+
t.Fatalf("enc.EncodeToken: expected to be able to add non-xml target ProcInst")
|
1837
|
+
}
|
1838
|
+
|
1839
|
+
if err := enc.EncodeToken(ProcInst{"xml", []byte("Instruction")}); err == nil {
|
1840
|
+
t.Fatalf("enc.EncodeToken: expected to not be allowed to encode xml target ProcInst when not first token")
|
1841
|
+
}
|
1842
|
+
}
|
1843
|
+
|
1844
|
+
func TestDecodeEncode(t *testing.T) {
|
1845
|
+
var in, out bytes.Buffer
|
1846
|
+
in.WriteString(`<?xml version="1.0" encoding="UTF-8"?>
|
1847
|
+
<?Target Instruction?>
|
1848
|
+
<root>
|
1849
|
+
</root>
|
1850
|
+
`)
|
1851
|
+
dec := NewDecoder(&in)
|
1852
|
+
enc := NewEncoder(&out)
|
1853
|
+
for tok, err := dec.Token(); err == nil; tok, err = dec.Token() {
|
1854
|
+
err = enc.EncodeToken(tok)
|
1855
|
+
if err != nil {
|
1856
|
+
t.Fatalf("enc.EncodeToken: Unable to encode token (%#v), %v", tok, err)
|
1857
|
+
}
|
1858
|
+
}
|
1859
|
+
}
|
1860
|
+
|
1861
|
+
// Issue 9796. Used to fail with GORACE="halt_on_error=1" -race.
|
1862
|
+
func TestRace9796(t *testing.T) {
|
1863
|
+
type A struct{}
|
1864
|
+
type B struct {
|
1865
|
+
C []A `xml:"X>Y"`
|
1866
|
+
}
|
1867
|
+
var wg sync.WaitGroup
|
1868
|
+
for i := 0; i < 2; i++ {
|
1869
|
+
wg.Add(1)
|
1870
|
+
go func() {
|
1871
|
+
Marshal(B{[]A{{}}})
|
1872
|
+
wg.Done()
|
1873
|
+
}()
|
1874
|
+
}
|
1875
|
+
wg.Wait()
|
1876
|
+
}
|
1877
|
+
|
1878
|
+
func TestIsValidDirective(t *testing.T) {
|
1879
|
+
testOK := []string{
|
1880
|
+
"<>",
|
1881
|
+
"< < > >",
|
1882
|
+
"<!DOCTYPE '<' '>' '>' <!--nothing-->>",
|
1883
|
+
"<!DOCTYPE doc [ <!ELEMENT doc ANY> <!ELEMENT doc ANY> ]>",
|
1884
|
+
"<!DOCTYPE doc [ <!ELEMENT doc \"ANY> '<' <!E\" LEMENT '>' doc ANY> ]>",
|
1885
|
+
"<!DOCTYPE doc <!-- just>>>> a < comment --> [ <!ITEM anything> ] >",
|
1886
|
+
}
|
1887
|
+
testKO := []string{
|
1888
|
+
"<",
|
1889
|
+
">",
|
1890
|
+
"<!--",
|
1891
|
+
"-->",
|
1892
|
+
"< > > < < >",
|
1893
|
+
"<!dummy <!-- > -->",
|
1894
|
+
"<!DOCTYPE doc '>",
|
1895
|
+
"<!DOCTYPE doc '>'",
|
1896
|
+
"<!DOCTYPE doc <!--comment>",
|
1897
|
+
}
|
1898
|
+
for _, s := range testOK {
|
1899
|
+
if !isValidDirective(Directive(s)) {
|
1900
|
+
t.Errorf("Directive %q is expected to be valid", s)
|
1901
|
+
}
|
1902
|
+
}
|
1903
|
+
for _, s := range testKO {
|
1904
|
+
if isValidDirective(Directive(s)) {
|
1905
|
+
t.Errorf("Directive %q is expected to be invalid", s)
|
1906
|
+
}
|
1907
|
+
}
|
1908
|
+
}
|
1909
|
+
|
1910
|
+
// Issue 11719. EncodeToken used to silently eat tokens with an invalid type.
|
1911
|
+
func TestSimpleUseOfEncodeToken(t *testing.T) {
|
1912
|
+
var buf bytes.Buffer
|
1913
|
+
enc := NewEncoder(&buf)
|
1914
|
+
if err := enc.EncodeToken(&StartElement{Name: Name{"", "object1"}}); err == nil {
|
1915
|
+
t.Errorf("enc.EncodeToken: pointer type should be rejected")
|
1916
|
+
}
|
1917
|
+
if err := enc.EncodeToken(&EndElement{Name: Name{"", "object1"}}); err == nil {
|
1918
|
+
t.Errorf("enc.EncodeToken: pointer type should be rejected")
|
1919
|
+
}
|
1920
|
+
if err := enc.EncodeToken(StartElement{Name: Name{"", "object2"}}); err != nil {
|
1921
|
+
t.Errorf("enc.EncodeToken: StartElement %s", err)
|
1922
|
+
}
|
1923
|
+
if err := enc.EncodeToken(EndElement{Name: Name{"", "object2"}}); err != nil {
|
1924
|
+
t.Errorf("enc.EncodeToken: EndElement %s", err)
|
1925
|
+
}
|
1926
|
+
if err := enc.EncodeToken(Universe{}); err == nil {
|
1927
|
+
t.Errorf("enc.EncodeToken: invalid type not caught")
|
1928
|
+
}
|
1929
|
+
if err := enc.Flush(); err != nil {
|
1930
|
+
t.Errorf("enc.Flush: %s", err)
|
1931
|
+
}
|
1932
|
+
if buf.Len() == 0 {
|
1933
|
+
t.Errorf("enc.EncodeToken: empty buffer")
|
1934
|
+
}
|
1935
|
+
want := "<object2></object2>"
|
1936
|
+
if buf.String() != want {
|
1937
|
+
t.Errorf("enc.EncodeToken: expected %q; got %q", want, buf.String())
|
1938
|
+
}
|
1939
|
+
}
|