Prototype: AvailableCopies(copies []AvailableCopy,title string) []string returns sorted free IDs for an exact title, preserving inputs. Inputs satisfy uniqueness and validity.

Final: NewLibrary([]BookCopy) (*Library,error) copies unique nonempty copy IDs and nonempty titles, empty catalog allowed. Nonempty member/title/copy IDs required in methods; invalid IDs error before mutation. Borrow(member,title) (*string,error) errors if member already holds that exact title, otherwise smallest free ID or nil if none. ReturnCopy(copyID,member) (bool,error) false for absent/unloaned copy, error if loan belongs to another member, true after release. Available(title) ([]string,error) sorted free IDs. Loans() []Loan sorted by CopyID and detached. No catalog edits or due dates.

All identifiers and strings compare exactly and case-sensitively. Numeric inputs are typed int; booleans cannot be passed as amounts. Arithmetic and logical timestamps fit int. All supplied collection inputs that are retained must be copied. Every collection or pointer snapshot must be detached; separate service instances own independent state. A nil pointer or nil optional slice denotes absence, while an ordinary empty result collection is nonnil. Invalid calls leave state unchanged unless the contract explicitly accepts time and expires state on a valid unsuccessful call. The exported signatures in exercise.go are the API specification.

Edit exercise.go; retain the public types and signatures. prototype and final are separate stages. The executable tests recover panics as failures, report named checks, and exit nonzero on any failure. A successful run must execute at least one check. Tests use logical time or explicit synchronization where relevant.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.