LoginSignup
18
14

More than 3 years have passed since last update.

Go で Go を build して Go を Go で開発しよう

Last updated at Posted at 2019-12-22

はじめに

有名な話ですが、Go は Go で開発することができます。(Go1.5 以降)
Go の開発を Go でできることは、メリットがたくさんあります。

  • 可読性が高いため、他人の書いたソースコードのメンテナンスがしやすい
  • 楽しい
  • 自分の書くソースコードの品質を担保しやすいので、他人に自分のコードを理解してもらいやすい
  • 楽しい

Go はクリーンでシンプルで、パワフルな言語で私は大好きです。
そんな自分が使っている好きなソフトウェアがどのように作られているかは、 とても興味があります。

そんな Go を読めて、 build できて、デバッグできて、ソースコードが書けることはとても面白い活動です。
また、処理系の中身がわかると、よりプログラミング言語の気持ちがわかるようになります。

というわけで、日本からももっと Go へコントリビュートしようぜという想いをこめて、
Go の build 方法と、ソースの変更をしてみた例を簡単に紹介します。

環境

今回試した環境は以下です。
必要なものは、Go1.4 以降の go コマンドと、
Go のソースコードのみのため、環境が変わっても手順などはかわらないはずです。

pure Go で、Go のバイナリが作れるって素敵ですよね。

  • go command
    • Go 1.13
  • go source ver
    • Go1.14beta1
  • host OS
    • Windows 10
  • host Arch
    • amd64

Go のソースコードはどうなっている??

Go のプロジェクト、およびソースコードは、以下の Git リモートリポジトリにて管理されています。

https://go.googlesource.com/go

ルートディレクトリは、以下のような構成になっています。

ディレクトリ名の通り、src 以下にソースコードが登録されています。

aki01@LAPTOP-8UTJLJ8V MINGW64 ~/work/src/go.googlesource.com/goroot (feature/print_gopher)
$ ls -al
total 320
drwxr-xr-x 1 aki01 197609     0 Dec 22 22:03 .
drwxr-xr-x 1 aki01 197609     0 Dec 21 08:36 ..
drwxr-xr-x 1 aki01 197609     0 Dec 22 11:19 .git
-rw-r--r-- 1 aki01 197609   347 Dec 21 08:36 .gitattributes
drwxr-xr-x 1 aki01 197609     0 Dec 21 08:36 .github
-rw-r--r-- 1 aki01 197609   928 Dec 21 08:36 .gitignore
-rw-r--r-- 1 aki01 197609 55383 Dec 21 08:36 AUTHORS
-rw-r--r-- 1 aki01 197609  1339 Dec 21 08:36 CONTRIBUTING.md
-rw-r--r-- 1 aki01 197609 84309 Dec 21 08:36 CONTRIBUTORS
-rw-r--r-- 1 aki01 197609  1479 Dec 21 08:36 LICENSE
-rw-r--r-- 1 aki01 197609  1303 Dec 21 08:36 PATENTS
-rw-r--r-- 1 aki01 197609  1607 Dec 21 08:36 README.md
-rw-r--r-- 1 aki01 197609   397 Dec 21 08:36 SECURITY.md
-rw-r--r-- 1 aki01 197609    48 Dec 22 11:24 VERSION.cache
drwxr-xr-x 1 aki01 197609     0 Dec 21 08:36 api
drwxr-xr-x 1 aki01 197609     0 Dec 22 22:03 bin
drwxr-xr-x 1 aki01 197609     0 Dec 21 08:37 doc
-rw-r--r-- 1 aki01 197609  5686 Dec 21 08:36 favicon.ico
drwxr-xr-x 1 aki01 197609     0 Dec 21 08:36 lib
drwxr-xr-x 1 aki01 197609     0 Dec 21 08:36 misc
drwxr-xr-x 1 aki01 197609     0 Dec 22 11:31 pkg
-rw-r--r-- 1 aki01 197609    26 Dec 21 08:36 robots.txt
drwxr-xr-x 1 aki01 197609     0 Dec 22 22:06 sandbox
drwxr-xr-x 1 aki01 197609     0 Dec 22 22:04 src < ココ
drwxr-xr-x 1 aki01 197609     0 Dec 21 08:36 test

