Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Go Module 1

Getting started with Go 1.27 interview questions

Interview questions on getting started with Go 1.27: short warm-ups, then what each harder question tests, the first step of a good answer and its follow-ups.

12 questions: 4 warm-ups and 8 with model answers · Levels: Fresher to senior

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher

    What does the Go 1 compatibility promise guarantee, and what does it leave out?

    Answered in the lesson What Go is and where it fits

  2. Fresher

    What is GOPATH used for in a project that uses modules?

    Answered in the lesson Install Go 1.27 and set up your editor

  3. Fresher

    What is the difference between go run and go build?

    Answered in the lesson Your first Go program: go run and go build

  4. Fresher

    How do you find which go test flag runs only some of the tests, without leaving the terminal?

    Answered in the lesson Find answers: go help, go doc and pkg.go.dev

Questions with model answers

What each question tests, the first step of a good answer and the follow-ups to expect.

  1. Fresher to mid

    Your team runs a Python API that serves 2,000 requests a second, and it must also ship a command-line tool to 300 laptops on three operating systems. A colleague proposes writing both in Go. How do you decide for each project, and what would you measure before deciding?

    What it tests
    Choosing a language from a project's constraints instead of taste: how it ships, how it handles concurrent work, which libraries it needs and what a rewrite costs, backed by measurements.
    First step
    Treat them as two decisions, because their constraints differ. For the tool, list what the laptops have installed: if no runtime is guaranteed, one executable per system is a strong argument. For the API, measure where its time and money go today before assuming a rewrite would make it faster.
    Follow-ups

    From the lesson What Go is and where it fits

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.

    Opening the model answers with your pass…

    Model answers open with any MySmartCoPilot pass.

    • Pro pass · 1 week₹79$2.99
    • 30 days₹179$5.99
    • 1 year₹1,699$45

    One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

    It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 4 minutes
  2. Mid to senior

    You raise the go line in go.mod from go 1.21 to go 1.22 so that you can range over integers. One test now fails, and nobody changed any code. How can that happen, how do you find the cause, and how would you raise the go line safely next time?

    What it tests
    Knowing that the go line sets the language version and GODEBUG defaults, the Go 1.22 loop-variable change, and a safe routine for raising the line.
    First step
    Start from what the go line does: it sets the language version the compiler applies to the module's code. Then list the changes of meaning between 1.21 and 1.22. Per-iteration loop variables are the change that can alter a test's result without any code change.
    Follow-ups

    From the lesson What Go is and where it fits

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  3. Fresher to mid

    After a Go upgrade, every build on a teammate's laptop fails with "compile: version "go1.26.8" does not match go tool version "go1.27.1"". What causes it, how do you confirm the cause, and how would you keep build machines from ever meeting it?

    What it tests
    Knowing how the go command finds its toolchain and its settings, reading a version-mismatch error precisely, and making build machines reproducible.
    First step
    Read the error literally: the go command is version 1.27.1, but the compiler it ran belongs to 1.26.8. So something points the new go command at the old installation's folder, and that is almost always a GOROOT set by hand: in a shell profile, or saved in the go env file by an older Go's go env -w.
    Follow-ups

    From the lesson Install Go 1.27 and set up your editor

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 4 minutes
  4. Mid to senior

    Your company network blocks proxy.golang.org, and a new hire's go build cannot download any module. Which settings decide where modules come from and how they are checked, what would you change, and what does each choice risk?

    What it tests
    Knowing GOPROXY with its separators and keywords, GOSUMDB and GOPRIVATE, and the security cost of each way around a blocked proxy.
    First step
    Print the settings first: go env GOPROXY GOSUMDB GOPRIVATE. The default asks proxy.golang.org and falls back to direct downloads only when the proxy answers 404 or 410, so a blocked connection is a terminal error, and every download is still checked against sum.golang.org.
    Follow-ups

    From the lesson Install Go 1.27 and set up your editor

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  5. Fresher to mid

    Go refuses to compile a function with an unused local variable, or a file with an unused import, yet it accepts an unused function or an unused package-level variable. Why the difference, and how do you work with the rule while you debug?

    What it tests
    Knowing what the specification and the gc compiler require, why the rules exist, and the honest workarounds as opposed to the ones to keep out of committed code.
    First step
    Separate the two rules. The specification itself makes an unused import illegal, while an unused local variable is an implementation restriction that the specification allows and gc applies. Then ask what each check protects: imports cost build time, and an unused local is very often a bug.
    Follow-ups

    From the lesson Your first Go program: go run and go build

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  6. Fresher to mid

    A binary built on a developer's Mac runs fine there, but the same file copied to a Linux server fails with "exec format error". Explain why, how you would build it correctly, and how you would check any binary before it ships.

    What it tests
    Understanding GOOS and GOARCH, cross-compiling with go build, what cgo changes, and reading what a binary was built for.
    First step
    The message comes from the Linux kernel: the file is not a format it can load. go build on the Mac made a Mach-O file for darwin/arm64. Build for the server instead, with GOOS=linux and GOARCH set to its processor, amd64 or arm64.
    Follow-ups

    From the lesson Your first Go program: go run and go build

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  7. Fresher to mid

    You need a standard-library function that splits a "key=value=more" string at its last "=" sign. Without a search engine, how do you find the function, check how it behaves at the edges, and confirm that behaviour before you rely on it?

    What it tests
    Using go doc to search a package offline, reading a doc comment precisely, and confirming behaviour with a small program or an executable example.
    First step
    Start from the package, not the function. go doc strings lists every function with its signature, so scanning it for Cut and LastIndex is quick. Then read the chosen function's own documentation, go doc strings.CutLast, which says what it returns when the separator is missing.
    Follow-ups

    From the lesson Find answers: go help, go doc and pkg.go.dev

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  8. Mid to senior

    Two modules on pkg.go.dev solve your problem. One is at v0.9.3 with thousands of importers, the other at v2.1.0 with a few hundred. How do you choose, and what do the version number, the licence and the importer count tell you, and not tell you?

    What it tests
    Reading module versions as promises, checking licences and known vulnerabilities, and not mistaking popularity for quality or safety.
    First step
    Read the version numbers as promises. A v0 version makes no compatibility promise at all, while v2.1.0 says its v2 API stays compatible until a v3, which would get a new module path. Check the licence before anything else, since it decides whether you may use the code at all.
    Follow-ups

    From the lesson Find answers: go help, go doc and pkg.go.dev

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes

All Go interview questions · The Go track

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.