project

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package project provides the functionality for creating a new Go project.

Package project provides the functionality for creating a new Go project.

Index

Constants

This section is empty.

Variables

View Source
var (
	SupportedWebframeworks   = []string{"chi", "echo", "fiber", "gin", "gorilla/mux", "httprouter", "standard-library"}
	SupportedDatabaseDrivers = []string{"mysql", "postgres", "sqlite", "mongo", "none"}
)

Supported Web framework, and DB driver and its dependencies.

Functions

func IsValidDatabaseDriver added in v0.3.0

func IsValidDatabaseDriver(input string) bool

IsValidDatabaseDriver check if the input is supported or not

func IsValidWebFramework

func IsValidWebFramework(input string) bool

isValidWebFramework check if the input is supported or not

Types

type DBDriverTemplateGenerator added in v0.3.0

type DBDriverTemplateGenerator interface {
	Service() []byte
	Env() []byte
	EnvExample() []byte
}

type DatabaseDriver added in v0.3.0

type DatabaseDriver struct {
	// contains filtered or unexported fields
}

DatabaseDriver represents a database driver that can be used in the project. It includes the dependencies of the driver and a template generator.

type Docker added in v0.3.4

type Docker struct {
	// contains filtered or unexported fields
}

Docker represents a dockerfile that can be used in the project. It includes the dependencies of the driver and a template generator.

type DockerTemplateGenerator added in v0.3.4

type DockerTemplateGenerator interface {
	Docker() []byte
}

type ProjectConfig

type ProjectConfig struct {
	ProjectName       string
	ProjectType       string
	DatabaseDriver    string
	Docker            string
	DatabaseDriverMap map[string]DatabaseDriver // can be any of the supported Db Drivers
	FrameworkMap      map[string]WebFramework   // Can be any of the supported router Packages.
	DockerMap         map[string]Docker         // can be any of the supported Db Drivers
	Exit              bool
	AbsolutePath      string
}

ProjectConfig represents the configuration for a new Go project. It includes the project name, type, a map of web frameworks, a flag to indicate whether to exit the CLI, and the absolute path of the project.

func (*ProjectConfig) CreateMainFile

func (p *ProjectConfig) CreateMainFile() error

Todo: Decompose this function into smaller ones. CreateMainFile creates the main file for the project. It creates the project directory, initializes the Go module, installs the dependencies, creates the necessary paths and files, and formats the Go code.

func (*ProjectConfig) ExitCLI

func (p *ProjectConfig) ExitCLI(tprogram *tea.Program)

ExitCLI releases the terminal and exits the program if the Exit flag is set.

type WebFramework

type WebFramework struct {
	// contains filtered or unexported fields
}

WebFramework represents a web framework that can be used in the project. It includes the dependencies of the framework and a template generator.

type WebFrameworkTemplateGenerator added in v0.3.4

type WebFrameworkTemplateGenerator interface {
	Main() []byte
	Server() []byte
	Routes() []byte
	RoutesWithDB() []byte
	ServerWithDB() []byte
}

WebFrameworkTemplateGenerator is an interface that defines the methods for generating templates for the main, server, and routes files.

Jump to

Keyboard shortcuts

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