blob: 8ceaf32f977905caf76577f270f748043c30efb3 [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
86the API. Code that uses untagged struct literals (such as pkg.T{3,
87"x"}) to create values of these types would fail to compile after
88such a change. However, code that uses tagged literals (pkg.T{A:
893, B: "x"}) will continue to compile after such a change. We will
90update such data structures in a way that allows tagged struct
91literals to remain compatible, although untagged literals may fail
92to 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
95in a separate package should use the tagged notation.
96</li>
97
Ian Lance Taylor25f15d52012-03-06 17:50:11 -080098<li>
99Dot imports. If a program imports a standard package
100using <code>import . "path"</code>, additional names defined in the
101imported package in future releases may conflict with other names
102defined in the program. We do not recommend the use of <code>import .</code>
103outside of tests, and using it may cause a program to fail
104to compile in future releases.
105</li>
106
Rob Pike68794e72012-02-09 09:42:40 +1100107</ul>
108
109<p>
110Of course, for all of these possibilities, should they arise, we
111would endeavor whenever feasible to update the specification,
112compilers, or libraries without affecting existing code.
113</p>
114
115<p>
116These same considerations apply to successive point releases. For
117instance, code that runs under Go 1.2 should be compatible with Go
1181.2.1, Go 1.3, Go 1.4, etc., although not necessarily with Go 1.1
119since it may use features added only in Go 1.2
120</p>
121
122<p>
123Features added between releases, available in the source repository
124but not part of the numbered binary releases, are under active
125development. No promise of compatibility is made for software using
126such features until they have been released.
127</p>
128
129<p>
130Finally, although it is not a correctness issue, it is possible
131that the performance of a program may be affected by
132changes in the implementation of the compilers or libraries upon
133which it depends.
134No guarantee can be made about the performance of a
135given program between releases.
136</p>
137
138<p>
139Although these expectations apply to Go 1 itself, we hope similar
140considerations would be made for the development of externally
141developed software based on Go 1.
142</p>
143
144<h2 id="subrepos">Sub-repositories</h2>
145
146<p>
147Code in sub-repositories of the main go tree, such as
Andrew Gerrand43ad89d2014-07-25 10:28:39 +1000148<a href="//code.google.com/p/go.net">code.google.com/p/go.net</a>,
Rob Pike68794e72012-02-09 09:42:40 +1100149may be developed under
150looser compatibility requirements. However, the sub-repositories
151will be tagged as appropriate to identify versions that are compatible
152with the Go 1 point releases.
153</p>
154
Rob Pike160b2462014-08-12 15:28:45 -0700155<h2 id="operating_systems">Operating systems</h2>
156
157<p>
158It is impossible to guarantee long-term compatibility with operating
159system interfaces, which are changed by outside parties.
160The <a href="/pkg/syscall/"><code>syscall</code></a> package
161is therefore outside the purview of the guarantees made here.
162As of Go version 1.4, the <code>syscall</code> package is frozen.
163Any evolution of the system call interface must be supported elsewhere,
Rob Pikeb049dc32014-08-12 15:45:35 -0700164such as in the
165<a href="http://godoc.org/code.google.com/p/go.sys">go.sys</a> subrepository.
Rob Pike160b2462014-08-12 15:28:45 -0700166For details and background, see
167<a href="https://golang.org/s/go1.4-syscall">this document</a>.
168</p>
169
Rob Pike68794e72012-02-09 09:42:40 +1100170<h2 id="tools">Tools</h2>
171
172<p>
173Finally, the Go tool chain (compilers, linkers, build tools, and so
174on) are under active development and may change behavior. This
175means, for instance, that scripts that depend on the location and
176properties of the tools may be broken by a point release.
177</p>
178
179<p>
180These caveats aside, we believe that Go 1 will be a firm foundation
181for the development of Go and its ecosystem.
182</p>