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

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

このコミットは、Go言語の標準ライブラリ内の複数のファイルに存在する軽微なタイポ(typo、誤字)を修正するものです。具体的には、コメントやコード内の説明文に現れる重複した単語を削除し、文章の正確性と可読性を向上させています。

コミット

commit 42c8904fe1e8dcb5c2f951af0f5e8427c7f77540
Author: Shenghou Ma <minux.ma@gmail.com>
Date:   Thu Nov 22 02:58:24 2012 +0800

    all: fix the the typos
    Fixes #4420.
    
    R=golang-dev, rsc, remyoudompheng
    CC=golang-dev
    https://golang.org/cl/6854080

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

https://github.com/golang/go/commit/42c8904fe1e8dcb5c2f951af0f5e8427c7f77540

元コミット内容

このコミットの目的は、Go言語の様々なパッケージに散在するタイポを修正することです。特に、コメントや変数名、説明文などに含まれる重複した単語(例: "the the"、"with with")を修正し、コードベース全体の品質と可読性を高めることを意図しています。関連するIssue #4420を解決します。

変更の背景

ソフトウェア開発において、コードの正確性はもちろん重要ですが、そのコードを理解しやすくするためのコメントやドキュメントの品質も同様に重要です。タイポは、たとえそれが軽微なものであっても、読者の理解を妨げたり、プロフェッショナルな印象を損ねたりする可能性があります。このコミットは、Go言語の標準ライブラリという、多くの開発者が参照し利用する基盤コードの品質を維持・向上させるための、継続的なメンテナンス活動の一環として行われました。特に、重複した単語は文法的な誤りであり、修正することでより自然で正確な英語表現になります。

前提知識の解説

このコミットを理解するために、以下のGo言語の基本的な概念と、関連するパッケージの役割について簡単に解説します。

  • Go言語 (Golang): Googleによって開発されたオープンソースのプログラミング言語です。シンプルさ、効率性、並行処理のサポートを重視しており、システムプログラミング、Webサービス、ネットワークプログラミングなどで広く利用されています。
  • 標準ライブラリ: Go言語には、様々な機能を提供する豊富な標準ライブラリが付属しています。これにより、ファイルI/O、ネットワーク通信、データ構造、暗号化など、多岐にわたるタスクを効率的に開発できます。
  • container/ring: リングバッファ(循環バッファ)を実装するためのパッケージです。データが固定サイズのバッファ内で循環的に上書きされるデータ構造を提供します。
  • encoding/binary: 構造体やプリミティブ型(整数、浮動小数点数など)のデータをバイナリ形式で読み書きするためのパッケージです。バイトオーダー(エンディアン)の指定が可能です。
  • encoding/csv: CSV (Comma Separated Values) 形式のデータを読み書きするためのパッケージです。CSVファイルの生成や解析に利用されます。
  • exp/locale/collate: テキストの照合(ソート順序の決定)に関する実験的なパッケージです。ロケール固有のルールに基づいて文字列を比較する機能を提供します。
  • go/printer: Goの抽象構文木 (AST) をGoのソースコードとして整形して出力するためのパッケージです。Goのコードフォーマッタやツールで利用されます。
  • html/template: HTMLテンプレートを安全に生成するためのパッケージです。クロスサイトスクリプティング (XSS) などの脆弱性を防ぐための自動エスケープ機能を提供します。
  • image/jpeg: JPEG形式の画像をデコードおよびエンコードするためのパッケージです。
  • net/http/httptest: HTTPテスト用のユーティリティを提供するパッケージです。HTTPサーバーやクライアントのテストハーネスを簡単に構築できます。
  • net/http: HTTPクライアントとサーバーの実装を提供するパッケージです。Webアプリケーション開発の基盤となります。
  • reflect: Goの実行時リフレクション機能を提供するパッケージです。プログラムの実行中に型情報や値にアクセスし、操作することができます。

このコミットは、これらのパッケージ内のコメントや文字列リテラルにおける単純なタイポ修正であり、各パッケージの機能的な振る舞いに影響を与えるものではありません。

技術的詳細

