stdlib

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 60 Imported by: 0

Documentation

Overview

pkg/stdlib/array.go Array utilities for the Xxlang standard library.

pkg/stdlib/bytes.go Byte manipulation utilities for the Xxlang standard library.

pkg/stdlib/bytesbuffer.go BytesBuffer module for efficient byte buffer operations.

pkg/stdlib/collections.go Collection utilities for the Xxlang standard library.

pkg/stdlib/concurrent.go Concurrency built-in functions for Xxlang

pkg/stdlib/crypto.go Cryptography utilities for the Xxlang standard library. Pure Go implementation using standard library - no CGO required. Includes Charlang-compatible encryption functions (TXTE, TXDEE, TXDEF, AES).

pkg/stdlib/csv.go CSV parsing and generation utilities for the Xxlang standard library.

pkg/stdlib/db.go Database module for Xxlang. Provides database connection, query, and execution capabilities. Supports SQLite, MySQL, PostgreSQL, Oracle, and MSSQL Server. All drivers are pure Go implementations (no CGO required).

Driver names:

  • SQLite: "sqlite"
  • MySQL: "mysql"
  • PostgreSQL: "postgres"
  • Oracle: "oracle"
  • MSSQL Server: "mssql"

pkg/stdlib/debug.go Debug utilities for the Xxlang standard library.

pkg/stdlib/docx.go DOCX module for Xxlang - Microsoft Word document processing.

pkg/stdlib/encoding.go Encoding utilities for the Xxlang standard library.

pkg/stdlib/env.go Environment variables and configuration utilities for the Xxlang standard library.

pkg/stdlib/file.go File module for streaming file operations in Xxlang standard library.

pkg/stdlib/fmt.go Advanced formatting utilities for the Xxlang standard library.

pkg/stdlib/fp.go Functional programming utilities for the Xxlang standard library.

pkg/stdlib/ftp.go FTP module for Xxlang - FTP client and server functionality.

Package stdlib provides the standard library modules for Xxlang. This file contains the GUI module for WebView2 support.

pkg/stdlib/html.go HTML module for Xxlang - HTML document handling.

pkg/stdlib/http.go HTTP server utilities for the Xxlang standard library. These functions are designed for HTTP server mode.

pkg/stdlib/image.go Image processing module for Xxlang.

pkg/stdlib/io.go I/O utilities for the Xxlang standard library.

pkg/stdlib/json.go JSON utilities for the Xxlang standard library. This module provides comprehensive JSON parsing, serialization, and file operations. The builtin functions toJson and fromJson are aliases for json.stringify and json.parse respectively.

pkg/stdlib/jsonpath.go JSONPath implementation for querying and manipulating JSON objects. JSONPath syntax reference: https://goessner.net/articles/JsonPath/

pkg/stdlib/le.go Line Editor (le) module for Xxlang - line-based text editing functionality.

pkg/stdlib/locale.go Locale module for Xxlang - provides language/region specific text processing functions

pkg/stdlib/log.go Logging utilities for the Xxlang standard library.

pkg/stdlib/mail.go Mail module for Xxlang - Email sending functionality.

pkg/stdlib/math.go Standard library math module.

pkg/stdlib/net.go Network utilities for the Xxlang standard library.

pkg/stdlib/os.go OS utilities for the Xxlang standard library.

pkg/stdlib/pdf.go PDF processing module for Xxlang. Provides functions for reading, creating, and manipulating PDF files. Implemented using only Go standard library - no third-party dependencies.

pkg/stdlib/pptx.go PPTX module for Xxlang - PowerPoint file handling.

pkg/stdlib/queue.go Queue module for Xxlang - FIFO data structure.

pkg/stdlib/regex.go Regular expression utilities for the Xxlang standard library. Uses regexp2 for full PCRE support including lookahead/lookbehind.

pkg/stdlib/set.go Set module for Xxlang - unordered collection of unique elements.

