func SaveMetadata(favourites map[string]bool, currency string, portfolio map[string]float64) error {
	homeDir, err := os.UserHomeDir()
	if err != nil {
		return err
	}
	configPath := homeDir + "/cryptgo-data.json"
	hiddenPath := homeDir + "/.cryptgo-data.json"
	metadata := Metadata{
		Favourites: favourites,
		Currency:   currency,
		Portfolio:  portfolio,
	}
	data, err := json.MarshalIndent(metadata, "", "\t")
	if err != nil {
		return err
	}
	err = os.WriteFile(configPath, data, 0666)
	if err != nil {
		return err
	}
	err = os.Rename(configPath, hiddenPath)
	if err != nil {
		return err
	}
	return nil
}
SaveMetadata exports favourites, currency and portfolio to disk.
Data is saved on ~/.cryptgo-data.json
package utils
import (
	"encoding/json"
	"os"
)
type Metadata struct {
	Favourites map[string]bool    `json:"favourites"`
	Currency   string             `json:"currency"`
	Portfolio  map[string]float64 `json:"portfolio"`
}
type Currency struct {
	ID             string `json:"id"`
	Symbol         string `json:"symbol"`
	CurrencySymbol string `json:"currencySymbol"`
	Type           string `json:"type"`
	RateUSD        string `json:"rateUsd"`
}
type AllCurrencyData struct {
	Data      []Currency `json:"data"`
	Timestamp uint       `json:"timestamp"`
}
func GetFavourites() map[string]bool {
	metadata := Metadata{}
	homeDir, err := os.UserHomeDir()
	if err != nil {
		return map[string]bool{}
	}
	configPath := homeDir + "/.cryptgo-data.json"
	if _, err := os.Stat(configPath); os.IsNotExist(err) {
		return map[string]bool{}
	}
	configFile, err := os.Open(configPath)
	if err != nil {
		return map[string]bool{}
	}
	err = json.NewDecoder(configFile).Decode(&metadata)
	if err != nil {
		return map[string]bool{}
	}
	if len(metadata.Favourites) > 0 {
		return metadata.Favourites
	}
	return map[string]bool{}
}
func GetPortfolio() map[string]float64 {
	metadata := Metadata{}
	homeDir, err := os.UserHomeDir()
	if err != nil {
		return map[string]float64{}
	}
	configPath := homeDir + "/.cryptgo-data.json"
	if _, err := os.Stat(configPath); os.IsNotExist(err) {
		return map[string]float64{}
	}
	configFile, err := os.Open(configPath)
	if err != nil {
		return map[string]float64{}
	}
	err = json.NewDecoder(configFile).Decode(&metadata)
	if err != nil {
		return map[string]float64{}
	}
	if len(metadata.Portfolio) > 0 {
		return metadata.Portfolio
	}
	return map[string]float64{}
}
func GetCurrencyID() string {
	metadata := Metadata{}
	homeDir, err := os.UserHomeDir()
	if err != nil {
		return "united-states-dollar"
	}
	configPath := homeDir + "/.cryptgo-data.json"
	if _, err := os.Stat(configPath); os.IsNotExist(err) {
		return "united-states-dollar"
	}
	configFile, err := os.Open(configPath)
	if err != nil {
		return "united-states-dollar"
	}
	err = json.NewDecoder(configFile).Decode(&metadata)
	if err != nil {
		return "united-states-dollar"
	}
	return metadata.Currency
}