このコミットで行われた修正は、すべて「重複した単語の削除」という非常にシンプルなものです。具体的には、以下のようなパターンで誤字が発生していました。

  • with with -> with
  • are are -> are
  • to to -> to
  • a a -> a
  • is is -> is
  • tokens tokens -> tokens
  • at at -> at
  • using using -> using
  • the the -> the
  • we we -> we
  • and and -> and

これらの重複は、通常、タイプミスやコピー&ペーストの際に発生しやすいものです。Goのコンパイラはこのような文法的な誤りを直接検出しないため、手動でのレビューや静的解析ツールによって発見される必要があります。このコミットは、そのようなレビュープロセスを通じて発見された軽微な問題を修正し、コードベースの品質を向上させています。機能的な変更は一切含まれていません。

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

以下に、変更された各ファイルとその具体的な変更行を示します。

diff --git a/src/pkg/container/ring/ring.go b/src/pkg/container/ring/ring.go
index 1d96918d37..6d3b3e5b32 100644
--- a/src/pkg/container/ring/ring.go
+++ b/src/pkg/container/ring/ring.go
@@ -74,7 +74,7 @@ func New(n int) *Ring {
 	return r
 }
 
-// Link connects ring r with with ring s such that r.Next()
+// Link connects ring r with ring s such that r.Next()
 // becomes s and returns the original value for r.Next().
 // r must not be empty.
 //
