▸case-01 I am writing a Go database service function that fetches a user record. If `db.Query` returns an error, I want to attach contextual information string 'query user profile' to the returned error. Write a Go code snippet for handling and returning this error. A colleague suggested using `fmt.Sprintf("query user profile: %v", err)` or `errors.New` so the error string is formatted simply. | pass→pass | 8,016 | 7,120 | -11% | 1 | 1 | 0% | 1,553 | 1,885 | +21% | 0 | 0 | — |
▸case-07 I have written a Go domain model and business service logic for a private enterprise application. Should I put these private application packages under `pkg/orders` or `internal/orders`? Explain the privacy boundary implications of choosing `internal/` versus `pkg/`. | pass→pass | 12,932 | 10,264 | -21% | 1 | 1 | 0% | 2,183 | 2,251 | +3% | 0 | 0 | — |
▸case-02 In my Go REST API service, I am parsing incoming request JSON parameters inside an HTTP handler. When an invalid parameter format is encountered, should I execute `panic("invalid parameter format")` so central recovery middleware catches it, or return an error value back up the call stack? Write a Go snippet demonstrating the proper failure handling in this handler function. | pass→pass | 12,838 | 8,613 | -33% | 1 | 1 | 0% | 2,526 | 2,046 | -19% | 0 | 0 | — |
▸case-03 Write the function signature for a Go repository method named `GetUserByID` that accepts an ID string and requires context for query cancellation. Place the receiver `r *UserRepository` first. A teammate suggested placing `id string` as the first argument and `ctx context.Context` as the final argument. | pass→pass | 3,746 | 3,663 | -2% | 1 | 1 | 0% | 621 | 1,094 | +76% | 0 | 0 | — |
▸case-04 I am designing a Go package structure for a user authentication module. Should I define the `DataStore` interface inside the `internal/database` package where SQL execution happens, or inside the `internal/auth` package where the authentication service consumes the storage methods? Explain where the interface belongs and write a code snippet showing its placement. | pass→pass | 13,108 | 9,397 | -28% | 1 | 1 | 0% | 2,720 | 2,415 | -11% | 0 | 0 | — |
▸case-05 I am designing a core package in a Go application and considering creating a central `AppService` interface that declares 15 methods including `CreateUser`, `SendEmail`, `LogAudit`, `ChargeCreditCard`, `GenerateReport`, and `DeleteAccount` so all services share one mock. Refactor this design approach: how should interfaces be scoped in Go when individual components only need 1 or 2 methods? | pass→pass | 15,868 | 10,221 | -36% | 1 | 1 | 0% | 2,464 | 2,384 | -3% | 0 | 0 | — |
▸case-06 We are organizing a Go repository that produces two standalone binaries (`server` and `worker`). Show the project directory tree layout for these entry points. A developer suggested putting `main.go` and `worker_main.go` directly in the project root directory. | pass→pass | 8,977 | 6,132 | -32% | 1 | 1 | 0% | 1,710 | 1,595 | -7% | 0 | 0 | — |
▸case-08 I need to fetch user profile data concurrently from 5 external API endpoints in Go. If any single request fails, I want all other active fetch operations to be canceled immediately and the error returned. Write a Go snippet demonstrating how to execute this concurrent fan-out task cleanly without raw goroutine tracking. | pass→pass | 11,843 | 7,749 | -35% | 1 | 1 | 0% | 2,430 | 2,001 | -18% | 0 | 0 | — |
▸case-09 I have a list of 1,000 URLs to fetch in Go. Spawning 1,000 concurrent goroutines simultaneously causes socket exhaustion. How should I structure the concurrency in Go to limit concurrent requests to a maximum of 10 at any time? Provide a Go code snippet. | pass→pass | 11,239 | 9,587 | -15% | 1 | 1 | 0% | 2,460 | 2,751 | +12% | 0 | 0 | — |
▸case-10 I am writing unit tests for a Go string transformation function `Slugify(input string) string` across 5 different test cases. Provide a Go test function structure. A developer suggested writing 5 individual test functions (`TestSlugifySpaces`, `TestSlugifySpecial`, etc.) with copy-pasted setup code. | pass→pass | 10,051 | 5,357 | -47% | 1 | 1 | 0% | 2,050 | 1,464 | -29% | 0 | 0 | — |
▸case-11 A Go unit test passed on CI but occasionally fails locally due to test caching or timing variations. What exact terminal command flags should I pass to `go test` to reproduce a test named `TestProcessOrder` deterministically without cached test results? | fail→pass | 11,208 | 4,418 | -61% | 1 | 1 | 0% | 1,316 | 1,182 | -10% | 0 | 0 | — |
▸case-12 Inside a Go HTTP handler (`http.HandlerFunc`), I need to perform an outgoing HTTP request using `http.NewRequestWithContext` to a downstream service. A developer suggested passing `context.Background()` so downstream network calls complete even if the client disconnects. Write the Go snippet showing how context should be passed. | pass→pass | 9,553 | 7,424 | -22% | 1 | 1 | 0% | 1,855 | 1,947 | +5% | 0 | 0 | — |
▸case-13 When a Go database repository fails to locate a requested user record, should it return `return ErrNotFound` directly or wrap it like `return fmt.Errorf("find user %d: %w", id, ErrNotFound)`? Explain the trade-off and state the recommended return statement. | pass→pass | 9,269 | 5,573 | -40% | 1 | 1 | 0% | 1,705 | 1,453 | -15% | 0 | 0 | — |
▸case-14 In a Go web service, a teammate proposed storing the active request's authenticated user in a package-level global variable `var CurrentUser *User` so helper functions across packages can read it without parameter passing. Evaluate this proposal and write code demonstrating the idiomatic Go approach. | pass→pass | 15,275 | 9,717 | -36% | 1 | 1 | 0% | 2,974 | 2,232 | -25% | 0 | 0 | — |
▸case-15 I am creating a consumer component in Go that only reads bytes from a data source. The underlying storage struct exposes 15 methods including `Read`, `Write`, `Close`, `Flush`, `Seek`, and `Stat`. How many methods should the interface defined by my consumer package declare? Write the interface definition in Go. | pass→pass | 5,679 | 5,130 | -10% | 1 | 1 | 0% | 960 | 1,360 | +42% | 0 | 0 | — |
▸case-16 I am setting up a Go repository structure for an internal backend service. I am considering putting all core business domain entities, database repositories, and HTTP handlers under `pkg/domain`, `pkg/repo`, and `pkg/handler`. Is this appropriate for private application code? Explain where private application packages belong versus `pkg/`. | pass→pass | 13,626 | 8,391 | -38% | 1 | 1 | 0% | 2,395 | 1,923 | -20% | 0 | 0 | — |
▸case-17 When running concurrent background workers in Go using `golang.org/x/sync/errgroup`, what happens when one of the worker goroutines returns a non-nil error? Write a brief code snippet showing how the caller inspects the result of `g.Wait()`. | pass→pass | 6,844 | 6,629 | -3% | 1 | 1 | 0% | 1,395 | 1,781 | +28% | 0 | 0 | — |
▸case-18 I am writing table-driven unit tests for a Go JSON parser function. Should I load a 10,000-line sample database dump file from an external server during unit test execution or define small inline test structs and strings inside the test file? Explain the recommended testing strategy. | pass→pass | 12,839 | 10,303 | -20% | 1 | 1 | 0% | 2,400 | 2,336 | -3% | 0 | 0 | — |
▸case-19 I am designing a Go background processing module that handles incoming tasks. Should I spawn a dedicated goroutine for each independent unit of work or mutate shared global state across workers protected by complex mutex locks? Describe the recommended concurrency model for independent work items. | fail→pass | 17,600 | 11,338 | -36% | 1 | 1 | 0% | 3,080 | 2,399 | -22% | 0 | 0 | — |
▸case-20 How do I run a single specific Go unit test function `TestCalculateTax` from the command line without running all tests in the package or reading cached results? | pass→pass | 5,560 | 4,310 | -22% | 1 | 1 | 0% | 875 | 1,173 | +34% | 0 | 0 | — |
▸case-21 In a Go database repository method that performs heavy computation before executing a SQL query, how should the method check for context cancellation or deadline expiration before starting the computation? Write a Go snippet showing the check. | pass→pass | 9,840 | 6,351 | -35% | 1 | 1 | 0% | 1,838 | 1,682 | -8% | 0 | 0 | — |
▸case-22 I am calling a C library from Go using Cgo. I allocate memory using `C.CString("hello")` to pass to a C function. How must I manage this memory allocation in Go to prevent memory leaks? Write the code snippet. | pass→pass | 9,040 | 4,644 | -49% | 1 | 1 | 0% | 1,407 | 1,373 | -2% | 0 | 0 | — |
▸case-23 We are adding a `status` column to a PostgreSQL table containing 10 million rows in our Go application backend. Should we use an `ALTER TABLE` statement with a default value in a single transaction or run an asynchronous migration script with batched updates? Describe the database migration strategy. | pass→pass | 16,045 | 14,158 | -12% | 1 | 1 | 0% | 2,752 | 2,939 | +7% | 0 | 0 | — |
▸case-24 Write a multi-stage Dockerfile for a Go application that compiles the binary in a `golang:1.22-alpine` builder image and creates a minimal production image using `alpine` or `scratch`. | pass→pass | 11,372 | 10,060 | -12% | 1 | 1 | 0% | 2,061 | 2,419 | +17% | 0 | 0 | — |