pre_go1.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <!--{
  2. "Title": "Pre-Go 1 Release History"
  3. }-->
  4. <p>
  5. This page summarizes the changes between stable releases of Go prior to Go 1.
  6. See the <a href="release.html">Release History</a> page for notes on recent releases.
  7. </p>
  8. <h2 id="r60">r60 (released 2011/09/07)</h2>
  9. <p>
  10. The r60 release corresponds to
  11. <code><a href="weekly.html#2011-08-17">weekly.2011-08-17</a></code>.
  12. This section highlights the most significant changes in this release.
  13. For a more detailed summary, see the
  14. <a href="weekly.html#2011-08-17">weekly release notes</a>.
  15. For complete information, see the
  16. <a href="//code.google.com/p/go/source/list?r=release-branch.r60">Mercurial change list</a>.
  17. </p>
  18. <h3 id="r60.lang">Language</h3>
  19. <p>
  20. An "else" block is now required to have braces except if the body of the "else"
  21. is another "if". Since gofmt always puts those braces in anyway,
  22. gofmt-formatted programs will not be affected.
  23. To fix other programs, run gofmt.
  24. </p>
  25. <h3 id="r60.pkg">Packages</h3>
  26. <p>
  27. <a href="/pkg/http/">Package http</a>'s URL parsing and query escaping code
  28. (such as <code>ParseURL</code> and <code>URLEscape</code>) has been moved to
  29. the new <a href="/pkg/url/">url package</a>, with several simplifications to
  30. the names. Client code can be updated automatically with gofix.
  31. </p>
  32. <p>
  33. <a href="/pkg/image/">Package image</a> has had significant changes made to the
  34. <code>Pix</code> field of struct types such as
  35. <a href="/pkg/image/#RGBA">image.RGBA</a> and
  36. <a href="/pkg/image/#NRGBA">image.NRGBA</a>.
  37. The <a href="/pkg/image/#Image">image.Image</a> interface type has not changed,
  38. though, and you should not need to change your code if you don't explicitly
  39. refer to <code>Pix</code> fields. For example, if you decode a number of images
  40. using the <a href="/pkg/image/jpeg/">image/jpeg</a> package, compose them using
  41. <a href="/pkg/image/draw/">image/draw</a>, and then encode the result using
  42. <a href="/pkg/img/png">image/png</a>, then your code should still work as
  43. before.
  44. If your code <i>does</i> refer to <code>Pix</code> fields see the
  45. <a href="/doc/devel/weekly.html#2011-07-19">weekly.2011-07-19</a>
  46. snapshot notes for how to update your code.
  47. </p>
  48. <p>
  49. <a href="/pkg/template/">Package template</a> has been replaced with a new
  50. templating package (formerly <code>exp/template</code>). The original template
  51. package is still available as <a href="/pkg/old/template/">old/template</a>.
  52. The <code>old/template</code> package is deprecated and will be removed.
  53. The Go tree has been updated to use the new template package. We encourage
  54. users of the old template package to switch to the new one. Code that uses
  55. <code>template</code> or <code>exp/template</code> will need to change its
  56. import lines to <code>"old/template"</code> or <code>"template"</code>,
  57. respectively.
  58. </p>
  59. <h3 id="r60.cmd">Tools</h3>
  60. <p>
  61. <a href="/cmd/goinstall/">Goinstall</a> now uses a new tag selection scheme.
  62. When downloading or updating, goinstall looks for a tag or branch with the
  63. <code>"go."</code> prefix that corresponds to the local Go version. For Go
  64. <code>release.r58</code> it looks for <code>go.r58</code>. For
  65. <code>weekly.2011-06-03</code> it looks for <code>go.weekly.2011-06-03</code>.
  66. If the specific <code>go.X</code> tag or branch is not found, it chooses the
  67. closest earlier version. If an appropriate tag or branch is found, goinstall
  68. uses that version of the code. Otherwise it uses the default version selected
  69. by the version control system. Library authors are encouraged to use the
  70. appropriate tag or branch names in their repositories to make their libraries
  71. more accessible.
  72. </p>
  73. <h3 id="r60.minor">Minor revisions</h3>
  74. <p>
  75. r60.1 includes a
  76. <a href="//golang.org/change/1824581bf62d">linker
  77. fix</a>, a pair of
  78. <a href="//golang.org/change/9ef4429c2c64">goplay</a>
  79. <a href="//golang.org/change/d42ed8c3098e">fixes</a>,
  80. and a <code>json</code> package
  81. <a href="//golang.org/change/d5e97874fe84">fix</a> and
  82. a new
  83. <a href="//golang.org/change/4f0e6269213f">struct tag
  84. option</a>.
  85. </p>
  86. <p>
  87. r60.2
  88. <a href="//golang.org/change/ff19536042ac">fixes</a>
  89. a memory leak involving maps.
  90. </p>
  91. <p>
  92. r60.3 fixes a
  93. <a href="//golang.org/change/01fa62f5e4e5">reflect bug</a>.
  94. </p>
  95. <h2 id="r59">r59 (released 2011/08/01)</h2>
  96. <p>
  97. The r59 release corresponds to
  98. <code><a href="weekly.html#2011-07-07">weekly.2011-07-07</a></code>.
  99. This section highlights the most significant changes in this release.
  100. For a more detailed summary, see the
  101. <a href="weekly.html#2011-07-07">weekly release notes</a>.
  102. For complete information, see the
  103. <a href="//code.google.com/p/go/source/list?r=release-branch.r59">Mercurial change list</a>.
  104. </p>
  105. <h3 id="r59.lang">Language</h3>
  106. <p>
  107. This release includes a language change that restricts the use of
  108. <code>goto</code>. In essence, a <code>goto</code> statement outside a block
  109. cannot jump to a label inside that block. Your code may require changes if it
  110. uses <code>goto</code>.
  111. See <a href="//golang.org/change/dc6d3cf9279d">this
  112. changeset</a> for how the new rule affected the Go tree.
  113. </p>
  114. <h3 id="r59.pkg">Packages</h3>
  115. <p>
  116. As usual, <a href="/cmd/gofix/">gofix</a> will handle the bulk of the rewrites
  117. necessary for these changes to package APIs.
  118. </p>
  119. <p>
  120. <a href="/pkg/http">Package http</a> has a new
  121. <a href="/pkg/http/#FileSystem">FileSystem</a> interface that provides access
  122. to files. The <a href="/pkg/http/#FileServer">FileServer</a> helper now takes a
  123. <code>FileSystem</code> argument instead of an explicit file system root. By
  124. implementing your own <code>FileSystem</code> you can use the
  125. <code>FileServer</code> to serve arbitrary data.
  126. </p>
  127. <p>
  128. <a href="/pkg/os/">Package os</a>'s <code>ErrorString</code> type has been
  129. hidden. Most uses of <code>os.ErrorString</code> can be replaced with
  130. <a href="/pkg/os/#NewError">os.NewError</a>.
  131. </p>
  132. <p>
  133. <a href="/pkg/reflect/">Package reflect</a> supports a new struct tag scheme
  134. that enables sharing of struct tags between multiple packages.
  135. In this scheme, the tags must be of the form:
  136. </p>
  137. <pre>
  138. `key:"value" key2:"value2"`
  139. </pre>
  140. <p>
  141. The <a href="/pkg/reflect/#StructField">StructField</a> type's Tag field now
  142. has type <a href="/pkg/reflect/#StructTag">StructTag</a>, which has a
  143. <code>Get</code> method. Clients of <a href="/pkg/json">json</a> and
  144. <a href="/pkg/xml">xml</a> will need to be updated. Code that says
  145. </p>
  146. <pre>
  147. type T struct {
  148. X int "name"
  149. }
  150. </pre>
  151. <p>
  152. should become
  153. </p>
  154. <pre>
  155. type T struct {
  156. X int `json:"name"` // or `xml:"name"`
  157. }
  158. </pre>
  159. <p>
  160. Use <a href="/cmd/govet/">govet</a> to identify struct tags that need to be
  161. changed to use the new syntax.
  162. </p>
  163. <p>
  164. <a href="/pkg/sort/">Package sort</a>'s <code>IntArray</code> type has been
  165. renamed to <a href="/pkg/sort/#IntSlice">IntSlice</a>, and similarly for
  166. <a href="/pkg/sort/#Float64Slice">Float64Slice</a> and
  167. <a href="/pkg/sort/#StringSlice">StringSlice</a>.
  168. </p>
  169. <p>
  170. <a href="/pkg/strings/">Package strings</a>'s <code>Split</code> function has
  171. itself been split into <a href="/pkg/strings/#Split">Split</a> and
  172. <a href="/pkg/strings/#SplitN">SplitN</a>.
  173. <code>SplitN</code> is the same as the old <code>Split</code>.
  174. The new <code>Split</code> is equivalent to <code>SplitN</code> with a final
  175. argument of -1.
  176. </p>
  177. <a href="/pkg/image/draw/">Package image/draw</a>'s
  178. <a href="/pkg/image/draw/#Draw">Draw</a> function now takes an additional
  179. argument, a compositing operator.
  180. If in doubt, use <a href="/pkg/image/draw/#Op">draw.Over</a>.
  181. </p>
  182. <h3 id="r59.cmd">Tools</h3>
  183. <p>
  184. <a href="/cmd/goinstall/">Goinstall</a> now installs packages and commands from
  185. arbitrary remote repositories (not just Google Code, Github, and so on).
  186. See the <a href="/cmd/goinstall/">goinstall documentation</a> for details.
  187. </p>
  188. <h2 id="r58">r58 (released 2011/06/29)</h2>
  189. <p>
  190. The r58 release corresponds to
  191. <code><a href="weekly.html#2011-06-09">weekly.2011-06-09</a></code>
  192. with additional bug fixes.
  193. This section highlights the most significant changes in this release.
  194. For a more detailed summary, see the
  195. <a href="weekly.html#2011-06-09">weekly release notes</a>.
  196. For complete information, see the
  197. <a href="//code.google.com/p/go/source/list?r=release-branch.r58">Mercurial change list</a>.
  198. </p>
  199. <h3 id="r58.lang">Language</h3>
  200. <p>
  201. This release fixes a <a href="//golang.org/change/b720749486e1">use of uninitialized memory in programs that misuse <code>goto</code></a>.
  202. </p>
  203. <h3 id="r58.pkg">Packages</h3>
  204. <p>
  205. As usual, <a href="/cmd/gofix/">gofix</a> will handle the bulk of the rewrites
  206. necessary for these changes to package APIs.
  207. </p>
  208. <p>
  209. <a href="/pkg/http/">Package http</a> drops the <code>finalURL</code> return
  210. value from the <a href="/pkg/http/#Client.Get">Client.Get</a> method. The value
  211. is now available via the new <code>Request</code> field on <a
  212. href="/pkg/http/#Response">http.Response</a>.
  213. Most instances of the type map[string][]string in have been
  214. replaced with the new <a href="/pkg/http/#Values">Values</a> type.
  215. </p>
  216. <p>
  217. <a href="/pkg/exec/">Package exec</a> has been redesigned with a more
  218. convenient and succinct API.
  219. </p>
  220. <p>
  221. <a href="/pkg/strconv/">Package strconv</a>'s <a href="/pkg/strconv/#Quote">Quote</a>
  222. function now escapes only those Unicode code points not classified as printable
  223. by <a href="/pkg/unicode/#IsPrint">unicode.IsPrint</a>.
  224. Previously Quote would escape all non-ASCII characters.
  225. This also affects the <a href="/pkg/fmt/">fmt</a> package's <code>"%q"</code>
  226. formatting directive. The previous quoting behavior is still available via
  227. strconv's new <a href="/pkg/strconv/#QuoteToASCII">QuoteToASCII</a> function.
  228. </p>
  229. <p>
  230. <a href="/pkg/os/signal/">Package os/signal</a>'s
  231. <a href="/pkg/os/#Signal">Signal</a> and
  232. <a href="/pkg/os/#UnixSignal">UnixSignal</a> types have been moved to the
  233. <a href="/pkg/os/">os</a> package.
  234. </p>
  235. <p>
  236. <a href="/pkg/image/draw/">Package image/draw</a> is the new name for
  237. <code>exp/draw</code>. The GUI-related code from <code>exp/draw</code> is now
  238. located in the <a href="/pkg/exp/gui/">exp/gui</a> package.
  239. </p>
  240. <h3 id="r58.cmd">Tools</h3>
  241. <p>
  242. <a href="/cmd/goinstall/">Goinstall</a> now observes the GOPATH environment
  243. variable to build and install your own code and external libraries outside of
  244. the Go tree (and avoid writing Makefiles).
  245. </p>
  246. <h3 id="r58.minor">Minor revisions</h3>
  247. <p>r58.1 adds
  248. <a href="//golang.org/change/293c25943586">build</a> and
  249. <a href="//golang.org/change/bf17e96b6582">runtime</a>
  250. changes to make Go run on OS X 10.7 Lion.
  251. </p>
  252. <h2 id="r57">r57 (released 2011/05/03)</h2>
  253. <p>
  254. The r57 release corresponds to
  255. <code><a href="weekly.html#2011-04-27">weekly.2011-04-27</a></code>
  256. with additional bug fixes.
  257. This section highlights the most significant changes in this release.
  258. For a more detailed summary, see the
  259. <a href="weekly.html#2011-04-27">weekly release notes</a>.
  260. For complete information, see the
  261. <a href="//code.google.com/p/go/source/list?r=release-branch.r57">Mercurial change list</a>.
  262. </p>
  263. <p>The new <a href="/cmd/gofix">gofix</a> tool finds Go programs that use old APIs and rewrites them to use
  264. newer ones. After you update to a new Go release, gofix helps make the
  265. necessary changes to your programs. Gofix will handle the http, os, and syscall
  266. package changes described below, and we will update the program to keep up with
  267. future changes to the libraries.
  268. Gofix can’t
  269. handle all situations perfectly, so read and test the changes it makes before
  270. committing them.
  271. See <a href="//blog.golang.org/2011/04/introducing-gofix.html">the gofix blog post</a> for more
  272. information.</p>
  273. <h3 id="r57.lang">Language</h3>
  274. <p>
  275. <a href="/doc/go_spec.html#Receive_operator">Multiple assignment syntax</a> replaces the <code>closed</code> function.
  276. The syntax for channel
  277. receives allows an optional second assigned value, a boolean value
  278. indicating whether the channel is closed. This code:
  279. </p>
  280. <pre>
  281. v := &lt;-ch
  282. if closed(ch) {
  283. // channel is closed
  284. }
  285. </pre>
  286. <p>should now be written as:</p>
  287. <pre>
  288. v, ok := &lt;-ch
  289. if !ok {
  290. // channel is closed
  291. }
  292. </pre>
  293. <p><a href="/doc/go_spec.html#Label_scopes">Unused labels are now illegal</a>, just as unused local variables are.</p>
  294. <h3 id="r57.pkg">Packages</h3>
  295. <p>
  296. <a href="/pkg/gob/">Package gob</a> will now encode and decode values of types that implement the
  297. <a href="/pkg/gob/#GobEncoder">GobEncoder</a> and
  298. <a href="/pkg/gob/#GobDecoder">GobDecoder</a> interfaces. This allows types with unexported
  299. fields to transmit self-consistent descriptions; examples include
  300. <a href="/pkg/big/#Int.GobDecode">big.Int</a> and <a href="/pkg/big/#Rat.GobDecode">big.Rat</a>.
  301. </p>
  302. <p>
  303. <a href="/pkg/http/">Package http</a> has been redesigned.
  304. For clients, there are new
  305. <a href="/pkg/http/#Client">Client</a> and <a href="/pkg/http/#Transport">Transport</a>
  306. abstractions that give more control over HTTP details such as headers sent
  307. and redirections followed. These abstractions make it easy to implement
  308. custom clients that add functionality such as <a href="//code.google.com/p/goauth2/source/browse/oauth/oauth.go">OAuth2</a>.
  309. For servers, <a href="/pkg/http/#ResponseWriter">ResponseWriter</a>
  310. has dropped its non-essential methods.
  311. The Hijack and Flush methods are no longer required;
  312. code can test for them by checking whether a specific value implements
  313. <a href="/pkg/http/#Hijacker">Hijacker</a> or <a href="/pkg/http/#Flusher">Flusher</a>.
  314. The RemoteAddr and UsingTLS methods are replaced by <a href="/pkg/http/#Request">Request</a>'s
  315. RemoteAddr and TLS fields.
  316. The SetHeader method is replaced by a Header method;
  317. its result, of type <a href="/pkg/http/#Header">Header</a>,
  318. implements Set and other methods.
  319. </p>
  320. <p>
  321. <a href="/pkg/net/">Package net</a>
  322. drops the <code>laddr</code> argument from <a href="/pkg/net/#Conn.Dial">Dial</a>
  323. and drops the <code>cname</code> return value
  324. from <a href="/pkg/net/#LookupHost">LookupHost</a>.
  325. The implementation now uses <a href="/cmd/cgo/">cgo</a> to implement
  326. network name lookups using the C library getaddrinfo(3)
  327. function when possible. This ensures that Go and C programs
  328. resolve names the same way and also avoids the OS X
  329. application-level firewall.
  330. </p>
  331. <p>
  332. <a href="/pkg/os/">Package os</a>
  333. introduces simplified <a href="/pkg/os/#File.Open">Open</a>
  334. and <a href="/pkg/os/#File.Create">Create</a> functions.
  335. The original Open is now available as <a href="/pkg/os/#File.OpenFile">OpenFile</a>.
  336. The final three arguments to <a href="/pkg/os/#Process.StartProcess">StartProcess</a>
  337. have been replaced by a pointer to a <a href="/pkg/os/#ProcAttr">ProcAttr</a>.
  338. </p>
  339. <p>
  340. <a href="/pkg/reflect/">Package reflect</a> has been redesigned.
  341. <a href="/pkg/reflect/#Type">Type</a> is now an interface that implements
  342. all the possible type methods.
  343. Instead of a type switch on a Type <code>t</code>, switch on <code>t.Kind()</code>.
  344. <a href="/pkg/reflect/#Value">Value</a> is now a struct value that
  345. implements all the possible value methods.
  346. Instead of a type switch on a Value <code>v</code>, switch on <code>v.Kind()</code>.
  347. Typeof and NewValue are now called <a href="/pkg/reflect/#Type.TypeOf">TypeOf</a> and <a href="/pkg/reflect/#Value.ValueOf">ValueOf</a>
  348. To create a writable Value, use <code>New(t).Elem()</code> instead of <code>Zero(t)</code>.
  349. See <a href="//golang.org/change/843855f3c026">the change description</a>
  350. for the full details.
  351. The new API allows a more efficient implementation of Value
  352. that avoids many of the allocations required by the previous API.
  353. </p>
  354. <p>
  355. Remember that gofix will handle the bulk of the rewrites
  356. necessary for these changes to package APIs.
  357. </p>
  358. <h3 id="r57.cmd">Tools</h3>
  359. <p><a href="/cmd/gofix/">Gofix</a>, a new command, is described above.</p>
  360. <p>
  361. <a href="/cmd/gotest/">Gotest</a> is now a Go program instead of a shell script.
  362. The new <code>-test.short</code> flag in combination with package testing's Short function
  363. allows you to write tests that can be run in normal or &ldquo;short&rdquo; mode;
  364. all.bash runs tests in short mode to reduce installation time.
  365. The Makefiles know about the flag: use <code>make testshort</code>.
  366. </p>
  367. <p>
  368. The run-time support now implements CPU and memory profiling.
  369. Gotest's new
  370. <a href="/cmd/gotest/"><code>-test.cpuprofile</code> and
  371. <code>-test.memprofile</code> flags</a> make it easy to
  372. profile tests.
  373. To add profiling to your web server, see the <a href="/pkg/http/pprof/">http/pprof</a>
  374. documentation.
  375. For other uses, see the <a href="/pkg/runtime/pprof/">runtime/pprof</a> documentation.
  376. </p>
  377. <h3 id="r57.minor">Minor revisions</h3>
  378. <p>r57.1 fixes a <a href="//golang.org/change/ff2bc62726e7145eb2ecc1e0f076998e4a8f86f0">nil pointer dereference in http.FormFile</a>.</p>
  379. <p>r57.2 fixes a <a href="//golang.org/change/063b0ff67d8277df03c956208abc068076818dae">use of uninitialized memory in programs that misuse <code>goto</code></a>.</p>
  380. <h2 id="r56">r56 (released 2011/03/16)</h2>
  381. <p>
  382. The r56 release was the first stable release and corresponds to
  383. <code><a href="weekly.html#2011-03-07">weekly.2011-03-07.1</a></code>.
  384. The numbering starts at 56 because before this release,
  385. what we now consider weekly snapshots were called releases.
  386. </p>