What Go developers told the Go team

In January 2026 the Go team published the results of its 2025 Go Developer Survey, answered by 5,379 developers in September 2025. Two findings matter to anyone using coding agents to move code into Go. The top frustration, picked by 33% of respondents, was "Ensuring our Go code follows best practices / Go idioms". And on AI developer tools, the report says: "A majority said that creating non-functional code was their primary problem with AI developer tools (53%), with 30% lamenting that even working code was of poor quality."

The open-text answers add detail. The Go team writes: "Respondents who were most frustrated by writing idiomatic Go were often looking for more official guidance, as well as tooling support to help enforce this guidance in their codebase." The second-largest frustration (28%) was "A feature I value from another language isn't part of Go", and those comments centred on error handling, enums and nil safety.

The survey asked Go developers about their own work. It did not study translation, and it does not show that agents carry habits from one language into another. It does show three things: idiomatic Go is hard for people, those people want help enforcing it, and 30% of those describing a problem with AI tools said that even working code was of poor quality.

The hypothesis

Mneme is an open-source tool that checks the code coding agents write against a team's recorded engineering decisions. Our hypothesis, which we have not tested, is this: Go code that an agent translates from Python or Java, and that passes parity tests, will often keep source-language patterns that fail under cancellation, concurrency or partial failure.

Parity tests run the same inputs through the old service and the new one and compare the outputs. They check what the code returns on the paths they exercise. They rarely check what happens when a client disconnects, where a transaction starts and ends, or whether a caller can inspect an error. A translation can be correct on every tested path and still not be Go.

At the architecture level, agents copy the legacy architecture they read in a repository. This article is about the level below that. During a translation the agent reads the old language while it writes the new one, so the service boundaries can move to Go intact while the functions inside keep their Java manners.

Five habits a translation can carry

Every example below is illustrative: written for this article, not taken from a real translation or a measured agent run. Most start from Java, where the habits are easiest to show; the first two note the Python version, and the last three are Java-specific.

1. Exceptions become panics, or disappear

The Go FAQ explains the language's position: "We believe that coupling exceptions to a control structure, as in the try-catch-finally idiom, results in convoluted code." Effective Go advises that real library functions avoid panic. A literal translation of a Java throw and catch looks like this:

// Illustrative: exception-style translation
func (s *OrderService) Place(o Order) Order {
    defer func() {
        if r := recover(); r != nil {
            log.Printf("place failed: %v", r)
        }
    }()
    if o.Total <= 0 {
        panic(InvalidOrderException{ID: o.ID})
    }
    return s.repo.Save(o)
}

On the happy path it behaves like the original. On the failure path the caller receives an empty Order and no error. The Go version returns the error as a value, wrapped so the caller can test for it with errors.Is (the %w verb, added in Go 1.13):

func (s *OrderService) Place(ctx context.Context, o Order) (Order, error) {
    if o.Total <= 0 {
        return Order{}, fmt.Errorf("place order %s: %w", o.ID, ErrInvalidOrder)
    }
    return s.repo.Save(ctx, o)
}

Python translations have a quieter variant: except Exception: pass turns into if err != nil { return nil }, and the error vanishes.

2. Thread-local state becomes a package variable

Java services often carry the current user or tenant in a ThreadLocal, and Python services can do the same with threading.local. Go has nothing to attach it to. The FAQ says goroutines "expose no unique identifier, name, or data structure to the programmer." An agent that wants somewhere to put request state may reach for a package-level variable:

// Illustrative: ThreadLocal translated to a package variable
var currentTenant string

func WithTenant(next http.Handler) http.Handler {
    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        currentTenant = r.Header.Get("X-Tenant")
        next.ServeHTTP(w, r)
    })
}

A single-request test passes. In production the net/http server runs each connection in its own goroutine, so concurrent requests overwrite each other's tenant. The context package is the place for this: "Use context Values only for request-scoped data that transits processes and APIs, not for passing optional parameters to functions." The fix stores the tenant with context.WithValue and passes r.WithContext(ctx) down the chain.

3. Class hierarchies become embedding chains

