goserver

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2025 License: MIT Imports: 11 Imported by: 0

README

goserver

Project Badges

goserver is a Go package that encapsulates the logic for running a development and production server. It automatically manages static file serving, external Go server compilation, hot-reloading, and process control, making it easy to switch between development and production modes.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ServerConfig

type ServerConfig struct {
	RootFolder                  string          // eg: web
	MainFileWithoutExtension    string          // eg: main.server
	ArgumentsForCompilingServer func() []string // eg: []string{"-X 'main.version=v1.0.0'"}
	ArgumentsToRunServer        func() []string // eg: []string{"dev" }
	PublicFolder                string          // eg: public
	AppPort                     string          // eg : 8080
	Writer                      io.Writer       // For logging output
	ExitChan                    chan bool       // Canal global para señalizar el cierre
}

type ServerHandler

type ServerHandler struct {
	*ServerConfig
	// contains filtered or unexported fields
}

func NewServerHandler

func NewServerHandler(c *ServerConfig) *ServerHandler

func (*ServerHandler) MainFilePath

func (h *ServerHandler) MainFilePath() string

MainFilePath eg: <root>/web/main.server.go

func (*ServerHandler) Name

func (h *ServerHandler) Name() string

func (*ServerHandler) NewFileEvent

func (h *ServerHandler) NewFileEvent(fileName, extension, filePath, event string) error

event: create,write,remove,rename

func (*ServerHandler) RestartExternalServer

func (h *ServerHandler) RestartExternalServer() error

func (*ServerHandler) RestartInternalServer

func (h *ServerHandler) RestartInternalServer() error

func (*ServerHandler) RestartServer

func (h *ServerHandler) RestartServer() (string, error)

RestartServer reinicia el servidor actual (interno o externo) y devuelve un mensaje de estado

func (*ServerHandler) Start

func (h *ServerHandler) Start(wg *sync.WaitGroup)

Start inicia el servidor como goroutine

func (*ServerHandler) StartExternalServer

func (h *ServerHandler) StartExternalServer() error

func (*ServerHandler) StartInternalServerFiles

func (h *ServerHandler) StartInternalServerFiles()

func (*ServerHandler) StopInternalServer

func (h *ServerHandler) StopInternalServer() error

func (*ServerHandler) UnobservedFiles

func (h *ServerHandler) UnobservedFiles() []string

UnobservedFiles returns the list of files that should not be tracked by file watchers eg: main.exe, main_temp.exe

Jump to

Keyboard shortcuts

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