func Write(c *Config) error {
	configDir, err := Dir()
	if err != nil {
		return err
	}
	dirExists := utils.DirExists(configDir)
	if !dirExists {
		err := os.Mkdir(configDir, 0744)
		if err != nil {
			return err
		}
	}
	configFilePath, err := Path()
	if err != nil {
		return err
	}
	file, err := os.Create(configFilePath)
	if err != nil {
		return err
	}
	defer file.Close()
	data, err := json.MarshalIndent(c, "", constants.JsonIndent)
	if err != nil {
		return err
	}
	_, err = file.Write(data)
	return err
}
Write writes config data to the config file. Returns an error if failed to write data
package config
import (
	"encoding/json"
	"errors"
	"fmt"
	"os"
	"path/filepath"
	"time"
	"github.com/matsuyoshi30/gitsu/internal/constants"
	"github.com/matsuyoshi30/gitsu/internal/models"
	"github.com/matsuyoshi30/gitsu/internal/utils"
)
var (
	ErrConfigFileDoesNotExist = errors.New("Config file does not exist")
	ErrUserIndexOutOfBounds   = errors.New("User index out of bounds")
	ErrNoDefaultUser          = errors.New("No default user")
	ErrNoUserWithAlias        = errors.New("No user with this alias")
)
type Config struct {
	Version string        `json:"version"`
	Users   []models.User `json:"users"`
}
func Dir() (string, error) {
	userConfigDir, err := os.UserConfigDir()
	if err != nil {
		return "", err
	}
	return filepath.Join(userConfigDir, constants.ConfigDir), nil
}
func Path() (string, error) {
	configDir, err := Dir()
	if err != nil {
		return "", err
	}
	return filepath.Join(configDir, constants.ConfigFileName), nil
}
func Exists() (bool, error) {
	configFilePath, err := Path()
	if err != nil {
		return false, err
	}
	return utils.FileExists(configFilePath), nil
}
func Read() (*Config, error) {
	exists, err := Exists()
	if err != nil {
		return nil, err
	}
	if !exists {
		return nil, ErrConfigFileDoesNotExist
	}
	configFilePath, err := Path()
	if err != nil {
		return nil, err
	}
	b, err := os.ReadFile(configFilePath)
	if err != nil {
		return nil, err
	}
	c := new(Config)
	err = json.Unmarshal(b, c)
	if err != nil {
		return nil, err
	}
	return c, nil
}