config

package
v0.0.0-...-a24a2df Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddConnection

func AddConnection(config *Config, conn Connection) error

AddConnection 添加数据库连接

func DeleteConnection

func DeleteConnection(config *Config, name string) error

DeleteConnection 删除数据库连接

func SaveConfig

func SaveConfig(config *Config) error

SaveConfig 保存配置文件

Types

type Config

type Config struct {
	Connections []Connection `toml:"connections"` // 数据库连接列表
}

Config 配置文件结构

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig 加载配置文件

type Connection

type Connection struct {
	Name     string `toml:"name"`     // 连接名称
	Type     string `toml:"type"`     // 数据库类型:mysql,postgres,sqlite
	Host     string `toml:"host"`     // 主机地址
	Port     int    `toml:"port"`     // 端口号
	User     string `toml:"user"`     // 用户名
	Password string `toml:"password"` // 密码
	DbName   string `toml:"dbname"`   // 数据库名称
	FilePath string `toml:"filepath"` // SQLite文件路径
	SSLMode  string `toml:"sslmode"`  // PostgreSQL SSL 模式:disable/require/verify-ca/verify-full,留空默认 disable
}

Connection 数据库连接配置

func GetConnectionByName

func GetConnectionByName(config *Config, name string) (*Connection, error)

GetConnectionByName 根据名称获取数据库连接

func GetConnections

func GetConnections(config *Config) []Connection

GetConnections 获取所有数据库连接

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL