Country or region and language

    Choose your country or region and your language.

    Suggested for you

      All countries and regions

        Choose your character

        It shows in the top bar and on your profile. Change it any time.

        Go exercises with boundary tests

        Start with a result you can check by hand. Then change the data so a shortcut fails: a recorded zero, repeated key, empty slice or canceled operation.

        Checked 15 November 2026

        Copy a manifest without changing it

        Write CopyAdjusted(values []int, delta int) []int. For [3,0,3] and delta 4, return [7,4,7]. The original must still be [3,0,3]. Try a negative adjustment and an empty input. A new slice header alone does not establish independent storage.

        Preserve a recorded zero

        Write a lookup that returns both the stored integer and its presence flag. {"dock":0} queried for dock must return (0,true). The same map queried for yard returns (0,false). Include a nil map. Use the comma-ok result instead of treating zero as missing.

        Wrap an error that callers can recognize

        Return nil for a positive count. For zero or a negative count, add context to a sentinel error while preserving errors.Is. A solution that only copies the sentinel’s message fails the identity requirement. Test both a wrapped failure and success.

        Drain a closed channel

        Feed a buffered channel the values 0, 7 and -2, then close it. Return all three in order. Test an empty closed channel too. Do not use zero as an end marker. For an input that may never close, introduce a separate cancellation contract before adding a select loop.

        Check a handler without a server

        Write a handler where GET returns 200 and a fixed body, while POST returns 405 and an empty body. Check headers before relying on the body. Use a response recorder to see whether writing a body before the status accidentally committed success.

        Turn the result into a reusable test

        Write a table of named inputs and expected outputs. Keep a normal case, the smallest permitted input and a case that exposes the likely mistake. Add a property only when it follows from the contract, such as preserving the caller’s slice. A test that copies the implementation can repeat the same defect.

        Open the Go course to compile and check your solutions. The Interview Hub uses separate contracts, and the Go reference explains the syntax behind these exercises.

        Sources

        Your Work Gym account

        Save your progress and pick up on another device. Your browser's progress comes with you.

        or

        You can keep practicing without an account.

        Help and feedback

        Ask a question, tell us what is not working, or share an idea. We reply by email.

        What is it about?

        We use it only to reply to you.