ires 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1024) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +32 -45
  3. data/ext/Gopkg.lock +31 -1
  4. data/ext/ires/image.go +227 -0
  5. data/ext/ires/ires.go +47 -59
  6. data/ext/ires/uri.go +143 -0
  7. data/ext/main.go +18 -9
  8. data/ext/vendor/github.com/PuerkitoBio/purell/LICENSE +12 -0
  9. data/ext/vendor/github.com/PuerkitoBio/purell/README.md +187 -0
  10. data/ext/vendor/github.com/PuerkitoBio/purell/bench_test.go +57 -0
  11. data/ext/vendor/github.com/PuerkitoBio/purell/benchmarks/v0.1.0 +9 -0
  12. data/ext/vendor/github.com/PuerkitoBio/purell/example_test.go +35 -0
  13. data/ext/vendor/github.com/PuerkitoBio/purell/purell.go +379 -0
  14. data/ext/vendor/github.com/PuerkitoBio/purell/purell_test.go +768 -0
  15. data/ext/vendor/github.com/PuerkitoBio/purell/urlnorm_test.go +53 -0
  16. data/ext/vendor/github.com/PuerkitoBio/urlesc/LICENSE +27 -0
  17. data/ext/vendor/github.com/PuerkitoBio/urlesc/README.md +16 -0
  18. data/ext/vendor/github.com/PuerkitoBio/urlesc/urlesc.go +180 -0
  19. data/ext/vendor/github.com/PuerkitoBio/urlesc/urlesc_test.go +641 -0
  20. data/ext/vendor/github.com/{satori/go.uuid → goware/urlx}/LICENSE +3 -1
  21. data/ext/vendor/github.com/goware/urlx/README.md +172 -0
  22. data/ext/vendor/github.com/goware/urlx/urlx.go +196 -0
  23. data/ext/vendor/github.com/goware/urlx/urlx_test.go +232 -0
  24. data/ext/vendor/golang.org/x/net/AUTHORS +3 -0
  25. data/ext/vendor/golang.org/x/net/CONTRIBUTING.md +31 -0
  26. data/ext/vendor/golang.org/x/net/CONTRIBUTORS +3 -0
  27. data/ext/vendor/golang.org/x/net/LICENSE +27 -0
  28. data/ext/vendor/golang.org/x/net/PATENTS +22 -0
  29. data/ext/vendor/golang.org/x/net/README.md +16 -0
  30. data/ext/vendor/golang.org/x/net/bpf/asm.go +41 -0
  31. data/ext/vendor/golang.org/x/net/bpf/constants.go +218 -0
  32. data/ext/vendor/golang.org/x/net/bpf/doc.go +82 -0
  33. data/ext/vendor/golang.org/x/net/bpf/instructions.go +704 -0
  34. data/ext/vendor/golang.org/x/net/bpf/instructions_test.go +525 -0
  35. data/ext/vendor/golang.org/x/net/bpf/setter.go +10 -0
  36. data/ext/vendor/golang.org/x/net/bpf/testdata/all_instructions.bpf +1 -0
  37. data/ext/vendor/golang.org/x/net/bpf/testdata/all_instructions.txt +79 -0
  38. data/ext/vendor/golang.org/x/net/bpf/vm.go +140 -0
  39. data/ext/vendor/golang.org/x/net/bpf/vm_aluop_test.go +512 -0
  40. data/ext/vendor/golang.org/x/net/bpf/vm_bpf_test.go +192 -0
  41. data/ext/vendor/golang.org/x/net/bpf/vm_extension_test.go +49 -0
  42. data/ext/vendor/golang.org/x/net/bpf/vm_instructions.go +174 -0
  43. data/ext/vendor/golang.org/x/net/bpf/vm_jump_test.go +380 -0
  44. data/ext/vendor/golang.org/x/net/bpf/vm_load_test.go +246 -0
  45. data/ext/vendor/golang.org/x/net/bpf/vm_ret_test.go +115 -0
  46. data/ext/vendor/golang.org/x/net/bpf/vm_scratch_test.go +247 -0
  47. data/ext/vendor/golang.org/x/net/bpf/vm_test.go +144 -0
  48. data/ext/vendor/golang.org/x/net/codereview.cfg +1 -0
  49. data/ext/vendor/golang.org/x/net/context/context.go +54 -0
  50. data/ext/vendor/golang.org/x/net/context/context_test.go +583 -0
  51. data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go +74 -0
  52. data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_17_test.go +29 -0
  53. data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go +147 -0
  54. data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17_test.go +79 -0
  55. data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_test.go +105 -0
  56. data/ext/vendor/golang.org/x/net/context/go17.go +72 -0
  57. data/ext/vendor/golang.org/x/net/context/go19.go +20 -0
  58. data/ext/vendor/golang.org/x/net/context/pre_go17.go +300 -0
  59. data/ext/vendor/golang.org/x/net/context/pre_go19.go +109 -0
  60. data/ext/vendor/golang.org/x/net/context/withtimeout_test.go +31 -0
  61. data/ext/vendor/golang.org/x/net/dict/dict.go +210 -0
  62. data/ext/vendor/golang.org/x/net/dns/dnsmessage/example_test.go +132 -0
  63. data/ext/vendor/golang.org/x/net/dns/dnsmessage/message.go +1997 -0
  64. data/ext/vendor/golang.org/x/net/dns/dnsmessage/message_test.go +1116 -0
  65. data/ext/vendor/golang.org/x/net/html/atom/atom.go +78 -0
  66. data/ext/vendor/golang.org/x/net/html/atom/atom_test.go +109 -0
  67. data/ext/vendor/golang.org/x/net/html/atom/gen.go +709 -0
  68. data/ext/vendor/golang.org/x/net/html/atom/table.go +777 -0
  69. data/ext/vendor/golang.org/x/net/html/atom/table_test.go +373 -0
  70. data/ext/vendor/golang.org/x/net/html/charset/charset.go +257 -0
  71. data/ext/vendor/golang.org/x/net/html/charset/charset_test.go +237 -0
  72. data/ext/vendor/golang.org/x/net/html/charset/testdata/HTTP-charset.html +48 -0
  73. data/ext/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-UTF-8-BOM.html +48 -0
  74. data/ext/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-charset.html +49 -0
  75. data/ext/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-content.html +49 -0
  76. data/ext/vendor/golang.org/x/net/html/charset/testdata/No-encoding-declaration.html +47 -0
  77. data/ext/vendor/golang.org/x/net/html/charset/testdata/README +9 -0
  78. data/ext/vendor/golang.org/x/net/html/charset/testdata/UTF-16BE-BOM.html +0 -0
  79. data/ext/vendor/golang.org/x/net/html/charset/testdata/UTF-16LE-BOM.html +0 -0
  80. data/ext/vendor/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-charset.html +49 -0
  81. data/ext/vendor/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-content.html +48 -0
  82. data/ext/vendor/golang.org/x/net/html/charset/testdata/meta-charset-attribute.html +48 -0
  83. data/ext/vendor/golang.org/x/net/html/charset/testdata/meta-content-attribute.html +48 -0
  84. data/ext/vendor/golang.org/x/net/html/const.go +104 -0
  85. data/ext/vendor/golang.org/x/net/html/doc.go +106 -0
  86. data/ext/vendor/golang.org/x/net/html/doctype.go +156 -0
  87. data/ext/vendor/golang.org/x/net/html/entity.go +2253 -0
  88. data/ext/vendor/golang.org/x/net/html/entity_test.go +29 -0
  89. data/ext/vendor/golang.org/x/net/html/escape.go +258 -0
  90. data/ext/vendor/golang.org/x/net/html/escape_test.go +97 -0
  91. data/ext/vendor/golang.org/x/net/html/example_test.go +40 -0
  92. data/ext/vendor/golang.org/x/net/html/foreign.go +226 -0
  93. data/ext/vendor/golang.org/x/net/html/node.go +193 -0
  94. data/ext/vendor/golang.org/x/net/html/node_test.go +146 -0
  95. data/ext/vendor/golang.org/x/net/html/parse.go +2094 -0
  96. data/ext/vendor/golang.org/x/net/html/parse_test.go +388 -0
  97. data/ext/vendor/golang.org/x/net/html/render.go +271 -0
  98. data/ext/vendor/golang.org/x/net/html/render_test.go +156 -0
  99. data/ext/vendor/golang.org/x/net/html/testdata/go1.html +2237 -0
  100. data/ext/vendor/golang.org/x/net/html/testdata/webkit/README +28 -0
  101. data/ext/vendor/golang.org/x/net/html/testdata/webkit/adoption01.dat +194 -0
  102. data/ext/vendor/golang.org/x/net/html/testdata/webkit/adoption02.dat +31 -0
  103. data/ext/vendor/golang.org/x/net/html/testdata/webkit/comments01.dat +135 -0
  104. data/ext/vendor/golang.org/x/net/html/testdata/webkit/doctype01.dat +370 -0
  105. data/ext/vendor/golang.org/x/net/html/testdata/webkit/entities01.dat +603 -0
  106. data/ext/vendor/golang.org/x/net/html/testdata/webkit/entities02.dat +249 -0
  107. data/ext/vendor/golang.org/x/net/html/testdata/webkit/html5test-com.dat +246 -0
  108. data/ext/vendor/golang.org/x/net/html/testdata/webkit/inbody01.dat +43 -0
  109. data/ext/vendor/golang.org/x/net/html/testdata/webkit/isindex.dat +40 -0
  110. data/ext/vendor/golang.org/x/net/html/testdata/webkit/pending-spec-changes-plain-text-unsafe.dat +0 -0
  111. data/ext/vendor/golang.org/x/net/html/testdata/webkit/pending-spec-changes.dat +52 -0
  112. data/ext/vendor/golang.org/x/net/html/testdata/webkit/plain-text-unsafe.dat +0 -0
  113. data/ext/vendor/golang.org/x/net/html/testdata/webkit/scriptdata01.dat +308 -0
  114. data/ext/vendor/golang.org/x/net/html/testdata/webkit/scripted/adoption01.dat +15 -0
  115. data/ext/vendor/golang.org/x/net/html/testdata/webkit/scripted/webkit01.dat +28 -0
  116. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tables01.dat +212 -0
  117. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests1.dat +1952 -0
  118. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests10.dat +799 -0
  119. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests11.dat +482 -0
  120. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests12.dat +62 -0
  121. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests14.dat +74 -0
  122. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests15.dat +208 -0
  123. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests16.dat +2299 -0
  124. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests17.dat +153 -0
  125. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests18.dat +269 -0
  126. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests19.dat +1237 -0
  127. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests2.dat +763 -0
  128. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests20.dat +455 -0
  129. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests21.dat +221 -0
  130. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests22.dat +157 -0
  131. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests23.dat +155 -0
  132. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests24.dat +79 -0
  133. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests25.dat +219 -0
  134. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests26.dat +313 -0
  135. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests3.dat +305 -0
  136. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests4.dat +59 -0
  137. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests5.dat +191 -0
  138. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests6.dat +663 -0
  139. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests7.dat +390 -0
  140. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests8.dat +148 -0
  141. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests9.dat +457 -0
  142. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests_innerHTML_1.dat +741 -0
  143. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tricky01.dat +261 -0
  144. data/ext/vendor/golang.org/x/net/html/testdata/webkit/webkit01.dat +610 -0
  145. data/ext/vendor/golang.org/x/net/html/testdata/webkit/webkit02.dat +159 -0
  146. data/ext/vendor/golang.org/x/net/html/token.go +1219 -0
  147. data/ext/vendor/golang.org/x/net/html/token_test.go +748 -0
  148. data/ext/vendor/golang.org/x/net/http2/Dockerfile +51 -0
  149. data/ext/vendor/golang.org/x/net/http2/Makefile +3 -0
  150. data/ext/vendor/golang.org/x/net/http2/README +20 -0
  151. data/ext/vendor/golang.org/x/net/http2/ciphers.go +641 -0
  152. data/ext/vendor/golang.org/x/net/http2/ciphers_test.go +309 -0
  153. data/ext/vendor/golang.org/x/net/http2/client_conn_pool.go +256 -0
  154. data/ext/vendor/golang.org/x/net/http2/configure_transport.go +80 -0
  155. data/ext/vendor/golang.org/x/net/http2/databuffer.go +146 -0
  156. data/ext/vendor/golang.org/x/net/http2/databuffer_test.go +157 -0
  157. data/ext/vendor/golang.org/x/net/http2/errors.go +133 -0
  158. data/ext/vendor/golang.org/x/net/http2/errors_test.go +24 -0
  159. data/ext/vendor/golang.org/x/net/http2/flow.go +50 -0
  160. data/ext/vendor/golang.org/x/net/http2/flow_test.go +53 -0
  161. data/ext/vendor/golang.org/x/net/http2/frame.go +1579 -0
  162. data/ext/vendor/golang.org/x/net/http2/frame_test.go +1191 -0
  163. data/ext/vendor/golang.org/x/net/http2/go16.go +16 -0
  164. data/ext/vendor/golang.org/x/net/http2/go17.go +106 -0
  165. data/ext/vendor/golang.org/x/net/http2/go17_not18.go +36 -0
  166. data/ext/vendor/golang.org/x/net/http2/go18.go +56 -0
  167. data/ext/vendor/golang.org/x/net/http2/go18_test.go +79 -0
  168. data/ext/vendor/golang.org/x/net/http2/go19.go +16 -0
  169. data/ext/vendor/golang.org/x/net/http2/go19_test.go +60 -0
  170. data/ext/vendor/golang.org/x/net/http2/gotrack.go +170 -0
  171. data/ext/vendor/golang.org/x/net/http2/gotrack_test.go +33 -0
  172. data/ext/vendor/golang.org/x/net/http2/h2demo/Makefile +8 -0
  173. data/ext/vendor/golang.org/x/net/http2/h2demo/README +16 -0
  174. data/ext/vendor/golang.org/x/net/http2/h2demo/h2demo.go +538 -0
  175. data/ext/vendor/golang.org/x/net/http2/h2demo/launch.go +302 -0
  176. data/ext/vendor/golang.org/x/net/http2/h2demo/rootCA.key +27 -0
  177. data/ext/vendor/golang.org/x/net/http2/h2demo/rootCA.pem +26 -0
  178. data/ext/vendor/golang.org/x/net/http2/h2demo/rootCA.srl +1 -0
  179. data/ext/vendor/golang.org/x/net/http2/h2demo/server.crt +20 -0
  180. data/ext/vendor/golang.org/x/net/http2/h2demo/server.key +27 -0
  181. data/ext/vendor/golang.org/x/net/http2/h2demo/tmpl.go +1991 -0
  182. data/ext/vendor/golang.org/x/net/http2/h2i/README.md +97 -0
  183. data/ext/vendor/golang.org/x/net/http2/h2i/h2i.go +522 -0
  184. data/ext/vendor/golang.org/x/net/http2/headermap.go +78 -0
  185. data/ext/vendor/golang.org/x/net/http2/hpack/encode.go +240 -0
  186. data/ext/vendor/golang.org/x/net/http2/hpack/encode_test.go +386 -0
  187. data/ext/vendor/golang.org/x/net/http2/hpack/hpack.go +490 -0
  188. data/ext/vendor/golang.org/x/net/http2/hpack/hpack_test.go +722 -0
  189. data/ext/vendor/golang.org/x/net/http2/hpack/huffman.go +212 -0
  190. data/ext/vendor/golang.org/x/net/http2/hpack/tables.go +479 -0
  191. data/ext/vendor/golang.org/x/net/http2/hpack/tables_test.go +214 -0
  192. data/ext/vendor/golang.org/x/net/http2/http2.go +391 -0
  193. data/ext/vendor/golang.org/x/net/http2/http2_test.go +199 -0
  194. data/ext/vendor/golang.org/x/net/http2/not_go16.go +21 -0
  195. data/ext/vendor/golang.org/x/net/http2/not_go17.go +87 -0
  196. data/ext/vendor/golang.org/x/net/http2/not_go18.go +29 -0
  197. data/ext/vendor/golang.org/x/net/http2/not_go19.go +16 -0
  198. data/ext/vendor/golang.org/x/net/http2/pipe.go +163 -0
  199. data/ext/vendor/golang.org/x/net/http2/pipe_test.go +130 -0
  200. data/ext/vendor/golang.org/x/net/http2/server.go +2857 -0
  201. data/ext/vendor/golang.org/x/net/http2/server_push_test.go +521 -0
  202. data/ext/vendor/golang.org/x/net/http2/server_test.go +3721 -0
  203. data/ext/vendor/golang.org/x/net/http2/testdata/draft-ietf-httpbis-http2.xml +5021 -0
  204. data/ext/vendor/golang.org/x/net/http2/transport.go +2285 -0
  205. data/ext/vendor/golang.org/x/net/http2/transport_test.go +3714 -0
  206. data/ext/vendor/golang.org/x/net/http2/write.go +370 -0
  207. data/ext/vendor/golang.org/x/net/http2/writesched.go +242 -0
  208. data/ext/vendor/golang.org/x/net/http2/writesched_priority.go +452 -0
  209. data/ext/vendor/golang.org/x/net/http2/writesched_priority_test.go +541 -0
  210. data/ext/vendor/golang.org/x/net/http2/writesched_random.go +72 -0
  211. data/ext/vendor/golang.org/x/net/http2/writesched_random_test.go +44 -0
  212. data/ext/vendor/golang.org/x/net/http2/writesched_test.go +125 -0
  213. data/ext/vendor/golang.org/x/net/http2/z_spec_test.go +356 -0
  214. data/ext/vendor/golang.org/x/net/icmp/dstunreach.go +41 -0
  215. data/ext/vendor/golang.org/x/net/icmp/echo.go +45 -0
  216. data/ext/vendor/golang.org/x/net/icmp/endpoint.go +113 -0
  217. data/ext/vendor/golang.org/x/net/icmp/example_test.go +63 -0
  218. data/ext/vendor/golang.org/x/net/icmp/extension.go +89 -0
  219. data/ext/vendor/golang.org/x/net/icmp/extension_test.go +259 -0
  220. data/ext/vendor/golang.org/x/net/icmp/helper_posix.go +75 -0
  221. data/ext/vendor/golang.org/x/net/icmp/interface.go +236 -0
  222. data/ext/vendor/golang.org/x/net/icmp/ipv4.go +61 -0
  223. data/ext/vendor/golang.org/x/net/icmp/ipv4_test.go +83 -0
  224. data/ext/vendor/golang.org/x/net/icmp/ipv6.go +23 -0
  225. data/ext/vendor/golang.org/x/net/icmp/listen_posix.go +100 -0
  226. data/ext/vendor/golang.org/x/net/icmp/listen_stub.go +33 -0
  227. data/ext/vendor/golang.org/x/net/icmp/message.go +152 -0
  228. data/ext/vendor/golang.org/x/net/icmp/message_test.go +134 -0
  229. data/ext/vendor/golang.org/x/net/icmp/messagebody.go +41 -0
  230. data/ext/vendor/golang.org/x/net/icmp/mpls.go +77 -0
  231. data/ext/vendor/golang.org/x/net/icmp/multipart.go +109 -0
  232. data/ext/vendor/golang.org/x/net/icmp/multipart_test.go +442 -0
  233. data/ext/vendor/golang.org/x/net/icmp/packettoobig.go +43 -0
  234. data/ext/vendor/golang.org/x/net/icmp/paramprob.go +63 -0
  235. data/ext/vendor/golang.org/x/net/icmp/ping_test.go +200 -0
  236. data/ext/vendor/golang.org/x/net/icmp/sys_freebsd.go +11 -0
  237. data/ext/vendor/golang.org/x/net/icmp/timeexceeded.go +39 -0
  238. data/ext/vendor/golang.org/x/net/idna/example_test.go +70 -0
  239. data/ext/vendor/golang.org/x/net/idna/idna.go +680 -0
  240. data/ext/vendor/golang.org/x/net/idna/idna_test.go +108 -0
  241. data/ext/vendor/golang.org/x/net/idna/punycode.go +203 -0
  242. data/ext/vendor/golang.org/x/net/idna/punycode_test.go +198 -0
  243. data/ext/vendor/golang.org/x/net/idna/tables.go +4477 -0
  244. data/ext/vendor/golang.org/x/net/idna/trie.go +72 -0
  245. data/ext/vendor/golang.org/x/net/idna/trieval.go +114 -0
  246. data/ext/vendor/golang.org/x/net/internal/iana/const.go +180 -0
  247. data/ext/vendor/golang.org/x/net/internal/iana/gen.go +293 -0
  248. data/ext/vendor/golang.org/x/net/internal/nettest/helper_bsd.go +53 -0
  249. data/ext/vendor/golang.org/x/net/internal/nettest/helper_nobsd.go +15 -0
  250. data/ext/vendor/golang.org/x/net/internal/nettest/helper_posix.go +31 -0
  251. data/ext/vendor/golang.org/x/net/internal/nettest/helper_stub.go +32 -0
  252. data/ext/vendor/golang.org/x/net/internal/nettest/helper_unix.go +29 -0
  253. data/ext/vendor/golang.org/x/net/internal/nettest/helper_windows.go +42 -0
  254. data/ext/vendor/golang.org/x/net/internal/nettest/interface.go +94 -0
  255. data/ext/vendor/golang.org/x/net/internal/nettest/rlimit.go +11 -0
  256. data/ext/vendor/golang.org/x/net/internal/nettest/stack.go +147 -0
  257. data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr.go +11 -0
  258. data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_bsd.go +13 -0
  259. data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_32bit.go +14 -0
  260. data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_64bit.go +14 -0
  261. data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_solaris_64bit.go +14 -0
  262. data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_stub.go +17 -0
  263. data/ext/vendor/golang.org/x/net/internal/socket/defs_darwin.go +44 -0
  264. data/ext/vendor/golang.org/x/net/internal/socket/defs_dragonfly.go +44 -0
  265. data/ext/vendor/golang.org/x/net/internal/socket/defs_freebsd.go +44 -0
  266. data/ext/vendor/golang.org/x/net/internal/socket/defs_linux.go +49 -0
  267. data/ext/vendor/golang.org/x/net/internal/socket/defs_netbsd.go +47 -0
  268. data/ext/vendor/golang.org/x/net/internal/socket/defs_openbsd.go +44 -0
  269. data/ext/vendor/golang.org/x/net/internal/socket/defs_solaris.go +44 -0
  270. data/ext/vendor/golang.org/x/net/internal/socket/error_unix.go +31 -0
  271. data/ext/vendor/golang.org/x/net/internal/socket/error_windows.go +26 -0
  272. data/ext/vendor/golang.org/x/net/internal/socket/iovec_32bit.go +19 -0
  273. data/ext/vendor/golang.org/x/net/internal/socket/iovec_64bit.go +19 -0
  274. data/ext/vendor/golang.org/x/net/internal/socket/iovec_solaris_64bit.go +19 -0
  275. data/ext/vendor/golang.org/x/net/internal/socket/iovec_stub.go +11 -0
  276. data/ext/vendor/golang.org/x/net/internal/socket/mmsghdr_stub.go +21 -0
  277. data/ext/vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go +42 -0
  278. data/ext/vendor/golang.org/x/net/internal/socket/msghdr_bsd.go +39 -0
  279. data/ext/vendor/golang.org/x/net/internal/socket/msghdr_bsdvar.go +16 -0
  280. data/ext/vendor/golang.org/x/net/internal/socket/msghdr_linux.go +36 -0
  281. data/ext/vendor/golang.org/x/net/internal/socket/msghdr_linux_32bit.go +24 -0
  282. data/ext/vendor/golang.org/x/net/internal/socket/msghdr_linux_64bit.go +24 -0
  283. data/ext/vendor/golang.org/x/net/internal/socket/msghdr_openbsd.go +14 -0
  284. data/ext/vendor/golang.org/x/net/internal/socket/msghdr_solaris_64bit.go +36 -0
  285. data/ext/vendor/golang.org/x/net/internal/socket/msghdr_stub.go +14 -0
  286. data/ext/vendor/golang.org/x/net/internal/socket/rawconn.go +66 -0
  287. data/ext/vendor/golang.org/x/net/internal/socket/rawconn_mmsg.go +74 -0
  288. data/ext/vendor/golang.org/x/net/internal/socket/rawconn_msg.go +77 -0
  289. data/ext/vendor/golang.org/x/net/internal/socket/rawconn_nommsg.go +18 -0
  290. data/ext/vendor/golang.org/x/net/internal/socket/rawconn_nomsg.go +18 -0
  291. data/ext/vendor/golang.org/x/net/internal/socket/rawconn_stub.go +25 -0
  292. data/ext/vendor/golang.org/x/net/internal/socket/reflect.go +62 -0
  293. data/ext/vendor/golang.org/x/net/internal/socket/socket.go +285 -0
  294. data/ext/vendor/golang.org/x/net/internal/socket/socket_go1_9_test.go +259 -0
  295. data/ext/vendor/golang.org/x/net/internal/socket/socket_test.go +46 -0
  296. data/ext/vendor/golang.org/x/net/internal/socket/sys.go +33 -0
  297. data/ext/vendor/golang.org/x/net/internal/socket/sys_bsd.go +17 -0
  298. data/ext/vendor/golang.org/x/net/internal/socket/sys_bsdvar.go +14 -0
  299. data/ext/vendor/golang.org/x/net/internal/socket/sys_darwin.go +7 -0
  300. data/ext/vendor/golang.org/x/net/internal/socket/sys_dragonfly.go +7 -0
  301. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux.go +27 -0
  302. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_386.go +55 -0
  303. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_386.s +11 -0
  304. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_amd64.go +10 -0
  305. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_arm.go +10 -0
  306. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_arm64.go +10 -0
  307. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_mips.go +10 -0
  308. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_mips64.go +10 -0
  309. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_mips64le.go +10 -0
  310. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_mipsle.go +10 -0
  311. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_ppc64.go +10 -0
  312. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_ppc64le.go +10 -0
  313. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_s390x.go +55 -0
  314. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_s390x.s +11 -0
  315. data/ext/vendor/golang.org/x/net/internal/socket/sys_netbsd.go +25 -0
  316. data/ext/vendor/golang.org/x/net/internal/socket/sys_posix.go +168 -0
  317. data/ext/vendor/golang.org/x/net/internal/socket/sys_solaris.go +71 -0
  318. data/ext/vendor/golang.org/x/net/internal/socket/sys_solaris_amd64.s +11 -0
  319. data/ext/vendor/golang.org/x/net/internal/socket/sys_stub.go +64 -0
  320. data/ext/vendor/golang.org/x/net/internal/socket/sys_unix.go +33 -0
  321. data/ext/vendor/golang.org/x/net/internal/socket/sys_windows.go +70 -0
  322. data/ext/vendor/golang.org/x/net/internal/socket/zsys_darwin_386.go +59 -0
  323. data/ext/vendor/golang.org/x/net/internal/socket/zsys_darwin_amd64.go +61 -0
  324. data/ext/vendor/golang.org/x/net/internal/socket/zsys_darwin_arm.go +59 -0
  325. data/ext/vendor/golang.org/x/net/internal/socket/zsys_dragonfly_amd64.go +61 -0
  326. data/ext/vendor/golang.org/x/net/internal/socket/zsys_freebsd_386.go +59 -0
  327. data/ext/vendor/golang.org/x/net/internal/socket/zsys_freebsd_amd64.go +61 -0
  328. data/ext/vendor/golang.org/x/net/internal/socket/zsys_freebsd_arm.go +59 -0
  329. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_386.go +63 -0
  330. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_amd64.go +66 -0
  331. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_arm.go +63 -0
  332. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_arm64.go +66 -0
  333. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_mips.go +63 -0
  334. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_mips64.go +66 -0
  335. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_mips64le.go +66 -0
  336. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_mipsle.go +63 -0
  337. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64.go +66 -0
  338. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64le.go +66 -0
  339. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_s390x.go +66 -0
  340. data/ext/vendor/golang.org/x/net/internal/socket/zsys_netbsd_386.go +65 -0
  341. data/ext/vendor/golang.org/x/net/internal/socket/zsys_netbsd_amd64.go +68 -0
  342. data/ext/vendor/golang.org/x/net/internal/socket/zsys_netbsd_arm.go +59 -0
  343. data/ext/vendor/golang.org/x/net/internal/socket/zsys_openbsd_386.go +59 -0
  344. data/ext/vendor/golang.org/x/net/internal/socket/zsys_openbsd_amd64.go +61 -0
  345. data/ext/vendor/golang.org/x/net/internal/socket/zsys_openbsd_arm.go +59 -0
  346. data/ext/vendor/golang.org/x/net/internal/socket/zsys_solaris_amd64.go +60 -0
  347. data/ext/vendor/golang.org/x/net/internal/timeseries/timeseries.go +525 -0
  348. data/ext/vendor/golang.org/x/net/internal/timeseries/timeseries_test.go +170 -0
  349. data/ext/vendor/golang.org/x/net/ipv4/batch.go +191 -0
  350. data/ext/vendor/golang.org/x/net/ipv4/bpf_test.go +93 -0
  351. data/ext/vendor/golang.org/x/net/ipv4/control.go +144 -0
  352. data/ext/vendor/golang.org/x/net/ipv4/control_bsd.go +40 -0
  353. data/ext/vendor/golang.org/x/net/ipv4/control_pktinfo.go +39 -0
  354. data/ext/vendor/golang.org/x/net/ipv4/control_stub.go +13 -0
  355. data/ext/vendor/golang.org/x/net/ipv4/control_test.go +21 -0
  356. data/ext/vendor/golang.org/x/net/ipv4/control_unix.go +73 -0
  357. data/ext/vendor/golang.org/x/net/ipv4/control_windows.go +16 -0
  358. data/ext/vendor/golang.org/x/net/ipv4/defs_darwin.go +77 -0
  359. data/ext/vendor/golang.org/x/net/ipv4/defs_dragonfly.go +38 -0
  360. data/ext/vendor/golang.org/x/net/ipv4/defs_freebsd.go +75 -0
  361. data/ext/vendor/golang.org/x/net/ipv4/defs_linux.go +122 -0
  362. data/ext/vendor/golang.org/x/net/ipv4/defs_netbsd.go +37 -0
  363. data/ext/vendor/golang.org/x/net/ipv4/defs_openbsd.go +37 -0
  364. data/ext/vendor/golang.org/x/net/ipv4/defs_solaris.go +84 -0
  365. data/ext/vendor/golang.org/x/net/ipv4/dgramopt.go +265 -0
  366. data/ext/vendor/golang.org/x/net/ipv4/doc.go +244 -0
  367. data/ext/vendor/golang.org/x/net/ipv4/endpoint.go +187 -0
  368. data/ext/vendor/golang.org/x/net/ipv4/example_test.go +224 -0
  369. data/ext/vendor/golang.org/x/net/ipv4/gen.go +199 -0
  370. data/ext/vendor/golang.org/x/net/ipv4/genericopt.go +57 -0
  371. data/ext/vendor/golang.org/x/net/ipv4/header.go +159 -0
  372. data/ext/vendor/golang.org/x/net/ipv4/header_test.go +228 -0
  373. data/ext/vendor/golang.org/x/net/ipv4/helper.go +63 -0
  374. data/ext/vendor/golang.org/x/net/ipv4/iana.go +34 -0
  375. data/ext/vendor/golang.org/x/net/ipv4/icmp.go +57 -0
  376. data/ext/vendor/golang.org/x/net/ipv4/icmp_linux.go +25 -0
  377. data/ext/vendor/golang.org/x/net/ipv4/icmp_stub.go +25 -0
  378. data/ext/vendor/golang.org/x/net/ipv4/icmp_test.go +95 -0
  379. data/ext/vendor/golang.org/x/net/ipv4/multicast_test.go +334 -0
  380. data/ext/vendor/golang.org/x/net/ipv4/multicastlistener_test.go +265 -0
  381. data/ext/vendor/golang.org/x/net/ipv4/multicastsockopt_test.go +195 -0
  382. data/ext/vendor/golang.org/x/net/ipv4/packet.go +69 -0
  383. data/ext/vendor/golang.org/x/net/ipv4/packet_go1_8.go +56 -0
  384. data/ext/vendor/golang.org/x/net/ipv4/packet_go1_9.go +67 -0
  385. data/ext/vendor/golang.org/x/net/ipv4/payload.go +23 -0
  386. data/ext/vendor/golang.org/x/net/ipv4/payload_cmsg.go +36 -0
  387. data/ext/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_8.go +59 -0
  388. data/ext/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_9.go +67 -0
  389. data/ext/vendor/golang.org/x/net/ipv4/payload_nocmsg.go +42 -0
  390. data/ext/vendor/golang.org/x/net/ipv4/readwrite_go1_8_test.go +248 -0
  391. data/ext/vendor/golang.org/x/net/ipv4/readwrite_go1_9_test.go +388 -0
  392. data/ext/vendor/golang.org/x/net/ipv4/readwrite_test.go +140 -0
  393. data/ext/vendor/golang.org/x/net/ipv4/sockopt.go +44 -0
  394. data/ext/vendor/golang.org/x/net/ipv4/sockopt_posix.go +71 -0
  395. data/ext/vendor/golang.org/x/net/ipv4/sockopt_stub.go +42 -0
  396. data/ext/vendor/golang.org/x/net/ipv4/sys_asmreq.go +119 -0
  397. data/ext/vendor/golang.org/x/net/ipv4/sys_asmreq_stub.go +25 -0
  398. data/ext/vendor/golang.org/x/net/ipv4/sys_asmreqn.go +42 -0
  399. data/ext/vendor/golang.org/x/net/ipv4/sys_asmreqn_stub.go +21 -0
  400. data/ext/vendor/golang.org/x/net/ipv4/sys_bpf.go +23 -0
  401. data/ext/vendor/golang.org/x/net/ipv4/sys_bpf_stub.go +16 -0
  402. data/ext/vendor/golang.org/x/net/ipv4/sys_bsd.go +37 -0
  403. data/ext/vendor/golang.org/x/net/ipv4/sys_darwin.go +93 -0
  404. data/ext/vendor/golang.org/x/net/ipv4/sys_dragonfly.go +35 -0
  405. data/ext/vendor/golang.org/x/net/ipv4/sys_freebsd.go +76 -0
  406. data/ext/vendor/golang.org/x/net/ipv4/sys_linux.go +59 -0
  407. data/ext/vendor/golang.org/x/net/ipv4/sys_solaris.go +57 -0
  408. data/ext/vendor/golang.org/x/net/ipv4/sys_ssmreq.go +54 -0
  409. data/ext/vendor/golang.org/x/net/ipv4/sys_ssmreq_stub.go +21 -0
  410. data/ext/vendor/golang.org/x/net/ipv4/sys_stub.go +13 -0
  411. data/ext/vendor/golang.org/x/net/ipv4/sys_windows.go +67 -0
  412. data/ext/vendor/golang.org/x/net/ipv4/unicast_test.go +247 -0
  413. data/ext/vendor/golang.org/x/net/ipv4/unicastsockopt_test.go +148 -0
  414. data/ext/vendor/golang.org/x/net/ipv4/zsys_darwin.go +99 -0
  415. data/ext/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go +31 -0
  416. data/ext/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go +93 -0
  417. data/ext/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go +95 -0
  418. data/ext/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go +95 -0
  419. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_386.go +148 -0
  420. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go +150 -0
  421. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go +148 -0
  422. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go +150 -0
  423. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_mips.go +148 -0
  424. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go +150 -0
  425. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go +150 -0
  426. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_mipsle.go +148 -0
  427. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_ppc.go +148 -0
  428. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go +150 -0
  429. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go +150 -0
  430. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go +150 -0
  431. data/ext/vendor/golang.org/x/net/ipv4/zsys_netbsd.go +30 -0
  432. data/ext/vendor/golang.org/x/net/ipv4/zsys_openbsd.go +30 -0
  433. data/ext/vendor/golang.org/x/net/ipv4/zsys_solaris.go +100 -0
  434. data/ext/vendor/golang.org/x/net/ipv6/batch.go +119 -0
  435. data/ext/vendor/golang.org/x/net/ipv6/bpf_test.go +96 -0
  436. data/ext/vendor/golang.org/x/net/ipv6/control.go +187 -0
  437. data/ext/vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go +48 -0
  438. data/ext/vendor/golang.org/x/net/ipv6/control_rfc3542_unix.go +94 -0
  439. data/ext/vendor/golang.org/x/net/ipv6/control_stub.go +13 -0
  440. data/ext/vendor/golang.org/x/net/ipv6/control_test.go +21 -0
  441. data/ext/vendor/golang.org/x/net/ipv6/control_unix.go +55 -0
  442. data/ext/vendor/golang.org/x/net/ipv6/control_windows.go +16 -0
  443. data/ext/vendor/golang.org/x/net/ipv6/defs_darwin.go +112 -0
  444. data/ext/vendor/golang.org/x/net/ipv6/defs_dragonfly.go +84 -0
  445. data/ext/vendor/golang.org/x/net/ipv6/defs_freebsd.go +105 -0
  446. data/ext/vendor/golang.org/x/net/ipv6/defs_linux.go +147 -0
  447. data/ext/vendor/golang.org/x/net/ipv6/defs_netbsd.go +80 -0
  448. data/ext/vendor/golang.org/x/net/ipv6/defs_openbsd.go +89 -0
  449. data/ext/vendor/golang.org/x/net/ipv6/defs_solaris.go +114 -0
  450. data/ext/vendor/golang.org/x/net/ipv6/dgramopt.go +302 -0
  451. data/ext/vendor/golang.org/x/net/ipv6/doc.go +243 -0
  452. data/ext/vendor/golang.org/x/net/ipv6/endpoint.go +128 -0
  453. data/ext/vendor/golang.org/x/net/ipv6/example_test.go +216 -0
  454. data/ext/vendor/golang.org/x/net/ipv6/gen.go +199 -0
  455. data/ext/vendor/golang.org/x/net/ipv6/genericopt.go +58 -0
  456. data/ext/vendor/golang.org/x/net/ipv6/header.go +55 -0
  457. data/ext/vendor/golang.org/x/net/ipv6/header_test.go +55 -0
  458. data/ext/vendor/golang.org/x/net/ipv6/helper.go +57 -0
  459. data/ext/vendor/golang.org/x/net/ipv6/iana.go +82 -0
  460. data/ext/vendor/golang.org/x/net/ipv6/icmp.go +60 -0
  461. data/ext/vendor/golang.org/x/net/ipv6/icmp_bsd.go +29 -0
  462. data/ext/vendor/golang.org/x/net/ipv6/icmp_linux.go +27 -0
  463. data/ext/vendor/golang.org/x/net/ipv6/icmp_solaris.go +27 -0
  464. data/ext/vendor/golang.org/x/net/ipv6/icmp_stub.go +23 -0
  465. data/ext/vendor/golang.org/x/net/ipv6/icmp_test.go +96 -0
  466. data/ext/vendor/golang.org/x/net/ipv6/icmp_windows.go +22 -0
  467. data/ext/vendor/golang.org/x/net/ipv6/mocktransponder_test.go +32 -0
  468. data/ext/vendor/golang.org/x/net/ipv6/multicast_test.go +264 -0
  469. data/ext/vendor/golang.org/x/net/ipv6/multicastlistener_test.go +261 -0
  470. data/ext/vendor/golang.org/x/net/ipv6/multicastsockopt_test.go +157 -0
  471. data/ext/vendor/golang.org/x/net/ipv6/payload.go +23 -0
  472. data/ext/vendor/golang.org/x/net/ipv6/payload_cmsg.go +35 -0
  473. data/ext/vendor/golang.org/x/net/ipv6/payload_cmsg_go1_8.go +55 -0
  474. data/ext/vendor/golang.org/x/net/ipv6/payload_cmsg_go1_9.go +57 -0
  475. data/ext/vendor/golang.org/x/net/ipv6/payload_nocmsg.go +41 -0
  476. data/ext/vendor/golang.org/x/net/ipv6/readwrite_go1_8_test.go +242 -0
  477. data/ext/vendor/golang.org/x/net/ipv6/readwrite_go1_9_test.go +373 -0
  478. data/ext/vendor/golang.org/x/net/ipv6/readwrite_test.go +148 -0
  479. data/ext/vendor/golang.org/x/net/ipv6/sockopt.go +43 -0
  480. data/ext/vendor/golang.org/x/net/ipv6/sockopt_posix.go +87 -0
  481. data/ext/vendor/golang.org/x/net/ipv6/sockopt_stub.go +46 -0
  482. data/ext/vendor/golang.org/x/net/ipv6/sockopt_test.go +133 -0
  483. data/ext/vendor/golang.org/x/net/ipv6/sys_asmreq.go +24 -0
  484. data/ext/vendor/golang.org/x/net/ipv6/sys_asmreq_stub.go +17 -0
  485. data/ext/vendor/golang.org/x/net/ipv6/sys_bpf.go +23 -0
  486. data/ext/vendor/golang.org/x/net/ipv6/sys_bpf_stub.go +16 -0
  487. data/ext/vendor/golang.org/x/net/ipv6/sys_bsd.go +57 -0
  488. data/ext/vendor/golang.org/x/net/ipv6/sys_darwin.go +106 -0
  489. data/ext/vendor/golang.org/x/net/ipv6/sys_freebsd.go +92 -0
  490. data/ext/vendor/golang.org/x/net/ipv6/sys_linux.go +74 -0
  491. data/ext/vendor/golang.org/x/net/ipv6/sys_solaris.go +74 -0
  492. data/ext/vendor/golang.org/x/net/ipv6/sys_ssmreq.go +54 -0
  493. data/ext/vendor/golang.org/x/net/ipv6/sys_ssmreq_stub.go +21 -0
  494. data/ext/vendor/golang.org/x/net/ipv6/sys_stub.go +13 -0
  495. data/ext/vendor/golang.org/x/net/ipv6/sys_windows.go +75 -0
  496. data/ext/vendor/golang.org/x/net/ipv6/unicast_test.go +184 -0
  497. data/ext/vendor/golang.org/x/net/ipv6/unicastsockopt_test.go +120 -0
  498. data/ext/vendor/golang.org/x/net/ipv6/zsys_darwin.go +131 -0
  499. data/ext/vendor/golang.org/x/net/ipv6/zsys_dragonfly.go +88 -0
  500. data/ext/vendor/golang.org/x/net/ipv6/zsys_freebsd_386.go +122 -0
  501. data/ext/vendor/golang.org/x/net/ipv6/zsys_freebsd_amd64.go +124 -0
  502. data/ext/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm.go +124 -0
  503. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_386.go +170 -0
  504. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_amd64.go +172 -0
  505. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_arm.go +170 -0
  506. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_arm64.go +172 -0
  507. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_mips.go +170 -0
  508. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_mips64.go +172 -0
  509. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_mips64le.go +172 -0
  510. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_mipsle.go +170 -0
  511. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_ppc.go +170 -0
  512. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64.go +172 -0
  513. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64le.go +172 -0
  514. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_s390x.go +172 -0
  515. data/ext/vendor/golang.org/x/net/ipv6/zsys_netbsd.go +84 -0
  516. data/ext/vendor/golang.org/x/net/ipv6/zsys_openbsd.go +93 -0
  517. data/ext/vendor/golang.org/x/net/ipv6/zsys_solaris.go +131 -0
  518. data/ext/vendor/golang.org/x/net/lex/httplex/httplex.go +351 -0
  519. data/ext/vendor/golang.org/x/net/lex/httplex/httplex_test.go +119 -0
  520. data/ext/vendor/golang.org/x/net/lif/address.go +105 -0
  521. data/ext/vendor/golang.org/x/net/lif/address_test.go +123 -0
  522. data/ext/vendor/golang.org/x/net/lif/binary.go +115 -0
  523. data/ext/vendor/golang.org/x/net/lif/defs_solaris.go +90 -0
  524. data/ext/vendor/golang.org/x/net/lif/lif.go +43 -0
  525. data/ext/vendor/golang.org/x/net/lif/link.go +126 -0
  526. data/ext/vendor/golang.org/x/net/lif/link_test.go +63 -0
  527. data/ext/vendor/golang.org/x/net/lif/sys.go +21 -0
  528. data/ext/vendor/golang.org/x/net/lif/sys_solaris_amd64.s +8 -0
  529. data/ext/vendor/golang.org/x/net/lif/syscall.go +28 -0
  530. data/ext/vendor/golang.org/x/net/lif/zsys_solaris_amd64.go +103 -0
  531. data/ext/vendor/golang.org/x/net/nettest/conntest.go +456 -0
  532. data/ext/vendor/golang.org/x/net/nettest/conntest_go16.go +24 -0
  533. data/ext/vendor/golang.org/x/net/nettest/conntest_go17.go +24 -0
  534. data/ext/vendor/golang.org/x/net/nettest/conntest_test.go +76 -0
  535. data/ext/vendor/golang.org/x/net/netutil/listen.go +48 -0
  536. data/ext/vendor/golang.org/x/net/netutil/listen_test.go +101 -0
  537. data/ext/vendor/golang.org/x/net/proxy/direct.go +18 -0
  538. data/ext/vendor/golang.org/x/net/proxy/per_host.go +140 -0
  539. data/ext/vendor/golang.org/x/net/proxy/per_host_test.go +55 -0
  540. data/ext/vendor/golang.org/x/net/proxy/proxy.go +134 -0
  541. data/ext/vendor/golang.org/x/net/proxy/proxy_test.go +215 -0
  542. data/ext/vendor/golang.org/x/net/proxy/socks5.go +214 -0
  543. data/ext/vendor/golang.org/x/net/publicsuffix/gen.go +713 -0
  544. data/ext/vendor/golang.org/x/net/publicsuffix/list.go +135 -0
  545. data/ext/vendor/golang.org/x/net/publicsuffix/list_test.go +416 -0
  546. data/ext/vendor/golang.org/x/net/publicsuffix/table.go +9419 -0
  547. data/ext/vendor/golang.org/x/net/publicsuffix/table_test.go +16756 -0
  548. data/ext/vendor/golang.org/x/net/route/address.go +425 -0
  549. data/ext/vendor/golang.org/x/net/route/address_darwin_test.go +63 -0
  550. data/ext/vendor/golang.org/x/net/route/address_test.go +103 -0
  551. data/ext/vendor/golang.org/x/net/route/binary.go +90 -0
  552. data/ext/vendor/golang.org/x/net/route/defs_darwin.go +114 -0
  553. data/ext/vendor/golang.org/x/net/route/defs_dragonfly.go +113 -0
  554. data/ext/vendor/golang.org/x/net/route/defs_freebsd.go +337 -0
  555. data/ext/vendor/golang.org/x/net/route/defs_netbsd.go +112 -0
  556. data/ext/vendor/golang.org/x/net/route/defs_openbsd.go +116 -0
  557. data/ext/vendor/golang.org/x/net/route/interface.go +64 -0
  558. data/ext/vendor/golang.org/x/net/route/interface_announce.go +32 -0
  559. data/ext/vendor/golang.org/x/net/route/interface_classic.go +66 -0
  560. data/ext/vendor/golang.org/x/net/route/interface_freebsd.go +78 -0
  561. data/ext/vendor/golang.org/x/net/route/interface_multicast.go +30 -0
  562. data/ext/vendor/golang.org/x/net/route/interface_openbsd.go +90 -0
  563. data/ext/vendor/golang.org/x/net/route/message.go +72 -0
  564. data/ext/vendor/golang.org/x/net/route/message_darwin_test.go +34 -0
  565. data/ext/vendor/golang.org/x/net/route/message_freebsd_test.go +92 -0
  566. data/ext/vendor/golang.org/x/net/route/message_test.go +239 -0
  567. data/ext/vendor/golang.org/x/net/route/route.go +123 -0
  568. data/ext/vendor/golang.org/x/net/route/route_classic.go +67 -0
  569. data/ext/vendor/golang.org/x/net/route/route_openbsd.go +65 -0
  570. data/ext/vendor/golang.org/x/net/route/route_test.go +390 -0
  571. data/ext/vendor/golang.org/x/net/route/sys.go +39 -0
  572. data/ext/vendor/golang.org/x/net/route/sys_darwin.go +87 -0
  573. data/ext/vendor/golang.org/x/net/route/sys_dragonfly.go +76 -0
  574. data/ext/vendor/golang.org/x/net/route/sys_freebsd.go +155 -0
  575. data/ext/vendor/golang.org/x/net/route/sys_netbsd.go +71 -0
  576. data/ext/vendor/golang.org/x/net/route/sys_openbsd.go +80 -0
  577. data/ext/vendor/golang.org/x/net/route/syscall.go +28 -0
  578. data/ext/vendor/golang.org/x/net/route/zsys_darwin.go +99 -0
  579. data/ext/vendor/golang.org/x/net/route/zsys_dragonfly.go +98 -0
  580. data/ext/vendor/golang.org/x/net/route/zsys_freebsd_386.go +126 -0
  581. data/ext/vendor/golang.org/x/net/route/zsys_freebsd_amd64.go +123 -0
  582. data/ext/vendor/golang.org/x/net/route/zsys_freebsd_arm.go +123 -0
  583. data/ext/vendor/golang.org/x/net/route/zsys_netbsd.go +97 -0
  584. data/ext/vendor/golang.org/x/net/route/zsys_openbsd.go +101 -0
  585. data/ext/vendor/golang.org/x/net/trace/events.go +532 -0
  586. data/ext/vendor/golang.org/x/net/trace/histogram.go +365 -0
  587. data/ext/vendor/golang.org/x/net/trace/histogram_test.go +325 -0
  588. data/ext/vendor/golang.org/x/net/trace/trace.go +1082 -0
  589. data/ext/vendor/golang.org/x/net/trace/trace_go16.go +21 -0
  590. data/ext/vendor/golang.org/x/net/trace/trace_go17.go +21 -0
  591. data/ext/vendor/golang.org/x/net/trace/trace_test.go +178 -0
  592. data/ext/vendor/golang.org/x/net/webdav/file.go +796 -0
  593. data/ext/vendor/golang.org/x/net/webdav/file_go1.6.go +17 -0
  594. data/ext/vendor/golang.org/x/net/webdav/file_go1.7.go +16 -0
  595. data/ext/vendor/golang.org/x/net/webdav/file_test.go +1184 -0
  596. data/ext/vendor/golang.org/x/net/webdav/if.go +173 -0
  597. data/ext/vendor/golang.org/x/net/webdav/if_test.go +322 -0
  598. data/ext/vendor/golang.org/x/net/webdav/internal/xml/README +11 -0
  599. data/ext/vendor/golang.org/x/net/webdav/internal/xml/atom_test.go +56 -0
  600. data/ext/vendor/golang.org/x/net/webdav/internal/xml/example_test.go +151 -0
  601. data/ext/vendor/golang.org/x/net/webdav/internal/xml/marshal.go +1223 -0
  602. data/ext/vendor/golang.org/x/net/webdav/internal/xml/marshal_test.go +1939 -0
  603. data/ext/vendor/golang.org/x/net/webdav/internal/xml/read.go +692 -0
  604. data/ext/vendor/golang.org/x/net/webdav/internal/xml/read_test.go +744 -0
  605. data/ext/vendor/golang.org/x/net/webdav/internal/xml/typeinfo.go +371 -0
  606. data/ext/vendor/golang.org/x/net/webdav/internal/xml/xml.go +1998 -0
  607. data/ext/vendor/golang.org/x/net/webdav/internal/xml/xml_test.go +752 -0
  608. data/ext/vendor/golang.org/x/net/webdav/litmus_test_server.go +94 -0
  609. data/ext/vendor/golang.org/x/net/webdav/lock.go +445 -0
  610. data/ext/vendor/golang.org/x/net/webdav/lock_test.go +731 -0
  611. data/ext/vendor/golang.org/x/net/webdav/prop.go +418 -0
  612. data/ext/vendor/golang.org/x/net/webdav/prop_test.go +613 -0
  613. data/ext/vendor/golang.org/x/net/webdav/webdav.go +702 -0
  614. data/ext/vendor/golang.org/x/net/webdav/webdav_test.go +344 -0
  615. data/ext/vendor/golang.org/x/net/webdav/xml.go +519 -0
  616. data/ext/vendor/golang.org/x/net/webdav/xml_test.go +906 -0
  617. data/ext/vendor/golang.org/x/net/websocket/client.go +106 -0
  618. data/ext/vendor/golang.org/x/net/websocket/dial.go +24 -0
  619. data/ext/vendor/golang.org/x/net/websocket/dial_test.go +43 -0
  620. data/ext/vendor/golang.org/x/net/websocket/exampledial_test.go +31 -0
  621. data/ext/vendor/golang.org/x/net/websocket/examplehandler_test.go +26 -0
  622. data/ext/vendor/golang.org/x/net/websocket/hybi.go +583 -0
  623. data/ext/vendor/golang.org/x/net/websocket/hybi_test.go +608 -0
  624. data/ext/vendor/golang.org/x/net/websocket/server.go +113 -0
  625. data/ext/vendor/golang.org/x/net/websocket/websocket.go +448 -0
  626. data/ext/vendor/golang.org/x/net/websocket/websocket_test.go +665 -0
  627. data/ext/vendor/golang.org/x/net/xsrftoken/xsrf.go +94 -0
  628. data/ext/vendor/golang.org/x/net/xsrftoken/xsrf_test.go +83 -0
  629. data/ext/vendor/golang.org/x/text/AUTHORS +3 -0
  630. data/ext/vendor/golang.org/x/text/CONTRIBUTING.md +31 -0
  631. data/ext/vendor/golang.org/x/text/CONTRIBUTORS +3 -0
  632. data/ext/vendor/golang.org/x/text/LICENSE +27 -0
  633. data/ext/vendor/golang.org/x/text/PATENTS +22 -0
  634. data/ext/vendor/golang.org/x/text/README.md +91 -0
  635. data/ext/vendor/golang.org/x/text/cases/cases.go +162 -0
  636. data/ext/vendor/golang.org/x/text/cases/context.go +376 -0
  637. data/ext/vendor/golang.org/x/text/cases/context_test.go +438 -0
  638. data/ext/vendor/golang.org/x/text/cases/example_test.go +53 -0
  639. data/ext/vendor/golang.org/x/text/cases/fold.go +34 -0
  640. data/ext/vendor/golang.org/x/text/cases/fold_test.go +51 -0
  641. data/ext/vendor/golang.org/x/text/cases/gen.go +839 -0
  642. data/ext/vendor/golang.org/x/text/cases/gen_trieval.go +219 -0
  643. data/ext/vendor/golang.org/x/text/cases/icu.go +61 -0
  644. data/ext/vendor/golang.org/x/text/cases/icu_test.go +210 -0
  645. data/ext/vendor/golang.org/x/text/cases/info.go +82 -0
  646. data/ext/vendor/golang.org/x/text/cases/map.go +816 -0
  647. data/ext/vendor/golang.org/x/text/cases/map_test.go +950 -0
  648. data/ext/vendor/golang.org/x/text/cases/tables.go +2251 -0
  649. data/ext/vendor/golang.org/x/text/cases/tables_test.go +1158 -0
  650. data/ext/vendor/golang.org/x/text/cases/trieval.go +215 -0
  651. data/ext/vendor/golang.org/x/text/cmd/gotext/doc.go +35 -0
  652. data/ext/vendor/golang.org/x/text/cmd/gotext/extract.go +195 -0
  653. data/ext/vendor/golang.org/x/text/cmd/gotext/main.go +356 -0
  654. data/ext/vendor/golang.org/x/text/cmd/gotext/message.go +127 -0
  655. data/ext/vendor/golang.org/x/text/codereview.cfg +1 -0
  656. data/ext/vendor/golang.org/x/text/collate/build/builder.go +702 -0
  657. data/ext/vendor/golang.org/x/text/collate/build/builder_test.go +290 -0
  658. data/ext/vendor/golang.org/x/text/collate/build/colelem.go +294 -0
  659. data/ext/vendor/golang.org/x/text/collate/build/colelem_test.go +215 -0
  660. data/ext/vendor/golang.org/x/text/collate/build/contract.go +309 -0
  661. data/ext/vendor/golang.org/x/text/collate/build/contract_test.go +266 -0
  662. data/ext/vendor/golang.org/x/text/collate/build/order.go +393 -0
  663. data/ext/vendor/golang.org/x/text/collate/build/order_test.go +229 -0
  664. data/ext/vendor/golang.org/x/text/collate/build/table.go +81 -0
  665. data/ext/vendor/golang.org/x/text/collate/build/trie.go +290 -0
  666. data/ext/vendor/golang.org/x/text/collate/build/trie_test.go +107 -0
  667. data/ext/vendor/golang.org/x/text/collate/collate.go +403 -0
  668. data/ext/vendor/golang.org/x/text/collate/collate_test.go +482 -0
  669. data/ext/vendor/golang.org/x/text/collate/export_test.go +51 -0
  670. data/ext/vendor/golang.org/x/text/collate/index.go +32 -0
  671. data/ext/vendor/golang.org/x/text/collate/maketables.go +553 -0
  672. data/ext/vendor/golang.org/x/text/collate/option.go +239 -0
  673. data/ext/vendor/golang.org/x/text/collate/option_test.go +209 -0
  674. data/ext/vendor/golang.org/x/text/collate/reg_test.go +230 -0
  675. data/ext/vendor/golang.org/x/text/collate/sort.go +81 -0
  676. data/ext/vendor/golang.org/x/text/collate/sort_test.go +55 -0
  677. data/ext/vendor/golang.org/x/text/collate/table_test.go +291 -0
  678. data/ext/vendor/golang.org/x/text/collate/tables.go +73789 -0
  679. data/ext/vendor/golang.org/x/text/collate/tools/colcmp/Makefile +7 -0
  680. data/ext/vendor/golang.org/x/text/collate/tools/colcmp/chars.go +1156 -0
  681. data/ext/vendor/golang.org/x/text/collate/tools/colcmp/col.go +97 -0
  682. data/ext/vendor/golang.org/x/text/collate/tools/colcmp/colcmp.go +529 -0
  683. data/ext/vendor/golang.org/x/text/collate/tools/colcmp/darwin.go +111 -0
  684. data/ext/vendor/golang.org/x/text/collate/tools/colcmp/gen.go +183 -0
  685. data/ext/vendor/golang.org/x/text/collate/tools/colcmp/icu.go +209 -0
  686. data/ext/vendor/golang.org/x/text/currency/common.go +66 -0
  687. data/ext/vendor/golang.org/x/text/currency/currency.go +185 -0
  688. data/ext/vendor/golang.org/x/text/currency/currency_test.go +171 -0
  689. data/ext/vendor/golang.org/x/text/currency/example_test.go +27 -0
  690. data/ext/vendor/golang.org/x/text/currency/format.go +215 -0
  691. data/ext/vendor/golang.org/x/text/currency/format_test.go +70 -0
  692. data/ext/vendor/golang.org/x/text/currency/gen.go +400 -0
  693. data/ext/vendor/golang.org/x/text/currency/gen_common.go +70 -0
  694. data/ext/vendor/golang.org/x/text/currency/query.go +152 -0
  695. data/ext/vendor/golang.org/x/text/currency/query_test.go +107 -0
  696. data/ext/vendor/golang.org/x/text/currency/tables.go +2574 -0
  697. data/ext/vendor/golang.org/x/text/currency/tables_test.go +93 -0
  698. data/ext/vendor/golang.org/x/text/doc.go +13 -0
  699. data/ext/vendor/golang.org/x/text/encoding/charmap/charmap.go +249 -0
  700. data/ext/vendor/golang.org/x/text/encoding/charmap/charmap_test.go +258 -0
  701. data/ext/vendor/golang.org/x/text/encoding/charmap/maketables.go +556 -0
  702. data/ext/vendor/golang.org/x/text/encoding/charmap/tables.go +7410 -0
  703. data/ext/vendor/golang.org/x/text/encoding/encoding.go +335 -0
  704. data/ext/vendor/golang.org/x/text/encoding/encoding_test.go +290 -0
  705. data/ext/vendor/golang.org/x/text/encoding/example_test.go +42 -0
  706. data/ext/vendor/golang.org/x/text/encoding/htmlindex/gen.go +173 -0
  707. data/ext/vendor/golang.org/x/text/encoding/htmlindex/htmlindex.go +86 -0
  708. data/ext/vendor/golang.org/x/text/encoding/htmlindex/htmlindex_test.go +144 -0
  709. data/ext/vendor/golang.org/x/text/encoding/htmlindex/map.go +105 -0
  710. data/ext/vendor/golang.org/x/text/encoding/htmlindex/tables.go +352 -0
  711. data/ext/vendor/golang.org/x/text/encoding/ianaindex/example_test.go +27 -0
  712. data/ext/vendor/golang.org/x/text/encoding/ianaindex/gen.go +192 -0
  713. data/ext/vendor/golang.org/x/text/encoding/ianaindex/ianaindex.go +209 -0
  714. data/ext/vendor/golang.org/x/text/encoding/ianaindex/ianaindex_test.go +192 -0
  715. data/ext/vendor/golang.org/x/text/encoding/ianaindex/tables.go +2348 -0
  716. data/ext/vendor/golang.org/x/text/encoding/internal/enctest/enctest.go +180 -0
  717. data/ext/vendor/golang.org/x/text/encoding/internal/identifier/gen.go +137 -0
  718. data/ext/vendor/golang.org/x/text/encoding/internal/identifier/identifier.go +81 -0
  719. data/ext/vendor/golang.org/x/text/encoding/internal/identifier/mib.go +1621 -0
  720. data/ext/vendor/golang.org/x/text/encoding/internal/internal.go +75 -0
  721. data/ext/vendor/golang.org/x/text/encoding/japanese/all.go +12 -0
  722. data/ext/vendor/golang.org/x/text/encoding/japanese/all_test.go +248 -0
  723. data/ext/vendor/golang.org/x/text/encoding/japanese/eucjp.go +225 -0
  724. data/ext/vendor/golang.org/x/text/encoding/japanese/iso2022jp.go +299 -0
  725. data/ext/vendor/golang.org/x/text/encoding/japanese/maketables.go +161 -0
  726. data/ext/vendor/golang.org/x/text/encoding/japanese/shiftjis.go +189 -0
  727. data/ext/vendor/golang.org/x/text/encoding/japanese/tables.go +26971 -0
  728. data/ext/vendor/golang.org/x/text/encoding/korean/all_test.go +94 -0
  729. data/ext/vendor/golang.org/x/text/encoding/korean/euckr.go +177 -0
  730. data/ext/vendor/golang.org/x/text/encoding/korean/maketables.go +143 -0
  731. data/ext/vendor/golang.org/x/text/encoding/korean/tables.go +34152 -0
  732. data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/all.go +12 -0
  733. data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/all_test.go +143 -0
  734. data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/gbk.go +269 -0
  735. data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/hzgb2312.go +245 -0
  736. data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/maketables.go +161 -0
  737. data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/tables.go +43999 -0
  738. data/ext/vendor/golang.org/x/text/encoding/testdata/candide-gb18030.txt +510 -0
  739. data/ext/vendor/golang.org/x/text/encoding/testdata/candide-utf-16le.txt +0 -0
  740. data/ext/vendor/golang.org/x/text/encoding/testdata/candide-utf-32be.txt +0 -0
  741. data/ext/vendor/golang.org/x/text/encoding/testdata/candide-utf-8.txt +510 -0
  742. data/ext/vendor/golang.org/x/text/encoding/testdata/candide-windows-1252.txt +510 -0
  743. data/ext/vendor/golang.org/x/text/encoding/testdata/rashomon-euc-jp.txt +178 -0
  744. data/ext/vendor/golang.org/x/text/encoding/testdata/rashomon-iso-2022-jp.txt +178 -0
  745. data/ext/vendor/golang.org/x/text/encoding/testdata/rashomon-shift-jis.txt +178 -0
  746. data/ext/vendor/golang.org/x/text/encoding/testdata/rashomon-utf-8.txt +178 -0
  747. data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-gb-levels-1-and-2-hz-gb2312.txt +107 -0
  748. data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-gb-levels-1-and-2-utf-8.txt +107 -0
  749. data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-simplified-gbk.txt +107 -0
  750. data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-simplified-utf-8.txt +107 -0
  751. data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-traditional-big5.txt +106 -0
  752. data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-traditional-utf-8.txt +106 -0
  753. data/ext/vendor/golang.org/x/text/encoding/testdata/unsu-joh-eun-nal-euc-kr.txt +175 -0
  754. data/ext/vendor/golang.org/x/text/encoding/testdata/unsu-joh-eun-nal-utf-8.txt +175 -0
  755. data/ext/vendor/golang.org/x/text/encoding/traditionalchinese/all_test.go +114 -0
  756. data/ext/vendor/golang.org/x/text/encoding/traditionalchinese/big5.go +199 -0
  757. data/ext/vendor/golang.org/x/text/encoding/traditionalchinese/maketables.go +140 -0
  758. data/ext/vendor/golang.org/x/text/encoding/traditionalchinese/tables.go +37142 -0
  759. data/ext/vendor/golang.org/x/text/encoding/unicode/override.go +82 -0
  760. data/ext/vendor/golang.org/x/text/encoding/unicode/unicode.go +434 -0
  761. data/ext/vendor/golang.org/x/text/encoding/unicode/unicode_test.go +499 -0
  762. data/ext/vendor/golang.org/x/text/encoding/unicode/utf32/utf32.go +296 -0
  763. data/ext/vendor/golang.org/x/text/encoding/unicode/utf32/utf32_test.go +248 -0
  764. data/ext/vendor/golang.org/x/text/feature/plural/common.go +70 -0
  765. data/ext/vendor/golang.org/x/text/feature/plural/data_test.go +190 -0
  766. data/ext/vendor/golang.org/x/text/feature/plural/example_test.go +46 -0
  767. data/ext/vendor/golang.org/x/text/feature/plural/gen.go +513 -0
  768. data/ext/vendor/golang.org/x/text/feature/plural/gen_common.go +74 -0
  769. data/ext/vendor/golang.org/x/text/feature/plural/message.go +244 -0
  770. data/ext/vendor/golang.org/x/text/feature/plural/message_test.go +197 -0
  771. data/ext/vendor/golang.org/x/text/feature/plural/plural.go +258 -0
  772. data/ext/vendor/golang.org/x/text/feature/plural/plural_test.go +216 -0
  773. data/ext/vendor/golang.org/x/text/feature/plural/tables.go +540 -0
  774. data/ext/vendor/golang.org/x/text/gen.go +318 -0
  775. data/ext/vendor/golang.org/x/text/internal/catmsg/catmsg.go +366 -0
  776. data/ext/vendor/golang.org/x/text/internal/catmsg/catmsg_test.go +316 -0
  777. data/ext/vendor/golang.org/x/text/internal/catmsg/codec.go +407 -0
  778. data/ext/vendor/golang.org/x/text/internal/catmsg/varint.go +62 -0
  779. data/ext/vendor/golang.org/x/text/internal/catmsg/varint_test.go +123 -0
  780. data/ext/vendor/golang.org/x/text/internal/colltab/collate_test.go +121 -0
  781. data/ext/vendor/golang.org/x/text/internal/colltab/collelem.go +371 -0
  782. data/ext/vendor/golang.org/x/text/internal/colltab/collelem_test.go +183 -0
  783. data/ext/vendor/golang.org/x/text/internal/colltab/colltab.go +105 -0
  784. data/ext/vendor/golang.org/x/text/internal/colltab/colltab_test.go +64 -0
  785. data/ext/vendor/golang.org/x/text/internal/colltab/contract.go +145 -0
  786. data/ext/vendor/golang.org/x/text/internal/colltab/contract_test.go +131 -0
  787. data/ext/vendor/golang.org/x/text/internal/colltab/iter.go +178 -0
  788. data/ext/vendor/golang.org/x/text/internal/colltab/iter_test.go +63 -0
  789. data/ext/vendor/golang.org/x/text/internal/colltab/numeric.go +236 -0
  790. data/ext/vendor/golang.org/x/text/internal/colltab/numeric_test.go +159 -0
  791. data/ext/vendor/golang.org/x/text/internal/colltab/table.go +275 -0
  792. data/ext/vendor/golang.org/x/text/internal/colltab/trie.go +159 -0
  793. data/ext/vendor/golang.org/x/text/internal/colltab/trie_test.go +106 -0
  794. data/ext/vendor/golang.org/x/text/internal/colltab/weighter.go +31 -0
  795. data/ext/vendor/golang.org/x/text/internal/colltab/weighter_test.go +42 -0
  796. data/ext/vendor/golang.org/x/text/internal/export/README +4 -0
  797. data/ext/vendor/golang.org/x/text/internal/export/idna/common_test.go +55 -0
  798. data/ext/vendor/golang.org/x/text/internal/export/idna/example_test.go +68 -0
  799. data/ext/vendor/golang.org/x/text/internal/export/idna/gen.go +276 -0
  800. data/ext/vendor/golang.org/x/text/internal/export/idna/gen_common.go +59 -0
  801. data/ext/vendor/golang.org/x/text/internal/export/idna/gen_test.go +91 -0
  802. data/ext/vendor/golang.org/x/text/internal/export/idna/gen_trieval.go +123 -0
  803. data/ext/vendor/golang.org/x/text/internal/export/idna/idna.go +717 -0
  804. data/ext/vendor/golang.org/x/text/internal/export/idna/idna_test.go +308 -0
  805. data/ext/vendor/golang.org/x/text/internal/export/idna/punycode.go +201 -0
  806. data/ext/vendor/golang.org/x/text/internal/export/idna/punycode_test.go +198 -0
  807. data/ext/vendor/golang.org/x/text/internal/export/idna/tables.go +4557 -0
  808. data/ext/vendor/golang.org/x/text/internal/export/idna/trie.go +70 -0
  809. data/ext/vendor/golang.org/x/text/internal/export/idna/trieval.go +119 -0
  810. data/ext/vendor/golang.org/x/text/internal/format/format.go +41 -0
  811. data/ext/vendor/golang.org/x/text/internal/gen.go +52 -0
  812. data/ext/vendor/golang.org/x/text/internal/gen/code.go +351 -0
  813. data/ext/vendor/golang.org/x/text/internal/gen/gen.go +281 -0
  814. data/ext/vendor/golang.org/x/text/internal/gen_test.go +38 -0
  815. data/ext/vendor/golang.org/x/text/internal/internal.go +51 -0
  816. data/ext/vendor/golang.org/x/text/internal/internal_test.go +38 -0
  817. data/ext/vendor/golang.org/x/text/internal/match.go +67 -0
  818. data/ext/vendor/golang.org/x/text/internal/match_test.go +56 -0
  819. data/ext/vendor/golang.org/x/text/internal/number/common.go +40 -0
  820. data/ext/vendor/golang.org/x/text/internal/number/decimal.go +498 -0
  821. data/ext/vendor/golang.org/x/text/internal/number/decimal_test.go +329 -0
  822. data/ext/vendor/golang.org/x/text/internal/number/format.go +540 -0
  823. data/ext/vendor/golang.org/x/text/internal/number/format_test.go +522 -0
  824. data/ext/vendor/golang.org/x/text/internal/number/gen.go +458 -0
  825. data/ext/vendor/golang.org/x/text/internal/number/gen_common.go +44 -0
  826. data/ext/vendor/golang.org/x/text/internal/number/number.go +154 -0
  827. data/ext/vendor/golang.org/x/text/internal/number/number_test.go +100 -0
  828. data/ext/vendor/golang.org/x/text/internal/number/pattern.go +485 -0
  829. data/ext/vendor/golang.org/x/text/internal/number/pattern_test.go +438 -0
  830. data/ext/vendor/golang.org/x/text/internal/number/roundingmode_string.go +16 -0
  831. data/ext/vendor/golang.org/x/text/internal/number/tables.go +1154 -0
  832. data/ext/vendor/golang.org/x/text/internal/number/tables_test.go +125 -0
  833. data/ext/vendor/golang.org/x/text/internal/stringset/set.go +86 -0
  834. data/ext/vendor/golang.org/x/text/internal/stringset/set_test.go +53 -0
  835. data/ext/vendor/golang.org/x/text/internal/tables.go +117 -0
  836. data/ext/vendor/golang.org/x/text/internal/tag/tag.go +100 -0
  837. data/ext/vendor/golang.org/x/text/internal/tag/tag_test.go +67 -0
  838. data/ext/vendor/golang.org/x/text/internal/testtext/codesize.go +53 -0
  839. data/ext/vendor/golang.org/x/text/internal/testtext/flag.go +22 -0
  840. data/ext/vendor/golang.org/x/text/internal/testtext/gc.go +14 -0
  841. data/ext/vendor/golang.org/x/text/internal/testtext/gccgo.go +11 -0
  842. data/ext/vendor/golang.org/x/text/internal/testtext/go1_6.go +23 -0
  843. data/ext/vendor/golang.org/x/text/internal/testtext/go1_7.go +17 -0
  844. data/ext/vendor/golang.org/x/text/internal/testtext/text.go +105 -0
  845. data/ext/vendor/golang.org/x/text/internal/triegen/compact.go +58 -0
  846. data/ext/vendor/golang.org/x/text/internal/triegen/data_test.go +875 -0
  847. data/ext/vendor/golang.org/x/text/internal/triegen/example_compact_test.go +71 -0
  848. data/ext/vendor/golang.org/x/text/internal/triegen/example_test.go +148 -0
  849. data/ext/vendor/golang.org/x/text/internal/triegen/gen_test.go +68 -0
  850. data/ext/vendor/golang.org/x/text/internal/triegen/print.go +251 -0
  851. data/ext/vendor/golang.org/x/text/internal/triegen/triegen.go +494 -0
  852. data/ext/vendor/golang.org/x/text/internal/ucd/example_test.go +81 -0
  853. data/ext/vendor/golang.org/x/text/internal/ucd/ucd.go +371 -0
  854. data/ext/vendor/golang.org/x/text/internal/ucd/ucd_test.go +105 -0
  855. data/ext/vendor/golang.org/x/text/internal/utf8internal/utf8internal.go +87 -0
  856. data/ext/vendor/golang.org/x/text/language/Makefile +16 -0
  857. data/ext/vendor/golang.org/x/text/language/common.go +16 -0
  858. data/ext/vendor/golang.org/x/text/language/coverage.go +197 -0
  859. data/ext/vendor/golang.org/x/text/language/coverage_test.go +154 -0
  860. data/ext/vendor/golang.org/x/text/language/display/dict.go +92 -0
  861. data/ext/vendor/golang.org/x/text/language/display/dict_test.go +39 -0
  862. data/ext/vendor/golang.org/x/text/language/display/display.go +420 -0
  863. data/ext/vendor/golang.org/x/text/language/display/display_test.go +705 -0
  864. data/ext/vendor/golang.org/x/text/language/display/examples_test.go +116 -0
  865. data/ext/vendor/golang.org/x/text/language/display/lookup.go +251 -0
  866. data/ext/vendor/golang.org/x/text/language/display/maketables.go +602 -0
  867. data/ext/vendor/golang.org/x/text/language/display/tables.go +50344 -0
  868. data/ext/vendor/golang.org/x/text/language/doc.go +102 -0
  869. data/ext/vendor/golang.org/x/text/language/examples_test.go +413 -0
  870. data/ext/vendor/golang.org/x/text/language/gen.go +1706 -0
  871. data/ext/vendor/golang.org/x/text/language/gen_common.go +20 -0
  872. data/ext/vendor/golang.org/x/text/language/gen_index.go +162 -0
  873. data/ext/vendor/golang.org/x/text/language/go1_1.go +38 -0
  874. data/ext/vendor/golang.org/x/text/language/go1_2.go +11 -0
  875. data/ext/vendor/golang.org/x/text/language/httpexample_test.go +48 -0
  876. data/ext/vendor/golang.org/x/text/language/index.go +769 -0
  877. data/ext/vendor/golang.org/x/text/language/language.go +887 -0
  878. data/ext/vendor/golang.org/x/text/language/language_test.go +878 -0
  879. data/ext/vendor/golang.org/x/text/language/lookup.go +396 -0
  880. data/ext/vendor/golang.org/x/text/language/lookup_test.go +457 -0
  881. data/ext/vendor/golang.org/x/text/language/match.go +933 -0
  882. data/ext/vendor/golang.org/x/text/language/match_test.go +505 -0
  883. data/ext/vendor/golang.org/x/text/language/parse.go +859 -0
  884. data/ext/vendor/golang.org/x/text/language/parse_test.go +517 -0
  885. data/ext/vendor/golang.org/x/text/language/tables.go +3675 -0
  886. data/ext/vendor/golang.org/x/text/language/tags.go +143 -0
  887. data/ext/vendor/golang.org/x/text/language/testdata/CLDRLocaleMatcherTest.txt +389 -0
  888. data/ext/vendor/golang.org/x/text/language/testdata/GoLocaleMatcherTest.txt +226 -0
  889. data/ext/vendor/golang.org/x/text/message/catalog.go +28 -0
  890. data/ext/vendor/golang.org/x/text/message/catalog/catalog.go +292 -0
  891. data/ext/vendor/golang.org/x/text/message/catalog/catalog_test.go +194 -0
  892. data/ext/vendor/golang.org/x/text/message/catalog/dict.go +90 -0
  893. data/ext/vendor/golang.org/x/text/message/doc.go +100 -0
  894. data/ext/vendor/golang.org/x/text/message/examples_test.go +42 -0
  895. data/ext/vendor/golang.org/x/text/message/fmt_test.go +1889 -0
  896. data/ext/vendor/golang.org/x/text/message/format.go +532 -0
  897. data/ext/vendor/golang.org/x/text/message/message.go +169 -0
  898. data/ext/vendor/golang.org/x/text/message/message_test.go +181 -0
  899. data/ext/vendor/golang.org/x/text/message/print.go +1194 -0
  900. data/ext/vendor/golang.org/x/text/number/doc.go +28 -0
  901. data/ext/vendor/golang.org/x/text/number/examples_test.go +28 -0
  902. data/ext/vendor/golang.org/x/text/number/format.go +122 -0
  903. data/ext/vendor/golang.org/x/text/number/format_test.go +107 -0
  904. data/ext/vendor/golang.org/x/text/number/number.go +77 -0
  905. data/ext/vendor/golang.org/x/text/number/number_test.go +190 -0
  906. data/ext/vendor/golang.org/x/text/number/option.go +177 -0
  907. data/ext/vendor/golang.org/x/text/runes/cond.go +187 -0
  908. data/ext/vendor/golang.org/x/text/runes/cond_test.go +282 -0
  909. data/ext/vendor/golang.org/x/text/runes/example_test.go +60 -0
  910. data/ext/vendor/golang.org/x/text/runes/runes.go +355 -0
  911. data/ext/vendor/golang.org/x/text/runes/runes_test.go +664 -0
  912. data/ext/vendor/golang.org/x/text/search/index.go +35 -0
  913. data/ext/vendor/golang.org/x/text/search/pattern.go +155 -0
  914. data/ext/vendor/golang.org/x/text/search/pattern_test.go +357 -0
  915. data/ext/vendor/golang.org/x/text/search/search.go +237 -0
  916. data/ext/vendor/golang.org/x/text/search/tables.go +12448 -0
  917. data/ext/vendor/golang.org/x/text/secure/bidirule/bench_test.go +54 -0
  918. data/ext/vendor/golang.org/x/text/secure/bidirule/bidirule.go +340 -0
  919. data/ext/vendor/golang.org/x/text/secure/bidirule/bidirule_test.go +851 -0
  920. data/ext/vendor/golang.org/x/text/secure/doc.go +6 -0
  921. data/ext/vendor/golang.org/x/text/secure/precis/benchmark_test.go +82 -0
  922. data/ext/vendor/golang.org/x/text/secure/precis/class.go +36 -0
  923. data/ext/vendor/golang.org/x/text/secure/precis/class_test.go +50 -0
  924. data/ext/vendor/golang.org/x/text/secure/precis/context.go +139 -0
  925. data/ext/vendor/golang.org/x/text/secure/precis/doc.go +14 -0
  926. data/ext/vendor/golang.org/x/text/secure/precis/enforce_test.go +396 -0
  927. data/ext/vendor/golang.org/x/text/secure/precis/gen.go +310 -0
  928. data/ext/vendor/golang.org/x/text/secure/precis/gen_trieval.go +68 -0
  929. data/ext/vendor/golang.org/x/text/secure/precis/nickname.go +72 -0
  930. data/ext/vendor/golang.org/x/text/secure/precis/options.go +157 -0
  931. data/ext/vendor/golang.org/x/text/secure/precis/profile.go +402 -0
  932. data/ext/vendor/golang.org/x/text/secure/precis/profile_test.go +149 -0
  933. data/ext/vendor/golang.org/x/text/secure/precis/profiles.go +78 -0
  934. data/ext/vendor/golang.org/x/text/secure/precis/tables.go +3887 -0
  935. data/ext/vendor/golang.org/x/text/secure/precis/tables_test.go +69 -0
  936. data/ext/vendor/golang.org/x/text/secure/precis/transformer.go +32 -0
  937. data/ext/vendor/golang.org/x/text/secure/precis/trieval.go +64 -0
  938. data/ext/vendor/golang.org/x/text/transform/examples_test.go +37 -0
  939. data/ext/vendor/golang.org/x/text/transform/transform.go +705 -0
  940. data/ext/vendor/golang.org/x/text/transform/transform_test.go +1317 -0
  941. data/ext/vendor/golang.org/x/text/unicode/bidi/bidi.go +198 -0
  942. data/ext/vendor/golang.org/x/text/unicode/bidi/bracket.go +335 -0
  943. data/ext/vendor/golang.org/x/text/unicode/bidi/core.go +1058 -0
  944. data/ext/vendor/golang.org/x/text/unicode/bidi/core_test.go +224 -0
  945. data/ext/vendor/golang.org/x/text/unicode/bidi/gen.go +133 -0
  946. data/ext/vendor/golang.org/x/text/unicode/bidi/gen_ranges.go +57 -0
  947. data/ext/vendor/golang.org/x/text/unicode/bidi/gen_trieval.go +64 -0
  948. data/ext/vendor/golang.org/x/text/unicode/bidi/prop.go +206 -0
  949. data/ext/vendor/golang.org/x/text/unicode/bidi/ranges_test.go +53 -0
  950. data/ext/vendor/golang.org/x/text/unicode/bidi/tables.go +1813 -0
  951. data/ext/vendor/golang.org/x/text/unicode/bidi/tables_test.go +82 -0
  952. data/ext/vendor/golang.org/x/text/unicode/bidi/trieval.go +60 -0
  953. data/ext/vendor/golang.org/x/text/unicode/cldr/base.go +100 -0
  954. data/ext/vendor/golang.org/x/text/unicode/cldr/cldr.go +130 -0
  955. data/ext/vendor/golang.org/x/text/unicode/cldr/cldr_test.go +27 -0
  956. data/ext/vendor/golang.org/x/text/unicode/cldr/collate.go +359 -0
  957. data/ext/vendor/golang.org/x/text/unicode/cldr/collate_test.go +275 -0
  958. data/ext/vendor/golang.org/x/text/unicode/cldr/data_test.go +186 -0
  959. data/ext/vendor/golang.org/x/text/unicode/cldr/decode.go +171 -0
  960. data/ext/vendor/golang.org/x/text/unicode/cldr/examples_test.go +21 -0
  961. data/ext/vendor/golang.org/x/text/unicode/cldr/makexml.go +400 -0
  962. data/ext/vendor/golang.org/x/text/unicode/cldr/resolve.go +602 -0
  963. data/ext/vendor/golang.org/x/text/unicode/cldr/resolve_test.go +368 -0
  964. data/ext/vendor/golang.org/x/text/unicode/cldr/slice.go +144 -0
  965. data/ext/vendor/golang.org/x/text/unicode/cldr/slice_test.go +175 -0
  966. data/ext/vendor/golang.org/x/text/unicode/cldr/xml.go +1487 -0
  967. data/ext/vendor/golang.org/x/text/unicode/doc.go +8 -0
  968. data/ext/vendor/golang.org/x/text/unicode/norm/composition.go +508 -0
  969. data/ext/vendor/golang.org/x/text/unicode/norm/composition_test.go +130 -0
  970. data/ext/vendor/golang.org/x/text/unicode/norm/example_iter_test.go +82 -0
  971. data/ext/vendor/golang.org/x/text/unicode/norm/example_test.go +27 -0
  972. data/ext/vendor/golang.org/x/text/unicode/norm/forminfo.go +259 -0
  973. data/ext/vendor/golang.org/x/text/unicode/norm/forminfo_test.go +54 -0
  974. data/ext/vendor/golang.org/x/text/unicode/norm/input.go +109 -0
  975. data/ext/vendor/golang.org/x/text/unicode/norm/iter.go +457 -0
  976. data/ext/vendor/golang.org/x/text/unicode/norm/iter_test.go +98 -0
  977. data/ext/vendor/golang.org/x/text/unicode/norm/maketables.go +976 -0
  978. data/ext/vendor/golang.org/x/text/unicode/norm/norm_test.go +14 -0
  979. data/ext/vendor/golang.org/x/text/unicode/norm/normalize.go +609 -0
  980. data/ext/vendor/golang.org/x/text/unicode/norm/normalize_test.go +1287 -0
  981. data/ext/vendor/golang.org/x/text/unicode/norm/readwriter.go +125 -0
  982. data/ext/vendor/golang.org/x/text/unicode/norm/readwriter_test.go +56 -0
  983. data/ext/vendor/golang.org/x/text/unicode/norm/tables.go +7651 -0
  984. data/ext/vendor/golang.org/x/text/unicode/norm/transform.go +88 -0
  985. data/ext/vendor/golang.org/x/text/unicode/norm/transform_test.go +101 -0
  986. data/ext/vendor/golang.org/x/text/unicode/norm/trie.go +54 -0
  987. data/ext/vendor/golang.org/x/text/unicode/norm/triegen.go +117 -0
  988. data/ext/vendor/golang.org/x/text/unicode/norm/ucd_test.go +275 -0
  989. data/ext/vendor/golang.org/x/text/unicode/rangetable/gen.go +115 -0
  990. data/ext/vendor/golang.org/x/text/unicode/rangetable/merge.go +260 -0
  991. data/ext/vendor/golang.org/x/text/unicode/rangetable/merge_test.go +184 -0
  992. data/ext/vendor/golang.org/x/text/unicode/rangetable/rangetable.go +70 -0
  993. data/ext/vendor/golang.org/x/text/unicode/rangetable/rangetable_test.go +55 -0
  994. data/ext/vendor/golang.org/x/text/unicode/rangetable/tables.go +6376 -0
  995. data/ext/vendor/golang.org/x/text/unicode/runenames/bits.go +59 -0
  996. data/ext/vendor/golang.org/x/text/unicode/runenames/example_test.go +118 -0
  997. data/ext/vendor/golang.org/x/text/unicode/runenames/gen.go +195 -0
  998. data/ext/vendor/golang.org/x/text/unicode/runenames/gen_bits.go +63 -0
  999. data/ext/vendor/golang.org/x/text/unicode/runenames/runenames.go +48 -0
  1000. data/ext/vendor/golang.org/x/text/unicode/runenames/runenames_test.go +46 -0
  1001. data/ext/vendor/golang.org/x/text/unicode/runenames/tables.go +15514 -0
  1002. data/ext/vendor/golang.org/x/text/width/common_test.go +92 -0
  1003. data/ext/vendor/golang.org/x/text/width/example_test.go +52 -0
  1004. data/ext/vendor/golang.org/x/text/width/gen.go +115 -0
  1005. data/ext/vendor/golang.org/x/text/width/gen_common.go +96 -0
  1006. data/ext/vendor/golang.org/x/text/width/gen_trieval.go +34 -0
  1007. data/ext/vendor/golang.org/x/text/width/kind_string.go +16 -0
  1008. data/ext/vendor/golang.org/x/text/width/runes_test.go +461 -0
  1009. data/ext/vendor/golang.org/x/text/width/tables.go +1316 -0
  1010. data/ext/vendor/golang.org/x/text/width/tables_test.go +59 -0
  1011. data/ext/vendor/golang.org/x/text/width/transform.go +239 -0
  1012. data/ext/vendor/golang.org/x/text/width/transform_test.go +701 -0
  1013. data/ext/vendor/golang.org/x/text/width/trieval.go +30 -0
  1014. data/ext/vendor/golang.org/x/text/width/width.go +206 -0
  1015. data/lib/ires/version.rb +1 -1
  1016. data/shared/darwin/ires.so +0 -0
  1017. data/shared/linux/ires.so +0 -0
  1018. metadata +1011 -23
  1019. data/ext/operate/image.go +0 -176
  1020. data/ext/util/uri/uri.go +0 -105
  1021. data/ext/vendor/github.com/satori/go.uuid/README.md +0 -65
  1022. data/ext/vendor/github.com/satori/go.uuid/benchmarks_test.go +0 -121
  1023. data/ext/vendor/github.com/satori/go.uuid/uuid.go +0 -488
  1024. data/ext/vendor/github.com/satori/go.uuid/uuid_test.go +0 -633
