Prototype: NewKeyValueStore() *KeyValueStore; Set(key,value string), Get(key) *string, Delete(key) bool. Empty keys/values valid; nil means absent, empty string pointer means present.

Final: NewTransactionalStore() *TransactionalStore supports the same CRUD plus Begin() int, Commit() (int,error), Rollback() (int,error), Depth() int. Begin starts a nested visible view; commit closes only innermost into parent, rollback discards only innermost. Return resulting depth. Commit/rollback at base error unchanged. Snapshot(prefix string) map[string]string returns a fresh current-view map filtered by exact prefix; empty prefix matches all. Go map key iteration is unordered; key order is not part of this variant. Reads include uncommitted writes/deletions. No type conversion or clocks.

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.