Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

[インデックス 12160] ファイルの概要

このコミットは、Go言語の公式リポジトリにおける週次開発スナップショットのドキュメント更新です。具体的には、doc/devel/weekly.html ファイルに2012年2月22日時点での主要な変更点、特にGo 1リリース前の互換性のない変更に関する情報が追加されています。また、.hgtags ファイルから古い週次タグのエントリが削除されています。

コミット

commit 6419bbbfd310d0e48b3de60c8891a8f0fcc98b6f
Author: Andrew Gerrand <adg@golang.org>
Date:   Thu Feb 23 16:40:13 2012 +1100

    weekly.2012-02-22
    
    R=golang-dev, r, bradfitz
    CC=golang-dev
    https://golang.org/cl/5698043

GitHub上でのコミットページへのリンク

https://github.com/golang/go/commit/6419bbbfd310d0e48b3de60c8891a8f0fcc98b6f

元コミット内容

このコミットの主な内容は、Go言語の週次開発スナップショット weekly.2012-02-22 のリリースに伴うドキュメントの更新です。これには、Go 1リリースに向けて導入された、os パッケージと runtime パッケージにおける重要な互換性のない変更点が含まれています。

変更の背景

Go言語は、2012年3月に初の安定版であるGo 1をリリースしました。このGo 1の目標の一つは、将来のバージョンアップにおいても既存のGo 1プログラムが動作し続けるように、言語仕様と標準ライブラリの安定性を確立することでした。

このコミットが行われた2012年2月は、Go 1のリリース直前にあたります。そのため、開発チームはGo 1の安定性を確保するために、それまでの開発版で導入されていた一部のAPIや挙動について、互換性のない変更(breaking changes)を積極的に行っていました。これらの変更は、Go言語の設計思想に沿ったよりクリーンで堅牢なAPIを提供し、将来的なメンテナンス性を向上させることを目的としていました。

このコミットは、これらの重要な変更点を開発者コミュニティに周知するための週次スナップショットのドキュメント更新の一環として行われました。特に、os パッケージと runtime パッケージにおける変更は、多くの既存コードに影響を与える可能性があったため、詳細な説明が必要とされました。

前提知識の解説

  • Go 1リリース: Go言語の最初のメジャー安定版リリース。このリリース以降、Go言語は「Go 1互換性保証」を掲げ、Go 1で書かれたプログラムは将来のGoバージョンでも動作することを保証しています。このコミットはGo 1リリース直前の最終調整段階での変更を反映しています。
  • os パッケージ: オペレーティングシステムとのインタラクション(ファイル操作、プロセス管理、環境変数など)を提供するGoの標準ライブラリパッケージです。
  • runtime パッケージ: Goランタイムシステムとのインタラクション(ガベージコレクション、ゴルーチン管理、低レベルなメモリ操作など)を提供するパッケージです。通常、アプリケーション開発者が直接使用することは稀で、主にデバッグやプロファイリング、あるいは非常に低レベルなシステムプログラミングで使用されます。
  • 互換性のない変更 (Breaking Changes): 既存のコードが新しいバージョンで動作しなくなるような変更のことです。APIの削除、関数のシグネチャ変更、挙動の変更などが含まれます。Go 1リリース前は、このような変更が積極的に行われ、APIの洗練が図られました。
  • go fix コマンド: Goツールチェーンの一部で、古いGoプログラムを新しいAPIや言語仕様に合わせて自動的に書き換えるツールです。このコミットで言及されているように、多くの互換性のない変更に対して go fix が対応していました。
  • 週次スナップショット (Weekly Snapshot): Go言語の開発版が定期的に公開されていた形式の一つです。Go 1リリース前は、開発の進捗を共有し、早期にフィードバックを得るために週次でスナップショットが提供されていました。

技術的詳細

このコミットで doc/devel/weekly.html に追加された内容は、主に os パッケージと runtime パッケージにおけるAPIの変更に焦点を当てています。

