Design and Implement an Object-Oriented Music Player in Go
You are asked to design and implement a small, object-oriented music management and playback system in Go.
Requirements
-
Core domain types:
-
Playlist features:
-
Add/remove songs
-
Reorder/move songs
-
Optional deduplication toggle (prevent duplicate songs by ID)
-
Merging playlists:
-
Merge two playlists while preserving the relative order of songs from each source
-
Define and implement a duplicate-handling policy (e.g., keep-first, keep-last, keep-both)
-
Player controls and behavior:
-
Play, pause, next, previous
-
Shuffle
-
Repeat modes (off, one, all)
-
Engineering aspects:
-
Expose clear APIs and data structures
-
Discuss time and space complexity of core operations
-
Consider concurrency for simultaneous edits and playback; design for thread safety
-
Consider persistence (saving/loading playlists)
-
Outline unit tests for core behaviors
Assume a console-based player (no actual audio) where playback means managing state and current song position.