# Goの基礎 (Go) > 変数、定数、基本型、関数、パッケージ、インポート、制御フロー、defer - 25 面接問題 - Junior - [面接問題: Go](https://sharpskill.dev/ja/technologies/go/interview-questions.md) ## 1. Goで変数を宣言する正しい構文はどれですか? **回答** Goでは変数を宣言する主な方法が3つあります。var x int(型を明示する宣言)、var x = 10(型推論を伴う宣言)、x := 10(型推論を伴う短縮宣言、関数内のみ)です。短縮形の := は簡潔で慣用的なため、ローカル変数で最もよく使われます。 ## 2. Goにおけるint型変数のゼロ値は何ですか? **回答** Goでは、宣言時に値が指定されない場合、すべての変数はデフォルトでゼロ値に初期化されます。数値型(int、float64)のゼロ値は0です。boolではfalse、stringでは空文字列、ポインタではnilになります。この挙動により、Goでは未初期化の変数が存在しないことが保証されます。 ## 3. Goにおける var x int と x := 0 の違いは何ですか? **回答** var x int は型を明示してゼロ値(0)を持つ変数を宣言しますが、x := 0 は型推論を伴う短縮宣言を使います。短縮宣言 := は関数内でのみ使用できますが、var はパッケージレベルでも使用できます。ローカル変数では、より簡潔で慣用的な := の形式が好まれます。 ## さらに22問利用可能 - Goで定数を宣言するにはどうすればよいですか? - Goの基本的な数値型にはどのようなものがありますか? 無料で登録: https://sharpskill.dev/ja/login ## その他のGo面接トピック - [Goのデータ構造](https://sharpskill.dev/ja/technologies/go/interview-questions/go-data-structures.md): 20問, Junior - [Go のインターフェース](https://sharpskill.dev/ja/technologies/go/interview-questions/go-interfaces.md): 18問, Junior - [エラー処理](https://sharpskill.dev/ja/technologies/go/interview-questions/error-handling.md): 20問, Junior - [Goroutine の基礎](https://sharpskill.dev/ja/technologies/go/interview-questions/goroutines-basics.md): 20問, Junior - [Channels](https://sharpskill.dev/ja/technologies/go/interview-questions/channels.md): 22問, Junior - [Go Modules](https://sharpskill.dev/ja/technologies/go/interview-questions/go-modules.md): 18問, Mid-Level - [HTTP サーバー](https://sharpskill.dev/ja/technologies/go/interview-questions/http-server.md): 24問, Mid-Level - [HTTPクライアント](https://sharpskill.dev/ja/technologies/go/interview-questions/http-client.md): 18問, Mid-Level - [JSON エンコーディング](https://sharpskill.dev/ja/technologies/go/interview-questions/json-encoding.md): 20問, Mid-Level - [Database/SQL](https://sharpskill.dev/ja/technologies/go/interview-questions/database-sql.md): 22問, Mid-Level - [context パッケージ](https://sharpskill.dev/ja/technologies/go/interview-questions/context-package.md): 20問, Mid-Level - [Testing](https://sharpskill.dev/ja/technologies/go/interview-questions/testing.md): 22問, Mid-Level - [並行処理パターン](https://sharpskill.dev/ja/technologies/go/interview-questions/concurrency-patterns.md): 24問, Mid-Level - [同期プリミティブ](https://sharpskill.dev/ja/technologies/go/interview-questions/sync-primitives.md): 22問, Mid-Level - [Go Web フレームワーク](https://sharpskill.dev/ja/technologies/go/interview-questions/go-web-frameworks.md): 20問, Mid-Level - [REST API 設計](https://sharpskill.dev/ja/technologies/go/interview-questions/rest-api-design.md): 20問, Mid-Level - [gRPC](https://sharpskill.dev/ja/technologies/go/interview-questions/grpc.md): 22問, Mid-Level - [Reflection](https://sharpskill.dev/ja/technologies/go/interview-questions/reflection.md): 20問, Senior - [メモリ管理](https://sharpskill.dev/ja/technologies/go/interview-questions/memory-management.md): 24問, Senior - [パフォーマンス最適化](https://sharpskill.dev/ja/technologies/go/interview-questions/performance-optimization.md): 22問, Senior - [Generics](https://sharpskill.dev/ja/technologies/go/interview-questions/generics.md): 20問, Senior - [Go Design Patterns](https://sharpskill.dev/ja/technologies/go/interview-questions/design-patterns.md): 24問, Senior - [Microservices](https://sharpskill.dev/ja/technologies/go/interview-questions/microservices.md): 24問, Senior - [セキュリティと認証](https://sharpskill.dev/ja/technologies/go/interview-questions/security-authentication.md): 24問, Senior - [Docker & Containerization](https://sharpskill.dev/ja/technologies/go/interview-questions/docker-containerization.md): 20問, Senior - [Kubernetes Basics](https://sharpskill.dev/ja/technologies/go/interview-questions/kubernetes-basics.md): 22問, Senior - [高度な Go](https://sharpskill.dev/ja/technologies/go/interview-questions/advanced-go.md): 20問, Senior - [CLI開発](https://sharpskill.dev/ja/technologies/go/interview-questions/cli-development.md): 20問, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/ja/technologies/go/interview-questions/go-basics