src ディレクトリは以下のようになっています。
そこそこ Go を知っている人ならば、どこにどのソースがあるのかわかるようになっていて、
とてもわかりやすい構成になっています。

aki01@LAPTOP-8UTJLJ8V MINGW64 ~/work/src/go.googlesource.com/goroot (feature/print_gopher)
$ ls -al src/
total 737
drwxr-xr-x 1 aki01 197609    0 Dec 22 22:04 .
drwxr-xr-x 1 aki01 197609    0 Dec 22 22:03 ..
-rw-r--r-- 1 aki01 197609  553 Dec 21 08:36 Make.dist
-rw-r--r-- 1 aki01 197609 2295 Dec 21 08:36 README.vendor
-rwxr-xr-x 1 aki01 197609  407 Dec 21 08:36 all.bash
-rw-r--r-- 1 aki01 197609  726 Dec 21 08:36 all.bat
-rwxr-xr-x 1 aki01 197609  385 Dec 21 08:36 all.rc
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 archive
-rwxr-xr-x 1 aki01 197609 3790 Dec 21 08:36 bootstrap.bash
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 bufio
-rwxr-xr-x 1 aki01 197609 2005 Dec 21 08:36 buildall.bash
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 builtin
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 bytes
-rwxr-xr-x 1 aki01 197609  521 Dec 21 08:36 clean.bash
-rw-r--r-- 1 aki01 197609  565 Dec 21 08:36 clean.bat
-rwxr-xr-x 1 aki01 197609  380 Dec 21 08:36 clean.rc
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 cmd
-rwxr-xr-x 1 aki01 197609 1519 Dec 21 08:36 cmp.bash
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 compress
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 container
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 context
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 crypto
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 database
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 debug
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 encoding
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 errors
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 expvar
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 flag
drwxr-xr-x 1 aki01 197609    0 Dec 22 11:24 fmt
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 go
-rw-r--r-- 1 aki01 197609  275 Dec 21 08:36 go.mod
-rw-r--r-- 1 aki01 197609 1562 Dec 21 08:36 go.sum
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 hash
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 html
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 image
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 index
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 internal
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 io
-rwxr-xr-x 1 aki01 197609 1988 Dec 21 08:36 iostest.bash
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 log
-rwxr-xr-x 1 aki01 197609 6957 Dec 21 08:36 make.bash
-rw-r--r-- 1 aki01 197609 4007 Dec 21 08:36 make.bat
-rwxr-xr-x 1 aki01 197609 3177 Dec 21 08:36 make.rc
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 math
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 mime
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 net
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 os
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 path
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 plugin
-rwxr-xr-x 1 aki01 197609 1021 Dec 21 08:36 race.bash
-rw-r--r-- 1 aki01 197609 1041 Dec 21 08:36 race.bat
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:37 reflect
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 regexp
-rwxr-xr-x 1 aki01 197609 2155 Dec 21 08:36 run.bash
-rw-r--r-- 1 aki01 197609 1164 Dec 21 08:36 run.bat
-rwxr-xr-x 1 aki01 197609  435 Dec 21 08:36 run.rc
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:37 runtime
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 sort
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 strconv
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 strings
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 sync
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 syscall
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 testdata
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 testing
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 text
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 time
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 unicode
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 unsafe
drwxr-xr-x 1 aki01 197609    0 Dec 21 08:36 vendor

Go で Go を build する

取得したソースコードで Go を build していきましょう。

build 方法については、オフィシャル で詳しくドキュメンテーションされています。