@@ -0,0 +1,194 @@
1
+ // Copyright 2017 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 catalog
6
+
7
+ import (
8
+ "bytes"
9
+ "fmt"
10
+ "reflect"
11
+ "testing"
12
+
13
+ "golang.org/x/text/internal"
14
+ "golang.org/x/text/internal/catmsg"
15
+ "golang.org/x/text/language"
16
+ )
17
+
18
+ type entry struct {
19
+ tag, key string
20
+ msg interface{}
21
+ }
22
+
23
+ var testCases = []struct {
24
+ desc string
25
+ cat []entry
26
+ lookup []entry
27
+ }{{
28
+ desc: "empty catalog",
29
+ lookup: []entry{
30
+ {"en", "key", ""},
31
+ {"en", "", ""},
32
+ {"nl", "", ""},
33
+ },
34
+ }, {
35
+ desc: "one entry",
36
+ cat: []entry{
37
+ {"en", "hello", "Hello!"},
38
+ },
39
+ lookup: []entry{
40
+ {"und", "hello", ""},
41
+ {"nl", "hello", ""},
42
+ {"en", "hello", "Hello!"},
43
+ {"en-US", "hello", "Hello!"},
44
+ {"en-GB", "hello", "Hello!"},
45
+ {"en-oxendict", "hello", "Hello!"},
46
+ {"en-oxendict-u-ms-metric", "hello", "Hello!"},
47
+ },
48
+ }, {
49
+ desc: "hierarchical languages",
50
+ cat: []entry{
51
+ {"en", "hello", "Hello!"},
52
+ {"en-GB", "hello", "Hellø!"},
53
+ {"en-US", "hello", "Howdy!"},
54
+ {"en", "greetings", "Greetings!"},
55
+ },
56
+ lookup: []entry{
57
+ {"und", "hello", ""},
58
+ {"nl", "hello", ""},
59
+ {"en", "hello", "Hello!"},
60
+ {"en-US", "hello", "Howdy!"},
61
+ {"en-GB", "hello", "Hellø!"},
62
+ {"en-oxendict", "hello", "Hello!"},
63
+ {"en-US-oxendict-u-ms-metric", "hello", "Howdy!"},
64
+
65
+ {"und", "greetings", ""},
66
+ {"nl", "greetings", ""},
67
+ {"en", "greetings", "Greetings!"},
68
+ {"en-US", "greetings", "Greetings!"},
69
+ {"en-GB", "greetings", "Greetings!"},
70
+ {"en-oxendict", "greetings", "Greetings!"},
71
+ {"en-US-oxendict-u-ms-metric", "greetings", "Greetings!"},
72
+ },
73
+ }, {
74
+ desc: "variables",
75
+ cat: []entry{
76
+ {"en", "hello %s", []Message{
77
+ Var("person", String("Jane")),
78
+ String("Hello ${person}!"),
79
+ }},
80
+ {"en", "hello error", []Message{
81
+ Var("person", String("Jane")),
82
+ noMatchMessage{}, // trigger sequence path.
83
+ String("Hello ${person."),
84
+ }},
85
+ {"en", "fallback to var value", []Message{
86
+ Var("you", noMatchMessage{}, noMatchMessage{}),
87
+ String("Hello ${you}."),
88
+ }},
89
+ {"en", "scopes", []Message{
90
+ Var("person1", String("Mark")),
91
+ Var("person2", String("Jane")),
92
+ Var("couple",
93
+ Var("person1", String("Joe")),
94
+ String("${person1} and ${person2}")),
95
+ String("Hello ${couple}."),
96
+ }},
97
+ {"en", "missing var", String("Hello ${missing}.")},
98
+ },
99
+ lookup: []entry{
100
+ {"en", "hello %s", "Hello Jane!"},
101
+ {"en", "hello error", "Hello $!(MISSINGBRACE)"},
102
+ {"en", "fallback to var value", "Hello you."},
103
+ {"en", "scopes", "Hello Joe and Jane."},
104
+ {"en", "missing var", "Hello missing."},
105
+ },
106
+ }, {
107
+ desc: "macros",
108
+ cat: []entry{
109
+ {"en", "macro1", String("Hello ${macro1(1)}.")},
110
+ {"en", "macro2", String("Hello ${ macro1(2) }!")},
111
+ {"en", "macroWS", String("Hello ${ macro1( 2 ) }!")},
112
+ {"en", "missing", String("Hello ${ missing(1 }.")},
113
+ {"en", "badnum", String("Hello ${ badnum(1b) }.")},
114
+ {"en", "undefined", String("Hello ${ undefined(1) }.")},
115
+ {"en", "macroU", String("Hello ${ macroU(2) }!")},
116
+ },
117
+ lookup: []entry{
118
+ {"en", "macro1", "Hello Joe."},
119
+ {"en", "macro2", "Hello Joe!"},
120
+ {"en-US", "macroWS", "Hello Joe!"},
121
+ {"en-NL", "missing", "Hello $!(MISSINGPAREN)."},
122
+ {"en", "badnum", "Hello $!(BADNUM)."},
123
+ {"en", "undefined", "Hello undefined."},
124
+ {"en", "macroU", "Hello macroU!"},
125
+ }}}
126
+
127
+ func initCat(entries []entry) (*Catalog, []language.Tag) {
128
+ tags := []language.Tag{}
129
+ cat := New()
130
+ for _, e := range entries {
131
+ tag := language.MustParse(e.tag)
132
+ tags = append(tags, tag)
133
+ switch msg := e.msg.(type) {
134
+ case string:
135
+ cat.SetString(tag, e.key, msg)
136
+ case Message:
137
+ cat.Set(tag, e.key, msg)
138
+ case []Message:
139
+ cat.Set(tag, e.key, msg...)
140
+ }
141
+ }
142
+ return cat, internal.UniqueTags(tags)
143
+ }
144
+
145
+ func TestCatalog(t *testing.T) {
146
+ for _, tc := range testCases {
147
+ t.Run(fmt.Sprintf("%s", tc.desc), func(t *testing.T) {
148
+ cat, wantTags := initCat(tc.cat)
149
+ cat.SetMacro(language.English, "macro1", String("Joe"))
150
+ cat.SetMacro(language.Und, "macro2", String("${macro1(1)}"))
151
+ cat.SetMacro(language.English, "macroU", noMatchMessage{})
152
+
153
+ if got := cat.Languages(); !reflect.DeepEqual(got, wantTags) {
154
+ t.Errorf("%s:Languages: got %v; want %v", tc.desc, got, wantTags)
155
+ }
156
+
157
+ for _, e := range tc.lookup {
158
+ t.Run(fmt.Sprintf("%s/%s", e.tag, e.key), func(t *testing.T) {
159
+ tag := language.MustParse(e.tag)
160
+ buf := testRenderer{}
161
+ ctx := cat.Context(tag, &buf)
162
+ want := e.msg.(string)
163
+ err := ctx.Execute(e.key)
164
+ gotFound := err != ErrNotFound
165
+ wantFound := want != ""
166
+ if gotFound != wantFound {
167
+ t.Fatalf("err: got %v (%v); want %v", gotFound, err, wantFound)
168
+ }
169
+ if got := buf.buf.String(); got != want {
170
+ t.Errorf("Lookup:\ngot %q\nwant %q", got, want)
171
+ }
172
+ })
173
+ }
174
+ })
175
+ }
176
+ }
177
+
178
+ type testRenderer struct {
179
+ buf bytes.Buffer
180
+ }
181
+
182
+ func (f *testRenderer) Arg(i int) interface{} { return nil }
183
+ func (f *testRenderer) Render(s string) { f.buf.WriteString(s) }
184
+
185
+ var msgNoMatch = catmsg.Register("no match", func(d *catmsg.Decoder) bool {
186
+ return false // no match
187
+ })
188
+
189
+ type noMatchMessage struct{}
190
+
191
+ func (noMatchMessage) Compile(e *catmsg.Encoder) error {
192
+ e.EncodeMessageType(msgNoMatch)
193
+ return catmsg.ErrIncomplete
194
+ }
@@ -0,0 +1,90 @@
1
+ // Copyright 2017 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 catalog
6
+
7
+ import (
8
+ "sync"
9
+
10
+ "golang.org/x/text/internal"
11
+ "golang.org/x/text/internal/catmsg"
12
+ "golang.org/x/text/language"
13
+ )
14
+
15
+ // TODO:
16
+ // Dictionary returns a Dictionary that returns the first Message, using the
17
+ // given language tag, that matches:
18
+ // 1. the last one registered by one of the Set methods
19
+ // 2. returned by one of the Loaders
20
+ // 3. repeat from 1. using the parent language
21
+ // This approach allows messages to be underspecified.
22
+ // func (c *Catalog) Dictionary(tag language.Tag) (Dictionary, error) {
23
+ // // TODO: verify dictionary exists.
24
+ // return &dict{&c.index, tag}, nil
25
+ // }
26
+
27
+ type dict struct {
28
+ s *store
29
+ tag language.Tag // TODO: make compact tag.
30
+ }
31
+
32
+ func (d *dict) Lookup(key string) (data string, ok bool) {
33
+ return d.s.lookup(d.tag, key)
34
+ }
35
+
36
+ func (c *Catalog) set(tag language.Tag, key string, s *store, msg ...Message) error {
37
+ data, err := catmsg.Compile(tag, &dict{&c.macros, tag}, firstInSequence(msg))
38
+
39
+ s.mutex.Lock()
40
+ defer s.mutex.Unlock()
41
+
42
+ m := s.index[tag]
43
+ if m == nil {
44
+ m = msgMap{}
45
+ if s.index == nil {
46
+ s.index = map[language.Tag]msgMap{}
47
+ }
48
+ s.index[tag] = m
49
+ }
50
+
51
+ m[key] = data
52
+ return err
53
+ }
54
+
55
+ type store struct {
56
+ mutex sync.RWMutex
57
+ index map[language.Tag]msgMap
58
+ }
59
+
60
+ type msgMap map[string]string
61
+
62
+ func (s *store) lookup(tag language.Tag, key string) (data string, ok bool) {
63
+ s.mutex.RLock()
64
+ defer s.mutex.RUnlock()
65
+
66
+ for ; ; tag = tag.Parent() {
67
+ if msgs, ok := s.index[tag]; ok {
68
+ if msg, ok := msgs[key]; ok {
69
+ return msg, true
70
+ }
71
+ }
72
+ if tag == language.Und {
73
+ break
74
+ }
75
+ }
76
+ return "", false
77
+ }
78
+
79
+ // Languages returns all languages for which the store contains variants.
80
+ func (s *store) languages() []language.Tag {
81
+ s.mutex.RLock()
82
+ defer s.mutex.RUnlock()
83
+
84
+ tags := make([]language.Tag, 0, len(s.index))
85
+ for t := range s.index {
86
+ tags = append(tags, t)
87
+ }
88
+ internal.SortTags(tags)
89
+ return tags
90
+ }
@@ -0,0 +1,100 @@
1
+ // Copyright 2017 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 message implements formatted I/O for localized strings with functions
6
+ // analogous to the fmt's print functions. It is a drop-in replacement for fmt.
7
+ //
8
+ //
9
+ // Localized Formatting
10
+ //
11
+ // A format string can be localized by replacing any of the print functions of
12
+ // fmt with an equivalent call to a Printer.
13
+ //
14
+ // p := message.NewPrinter(language.English)
15
+ // p.Println(123456.78) // Prints 123,456.78
16
+ //
17
+ // p.Printf("%d ducks in a row", 4331) // Prints 4,331 ducks in a row
18
+ //
19
+ // p := message.NewPrinter(language.Dutch)
20
+ // p.Println("Hoogte: %f meter", 1244.9) // Prints Hoogte: 1.244,9 meter
21
+ //
22
+ // p := message.NewPrinter(language.Bengali)
23
+ // p.Println(123456.78) // Prints ১,২৩,৪৫৬.৭৮
24
+ //
25
+ // Printer currently supports numbers and specialized types for which packages
26
+ // exist in x/text. Other builtin types such as time.Time and slices are
27
+ // planned.
28
+ //
29
+ // Format strings largely have the same meaning as with fmt with the following
30
+ // notable exceptions:
31
+ // - flag # always resorts to fmt for printing
32
+ // - verb 'f', 'e', 'g', 'd' use localized formatting unless the '#' flag is
33
+ // specified.
34
+ //
35
+ // See package fmt for more options.
36
+ //
37
+ //
38
+ // Translation
39
+ //
40
+ // The format strings that are passed to Printf, Sprintf, Fprintf, or Errorf
41
+ // are used as keys to look up translations for the specified languages.
42
+ // More on how these need to be specified below.
43
+ //
44
+ // One can use arbitrary keys to distinguish between otherwise ambiguous
45
+ // strings:
46
+ // p := message.NewPrinter(language.English)
47
+ // p.Printf("archive(noun)") // Prints "archive"
48
+ // p.Printf("archive(verb)") // Prints "archive"
49
+ //
50
+ // p := message.NewPrinter(language.German)
51
+ // p.Printf("archive(noun)") // Prints "Archiv"
52
+ // p.Printf("archive(verb)") // Prints "archivieren"
53
+ //
54
+ // To retain the fallback functionality, use Key:
55
+ // p.Printf(message.Key("archive(noun)", "archive"))
56
+ // p.Printf(message.Key("archive(verb)", "archive"))
57
+ //
58
+ //
59
+ // Translation Pipeline
60
+ //
61
+ // Format strings that contain text need to be translated to support different
62
+ // locales. The first step is to extract strings that need to be translated.
63
+ //
64
+ // 1. Install gotext
65
+ // go get -u golang.org/x/text/cmd/gotext
66
+ // gotext -help
67
+ //
68
+ // 2. Mark strings in your source to be translated by using message.Printer,
69
+ // instead of the functions of the fmt package.
70
+ //
71
+ // 3. Extract the strings from your source
72
+ //
73
+ // gotext extract
74
+ //
75
+ // The output will be written to the textdata directory.
76
+ //
77
+ // 4. Send the files for translation
78
+ //
79
+ // It is planned to support multiple formats, but for now one will have to
80
+ // rewrite the JSON output to the desired format.
81
+ //
82
+ // 5. Inject translations into program
83
+ //
84
+ // 6. Repeat from 2
85
+ //
86
+ // Right now this has to be done programmatically with calls to Set or
87
+ // SetString. These functions as well as the methods defined in
88
+ // see also package golang.org/x/text/message/catalog can be used to implement
89
+ // either dynamic or static loading of messages.
90
+ //
91
+ //
92
+ // Plural and Gender Forms
93
+ //
94
+ // Translated messages can vary based on the plural and gender forms of
95
+ // substitution values. In general, it is up to the translators to provide
96
+ // alternative translations for such forms. See the packages in
97
+ // golang.org/x/text/feature and golang.org/x/text/message/catalog for more
98
+ // information.
99
+ //
100
+ package message
@@ -0,0 +1,42 @@
1
+ // Copyright 2017 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 message_test
6
+
7
+ import (
8
+ "net/http"
9
+
10
+ "golang.org/x/text/language"
11
+ "golang.org/x/text/message"
12
+ )
13
+
14
+ func Example_http() {
15
+ // languages supported by this service:
16
+ matcher := language.NewMatcher(message.DefaultCatalog.Languages())
17
+
18
+ http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
19
+ lang, _ := r.Cookie("lang")
20
+ accept := r.Header.Get("Accept-Language")
21
+ fallback := "en"
22
+ tag, _ := language.MatchStrings(matcher, lang.String(), accept, fallback)
23
+
24
+ p := message.NewPrinter(tag)
25
+
26
+ p.Fprintln(w, "User language is", tag)
27
+ })
28
+ }
29
+
30
+ func ExamplePrinter_numbers() {
31
+ for _, lang := range []string{"en", "de", "de-CH", "fr", "bn"} {
32
+ p := message.NewPrinter(language.Make(lang))
33
+ p.Printf("%-6s %g\n", lang, 123456.78)
34
+ }
35
+
36
+ // Output:
37
+ // en 123,456.78
38
+ // de 123.456,78
39
+ // de-CH 123’456.78
40
+ // fr 123 456,78
41
+ // bn ১,২৩,৪৫৬.৭৮
42
+ }
@@ -0,0 +1,1889 @@
1
+ // Copyright 2017 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 message
6
+
7
+ import (
8
+ "bytes"
9
+ "fmt"
10
+ "io"
11
+ "math"
12
+ "reflect"
13
+ "runtime"
14
+ "strings"
15
+ "testing"
16
+ "time"
17
+
18
+ "golang.org/x/text/language"
19
+ )
20
+
21
+ type (
22
+ renamedBool bool
23
+ renamedInt int
24
+ renamedInt8 int8
25
+ renamedInt16 int16
26
+ renamedInt32 int32
27
+ renamedInt64 int64
28
+ renamedUint uint
29
+ renamedUint8 uint8
30
+ renamedUint16 uint16
31
+ renamedUint32 uint32
32
+ renamedUint64 uint64
33
+ renamedUintptr uintptr
34
+ renamedString string
35
+ renamedBytes []byte
36
+ renamedFloat32 float32
37
+ renamedFloat64 float64
38
+ renamedComplex64 complex64
39
+ renamedComplex128 complex128
40
+ )
41
+
42
+ func TestFmtInterface(t *testing.T) {
43
+ p := NewPrinter(language.Und)
44
+ var i1 interface{}
45
+ i1 = "abc"
46
+ s := p.Sprintf("%s", i1)
47
+ if s != "abc" {
48
+ t.Errorf(`Sprintf("%%s", empty("abc")) = %q want %q`, s, "abc")
49
+ }
50
+ }
51
+
52
+ var (
53
+ NaN = math.NaN()
54
+ posInf = math.Inf(1)
55
+ negInf = math.Inf(-1)
56
+
57
+ intVar = 0
58
+
59
+ array = [5]int{1, 2, 3, 4, 5}
60
+ iarray = [4]interface{}{1, "hello", 2.5, nil}
61
+ slice = array[:]
62
+ islice = iarray[:]
63
+ )
64
+
65
+ type A struct {
66
+ i int
67
+ j uint
68
+ s string
69
+ x []int
70
+ }
71
+
72
+ type I int
73
+
74
+ func (i I) String() string {
75
+ p := NewPrinter(language.Und)
76
+ return p.Sprintf("<%d>", int(i))
77
+ }
78
+
79
+ type B struct {
80
+ I I
81
+ j int
82
+ }
83
+
84
+ type C struct {
85
+ i int
86
+ B
87
+ }
88
+
89
+ type F int
90
+
91
+ func (f F) Format(s fmt.State, c rune) {
92
+ p := NewPrinter(language.Und)
93
+ p.Fprintf(s, "<%c=F(%d)>", c, int(f))
94
+ }
95
+
96
+ type G int
97
+
98
+ func (g G) GoString() string {
99
+ p := NewPrinter(language.Und)
100
+ return p.Sprintf("GoString(%d)", int(g))
101
+ }
102
+
103
+ type S struct {
104
+ F F // a struct field that Formats
105
+ G G // a struct field that GoStrings
106
+ }
107
+
108
+ type SI struct {
109
+ I interface{}
110
+ }
111
+
112
+ // P is a type with a String method with pointer receiver for testing %p.
113
+ type P int
114
+
115
+ var pValue P
116
+
117
+ func (p *P) String() string {
118
+ return "String(p)"
119
+ }
120
+
121
+ var barray = [5]renamedUint8{1, 2, 3, 4, 5}
122
+ var bslice = barray[:]
123
+
124
+ type byteStringer byte
125
+
126
+ func (byteStringer) String() string {
127
+ return "X"
128
+ }
129
+
130
+ var byteStringerSlice = []byteStringer{'h', 'e', 'l', 'l', 'o'}
131
+
132
+ type byteFormatter byte
133
+
134
+ func (byteFormatter) Format(f fmt.State, _ rune) {
135
+ p := NewPrinter(language.Und)
136
+ p.Fprint(f, "X")
137
+ }
138
+
139
+ var byteFormatterSlice = []byteFormatter{'h', 'e', 'l', 'l', 'o'}
140
+
141
+ var fmtTests = []struct {
142
+ fmt string
143
+ val interface{}
144
+ out string
145
+ }{
146
+ // The behavior of the following tests differs from that of the fmt package.
147
+
148
+ // Unlike with the fmt package, it is okay to have extra arguments for
149
+ // strings without format parameters. This is because it is impossible to
150
+ // distinguish between reordered or ordered format strings in this case.
151
+ // (For reordered format strings it is okay to not use arguments.)
152
+ {"", nil, ""},
153
+ {"", 2, ""},
154
+ {"no args", "hello", "no args"},
155
+
156
+ {"%017091901790959340919092959340919017929593813360", 0, "%!(NOVERB)"},
157
+ {"%184467440737095516170v", 0, "%!(NOVERB)"},
158
+ // Extra argument errors should format without flags set.
159
+ {"%010.2", "12345", "%!(NOVERB)"},
160
+
161
+ // Some key other differences, asides from localized values:
162
+ // - NaN values should not use affixes; so no signs (CLDR requirement)
163
+ // - Infinity uses patterns, so signs may be different (CLDR requirement)
164
+ // - The # flag is used to disable localization.
165
+
166
+ // All following tests are analogous to those of the fmt package, but with
167
+ // localized numbers when appropriate.
168
+ {"%d", 12345, "12,345"},
169
+ {"%v", 12345, "12,345"},
170
+ {"%t", true, "true"},
171
+
172
+ // basic string
173
+ {"%s", "abc", "abc"},
174
+ {"%q", "abc", `"abc"`},
175
+ {"%x", "abc", "616263"},
176
+ {"%x", "\xff\xf0\x0f\xff", "fff00fff"},
177
+ {"%X", "\xff\xf0\x0f\xff", "FFF00FFF"},
178
+ {"%x", "", ""},
179
+ {"% x", "", ""},
180
+ {"%#x", "", ""},
181
+ {"%# x", "", ""},
182
+ {"%x", "xyz", "78797a"},
183
+ {"%X", "xyz", "78797A"},
184
+ {"% x", "xyz", "78 79 7a"},
185
+ {"% X", "xyz", "78 79 7A"},
186
+ {"%#x", "xyz", "0x78797a"},
187
+ {"%#X", "xyz", "0X78797A"},
188
+ {"%# x", "xyz", "0x78 0x79 0x7a"},
189
+ {"%# X", "xyz", "0X78 0X79 0X7A"},
190
+
191
+ // basic bytes
192
+ {"%s", []byte("abc"), "abc"},
193
+ {"%s", [3]byte{'a', 'b', 'c'}, "abc"},
194
+ {"%s", &[3]byte{'a', 'b', 'c'}, "&abc"},
195
+ {"%q", []byte("abc"), `"abc"`},
196
+ {"%x", []byte("abc"), "616263"},
197
+ {"%x", []byte("\xff\xf0\x0f\xff"), "fff00fff"},
198
+ {"%X", []byte("\xff\xf0\x0f\xff"), "FFF00FFF"},
199
+ {"%x", []byte(""), ""},
200
+ {"% x", []byte(""), ""},
201
+ {"%#x", []byte(""), ""},
202
+ {"%# x", []byte(""), ""},
203
+ {"%x", []byte("xyz"), "78797a"},
204
+ {"%X", []byte("xyz"), "78797A"},
205
+ {"% x", []byte("xyz"), "78 79 7a"},
206
+ {"% X", []byte("xyz"), "78 79 7A"},
207
+ {"%#x", []byte("xyz"), "0x78797a"},
208
+ {"%#X", []byte("xyz"), "0X78797A"},
209
+ {"%# x", []byte("xyz"), "0x78 0x79 0x7a"},
210
+ {"%# X", []byte("xyz"), "0X78 0X79 0X7A"},
211
+
212
+ // escaped strings
213
+ {"%q", "", `""`},
214
+ {"%#q", "", "``"},
215
+ {"%q", "\"", `"\""`},
216
+ {"%#q", "\"", "`\"`"},
217
+ {"%q", "`", `"` + "`" + `"`},
218
+ {"%#q", "`", `"` + "`" + `"`},
219
+ {"%q", "\n", `"\n"`},
220
+ {"%#q", "\n", `"\n"`},
221
+ {"%q", `\n`, `"\\n"`},
222
+ {"%#q", `\n`, "`\\n`"},
223
+ {"%q", "abc", `"abc"`},
224
+ {"%#q", "abc", "`abc`"},
225
+ {"%q", "日本語", `"日本語"`},
226
+ {"%+q", "日本語", `"\u65e5\u672c\u8a9e"`},
227
+ {"%#q", "日本語", "`日本語`"},
228
+ {"%#+q", "日本語", "`日本語`"},
229
+ {"%q", "\a\b\f\n\r\t\v\"\\", `"\a\b\f\n\r\t\v\"\\"`},
230
+ {"%+q", "\a\b\f\n\r\t\v\"\\", `"\a\b\f\n\r\t\v\"\\"`},
231
+ {"%#q", "\a\b\f\n\r\t\v\"\\", `"\a\b\f\n\r\t\v\"\\"`},
232
+ {"%#+q", "\a\b\f\n\r\t\v\"\\", `"\a\b\f\n\r\t\v\"\\"`},
233
+ {"%q", "☺", `"☺"`},
234
+ {"% q", "☺", `"☺"`}, // The space modifier should have no effect.
235
+ {"%+q", "☺", `"\u263a"`},
236
+ {"%#q", "☺", "`☺`"},
237
+ {"%#+q", "☺", "`☺`"},
238
+ {"%10q", "⌘", ` "⌘"`},
239
+ {"%+10q", "⌘", ` "\u2318"`},
240
+ {"%-10q", "⌘", `"⌘" `},
241
+ {"%+-10q", "⌘", `"\u2318" `},
242
+ {"%010q", "⌘", `0000000"⌘"`},
243
+ {"%+010q", "⌘", `00"\u2318"`},
244
+ {"%-010q", "⌘", `"⌘" `}, // 0 has no effect when - is present.
245
+ {"%+-010q", "⌘", `"\u2318" `},
246
+ {"%#8q", "\n", ` "\n"`},
247
+ {"%#+8q", "\r", ` "\r"`},
248
+ {"%#-8q", "\t", "` ` "},
249
+ {"%#+-8q", "\b", `"\b" `},
250
+ {"%q", "abc\xffdef", `"abc\xffdef"`},
251
+ {"%+q", "abc\xffdef", `"abc\xffdef"`},
252
+ {"%#q", "abc\xffdef", `"abc\xffdef"`},
253
+ {"%#+q", "abc\xffdef", `"abc\xffdef"`},
254
+ // Runes that are not printable.
255
+ {"%q", "\U0010ffff", `"\U0010ffff"`},
256
+ {"%+q", "\U0010ffff", `"\U0010ffff"`},
257
+ {"%#q", "\U0010ffff", "`􏿿`"},
258
+ {"%#+q", "\U0010ffff", "`􏿿`"},
259
+ // Runes that are not valid.
260
+ {"%q", string(0x110000), `"�"`},
261
+ {"%+q", string(0x110000), `"\ufffd"`},
262
+ {"%#q", string(0x110000), "`�`"},
263
+ {"%#+q", string(0x110000), "`�`"},
264
+
265
+ // characters
266
+ {"%c", uint('x'), "x"},
267
+ {"%c", 0xe4, "ä"},
268
+ {"%c", 0x672c, "本"},
269
+ {"%c", '日', "日"},
270
+ {"%.0c", '⌘', "⌘"}, // Specifying precision should have no effect.
271
+ {"%3c", '⌘', " ⌘"},
272
+ {"%-3c", '⌘', "⌘ "},
273
+ // Runes that are not printable.
274
+ {"%c", '\U00000e00', "\u0e00"},
275
+ {"%c", '\U0010ffff', "\U0010ffff"},
276
+ // Runes that are not valid.
277
+ {"%c", -1, "�"},
278
+ {"%c", 0xDC80, "�"},
279
+ {"%c", rune(0x110000), "�"},
280
+ {"%c", int64(0xFFFFFFFFF), "�"},
281
+ {"%c", uint64(0xFFFFFFFFF), "�"},
282
+
283
+ // escaped characters
284
+ {"%q", uint(0), `'\x00'`},
285
+ {"%+q", uint(0), `'\x00'`},
286
+ {"%q", '"', `'"'`},
287
+ {"%+q", '"', `'"'`},
288
+ {"%q", '\'', `'\''`},
289
+ {"%+q", '\'', `'\''`},
290
+ {"%q", '`', "'`'"},
291
+ {"%+q", '`', "'`'"},
292
+ {"%q", 'x', `'x'`},
293
+ {"%+q", 'x', `'x'`},
294
+ {"%q", 'ÿ', `'ÿ'`},
295
+ {"%+q", 'ÿ', `'\u00ff'`},
296
+ {"%q", '\n', `'\n'`},
297
+ {"%+q", '\n', `'\n'`},
298
+ {"%q", '☺', `'☺'`},
299
+ {"%+q", '☺', `'\u263a'`},
300
+ {"% q", '☺', `'☺'`}, // The space modifier should have no effect.
301
+ {"%.0q", '☺', `'☺'`}, // Specifying precision should have no effect.
302
+ {"%10q", '⌘', ` '⌘'`},
303
+ {"%+10q", '⌘', ` '\u2318'`},
304
+ {"%-10q", '⌘', `'⌘' `},
305
+ {"%+-10q", '⌘', `'\u2318' `},
306
+ {"%010q", '⌘', `0000000'⌘'`},
307
+ {"%+010q", '⌘', `00'\u2318'`},
308
+ {"%-010q", '⌘', `'⌘' `}, // 0 has no effect when - is present.
309
+ {"%+-010q", '⌘', `'\u2318' `},
310
+ // Runes that are not printable.
311
+ {"%q", '\U00000e00', `'\u0e00'`},
312
+ {"%q", '\U0010ffff', `'\U0010ffff'`},
313
+ // Runes that are not valid.
314
+ {"%q", int32(-1), "%!q(int32=-1)"},
315
+ {"%q", 0xDC80, `'�'`},
316
+ {"%q", rune(0x110000), "%!q(int32=1,114,112)"},
317
+ {"%q", int64(0xFFFFFFFFF), "%!q(int64=68,719,476,735)"},
318
+ {"%q", uint64(0xFFFFFFFFF), "%!q(uint64=68,719,476,735)"},
319
+
320
+ // width
321
+ {"%5s", "abc", " abc"},
322
+ {"%2s", "\u263a", " ☺"},
323
+ {"%-5s", "abc", "abc "},
324
+ {"%-8q", "abc", `"abc" `},
325
+ {"%05s", "abc", "00abc"},
326
+ {"%08q", "abc", `000"abc"`},
327
+ {"%5s", "abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz"},
328
+ {"%.5s", "abcdefghijklmnopqrstuvwxyz", "abcde"},
329
+ {"%.0s", "日本語日本語", ""},
330
+ {"%.5s", "日本語日本語", "日本語日本"},
331
+ {"%.10s", "日本語日本語", "日本語日本語"},
332
+ {"%.5s", []byte("日本語日本語"), "日本語日本"},
333
+ {"%.5q", "abcdefghijklmnopqrstuvwxyz", `"abcde"`},
334
+ {"%.5x", "abcdefghijklmnopqrstuvwxyz", "6162636465"},
335
+ {"%.5q", []byte("abcdefghijklmnopqrstuvwxyz"), `"abcde"`},
336
+ {"%.5x", []byte("abcdefghijklmnopqrstuvwxyz"), "6162636465"},
337
+ {"%.3q", "日本語日本語", `"日本語"`},
338
+ {"%.3q", []byte("日本語日本語"), `"日本語"`},
339
+ {"%.1q", "日本語", `"日"`},
340
+ {"%.1q", []byte("日本語"), `"日"`},
341
+ {"%.1x", "日本語", "e6"},
342
+ {"%.1X", []byte("日本語"), "E6"},
343
+ {"%10.1q", "日本語日本語", ` "日"`},
344
+ {"%10v", nil, " <nil>"},
345
+ {"%-10v", nil, "<nil> "},
346
+
347
+ // integers
348
+ {"%d", uint(12345), "12,345"},
349
+ {"%d", int(-12345), "-12,345"},
350
+ {"%d", ^uint8(0), "255"},
351
+ {"%d", ^uint16(0), "65,535"},
352
+ {"%d", ^uint32(0), "4,294,967,295"},
353
+ {"%d", ^uint64(0), "18,446,744,073,709,551,615"},
354
+ {"%d", int8(-1 << 7), "-128"},
355
+ {"%d", int16(-1 << 15), "-32,768"},
356
+ {"%d", int32(-1 << 31), "-2,147,483,648"},
357
+ {"%d", int64(-1 << 63), "-9,223,372,036,854,775,808"},
358
+ {"%.d", 0, ""},
359
+ {"%.0d", 0, ""},
360
+ {"%6.0d", 0, " "},
361
+ {"%06.0d", 0, " "},
362
+ {"% d", 12345, " 12,345"},
363
+ {"%+d", 12345, "+12,345"},
364
+ {"%+d", -12345, "-12,345"},
365
+ {"%b", 7, "111"},
366
+ {"%b", -6, "-110"},
367
+ {"%b", ^uint32(0), "11111111111111111111111111111111"},
368
+ {"%b", ^uint64(0), "1111111111111111111111111111111111111111111111111111111111111111"},
369
+ {"%b", int64(-1 << 63), zeroFill("-1", 63, "")},
370
+ {"%o", 01234, "1234"},
371
+ {"%#o", 01234, "01234"},
372
+ {"%o", ^uint32(0), "37777777777"},
373
+ {"%o", ^uint64(0), "1777777777777777777777"},
374
+ {"%#X", 0, "0X0"},
375
+ {"%x", 0x12abcdef, "12abcdef"},
376
+ {"%X", 0x12abcdef, "12ABCDEF"},
377
+ {"%x", ^uint32(0), "ffffffff"},
378
+ {"%X", ^uint64(0), "FFFFFFFFFFFFFFFF"},
379
+ {"%.20b", 7, "00000000000000000111"},
380
+ {"%10d", 12345, " 12,345"},
381
+ {"%10d", -12345, " -12,345"},
382
+ {"%+10d", 12345, " +12,345"},
383
+ {"%010d", 12345, "0,000,012,345"},
384
+ {"%010d", -12345, "-0,000,012,345"},
385
+ {"%20.8d", 1234, " 00,001,234"},
386
+ {"%20.8d", -1234, " -00,001,234"},
387
+ {"%020.8d", 1234, " 00,001,234"},
388
+ {"%020.8d", -1234, " -00,001,234"},
389
+ {"%-20.8d", 1234, "00,001,234 "},
390
+ {"%-20.8d", -1234, "-00,001,234 "},
391
+ {"%-#20.8x", 0x1234abc, "0x01234abc "},
392
+ {"%-#20.8X", 0x1234abc, "0X01234ABC "},
393
+ {"%-#20.8o", 01234, "00001234 "},
394
+
395
+ // Test correct f.intbuf overflow checks.
396
+ {"%068d", 1, "00," + strings.Repeat("000,", 21) + "001"},
397
+ {"%068d", -1, "-00," + strings.Repeat("000,", 21) + "001"},
398
+ {"%#.68x", 42, zeroFill("0x", 68, "2a")},
399
+ {"%.68d", -42, "-00," + strings.Repeat("000,", 21) + "042"},
400
+ {"%+.68d", 42, "+00," + strings.Repeat("000,", 21) + "042"},
401
+ {"% .68d", 42, " 00," + strings.Repeat("000,", 21) + "042"},
402
+ {"% +.68d", 42, "+00," + strings.Repeat("000,", 21) + "042"},
403
+
404
+ // unicode format
405
+ {"%U", 0, "U+0000"},
406
+ {"%U", -1, "U+FFFFFFFFFFFFFFFF"},
407
+ {"%U", '\n', `U+000A`},
408
+ {"%#U", '\n', `U+000A`},
409
+ {"%+U", 'x', `U+0078`}, // Plus flag should have no effect.
410
+ {"%# U", 'x', `U+0078 'x'`}, // Space flag should have no effect.
411
+ {"%#.2U", 'x', `U+0078 'x'`}, // Precisions below 4 should print 4 digits.
412
+ {"%U", '\u263a', `U+263A`},
413
+ {"%#U", '\u263a', `U+263A '☺'`},
414
+ {"%U", '\U0001D6C2', `U+1D6C2`},
415
+ {"%#U", '\U0001D6C2', `U+1D6C2 '𝛂'`},
416
+ {"%#14.6U", '⌘', " U+002318 '⌘'"},
417
+ {"%#-14.6U", '⌘', "U+002318 '⌘' "},
418
+ {"%#014.6U", '⌘', " U+002318 '⌘'"},
419
+ {"%#-014.6U", '⌘', "U+002318 '⌘' "},
420
+ {"%.68U", uint(42), zeroFill("U+", 68, "2A")},
421
+ {"%#.68U", '日', zeroFill("U+", 68, "65E5") + " '日'"},
422
+
423
+ // floats
424
+ {"%+.3e", 0.0, "+0.000\u202f×\u202f10⁰⁰"},
425
+ {"%+.3e", 1.0, "+1.000\u202f×\u202f10⁰⁰"},
426
+ {"%+.3f", -1.0, "-1.000"},
427
+ {"%+.3F", -1.0, "-1.000"},
428
+ {"%+.3F", float32(-1.0), "-1.000"},
429
+ {"%+07.2f", 1.0, "+001.00"},
430
+ {"%+07.2f", -1.0, "-001.00"},
431
+ {"%-07.2f", 1.0, "1.00 "},
432
+ {"%-07.2f", -1.0, "-1.00 "},
433
+ {"%+-07.2f", 1.0, "+1.00 "},
434
+ {"%+-07.2f", -1.0, "-1.00 "},
435
+ {"%-+07.2f", 1.0, "+1.00 "},
436
+ {"%-+07.2f", -1.0, "-1.00 "},
437
+ {"%+10.2f", +1.0, " +1.00"},
438
+ {"%+10.2f", -1.0, " -1.00"},
439
+ {"% .3E", -1.0, "-1.000\u202f×\u202f10⁰⁰"},
440
+ {"% .3e", 1.0, " 1.000\u202f×\u202f10⁰⁰"},
441
+ {"%+.3g", 0.0, "+0"},
442
+ {"%+.3g", 1.0, "+1"},
443
+ {"%+.3g", -1.0, "-1"},
444
+ {"% .3g", -1.0, "-1"},
445
+ {"% .3g", 1.0, " 1"},
446
+ {"%b", float32(1.0), "8388608p-23"},
447
+ {"%b", 1.0, "4503599627370496p-52"},
448
+ // Test sharp flag used with floats.
449
+ {"%#g", 1e-323, "1.00000e-323"},
450
+ {"%#g", -1.0, "-1.00000"},
451
+ {"%#g", 1.1, "1.10000"},
452
+ {"%#g", 123456.0, "123456."},
453
+ {"%#g", 1234567.0, "1.234567e+06"},
454
+ {"%#g", 1230000.0, "1.23000e+06"},
455
+ {"%#g", 1000000.0, "1.00000e+06"},
456
+ {"%#.0f", 1.0, "1."},
457
+ {"%#.0e", 1.0, "1.e+00"},
458
+ {"%#.0g", 1.0, "1."},
459
+ {"%#.0g", 1100000.0, "1.e+06"},
460
+ {"%#.4f", 1.0, "1.0000"},
461
+ {"%#.4e", 1.0, "1.0000e+00"},
462
+ {"%#.4g", 1.0, "1.000"},
463
+ {"%#.4g", 100000.0, "1.000e+05"},
464
+ {"%#.0f", 123.0, "123."},
465
+ {"%#.0e", 123.0, "1.e+02"},
466
+ {"%#.0g", 123.0, "1.e+02"},
467
+ {"%#.4f", 123.0, "123.0000"},
468
+ {"%#.4e", 123.0, "1.2300e+02"},
469
+ {"%#.4g", 123.0, "123.0"},
470
+ {"%#.4g", 123000.0, "1.230e+05"},
471
+ {"%#9.4g", 1.0, " 1.000"},
472
+ // The sharp flag has no effect for binary float format.
473
+ {"%#b", 1.0, "4503599627370496p-52"},
474
+ // Precision has no effect for binary float format.
475
+ {"%.4b", float32(1.0), "8388608p-23"},
476
+ {"%.4b", -1.0, "-4503599627370496p-52"},
477
+ // Test correct f.intbuf boundary checks.
478
+ {"%.68f", 1.0, zeroFill("1.", 68, "")},
479
+ {"%.68f", -1.0, zeroFill("-1.", 68, "")},
480
+ // float infinites and NaNs
481
+ {"%f", posInf, "∞"},
482
+ {"%.1f", negInf, "-∞"},
483
+ {"% f", NaN, "NaN"},
484
+ {"%20f", posInf, " ∞"},
485
+ {"% 20F", posInf, " ∞"},
486
+ {"% 20e", negInf, " -∞"},
487
+ {"%+20E", negInf, " -∞"},
488
+ {"% +20g", negInf, " -∞"},
489
+ {"%+-20G", posInf, "+∞ "},
490
+ {"%20e", NaN, " NaN"},
491
+ {"% +20E", NaN, " NaN"},
492
+ {"% -20g", NaN, "NaN "},
493
+ {"%+-20G", NaN, "NaN "},
494
+ // Zero padding does not apply to infinities and NaN.
495
+ {"%+020e", posInf, " +∞"},
496
+ {"%-020f", negInf, "-∞ "},
497
+ {"%-020E", NaN, "NaN "},
498
+
499
+ // complex values
500
+ {"%.f", 0i, "(0+0i)"},
501
+ {"% .f", 0i, "( 0+0i)"},
502
+ {"%+.f", 0i, "(+0+0i)"},
503
+ {"% +.f", 0i, "(+0+0i)"},
504
+ {"%+.3e", 0i, "(+0.000\u202f×\u202f10⁰⁰+0.000\u202f×\u202f10⁰⁰i)"},
505
+ {"%+.3f", 0i, "(+0.000+0.000i)"},
506
+ {"%+.3g", 0i, "(+0+0i)"},
507
+ {"%+.3e", 1 + 2i, "(+1.000\u202f×\u202f10⁰⁰+2.000\u202f×\u202f10⁰⁰i)"},
508
+ {"%+.3f", 1 + 2i, "(+1.000+2.000i)"},
509
+ {"%+.3g", 1 + 2i, "(+1+2i)"},
510
+ {"%.3e", 0i, "(0.000\u202f×\u202f10⁰⁰+0.000\u202f×\u202f10⁰⁰i)"},
511
+ {"%.3f", 0i, "(0.000+0.000i)"},
512
+ {"%.3F", 0i, "(0.000+0.000i)"},
513
+ {"%.3F", complex64(0i), "(0.000+0.000i)"},
514
+ {"%.3g", 0i, "(0+0i)"},
515
+ {"%.3e", 1 + 2i, "(1.000\u202f×\u202f10⁰⁰+2.000\u202f×\u202f10⁰⁰i)"},
516
+ {"%.3f", 1 + 2i, "(1.000+2.000i)"},
517
+ {"%.3g", 1 + 2i, "(1+2i)"},
518
+ {"%.3e", -1 - 2i, "(-1.000\u202f×\u202f10⁰⁰-2.000\u202f×\u202f10⁰⁰i)"},
519
+ {"%.3f", -1 - 2i, "(-1.000-2.000i)"},
520
+ {"%.3g", -1 - 2i, "(-1-2i)"},
521
+ {"% .3E", -1 - 2i, "(-1.000\u202f×\u202f10⁰⁰-2.000\u202f×\u202f10⁰⁰i)"},
522
+ {"%+.3g", 1 + 2i, "(+1+2i)"},
523
+ {"%+.3g", complex64(1 + 2i), "(+1+2i)"},
524
+ {"%#g", 1 + 2i, "(1.00000+2.00000i)"},
525
+ {"%#g", 123456 + 789012i, "(123456.+789012.i)"},
526
+ {"%#g", 1e-10i, "(0.00000+1.00000e-10i)"},
527
+ {"%#g", -1e10 - 1.11e100i, "(-1.00000e+10-1.11000e+100i)"},
528
+ {"%#.0f", 1.23 + 1.0i, "(1.+1.i)"},
529
+ {"%#.0e", 1.23 + 1.0i, "(1.e+00+1.e+00i)"},
530
+ {"%#.0g", 1.23 + 1.0i, "(1.+1.i)"},
531
+ {"%#.0g", 0 + 100000i, "(0.+1.e+05i)"},
532
+ {"%#.0g", 1230000 + 0i, "(1.e+06+0.i)"},
533
+ {"%#.4f", 1 + 1.23i, "(1.0000+1.2300i)"},
534
+ {"%#.4e", 123 + 1i, "(1.2300e+02+1.0000e+00i)"},
535
+ {"%#.4g", 123 + 1.23i, "(123.0+1.230i)"},
536
+ {"%#12.5g", 0 + 100000i, "( 0.0000 +1.0000e+05i)"},
537
+ {"%#12.5g", 1230000 - 0i, "( 1.2300e+06 +0.0000i)"},
538
+ {"%b", 1 + 2i, "(4503599627370496p-52+4503599627370496p-51i)"},
539
+ {"%b", complex64(1 + 2i), "(8388608p-23+8388608p-22i)"},
540
+ // The sharp flag has no effect for binary complex format.
541
+ {"%#b", 1 + 2i, "(4503599627370496p-52+4503599627370496p-51i)"},
542
+ // Precision has no effect for binary complex format.
543
+ {"%.4b", 1 + 2i, "(4503599627370496p-52+4503599627370496p-51i)"},
544
+ {"%.4b", complex64(1 + 2i), "(8388608p-23+8388608p-22i)"},
545
+ // complex infinites and NaNs
546
+ {"%f", complex(posInf, posInf), "(∞+∞i)"},
547
+ {"%f", complex(negInf, negInf), "(-∞-∞i)"},
548
+ {"%f", complex(NaN, NaN), "(NaN+NaNi)"},
549
+ {"%.1f", complex(posInf, posInf), "(∞+∞i)"},
550
+ {"% f", complex(posInf, posInf), "( ∞+∞i)"},
551
+ {"% f", complex(negInf, negInf), "(-∞-∞i)"},
552
+ {"% f", complex(NaN, NaN), "(NaN+NaNi)"},
553
+ {"%8e", complex(posInf, posInf), "( ∞ +∞i)"},
554
+ {"% 8E", complex(posInf, posInf), "( ∞ +∞i)"},
555
+ {"%+8f", complex(negInf, negInf), "( -∞ -∞i)"},
556
+ {"% +8g", complex(negInf, negInf), "( -∞ -∞i)"}, // TODO(g)
557
+ {"% -8G", complex(NaN, NaN), "(NaN +NaN i)"},
558
+ {"%+-8b", complex(NaN, NaN), "(+NaN +NaN i)"},
559
+ // Zero padding does not apply to infinities and NaN.
560
+ {"%08f", complex(posInf, posInf), "( ∞ +∞i)"},
561
+ {"%-08g", complex(negInf, negInf), "(-∞ -∞ i)"},
562
+ {"%-08G", complex(NaN, NaN), "(NaN +NaN i)"},
563
+
564
+ // old test/fmt_test.go
565
+ {"%e", 1.0, "1.000000\u202f×\u202f10⁰⁰"},
566
+ {"%e", 1234.5678e3, "1.234568\u202f×\u202f10⁰⁶"},
567
+ {"%e", 1234.5678e-8, "1.234568\u202f×\u202f10⁻⁰⁵"},
568
+ {"%e", -7.0, "-7.000000\u202f×\u202f10⁰⁰"},
569
+ {"%e", -1e-9, "-1.000000\u202f×\u202f10⁻⁰⁹"},
570
+ {"%f", 1234.5678e3, "1,234,567.800000"},
571
+ {"%f", 1234.5678e-8, "0.000012"},
572
+ {"%f", -7.0, "-7.000000"},
573
+ {"%f", -1e-9, "-0.000000"},
574
+ {"%g", 1234.5678e3, "1.2345678\u202f×\u202f10⁰⁶"},
575
+ {"%g", float32(1234.5678e3), "1.2345678\u202f×\u202f10⁰⁶"},
576
+ {"%g", 1234.5678e-8, "1.2345678\u202f×\u202f10⁻⁰⁵"},
577
+ {"%g", -7.0, "-7"},
578
+ {"%g", -1e-9, "-1\u202f×\u202f10⁻⁰⁹"},
579
+ {"%g", float32(-1e-9), "-1\u202f×\u202f10⁻⁰⁹"},
580
+ {"%E", 1.0, "1.000000\u202f×\u202f10⁰⁰"},
581
+ {"%E", 1234.5678e3, "1.234568\u202f×\u202f10⁰⁶"},
582
+ {"%E", 1234.5678e-8, "1.234568\u202f×\u202f10⁻⁰⁵"},
583
+ {"%E", -7.0, "-7.000000\u202f×\u202f10⁰⁰"},
584
+ {"%E", -1e-9, "-1.000000\u202f×\u202f10⁻⁰⁹"},
585
+ {"%G", 1234.5678e3, "1.2345678\u202f×\u202f10⁰⁶"},
586
+ {"%G", float32(1234.5678e3), "1.2345678\u202f×\u202f10⁰⁶"},
587
+ {"%G", 1234.5678e-8, "1.2345678\u202f×\u202f10⁻⁰⁵"},
588
+ {"%G", -7.0, "-7"},
589
+ {"%G", -1e-9, "-1\u202f×\u202f10⁻⁰⁹"},
590
+ {"%G", float32(-1e-9), "-1\u202f×\u202f10⁻⁰⁹"},
591
+ {"%20.5s", "qwertyuiop", " qwert"},
592
+ {"%.5s", "qwertyuiop", "qwert"},
593
+ {"%-20.5s", "qwertyuiop", "qwert "},
594
+ {"%20c", 'x', " x"},
595
+ {"%-20c", 'x', "x "},
596
+ {"%20.6e", 1.2345e3, " 1.234500\u202f×\u202f10⁰³"},
597
+ {"%20.6e", 1.2345e-3, " 1.234500\u202f×\u202f10⁻⁰³"},
598
+ {"%20e", 1.2345e3, " 1.234500\u202f×\u202f10⁰³"},
599
+ {"%20e", 1.2345e-3, " 1.234500\u202f×\u202f10⁻⁰³"},
600
+ {"%20.8e", 1.2345e3, " 1.23450000\u202f×\u202f10⁰³"},
601
+ {"%20f", 1.23456789e3, " 1,234.567890"},
602
+ {"%20f", 1.23456789e-3, " 0.001235"},
603
+ {"%20f", 12345678901.23456789, "12,345,678,901.234568"},
604
+ {"%-20f", 1.23456789e3, "1,234.567890 "},
605
+ {"%20.8f", 1.23456789e3, " 1,234.56789000"},
606
+ {"%20.8f", 1.23456789e-3, " 0.00123457"},
607
+ {"%g", 1.23456789e3, "1,234.56789"},
608
+ {"%g", 1.23456789e-3, "0.00123456789"},
609
+ {"%g", 1.23456789e20, "1.23456789\u202f×\u202f10²⁰"},
610
+
611
+ // arrays
612
+ {"%v", array, "[1 2 3 4 5]"},
613
+ {"%v", iarray, "[1 hello 2.5 <nil>]"},
614
+ {"%v", barray, "[1 2 3 4 5]"},
615
+ {"%v", &array, "&[1 2 3 4 5]"},
616
+ {"%v", &iarray, "&[1 hello 2.5 <nil>]"},
617
+ {"%v", &barray, "&[1 2 3 4 5]"},
618
+
619
+ // slices
620
+ {"%v", slice, "[1 2 3 4 5]"},
621
+ {"%v", islice, "[1 hello 2.5 <nil>]"},
622
+ {"%v", bslice, "[1 2 3 4 5]"},
623
+ {"%v", &slice, "&[1 2 3 4 5]"},
624
+ {"%v", &islice, "&[1 hello 2.5 <nil>]"},
625
+ {"%v", &bslice, "&[1 2 3 4 5]"},
626
+
627
+ // byte arrays and slices with %b,%c,%d,%o,%U and %v
628
+ {"%b", [3]byte{65, 66, 67}, "[1000001 1000010 1000011]"},
629
+ {"%c", [3]byte{65, 66, 67}, "[A B C]"},
630
+ {"%d", [3]byte{65, 66, 67}, "[65 66 67]"},
631
+ {"%o", [3]byte{65, 66, 67}, "[101 102 103]"},
632
+ {"%U", [3]byte{65, 66, 67}, "[U+0041 U+0042 U+0043]"},
633
+ {"%v", [3]byte{65, 66, 67}, "[65 66 67]"},
634
+ {"%v", [1]byte{123}, "[123]"},
635
+ {"%012v", []byte{}, "[]"},
636
+ {"%#012v", []byte{}, "[]byte{}"},
637
+ {"%6v", []byte{1, 11, 111}, "[ 1 11 111]"},
638
+ {"%06v", []byte{1, 11, 111}, "[000001 000011 000111]"},
639
+ {"%-6v", []byte{1, 11, 111}, "[1 11 111 ]"},
640
+ {"%-06v", []byte{1, 11, 111}, "[1 11 111 ]"},
641
+ {"%#v", []byte{1, 11, 111}, "[]byte{0x1, 0xb, 0x6f}"},
642
+ {"%#6v", []byte{1, 11, 111}, "[]byte{ 0x1, 0xb, 0x6f}"},
643
+ {"%#06v", []byte{1, 11, 111}, "[]byte{0x000001, 0x00000b, 0x00006f}"},
644
+ {"%#-6v", []byte{1, 11, 111}, "[]byte{0x1 , 0xb , 0x6f }"},
645
+ {"%#-06v", []byte{1, 11, 111}, "[]byte{0x1 , 0xb , 0x6f }"},
646
+ // f.space should and f.plus should not have an effect with %v.
647
+ {"% v", []byte{1, 11, 111}, "[ 1 11 111]"},
648
+ {"%+v", [3]byte{1, 11, 111}, "[1 11 111]"},
649
+ {"%# -6v", []byte{1, 11, 111}, "[]byte{ 0x1 , 0xb , 0x6f }"},
650
+ {"%#+-6v", [3]byte{1, 11, 111}, "[3]uint8{0x1 , 0xb , 0x6f }"},
651
+ // f.space and f.plus should have an effect with %d.
652
+ {"% d", []byte{1, 11, 111}, "[ 1 11 111]"},
653
+ {"%+d", [3]byte{1, 11, 111}, "[+1 +11 +111]"},
654
+ {"%# -6d", []byte{1, 11, 111}, "[ 1 11 111 ]"},
655
+ {"%#+-6d", [3]byte{1, 11, 111}, "[+1 +11 +111 ]"},
656
+
657
+ // floates with %v
658
+ {"%v", 1.2345678, "1.2345678"},
659
+ {"%v", float32(1.2345678), "1.2345678"},
660
+
661
+ // complexes with %v
662
+ {"%v", 1 + 2i, "(1+2i)"},
663
+ {"%v", complex64(1 + 2i), "(1+2i)"},
664
+
665
+ // structs
666
+ {"%v", A{1, 2, "a", []int{1, 2}}, `{1 2 a [1 2]}`},
667
+ {"%+v", A{1, 2, "a", []int{1, 2}}, `{i:1 j:2 s:a x:[1 2]}`},
668
+
669
+ // +v on structs with Stringable items
670
+ {"%+v", B{1, 2}, `{I:<1> j:2}`},
671
+ {"%+v", C{1, B{2, 3}}, `{i:1 B:{I:<2> j:3}}`},
672
+
673
+ // other formats on Stringable items
674
+ {"%s", I(23), `<23>`},
675
+ {"%q", I(23), `"<23>"`},
676
+ {"%x", I(23), `3c32333e`},
677
+ {"%#x", I(23), `0x3c32333e`},
678
+ {"%# x", I(23), `0x3c 0x32 0x33 0x3e`},
679
+ // Stringer applies only to string formats.
680
+ {"%d", I(23), `23`},
681
+ // Stringer applies to the extracted value.
682
+ {"%s", reflect.ValueOf(I(23)), `<23>`},
683
+
684
+ // go syntax
685
+ {"%#v", A{1, 2, "a", []int{1, 2}}, `message.A{i:1, j:0x2, s:"a", x:[]int{1, 2}}`},
686
+ {"%#v", new(byte), "(*uint8)(0xPTR)"},
687
+ {"%#v", TestFmtInterface, "(func(*testing.T))(0xPTR)"},
688
+ {"%#v", make(chan int), "(chan int)(0xPTR)"},
689
+ {"%#v", uint64(1<<64 - 1), "0xffffffffffffffff"},
690
+ {"%#v", 1000000000, "1000000000"},
691
+ {"%#v", map[string]int{"a": 1}, `map[string]int{"a":1}`},
692
+ {"%#v", map[string]B{"a": {1, 2}}, `map[string]message.B{"a":message.B{I:1, j:2}}`},
693
+ {"%#v", []string{"a", "b"}, `[]string{"a", "b"}`},
694
+ {"%#v", SI{}, `message.SI{I:interface {}(nil)}`},
695
+ {"%#v", []int(nil), `[]int(nil)`},
696
+ {"%#v", []int{}, `[]int{}`},
697
+ {"%#v", array, `[5]int{1, 2, 3, 4, 5}`},
698
+ {"%#v", &array, `&[5]int{1, 2, 3, 4, 5}`},
699
+ {"%#v", iarray, `[4]interface {}{1, "hello", 2.5, interface {}(nil)}`},
700
+ {"%#v", &iarray, `&[4]interface {}{1, "hello", 2.5, interface {}(nil)}`},
701
+ {"%#v", map[int]byte(nil), `map[int]uint8(nil)`},
702
+ {"%#v", map[int]byte{}, `map[int]uint8{}`},
703
+ {"%#v", "foo", `"foo"`},
704
+ {"%#v", barray, `[5]message.renamedUint8{0x1, 0x2, 0x3, 0x4, 0x5}`},
705
+ {"%#v", bslice, `[]message.renamedUint8{0x1, 0x2, 0x3, 0x4, 0x5}`},
706
+ {"%#v", []int32(nil), "[]int32(nil)"},
707
+ {"%#v", 1.2345678, "1.2345678"},
708
+ {"%#v", float32(1.2345678), "1.2345678"},
709
+ // Only print []byte and []uint8 as type []byte if they appear at the top level.
710
+ {"%#v", []byte(nil), "[]byte(nil)"},
711
+ {"%#v", []uint8(nil), "[]byte(nil)"},
712
+ {"%#v", []byte{}, "[]byte{}"},
713
+ {"%#v", []uint8{}, "[]byte{}"},
714
+ {"%#v", reflect.ValueOf([]byte{}), "[]uint8{}"},
715
+ {"%#v", reflect.ValueOf([]uint8{}), "[]uint8{}"},
716
+ {"%#v", &[]byte{}, "&[]uint8{}"},
717
+ {"%#v", &[]byte{}, "&[]uint8{}"},
718
+ {"%#v", [3]byte{}, "[3]uint8{0x0, 0x0, 0x0}"},
719
+ {"%#v", [3]uint8{}, "[3]uint8{0x0, 0x0, 0x0}"},
720
+
721
+ // slices with other formats
722
+ {"%#x", []int{1, 2, 15}, `[0x1 0x2 0xf]`},
723
+ {"%x", []int{1, 2, 15}, `[1 2 f]`},
724
+ {"%d", []int{1, 2, 15}, `[1 2 15]`},
725
+ {"%d", []byte{1, 2, 15}, `[1 2 15]`},
726
+ {"%q", []string{"a", "b"}, `["a" "b"]`},
727
+ {"% 02x", []byte{1}, "01"},
728
+ {"% 02x", []byte{1, 2, 3}, "01 02 03"},
729
+
730
+ // Padding with byte slices.
731
+ {"%2x", []byte{}, " "},
732
+ {"%#2x", []byte{}, " "},
733
+ {"% 02x", []byte{}, "00"},
734
+ {"%# 02x", []byte{}, "00"},
735
+ {"%-2x", []byte{}, " "},
736
+ {"%-02x", []byte{}, " "},
737
+ {"%8x", []byte{0xab}, " ab"},
738
+ {"% 8x", []byte{0xab}, " ab"},
739
+ {"%#8x", []byte{0xab}, " 0xab"},
740
+ {"%# 8x", []byte{0xab}, " 0xab"},
741
+ {"%08x", []byte{0xab}, "000000ab"},
742
+ {"% 08x", []byte{0xab}, "000000ab"},
743
+ {"%#08x", []byte{0xab}, "00000xab"},
744
+ {"%# 08x", []byte{0xab}, "00000xab"},
745
+ {"%10x", []byte{0xab, 0xcd}, " abcd"},
746
+ {"% 10x", []byte{0xab, 0xcd}, " ab cd"},
747
+ {"%#10x", []byte{0xab, 0xcd}, " 0xabcd"},
748
+ {"%# 10x", []byte{0xab, 0xcd}, " 0xab 0xcd"},
749
+ {"%010x", []byte{0xab, 0xcd}, "000000abcd"},
750
+ {"% 010x", []byte{0xab, 0xcd}, "00000ab cd"},
751
+ {"%#010x", []byte{0xab, 0xcd}, "00000xabcd"},
752
+ {"%# 010x", []byte{0xab, 0xcd}, "00xab 0xcd"},
753
+ {"%-10X", []byte{0xab}, "AB "},
754
+ {"% -010X", []byte{0xab}, "AB "},
755
+ {"%#-10X", []byte{0xab, 0xcd}, "0XABCD "},
756
+ {"%# -010X", []byte{0xab, 0xcd}, "0XAB 0XCD "},
757
+ // Same for strings
758
+ {"%2x", "", " "},
759
+ {"%#2x", "", " "},
760
+ {"% 02x", "", "00"},
761
+ {"%# 02x", "", "00"},
762
+ {"%-2x", "", " "},
763
+ {"%-02x", "", " "},
764
+ {"%8x", "\xab", " ab"},
765
+ {"% 8x", "\xab", " ab"},
766
+ {"%#8x", "\xab", " 0xab"},
767
+ {"%# 8x", "\xab", " 0xab"},
768
+ {"%08x", "\xab", "000000ab"},
769
+ {"% 08x", "\xab", "000000ab"},
770
+ {"%#08x", "\xab", "00000xab"},
771
+ {"%# 08x", "\xab", "00000xab"},
772
+ {"%10x", "\xab\xcd", " abcd"},
773
+ {"% 10x", "\xab\xcd", " ab cd"},
774
+ {"%#10x", "\xab\xcd", " 0xabcd"},
775
+ {"%# 10x", "\xab\xcd", " 0xab 0xcd"},
776
+ {"%010x", "\xab\xcd", "000000abcd"},
777
+ {"% 010x", "\xab\xcd", "00000ab cd"},
778
+ {"%#010x", "\xab\xcd", "00000xabcd"},
779
+ {"%# 010x", "\xab\xcd", "00xab 0xcd"},
780
+ {"%-10X", "\xab", "AB "},
781
+ {"% -010X", "\xab", "AB "},
782
+ {"%#-10X", "\xab\xcd", "0XABCD "},
783
+ {"%# -010X", "\xab\xcd", "0XAB 0XCD "},
784
+
785
+ // renamings
786
+ {"%v", renamedBool(true), "true"},
787
+ {"%d", renamedBool(true), "%!d(message.renamedBool=true)"},
788
+ {"%o", renamedInt(8), "10"},
789
+ {"%d", renamedInt8(-9), "-9"},
790
+ {"%v", renamedInt16(10), "10"},
791
+ {"%v", renamedInt32(-11), "-11"},
792
+ {"%X", renamedInt64(255), "FF"},
793
+ {"%v", renamedUint(13), "13"},
794
+ {"%o", renamedUint8(14), "16"},
795
+ {"%X", renamedUint16(15), "F"},
796
+ {"%d", renamedUint32(16), "16"},
797
+ {"%X", renamedUint64(17), "11"},
798
+ {"%o", renamedUintptr(18), "22"},
799
+ {"%x", renamedString("thing"), "7468696e67"},
800
+ {"%d", renamedBytes([]byte{1, 2, 15}), `[1 2 15]`},
801
+ {"%q", renamedBytes([]byte("hello")), `"hello"`},
802
+ {"%x", []renamedUint8{'h', 'e', 'l', 'l', 'o'}, "68656c6c6f"},
803
+ {"%X", []renamedUint8{'h', 'e', 'l', 'l', 'o'}, "68656C6C6F"},
804
+ {"%s", []renamedUint8{'h', 'e', 'l', 'l', 'o'}, "hello"},
805
+ {"%q", []renamedUint8{'h', 'e', 'l', 'l', 'o'}, `"hello"`},
806
+ {"%v", renamedFloat32(22), "22"},
807
+ {"%v", renamedFloat64(33), "33"},
808
+ {"%v", renamedComplex64(3 + 4i), "(3+4i)"},
809
+ {"%v", renamedComplex128(4 - 3i), "(4-3i)"},
810
+
811
+ // Formatter
812
+ {"%x", F(1), "<x=F(1)>"},
813
+ {"%x", G(2), "2"},
814
+ {"%+v", S{F(4), G(5)}, "{F:<v=F(4)> G:5}"},
815
+
816
+ // GoStringer
817
+ {"%#v", G(6), "GoString(6)"},
818
+ {"%#v", S{F(7), G(8)}, "message.S{F:<v=F(7)>, G:GoString(8)}"},
819
+
820
+ // %T
821
+ {"%T", byte(0), "uint8"},
822
+ {"%T", reflect.ValueOf(nil), "reflect.Value"},
823
+ {"%T", (4 - 3i), "complex128"},
824
+ {"%T", renamedComplex128(4 - 3i), "message.renamedComplex128"},
825
+ {"%T", intVar, "int"},
826
+ {"%6T", &intVar, " *int"},
827
+ {"%10T", nil, " <nil>"},
828
+ {"%-10T", nil, "<nil> "},
829
+
830
+ // %p with pointers
831
+ {"%p", (*int)(nil), "0x0"},
832
+ {"%#p", (*int)(nil), "0"},
833
+ {"%p", &intVar, "0xPTR"},
834
+ {"%#p", &intVar, "PTR"},
835
+ {"%p", &array, "0xPTR"},
836
+ {"%p", &slice, "0xPTR"},
837
+ {"%8.2p", (*int)(nil), " 0x00"},
838
+ {"%-20.16p", &intVar, "0xPTR "},
839
+ // %p on non-pointers
840
+ {"%p", make(chan int), "0xPTR"},
841
+ {"%p", make(map[int]int), "0xPTR"},
842
+ {"%p", func() {}, "0xPTR"},
843
+ {"%p", 27, "%!p(int=27)"}, // not a pointer at all
844
+ {"%p", nil, "%!p(<nil>)"}, // nil on its own has no type ...
845
+ {"%#p", nil, "%!p(<nil>)"}, // ... and hence is not a pointer type.
846
+ // pointers with specified base
847
+ {"%b", &intVar, "PTR_b"},
848
+ {"%d", &intVar, "PTR_d"},
849
+ {"%o", &intVar, "PTR_o"},
850
+ {"%x", &intVar, "PTR_x"},
851
+ {"%X", &intVar, "PTR_X"},
852
+ // %v on pointers
853
+ {"%v", nil, "<nil>"},
854
+ {"%#v", nil, "<nil>"},
855
+ {"%v", (*int)(nil), "<nil>"},
856
+ {"%#v", (*int)(nil), "(*int)(nil)"},
857
+ {"%v", &intVar, "0xPTR"},
858
+ {"%#v", &intVar, "(*int)(0xPTR)"},
859
+ {"%8.2v", (*int)(nil), " <nil>"},
860
+ {"%-20.16v", &intVar, "0xPTR "},
861
+ // string method on pointer
862
+ {"%s", &pValue, "String(p)"}, // String method...
863
+ {"%p", &pValue, "0xPTR"}, // ... is not called with %p.
864
+
865
+ // %d on Stringer should give integer if possible
866
+ {"%s", time.Time{}.Month(), "January"},
867
+ {"%d", time.Time{}.Month(), "1"},
868
+
869
+ // erroneous things
870
+ {"%s %", "hello", "hello %!(NOVERB)"},
871
+ {"%s %.2", "hello", "hello %!(NOVERB)"},
872
+
873
+ // The "<nil>" show up because maps are printed by
874
+ // first obtaining a list of keys and then looking up
875
+ // each key. Since NaNs can be map keys but cannot
876
+ // be fetched directly, the lookup fails and returns a
877
+ // zero reflect.Value, which formats as <nil>.
878
+ // This test is just to check that it shows the two NaNs at all.
879
+ {"%v", map[float64]int{NaN: 1, NaN: 2}, "map[NaN:<nil> NaN:<nil>]"},
880
+
881
+ // Comparison of padding rules with C printf.
882
+ /*
883
+ C program:
884
+ #include <stdio.h>
885
+
886
+ char *format[] = {
887
+ "[%.2f]",
888
+ "[% .2f]",
889
+ "[%+.2f]",
890
+ "[%7.2f]",
891
+ "[% 7.2f]",
892
+ "[%+7.2f]",
893
+ "[% +7.2f]",
894
+ "[%07.2f]",
895
+ "[% 07.2f]",
896
+ "[%+07.2f]",
897
+ "[% +07.2f]"
898
+ };
899
+
900
+ int main(void) {
901
+ int i;
902
+ for(i = 0; i < 11; i++) {
903
+ printf("%s: ", format[i]);
904
+ printf(format[i], 1.0);
905
+ printf(" ");
906
+ printf(format[i], -1.0);
907
+ printf("\n");
908
+ }
909
+ }
910
+
911
+ Output:
912
+ [%.2f]: [1.00] [-1.00]
913
+ [% .2f]: [ 1.00] [-1.00]
914
+ [%+.2f]: [+1.00] [-1.00]
915
+ [%7.2f]: [ 1.00] [ -1.00]
916
+ [% 7.2f]: [ 1.00] [ -1.00]
917
+ [%+7.2f]: [ +1.00] [ -1.00]
918
+ [% +7.2f]: [ +1.00] [ -1.00]
919
+ [%07.2f]: [0001.00] [-001.00]
920
+ [% 07.2f]: [ 001.00] [-001.00]
921
+ [%+07.2f]: [+001.00] [-001.00]
922
+ [% +07.2f]: [+001.00] [-001.00]
923
+
924
+ */
925
+ {"%.2f", 1.0, "1.00"},
926
+ {"%.2f", -1.0, "-1.00"},
927
+ {"% .2f", 1.0, " 1.00"},
928
+ {"% .2f", -1.0, "-1.00"},
929
+ {"%+.2f", 1.0, "+1.00"},
930
+ {"%+.2f", -1.0, "-1.00"},
931
+ {"%7.2f", 1.0, " 1.00"},
932
+ {"%7.2f", -1.0, " -1.00"},
933
+ {"% 7.2f", 1.0, " 1.00"},
934
+ {"% 7.2f", -1.0, " -1.00"},
935
+ {"%+7.2f", 1.0, " +1.00"},
936
+ {"%+7.2f", -1.0, " -1.00"},
937
+ {"% +7.2f", 1.0, " +1.00"},
938
+ {"% +7.2f", -1.0, " -1.00"},
939
+ // Padding with 0's indicates minimum number of integer digits minus the
940
+ // period, if present, and minus the sign if it is fixed.
941
+ // TODO: consider making this number the number of significant digits.
942
+ {"%07.2f", 1.0, "0,001.00"},
943
+ {"%07.2f", -1.0, "-0,001.00"},
944
+ {"% 07.2f", 1.0, " 001.00"},
945
+ {"% 07.2f", -1.0, "-001.00"},
946
+ {"%+07.2f", 1.0, "+001.00"},
947
+ {"%+07.2f", -1.0, "-001.00"},
948
+ {"% +07.2f", 1.0, "+001.00"},
949
+ {"% +07.2f", -1.0, "-001.00"},
950
+
951
+ // Complex numbers: exhaustively tested in TestComplexFormatting.
952
+ {"%7.2f", 1 + 2i, "( 1.00 +2.00i)"},
953
+ {"%+07.2f", -1 - 2i, "(-001.00-002.00i)"},
954
+
955
+ // Use spaces instead of zero if padding to the right.
956
+ {"%0-5s", "abc", "abc "},
957
+ {"%-05.1f", 1.0, "1.0 "},
958
+
959
+ // float and complex formatting should not change the padding width
960
+ // for other elements. See issue 14642.
961
+ {"%06v", []interface{}{+10.0, 10}, "[000,010 000,010]"},
962
+ {"%06v", []interface{}{-10.0, 10}, "[-000,010 000,010]"},
963
+ {"%06v", []interface{}{+10.0 + 10i, 10}, "[(000,010+00,010i) 000,010]"},
964
+ {"%06v", []interface{}{-10.0 + 10i, 10}, "[(-000,010+00,010i) 000,010]"},
965
+
966
+ // integer formatting should not alter padding for other elements.
967
+ {"%03.6v", []interface{}{1, 2.0, "x"}, "[000,001 002 00x]"},
968
+ {"%03.0v", []interface{}{0, 2.0, "x"}, "[ 002 000]"},
969
+
970
+ // Complex fmt used to leave the plus flag set for future entries in the array
971
+ // causing +2+0i and +3+0i instead of 2+0i and 3+0i.
972
+ {"%v", []complex64{1, 2, 3}, "[(1+0i) (2+0i) (3+0i)]"},
973
+ {"%v", []complex128{1, 2, 3}, "[(1+0i) (2+0i) (3+0i)]"},
974
+
975
+ // Incomplete format specification caused crash.
976
+ {"%.", 3, "%!.(int=3)"},
977
+
978
+ // Padding for complex numbers. Has been bad, then fixed, then bad again.
979
+ {"%+10.2f", +104.66 + 440.51i, "( +104.66 +440.51i)"},
980
+ {"%+10.2f", -104.66 + 440.51i, "( -104.66 +440.51i)"},
981
+ {"%+10.2f", +104.66 - 440.51i, "( +104.66 -440.51i)"},
982
+ {"%+10.2f", -104.66 - 440.51i, "( -104.66 -440.51i)"},
983
+ {"%010.2f", +104.66 + 440.51i, "(0,000,104.66+000,440.51i)"},
984
+ {"%+010.2f", +104.66 + 440.51i, "(+000,104.66+000,440.51i)"},
985
+ {"%+010.2f", -104.66 + 440.51i, "(-000,104.66+000,440.51i)"},
986
+ {"%+010.2f", +104.66 - 440.51i, "(+000,104.66-000,440.51i)"},
987
+ {"%+010.2f", -104.66 - 440.51i, "(-000,104.66-000,440.51i)"},
988
+
989
+ // []T where type T is a byte with a Stringer method.
990
+ {"%v", byteStringerSlice, "[X X X X X]"},
991
+ {"%s", byteStringerSlice, "hello"},
992
+ {"%q", byteStringerSlice, "\"hello\""},
993
+ {"%x", byteStringerSlice, "68656c6c6f"},
994
+ {"%X", byteStringerSlice, "68656C6C6F"},
995
+ {"%#v", byteStringerSlice, "[]message.byteStringer{0x68, 0x65, 0x6c, 0x6c, 0x6f}"},
996
+
997
+ // And the same for Formatter.
998
+ {"%v", byteFormatterSlice, "[X X X X X]"},
999
+ {"%s", byteFormatterSlice, "hello"},
1000
+ {"%q", byteFormatterSlice, "\"hello\""},
1001
+ {"%x", byteFormatterSlice, "68656c6c6f"},
1002
+ {"%X", byteFormatterSlice, "68656C6C6F"},
1003
+ // This next case seems wrong, but the docs say the Formatter wins here.
1004
+ {"%#v", byteFormatterSlice, "[]message.byteFormatter{X, X, X, X, X}"},
1005
+
1006
+ // reflect.Value handled specially in Go 1.5, making it possible to
1007
+ // see inside non-exported fields (which cannot be accessed with Interface()).
1008
+ // Issue 8965.
1009
+ {"%v", reflect.ValueOf(A{}).Field(0).String(), "<int Value>"}, // Equivalent to the old way.
1010
+ {"%v", reflect.ValueOf(A{}).Field(0), "0"}, // Sees inside the field.
1011
+
1012
+ // verbs apply to the extracted value too.
1013
+ {"%s", reflect.ValueOf("hello"), "hello"},
1014
+ {"%q", reflect.ValueOf("hello"), `"hello"`},
1015
+ {"%#04x", reflect.ValueOf(256), "0x0100"},
1016
+
1017
+ // invalid reflect.Value doesn't crash.
1018
+ {"%v", reflect.Value{}, "<invalid reflect.Value>"},
1019
+ {"%v", &reflect.Value{}, "<invalid Value>"},
1020
+ {"%v", SI{reflect.Value{}}, "{<invalid Value>}"},
1021
+
1022
+ // Tests to check that not supported verbs generate an error string.
1023
+ {"%☠", nil, "%!☠(<nil>)"},
1024
+ {"%☠", interface{}(nil), "%!☠(<nil>)"},
1025
+ {"%☠", int(0), "%!☠(int=0)"},
1026
+ {"%☠", uint(0), "%!☠(uint=0)"},
1027
+ {"%☠", []byte{0, 1}, "[%!☠(uint8=0) %!☠(uint8=1)]"},
1028
+ {"%☠", []uint8{0, 1}, "[%!☠(uint8=0) %!☠(uint8=1)]"},
1029
+ {"%☠", [1]byte{0}, "[%!☠(uint8=0)]"},
1030
+ {"%☠", [1]uint8{0}, "[%!☠(uint8=0)]"},
1031
+ {"%☠", "hello", "%!☠(string=hello)"},
1032
+ {"%☠", 1.2345678, "%!☠(float64=1.2345678)"},
1033
+ {"%☠", float32(1.2345678), "%!☠(float32=1.2345678)"},
1034
+ {"%☠", 1.2345678 + 1.2345678i, "%!☠(complex128=(1.2345678+1.2345678i))"},
1035
+ {"%☠", complex64(1.2345678 + 1.2345678i), "%!☠(complex64=(1.2345678+1.2345678i))"},
1036
+ {"%☠", &intVar, "%!☠(*int=0xPTR)"},
1037
+ {"%☠", make(chan int), "%!☠(chan int=0xPTR)"},
1038
+ {"%☠", func() {}, "%!☠(func()=0xPTR)"},
1039
+ {"%☠", reflect.ValueOf(renamedInt(0)), "%!☠(message.renamedInt=0)"},
1040
+ {"%☠", SI{renamedInt(0)}, "{%!☠(message.renamedInt=0)}"},
1041
+ {"%☠", &[]interface{}{I(1), G(2)}, "&[%!☠(message.I=1) %!☠(message.G=2)]"},
1042
+ {"%☠", SI{&[]interface{}{I(1), G(2)}}, "{%!☠(*[]interface {}=&[1 2])}"},
1043
+ {"%☠", reflect.Value{}, "<invalid reflect.Value>"},
1044
+ {"%☠", map[float64]int{NaN: 1}, "map[%!☠(float64=NaN):%!☠(<nil>)]"},
1045
+ }
1046
+
1047
+ // zeroFill generates zero-filled strings of the specified width. The length
1048
+ // of the suffix (but not the prefix) is compensated for in the width calculation.
1049
+ func zeroFill(prefix string, width int, suffix string) string {
1050
+ return prefix + strings.Repeat("0", width-len(suffix)) + suffix
1051
+ }
1052
+
1053
+ func TestSprintf(t *testing.T) {
1054
+ p := NewPrinter(language.Und)
1055
+ for _, tt := range fmtTests {
1056
+ t.Run(fmt.Sprint(tt.fmt, "/", tt.val), func(t *testing.T) {
1057
+ s := p.Sprintf(tt.fmt, tt.val)
1058
+ i := strings.Index(tt.out, "PTR")
1059
+ if i >= 0 && i < len(s) {
1060
+ var pattern, chars string
1061
+ switch {
1062
+ case strings.HasPrefix(tt.out[i:], "PTR_b"):
1063
+ pattern = "PTR_b"
1064
+ chars = "01"
1065
+ case strings.HasPrefix(tt.out[i:], "PTR_o"):
1066
+ pattern = "PTR_o"
1067
+ chars = "01234567"
1068
+ case strings.HasPrefix(tt.out[i:], "PTR_d"):
1069
+ pattern = "PTR_d"
1070
+ chars = "0123456789"
1071
+ case strings.HasPrefix(tt.out[i:], "PTR_x"):
1072
+ pattern = "PTR_x"
1073
+ chars = "0123456789abcdef"
1074
+ case strings.HasPrefix(tt.out[i:], "PTR_X"):
1075
+ pattern = "PTR_X"
1076
+ chars = "0123456789ABCDEF"
1077
+ default:
1078
+ pattern = "PTR"
1079
+ chars = "0123456789abcdefABCDEF"
1080
+ }
1081
+ p := s[:i] + pattern
1082
+ for j := i; j < len(s); j++ {
1083
+ if !strings.ContainsRune(chars, rune(s[j])) {
1084
+ p += s[j:]
1085
+ break
1086
+ }
1087
+ }
1088
+ s = p
1089
+ }
1090
+ if s != tt.out {
1091
+ if _, ok := tt.val.(string); ok {
1092
+ // Don't requote the already-quoted strings.
1093
+ // It's too confusing to read the errors.
1094
+ t.Errorf("Sprintf(%q, %q) = <%s> want <%s>", tt.fmt, tt.val, s, tt.out)
1095
+ } else {
1096
+ t.Errorf("Sprintf(%q, %v) = %q want %q", tt.fmt, tt.val, s, tt.out)
1097
+ }
1098
+ }
1099
+ })
1100
+ }
1101
+ }
1102
+
1103
+ var f float64
1104
+
1105
+ // TestComplexFormatting checks that a complex always formats to the same
1106
+ // thing as if done by hand with two singleton prints.
1107
+ func TestComplexFormatting(t *testing.T) {
1108
+ var yesNo = []bool{true, false}
1109
+ var values = []float64{1, 0, -1, posInf, negInf, NaN}
1110
+ p := NewPrinter(language.Und)
1111
+ for _, plus := range yesNo {
1112
+ for _, zero := range yesNo {
1113
+ for _, space := range yesNo {
1114
+ for _, char := range "fFeEgG" {
1115
+ realFmt := "%"
1116
+ if zero {
1117
+ realFmt += "0"
1118
+ }
1119
+ if space {
1120
+ realFmt += " "
1121
+ }
1122
+ if plus {
1123
+ realFmt += "+"
1124
+ }
1125
+ realFmt += "10.2"
1126
+ realFmt += string(char)
1127
+ // Imaginary part always has a sign, so force + and ignore space.
1128
+ imagFmt := "%"
1129
+ if zero {
1130
+ imagFmt += "0"
1131
+ }
1132
+ imagFmt += "+"
1133
+ imagFmt += "10.2"
1134
+ imagFmt += string(char)
1135
+ for _, realValue := range values {
1136
+ for _, imagValue := range values {
1137
+ one := p.Sprintf(realFmt, complex(realValue, imagValue))
1138
+ two := p.Sprintf("("+realFmt+imagFmt+"i)", realValue, imagValue)
1139
+ if math.IsNaN(imagValue) {
1140
+ p := len(two) - len("NaNi)") - 1
1141
+ if two[p] == ' ' {
1142
+ two = two[:p] + "+" + two[p+1:]
1143
+ } else {
1144
+ two = two[:p+1] + "+" + two[p+1:]
1145
+ }
1146
+ }
1147
+ if one != two {
1148
+ t.Error(f, one, two)
1149
+ }
1150
+ }
1151
+ }
1152
+ }
1153
+ }
1154
+ }
1155
+ }
1156
+ }
1157
+
1158
+ type SE []interface{} // slice of empty; notational compactness.
1159
+
1160
+ var reorderTests = []struct {
1161
+ format string
1162
+ args SE
1163
+ out string
1164
+ }{
1165
+ {"%[1]d", SE{1}, "1"},
1166
+ {"%[2]d", SE{2, 1}, "1"},
1167
+ {"%[2]d %[1]d", SE{1, 2}, "2 1"},
1168
+ {"%[2]*[1]d", SE{2, 5}, " 2"},
1169
+ {"%6.2f", SE{12.0}, " 12.00"}, // Explicit version of next line.
1170
+ {"%[3]*.[2]*[1]f", SE{12.0, 2, 6}, " 12.00"},
1171
+ {"%[1]*.[2]*[3]f", SE{6, 2, 12.0}, " 12.00"},
1172
+ {"%10f", SE{12.0}, " 12.000000"},
1173
+ {"%[1]*[3]f", SE{10, 99, 12.0}, " 12.000000"},
1174
+ {"%.6f", SE{12.0}, "12.000000"}, // Explicit version of next line.
1175
+ {"%.[1]*[3]f", SE{6, 99, 12.0}, "12.000000"},
1176
+ {"%6.f", SE{12.0}, " 12"}, // // Explicit version of next line; empty precision means zero.
1177
+ {"%[1]*.[3]f", SE{6, 3, 12.0}, " 12"},
1178
+ // An actual use! Print the same arguments twice.
1179
+ {"%d %d %d %#[1]o %#o %#o", SE{11, 12, 13}, "11 12 13 013 014 015"},
1180
+
1181
+ // Erroneous cases.
1182
+ {"%[d", SE{2, 1}, "%!d(BADINDEX)"},
1183
+ {"%]d", SE{2, 1}, "%!](int=2)d%!(EXTRA int=1)"},
1184
+ {"%[]d", SE{2, 1}, "%!d(BADINDEX)"},
1185
+ {"%[-3]d", SE{2, 1}, "%!d(BADINDEX)"},
1186
+ {"%[99]d", SE{2, 1}, "%!d(BADINDEX)"},
1187
+ {"%[3]", SE{2, 1}, "%!(NOVERB)"},
1188
+ {"%[1].2d", SE{5, 6}, "%!d(BADINDEX)"},
1189
+ {"%[1]2d", SE{2, 1}, "%!d(BADINDEX)"},
1190
+ {"%3.[2]d", SE{7}, "%!d(BADINDEX)"},
1191
+ {"%.[2]d", SE{7}, "%!d(BADINDEX)"},
1192
+ {"%d %d %d %#[1]o %#o %#o %#o", SE{11, 12, 13}, "11 12 13 013 014 015 %!o(MISSING)"},
1193
+ {"%[5]d %[2]d %d", SE{1, 2, 3}, "%!d(BADINDEX) 2 3"},
1194
+ {"%d %[3]d %d", SE{1, 2}, "1 %!d(BADINDEX) 2"}, // Erroneous index does not affect sequence.
1195
+ {"%.[]", SE{}, "%!](BADINDEX)"}, // Issue 10675
1196
+ {"%.-3d", SE{42}, "%!-(int=42)3d"}, // TODO: Should this set return better error messages?
1197
+ // The following messages are interpreted as if there is no substitution,
1198
+ // in which case it is okay to have extra arguments. This is different
1199
+ // semantics from the fmt package.
1200
+ {"%2147483648d", SE{42}, "%!(NOVERB)"},
1201
+ {"%-2147483648d", SE{42}, "%!(NOVERB)"},
1202
+ {"%.2147483648d", SE{42}, "%!(NOVERB)"},
1203
+ }
1204
+
1205
+ func TestReorder(t *testing.T) {
1206
+ p := NewPrinter(language.Und)
1207
+ for _, tc := range reorderTests {
1208
+ t.Run(fmt.Sprint(tc.format, "/", tc.args), func(t *testing.T) {
1209
+ s := p.Sprintf(tc.format, tc.args...)
1210
+ if s != tc.out {
1211
+ t.Errorf("Sprintf(%q, %v) = %q want %q", tc.format, tc.args, s, tc.out)
1212
+ }
1213
+ })
1214
+ }
1215
+ }
1216
+
1217
+ func BenchmarkSprintfPadding(b *testing.B) {
1218
+ b.RunParallel(func(pb *testing.PB) {
1219
+ p := NewPrinter(language.English)
1220
+ for pb.Next() {
1221
+ p.Sprintf("%16f", 1.0)
1222
+ }
1223
+ })
1224
+ }
1225
+
1226
+ func BenchmarkSprintfEmpty(b *testing.B) {
1227
+ b.RunParallel(func(pb *testing.PB) {
1228
+ p := NewPrinter(language.English)
1229
+ for pb.Next() {
1230
+ p.Sprintf("")
1231
+ }
1232
+ })
1233
+ }
1234
+
1235
+ func BenchmarkSprintfString(b *testing.B) {
1236
+ b.RunParallel(func(pb *testing.PB) {
1237
+ p := NewPrinter(language.English)
1238
+ for pb.Next() {
1239
+ p.Sprintf("%s", "hello")
1240
+ }
1241
+ })
1242
+ }
1243
+
1244
+ func BenchmarkSprintfTruncateString(b *testing.B) {
1245
+ b.RunParallel(func(pb *testing.PB) {
1246
+ p := NewPrinter(language.English)
1247
+ for pb.Next() {
1248
+ p.Sprintf("%.3s", "日本語日本語日本語")
1249
+ }
1250
+ })
1251
+ }
1252
+
1253
+ func BenchmarkSprintfQuoteString(b *testing.B) {
1254
+ b.RunParallel(func(pb *testing.PB) {
1255
+ p := NewPrinter(language.English)
1256
+ for pb.Next() {
1257
+ p.Sprintf("%q", "日本語日本語日本語")
1258
+ }
1259
+ })
1260
+ }
1261
+
1262
+ func BenchmarkSprintfInt(b *testing.B) {
1263
+ b.RunParallel(func(pb *testing.PB) {
1264
+ p := NewPrinter(language.English)
1265
+ for pb.Next() {
1266
+ p.Sprintf("%d", 5)
1267
+ }
1268
+ })
1269
+ }
1270
+
1271
+ func BenchmarkSprintfIntInt(b *testing.B) {
1272
+ b.RunParallel(func(pb *testing.PB) {
1273
+ p := NewPrinter(language.English)
1274
+ for pb.Next() {
1275
+ p.Sprintf("%d %d", 5, 6)
1276
+ }
1277
+ })
1278
+ }
1279
+
1280
+ func BenchmarkSprintfPrefixedInt(b *testing.B) {
1281
+ b.RunParallel(func(pb *testing.PB) {
1282
+ p := NewPrinter(language.English)
1283
+ for pb.Next() {
1284
+ p.Sprintf("This is some meaningless prefix text that needs to be scanned %d", 6)
1285
+ }
1286
+ })
1287
+ }
1288
+
1289
+ func BenchmarkSprintfFloat(b *testing.B) {
1290
+ b.RunParallel(func(pb *testing.PB) {
1291
+ p := NewPrinter(language.English)
1292
+ for pb.Next() {
1293
+ p.Sprintf("%g", 5.23184)
1294
+ }
1295
+ })
1296
+ }
1297
+
1298
+ func BenchmarkSprintfComplex(b *testing.B) {
1299
+ b.RunParallel(func(pb *testing.PB) {
1300
+ p := NewPrinter(language.English)
1301
+ for pb.Next() {
1302
+ p.Sprintf("%f", 5.23184+5.23184i)
1303
+ }
1304
+ })
1305
+ }
1306
+
1307
+ func BenchmarkSprintfBoolean(b *testing.B) {
1308
+ b.RunParallel(func(pb *testing.PB) {
1309
+ p := NewPrinter(language.English)
1310
+ for pb.Next() {
1311
+ p.Sprintf("%t", true)
1312
+ }
1313
+ })
1314
+ }
1315
+
1316
+ func BenchmarkSprintfHexString(b *testing.B) {
1317
+ b.RunParallel(func(pb *testing.PB) {
1318
+ p := NewPrinter(language.English)
1319
+ for pb.Next() {
1320
+ p.Sprintf("% #x", "0123456789abcdef")
1321
+ }
1322
+ })
1323
+ }
1324
+
1325
+ func BenchmarkSprintfHexBytes(b *testing.B) {
1326
+ data := []byte("0123456789abcdef")
1327
+ b.RunParallel(func(pb *testing.PB) {
1328
+ p := NewPrinter(language.English)
1329
+ for pb.Next() {
1330
+ p.Sprintf("% #x", data)
1331
+ }
1332
+ })
1333
+ }
1334
+
1335
+ func BenchmarkSprintfBytes(b *testing.B) {
1336
+ data := []byte("0123456789abcdef")
1337
+ b.RunParallel(func(pb *testing.PB) {
1338
+ p := NewPrinter(language.English)
1339
+ for pb.Next() {
1340
+ p.Sprintf("%v", data)
1341
+ }
1342
+ })
1343
+ }
1344
+
1345
+ func BenchmarkSprintfStringer(b *testing.B) {
1346
+ stringer := I(12345)
1347
+ b.RunParallel(func(pb *testing.PB) {
1348
+ p := NewPrinter(language.English)
1349
+ for pb.Next() {
1350
+ p.Sprintf("%v", stringer)
1351
+ }
1352
+ })
1353
+ }
1354
+
1355
+ func BenchmarkSprintfStructure(b *testing.B) {
1356
+ s := &[]interface{}{SI{12345}, map[int]string{0: "hello"}}
1357
+ b.RunParallel(func(pb *testing.PB) {
1358
+ p := NewPrinter(language.English)
1359
+ for pb.Next() {
1360
+ p.Sprintf("%#v", s)
1361
+ }
1362
+ })
1363
+ }
1364
+
1365
+ func BenchmarkManyArgs(b *testing.B) {
1366
+ b.RunParallel(func(pb *testing.PB) {
1367
+ var buf bytes.Buffer
1368
+ p := NewPrinter(language.English)
1369
+ for pb.Next() {
1370
+ buf.Reset()
1371
+ p.Fprintf(&buf, "%2d/%2d/%2d %d:%d:%d %s %s\n", 3, 4, 5, 11, 12, 13, "hello", "world")
1372
+ }
1373
+ })
1374
+ }
1375
+
1376
+ func BenchmarkFprintInt(b *testing.B) {
1377
+ var buf bytes.Buffer
1378
+ p := NewPrinter(language.English)
1379
+ for i := 0; i < b.N; i++ {
1380
+ buf.Reset()
1381
+ p.Fprint(&buf, 123456)
1382
+ }
1383
+ }
1384
+
1385
+ func BenchmarkFprintfBytes(b *testing.B) {
1386
+ data := []byte(string("0123456789"))
1387
+ var buf bytes.Buffer
1388
+ p := NewPrinter(language.English)
1389
+ for i := 0; i < b.N; i++ {
1390
+ buf.Reset()
1391
+ p.Fprintf(&buf, "%s", data)
1392
+ }
1393
+ }
1394
+
1395
+ func BenchmarkFprintIntNoAlloc(b *testing.B) {
1396
+ var x interface{} = 123456
1397
+ var buf bytes.Buffer
1398
+ p := NewPrinter(language.English)
1399
+ for i := 0; i < b.N; i++ {
1400
+ buf.Reset()
1401
+ p.Fprint(&buf, x)
1402
+ }
1403
+ }
1404
+
1405
+ var mallocBuf bytes.Buffer
1406
+ var mallocPointer *int // A pointer so we know the interface value won't allocate.
1407
+
1408
+ var mallocTest = []struct {
1409
+ count int
1410
+ desc string
1411
+ fn func(p *Printer)
1412
+ }{
1413
+ {0, `Sprintf("")`, func(p *Printer) { p.Sprintf("") }},
1414
+ {1, `Sprintf("xxx")`, func(p *Printer) { p.Sprintf("xxx") }},
1415
+ {2, `Sprintf("%x")`, func(p *Printer) { p.Sprintf("%x", 7) }},
1416
+ {2, `Sprintf("%s")`, func(p *Printer) { p.Sprintf("%s", "hello") }},
1417
+ {3, `Sprintf("%x %x")`, func(p *Printer) { p.Sprintf("%x %x", 7, 112) }},
1418
+ {2, `Sprintf("%g")`, func(p *Printer) { p.Sprintf("%g", float32(3.14159)) }}, // TODO: Can this be 1?
1419
+ {1, `Fprintf(buf, "%s")`, func(p *Printer) { mallocBuf.Reset(); p.Fprintf(&mallocBuf, "%s", "hello") }},
1420
+ // If the interface value doesn't need to allocate, amortized allocation overhead should be zero.
1421
+ {0, `Fprintf(buf, "%x %x %x")`, func(p *Printer) {
1422
+ mallocBuf.Reset()
1423
+ p.Fprintf(&mallocBuf, "%x %x %x", mallocPointer, mallocPointer, mallocPointer)
1424
+ }},
1425
+ }
1426
+
1427
+ var _ bytes.Buffer
1428
+
1429
+ func TestCountMallocs(t *testing.T) {
1430
+ switch {
1431
+ case testing.Short():
1432
+ t.Skip("skipping malloc count in short mode")
1433
+ case runtime.GOMAXPROCS(0) > 1:
1434
+ t.Skip("skipping; GOMAXPROCS>1")
1435
+ // TODO: detect race detecter enabled.
1436
+ // case race.Enabled:
1437
+ // t.Skip("skipping malloc count under race detector")
1438
+ }
1439
+ p := NewPrinter(language.English)
1440
+ for _, mt := range mallocTest {
1441
+ mallocs := testing.AllocsPerRun(100, func() { mt.fn(p) })
1442
+ if got, max := mallocs, float64(mt.count); got > max {
1443
+ t.Errorf("%s: got %v allocs, want <=%v", mt.desc, got, max)
1444
+ }
1445
+ }
1446
+ }
1447
+
1448
+ type flagPrinter struct{}
1449
+
1450
+ func (flagPrinter) Format(f fmt.State, c rune) {
1451
+ s := "%"
1452
+ for i := 0; i < 128; i++ {
1453
+ if f.Flag(i) {
1454
+ s += string(i)
1455
+ }
1456
+ }
1457
+ if w, ok := f.Width(); ok {
1458
+ s += fmt.Sprintf("%d", w)
1459
+ }
1460
+ if p, ok := f.Precision(); ok {
1461
+ s += fmt.Sprintf(".%d", p)
1462
+ }
1463
+ s += string(c)
1464
+ io.WriteString(f, "["+s+"]")
1465
+ }
1466
+
1467
+ var flagtests = []struct {
1468
+ in string
1469
+ out string
1470
+ }{
1471
+ {"%a", "[%a]"},
1472
+ {"%-a", "[%-a]"},
1473
+ {"%+a", "[%+a]"},
1474
+ {"%#a", "[%#a]"},
1475
+ {"% a", "[% a]"},
1476
+ {"%0a", "[%0a]"},
1477
+ {"%1.2a", "[%1.2a]"},
1478
+ {"%-1.2a", "[%-1.2a]"},
1479
+ {"%+1.2a", "[%+1.2a]"},
1480
+ {"%-+1.2a", "[%+-1.2a]"},
1481
+ {"%-+1.2abc", "[%+-1.2a]bc"},
1482
+ {"%-1.2abc", "[%-1.2a]bc"},
1483
+ }
1484
+
1485
+ func TestFlagParser(t *testing.T) {
1486
+ var flagprinter flagPrinter
1487
+ for _, tt := range flagtests {
1488
+ s := NewPrinter(language.Und).Sprintf(tt.in, &flagprinter)
1489
+ if s != tt.out {
1490
+ t.Errorf("Sprintf(%q, &flagprinter) => %q, want %q", tt.in, s, tt.out)
1491
+ }
1492
+ }
1493
+ }
1494
+
1495
+ func TestStructPrinter(t *testing.T) {
1496
+ type T struct {
1497
+ a string
1498
+ b string
1499
+ c int
1500
+ }
1501
+ var s T
1502
+ s.a = "abc"
1503
+ s.b = "def"
1504
+ s.c = 123
1505
+ var tests = []struct {
1506
+ fmt string
1507
+ out string
1508
+ }{
1509
+ {"%v", "{abc def 123}"},
1510
+ {"%+v", "{a:abc b:def c:123}"},
1511
+ {"%#v", `message.T{a:"abc", b:"def", c:123}`},
1512
+ }
1513
+ p := NewPrinter(language.Und)
1514
+ for _, tt := range tests {
1515
+ out := p.Sprintf(tt.fmt, s)
1516
+ if out != tt.out {
1517
+ t.Errorf("Sprintf(%q, s) = %#q, want %#q", tt.fmt, out, tt.out)
1518
+ }
1519
+ // The same but with a pointer.
1520
+ out = p.Sprintf(tt.fmt, &s)
1521
+ if out != "&"+tt.out {
1522
+ t.Errorf("Sprintf(%q, &s) = %#q, want %#q", tt.fmt, out, "&"+tt.out)
1523
+ }
1524
+ }
1525
+ }
1526
+
1527
+ func TestSlicePrinter(t *testing.T) {
1528
+ p := NewPrinter(language.Und)
1529
+ slice := []int{}
1530
+ s := p.Sprint(slice)
1531
+ if s != "[]" {
1532
+ t.Errorf("empty slice printed as %q not %q", s, "[]")
1533
+ }
1534
+ slice = []int{1, 2, 3}
1535
+ s = p.Sprint(slice)
1536
+ if s != "[1 2 3]" {
1537
+ t.Errorf("slice: got %q expected %q", s, "[1 2 3]")
1538
+ }
1539
+ s = p.Sprint(&slice)
1540
+ if s != "&[1 2 3]" {
1541
+ t.Errorf("&slice: got %q expected %q", s, "&[1 2 3]")
1542
+ }
1543
+ }
1544
+
1545
+ // presentInMap checks map printing using substrings so we don't depend on the
1546
+ // print order.
1547
+ func presentInMap(s string, a []string, t *testing.T) {
1548
+ for i := 0; i < len(a); i++ {
1549
+ loc := strings.Index(s, a[i])
1550
+ if loc < 0 {
1551
+ t.Errorf("map print: expected to find %q in %q", a[i], s)
1552
+ }
1553
+ // make sure the match ends here
1554
+ loc += len(a[i])
1555
+ if loc >= len(s) || (s[loc] != ' ' && s[loc] != ']') {
1556
+ t.Errorf("map print: %q not properly terminated in %q", a[i], s)
1557
+ }
1558
+ }
1559
+ }
1560
+
1561
+ func TestMapPrinter(t *testing.T) {
1562
+ p := NewPrinter(language.Und)
1563
+ m0 := make(map[int]string)
1564
+ s := p.Sprint(m0)
1565
+ if s != "map[]" {
1566
+ t.Errorf("empty map printed as %q not %q", s, "map[]")
1567
+ }
1568
+ m1 := map[int]string{1: "one", 2: "two", 3: "three"}
1569
+ a := []string{"1:one", "2:two", "3:three"}
1570
+ presentInMap(p.Sprintf("%v", m1), a, t)
1571
+ presentInMap(p.Sprint(m1), a, t)
1572
+ // Pointer to map prints the same but with initial &.
1573
+ if !strings.HasPrefix(p.Sprint(&m1), "&") {
1574
+ t.Errorf("no initial & for address of map")
1575
+ }
1576
+ presentInMap(p.Sprintf("%v", &m1), a, t)
1577
+ presentInMap(p.Sprint(&m1), a, t)
1578
+ }
1579
+
1580
+ func TestEmptyMap(t *testing.T) {
1581
+ const emptyMapStr = "map[]"
1582
+ var m map[string]int
1583
+ p := NewPrinter(language.Und)
1584
+ s := p.Sprint(m)
1585
+ if s != emptyMapStr {
1586
+ t.Errorf("nil map printed as %q not %q", s, emptyMapStr)
1587
+ }
1588
+ m = make(map[string]int)
1589
+ s = p.Sprint(m)
1590
+ if s != emptyMapStr {
1591
+ t.Errorf("empty map printed as %q not %q", s, emptyMapStr)
1592
+ }
1593
+ }
1594
+
1595
+ // TestBlank checks that Sprint (and hence Print, Fprint) puts spaces in the
1596
+ // right places, that is, between arg pairs in which neither is a string.
1597
+ func TestBlank(t *testing.T) {
1598
+ p := NewPrinter(language.Und)
1599
+ got := p.Sprint("<", 1, ">:", 1, 2, 3, "!")
1600
+ expect := "<1>:1 2 3!"
1601
+ if got != expect {
1602
+ t.Errorf("got %q expected %q", got, expect)
1603
+ }
1604
+ }
1605
+
1606
+ // TestBlankln checks that Sprintln (and hence Println, Fprintln) puts spaces in
1607
+ // the right places, that is, between all arg pairs.
1608
+ func TestBlankln(t *testing.T) {
1609
+ p := NewPrinter(language.Und)
1610
+ got := p.Sprintln("<", 1, ">:", 1, 2, 3, "!")
1611
+ expect := "< 1 >: 1 2 3 !\n"
1612
+ if got != expect {
1613
+ t.Errorf("got %q expected %q", got, expect)
1614
+ }
1615
+ }
1616
+
1617
+ // TestFormatterPrintln checks Formatter with Sprint, Sprintln, Sprintf.
1618
+ func TestFormatterPrintln(t *testing.T) {
1619
+ p := NewPrinter(language.Und)
1620
+ f := F(1)
1621
+ expect := "<v=F(1)>\n"
1622
+ s := p.Sprint(f, "\n")
1623
+ if s != expect {
1624
+ t.Errorf("Sprint wrong with Formatter: expected %q got %q", expect, s)
1625
+ }
1626
+ s = p.Sprintln(f)
1627
+ if s != expect {
1628
+ t.Errorf("Sprintln wrong with Formatter: expected %q got %q", expect, s)
1629
+ }
1630
+ s = p.Sprintf("%v\n", f)
1631
+ if s != expect {
1632
+ t.Errorf("Sprintf wrong with Formatter: expected %q got %q", expect, s)
1633
+ }
1634
+ }
1635
+
1636
+ func args(a ...interface{}) []interface{} { return a }
1637
+
1638
+ var startests = []struct {
1639
+ fmt string
1640
+ in []interface{}
1641
+ out string
1642
+ }{
1643
+ {"%*d", args(4, 42), " 42"},
1644
+ {"%-*d", args(4, 42), "42 "},
1645
+ {"%*d", args(-4, 42), "42 "},
1646
+ {"%-*d", args(-4, 42), "42 "},
1647
+ {"%.*d", args(4, 42), "0,042"},
1648
+ {"%*.*d", args(8, 4, 42), " 0,042"},
1649
+ {"%0*d", args(4, 42), "0,042"},
1650
+ // Some non-int types for width. (Issue 10732).
1651
+ {"%0*d", args(uint(4), 42), "0,042"},
1652
+ {"%0*d", args(uint64(4), 42), "0,042"},
1653
+ {"%0*d", args('\x04', 42), "0,042"},
1654
+ {"%0*d", args(uintptr(4), 42), "0,042"},
1655
+
1656
+ // erroneous
1657
+ {"%*d", args(nil, 42), "%!(BADWIDTH)42"},
1658
+ {"%*d", args(int(1e7), 42), "%!(BADWIDTH)42"},
1659
+ {"%*d", args(int(-1e7), 42), "%!(BADWIDTH)42"},
1660
+ {"%.*d", args(nil, 42), "%!(BADPREC)42"},
1661
+ {"%.*d", args(-1, 42), "%!(BADPREC)42"},
1662
+ {"%.*d", args(int(1e7), 42), "%!(BADPREC)42"},
1663
+ {"%.*d", args(uint(1e7), 42), "%!(BADPREC)42"},
1664
+ {"%.*d", args(uint64(1<<63), 42), "%!(BADPREC)42"}, // Huge negative (-inf).
1665
+ {"%.*d", args(uint64(1<<64-1), 42), "%!(BADPREC)42"}, // Small negative (-1).
1666
+ {"%*d", args(5, "foo"), "%!d(string= foo)"},
1667
+ {"%*% %d", args(20, 5), "% 5"},
1668
+ {"%*", args(4), "%!(NOVERB)"},
1669
+ }
1670
+
1671
+ func TestWidthAndPrecision(t *testing.T) {
1672
+ p := NewPrinter(language.Und)
1673
+ for i, tt := range startests {
1674
+ t.Run(fmt.Sprint(tt.fmt, tt.in), func(t *testing.T) {
1675
+ s := p.Sprintf(tt.fmt, tt.in...)
1676
+ if s != tt.out {
1677
+ t.Errorf("#%d: %q: got %q expected %q", i, tt.fmt, s, tt.out)
1678
+ }
1679
+ })
1680
+ }
1681
+ }
1682
+
1683
+ // PanicS is a type that panics in String.
1684
+ type PanicS struct {
1685
+ message interface{}
1686
+ }
1687
+
1688
+ // Value receiver.
1689
+ func (p PanicS) String() string {
1690
+ panic(p.message)
1691
+ }
1692
+
1693
+ // PanicGo is a type that panics in GoString.
1694
+ type PanicGo struct {
1695
+ message interface{}
1696
+ }
1697
+
1698
+ // Value receiver.
1699
+ func (p PanicGo) GoString() string {
1700
+ panic(p.message)
1701
+ }
1702
+
1703
+ // PanicF is a type that panics in Format.
1704
+ type PanicF struct {
1705
+ message interface{}
1706
+ }
1707
+
1708
+ // Value receiver.
1709
+ func (p PanicF) Format(f fmt.State, c rune) {
1710
+ panic(p.message)
1711
+ }
1712
+
1713
+ var panictests = []struct {
1714
+ desc string
1715
+ fmt string
1716
+ in interface{}
1717
+ out string
1718
+ }{
1719
+ // String
1720
+ {"String", "%s", (*PanicS)(nil), "<nil>"}, // nil pointer special case
1721
+ {"String", "%s", PanicS{io.ErrUnexpectedEOF}, "%!s(PANIC=unexpected EOF)"},
1722
+ {"String", "%s", PanicS{3}, "%!s(PANIC=3)"},
1723
+ // GoString
1724
+ {"GoString", "%#v", (*PanicGo)(nil), "<nil>"}, // nil pointer special case
1725
+ {"GoString", "%#v", PanicGo{io.ErrUnexpectedEOF}, "%!v(PANIC=unexpected EOF)"},
1726
+ {"GoString", "%#v", PanicGo{3}, "%!v(PANIC=3)"},
1727
+ // Issue 18282. catchPanic should not clear fmtFlags permanently.
1728
+ {"Issue 18282", "%#v", []interface{}{PanicGo{3}, PanicGo{3}}, "[]interface {}{%!v(PANIC=3), %!v(PANIC=3)}"},
1729
+ // Format
1730
+ {"Format", "%s", (*PanicF)(nil), "<nil>"}, // nil pointer special case
1731
+ {"Format", "%s", PanicF{io.ErrUnexpectedEOF}, "%!s(PANIC=unexpected EOF)"},
1732
+ {"Format", "%s", PanicF{3}, "%!s(PANIC=3)"},
1733
+ }
1734
+
1735
+ func TestPanics(t *testing.T) {
1736
+ p := NewPrinter(language.Und)
1737
+ for i, tt := range panictests {
1738
+ t.Run(fmt.Sprint(tt.desc, "/", tt.fmt, "/", tt.in), func(t *testing.T) {
1739
+ s := p.Sprintf(tt.fmt, tt.in)
1740
+ if s != tt.out {
1741
+ t.Errorf("%d: %q: got %q expected %q", i, tt.fmt, s, tt.out)
1742
+ }
1743
+ })
1744
+ }
1745
+ }
1746
+
1747
+ // recurCount tests that erroneous String routine doesn't cause fatal recursion.
1748
+ var recurCount = 0
1749
+
1750
+ type Recur struct {
1751
+ i int
1752
+ failed *bool
1753
+ }
1754
+
1755
+ func (r *Recur) String() string {
1756
+ p := NewPrinter(language.Und)
1757
+ if recurCount++; recurCount > 10 {
1758
+ *r.failed = true
1759
+ return "FAIL"
1760
+ }
1761
+ // This will call badVerb. Before the fix, that would cause us to recur into
1762
+ // this routine to print %!p(value). Now we don't call the user's method
1763
+ // during an error.
1764
+ return p.Sprintf("recur@%p value: %d", r, r.i)
1765
+ }
1766
+
1767
+ func TestBadVerbRecursion(t *testing.T) {
1768
+ p := NewPrinter(language.Und)
1769
+ failed := false
1770
+ r := &Recur{3, &failed}
1771
+ p.Sprintf("recur@%p value: %d\n", &r, r.i)
1772
+ if failed {
1773
+ t.Error("fail with pointer")
1774
+ }
1775
+ failed = false
1776
+ r = &Recur{4, &failed}
1777
+ p.Sprintf("recur@%p, value: %d\n", r, r.i)
1778
+ if failed {
1779
+ t.Error("fail with value")
1780
+ }
1781
+ }
1782
+
1783
+ func TestNilDoesNotBecomeTyped(t *testing.T) {
1784
+ p := NewPrinter(language.Und)
1785
+ type A struct{}
1786
+ type B struct{}
1787
+ var a *A = nil
1788
+ var b B = B{}
1789
+ got := p.Sprintf("%s %s %s %s %s", nil, a, nil, b, nil) // go vet should complain about this line.
1790
+ const expect = "%!s(<nil>) %!s(*message.A=<nil>) %!s(<nil>) {} %!s(<nil>)"
1791
+ if got != expect {
1792
+ t.Errorf("expected:\n\t%q\ngot:\n\t%q", expect, got)
1793
+ }
1794
+ }
1795
+
1796
+ var formatterFlagTests = []struct {
1797
+ in string
1798
+ val interface{}
1799
+ out string
1800
+ }{
1801
+ // scalar values with the (unused by fmt) 'a' verb.
1802
+ {"%a", flagPrinter{}, "[%a]"},
1803
+ {"%-a", flagPrinter{}, "[%-a]"},
1804
+ {"%+a", flagPrinter{}, "[%+a]"},
1805
+ {"%#a", flagPrinter{}, "[%#a]"},
1806
+ {"% a", flagPrinter{}, "[% a]"},
1807
+ {"%0a", flagPrinter{}, "[%0a]"},
1808
+ {"%1.2a", flagPrinter{}, "[%1.2a]"},
1809
+ {"%-1.2a", flagPrinter{}, "[%-1.2a]"},
1810
+ {"%+1.2a", flagPrinter{}, "[%+1.2a]"},
1811
+ {"%-+1.2a", flagPrinter{}, "[%+-1.2a]"},
1812
+ {"%-+1.2abc", flagPrinter{}, "[%+-1.2a]bc"},
1813
+ {"%-1.2abc", flagPrinter{}, "[%-1.2a]bc"},
1814
+
1815
+ // composite values with the 'a' verb
1816
+ {"%a", [1]flagPrinter{}, "[[%a]]"},
1817
+ {"%-a", [1]flagPrinter{}, "[[%-a]]"},
1818
+ {"%+a", [1]flagPrinter{}, "[[%+a]]"},
1819
+ {"%#a", [1]flagPrinter{}, "[[%#a]]"},
1820
+ {"% a", [1]flagPrinter{}, "[[% a]]"},
1821
+ {"%0a", [1]flagPrinter{}, "[[%0a]]"},
1822
+ {"%1.2a", [1]flagPrinter{}, "[[%1.2a]]"},
1823
+ {"%-1.2a", [1]flagPrinter{}, "[[%-1.2a]]"},
1824
+ {"%+1.2a", [1]flagPrinter{}, "[[%+1.2a]]"},
1825
+ {"%-+1.2a", [1]flagPrinter{}, "[[%+-1.2a]]"},
1826
+ {"%-+1.2abc", [1]flagPrinter{}, "[[%+-1.2a]]bc"},
1827
+ {"%-1.2abc", [1]flagPrinter{}, "[[%-1.2a]]bc"},
1828
+
1829
+ // simple values with the 'v' verb
1830
+ {"%v", flagPrinter{}, "[%v]"},
1831
+ {"%-v", flagPrinter{}, "[%-v]"},
1832
+ {"%+v", flagPrinter{}, "[%+v]"},
1833
+ {"%#v", flagPrinter{}, "[%#v]"},
1834
+ {"% v", flagPrinter{}, "[% v]"},
1835
+ {"%0v", flagPrinter{}, "[%0v]"},
1836
+ {"%1.2v", flagPrinter{}, "[%1.2v]"},
1837
+ {"%-1.2v", flagPrinter{}, "[%-1.2v]"},
1838
+ {"%+1.2v", flagPrinter{}, "[%+1.2v]"},
1839
+ {"%-+1.2v", flagPrinter{}, "[%+-1.2v]"},
1840
+ {"%-+1.2vbc", flagPrinter{}, "[%+-1.2v]bc"},
1841
+ {"%-1.2vbc", flagPrinter{}, "[%-1.2v]bc"},
1842
+
1843
+ // composite values with the 'v' verb.
1844
+ {"%v", [1]flagPrinter{}, "[[%v]]"},
1845
+ {"%-v", [1]flagPrinter{}, "[[%-v]]"},
1846
+ {"%+v", [1]flagPrinter{}, "[[%+v]]"},
1847
+ {"%#v", [1]flagPrinter{}, "[1]message.flagPrinter{[%#v]}"},
1848
+ {"% v", [1]flagPrinter{}, "[[% v]]"},
1849
+ {"%0v", [1]flagPrinter{}, "[[%0v]]"},
1850
+ {"%1.2v", [1]flagPrinter{}, "[[%1.2v]]"},
1851
+ {"%-1.2v", [1]flagPrinter{}, "[[%-1.2v]]"},
1852
+ {"%+1.2v", [1]flagPrinter{}, "[[%+1.2v]]"},
1853
+ {"%-+1.2v", [1]flagPrinter{}, "[[%+-1.2v]]"},
1854
+ {"%-+1.2vbc", [1]flagPrinter{}, "[[%+-1.2v]]bc"},
1855
+ {"%-1.2vbc", [1]flagPrinter{}, "[[%-1.2v]]bc"},
1856
+ }
1857
+
1858
+ func TestFormatterFlags(t *testing.T) {
1859
+ p := NewPrinter(language.Und)
1860
+ for _, tt := range formatterFlagTests {
1861
+ s := p.Sprintf(tt.in, tt.val)
1862
+ if s != tt.out {
1863
+ t.Errorf("Sprintf(%q, %T) = %q, want %q", tt.in, tt.val, s, tt.out)
1864
+ }
1865
+ }
1866
+ }
1867
+
1868
+ func TestParsenum(t *testing.T) {
1869
+ testCases := []struct {
1870
+ s string
1871
+ start, end int
1872
+ num int
1873
+ isnum bool
1874
+ newi int
1875
+ }{
1876
+ {"a123", 0, 4, 0, false, 0},
1877
+ {"1234", 1, 1, 0, false, 1},
1878
+ {"123a", 0, 4, 123, true, 3},
1879
+ {"12a3", 0, 4, 12, true, 2},
1880
+ {"1234", 0, 4, 1234, true, 4},
1881
+ {"1a234", 1, 3, 0, false, 1},
1882
+ }
1883
+ for _, tt := range testCases {
1884
+ num, isnum, newi := parsenum(tt.s, tt.start, tt.end)
1885
+ if num != tt.num || isnum != tt.isnum || newi != tt.newi {
1886
+ t.Errorf("parsenum(%q, %d, %d) = %d, %v, %d, want %d, %v, %d", tt.s, tt.start, tt.end, num, isnum, newi, tt.num, tt.isnum, tt.newi)
1887
+ }
1888
+ }
1889
+ }