1. What does a Go build typically produce?
- Java bytecode
- A folder of interpreted scripts
- A single compiled binary
- A Docker image automatically
जवाब देखें
जवाब: A single compiled binary
Static binaries are easy to deploy.
पाठ: Why Go
Go (Golang) कोर्स के 26 सवाल, हर सवाल के सही जवाब और explanation के साथ। जवाब देखने से पहले ख़ुद सोचें।
जवाब: A single compiled binary
Static binaries are easy to deploy.
पाठ: Why Go
जवाब: func main() in package main
package main + func main.
जवाब: By starting its name with an uppercase letter
Capitalisation controls visibility.
पाठ: Modules and Packages
जवाब: The empty string ""
Every type has a defined zero value.
जवाब: for condition { ... }
for covers every loop form.
पाठ: Control Flow
जवाब: Return an error value as the last result
Errors are values.
जवाब: The key is not in the map, and v is the zero value
Comma-ok distinguishes missing from zero.
पाठ: Slices and Maps
जवाब: It has a value receiver, so it modified a copy
Pointer receivers modify the original.
पाठ: Structs and Methods
जवाब: By having all the interface's methods; no declaration is needed
Satisfaction is implicit.
पाठ: Interfaces
जवाब: Types that support < and > comparisons
Constraints limit type parameters.
पाठ: Generics
जवाब: %w
%w preserves the chain.
जवाब: Last in, first out
Like a stack.
जवाब: It produces duplicate log entries as the error moves up
Handle an error once.
पाठ: Designing Errors
जवाब: No, you must wait explicitly, for example with a WaitGroup
Coordinate completion explicitly.
जवाब: The channel being closed and drained
Close signals completion.
जवाब: A channel that is closed when the context is cancelled or times out
Select on Done to stop work.
जवाब: Concurrent access to the same memory with at least one write and no synchronisation
Use mutexes, atomics or channels.
जवाब: The mux responds 405 Method Not Allowed
Method-aware routing since Go 1.22.
जवाब: Excludes the field from JSON encoding and decoding
Keep internal fields out of payloads.
जवाब: Year-month-day, written using the reference date
Layouts use the reference time.
पाठ: Time and Formatting
जवाब: Each case becomes a named subtest, so failures point to the exact case
Named, isolated cases.
पाठ: Table-Driven Tests
जवाब: Code that compiles but is likely a bug
Static analysis for common mistakes.
पाठ: go vet
जवाब: It enforces one standard style automatically, ending style debates
Consistency at zero cost.
जवाब: Under internal/
internal/ cannot be imported by other modules.
जवाब: Stops accepting new connections and waits for in-flight requests to finish
Graceful draining.
जवाब: Tests run with the -race flag in CI
Correct, synchronised, formatted.