os パッケージの変更点

  1. エラー定数の変更:
    • EINVAL のようなエラー定数が os パッケージから削除されました。これは、これらの値が基盤となるオペレーティングシステムによって異なり、移植性が低かったためです。
    • 代わりに、IsPermission のようなポータブルな関数が導入され、一般的なエラープロパティ(例:パーミッションエラー)をテストできるようになりました。
    • ErrPermissionErrNoEnv のような、よりGoらしい名前を持つ新しいエラー値が追加されました。これにより、エラーハンドリングの移植性と一貫性が向上しました。
  2. os.Getenverror 関数の削除:
    • この関数は削除されました。環境変数が存在しない場合と空文字列の場合を区別するには、os.Environ または syscall.Getenv を使用するように変更されました。
  3. Process.Wait メソッドと Wait 関数の変更:
    • Process.Wait メソッドからオプション引数が削除され、関連する定数もパッケージからなくなりました。
    • Wait 関数自体も削除され、Process 型のメソッドとしての Wait のみが残されました。これにより、プロセス待機APIがよりオブジェクト指向的な設計に統一されました。
  4. Waitmsg 型の置き換え:
    • 非ポータブルな Waitmsg 型が、ポータブルな ProcessState に置き換えられました。これにより、異なるOS間でのプロセス状態の表現が一貫しました。

runtime パッケージの変更点

  1. APIの削減と他パッケージへの移行:
    • runtime パッケージから多くのAPIが削除され、その機能は他のパッケージによって提供されるようになりました。
    • runtime.Type インターフェースやその具体的な型実装を使用していたコードは、reflect パッケージを使用するように変更されました。reflect パッケージは、実行時の型情報へのアクセスと操作を提供します。
    • runtime.Semacquireruntime.Semrelease を使用していたコードは、Goのチャネル(channels)または sync パッケージの抽象化(例:sync.Mutex, sync.WaitGroup)を使用するように変更されました。これにより、よりGoらしい並行処理のプリミティブが推奨されました。
  2. デバッグ用APIの削除:
    • メモリ割り当てのデバッグ用に作成された安全でないAPIである runtime.Allocruntime.Freeruntime.Lookup は、代替なしで削除されました。これは、これらのAPIが低レベルすぎ、通常のアプリケーション開発では不要であり、Goランタイムの内部実装に強く依存していたためと考えられます。
  3. 関数名の変更:
    • runtime.Cgocallsruntime.NumCgoCall に、runtime.Goroutinesruntime.NumGoroutine にそれぞれ名前が変更されました。これにより、関数名がより明確になり、Goの命名規則に沿うようになりました。

その他の変更点

コミットメッセージには、上記以外にも多数の細かい変更点がリストアップされています。これらは、コンパイラ(5c, 6c, 8c, 6g, 8g, 5g, 8a, 8l, cmd/gc)、ビルドシステム(build, builder, cmd/dist)、標準ライブラリの様々なパッケージ(bufio, bytes, cgo, database/sql/driver, doc, encoding/gob, encoding/json, go/doc, go/parser, go/printer, gofmt, godoc, html/template, image, ld, math/rand, misc/dist/windows, misc/goplay, net, os, syscall, net/http, net/smtp, net/textproto, net/url, path, path/filepath, pprof, runtime, spec, syscall, test, text/template, time)にわたるバグ修正、改善、APIの調整を含んでいます。

特筆すべきは、test パッケージが新しいGoベースのテストフレームワークに移行したこと、spec(Go言語仕様)に関する記述の洗練、そして go fix コマンドがこれらの変更のほとんどに対応していることが明記されている点です。これは、開発者が既存のコードをGo 1に移行する際の負担を軽減するための重要な措置でした。

コアとなるコードの変更箇所

このコミットのコアとなる変更は、doc/devel/weekly.html ファイルへの大規模な追加です。

diff --git a/doc/devel/weekly.html b/doc/devel/weekly.html
index 4816287752..032a1e9081 100644
--- a/doc/devel/weekly.html
+++ b/doc/devel/weekly.html
@@ -14,6 +14,125 @@ hg pull
 hg update weekly.<i>YYYY-MM-DD</i>
 </pre>
 