The FAQ is direct about objects: "Although Go has types and methods and allows an object-oriented style of programming, there is no type hierarchy." Effective Go warns that "There's an important way in which embedding differs from subclassing": a promoted method's receiver is the inner type. A Java template method, where a base class calls a method its subclass overrides, does not survive the move:

// Illustrative: inheritance translated to embedding
type BaseRepository struct{ db *sql.DB }

func (b *BaseRepository) Table() string { return "" }
func (b *BaseRepository) Count(ctx context.Context) (int, error) {
    q := "SELECT count(*) FROM " + b.Table() // always BaseRepository.Table
    // ...
}

type UserRepository struct{ BaseRepository }

func (u *UserRepository) Table() string { return "users" }

It compiles. UserRepository.Count queries an empty table name, because the base type never sees the outer type's method. A test of Count catches this case. A translation can also produce a deep embedding chain that works and that no Go developer would have designed, and no test will flag that. The Go version passes the table name in or defines a small interface.

4. Context is accepted and then ignored

The context package documentation asks for the context as a function's first parameter, usually named ctx, and a translation can add that parameter without using it. The Go blog's context article states the purpose: "When a request is canceled or times out, all the goroutines working on that request should exit quickly so the system can reclaim any resources they are using."

// Illustrative: the request's context is dropped
func (h *Handler) Report(w http.ResponseWriter, r *http.Request) {
    rows, err := h.db.QueryContext(context.Background(), reportSQL)
    // ...
}

Replacing context.Background() with r.Context() lets a client disconnect cancel the query. Without it, an abandoned report keeps its query running and its database connection busy until the query finishes, and no parity test notices.

5. Transaction semantics change shape

In Spring, a bare @Transactional uses REQUIRED propagation, which Spring's API documentation describes as "Support a current transaction, create a new one if none exists." Nested service calls join the outer transaction without anyone writing it down. Go's database/sql has no implicit propagation. A translation that gives each repository method its own transaction splits one atomic operation into two:

// Illustrative: two writes that were one transaction in Java
func (s *TransferService) Transfer(ctx context.Context, from, to string, amt int64) error {
    if err := s.accounts.Debit(ctx, from, amt); err != nil { // commits on its own
        return err
    }
    return s.accounts.Credit(ctx, to, amt) // commits on its own
}

The Go documentation on executing transactions shows the explicit form: tx, err := db.BeginTx(ctx, nil), a deferred tx.Rollback(), both writes on tx, then tx.Commit(). Both versions pass a happy-path test. Only a failure between the debit and the credit shows the difference, and that failure is the one that loses money.

Which habits a rule can catch

Some of these habits leave a literal trace in the code. Others exist only in how the code is structured, and no text match finds them.