pkg/stdlib/sftp.go SFTP module for Xxlang - SFTP client and server functionality.

Package stdlib provides standard library modules for the Xxlang language. This file implements the socket module for TCP/UDP network operations.

pkg/stdlib/socks.go SOCKS and encrypted proxy module for Xxlang. Provides SOCKS4/SOCKS5 proxy and encrypted tunnel proxy functionality.

pkg/stdlib/sort.go Sorting utilities for the Xxlang standard library.

pkg/stdlib/ssh.go SSH module for Xxlang - SSH client functionality.

pkg/stdlib/stdlib.go Standard library modules for Xxlang.

pkg/stdlib/strconv.go String conversion utilities for the Xxlang standard library.

pkg/stdlib/stringbuilder.go StringBuilder module for efficient string concatenation.

pkg/stdlib/strings.go String utilities for the Xxlang standard library.

pkg/stdlib/task.go Task and scheduling module for Xxlang.

pkg/stdlib/testing.go Testing utilities for the Xxlang standard library.

pkg/stdlib/text.go Text processing utilities for the Xxlang standard library.

pkg/stdlib/time.go Time utilities for the Xxlang standard library.

pkg/stdlib/toml.go TOML module for Xxlang - TOML document handling.

pkg/stdlib/utils.go Utility functions for the Xxlang standard library.

pkg/stdlib/uuid.go UUID generation utilities for the Xxlang standard library.

pkg/stdlib/validate.go Validation utilities for the Xxlang standard library.

pkg/stdlib/websocket.go WebSocket utilities for the Xxlang standard library. These functions are designed for WebSocket server mode.

pkg/stdlib/xlsx.go XLSX module for Xxlang - Excel file handling.

pkg/stdlib/xml.go XML module for Xxlang - XML document handling.

pkg/stdlib/yaml.go YAML parsing and generation utilities for the Xxlang standard library. This module provides comprehensive YAML parsing, serialization, and file operations without using third-party libraries or CGO.

pkg/stdlib/zip.go ZIP file utilities for the Xxlang standard library. Provides comprehensive ZIP creation, extraction, and manipulation with full UTF-8 support.

UTF-8/Unicode Filename Support: - Modern ZIP tools correctly set the UTF-8 flag for non-ASCII filenames - Go's archive/zip package automatically handles UTF-8 flagged entries - For legacy ZIP files with GBK/CP437 encoded names, use the gbkToUtf8 option - This module includes special handling for Chinese and other Unicode filenames

Index

Constants

This section is empty.

Variables

View Source
var Registry = make(map[string]*Module)

Registry holds all registered standard library modules.

Functions

func Array

func Array(elements ...objects.Object) *objects.Array

Array creates an array object.

func Bool

func Bool(v bool) *objects.Bool

Bool creates a boolean object.

func BuiltinFunc

func BuiltinFunc(fn func(...objects.Object) objects.Object) *objects.Builtin

BuiltinFunc creates a builtin function object.

func CreateImage added in v0.5.13

func CreateImage(args ...objects.Object) objects.Object

CreateImage creates a new solid color image. Usage: image.createImage(width, height) -> bytes (white PNG)

image.createImage(width, height, colorHex) -> bytes

Example:

img := image.createImage(100, 100, "#FF0000")  // Red image
saveBytes("red.png", img)

func Error

func Error(msg string) *objects.Error

Error creates an error object.

func Float

func Float(v float64) *objects.Float

Float creates a float object.

func GenQr added in v0.5.13

func GenQr(args ...objects.Object) objects.Object

GenQr generates a QR code image from text. Usage: image.genQr(text) -> bytes (PNG image)

image.genQr(text, size) -> bytes
image.genQr(text, size, level) -> bytes  (level: low, medium, high, highest)

Example:

qrBytes := image.genQr("https://example.com")
saveBytes("qr.png", qrBytes)

