Documentation
¶
Index ¶
- Variables
- func DebugCompileInfo(h *GoBuild) string
- func FormatChains(chains []ImportChain) string
- type BinarySizer
- type CompileCallback
- type Compiler
- type Config
- type GoBuild
- func (h *GoBuild) BinarySize() string
- func (h *GoBuild) BuildArguments() []string
- func (h *GoBuild) Cancel() error
- func (h *GoBuild) CompileProgram() error
- func (h *GoBuild) CompileToMemory() ([]byte, error)
- func (h *GoBuild) FinalOutputPath() string
- func (h *GoBuild) IsCompiling() bool
- func (h *GoBuild) MainInputFileRelativePath() string
- func (h *GoBuild) MainOutputFileNameWithExtension() string
- func (h *GoBuild) RenameOutputFile() error
- func (h *GoBuild) RenameOutputFileFrom(tempFileName string) error
- func (h *GoBuild) UnobservedFiles() []string
- type ImportChain
Constants ¶
This section is empty.
Variables ¶
var ForbiddenWASMImports = []string{
"bytes", "encoding/json", "errors", "fmt", "io",
"reflect", "strconv", "strings", "unicode",
}
ForbiddenWASMImports son los paquetes de la biblioteca estándar que no deben aparecer en el grafo de un binario WASM del ecosistema. Cada uno tiene un reemplazo en tinywasm/*, y cada uno arrastra bastante más de lo que aparenta: "bytes" trae las tablas completas de unicode, "fmt" trae reflect y strconv.
Functions ¶
func DebugCompileInfo ¶ added in v0.0.26
func FormatChains ¶ added in v0.0.27
func FormatChains(chains []ImportChain) string
FormatChains formatea las cadenas para mostrar al usuario. El formato es el producto de esta herramienta: debe decir exactamente qué cadena existe, no sólo que algo se encontró.
Types ¶
type BinarySizer ¶ added in v0.0.22
type BinarySizer struct {
// contains filtered or unexported fields
}
BinarySizer formats binary sizes in human-readable format
func NewBinarySizer ¶ added in v0.0.22
func NewBinarySizer(getBinary func() []byte) *BinarySizer
NewBinarySizer creates a new BinarySizer instance
func (*BinarySizer) BinarySize ¶ added in v0.0.22
func (b *BinarySizer) BinarySize() string
BinarySize returns the binary size in human-readable format Returns format: "10.4 KB", "2.3 MB", "1.5 GB" Returns "0.0 KB" if binary is unavailable or empty
func (*BinarySizer) SetLog ¶ added in v0.0.22
func (b *BinarySizer) SetLog(f func(...any))
SetLog sets the logging function
type CompileCallback ¶
type CompileCallback func(error)
CompileCallback is called when compilation completes (success or failure)
type Compiler ¶ added in v0.0.26
type Compiler interface {
CompileProgram() error
FinalOutputPath() string
UnobservedFiles() []string
}
compilation represents an active compilation process Compiler defines the interface for a Go compiler.
type Config ¶
type Config struct {
AppRootDir string // eg: /abs/path/to/project
Command string // eg: "go", "tinygo"
MainInputFileRelativePath string // eg: web/main.server.go, web/main.wasm.go
OutName string // eg: app, user, main.server
Extension string // eg: .exe, .wasm
CompilingArguments func() []string // eg: []string{"-X 'main.version=v1.0.0'"}
OutFolderRelativePath string // eg: web, web/public/wasm
Logger func(message ...any) // output for log messages to integrate with other tools (e.g., TUI)
Callback CompileCallback // optional callback for async compilation
Timeout time.Duration // max compilation time, defaults to 5 seconds if not set
Env []string // environment variables, eg: []string{"GOOS=js", "GOARCH=wasm"}
GuardImports bool // corre CheckForbiddenImports antes de compilar; false por defecto
ForbiddenList []string // paquetes prohibidos para GuardImports; nil = ForbiddenWASMImports
}
type GoBuild ¶
type GoBuild struct {
// contains filtered or unexported fields
}
GoBuild represents a Go compiler instance
func (*GoBuild) BinarySize ¶ added in v0.0.22
BinarySize returns the compiled binary size in human-readable format Returns format: "10.4 KB", "2.3 MB", "1.5 GB" Returns "0.0 KB" if binary is unavailable
func (*GoBuild) BuildArguments ¶
BuildArguments returns the build arguments that would be used for compilation This is exposed for testing purposes
func (*GoBuild) CompileProgram ¶
CompileProgram compiles the Go program If a callback is configured, it runs asynchronously and returns immediately Otherwise, it runs synchronously and returns the compilation result Thread-safe: cancels any previous compilation automatically
func (*GoBuild) CompileToMemory ¶ added in v0.0.20
CompileToMemory compiles the Go program returning the binary as a byte slice. It avoids writing to physical disk by using stdout.
func (*GoBuild) FinalOutputPath ¶
FinalOutputPath returns the full path to the final output file eg: web/build/main.wasm
func (*GoBuild) IsCompiling ¶
IsCompiling returns true if there's an active compilation
func (*GoBuild) MainInputFileRelativePath ¶
MainInputFileRelativePath eg: cmd/main.go
func (*GoBuild) MainOutputFileNameWithExtension ¶
MainOutputFileNameWithExtension returns the output filename with extension (e.g., "main.wasm", "app.exe")
func (*GoBuild) RenameOutputFile ¶
RenameOutputFile renames the default temporary output file to the final output file This is exposed for testing purposes
func (*GoBuild) RenameOutputFileFrom ¶
RenameOutputFileFrom renames a specific temporary file to the final output file This is exposed for testing purposes
func (*GoBuild) UnobservedFiles ¶
UnobservedFiles returns the list of files that should not be tracked by file watchers eg: main.exe, main_temp.exe
type ImportChain ¶ added in v0.0.27
type ImportChain struct {
Forbidden string // el paquete prohibido que se alcanzó
Path []string // raíz → … → Forbidden
}
ImportChain es un camino desde el paquete raíz hasta uno prohibido.
func CheckForbiddenImports ¶ added in v0.0.27
func CheckForbiddenImports(dir, pkg, goos, goarch string, forbidden []string) ([]ImportChain, error)
CheckForbiddenImports recorre el grafo de dependencias de pkg —compilado para GOOS/GOARCH— y devuelve una cadena por cada paquete prohibido alcanzable. Devuelve nil, nil si no hay ninguna.
dir es el directorio del módulo; pkg el patrón a analizar (eg "./edge/"). Si forbidden es nil se usa ForbiddenWASMImports.