HabitA literal rule can catchNeeds a Go-aware tool or review
Exceptions as panicsPartly: forbid recover() everywhere except the recovery middleware (the one HTTP wrapper that turns a panic into a 500 response), and panic( in service packagesSwallowed errors, missing %w wrapping
Thread-local as package stateNo: a package variable has no fixed textReview, plus go test -race on concurrent tests
Embedding as inheritanceNoReview
Ignored contextPartly: forbid context.Background() in handler and data-access packagesgo vet's lostcancel check for discarded cancel functions; review for a ctx that is never passed on
Transaction shapePartly: forbid .Begin() in data-access packages so every transaction goes through BeginTx with a contextWhere the transaction boundary sits: review and failure-path tests

The Go tools have limits too. The race detector documentation says it "only finds races that happen at runtime, so it can't find races in code paths that are not executed." The lostcancel analyzer checks that the cancel function from context.WithCancel is called. It does not check whether a request's context reaches the database.

Literal rules are blunt. context.Background() belongs in main and in tests, so a rule against it has to be limited to the packages where it is wrong. A helper function that wraps the call hides it from a text match. Write the rule for the common case and leave the rest to review.

Where Mneme fits

Mneme only enforces a decision that has an active typed rule: a machine-checkable condition attached to a decision whose status is active. For these habits the usable rule is a forbidden literal, an exact, case-sensitive piece of text that must not appear in code. The rule can list paths it includes and paths it excludes, so a ban on context.Background() can cover the handler packages and skip main and the tests. A change that adds the text in a covered path gets a FAIL verdict naming the decision it broke. In strict mode a FAIL blocks the write or fails the CI job; in warn mode it is reported and the change goes through.

When the check runs depends on the agent and the way it writes:

  • Claude Code (Anthropic's coding agent): its Edit, Write and MultiEdit tools are checked before the file changes.
  • Codex CLI (OpenAI's command-line interface, or CLI, agent): its apply_patch tool is checked before the file changes.
  • Kiro CLI 3.0 (Amazon Web Services' terminal coding agent): its native write tools are checked before the file changes.

An agent can also write through shell commands, and those changes land on disk before any check. Claude Code and Codex CLI check them when the agent finishes its turn. For other agents, the check happens in continuous integration (CI). There, strict mode fails the job on a violation, and warn mode reports it without failing.

Mneme's supported languages reference puts Go in Tier 2: Mneme's repository-level rules apply to Go code, but Mneme has no Go-specific checks and no abstract syntax tree (AST) or compiler-aware enforcement. Mneme cannot see that a ctx parameter goes unused or that embedding stands in for inheritance. Those belong to go vet, the race detector, linters and the people reviewing the change.

Whether the language move should happen at all, and how the two stacks coexist, is the migration decision, covered in Migrating from Node.js to Go. Idiom decisions sit underneath it, and they need an owner like any other part of engineering decision governance.

What engineering leaders should do

  • Write the idiom decisions before the translation starts. For each source pattern, record the Go equivalent and the reason: errors as wrapped values, request state in context, explicit transactions on BeginTx.
  • Turn the literal-shaped ones into path-limited rules. recover(), context.Background() and .Begin() in the packages where they are wrong.
  • Run the Go tools in CI. go vet on every change, and go test -race on tests that send concurrent requests.
  • Test the failure paths, not only parity. Cancel a request mid-query, fail between two writes, send two tenants at once. Happy-path comparison against the old service cannot find these habits.
  • Brief reviewers on the remaining habits. Embedding chains and swallowed errors need a person who knows what idiomatic Go looks like.

How we would test it

The hypothesis is testable. Translate the same Java and Python services into Go with and without written idiom decisions, then count each habit in the output and run failure-path tests against both. We have not run that comparison, and we have no results to report. Until someone does, treat the five habits as a review checklist for translated code, not as a measured failure rate.

Frequently asked questions

Do AI agents write idiomatic Go when translating from Java (and sometimes Python)?+
There is no published measurement of this. The Go team's 2025 developer survey found that 33% of respondents named following Go idioms as a top frustration, and 53% said creating non-functional code was their primary problem with AI developer tools, but it did not study translation. Mneme's untested hypothesis is that translated Go code that passes parity tests will often keep source-language patterns, such as exception-style error handling and ignored context cancellation, that fail under cancellation, concurrency or partial failure.
Which source-language patterns survive a translation to Go?+
Five candidates: panics and recover used as try and catch, thread-local request state moved into package variables, class hierarchies rebuilt as embedding chains, a context parameter accepted and then replaced with context.Background(), and transaction propagation from frameworks like Spring lost when each repository method opens its own transaction. Each can pass a happy-path test.
Can a code rule catch non-idiomatic Go?+
Some of it. A rule that forbids exact text in certain packages can catch recover() outside the HTTP middleware that turns panics into error responses, context.Background() in handlers, or transactions started without a context. It cannot catch request state in package variables, embedding used as inheritance, or a transaction boundary in the wrong place. Those need go vet, the race detector and review.
Does Mneme have Go-specific checks?+
No. Go is Tier 2 in Mneme's supported languages reference: Mneme's repository-level rules apply to Go code, but there are no Go-specific checks and no AST or compiler-aware enforcement. Mneme enforces decisions that carry an active typed rule, such as a forbidden piece of exact text limited to certain paths, and a change that breaks one gets a FAIL verdict that names the decision, and in strict mode it blocks.