+<h2 id="2012-02-22">2012-02-22</h2>
+
+<pre>
+This weekly snapshot includes changes to the os and runtime packages.
+
+This should be the last of the significant incompatible changes before Go 1.
+
+There are no longer error constants such as EINVAL in the os package, since the
+set of values varied with the underlying operating system. There are new
+portable functions like IsPermission to test common error properties, plus a
+few new error values with more Go-like names, such as ErrPermission and
+ErrNoEnv.
+
+The os.Getenverror function has been removed. To distinguish between a
+non-existent environment variable and an empty string, use os.Environ or
+syscall.Getenv.
+
+The Process.Wait method has dropped its option argument and the associated
+constants are gone from the package. Also, the function Wait is gone; only the
+method of the Process type persists.
+
+The non-portable Waitmsg type has been replaced with the portable ProcessState.
+
+Much of the API exported by package runtime has been removed in favor of
+functionality provided by other packages. Code using the runtime.Type
+interface or its specific concrete type implementations should now use package
+reflect.  Code using runtime.Semacquire or runtime.Semrelease should use
+channels or the abstractions in package sync.
+
+The runtime.Alloc, runtime.Free, and runtime.Lookup functions, an unsafe API
+created for debugging the memory allocator, have no replacement.
+
+The runtime.Cgocalls and runtime.Goroutines functions have been renamed to
+runtime.NumCgoCall and runtime.NumGoroutine.
+
+The "go fix" command will update code to accommodate most of these changes.
+
+Other changes:
+* 5c, 6c, 8c, 6g, 8g: correct boundary checking (thanks Shenghou Ma).
+* 5g, 6g, 8g: flush modified globals aggressively.
+* 8a, 8l: add EMMS instruction (thanks Evan Shaw).
+* bufio: don't return errors from good Peeks.
+* build: add make.bash --no-clean option,
+	improve Windows support.
+* builder: reuse existing workspace if possible (thanks Shenghou Ma),
+	update for os.Wait changes.
+* bytes: document Compare/Equal semantics for nil arguments, and add tests.
+* cgo: fix definition of opaque types (thanks Gustavo Niemeyer).
+* cmd/api: record return type of functions for variable typecheck (thanks Rémy Oudompheng).
+* cmd/cgo: bug fixes.
+* cmd/dist: add clang specific -Wno options (thanks Bobby Powers),
+	fix install cmd/5g on non-arm system,
+	fix pprof permissions (thanks Bobby Powers),
+	make dir check in defaulttarg() more robust (thanks Shenghou Ma),
+	use correct package target when cross-compiling (thanks Alex Brainman).
+* cmd/gc: correctly typecheck expression lists in returns (thanks Rémy Oudompheng),
+	don't believe that variables mentioned 256 times are unused (thanks Rémy Oudompheng),
+	error on constant shift overflows (thanks Rémy Oudompheng),
+	fix comparison of struct with _ field.
+	fix error for floating-point constant %,
+	new, less strict bool rules.
+* cmd/go: add tool -n flag,
+	go test -i correctly handle cgo packages (thanks Shenghou Ma).
+* codereview: fix submit message for new clone URL (thanks Shenghou Ma).
+* database/sql/driver: API cleanups.
+* doc: many fixes and adjustments.
+* encoding/gob: cache engine for user type, not base type,
+	catch internal error when it happens,
+	fix mutually recursive slices of structs.
+* encoding/json: ignore anonymous fields.
+* go/doc: return Examples in name order.
+* go/parser: imaginary constants and ! may start an expression.
+* go/printer, gofmt: improved comma placement.
+* go/printer: don't lose relevant parentheses when rewriting selector expressions.
+* godoc: adjust line height in pre blocks,
+	don't print spurious suggestion when running "go doc foo",
+	fix absolute->relative mapping,
+	fix tag mismatch validation errors (thanks Scott Lawrence),
+	import example code support,
+	support flat directory view again.
+* html/template: add Clone and AddParseTree,
+	don't indirect past a Stringer,
+	minor tweak to docs to improve HTML typography.
+* image: add Decode example.
+* ld: add NOPTRBSS for large, pointer-free uninitialized data.
+* math/rand: Intn etc. should panic if their argument is <= 0.
+* misc/dist/windows: distro builder updates (thanks Joe Poirier).
+* misc/goplay: remain in work directory, build in temp directory.
+* net, os, syscall: delete os.EPLAN9 (thanks Mikio Hara).
+* net/http: add optional Server.TLSConfig field.
+* net/smtp: use EHLO then HELO.
+* net/textproto: accept bad MIME headers as browsers do.
+* net/url: regularise receiver names.
+* net: make LocalAddr on multicast return group address (thanks Mikio Hara),
+	make parseProcNetIGMP more robust (thanks Mikio Hara),
+	more selfConnect debugging: panic if ra == nil in internetSocket,
+	panic if sockaddrToTCP returns nil incorrectly,
+	other miscellaneous fixes.
+* path, path/filepath: polish documentation (thanks Rémy Oudompheng).
+* pprof: add Profile type.
+* runtime: avoid malloc during malloc,
+	define NSIG to fix plan 9 build (thanks David du Colombier),
+	fix FreeBSD signal handling around thread creation (thanks Devon H. O'Dell),
+	goroutine profile, stack dumps,
+	implement runtime.osyield on FreeBSD 386, amd64 (thanks Devon H. O'Dell),
+	permit default behaviour of SIGTSTP, SIGTTIN, SIGTTOU,
+	release unused memory to the OS (thanks Sébastien Paolacci),
+	remove an obsolete file (thanks Mikio Hara).
+* spec: make all comparison results untyped bool,
+	refine the wording about variables in type switches,
+	struct comparison only compares non-blank fields.
+* syscall: Make Pdeathsig type Signal in SysProcAttr on Linux (thanks Albert Strasheim),
+	fix bounds check in Error,
+	force Windows to always use US English error messages (thanks Shenghou Ma).
+* test: migrated to new go-based testing framework.
+* text/template: evaluate function fields.
+* time: use Go distribution zoneinfo if system copy not found.
+</pre>
+
 <h2 id="2012-02-14">2012-02-14</h2>
 
 <pre>

また、.hgtags ファイルからは、weekly というタグのエントリが削除されています。これは、週次スナップショットのタグ付け方法の変更、あるいは特定のタグの整理の一環と考えられます。

diff --git a/.hgtags b/.hgtags
index db6d1f48b9..48827d118d 100644
--- a/.hgtags
+++ b/.hgtags
@@ -105,4 +105,3 @@ b4a91b6933748db1a7150c06a1b55ad506e52906 weekly.2011-11-18
 1107a7d3cb075836387adfab5ce56d1b3e56637d weekly.2012-01-27
 52ba9506bd993663a0a033c2bd68699e25d061ab weekly.2012-02-07
 43cf9b39b6477d3144b0353ee91096e55db6107f weekly.2012-02-14
-43cf9b39b6477d3144b0353ee91096e55db6107f weekly

コアとなるコードの解説

このコミットは、Go言語のソースコード自体を変更するものではなく、Goプロジェクトのドキュメントを更新するものです。したがって、「コアとなるコード」とは、Go言語のランタイムや標準ライブラリのコードではなく、開発者向けの週次更新情報を提供するHTMLドキュメント doc/devel/weekly.html を指します。

追加されたHTMLコンテンツは、<h2>2012-02-22</h2> という見出しの下に、os パッケージと runtime パッケージにおける主要な互換性のない変更点と、その他の多数の細かい変更点を箇条書きで詳細に記述しています。この情報は、Go 1リリースを控えた時期に、開発者が自身のコードを新しいGoバージョンに対応させるために不可欠なものでした。

特に強調されているのは、これらの変更が「Go 1リリース前の重要な互換性のない変更の最後になるはずだ」という点です。これは、Go 1の互換性保証に向けた開発チームの強い意志を示しています。

.hgtags ファイルの変更は、Mercurialリポジトリにおけるタグ管理に関連するもので、このコミットがGitに移行される前のMercurial時代の名残です。weekly という汎用的なタグが削除され、より具体的な日付付きのタグが残されていることから、タグ管理の厳密化が図られた可能性があります。

全体として、このコミットはGo 1リリースに向けた最終段階における、APIの洗練とドキュメントの整備という重要な側面を反映しています。

関連リンク

参考にした情報源リンク

  • Go言語の公式ドキュメント
  • Go言語のGitHubリポジトリのコミット履歴
  • Go言語のリリースに関する一般的な情報源(ブログ記事など)
  • Mercurialの.hgtagsに関する情報