config

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultConfig is the default configuration
	DefaultConfig = Config{
		Profiles: map[string]Profile{
			"default": {
				Author:  "",
				Email:   "",
				License: "MIT",
				Defaults: ProfileDefaults{
					GoVersion:    "1.21",
					Framework:    "gin",
					Architecture: "standard",
					Logger:       "slog",
					Database: DatabaseDefaults{
						Driver: "",
						ORM:    "gorm",
					},
					Auth: AuthDefaults{
						Type: "",
					},
					Logging: LoggingDefaults{
						Type:       "slog",
						Level:      "info",
						Format:     "json",
						Structured: true,
					},
				},
			},
		},
		CurrentProfile: "default",
	}
)

Functions

func ValidateArchitecture

func ValidateArchitecture(architecture string) error

ValidateArchitecture validates an architecture pattern

func ValidateAuthType

func ValidateAuthType(authType string) error

ValidateAuthType validates an authentication type

func ValidateAuthor

func ValidateAuthor(author string) error

ValidateAuthor validates an author name

func ValidateDatabaseDriver

func ValidateDatabaseDriver(driver string) error

ValidateDatabaseDriver validates a database driver

func ValidateEmail

func ValidateEmail(email string) error

ValidateEmail validates an email address

func ValidateFeatures

func ValidateFeatures(features map[string]interface{}) error

ValidateFeatures validates project features configuration

func ValidateFramework

func ValidateFramework(framework string) error

ValidateFramework validates a framework choice

func ValidateGoVersion

func ValidateGoVersion(version string) error

ValidateGoVersion validates a Go version string

func ValidateLogFormat

func ValidateLogFormat(format string) error

ValidateLogFormat validates a log format

func ValidateLogLevel

func ValidateLogLevel(level string) error

ValidateLogLevel validates a log level

func ValidateLogger

func ValidateLogger(logger string) error

ValidateLogger validates a logger type

func ValidateModulePath

func ValidateModulePath(path string) error

ValidateModulePath validates a Go module path

func ValidateORM

func ValidateORM(orm string) error

ValidateORM validates an ORM choice

func ValidateOutputPath

func ValidateOutputPath(path string) error

ValidateOutputPath validates an output directory path

func ValidateProjectName

func ValidateProjectName(name string) error

ValidateProjectName validates a project name

func ValidateTemplateType

func ValidateTemplateType(templateType string) error

ValidateTemplateType validates a template type

Types

type AuthDefaults

type AuthDefaults struct {
	// Type is the default authentication type
	Type string `yaml:"type" mapstructure:"type"`
}

AuthDefaults contains default authentication configuration

type Config

type Config struct {
	// Profiles contain user configuration profiles
	Profiles map[string]Profile `yaml:"profiles" mapstructure:"profiles"`
	// CurrentProfile is the active profile name
	CurrentProfile string `yaml:"current_profile" mapstructure:"current_profile"`
}

Config represents the application configuration

func Load

func Load(configFile string) (*Config, error)

Load loads the configuration from the config file

func (*Config) AddProfile

func (c *Config) AddProfile(name string, profile Profile)

AddProfile adds a new profile to the configuration

func (*Config) GetCurrentProfile

func (c *Config) GetCurrentProfile() (*Profile, error)

GetCurrentProfile returns the current active profile

func (*Config) RemoveProfile

func (c *Config) RemoveProfile(name string) error

RemoveProfile removes a profile from the configuration

func (*Config) Save

func (c *Config) Save(configFile string) error

Save saves the configuration to the specified file

func (*Config) SetCurrentProfile

func (c *Config) SetCurrentProfile(name string) error

SetCurrentProfile sets the current active profile

type DatabaseDefaults

type DatabaseDefaults struct {
	// Driver is the default database driver
	Driver string `yaml:"driver" mapstructure:"driver"`
	// ORM is the default ORM
	ORM string `yaml:"orm" mapstructure:"orm"`
}

DatabaseDefaults contains default database configuration

type LoggingDefaults

type LoggingDefaults struct {
	// Type is the default logger type
	Type string `yaml:"type" mapstructure:"type"`
	// Level is the default log level
	Level string `yaml:"level" mapstructure:"level"`
	// Format is the default log format
	Format string `yaml:"format" mapstructure:"format"`
	// Structured indicates if structured logging is enabled by default
	Structured bool `yaml:"structured" mapstructure:"structured"`
}

LoggingDefaults contains default logging configuration

type Profile

type Profile struct {
	// Author is the default project author
	Author string `yaml:"author" mapstructure:"author"`
	// Email is the default author email
	Email string `yaml:"email" mapstructure:"email"`
	// License is the default license type
	License string `yaml:"license" mapstructure:"license"`
	// Defaults contains default values for project generation
	Defaults ProfileDefaults `yaml:"defaults" mapstructure:"defaults"`
}

Profile represents a user configuration profile

type ProfileDefaults

type ProfileDefaults struct {
	// GoVersion is the default Go version to use
	GoVersion string `yaml:"go_version" mapstructure:"go_version"`
	// Framework is the default framework
	Framework string `yaml:"framework" mapstructure:"framework"`
	// Architecture is the default architecture pattern
	Architecture string `yaml:"architecture" mapstructure:"architecture"`
	// Logger is the default logger type
	Logger string `yaml:"logger" mapstructure:"logger"`
	// Database is the default database configuration
	Database DatabaseDefaults `yaml:"database" mapstructure:"database"`
	// Auth is the default authentication configuration
	Auth AuthDefaults `yaml:"auth" mapstructure:"auth"`
	// Logging is the default logging configuration
	Logging LoggingDefaults `yaml:"logging" mapstructure:"logging"`
}

ProfileDefaults contains default values for project generation

Jump to

Keyboard shortcuts

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