Implementing use cases
Remember the use cases defined in the previous chapter? Let’s try to implement a couple of them:
- UC-01 Upload audio
- UC-02 Request metadata
Uploading audio
In this use case, an authenticated user uploads an audio file by giving the location of the file on their device for the purpose of extracting its metadata. Under the hood, the upload process will save a local copy and run the metadata extraction process on the audio file. A unique ID for the audio file is returned immediately.
Before we begin to implement this use case, let’s consider what the command for uploading may look like. Suppose we’ve settled on the following final command structure:
./audiofile-cli upload -filename <filepath>
Since /cmd/cli/main.go
is already defined, we’ll just need to make sure that the upload
command exists and satisfies the command
interface, with the ParseFlags
, Run
, and Name
methods. In the internal/command
folder...