How to refer to "any" type in Go!?

Report a typo

Bruno has written a Go program that uses the json.Marshal() function to encode the songs map to the songsJSON variable.

However, he's made a small mistake when declaring the type of the values of the songs map!

Can you identify the error and help Bruno use the correct type to process "any" type of values in the songs map, and then print the encoded songsJSON variable content as a string?

Sample Input 1:

Treasure 2:59 2012

Sample Output 1:

{"duration":"2:59","name":"Treasure","releaseYear":2012}
Write a program in Go
package main

import (
"encoding/json"
"fmt"
"log"
)

func main() {
// DO NOT delete! - This code block takes as an input the values for the 'songs' map:
var songName string
var songDuration string
var songReleaseYear int

fmt.Scanln(&songName, &songDuration, &songReleaseYear)

// What type in Go allows us to refer to "any" type!?
// Correct the type of the values of the songs map below to accept "any" type of values!
songs := map[string]string{
"name": songName,
"duration": songDuration,
"releaseYear": songReleaseYear,
}

// Do NOT delete! - This code block encodes 'songs' to 'songsJSON'
// And then prints the encoded result as a string!
songsJSON, err := json.Marshal(songs)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(songsJSON))
}
___

Create a free account to access the full topic