まず、そのオフィシャルの指示にしたがって、all.bat (all.bash) を実行します。

C:\Users\aki01\work\src\go.googlesource.com\goroot\src>all.bat
ERROR: Cannot find C:\Users\aki01\Go1.4\bin\go.exe
Set GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.

おっと、エラーで fail してしまいました。
どうやら、ツールチェインを build する go コマンドのデフォルトパスが /users/myUser/Go1.4 となっているようです。

Go1.4 以降の go コマンドであればよいはずなので、
普段の go コマンドの場所をエラーメッセージの指定する環境変数 (GOROOT_BOOTSTRAP) へ設定します。

C:\Users\aki01\work\src\go.googlesource.com\goroot\src>go version
go version go1.13 windows/amd64

C:\Users\aki01\work\src\go.googlesource.com\goroot\src>where go
C:\Go\bin\go.exe

C:\Users\aki01\work\src\go.googlesource.com\goroot\src>set GOROOT_BOOTSTRAP=c:\Go

改めて、all.bat を実行すると、ツールチェインの build から build が始まり、
go の各コマンドと、標準パッケージが無事 build されました。

C:\Users\aki01\work\src\go.googlesource.com\goroot\src>all.bat
Building Go cmd/dist using c:\go
Building Go toolchain1 using c:\go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for windows/amd64.

Go 本体の build が終わった後は、テストが流れていきます。

テストも Goではおなじみの testing package で行っているように見えます。いい感じ。

