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: config.go
    path of file: ./repos/liftbridge/server
    
    the code of the file until where you have to start completion: package server

import (
	"crypto/tls"
	"crypto/x509"
	"fmt"
	"io/ioutil"
	"net"
	"strconv"
	"strings"
	"time"

	"github.com/dustin/go-humanize"
	"github.com/hako/durafmt"
	client "github.com/liftbridge-io/liftbridge-api/go"
	"github.com/nats-io/nats.go"
	"github.com/nats-io/nuid"
	"github.com/pkg/errors"
	log "github.com/sirupsen/logrus"
	"github.com/spf13/viper"

	proto "github.com/liftbridge-io/liftbridge/server/protocol"
)

const (
	// DefaultNamespace is the default cluster namespace to use if one is not
	// specified.
	DefaultNamespace = "liftbridge-default"

	// DefaultPort is the port to bind to if one is not specified.
	DefaultPort = 9292
)

// Config setting defaults.
const (
	defaultListenAddress                  = "0.0.0.0"
	defaultConnectionAddress              = "localhost"
	defaultReplicaMaxLagTime              = 15 * time.Second
	defaultReplicaMaxLeaderTimeout        = 15 * time.Second
	defaultReplicaMaxIdleWait             = 10 * time.Second
	defaultReplicationMaxBytes            = 1024 * 1024 // 1MB
	defaultRaftSnapshots                  = 2
	defaultRaftCacheSize                  = 512
	defaultMetadataCacheMaxAge            = 2 * time.Minute
	defaultBatchMaxMessages               = 1024
	defaultReplicaFetchTimeout            = 3 * ti
    
func parseNATSConfig(config *Config, v *viper.Viper) error {
	if v.IsSet(configNATSEmbeddedConfig) {
		config.EmbeddedNATS = true
		config.EmbeddedNATSConfig = v.GetString(configNATSEmbeddedConfig)
	}

	if v.IsSet(configNATSEmbedded) {
		config.EmbeddedNATS = true
	}

	if v.IsSet(configNATSServers) {
		servers := v.GetStringSlice(configNATSServers)
		config.NATS.Servers = servers
	}

	if v.IsSet(configNATSUser) {
		config.NATS.User = v.GetString(configNATSUser)
	}

	if v.IsSet(configNATSPassword) {
		config.NATS.Password = v.GetString(configNATSPassword)
	}

	// NATS TLS config
	// Both Cert and Key must be presented

	if v.IsSet(configNATSCert) && v.IsSet(configNATSKey) {

		// Load cert and key file
		certFile := v.GetString(configNATSCert)
		keyFile := v.GetString(configNATSKey)

		cert, err := tls.LoadX509KeyPair(certFile, keyFile)
		if err != nil {
			return err
		}

		tlsConfig := &tls.Config{
			Certificates: []tls.Certificate{cert},
			MinVersion:   tls.VersionTLS12,
		}

		// Load CACert if available
		if v.IsSet(configNATSCA) {
			caFile := v.GetString(configNATSCA)
			// Load CA cert
			caCert, err := ioutil.ReadFile(caFile)

			if err != nil {
				return err
			}
			caCertPool := x509.NewCertPool()
			caCertPool.AppendCertsFromPEM(caCert)

			tlsConfig.RootCAs = caCertPool
		}
		config.NATS.TLSConfig = tlsConfig
	}

	return nil
}