func (c *Config) Validate() error {
	if c.Port < 1 || 65535 < c.Port {
		return fmt.Errorf("must be between 1 and 65535, given %d: %w", c.Port, ErrInvalidRPCPort)
	}
	if c.CertFile != "" {
		if _, err := os.Stat(c.CertFile); err != nil {
			return fmt.Errorf("%s: %w", c.CertFile, ErrInvalidCertFile)
		}
	}
	if c.KeyFile != "" {
		if _, err := os.Stat(c.KeyFile); err != nil {
			return fmt.Errorf("%s: %w", c.KeyFile, ErrInvalidKeyFile)
		}
	}
	return nil
}
Validate validates the port number and the files for certification.
package rpc
import (
	"errors"
	"fmt"
	"os"
)
var (
	ErrInvalidRPCPort = errors.New("invalid port number for RPC server")
	ErrInvalidCertFile = errors.New("invalid cert file for RPC server")
	ErrInvalidKeyFile = errors.New("invalid key file for RPC server")
)
type Config struct {
	Port     int
	CertFile string
	KeyFile  string
}