テストのログ
##### Testing packages.
ok      archive/tar     1.349s
ok      archive/zip     0.860s
ok      bufio   0.841s
ok      bytes   0.590s
ok      compress/bzip2  0.642s
ok      compress/flate  1.857s
ok      compress/gzip   0.948s
ok      compress/lzw    1.574s
ok      compress/zlib   1.124s
ok      container/heap  0.774s
ok      container/list  1.368s
ok      container/ring  0.465s
ok      context 1.684s
ok      crypto  0.406s
ok      crypto/aes      0.446s
ok      crypto/cipher   0.638s
ok      crypto/des      0.755s
ok      crypto/dsa      0.388s
ok      crypto/ecdsa    0.790s
ok      crypto/ed25519  0.597s
ok      crypto/elliptic 1.032s
ok      crypto/hmac     0.831s
ok      crypto/internal/subtle  0.617s
ok      crypto/md5      0.746s
ok      crypto/rand     0.444s
ok      crypto/rc4      0.559s
ok      crypto/rsa      0.810s
ok      crypto/sha1     0.756s
ok      crypto/sha256   0.485s
ok      crypto/sha512   0.717s
ok      crypto/subtle   0.702s
ok      crypto/tls      2.917s
ok      crypto/x509     1.847s
ok      database/sql    1.023s
ok      database/sql/driver     0.458s
ok      debug/dwarf     0.665s
ok      debug/elf       0.878s
ok      debug/gosym     0.444s
ok      debug/macho     0.651s
ok      debug/pe        29.414s
ok      debug/plan9obj  0.707s
ok      encoding/ascii85        1.012s
ok      encoding/asn1   0.706s
ok      encoding/base32 0.951s
ok      encoding/base64 0.599s
ok      encoding/binary 0.497s
ok      encoding/csv    0.612s
ok      encoding/gob    0.932s
ok      encoding/hex    0.561s
ok      encoding/json   0.962s
ok      encoding/pem    0.805s
ok      encoding/xml    0.686s
ok      errors  0.567s
ok      expvar  0.537s
ok      flag    0.507s
ok      fmt     0.476s
ok      go/ast  0.896s
ok      go/build        11.796s
ok      go/constant     0.423s
ok      go/doc  1.546s
ok      go/format       0.728s
ok      go/importer     1.182s
ok      go/internal/gccgoimporter       0.788s
ok      go/internal/gcimporter  1.543s
ok      go/internal/srcimporter 4.109s
ok      go/parser       0.593s
ok      go/printer      1.159s
ok      go/scanner      0.467s
ok      go/token        0.528s
ok      go/types        3.538s
ok      hash    0.403s
ok      hash/adler32    0.494s
ok      hash/crc32      0.898s
ok      hash/crc64      0.542s
ok      hash/fnv        1.127s
ok      hash/maphash    1.282s
ok      html    0.891s
ok      html/template   0.552s
ok      image   0.879s
ok      image/color     0.642s
ok      image/draw      0.454s
ok      image/gif       1.577s
ok      image/jpeg      1.200s
ok      image/png       0.781s
ok      index/suffixarray       1.100s
ok      internal/cpu    0.499s
ok      internal/fmtsort        0.391s
ok      internal/poll   0.569s
ok      internal/reflectlite    0.657s
ok      internal/singleflight   0.461s
ok      internal/syscall/windows        0.664s
ok      internal/syscall/windows/registry       0.623s
ok      internal/trace  0.732s
ok      internal/xcoff  0.511s
ok      io      0.389s
ok      io/ioutil       0.423s
ok      log     0.867s
ok      math    0.721s
ok      math/big        1.865s
ok      math/bits       0.465s
ok      math/cmplx      0.429s
ok      math/rand       0.688s
ok      mime    0.450s
ok      mime/multipart  1.220s
ok      mime/quotedprintable    0.684s
ok      net     16.751s
ok      net/http        23.643s
ok      net/http/cgi    1.529s
ok      net/http/cookiejar      0.909s
ok      net/http/fcgi   0.458s
ok      net/http/httptest       2.944s
ok      net/http/httptrace      0.450s
ok      net/http/httputil       1.120s
ok      net/http/internal       0.475s
ok      net/http/pprof  2.738s
ok      net/internal/socktest   0.449s
ok      net/mail        0.586s
ok      net/rpc 0.698s
ok      net/rpc/jsonrpc 0.679s
ok      net/smtp        1.110s
ok      net/textproto   0.916s
ok      net/url 0.654s
ok      os      10.443s
ok      os/exec 52.157s
ok      os/signal       5.964s
ok      os/user 0.757s
ok      path    0.522s
ok      path/filepath   2.734s
ok      plugin  0.545s
ok      reflect 1.883s
ok      regexp  0.758s
ok      regexp/syntax   0.876s
ok      runtime 158.522s
ok      runtime/debug   0.444s
ok      runtime/internal/atomic 0.749s
ok      runtime/internal/math   0.756s
ok      runtime/internal/sys    0.438s
ok      runtime/pprof   19.055s
ok      runtime/pprof/internal/profile  0.373s
ok      runtime/trace   4.164s
ok      sort    0.548s
ok      strconv 1.288s
ok      strings 0.767s
ok      sync    2.595s
ok      sync/atomic     0.758s
ok      syscall 0.475s
ok      testing 0.749s
ok      testing/iotest  0.615s
ok      testing/quick   0.642s
ok      text/scanner    0.846s
ok      text/tabwriter  0.492s
ok      text/template   0.652s
ok      text/template/parse     0.608s
ok      time    3.131s
ok      unicode 0.485s
ok      unicode/utf16   0.436s
ok      unicode/utf8    0.411s
ok      cmd/addr2line   16.158s
ok      cmd/api 0.882s
ok      cmd/asm/internal/asm    2.619s
ok      cmd/asm/internal/lex    0.502s
ok      cmd/compile     0.757s
ok      cmd/compile/internal/gc 42.494s
ok      cmd/compile/internal/logopt     3.110s
ok      cmd/compile/internal/ssa        1.713s
ok      cmd/compile/internal/syntax     0.747s
ok      cmd/compile/internal/test       0.515s [no tests to run]
ok      cmd/compile/internal/types      0.633s
ok      cmd/cover       26.559s
ok      cmd/doc 1.812s
ok      cmd/fix 15.478s
ok      cmd/go  248.974s
ok      cmd/go/internal/auth    0.536s
ok      cmd/go/internal/cache   3.530s
ok      cmd/go/internal/generate        0.750s
ok      cmd/go/internal/get     0.979s
ok      cmd/go/internal/imports 1.040s
ok      cmd/go/internal/load    0.714s
ok      cmd/go/internal/lockedfile      5.678s
ok      cmd/go/internal/lockedfile/internal/filelock    0.771s
ok      cmd/go/internal/modconv 1.050s
ok      cmd/go/internal/modfetch        1.070s
ok      cmd/go/internal/modfetch/codehost       0.631s
ok      cmd/go/internal/modfetch/zip_sum_test   0.678s
ok      cmd/go/internal/modload 0.771s
ok      cmd/go/internal/mvs     0.549s
ok      cmd/go/internal/par     1.073s
ok      cmd/go/internal/renameio        7.345s
ok      cmd/go/internal/search  0.886s
ok      cmd/go/internal/txtar   0.891s
ok      cmd/go/internal/web     0.721s
ok      cmd/go/internal/work    1.080s
ok      cmd/gofmt       1.621s
ok      cmd/internal/buildid    1.417s
ok      cmd/internal/dwarf      0.943s
ok      cmd/internal/edit       0.549s
ok      cmd/internal/goobj      5.877s
ok      cmd/internal/obj        0.468s
ok      cmd/internal/obj/arm64  0.908s
ok      cmd/internal/obj/x86    9.071s
ok      cmd/internal/objabi     0.780s
ok      cmd/internal/src        0.533s
ok      cmd/internal/test2json  1.604s
ok      cmd/link        45.006s
ok      cmd/link/internal/ld    22.251s
ok      cmd/link/internal/sym   0.473s
ok      cmd/nm  26.542s
ok      cmd/objdump     22.501s
ok      cmd/pack        18.809s
ok      cmd/trace       0.768s
ok      cmd/vet 31.327s

