[インデックス 15876] ファイルの概要
このコミットは、Go 1.1 リリースノートのドキュメントファイル doc/go1.1.html を更新し、残っていた「TODO」項目の一部を完了させたものです。特に、net関連の変更を除いて、「マイナーチェンジ」セクションの主要な作業が完了したことを示しています。
コミット
- コミットハッシュ:
178d8d4f7ad1907cd9c0245b2ee4eacd5ae907df - 作者: Rob Pike r@golang.org
- コミット日時: 2013年3月21日 木曜日 13:51:49 -0700
GitHub上でのコミットページへのリンク
https://github.com/golang/go/commit/178d8d4f7ad1907cd9c0245b2ee4eacd5ae907df
元コミット内容
doc/go1.1.html: more TODOs done
Only the net stuff remains as significant work in the "minor changes" section.
R=golang-dev, dave, elias.naur, rsc
CC=golang-dev
https://golang.org/cl/7933044
変更の背景
このコミットは、Go言語の次期メジャーリリースであるGo 1.1のリリースノート (doc/go1.1.html) の準備作業の一環として行われました。Goのリリースプロセスでは、新機能や変更点をユーザーに正確に伝えるために詳細なリリースノートが作成されます。開発の進行に伴い、リリースノートのドラフトには「TODO」としてマークされた未記述の項目が残されます。このコミットの目的は、それらの「TODO」項目を具体的な説明に置き換え、リリースノートの完成度を高めることでした。特に、netパッケージ関連の変更を除き、「マイナーチェンジ」セクションの記述がほぼ完了したことを示しています。
前提知識の解説
- Go 1.1: Go言語のメジャーバージョンアップであり、パフォーマンスの向上、標準ライブラリの拡張、ツールチェインの改善など、多くの重要な変更が導入されました。リリースノートはこれらの変更を公式にアナウンスする主要なドキュメントです。
doc/go1.1.html: Go言語の公式ドキュメントの一部であり、Go 1.1リリースにおける新機能、変更点、非互換性などが記述されるHTMLファイルです。go testコマンド: Go言語のテスト実行ツールです。パッケージ内のテストコードを実行し、結果を報告します。プロファイリング機能も内蔵しており、CPUプロファイルやメモリプロファイルなどを生成できます。- プロファイリング: ソフトウェアの実行中に、CPU使用率、メモリ割り当て、関数呼び出し回数などのパフォーマンスデータを収集する手法です。これにより、プログラムのボトルネックを特定し、最適化に役立てることができます。
- PEMブロック: Privacy-Enhanced Mailの略で、暗号化されたデータ(証明書、秘密鍵など)をASCII形式で表現するための標準的なエンコーディング形式です。
BEGIN ...とEND ...の行で囲まれます。 - Goの標準ライブラリ: Go言語には豊富な標準ライブラリが付属しており、ネットワーキング、暗号化、データエンコーディング、ファイルシステム操作など、多岐にわたる機能を提供します。このコミットでは、
crypto/x509,database/sql,encoding/json,encoding/xml,go/format,mime/multipart,net/textproto,image/jpeg,runtime/debugといった様々なパッケージの変更が記述されています。 go/formatパッケージ:gofmtツールが提供するコードフォーマット機能をプログラムから利用するためのパッケージです。GoのソースコードやAST (Abstract Syntax Tree) ノードを整形できます。- ガベージコレクタ (GC): Go言語のランタイムシステムに組み込まれている自動メモリ管理機能です。不要になったメモリを自動的に解放し、メモリリークを防ぎます。GCの動作は、パフォーマンスに大きな影響を与えるため、その統計情報や制御は重要です。
技術的詳細
このコミットは、doc/go1.1.html 内の複数の「TODO」コメントを、Go 1.1で導入された具体的な変更点の記述に置き換えています。以下に、各パッケージにおける主要な変更点の詳細を説明します。
-
go testコマンドの変更:- プロファイリング(例:
-cpuprofileフラグ)を有効にしてgo testを実行した場合、テストバイナリ(例:mypackage.test)が削除されずに残るようになりました。これにより、プロファイル分析が容易になります。以前は、プロファイル分析のためにバイナリを別途保存する必要がありました。
- プロファイリング(例:
-
crypto/x509パッケージの拡張:- PEMブロックのサポートが追加されました。具体的には、
DecryptPEMBlockのような関数が追加され、PEMエンコードされたデータの復号化が可能になりました。 - 楕円曲線秘密鍵をパースするための新しい関数
ParseECPrivateKeyが追加されました。これにより、楕円曲線暗号 (ECC) を利用した鍵の取り扱いが容易になります。
- PEMブロックのサポートが追加されました。具体的には、
-
database/sqlパッケージの改善:DB型に新しいPingメソッドが追加されました。このメソッドは、データベース接続の健全性をテストするために使用され、アプリケーションがデータベースに接続可能かどうかを確認するのに役立ちます。database/sql/driverパッケージには、Queryerインターフェースが追加されました。これは、Connが実装することで、クエリのパフォーマンスを向上させることができるインターフェースです。
-
encoding/jsonパッケージの機能強化:Decoder型に新しいメソッドReaderが追加されました。これにより、デコーダのバッファに残っているデータにアクセスできるようになります。Decoder型にUseNumberメソッドが追加されました。このメソッドを呼び出すと、JSONの数値をfloat64ではなく、新しいNumber型(文字列)としてアンマーシャルするようになります。これにより、浮動小数点数の精度問題や、大きな整数を扱う際のデータ損失を防ぐことができます。
-
encoding/xmlパッケージの改善:- 新しい関数
EscapeTextが追加されました。これは、XML出力において特殊文字をエスケープして書き込むためのものです。 Encoder型にIndentメソッドが追加されました。これにより、XML出力にインデントを追加し、可読性を向上させることができます。
- 新しい関数
-
go/formatパッケージの導入:gofmtのフォーマット機能をプログラムから利用するための新しいパッケージgo/formatが導入されました。- このパッケージには、GoパーサーのASTノードをフォーマットする
Node関数と、任意のGoソースコードをフォーマットするSource関数が含まれています。これにより、GoツールやIDEがコードフォーマット機能を容易に統合できるようになります。
-
mime/multipartパッケージの拡張:Writer型に新しいメソッドSetBoundaryが追加されました。これにより、マルチパートメッセージの境界セパレータをプログラムで定義できるようになります。
-
net/textprotoパッケージの追加関数:- 新しい関数
TrimBytesとTrimStringが追加されました。これらは、文字列の先頭と末尾のASCIIスペースのみをトリムするためのものです。
- 新しい関数
-
image/jpegパッケージの改善:- プログレッシブJPEGファイルの読み込みがサポートされました。
- いくつかのサブサンプリング設定が追加で処理できるようになりました。
-
runtime/debugパッケージの機能強化:- メモリ使用量に関する3つの新しい関数が追加されました。
FreeOSMemory: ガベージコレクタを実行し、未使用メモリをオペレーティングシステムに返却しようとします。これにより、Goプログラムが使用するメモリフットプリントを削減できます。ReadGCStats: ガベージコレクタの統計情報を取得します。これにより、GCの動作を監視し、パフォーマンスチューニングに役立てることができます。SetGCPercent: ガベージコレクタの実行頻度をプログラムで制御できるようになります。これにより、GCを完全に無効にすることも可能です。
- メモリ使用量に関する3つの新しい関数が追加されました。
これらの変更は、Go 1.1がより堅牢で、機能豊富で、開発者にとって使いやすい言語になるための重要なステップでした。
コアとなるコードの変更箇所
このコミットは、doc/go1.1.html ファイルのみを変更しています。
具体的な変更は、既存の「TODO」コメントを削除し、その代わりにGo 1.1で導入された新機能や変更点に関する詳細な説明を追加することです。
--- a/doc/go1.1.html
+++ b/doc/go1.1.html
@@ -16,15 +16,15 @@ TODO
<a href="/doc/go1compat.html">The Go compatibility document</a> promises
that programs written to the Go 1 language specification will continue to operate,
and those promises are maintained.
-In the interest of firming up the specification, though, there are some
+In the interest of firming up the specification, though, there are
details about some error cases that have been clarified.
-There is also some new language features.
+There are also some new language features.
</p>
<h3 id="divzero">Integer division by zero</h3>
<p>
-In Go 1, integer division by a constant zero produced a runtime panic:
+In Go 1, integer division by a constant zero produced a run-time panic:
</p>
<pre>
@@ -214,7 +214,17 @@ package code.google.com/p/foo/quxx: cannot download, $GOPATH must not be set to
</pre>
<p>
-TODO: go test uses -c with a profile flag.
+The <code>go test</code> command no longer deletes the binary when run with profiling enabled,
+to make it easier to analyze the profile.
+The implementation sets the <code>-c</code> flag automatically, so after running,
+</p>
+
+<pre>
+$ go test -cpuprofile cpuprof.out mypackage
+</pre>
+
+<p>
+the file <code>mypackage.test</code> will be left in the directory where <code>go test</code> was run.
</p>
<h3 id="gofix">Changes to go fix</h3>
@@ -421,24 +431,54 @@ The <a href="/pkg/crypto/hmac/"><code>crypto/hmac</code></a> package has a new f
<a href="/pkg/crypto/hmac/#Equal"><code>Equal</code></a>, to compare two MACs.\n </li>\n \n-<li> TODO: \n-<code>crypto/x509</code>: DecryptPEMBlock, EncryptPEMBlock etc.\n+<li>\n+The <a href="/pkg/crypto/x509/"><code>crypto/x509</code></a> package\n+now supports PEM blocks (see\n+<a href="/pkg/crypto/x509/#DecryptPEMBlock"><code>DecryptPEMBlock</code></a> for instance),\n+and a new function\n+<a href="/pkg/crypto/x509/#ParseECPrivateKey"><code>ParseECPrivateKey</code></a> to parse elliptic curve private keys.\n </li>\n \n-<li> TODO: \n-<code>database/sql/driver</code>: Queryer\n+<li>\n+The <a href="/pkg/database/sql/"><code>database/sql/</code></a> package\n+has a new \n+<a href="/pkg/database/sql/#DB.Ping"><code>Ping</code></a>\n+method for its\n+<a href="/pkg/database/sql/#DB"><code>DB</code></a>\n+type that tests the health of the connection.\n </li>\n \n-<li> TODO: \n-<code>database/sql</code>: Ping, SetMaxIdleConns\n+<li>\n+The <a href="/pkg/database/sql/driver/"><code>database/sql/driver</code></a> package\n+has a new\n+<a href="/pkg/database/sql/driver/#Queryer"><code>Queryer</code></a>\n+interface that a\n+<a href="/pkg/database/sql/driver/#Conn"><code>Conn</code></a>\n+may implement to improve performance.\n </li>\n \n-<li> TODO: \n-<code>encoding/json</code>: Decoder.Buffered, UseNumber, Number\n+<li>\n+The <a href="/pkg/encoding/json/"><code>encoding/json</code></a> package\'s\n+<a href="/pkg/encoding/json/#Decoder"><code>Decoder</code></a>\n+has a new method\n+<a href="/pkg/encoding/json/#Decoder.Reader\"><code>Reader</code></a>\n+to provide access to the remaining data in its buffer,\n+as well as a new method\n+<a href="/pkg/encoding/json/#Decoder.UseNumber"><code>UseNumber</code></a>\n+to unmarshal a value into the new type\n+<a href="/pkg/encoding/json/#Number"><code>Number</code></a>,\n+a string, rather than a float64.\n </li>\n \n-<li> TODO: \n-<code>encoding/xml</code>: EscapeText Encoder.Indent\n+<li>\n+The <a href="/pkg/encoding/xml/"><code>endoding/xml</code></a> package\n+has a new function,\n+<a href="/pkg/encoding/xml/#EscapeText"><code>EscapeText</code></a>,\n+which writes escaped XML output,\n+and a method on\n+<a href="/pkg/encoding/xml/#Encoder"><code>Encoder</code></a>,\n+<a href="/pkg/encoding/xml/#Encoder.Indent"><code>Indent</code></a>,\n+to specify indented output.\n </li>\n \n <li>\n@@ -455,8 +495,15 @@ information that the <a href="/cmd/godoc/"><code>godoc</code></a>\n command can filter or present according to the value of the <code>-notes</code> flag.\n </li>\n \n-<li> TODO: \n-<code>go/format</code>: Node, Source\n+<li>\n+A new package, <a href="/pkg/go/format/"><code>go/format</code></a>, provides\n+a convenient way for a program to access the formatting capabilities of <code>gofmt</code>.\n+It has two functions,\n+<a href="/pkg/go/format/#Node"><code>Node</code></a> to format a Go parser\n+<a href="/pkg/go/ast/#Node"><code>Node</code></a>,\n+and\n+<a href="/pkg/go/format/#Source"><code>Source</code></a>\n+to format arbitrary Go source code.\n </li>\n \n <li>\n@@ -498,8 +545,12 @@ and\n <a href="/pkg/math/big/#Rat.SetFloat64"><code>SetFloat64</code></a>.\n </li>\n \n-<li> TODO: \n-<code>mime/multipart</code>: Writer.SetBoundary\n+<li>\n+The <a href="/pkg/mime/multipart/"><code>mime/multipart</code></a> package\n+has a new method for its\n+<a href="/pkg/mime/multipart/#Writer"><code>Writer</code></a>,\n+<a href="/pkg/mime/multipart/#Writer.SetBoundary"><code>SetBoundary</code></a>,\n+to define the boundary separator used to package the output.\n </li>\n \n <li>\n@@ -518,11 +569,15 @@ The new <a href="/pkg/net/http/cookiejar/">net/http/cookiejar</a> package provid\n <code>net/smtp</code>: Client.Hello\n </li>\n \n-<li> TODO: \n-<code>net/textproto</code>: TrimBytes, TrimString\n+<li>\n+The <a href="/pkg/net/textproto/"><code>net/textproto</code></a> package\n+has two new functions,\n+<a href="/pkg/net/textproto/#TrimBytes"><code>TrimBytes</code></a> and\n+<a href="/pkg/net/textproto/#TrimString"><code>TrimString</code></a>,\n+which do ASCII-only trimming of leading and trailing spaces.\n </li>\n \n-<li>\n+<li> TODO:\n <code>net</code>: DialOption, DialOpt, ListenUnixgram, LookupNS, IPConn.ReadMsgIP, IPConn.WriteMsgIP, UDPConn.ReadMsgUDP, UDPConn.WriteMsgUDP, UnixConn.CloseRead, UnixConn.CloseWrite\n </li>\n \n@@ -530,8 +585,9 @@ The new <a href="/pkg/net/http/cookiejar/">net/http/cookiejar</a> package provid\n The new method <a href="/pkg/os/#FileMode.IsRegular"><code>os.FileMode.IsRegular</code> </a> makes it easy to ask if a file is a plain file.\n </li>\n \n-<li> TODO: \n-<code>pkg/image</code>: new subsamplings\n+<li>\n+The <a href="/pkg/image/jpeg/"><code>image/jpeg</code></a> package now\n+reads progressive JPEG files and handles a few more subsampling configurations.\n </li>\n \n <li>\n@@ -543,8 +599,17 @@ method, while\n strings into pieces based on separators defined by the regular expression.\n </li>\n \n-<li> TODO: \n-<code>runtime/debug</code>: FreeOSMemory, ReadGCStats, SetGCPercent\n+<li>\n+The <a href="/pkg/runtime/debug/"><code>runtime/debug</code></a> package\n+has three new functions regarding memory usage.\n+The <a href="/pkg/runtime/debug/#FreeOSMemory"><code>FreeOSMemory</code></a>\n+function triggers a run of the garbage collector and then attempts to return unused\n+memory to the operating system;\n+the <a href="/pkg/runtime/debug/#ReadGCStats"><code>ReadGCStats</code></a>\n+function retrieves statistics about the collector; and\n+<a href="/pkg/runtime/debug/#SetGCPercent"><code>SetGCPercent</code></a>\n+provides a programmatic way to control how often the collector runs,\n+including disabling it altogether.\n </li>\n \n <li>
コアとなるコードの解説
このコミットのコアとなる変更は、doc/go1.1.html 内の「TODO」プレースホルダーを、Go 1.1で実際に実装された機能や改善点の具体的な説明に置き換えることです。
go testのプロファイリングに関する記述: 以前は「TODO: go test uses -c with a profile flag.」とだけ書かれていた部分が、プロファイリング時にテストバイナリが削除されなくなったこと、およびその理由(プロファイル分析を容易にするため)と具体的な使用例(go test -cpuprofile cpuprof.out mypackage)に置き換えられました。- 各パッケージの変更点の記述:
crypto/x509: 「TODO: crypto/x509: DecryptPEMBlock, EncryptPEMBlock etc.」が、PEMブロックのサポートとParseECPrivateKey関数の追加に関する詳細な説明に置き換えられました。database/sqlおよびdatabase/sql/driver: 「TODO: database/sql/driver: Queryer」と「TODO: database/sql: Ping, SetMaxIdleConns」が、DB.Pingメソッドとdriver.Queryerインターフェースの追加に関する説明に置き換えられました。encoding/json: 「TODO: encoding/json: Decoder.Buffered, UseNumber, Number」が、Decoder.ReaderメソッドとDecoder.UseNumberメソッド、および新しいNumber型に関する詳細な説明に置き換えられました。encoding/xml: 「TODO: encoding/xml: EscapeText Encoder.Indent」が、EscapeText関数とEncoder.Indentメソッドの追加に関する説明に置き換えられました。go/format: 「TODO: go/format: Node, Source」が、go/formatパッケージの導入と、NodeおよびSource関数の機能に関する詳細な説明に置き換えられました。mime/multipart: 「TODO: mime/multipart: Writer.SetBoundary」が、Writer.SetBoundaryメソッドの追加に関する説明に置き換えられました。net/textproto: 「TODO: net/textproto: TrimBytes, TrimString」が、TrimBytesとTrimString関数の追加に関する説明に置き換えられました。image/jpeg: 「TODO: pkg/image: new subsamplings」が、プログレッシブJPEGの読み込みとサブサンプリング設定のサポートに関する説明に置き換えられました。runtime/debug: 「TODO: runtime/debug: FreeOSMemory, ReadGCStats, SetGCPercent」が、FreeOSMemory,ReadGCStats,SetGCPercentの3つの新しい関数に関する詳細な説明に置き換えられました。
これらの変更は、Go 1.1のリリースノートが、開発者にとって正確で包括的な情報源となるようにするための重要なドキュメント更新作業の一部です。
関連リンク
- Go 1.1 Release Notes (公式): https://golang.org/doc/go1.1 (このコミットが更新しているドキュメントの最終版)
- Go言語公式ウェブサイト: https://golang.org/
- Go Packages (公式ドキュメント): https://pkg.go.dev/
参考にした情報源リンク
- Go 1.1 Release Notes (公式): https://golang.org/doc/go1.1
- Go言語の各パッケージの公式ドキュメント (例:
crypto/x509,encoding/jsonなど) - Go言語のコミット履歴 (GitHub): https://github.com/golang/go/commits/master
- Gerrit Change 7933044: https://golang.org/cl/7933044 (コミットメッセージに記載されているGerritの変更リンク)
- 一般的なGo言語の知識と標準ライブラリの利用方法に関する情報源。