
Go Basics
Variables, constants, basic types, functions, packages, imports, control flow, defer
1What is the correct syntax to declare a variable in Go?
What is the correct syntax to declare a variable in Go?
Jawaban
In Go, there are three main ways to declare a variable: var x int (explicit declaration with type), var x = 10 (declaration with type inference), and x := 10 (short declaration with inference, only inside functions). The short form := is most commonly used for local variables as it is concise and idiomatic.
2What is the zero value of an int variable in Go?
What is the zero value of an int variable in Go?
Jawaban
In Go, all variables are initialized with a zero value by default if no value is provided during declaration. For numeric types (int, float64), the zero value is 0. For booleans it's false, for strings it's an empty string, and for pointers it's nil. This behavior ensures there are never uninitialized variables in Go.
3What is the difference between var x int and x := 0 in Go?
What is the difference between var x int and x := 0 in Go?
Jawaban
var x int declares a variable with zero value (0) and an explicit type, while x := 0 uses short declaration with type inference. The short declaration := can only be used inside functions, while var can be used at package level. The := form is preferred for local variables as it is more concise and idiomatic.
How to declare a constant in Go?
What are the basic numeric types in Go?
+22 pertanyaan wawancara
Topik wawancara Go lainnya
Go Data Structures
Go Interfaces
Error Handling
Goroutines Basics
Channels
Go Modules
HTTP Server
HTTP Client
JSON Encoding
database/sql
Context Package
Testing
Concurrency Patterns
Sync Primitives
Go Web Frameworks
REST API Design
gRPC
Reflection
Memory Management
Performance Optimization
Generics
Go Design Patterns
Microservices
Security & Authentication
Docker & Containerization
Kubernetes Basics
Advanced Go
CLI Development
Kuasai Go untuk wawancara berikutnya
Akses semua pertanyaan, flashcards, tes teknis, latihan code review dan simulator wawancara.
Mulai gratis