qrBytes := image.genQr("Hello World", 256)
qrBytes := image.genQr("Data", 256, "high")

func GetConfigMap added in v0.4.19

func GetConfigMap() map[string]interface{}

GetConfigMap reads the Xxlang configuration and returns it as a Go map. This is useful for accessing config values from Go code before the VM starts. Search path priority: 1. ~/.xxl/settings.json (user home directory) 2. /.xxl/settings.json (Linux/Unix systems) 3. C:\.xxl\settings.json (Windows systems) Returns an empty map if no config file is found.

func GetImageInfo added in v0.5.13

func GetImageInfo(args ...objects.Object) objects.Object

GetImageInfo gets information about an image. Usage: image.getImageInfo(imageBytes) -> map

image.getImageInfo(imagePath) -> map

Returns map with: width, height, format, hasAlpha, bounds

Example:

info := image.getImageInfo(loadBytes("photo.jpg"))
pln("Width:", info["width"])

func Has

func Has(name string) bool

Has checks if a module exists in the registry.

func Int

func Int(v int64) *objects.Int

Int creates an integer object.

func IsCronExprDue added in v0.5.13

func IsCronExprDue(args ...objects.Object) objects.Object

IsCronExprDue checks if a cron expression is due at the current or specified time. Usage: task.isCronExprDue(expr) -> bool

task.isCronExprDue(expr, timeStr) -> bool  (check at specified time)

Example:

task.isCronExprDue("* * * * *")           // true if current minute matches
task.isCronExprDue("0 0 * * *")           // true if it's midnight

func IsCronExprValid added in v0.5.13

func IsCronExprValid(args ...objects.Object) objects.Object

IsCronExprValid checks if a cron expression is valid. Usage: task.isCronExprValid(expr) -> bool

Example:

task.isCronExprValid("* * * * *")        // true
task.isCronExprValid("*/5 * * * *")      // true
task.isCronExprValid("invalid")          // false
task.isCronExprValid("0 0 * * * *")      // true (with seconds)

func Null

func Null() *objects.Null

Null returns the null object.

func Paths added in v0.4.25

func Paths(obj objects.Object) []string

Paths returns all JSONPath strings that lead to values in the object

func Register

func Register(m *Module)

Register adds a module to the registry.

func ResizeImage added in v0.5.13

func ResizeImage(args ...objects.Object) objects.Object

ResizeImage resizes an image to specified dimensions. Usage: image.resizeImage(imageBytes, width, height) -> bytes (PNG)

image.resizeImage(imageBytes, width, height, format) -> bytes

Example:

imgBytes := loadBytes("photo.jpg")
resized := image.resizeImage(imgBytes, 800, 600)
saveBytes("resized.png", resized)

func RunTicker added in v0.5.13

func RunTicker(args ...objects.Object) objects.Object

RunTicker runs a function periodically at specified intervals. Returns a ticker ID that can be used to stop the ticker. Usage: task.runTicker(intervalSeconds, callback) -> int (ticker ID)

task.runTicker(intervalSeconds, callback, arg1, arg2, ...) -> int

The callback function will be called with any additional arguments. To stop the ticker, return an error from the callback or use stopTicker.

Example:

id := task.runTicker(5, func() { pln("tick!") })
id := task.runTicker(1.5, myFunc, arg1, arg2)

func ScanQr added in v0.5.13

func ScanQr(args ...objects.Object) objects.Object

ScanQr scans a QR code from image bytes. Usage: image.scanQr(imageBytes) -> string or error

Example:

imgBytes := loadBytes("qr.png")
result := image.scanQr(imgBytes)

func SetScriptArgs added in v0.4.19

func SetScriptArgs(args []string)

SetScriptArgs sets the script-specific arguments for scripts to access

func StopTicker added in v0.5.13

func StopTicker(args ...objects.Object) objects.Object

StopTicker stops a running ticker by ID. Usage: task.stopTicker(tickerID) -> bool