diff --git a/src/pkg/encoding/binary/binary.go b/src/pkg/encoding/binary/binary.go
index 06670141e1..04d5723c1e 100644
--- a/src/pkg/encoding/binary/binary.go
+++ b/src/pkg/encoding/binary/binary.go
@@ -184,7 +184,7 @@ func Read(r io.Reader, order ByteOrder, data interface{}) error {
 // values, or a pointer to such data.\n // Bytes written to w are encoded using the specified byte order\n // and read from successive fields of the data.\n-// When writing structs, zero values are are written for fields\n+// When writing structs, zero values are written for fields\n // with blank (_) field names.\n func Write(w io.Writer, order ByteOrder, data interface{}) error {
 // Fast path for basic types.
diff --git a/src/pkg/encoding/csv/writer.go b/src/pkg/encoding/csv/writer.go
index 324944cc82..17e485083e 100644
--- a/src/pkg/encoding/csv/writer.go
+++ b/src/pkg/encoding/csv/writer.go
@@ -22,7 +22,7 @@ import (
 //
 // If UseCRLF is true, the Writer ends each record with \\r\\n instead of \\n.
 type Writer struct {
-	Comma   rune // Field delimiter (set to to ',' by NewWriter)
+	Comma   rune // Field delimiter (set to ',' by NewWriter)
 	UseCRLF bool // True to use \\r\\n as the line terminator
 	w       *bufio.Writer
 }
diff --git a/src/pkg/exp/locale/collate/collate.go b/src/pkg/exp/locale/collate/collate.go
index a08dcae0d5..8a5c9dc7a8 100644
--- a/src/pkg/exp/locale/collate/collate.go
+++ b/src/pkg/exp/locale/collate/collate.go
@@ -450,7 +450,7 @@ func (c *Collator) keyFromElems(buf *Buffer, ws []colElem) {
 		}
 		// Derive the quaternary weights from the options and other levels.
 		// Note that we represent maxQuaternary as 0xFF. The first byte of the
-		// representation of a a primary weight is always smaller than 0xFF,
+		// representation of a primary weight is always smaller than 0xFF,
 		// so using this single byte value will compare correctly.
 		if Quaternary <= c.Strength && c.Alternate >= AltShifted {
 			if c.Alternate == AltShiftTrimmed {
diff --git a/src/pkg/go/printer/printer.go b/src/pkg/go/printer/printer.go
index e79e3ffda2..990655e716 100644
--- a/src/pkg/go/printer/printer.go
+++ b/src/pkg/go/printer/printer.go
@@ -452,7 +452,7 @@ func trimRight(s string) string {
 
 // stripCommonPrefix removes a common prefix from /*-style comment lines (unless no
 // comment line is indented, all but the first line have some form of space prefix).
-// The prefix is computed using heuristics such that is is likely that the comment
+// The prefix is computed using heuristics such that is likely that the comment
 // contents are nicely laid out after re-printing each line using the printer's
 // current indentation.
 //
diff --git a/src/pkg/html/template/js.go b/src/pkg/html/template/js.go
index a895a50aa9..a9740931fc 100644
--- a/src/pkg/html/template/js.go
+++ b/src/pkg/html/template/js.go
@@ -14,7 +14,7 @@ import (
 )
 
 // nextJSCtx returns the context that determines whether a slash after the
-// given run of tokens tokens starts a regular expression instead of a division
+// given run of tokens starts a regular expression instead of a division
 // operator: / or /=.
 //
 // This assumes that the token run does not include any string tokens, comment
diff --git a/src/pkg/image/jpeg/huffman.go b/src/pkg/image/jpeg/huffman.go
index 2fc64ade54..9b731fdc4f 100644
--- a/src/pkg/image/jpeg/huffman.go
+++ b/src/pkg/image/jpeg/huffman.go
@@ -163,7 +163,7 @@ func (d *decoder) processDHT(n int) error {
 
 // Returns the next Huffman-coded value from the bit stream, decoded according to h.
 // TODO(nigeltao): This decoding algorithm is simple, but slow. A lookahead table, instead of always
-// peeling off only 1 bit at at time, ought to be faster.
+// peeling off only 1 bit at time, ought to be faster.
 func (d *decoder) decodeHuffman(h *huffman) (uint8, error) {
 	if h.length == 0 {
 		return 0, FormatError("uninitialized Huffman table")
diff --git a/src/pkg/net/http/httptest/server.go b/src/pkg/net/http/httptest/server.go
index 165600e52b..0997a8a232 100644
--- a/src/pkg/net/http/httptest/server.go
+++ b/src/pkg/net/http/httptest/server.go
@@ -21,7 +21,7 @@ import (
 type Server struct {
 	URL      string // base URL of form http://ipaddr:port with no trailing slash
 	Listener net.Listener
-	TLS      *tls.Config // nil if not using using TLS
+	TLS      *tls.Config // nil if not using TLS
 
 	// Config may be changed after calling NewUnstartedServer and
 	// before Start or StartTLS.
diff --git a/src/pkg/net/http/server.go b/src/pkg/net/http/server.go
index 719cecfbda..805e0737a9 100644
--- a/src/pkg/net/http/server.go
+++ b/src/pkg/net/http/server.go
@@ -127,7 +127,7 @@ type response struct {
 
 	// requestBodyLimitHit is set by requestTooLarge when
 	// maxBytesReader hits its max size. It is checked in
-	// WriteHeader, to make sure we don't consume the the
+	// WriteHeader, to make sure we don't consume the
 	// remaining request body to try to advance to the next HTTP
 	// request. Instead, when this is set, we stop reading
 	// subsequent requests on this connection and stop reading
diff --git a/src/pkg/net/http/transport_test.go b/src/pkg/net/http/transport_test.go
index e4072e88fe..e114e71480 100644
--- a/src/pkg/net/http/transport_test.go
+++ b/src/pkg/net/http/transport_test.go
@@ -281,7 +281,7 @@ func TestTransportMaxPerHostIdleConns(t *testing.T) {
 	c := &Client{Transport: tr}
 
 	// Start 3 outstanding requests and wait for the server to get them.
-	// Their responses will hang until we we write to resch, though.
+	// Their responses will hang until we write to resch, though.
 	donech := make(chan bool)
 	doReq := func() {
 		resp, err := c.Get(ts.URL)
diff --git a/src/pkg/reflect/type.go b/src/pkg/reflect/type.go
index 110141955c..6c7571b28f 100644
--- a/src/pkg/reflect/type.go
+++ b/src/pkg/reflect/type.go
@@ -1338,7 +1338,7 @@ func cachePut(k cacheKey, t *rtype) Type {
 	return t
 }
 
-// ChanOf returns the channel type with the given direction and and element type.
+// ChanOf returns the channel type with the given direction and element type.
 // For example, if t represents int, ChanOf(RecvDir, t) represents <-chan int.
 //
 // The gc runtime imposes a limit of 64 kB on channel element types.

コアとなるコードの解説

このコミットは、Go標準ライブラリ内の複数のファイルにわたるコメントや文字列リテラル内の重複した単語を修正しています。以下に、各ファイルの具体的な修正内容とその意図を解説します。

  1. src/pkg/container/ring/ring.go:

    • 修正前: // Link connects ring r with with ring s such that r.Next()
    • 修正後: // Link connects ring r with ring s such that r.Next()
    • 解説: "with" が重複していました。リングバッファのリンク操作に関するコメントの可読性を向上させます。
  2. src/pkg/encoding/binary/binary.go:

    • 修正前: // When writing structs, zero values are are written for fields
    • 修正後: // When writing structs, zero values are written for fields
    • 解説: "are" が重複していました。バイナリエンコーディングにおける構造体の書き込みに関するコメントの修正です。
  3. src/pkg/encoding/csv/writer.go:

    • 修正前: Comma rune // Field delimiter (set to to ',' by NewWriter)
    • 修正後: Comma rune // Field delimiter (set to ',' by NewWriter)
    • 解説: "to" が重複していました。CSVライターのフィールド区切り文字に関するコメントの修正です。
  4. src/pkg/exp/locale/collate/collate.go:

    • 修正前: // representation of a a primary weight is always smaller than 0xFF,
    • 修正後: // representation of a primary weight is always smaller than 0xFF,
    • 解説: "a" が重複していました。ロケール照合における重み付けに関するコメントの修正です。
  5. src/pkg/go/printer/printer.go:

    • 修正前: // The prefix is computed using heuristics such that is is likely that the comment
    • 修正後: // The prefix is computed using heuristics such that is likely that the comment
    • 解説: "is" が重複していました。Goコードの整形(プリンター)におけるコメントのプレフィックス処理に関するコメントの修正です。
  6. src/pkg/html/template/js.go:

    • 修正前: // given run of tokens tokens starts a regular expression instead of a division
    • 修正後: // given run of tokens starts a regular expression instead of a division
    • 解説: "tokens" が重複していました。HTMLテンプレートのJavaScriptコンテキスト解析に関するコメントの修正です。
  7. src/pkg/image/jpeg/huffman.go:

    • 修正前: // peeling off only 1 bit at at time, ought to be faster.
    • 修正後: // peeling off only 1 bit at time, ought to be faster.
    • 解説: "at" が重複していました。JPEGのハフマン符号化デコードに関するコメントの修正です。
  8. src/pkg/net/http/httptest/server.go:

    • 修正前: TLS *tls.Config // nil if not using using TLS
    • 修正後: TLS *tls.Config // nil if not using TLS
    • 解説: "using" が重複していました。HTTPテストサーバーのTLS設定に関するコメントの修正です。
  9. src/pkg/net/http/server.go:

    • 修正前: // WriteHeader, to make sure we don't consume the the
    • 修正後: // WriteHeader, to make sure we don't consume the
    • 解説: "the" が重複していました。HTTPサーバーのレスポンスヘッダー書き込みに関するコメントの修正です。
  10. src/pkg/net/http/transport_test.go:

    • 修正前: // Their responses will hang until we we write to resch, though.
    • 修正後: // Their responses will hang until we write to resch, though.
    • 解説: "we" が重複していました。HTTPトランスポートのテストコード内のコメントの修正です。
  11. src/pkg/reflect/type.go:

    • 修正前: // ChanOf returns the channel type with the given direction and and element type.
    • 修正後: // ChanOf returns the channel type with the given direction and element type.
    • 解説: "and" が重複していました。リフレクションにおけるチャネル型の取得に関するコメントの修正です。

これらの修正はすべて、コードの機能には影響を与えず、単にコメントや説明文の文法的な正確性と可読性を向上させるためのものです。

関連リンク

参考にした情報源リンク

  • Go言語公式ドキュメント (各パッケージの概要): https://pkg.go.dev/
  • Go言語の標準ライブラリに関する一般的な情報源。