Go slices, length, and capacity

F-GOSLICE-V4-2medium

Protect an extended window

A Go code buffer extends ranges and reuses storage for unread codes and incoming chunks.

What needs to change

Repair extendWindow so the extended selected window satisfies the source-preservation contract.

Reproduce

  1. Run go run main.go with the supplied input and compare owner and edited-window reports.

Acceptance criteria

Your review marks · Saved in this browser. Test acceptance is tracked separately.

Notes

main.go supplies valid start/end bounds and the appended code.

The source buffer must retain its values. The caller then changes the returned window’s first value and reports both source and result.

Supplied input is well formed: 0<=seed count<=capacity<=64; both range pairs satisfy 0<=start<=end<=seed count; code and seed values are integers in -1000..1000. The caller assumes this domain rather than validating it.

Sign in to open this exercise

The ticket brief is public. Sign in to access the exercise. Paid exercises require Pro.

Sign in