Extended libraries provide Python-compatible functionality and require explicit registration by the host application.
Setup
import (
"github.com/paularlott/scriptling/extlibs"
)
// Register libraries as needed
p.RegisterLibrary("requests", extlibs.RequestsLibrary)
// Register os/pathlib with security restrictions
extlibs.RegisterOSLibrary(p, []string{"/tmp", "/data"})
extlibs.RegisterPathlibLibrary(p, []string{"/tmp", "/data"})
HTTP & Networking
| Library |
Description |
| requests |
HTTP library for sending requests |
| http |
HTTP client with advanced features |
System & Files
| Library |
Description |
| sys |
System-specific parameters |
| os |
Operating system interfaces |
| os.path |
Pathname manipulations |
| pathlib |
Object-oriented filesystem paths |
| glob |
Unix shell-style wildcards |
| subprocess |
Spawn and manage subprocesses |
Security
| Library |
Description |
| secrets |
Cryptographically strong random numbers |
Parsing & Logging
| Library |
Description |
| html.parser |
HTML/XHTML parser |
| logging |
Logging functionality |
| yaml |
YAML parsing and generation |
Utilities
| Library |
Description |
| wait_for |
Wait for resources to become available |
| kv |
Persistent key-value store |
Usage Example
import json
import requests
# HTTP request
response = requests.get("https://api.example.com/data", timeout=10)
if response.status_code == 200:
data = response.json()
print(data)