##### os/user with tag osusergo
ok      os/user 0.612s

##### GOMAXPROCS=2 runtime -cpu=1,2,4 -quick
ok      runtime 35.922s

##### Testing without libgcc.
ok      crypto/x509     1.085s
ok      net     0.618s
ok      os/user 0.399s

##### sync -cpu=10
ok      sync    1.689s

##### Testing race detector
ok      runtime/race    25.388s
ok      flag    1.331s
ok      net     1.486s
ok      os      1.890s
ok      os/exec 3.251s
ok      encoding/gob    1.125s
ok      flag    1.445s
ok      os/exec 3.224s

##### ../misc/cgo/stdio
PASS

##### ../misc/cgo/life
PASS

##### ../misc/cgo/test
PASS
scatter = 00000000005681C0
sqrt is: 0
hello from C
ok      misc/cgo/test   25.251s
PASS
scatter = 0000000000401ED0
sqrt is: 0
hello from C
ok      misc/cgo/test   25.257s
PASS
scatter = 00000000005681C0
sqrt is: 0
hello from C
ok      misc/cgo/test   25.106s
PASS
scatter = 00000000005681C0
sqrt is: 0
hello from C
ok      misc/cgo/test   25.464s

##### ../misc/cgo/testgodefs
PASS

##### ../misc/cgo/testso
ok      misc/cgo/testso 6.517s

##### ../misc/cgo/testsovar
ok      misc/cgo/testsovar      7.198s

##### ../misc/cgo/testcarchive
SKIP - short mode and $GO_BUILDER_NAME not set

##### ../misc/cgo/testcshared
SKIP - short mode and $GO_BUILDER_NAME not set

##### ../test/bench/go1

##### ../test

##### API check

ALL TESTS PASSED