Returns true if the ticker was stopped, false if not found.

func String

func String(v string) *objects.String

String creates a string object.

func TestFromJsonToJsonIndent added in v0.6.0

func TestFromJsonToJsonIndent(t *testing.T)

TestFromJsonToJsonIndent covers fromJson and toJson with string indentation and int indentation.

func TestParseDocumentsError added in v0.6.0

func TestParseDocumentsError(t *testing.T)

TestParseDocumentsError ensures that invalid documents produce an error in parseDocuments

func TestYAMLDeepMergeNonMap added in v0.6.0

func TestYAMLDeepMergeNonMap(t *testing.T)

TestYAMLDeepMergeNonMap verifies non-map overrides in deepMerge

func TestYAMLFileIO added in v0.6.0

func TestYAMLFileIO(t *testing.T)

TestYAMLFileIO covers writeFile, readFile, and updateFile behaviors using a temp directory.

func TestYAMLFlattenExpandRoundtrip added in v0.6.0

func TestYAMLFlattenExpandRoundtrip(t *testing.T)

TestYAMLFlattenExpandRoundtrip ensures flatten followed by expand yields equivalent structure

func TestYAMLKeysValues added in v0.6.0

func TestYAMLKeysValues(t *testing.T)

TestYAMLKeysValues ensures keys() and values() work on a map

func TestYAMLStringifyIndentEdgeCase added in v0.6.0

func TestYAMLStringifyIndentEdgeCase(t *testing.T)

TestYAMLStringifyIndentEdgeCase ensures negative indent is treated as 0 and non-negative works.

Types

type CompiledRegex

type CompiledRegex struct {
	Pattern string
	Re      *regexp2.Regexp
}

CompiledRegex represents a compiled regular expression

func (*CompiledRegex) HashKey

func (cr *CompiledRegex) HashKey() objects.HashKey

func (*CompiledRegex) Inspect

func (cr *CompiledRegex) Inspect() string

func (*CompiledRegex) ToBool

func (cr *CompiledRegex) ToBool() *objects.Bool

func (*CompiledRegex) Type

func (cr *CompiledRegex) Type() objects.ObjectType

func (*CompiledRegex) TypeTag

func (cr *CompiledRegex) TypeTag() objects.TypeTag

type EncryptedConn added in v0.5.10

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

EncryptedConn wraps a net.Conn with encryption.

func NewEncryptedConn added in v0.5.10

func NewEncryptedConn(conn net.Conn, password string, isServer bool) (*EncryptedConn, error)

NewEncryptedConn creates a new encrypted connection.

func (*EncryptedConn) Close added in v0.5.10

func (ec *EncryptedConn) Close() error

Close closes the underlying connection.

func (*EncryptedConn) Read added in v0.5.10

func (ec *EncryptedConn) Read(b []byte) (int, error)

Read reads and decrypts data from the connection.

func (*EncryptedConn) Write added in v0.5.10

func (ec *EncryptedConn) Write(b []byte) (int, error)

Write encrypts and writes data to the connection.

type JSONPath added in v0.4.25

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

JSONPath represents a parsed JSONPath expression

func ParseJSONPath added in v0.4.25

func ParseJSONPath(path string) (*JSONPath, error)

ParseJSONPath parses a JSONPath expression string into a JSONPath struct

func (*JSONPath) Delete added in v0.4.25

func (jp *JSONPath) Delete(obj objects.Object) (objects.Object, error)

Delete deletes values at the specified path

func (*JSONPath) Get added in v0.4.25

func (jp *JSONPath) Get(obj objects.Object) []objects.Object

Get retrieves values from an object using the JSONPath

func (*JSONPath) GetWithPath added in v0.4.25

func (jp *JSONPath) GetWithPath(obj objects.Object) []JSONPathMatch

GetWithPath retrieves values along with their paths

