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