More Related Content
Similar to メルカリアッテの実務で使えた、GAE/Goの開発を効率的にする方法 (20)
More from Takuya Ueda (14)
メルカリアッテの実務で使えた、GAE/Goの開発を効率的にする方法
- 12. aetestの使い方
ctx, done, err := aetest.NewContext()
if err != nil {...}
defer done()
it := &memcache.Item{
Key: "some-key",
Value: []byte("some-value"),
}
err = memcache.Set(ctx, it)
if err != nil {...}
it, err = memcache.Get(ctx, "some-key")
if err != nil {...}
if string(it.Value) != "some-value" {
...
}
内部で
aetest.NewInstance()
が呼ばれている
Memcacheへ
アクセスしている
- 18. coverprofile
■ テストカバレッジの分析
$ go test -coverprofile=profile fmt
$ head profile
mode: set
fmt/format.go:30.13,31.29 1 1
fmt/format.go:31.29,34.3 2 1
fmt/format.go:67.28,69.2 1 1
fmt/format.go:71.33,74.2 2 1
fmt/format.go:77.85,80.11 3 1
fmt/format.go:84.2,85.11 2 1
fmt/format.go:96.2,96.8 1 1
fmt/format.go:80.11,83.3 2 0
fmt/format.go:85.11,86.21 1 1
パッケージ名
テストできるのは
パッケージごと
- 23. goappコマンドとgoコマンド
■ GAE/Goではgoappコマンドを使う
● goコマンドと何が違うのか?
● ソースコードレベルで比べてみた
if buildContext.InstallSuffix != "" {
buildContext.InstallSuffix += "_"
}
buildContext.InstallSuffix += "appengine"
buildContext.BuildTags =
append(buildContext.BuildTags, "appengine")
InstallSuffixと
BuildTagsくらいの差分
- 24. appengieタグ
■ goappを使うとappengineタグが付く
● Standard Environment 向けにはappengineタグ
● Flexible Environment 向けにはappengineタグなし
■ goコマンドでも同じか?
● -tags "appengine"でタグが付けれる
● GOPTHとGOROOTが違うの注意
● GOROOTにappengineパッケージがある
○ google.golang.org/appengineではない