
エントリーの編集

エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。

- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
Goのテスト内で静的ファイル配信サーバーを起動する | おそらくはそれさえも平凡な日々
実質一行。異常に簡単だった。 import ( "net/http" "net/http/httptest" "testing" ) func TestDownloa... 実質一行。異常に簡単だった。 import ( "net/http" "net/http/httptest" "testing" ) func TestDownload(t *testing.T) { ts := httptest.NewServer(http.FileServer(http.Dir("testdata"))) defer ts.Close() resp, err := http.Get(ts.URL + "/test.txt") ... } ちなみに、テスト用のファイルを testdata という名前のディレクトリに置くのは、公式のドキュメントにも書かれている慣習ですね。 https://golang.org/cmd/go/ The go tool will ignore a directory named "testdata", making it available
2017/10/08 リンク