You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: upgrade.go
    path of file: ./repos/cosmos-sdk/tools/confix
    
    the code of the file until where you have to start completion: package confix

import (
	"bytes"
	"context"
	"errors"
	"fmt"
	"os"
	"strings"

	"github.com/creachadair/atomicfile"
	"github.com/creachadair/tomledit"
	"github.com/creachadair/tomledit/transform"
	"github.
    
func CheckValid(fileName string, data []byte) error {
	v := viper.New()
	v.SetConfigType("toml")

	if err := v.ReadConfig(bytes.NewReader(data)); err != nil {
		return fmt.Errorf("reading config: %w", err)
	}

	switch {
	case strings.HasSuffix(fileName, AppConfig):
		var cfg srvcfg.Config
		if err := v.Unmarshal(&cfg); err != nil {
			return fmt.Errorf("failed to unmarshal as server config: %w", err)
		}

		if err := cfg.ValidateBasic(); err != nil {
			return fmt.Errorf("server config invalid: %w", err)
		}
	case strings.HasSuffix(fileName, ClientConfig):
		var cfg clientcfg.ClientConfig
		if err := v.Unmarshal(&cfg); err != nil {
			return fmt.Errorf("failed to unmarshal as client config: %w", err)
		}

		if cfg.ChainID == "" {
			return errors.New("client config invalid: chain-id is empty")
		}
	case strings.HasSuffix(fileName, CMTConfig):
		return errors.New("cometbft config is not supported")

	default:
		return fmt.Errorf("unknown config: %s", fileName)
	}

	return nil
}