MyFavArtist App - This application will use last.fm to get popular artist based on region.
To get this app running locally:
- Clone this repo
- Install Golang programming language (instructions)
- Install Docker (instructions)
Configuration
- This app uses listening port 8080, need to update the lastfm auth key to run
- How to compile and generate binary
- Put the code in GOPATH which is usually ($HOME/go/src)
- Optional: Run
go install
will get the dependency packages (Go mod take care of this anyway) - cd to myfavartist directory, Run
go build -o bin/myfavartist main.go
(This will generate binary file name myfavartist in bin directory)
- cd to myfavartist directory
- To build into docker image
docker build . -t myfavartist:1.0
- To list images from the local docker hub repo
docker images
- To run docker image
docker run -it -d -p 8080:8080 myfavartist:1.0
(This will run myfavartist app and listen on port 8080)
Unit Testing
-
This app uses go programming languages default test framework
-
cd to myfavartist directory, Run
go test ./...
from project directory, this command will get the result something similar below[user@dev utils]$ go test -v ./...
Curl command to get artist detail based on region
- Run
curl -X GET -H "Content-type: application/json" \-H "Accept: application/json" "http://localhost:8080/api/v1/artist/italy"
(This will fectch if the artist and track details)