1
0

go1compat.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <!--{
  2. "Title": "Go 1 and the Future of Go Programs",
  3. "Path": "/doc/go1compat"
  4. }-->
  5. <h2 id="introduction">Introduction</h2>
  6. <p>
  7. The release of Go version 1, Go 1 for short, is a major milestone
  8. in the development of the language. Go 1 is a stable platform for
  9. the growth of programs and projects written in Go.
  10. </p>
  11. <p>
  12. Go 1 defines two things: first, the specification of the language;
  13. and second, the specification of a set of core APIs, the "standard
  14. packages" of the Go library. The Go 1 release includes their
  15. implementation in the form of two compiler suites (gc and gccgo),
  16. and the core libraries themselves.
  17. </p>
  18. <p>
  19. It is intended that programs written to the Go 1 specification will
  20. continue to compile and run correctly, unchanged, over the lifetime
  21. of that specification. At some indefinite point, a Go 2 specification
  22. may arise, but until that time, Go programs that work today should
  23. continue to work even as future "point" releases of Go 1 arise (Go
  24. 1.1, Go 1.2, etc.).
  25. </p>
  26. <p>
  27. Compatibility is at the source level. Binary compatibility for
  28. compiled packages is not guaranteed between releases. After a point
  29. release, Go source will need to be recompiled to link against the
  30. new release.
  31. </p>
  32. <p>
  33. The APIs may grow, acquiring new packages and features, but not in
  34. a way that breaks existing Go 1 code.
  35. </p>
  36. <h2 id="expectations">Expectations</h2>
  37. <p>
  38. Although we expect that the vast majority of programs will maintain
  39. this compatibility over time, it is impossible to guarantee that
  40. no future change will break any program. This document is an attempt
  41. to set expectations for the compatibility of Go 1 software in the
  42. future. There are a number of ways in which a program that compiles
  43. and runs today may fail to do so after a future point release. They
  44. are all unlikely but worth recording.
  45. </p>
  46. <ul>
  47. <li>
  48. Security. A security issue in the specification or implementation
  49. may come to light whose resolution requires breaking compatibility.
  50. We reserve the right to address such security issues.
  51. </li>
  52. <li>
  53. Unspecified behavior. The Go specification tries to be explicit
  54. about most properties of the language, but there are some aspects
  55. that are undefined. Programs that depend on such unspecified behavior
  56. may break in future releases.
  57. </li>
  58. <li>
  59. Specification errors. If it becomes necessary to address an
  60. inconsistency or incompleteness in the specification, resolving the
  61. issue could affect the meaning or legality of existing programs.
  62. We reserve the right to address such issues, including updating the
  63. implementations. Except for security issues, no incompatible changes
  64. to the specification would be made.
  65. </li>
  66. <li>
  67. Bugs. If a compiler or library has a bug that violates the
  68. specification, a program that depends on the buggy behavior may
  69. break if the bug is fixed. We reserve the right to fix such bugs.
  70. </li>
  71. <li>
  72. Struct literals. For the addition of features in later point
  73. releases, it may be necessary to add fields to exported structs in
  74. the API. Code that uses unkeyed struct literals (such as pkg.T{3,
  75. "x"}) to create values of these types would fail to compile after
  76. such a change. However, code that uses keyed literals (pkg.T{A:
  77. 3, B: "x"}) will continue to compile after such a change. We will
  78. update such data structures in a way that allows keyed struct
  79. literals to remain compatible, although unkeyed literals may fail
  80. to compile. (There are also more intricate cases involving nested
  81. data structures or interfaces, but they have the same resolution.)
  82. We therefore recommend that composite literals whose type is defined
  83. in a separate package should use the keyed notation.
  84. </li>
  85. <li>
  86. Methods. As with struct fields, it may be necessary to add methods
  87. to types.
  88. Under some circumstances, such as when the type is embedded in
  89. a struct along with another type,
  90. the addition of the new method may break
  91. the struct by creating a conflict with an existing method of the other
  92. embedded type.
  93. We cannot protect against this rare case and do not guarantee compatibility
  94. should it arise.
  95. </li>
  96. <li>
  97. Dot imports. If a program imports a standard package
  98. using <code>import . "path"</code>, additional names defined in the
  99. imported package in future releases may conflict with other names
  100. defined in the program. We do not recommend the use of <code>import .</code>
  101. outside of tests, and using it may cause a program to fail
  102. to compile in future releases.
  103. </li>
  104. <li>
  105. Use of package <code>unsafe</code>. Packages that import
  106. <a href="/pkg/unsafe/"><code>unsafe</code></a>
  107. may depend on internal properties of the Go implementation.
  108. We reserve the right to make changes to the implementation
  109. that may break such programs.
  110. </li>
  111. </ul>
  112. <p>
  113. Of course, for all of these possibilities, should they arise, we
  114. would endeavor whenever feasible to update the specification,
  115. compilers, or libraries without affecting existing code.
  116. </p>
  117. <p>
  118. These same considerations apply to successive point releases. For
  119. instance, code that runs under Go 1.2 should be compatible with Go
  120. 1.2.1, Go 1.3, Go 1.4, etc., although not necessarily with Go 1.1
  121. since it may use features added only in Go 1.2
  122. </p>
  123. <p>
  124. Features added between releases, available in the source repository
  125. but not part of the numbered binary releases, are under active
  126. development. No promise of compatibility is made for software using
  127. such features until they have been released.
  128. </p>
  129. <p>
  130. Finally, although it is not a correctness issue, it is possible
  131. that the performance of a program may be affected by
  132. changes in the implementation of the compilers or libraries upon
  133. which it depends.
  134. No guarantee can be made about the performance of a
  135. given program between releases.
  136. </p>
  137. <p>
  138. Although these expectations apply to Go 1 itself, we hope similar
  139. considerations would be made for the development of externally
  140. developed software based on Go 1.
  141. </p>
  142. <h2 id="subrepos">Sub-repositories</h2>
  143. <p>
  144. Code in sub-repositories of the main go tree, such as
  145. <a href="//golang.org/x/net">golang.org/x/net</a>,
  146. may be developed under
  147. looser compatibility requirements. However, the sub-repositories
  148. will be tagged as appropriate to identify versions that are compatible
  149. with the Go 1 point releases.
  150. </p>
  151. <h2 id="operating_systems">Operating systems</h2>
  152. <p>
  153. It is impossible to guarantee long-term compatibility with operating
  154. system interfaces, which are changed by outside parties.
  155. The <a href="/pkg/syscall/"><code>syscall</code></a> package
  156. is therefore outside the purview of the guarantees made here.
  157. As of Go version 1.4, the <code>syscall</code> package is frozen.
  158. Any evolution of the system call interface must be supported elsewhere,
  159. such as in the
  160. <a href="//golang.org/x/sys">go.sys</a> subrepository.
  161. For details and background, see
  162. <a href="//golang.org/s/go1.4-syscall">this document</a>.
  163. </p>
  164. <h2 id="tools">Tools</h2>
  165. <p>
  166. Finally, the Go tool chain (compilers, linkers, build tools, and so
  167. on) are under active development and may change behavior. This
  168. means, for instance, that scripts that depend on the location and
  169. properties of the tools may be broken by a point release.
  170. </p>
  171. <p>
  172. These caveats aside, we believe that Go 1 will be a firm foundation
  173. for the development of Go and its ecosystem.
  174. </p>