func (*JSONPath) Set added in v0.4.25

func (jp *JSONPath) Set(obj objects.Object, value objects.Object) (objects.Object, error)

Set sets a value at the specified path

type JSONPathMatch added in v0.4.25

type JSONPathMatch struct {
	Path  string
	Value objects.Object
}

JSONPathMatch represents a match result with its path

type Module

type Module struct {
	Name    string
	Exports map[string]objects.Object
}

Module represents a standard library module.

func Get

func Get(name string) *Module

Get retrieves a module from the registry.

type ProxyClient added in v0.5.10

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

ProxyClient represents an encrypted proxy client.

func NewProxyClient added in v0.5.10

func NewProxyClient() *ProxyClient

NewProxyClient creates a new proxy client.

func (*ProxyClient) Connections added in v0.5.10

func (c *ProxyClient) Connections() int

Connections returns the number of active connections.

func (*ProxyClient) GetLocalAddr added in v0.5.10

func (c *ProxyClient) GetLocalAddr() string

GetLocalAddr returns the local address.

func (*ProxyClient) GetServerAddr added in v0.5.10

func (c *ProxyClient) GetServerAddr() string

GetServerAddr returns the server address.

func (*ProxyClient) HashKey added in v0.5.10

func (c *ProxyClient) HashKey() objects.HashKey

HashKey returns a hash key.

func (*ProxyClient) Inspect added in v0.5.10

func (c *ProxyClient) Inspect() string

Inspect returns a string representation.

func (*ProxyClient) IsRunning added in v0.5.10

func (c *ProxyClient) IsRunning() bool

IsRunning returns whether the client is running.

func (*ProxyClient) Start added in v0.5.10

func (c *ProxyClient) Start(localAddr, serverAddr, password string, verbose bool) error

Start starts the proxy client.

func (*ProxyClient) Stop added in v0.5.10

func (c *ProxyClient) Stop() error

Stop stops the proxy client.

func (*ProxyClient) ToBool added in v0.5.10

func (c *ProxyClient) ToBool() *objects.Bool

ToBool returns true if running.

func (*ProxyClient) Type added in v0.5.10

func (c *ProxyClient) Type() objects.ObjectType

Type returns the object type.

func (*ProxyClient) TypeTag added in v0.5.10

func (c *ProxyClient) TypeTag() objects.TypeTag

TypeTag returns the fast type tag.

type ProxyServer added in v0.5.10

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

ProxyServer represents an encrypted proxy server.

func NewProxyServer added in v0.5.10

func NewProxyServer() *ProxyServer

NewProxyServer creates a new proxy server.

func (*ProxyServer) Connections added in v0.5.10

func (s *ProxyServer) Connections() int

Connections returns the number of active connections.

func (*ProxyServer) GetListenAddr added in v0.5.10

func (s *ProxyServer) GetListenAddr() string

GetListenAddr returns the listen address.

func (*ProxyServer) HashKey added in v0.5.10

func (s *ProxyServer) HashKey() objects.HashKey

HashKey returns a hash key.

func (*ProxyServer) Inspect added in v0.5.10

func (s *ProxyServer) Inspect() string

Inspect returns a string representation.

func (*ProxyServer) IsRunning added in v0.5.10

func (s *ProxyServer) IsRunning() bool

IsRunning returns whether the server is running.

func (*ProxyServer) Start added in v0.5.10

func (s *ProxyServer) Start(listenAddr, password string, verbose bool) error

Start starts the proxy server.

func (*ProxyServer) Stop added in v0.5.10

func (s *ProxyServer) Stop() error

Stop stops the proxy server.

func (*ProxyServer) ToBool added in v0.5.10

func (s *ProxyServer) ToBool() *objects.Bool

ToBool returns true if running.

func (*ProxyServer) Type added in v0.5.10

func (s *ProxyServer) Type() objects.ObjectType

Type returns the object type.