---
Installed Go for windows/amd64 in C:\Users\aki01\work\src\go.googlesource.com\goroot
Installed commands in C:\Users\aki01\work\src\go.googlesource.com\goroot\bin
*** You need to add C:\Users\aki01\work\src\go.googlesource.com\goroot\bin to your PATH.

build が完了すると、リポジトリのルートディレクトリの下の bin ディレクトリにバイナリが作成されます。

C:\Users\aki01\work\src\go.googlesource.com\goroot\src>..\bin\go.exe version
go version devel +a5bfd9da1d Tue Dec 17 14:59:30 2019 +0000 windows/amd64

C:\Users\aki01\work\src\go.googlesource.com\goroot\src>git log
commit a5bfd9da1d1b24f326399b6b75558ded14514f23 (HEAD, tag: go1.14beta1)
commit a5bfd9da1d1b24f326399b6b75558ded14514f23 (HEAD, tag: go1.14beta1)
Author: Bryan C. Mills <bcmills@google.com>
Date:   Tue Dec 17 09:00:57 2019 -0500

    go/build: rename WorkingDir to Dir

    Fixes #36168

    Change-Id: If2b7368671e83657a3a74dd030e66e7c68bf2361
    Reviewed-on: https://go-review.googlesource.com/c/go/+/211657
    Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>

Go で Go を開発する

簡単に Go で Go が build できるようになりました。

というわけで、早速 Go のソースコードをオレオレにしてみましょう。
おなじみの fmt パッケージのソースに、 Gopher の AA を標準出力へ出力する PrintGopher() 関数を追加してみました。
(AA は tenntenn さんのツイート がソースです)

src/fmt/print.go
// Print formats using the default formats for its operands and writes to standard output.
// Spaces are added between operands when neither is a string.
// It returns the number of bytes written and any write error encountered.
func Print(a ...interface{}) (n int, err error) {
    return Fprint(os.Stdout, a...)
}

// PrintGopher writes gopher to standard output.
func PrintGopher() (n int, err error) {
    return Fprint(os.Stdout, "ʕ◔ϖ◔ʔ\n")
}

もう一度 Go 本体を build して、追加した関数をコールしてみましょう。

sandbox/main.go
package main

import "fmt"

func main() {
    fmt.PrintGopher()
}

C:\Users\aki01\work\src\go.googlesource.com\goroot\sandbox>..\bin\go.exe build

C:\Users\aki01\work\src\go.googlesource.com\goroot\sandbox>sandbox.exe
ʕ◔ϖ◔ʔ

やったー!! 動きました。
これで Go が Go で開発できるようになりました。
さあーコントリビュートするぞー。

2020/01/23 追記

↑ の fmt package のソースコードは、ユーザアプリケーションの build 時にコンパイルされるため、
厳密には Go 本体のソース変更にはなっていませんでした。

本体のソースコードだと、例えば以下のような変更を加えることができます。

src/cmd/go/main.go
            cmd.Run(cmd, args)
            if cmd.Name() == "build" {
                fmt.Fprintf(os.Stderr, "ʕ◔ϖ◔ʔ < build success!!\n") // added
            }
            base.Exit()
            return

この追加により、go build コマンドを実行した際、その実行が成功したことを出力することができるようになります。

C:\Users\aki01\work\src\go.googlesource.com\goroot\sandbox>..\bin\go.exe build
ʕ◔ϖ◔ʔ < build success!!

RoundUp

今回、Go を Go で build して、ソースコードを変更してみましたが、
普段 Go で書いているアプリケーションを書くような感覚でサクッとできてしまいました。

いざ Go 本体へ commit となると、普段からプロジェクトを watch したり、
適切な英文のプロポーザルを書いたりとまだ頑張りどころがありますが、
いい commit アイテムとの出会いがあれば、Go にコントリビュートできそうだと思うことができました。

ぜひ、Go を普段使っている皆さんも、Go の処理系への理解を深めて、GO への commit を目指してみてはいかがでしょうか。

Reference

18
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
14