Prototype: NewFileCatalog() *FileCatalog; Upload(name string,size int) (bool,error) nonempty name/nonnegative size, duplicate false preserving size; Get(name) *int nil missing, pointer zero valid.

Final: NewFileStorage(quota int) (*FileStorage,error) nonnegative quota, time/usage zero. AdvanceTo(ts int) error requires nonnegative nondecreasing time, equal valid; delete all expiry<=ts and release usage. No other method advances time. Upload(name string,size int,ttl *int) (bool,error) validates nonempty name, nonnegative size, positive supplied TTL before duplicate/quota; nil TTL permanent, else current+ttl. Duplicate or insufficient quota false unchanged. Get(name) *File detached optional expiry. Copy(source,destination) (bool,error) validates nonempty destination first; missing source/existing destination/same name/insufficient quota false; success copies size and absolute expiry, charges again. Delete(name) bool release once. Usage() int. Search(prefix string,limit int) ([]File,error) exact prefix, sort size descending/name ascending; negative error, zero empty. Explicit limit (use 10 for customary default). Expired names reusable.

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.