func (*ProxyServer) TypeTag added in v0.5.10

func (s *ProxyServer) TypeTag() objects.TypeTag

TypeTag returns the fast type tag.

type SocksClient added in v0.5.10

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

SocksClient represents a SOCKS proxy client connection.

func NewSocksClient added in v0.5.10

func NewSocksClient() *SocksClient

NewSocksClient creates a new SOCKS client.

func (*SocksClient) Close added in v0.5.10

func (c *SocksClient) Close() error

Close closes the connection.

func (*SocksClient) Connect added in v0.5.10

func (c *SocksClient) Connect(proxyAddr, target string, socks5 bool) error

Connect connects to a target through a SOCKS proxy.

func (*SocksClient) ConnectWithAuth added in v0.5.10

func (c *SocksClient) ConnectWithAuth(proxyAddr, target, username, password string) error

ConnectWithAuth connects with username/password authentication (SOCKS5).

func (*SocksClient) HashKey added in v0.5.10

func (c *SocksClient) HashKey() objects.HashKey

HashKey returns a hash key.

func (*SocksClient) Inspect added in v0.5.10

func (c *SocksClient) Inspect() string

Inspect returns a string representation.

func (*SocksClient) IsConnected added in v0.5.10

func (c *SocksClient) IsConnected() bool

IsConnected returns whether the client is connected.

func (*SocksClient) Read added in v0.5.10

func (c *SocksClient) Read(buf []byte) (int, error)

Read reads data from the connection.

func (*SocksClient) ToBool added in v0.5.10

func (c *SocksClient) ToBool() *objects.Bool

ToBool returns true if connected.

func (*SocksClient) Type added in v0.5.10

func (c *SocksClient) Type() objects.ObjectType

Type returns the object type.

func (*SocksClient) TypeTag added in v0.5.10

func (c *SocksClient) TypeTag() objects.TypeTag

TypeTag returns the fast type tag.

func (*SocksClient) Write added in v0.5.10

func (c *SocksClient) Write(data []byte) (int, error)

Write writes data to the connection.

type SocksServer added in v0.5.10

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

SocksServer represents a SOCKS proxy server.

func NewSocksServer added in v0.5.10

func NewSocksServer() *SocksServer

NewSocksServer creates a new SOCKS server.

func (*SocksServer) GetPort added in v0.5.10

func (s *SocksServer) GetPort() int

GetPort returns the server port.

func (*SocksServer) HashKey added in v0.5.10

func (s *SocksServer) HashKey() objects.HashKey

HashKey returns a hash key.

func (*SocksServer) Inspect added in v0.5.10

func (s *SocksServer) Inspect() string

Inspect returns a string representation.

func (*SocksServer) IsRunning added in v0.5.10

func (s *SocksServer) IsRunning() bool

IsRunning returns whether the server is running.

func (*SocksServer) SetAuth added in v0.5.10

func (s *SocksServer) SetAuth(username, password string)

SetAuth sets username/password authentication (SOCKS5 only).

func (*SocksServer) SetSocks5 added in v0.5.10

func (s *SocksServer) SetSocks5(socks5 bool)

SetSocks5 sets whether to use SOCKS5.

func (*SocksServer) Start added in v0.5.10

func (s *SocksServer) Start(port int) error

Start starts the SOCKS server on the specified port.

func (*SocksServer) Stop added in v0.5.10

func (s *SocksServer) Stop() error

Stop stops the SOCKS server.

func (*SocksServer) ToBool added in v0.5.10

func (s *SocksServer) ToBool() *objects.Bool

ToBool returns true if running.

func (*SocksServer) Type added in v0.5.10

func (s *SocksServer) Type() objects.ObjectType

Type returns the object type.

func (*SocksServer) TypeTag added in v0.5.10

func (s *SocksServer) TypeTag() objects.TypeTag

TypeTag returns the fast type tag.

Jump to

Keyboard shortcuts

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