| 項目 | バージョン |
|---|---|
| Windows | 11 |
| nodejs | 20.10.0 |
| Golang | 1.24.5 |
| Docker | 20.10.16 |
詳しいソースコードは1.environment_constructionをご覧ください。
VS Codeで本リポジトリを開き、Dev Containerの「コンテナを再度開く」からGolangを起動してください。
VS Codeのterminalから、
go run 1.environment_construction/HelloWorld.go
と実行すれば、完了です。
VS Codeで本リポジトリを開き、Dev Containerの「コンテナを再度開く」からTypeScriptを起動してください。
VS Codeのterminalから、
tsc 1.environment_construction/HelloWorld.ts && node 1.environment_construction/HelloWorld.js
と実行すれば、完了です。
https://typescriptbook.jp/を読了後、作成したコードは2.TypeScript/2-1.TypeScriptにあります。
https://typescriptbook.jp/tutorialsの各章と本リポジトリのパスの対応は下記の通りです。
(「Vercelにデプロイしてみよう」の章だけパスではなくデプロイ先のURLになっています)
- 簡単な関数を作ってみよう
- Reactでいいねボタンを作ろう
- Next.jsで猫画像ジェネレーターを作ろう
- Vercelにデプロイしてみよう
- Jestでテストを書こう
- Reactコンポーネントのテストを書こう
- Prettierでコード整形を自動化しよう
- ESLintでTypeScriptのコーディング規約チェックを自動化しよう(JavaScript)
- ESLintでTypeScriptのコーディング規約チェックを自動化しよう(TypeScript)
https://fastify.dev/docs/latest/Guides/Getting-Started/を読了後、作成したコードは2.TypeScript/2-2.Fastifyにあります。
各章と実行コマンドの対応は下記の通りです。
node src/main.js
node src/main-plugin.js
docker compose up -d
node src/main-validation.js
下記のリクエストを投げて、検証してみましょう。
curl -X POST -H "Content-Type: application/json" -d '{"test":"test"}' localhost:3000
下記のように、必須のプロパティがないため、はじかれます。
{"statusCode":400,"code":"FST_ERR_VALIDATION","error":"Bad Request","message":"body must have required property 'someKey'"}
次に、必須のプロパティを加えたリクエストを投げます。
curl -X POST -H "Content-Type: application/json" -d '{"someKey":"test","someOtherKey":"test"}' localhost:3000
今度は、下記の通り、someOtherKeyが数字でなければならないと、はじかれました。
{"statusCode":400,"code":"FST_ERR_VALIDATION","error":"Bad Request","message":"body/someOtherKey must be number"}
そこで、someOtherKeyの値を数字にして、リクエストを送信します。
curl -X POST -H "Content-Type: application/json" -d '{"someKey":"test","someOtherKey":0}' localhost:3000
今度は、うまくいきました。
{"someKey":"test","someOtherKey":0}
node src/main-serialization.js
node src/main-parsing.js
https://go.dev/tour/welcome/1を読了後、作成したコードは3.Golang/Tourにあります。
フォルダ構成はgo-tour-jpのリポジトリに準拠しました
実行方法の例は下記の通りです。
cd 3.Golang/Tour/welcome
go run hello.go
https://go.dev/doc/tutorial/を読了後、作成したコードは3.Golang/Tutorialsにあります。
下記のコマンドで実行できます。
cd 3.Golang/Tutorials/create-module/hello
go run .
greetingsをテストしたい場合、下記のコマンドで実行できます。
cd 3.Golang/Tutorials/create-module/greetings
go test
下記のコマンドで実行できます。
cd 3.Golang/Tutorials/workspace
git clone https://go.googlesource.com/example
go run ./hello
下記のコマンドで実行できます。
cd 3.Golang/Tutorials/data-access
docker compose up
下記のコマンドで実行できます。
cd 3.Golang/web-service-gin
go run .
下記のコマンドで実行できます。
cd 3.Golang/Tutorials/generics
go run .
下記のコマンドで実行できます。
go test -fuzz=Fuzz -fuzztime 30s
下記のコマンドで実行できます。
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...