[インデックス 11889] ファイルの概要
このコミットは、Go言語の公式ドキュメントにおけるインストールガイドの構成を大幅に更新するものです。具体的には、バイナリディストリビューションからのインストール手順と、ソースコードからのビルド手順を分離し、それぞれ独立したドキュメントとして提供するように変更されました。
コミット
- コミットハッシュ:
e07f089cb02790b6fedab92105eba09bd578aae7
- Author: Andrew Gerrand adg@golang.org
- Date: Tue Feb 14 17:02:28 2012 +1100
GitHub上でのコミットページへのリンク
https://github.com/golang/go/commit/e07f089cb02790b6fedab92105eba09bd578aae7
元コミット内容
doc: update install.html for binary distros, add install-source.html
R=bsiegert, rsc, r
CC=golang-dev
https://golang.org/cl/5605047
変更の背景
このコミットが行われた2012年当時、Go言語はまだ比較的新しい言語であり、そのインストール方法は進化の途中にありました。初期のGoのインストールガイドは、ソースコードからのビルド手順とバイナリディストリビューションからのインストール手順が混在しており、ユーザーにとって混乱を招く可能性がありました。
この変更の主な背景は以下の通りです。
- ユーザーエクスペリエンスの向上: 多くのユーザーは、Goをすぐに使い始めるためにバイナリディストリビューションを好みます。ソースからのビルドは、開発者や特定の環境要件を持つユーザーに限定されます。両方の手順が同じページに混在していると、必要な情報を見つけにくく、特に初心者にとっては敷居が高く感じられる可能性がありました。
- ドキュメントの明確化と整理: インストール方法が複数ある場合、それぞれの方法に特化したドキュメントを用意することで、情報の構造がより明確になります。これにより、ユーザーは自分のニーズに合ったドキュメントに直接アクセスできるようになります。
- Goエコシステムの成熟: Goが普及するにつれて、より多くのユーザーがバイナリディストリビューションを利用するようになります。これに対応するため、バイナリインストールを主要な方法として強調し、その手順を簡潔にまとめる必要がありました。
- メンテナンスの容易性: ドキュメントを分割することで、それぞれのインストール方法に関する変更や更新が独立して行えるようになり、ドキュメント全体のメンテナンスが容易になります。
このコミットは、Go言語のインストールプロセスをよりユーザーフレンドリーにし、ドキュメントの品質を向上させるための重要なステップでした。
前提知識の解説
このコミットの変更内容を理解するためには、以下の前提知識が役立ちます。
1. Go言語のコンパイラ: gc
と gccgo
Go言語には、主に2つの公式コンパイラツールチェーンが存在します。
gc
(Go Compiler):- Goプロジェクトによって開発・メンテナンスされている、Go言語の「標準」コンパイラです。
- Go言語のリリースサイクルと密接に連携しており、最新の言語機能や最適化が最も早く取り入れられます。
- Goのツールチェイン(
go build
,go run
など)の基盤となっています。 - このコミットの時点では、
6g
,8g
,5g
といったアーキテクチャ固有のコンパイラ名が使われていましたが、後にgo build
コマンドに統合され、ユーザーが直接これらのコマンドを意識することは少なくなりました。
gccgo
:- GCC (GNU Compiler Collection) のフロントエンドとして実装されたGoコンパイラです。
- GCCの強力な最適化バックエンドを利用できるため、特定のケースでは
gc
よりも優れたパフォーマンスを発揮することがあります。 - GCCの一部としてリリースされるため、Go言語の最新機能への対応は
gc
よりも遅れる傾向があります。 - C/C++など他のGCCがサポートする言語との連携が容易です。
このコミットは主に gc
コンパイラのインストールに関するドキュメントの変更に焦点を当てています。
2. Go言語のインストール方法
Go言語のインストールには、大きく分けて以下の2つの主要な方法があります。
- バイナリディストリビューションからのインストール:
- Goの公式サイトから、事前にコンパイルされたGoツールチェインのアーカイブ(例:
.tar.gz
,.zip
,.pkg
)をダウンロードし、システムに展開する方法です。 - 最も簡単で推奨されるインストール方法であり、Goをすぐに使い始めたいユーザーに適しています。
- このコミットでは、
install.html
がこの方法に特化するように変更されました。
- Goの公式サイトから、事前にコンパイルされたGoツールチェインのアーカイブ(例:
- ソースコードからのビルド:
- Goのソースコードリポジトリをクローンし、自身の環境でGoツールチェインをコンパイルしてビルドする方法です。
- Goの最新の開発版を試したい、特定のプラットフォーム向けにカスタマイズしたい、Goの内部動作を研究したいといったユーザーに適しています。
- このコミットでは、この方法のために
install-source.html
という新しいドキュメントが作成されました。
3. Mercurial (Hg)
Mercurialは、Gitと同様の分散型バージョン管理システム(DVCS)です。Go言語の初期の開発では、GitではなくMercurialが主要なバージョン管理システムとして使用されていました。
- Goのソースコードは、
code.google.com/p/go
というMercurialリポジトリで管理されていました。 - ソースからのビルド手順には、
hg clone
コマンドを使ったリポジトリのクローンが含まれていました。 - Goプロジェクトは後にGitに移行しましたが、このコミットの時点ではMercurialが使われていたため、ドキュメントにもその記述が見られます。
4. 環境変数 (GOROOT
, GOOS
, GOARCH
など)
Go言語のビルドおよび実行環境は、いくつかの環境変数によって制御されます。
GOROOT
: Goのインストールディレクトリのルートパスを指定します。GOOS
: ターゲットとするオペレーティングシステム(例:linux
,darwin
,windows
)を指定します。GOARCH
: ターゲットとするアーキテクチャ(例:amd64
,386
,arm
)を指定します。GOHOSTOS
,GOHOSTARCH
: ビルドを実行するホストのOSとアーキテクチャを指定します。クロスコンパイル時に重要になります。GOBIN
: Goのバイナリがインストールされるディレクトリを指定します。
これらの環境変数は、Goのビルドシステムが正しく動作するために不可欠であり、特にソースからのビルドやクロスコンパイルを行う際に重要となります。
技術的詳細
このコミットの技術的な詳細は、主にGo言語の公式ドキュメントの構造変更と、それに伴うコンテンツの再編成にあります。
1. ドキュメントの分割と役割分担
doc/install.html
の役割変更:- このファイルは、Go言語のインストールに関する主要なエントリポイントとして機能していました。
- コミット前は、バイナリインストールとソースからのビルドの両方の手順が混在していました。
- コミット後は、バイナリディストリビューションからのインストールに特化するように大幅に簡素化されました。これにより、Goをすぐに使い始めたいユーザーが迷うことなく手順を進められるようになりました。
gc
コンパイラのバイナリインストールに焦点を当て、gccgo
やソースからのビルドへのリンクが冒頭に配置され、ユーザーが適切なドキュメントに誘導されるようになりました。
doc/install-source.html
の新規追加:- このコミットの主要な変更点の一つは、
install-source.html
という新しいファイルが追加されたことです。 - このファイルは、Go言語のソースコードからビルドする手順に完全に特化しています。
- ソースからのビルドに必要な前提ツール(Cコンパイラ、Mercurialなど)のインストール方法、リポジトリの取得、ビルドスクリプトの実行方法、環境変数の設定など、詳細な手順が網羅されています。
gc
コンパイラに焦点を当てつつ、gccgo
への言及も含まれています。
- このコミットの主要な変更点の一つは、
doc/gccgo_install.html
の微修正:- このファイルは
gccgo
コンパイラのインストールに関するドキュメントです。 - 今回のコミットでは、タイトルとパスのメタデータが更新されたのみで、コンテンツ自体に大きな変更はありません。これは、
gccgo
のインストールがgc
とは異なる独立したプロセスであることを明確にするためと考えられます。
- このファイルは
2. コンテンツの再編成と簡素化
install.html
からの情報の削除:- コミット前の
install.html
に含まれていた、CツールやMercurialのインストール、リポジトリのフェッチ、ソースからのビルド、Goプログラムのコンパイル・リンク・実行に関する詳細な説明が、install-source.html
へと移動または削除されました。 - これにより、
install.html
はバイナリインストールに特化した、より簡潔で読みやすいドキュメントになりました。
- コミット前の
- 新しい
install-source.html
の詳細な記述:install-source.html
は、ソースからのビルドに必要なすべてのステップを網羅しています。- Goのコンパイラ(
amd64
,386
,arm
)の特性、サポートされるOSとアーキテクチャの組み合わせ、ビルドに必要なCツール(GCC, libc6-devなど)のインストールコマンド、MercurialのインストールとCA証明書の設定、Goリポジトリのクローン方法、all.bash
スクリプトによるビルド手順、インストール後のテスト方法、そしてGoのビルド環境をカスタマイズするための各種環境変数(GOROOT
,GOOS
,GOARCH
,GOBIN
など)の詳細な説明が含まれています。 - 特に、
$GOOS
と$GOARCH
の有効な組み合わせの表は、クロスコンパイルを行うユーザーにとって非常に有用な情報です。
3. ドキュメントのメタデータ
- 各HTMLファイルの冒頭には、
<!--{ "Title": "...", "Path": "..." }-->
という形式のメタデータが含まれています。 - これは、GoのドキュメントシステムがページのタイトルやURLパスを生成するために使用するものです。
- このコミットでは、
install-source.html
に新しいパス/install/source/
が割り当てられ、gccgo_install.html
のパスも/install/gccgo/
に更新されました。これにより、ドキュメントのURL構造がより論理的で予測可能になりました。
この変更は、Go言語のドキュメントがユーザーの多様なニーズに対応し、より使いやすくなるための重要な改善であり、Goプロジェクトがドキュメントの品質にも力を入れていることを示しています。
コアとなるコードの変更箇所
このコミットにおけるコアとなるコードの変更は、主に以下の3つのHTMLドキュメントファイルに集中しています。
-
doc/gccgo_install.html
:- 変更点: 3行変更 (1挿入, 2削除)
- 内容: ファイル冒頭のメタデータ部分が修正されました。
--- a/doc/gccgo_install.html +++ b/doc/gccgo_install.html @@ -1,5 +1,6 @@ <!--{ - "Title": "Setting up and using gccgo" + "Title": "Setting up and using gccgo", + "Path": "/install/gccgo/" }--> <p>
"Path"
メタデータが追加され、このドキュメントのURLが/install/gccgo/
となるように指定されました。
-
doc/install-source.html
:- 変更点: 475行挿入 (新規ファイル)
- 内容: Go言語をソースコードからビルドするための詳細な手順を記述した新しいファイルが追加されました。
h2
タグで「Introduction」「Install C tools, if needed」「Install Mercurial, if needed」「Fetch the repository」「Install Go」「Testing your installation」「What's next」「Community resources」「Keeping up with releases」「Optional environment variables」といったセクションが定義されています。- Goの
gc
コンパイラ(6g
,8g
,5g
)とgccgo
の違い、サポートされるアーキテクチャ(amd64
,386
,arm
)、OS(FreeBSD, Linux, NetBSD, OpenBSD, OS X, Windows)に関する説明が含まれています。 - Cコンパイラ(GCC, libc6-dev)、Mercurialのインストール手順、Goリポジトリのクローン方法(
hg clone
)、ビルドスクリプト(./all.bash
)の実行方法が具体的に示されています。 - インストール後のテスト方法として、
hello.go
プログラムの作成と実行例が提供されています。 $GOROOT
,$GOROOT_FINAL
,$GOOS
,$GOARCH
,$GOHOSTOS
,$GOHOSTARCH
,$GOBIN
,$GOARM
といった環境変数の詳細な解説と、それらの設定例が含まれています。
-
doc/install.html
:- 変更点: 397行変更 (109挿入, 288削除)
- 内容: このファイルは大幅に簡素化され、Go言語のバイナリディストリビューションからのインストールに特化するように変更されました。
--- a/doc/install.html +++ b/doc/install.html @@ -5,257 +5,140 @@ <h2 id="introduction">Introduction</h2> -<p>Go is an open source project, distributed under a -<a href="/LICENSE">BSD-style license</a>. -This document explains how to check out the sources, -build them on your own machine, and run them. +<p> +Go is an open source project with a BSD-style license. +There are two official Go compiler toolchains: the <code>gc</code> Go compiler +and the <code>gccgo</code> compiler that is part of the GNU C Compiler (GCC). </p> -<div class="detail"> - <p> -There are two distinct ways to experiment with Go. -This document focuses on the <code>gc</code> Go -compiler and tools (<code>6g</code>, <code>8g</code> etc.). -For information on how to use <code>gccgo</code>, a more traditional -compiler using the GCC back end, see -<a href="gccgo_install.html">Setting up and using gccgo</a>. +The <code>gc</code> compiler is the more mature and well-tested of the two. +This page is about installing a binary distribution of the <code>gc</code> +compiler. </p> <p> -The Go compilers support three instruction sets. -There are important differences in the quality of the compilers for the different -architectures. +For information about installing the <code>gc</code> compiler from source, see +<a href="/install/source/">Installing Go from source</a>. +For information about installing <code>gccgo</code>, see +<a href="/install/gccgo/">Setting up and using gccgo</a>. </p> -<dl> -<dt> - <code>amd64</code> (a.k.a. <code>x86-64</code>); <code>6g,6l,6c,6a</code> -</dt> -<dd> - The most mature implementation. The compiler has an effective optimizer - (registerizer) and generates good code (although <code>gccgo</code> - can do noticeably better sometimes). -</dd> -<dt> - <code>386</code> (a.k.a. <code>x86</code> or <code>x86-32</code>); <code>8g,8l,8c,8a</code> -</dt> -<dd> - Comparable to the <code>amd64</code> port. -</dd> -<dt> - <code>arm</code> (a.k.a. <code>ARM</code>); <code>5g,5l,5c,5a</code> -</dt> -<dd> - Incomplete. - It only supports Linux binaries, the optimizer is incomplete, - and floating point uses the VFP unit. - However, all tests pass. - Work on the optimizer is continuing. - Tested against a Nexus One. -</dd> -</dl> +<h2 id="download">Obtaining the Go tools</h2> <p> -Except for things like low-level operating system interface code, the run-time -support is the same in all ports and includes a mark-and-sweep garbage collector -(a fancier one is in the works), efficient array and string slicing, -support for segmented stacks, and a strong goroutine implementation. +Visit the +<a href="http://code.google.com/p/go/downloads">Go project's downloads page</a> +and select the binary distribution that matches +your operating system and processor architecture. </p> <p> -The compilers can target the FreeBSD, Linux, OpenBSD -and OS X (a.k.a. Darwin) operating systems. -(A port to Microsoft Windows is in progress but incomplete. See the -<a href="http://code.google.com/p/go/wiki/WindowsPort">Windows Port</a> -page for details.) -The full set of supported combinations is listed in the discussion of -<a href="#environment">environment variables</a> below. -</p> - -</div> - -<h2 id="ctools">Install C tools, if needed</h2> - -<p>The Go tool chain is written in C. -To build it, you need these programs installed: -<ul> -<li>GCC, -<li>the standard C libraries, -<li>the parser generator Bison, -<li>GNU <tt>make</tt> (version 3.81 or later), -and -<li><tt>awk</tt>. -</ul> -</p> - -<p>On OS X, they can be -installed as part of -<a href="http://developer.apple.com/Xcode/">Xcode</a>. +Official binary distributions are available +for the FreeBSD, Linux, Mac OS X, and Windows operating systems +and the 32-bit (<code>386</code>) and 64-bit (<code>amd64</code>) +x86 processor architectures. </p> <p> -On Ubuntu/Debian, use <code>sudo apt-get install bison gawk gcc libc6-dev -make</code>. If you want to build 32-bit binaries on a 64-bit system you'll -also need the <code>libc6-dev-i386</code> package. +If a binary distribution is not available for your +OS/arch combination you may want to try +<a href="/install/source/">installing from source</a> or +<a href="/install/gccgo/">installing gccgo instead of gc</a>. </p> -<h2 id="mercurial">Install Mercurial, if needed</h2> +<h2 id="install">Installing the Go tools</h2> <p> -To perform the next step you must have Mercurial installed. (Check that you have an <code>hg</code> command.) This suffices to install Mercurial on most systems: -</p> -<pre> -sudo easy_install mercurial==2.0 -</pre> -(On Ubuntu/Debian, you might try <code>apt-get install python-setuptools -python-dev build-essential</code> first. The Mercurial in your distribution's -package repository will most likely be old and broken.) -</p> -<p> -If that fails, try installing manually from the <a href="http://mercurial.selenic.com/wiki/Download">Mercurial Download</a> page.</p> +The Go binary distributions assume they will be installed in +<code>/usr/local/go</code>, but it is possible to install them in a different +location. If you do this, you will need to set the <code>GOROOT</code> +environment variable to that directory when using the Go tools. </p> <p> -Mercurial versions 1.7.x and up require the configuration of -<a href="http://mercurial.selenic.com/wiki/CACertificates">Certification Authorities</a> -(CAs). Error messages of the form: -</p> -<pre> -warning: code.google.com certificate with fingerprint b1:af: ... bc not verified (check hostfingerprints or web.cacerts config setting) -</pre> -<p> -when using Mercurial indicate that the CAs are missing. -Check your Mercurial version (<code>hg --version</code>) and -<a href="http://mercurial.selenic.com/wiki/CACertificates#Configuration_of_HTTPS_certificate_authorities">configure the CAs</a> -if necessary. +For example, if you installed Go to your home directory you should add the +following commands to <code>$HOME/.profile</code>: </p> -<h2 id="fetch">Fetch the repository</h2> - -<p> -<p>Go will install to a directory named <code>go</code>. -Change to the directory that will be its parent -and make sure the <code>go</code> directory does not exist. -Then check out the repository:</p> - <pre> -$ hg clone -u release https://code.google.com/p/go +export GOROOT=$HOME/go +export PATH=$PATH:$GOROOT/bin </pre> -<h2 id="install">Install Go</h2> +<h3 id="freebsd_linux">FreeBSD and Linux</h3> <p> -To build the Go distribution, run +Extract the archive into <code>/usr/local</code>, creating a Go tree in +<code>/usr/local/go</code> (typically this must be run as root or through +<code>sudo</code>): </p> <pre> -$ cd go/src -$ ./all.bash +tar -C /usr/local go.release.go1.tar.gz </pre> <p> -If all goes well, it will finish by printing output like: +Add <code>/usr/local/go/bin</code> to the <code>PATH</code> environment +variable. You can do this by adding this line to your <code>/etc/profile</code> +(for a system-wide installation) or <code>$HOME/.profile</code>: </p> <pre> -ALL TESTS PASSED - ---- -Installed Go for linux/amd64 in /home/you/go. -Installed commands in /home/you/go/bin. -*** You need to add /home/you/go/bin to your $PATH. *** -The compiler is 6g. +export PATH=$PATH:/usr/local/go/bin </pre> -<p> -where the details on the last few lines reflect the operating system, -architecture, and root directory used during the install. -</p> - -<div class="detail"> - -<p>For more information about ways to control the build, -see the discussion of <a href="#environment">environment variables</a> below.</p> -</div> - -<h2 id="writing">Writing programs</h2> +<h3 id="osx">Mac OS X</h3> <p> -Given a file <code>file.go</code>, compile it using +Open the <code>.pkg</code> file and follow the prompts to install the Go tools. +The package installs the Go distribution to <code>/usr/local/go</code>. </p> <pre> -$ 6g file.go -</pre> - <p> -<code>6g</code> is the Go compiler for <code>amd64</code>; it will write the output -in <code>file.6</code>. The ‘<code>6</code>’ identifies -files for the <code>amd64</code> architecture. -The identifier letters for <code>386</code> and <code>arm</code> -are ‘<code>8</code>’ and ‘<code>5</code>’. -That is, if you were compiling for <code>386</code>, you would use -<code>8g</code> and the output would be named <code>file.8</code>. +The package should put the <code>/usr/local/go/bin</code> directory in your +<code>PATH</code> environment variable. You may need to restart any open +Terminal sessions for the change to take effect. </p> +<h3 id="windows">Windows</h3> + <p> -To link the file, use +<font color="red">TODO: windows installation instructions.</font> </p> -<pre> -$ 6l file.6 -</pre> +<h2 id="testing">Testing your installation</h2> <p> -and to run it +Check that Go is installed correctly by building a simple program, as follows. </p> <pre> -$ ./6.out -</pre> - -<p>A complete example: +<p> +Create a file named <code>hello.go</code> and put the following program in it: </p> <pre> -$ cat >hello.go <<EOF package main import "fmt" func main() { -\tfmt.Printf("hello, world\n") + fmt.Printf("hello, world\n") }\n -EOF -$ 6g hello.go -$ 6l hello.6 -$ ./6.out -hello, world -$ </pre> <p> -There is no need to list <code>hello.6</code>'s package dependencies -(in this case, package <code>fmt</code>) on the <code>6l</code> -command line. -The linker learns about them by reading <code>hello.6</code>. +Then run it with the <code>go</code> tool: </p> -<div class="detail"> +<pre> +$ go run hello.go +hello, world +</pre> + <p> -To build more complicated programs, you will probably -want to use a -<code>Makefile</code>. -There are examples in places like -<code>go/src/cmd/godoc/Makefile</code> -and <code>go/src/pkg/*/Makefile</code>. -The -<a href="contribute.html">document</a> -about contributing to the Go project -gives more detail about -the process of building and testing Go programs. +If you see the "hello, world" message then your Go installation is working. </p> -</div> <h2 id="next">What's next</h2> @@ -264,6 +147,11 @@ Start by taking <a href="http://code.google.com/p/go-tour/">A Tour of Go</a> or reading the <a href="go_tutorial.html">Go Tutorial</a>. </p> +<p> +For more detail about the process of building and testing Go programs +read <a href="/doc/code.html">How to Write Go Code</a>. +</p> + <p> Build a web application by following the <a href="codelab/wiki/">Wiki Codelab</a>. @@ -279,39 +167,6 @@ For the full story, consult Go's extensive <a href="docs.html">documentation</a>. </p> -<h2 id="releases">Keeping up with releases</h2> - -<p> -The Go project maintains two stable tags in its Mercurial repository: -<code>release</code> and <code>weekly</code>. -The <code>weekly</code> tag is updated about once a week, and should be used by -those who want to track the project's development. -The <code>release</code> tag is given, less often, to those weekly releases -that have proven themselves to be robust. -</p> - -<p> -Most Go users will want to keep their Go installation at the latest -<code>release</code> tag. -New releases are announced on the -<a href="http://groups.google.com/group/golang-announce">golang-announce</a> -mailing list. -</p> - -<p> -To update an existing tree to the latest release, you can run: -</p> - -<pre> -$ cd go/src -$ hg pull -$ hg update release -$ ./all.bash -</pre> - -<p> -To use the <code>weekly</code> tag run <code>hg update weekly</code> instead. -</p> - <h2 id="community">Community resources</h2> @@ -326,158 +181,6 @@ The official mailing list for discussion of the Go language is </p> <p> -Bugs can be reported using the <a href="http://code.google.com/p/go/issues/list">Go issue tracker</a>. -</p> - -<p> -For those who wish to keep up with development, -there is another mailing list, <a href="http://groups.google.com/group/golang-checkins">golang-checkins</a>, -that receives a message summarizing each checkin to the Go repository. -</p> - -<h2 id="environment">Optional environment variables</h2> - -<p> -The Go compilation environment can be customized by environment variables. -<i>None are required by the build</i>, but you may wish to set them -to override the defaults. +Bugs should be reported using the +<a href="http://code.google.com/p/go/issues/list">Go issue tracker</a>. </p> - -<dl> -<dt> - <code>$GOROOT</code> -</dt> -<dd> - The root of the Go tree, often <code>$HOME/go</code>. - This defaults to the parent of the directory where <code>all.bash</code> is run. - If you choose not to set <code>$GOROOT</code>, you must - run <code>go tool make</code> instead of <code>make</code> or <code>gmake</code> - when developing Go programs using the conventional makefiles. -</dd> - -<dt> - <code>$GOROOT_FINAL</code> -</dt> -<dd> - The value assumed by installed binaries and scripts when - <code>$GOROOT</code> is not set. - It defaults to the value used for <code>$GOROOT</code>. - If you want to build the Go tree in one location - but move it elsewhere after the build, set - <code>$GOROOT_FINAL</code> to the eventual location. -</dd> - -<dt> -<code>$GOOS</code> and <code>$GOARCH</code> -</dt> -<dd> - The name of the target operating system and compilation architecture. - These default to the values of <code>$GOHOSTOS</code> and - <code>$GOHOSTARCH</code> respectively (described below). - - <p> - Choices for <code>$GOOS</code> are - <code>darwin</code> (Mac OS X 10.5 or 10.6), - <code>freebsd</code>, <code>linux</code>, <code>openbsd</code>, - and <code>windows</code> (Windows, an incomplete port). - Choices for <code>$GOARCH</code> are <code>amd64</code> (64-bit x86, the most mature port), - <code>386</code> (32-bit x86), and - <code>arm</code> (32-bit ARM, an incomplete port). - The valid combinations of <code>$GOOS</code> and <code>$GOARCH</code> are: - <table cellpadding="0"> - <tr> - <th width="50"><th align="left" width="100"><code>$GOOS</code></th> <th align="left" width="100"><code>$GOARCH</code></th> <th align="left"></th> - </tr> - <tr> - <td></td><td><code>darwin</code></td> <td><code>386</code></td> - </tr> - <tr> - <td></td><td><code>darwin</code></td> <td><code>amd64</code></td> - </tr> - <tr> - <td></td><td><code>freebsd</code></td> <td><code>386</code></td> - </tr> - <tr> - <td></td><td><code>freebsd</code></td> <td><code>amd64</code></td> - </tr> - <tr> - <td></td><td><code>linux</code></td> <td><code>386</code></td> - </tr> - <tr> - <td></td><td><code>linux</code></td> <td><code>amd64</code></td> - </tr> - <tr> - <td></td><td><code>linux</code></td> <td><code>arm</code></td> <td><i>incomplete</i></td> - </tr> - <tr> - <td></td><td><code>openbsd</code></td> <td><code>386</code></td> - </tr> - <tr> - <td></td><td><code>openbsd</code></td> <td><code>amd64</code></td> - </tr> - <tr> - <td></td><td><code>windows</code></td> <td><code>386</code></td> <td><i>incomplete</i></td> - </tr> - </table> -</dd> - -<dt> -<code>$GOHOSTOS</code> and <code>$GOHOSTARCH</code> -</dt> -<dd> - The name of the host operating system and compilation architecture. - These default to the local system's operating system and - architecture. - - <p> - Valid choices are the same as for <code>$GOOS</code> and - <code>$GOARCH</code>, listed above. - The specified values must be compatible with the local system. - For example, you should not set <code>$GOHOSTARCH</code> to - <code>arm</code> on an x86 system. -</dd> - -<dt> -<code>$GOBIN</code> -</dt> -<dd> - The location where binaries will be installed. - The default is <code>$GOROOT/bin</code>. - After installing, you will want to arrange to add this - directory to your <code>$PATH</code>, so you can use the tools. -</dd> - -<dt> -<code>$GOARM</code> (arm, default=6) -</dt> -<dd> - The ARM architecture version the run-time libraries should target. - Setting <code>$GOARM</code> to 5 causes the linker to emit calls - to a software floating point implementation instead of using - hardware floating point support. -</dd> -</dl> - -<p> -Note that <code>$GOARCH</code> and <code>$GOOS</code> identify the -<em>target</em> environment, not the environment you are running on. -In effect, you are always cross-compiling. -By architecture, we mean the kind of binaries -that the target environment can run: -an x86-64 system running a 32-bit-only operating system -must set <code>GOARCH</code> to <code>386</code>, -not <code>amd64</code>. -</p> - -<p> -If you choose to override the defaults, -set these variables in your shell profile (<code>$HOME/.bashrc</code>, -<code>$HOME/.profile</code>, or equivalent). The settings might look -something like this: -</p> - -<pre> -export GOROOT=$HOME/go -export GOARCH=amd64 -export GOOS=linux -</pre>
install.html
からは、ソースからのビルドに関する詳細な説明(Cツール、Mercurial、リポジトリのフェッチ、all.bash
の実行、環境変数など)が削除されました。代わりに、Goのダウンロードページへのリンク、バイナリディストリビューションのインストール手順(tar -C /usr/local go.release.go1.tar.gz
など)、PATH
環境変数の設定、そしてインストール後のテスト方法(hello.go
の実行)が簡潔に記述されています。また、ソースからのインストールやgccgo
のインストールに関する新しいドキュメントへのリンクが追加されました。
これらの変更により、Goのインストールドキュメントは、ユーザーのニーズに応じて「バイナリインストール」「ソースからのビルド」「gccgoインストール」の3つの明確なパスに分かれ、それぞれの情報がより整理され、アクセスしやすくなりました。
コアとなるコードの解説
このコミットの核心は、Go言語のインストールに関するドキュメントの構造を、ユーザーの異なるニーズに合わせて最適化した点にあります。
doc/install.html
の簡素化と目的の明確化
以前の install.html
は、Goのインストールに関するあらゆる情報を詰め込んだ「オールインワン」のページでした。しかし、これは情報過多となり、特にGoを初めて使うユーザーにとっては混乱を招く可能性がありました。
このコミットにより、install.html
は以下の点に焦点を当てるようになりました。
- バイナリディストリビューションの推奨: ほとんどのユーザーにとって最も簡単なインストール方法である、事前にコンパイルされたバイナリパッケージの使用を明確に推奨しています。
- 簡潔な手順: ダウンロード、アーカイブの展開、
PATH
環境変数の設定といった、バイナリインストールに必要な最小限かつ最も一般的な手順のみを記載しています。 - 他のインストール方法への誘導: ソースからのビルドや
gccgo
の使用を希望するユーザーのために、それぞれの専用ドキュメントへの明確なリンクを提供しています。これにより、ユーザーは自分の目的に合った詳細情報にスムーズにアクセスできます。 - Goコンパイラの概要:
gc
とgccgo
の2つの主要なコンパイラが存在することを冒頭で説明し、このページがgc
のバイナリインストールに特化していることを明示しています。
この変更により、install.html
は「Goを素早く使い始めるためのガイド」としての役割をより効果的に果たせるようになりました。
doc/install-source.html
の新規作成と詳細な解説
Goのソースコードからビルドするプロセスは、バイナリインストールよりも多くのステップと前提知識を必要とします。この複雑なプロセスを独立したドキュメントとして切り出すことで、以下のメリットが生まれました。
- 包括的な情報提供: ソースからのビルドに必要なすべての前提条件(Cコンパイラ、Mercurialなど)、リポジトリの取得方法、ビルドスクリプトの実行、そしてGoのビルド環境をカスタマイズするための詳細な環境変数(
GOROOT
,GOOS
,GOARCH
など)に関する情報が、一箇所に集約されました。 - 技術的詳細の深掘り: 各アーキテクチャ(
amd64
,386
,arm
)の特性や、サポートされるOSとアーキテクチャの組み合わせといった、より技術的な詳細が提供されています。これは、特定の環境でGoをビルドしたり、クロスコンパイルを行ったりする開発者にとって不可欠な情報です。 - 自己完結性: このドキュメントは、ソースからのビルドに関するすべての情報を網羅しているため、ユーザーは他のドキュメントを参照することなく、このページだけでビルドを完遂できます。
install-source.html
は、Goの内部構造に興味がある開発者や、特定の要件を持つ環境でGoを運用する必要があるユーザーにとって、非常に価値のあるリソースとなっています。
doc/gccgo_install.html
のメタデータ更新
gccgo_install.html
の変更は小さいですが、Path
メタデータの追加は、GoのドキュメントシステムにおけるURL構造の標準化と、各ドキュメントの役割の明確化に貢献しています。これにより、gccgo
のインストールガイドが /install/gccgo/
という一貫したURLでアクセスできるようになり、ドキュメント全体のナビゲーションが改善されました。
全体的な影響
このコミットは、Go言語のドキュメントが、単に情報を提供するだけでなく、ユーザーの多様なニーズとスキルレベルに合わせて情報を整理し、アクセスしやすくすることを目指していることを示しています。ドキュメントの分割と専門化は、ユーザーエクスペリエンスの向上、情報の明確化、そして将来的なメンテナンスの容易化に大きく貢献しました。これは、Goプロジェクトがユーザーコミュニティの成長と多様化に対応するための、思慮深いアプローチの一例と言えるでしょう。
関連リンク
- Go言語公式サイト: https://go.dev/
- Goプロジェクトのダウンロードページ (コミット当時のリンク): http://code.google.com/p/go/downloads
- A Tour of Go: http://code.google.com/p/go-tour/
- Go Tutorial: go_tutorial.html (相対パスのため、現在のGoドキュメントサイトで検索してください)
- How to Write Go Code: /doc/code.html
- Wiki Codelab: codelab/wiki/ (相対パスのため、現在のGoドキュメントサイトで検索してください)
- Effective Go: effective_go.html (相対パスのため、現在のGoドキュメントサイトで検索してください)
- Go Documentation: docs.html (相対パスのため、現在のGoドキュメントサイトで検索してください)
- Go Nuts メーリングリスト: http://groups.google.com/group/golang-nuts
- Go issue tracker: http://code.google.com/p/go/issues/list
- golang-checkins メーリングリスト: http://groups.google.com/group/golang-checkins
- golang-announce メーリングリスト: http://groups.google.com/group/golang-announce
- Freenode IRC: http://freenode.net/
参考にした情報源リンク
- Mercurial Download: http://mercurial.selenic.com/wiki/Download
- Mercurial CACertificates: http://mercurial.selenic.com/wiki/CACertificates
- Mercurial CACertificates Configuration: http://mercurial.selenic.com/wiki/CACertificates#Configuration_of_HTTPS_certificate_authorities
- Xcode (Apple Developer): http://developer.apple.com/Xcode/
- Go Wiki - Windows Port (コミット当時のリンク): http://code.google.com/p/go/wiki/WindowsPort
- Go CL 5605047: https://golang.org/cl/5605047 (GoのコードレビューシステムGerritの変更リスト)
- Go言語の歴史に関する一般的な情報 (Web検索による)
- Go言語のドキュメント構造に関する一般的な情報 (Web検索による)