Console IO

Console input and output functions

input

Prompts for and reads user input from the console.

prompt string to display as a prompt

returns string containing the user's input

File Operations

File system operations and file manipulation

file-schema//Open

Opens a file for reading.

path uri representing the file to open

returns native file object

Open %data/file.txt |type?
; returns native
Open %data/file.txt |kind?
; returns file

file-schema//Open\append

Opens a file for appending.

path uri representing the file to open for appending

returns native writer object

Open\append %data/file.txt |type?
; returns native
Open\append %data/file.txt |kind?
; returns writer

file-schema//Create

Creates a new file.

path uri representing the file to create

returns native file object

Create %data/created.txt |type?
; returns native
Create %data/created.txt |kind?
; returns file

file-ext?

Gets the extension of a file.

path uri or string representing a file path

returns string containing the file extension (including the dot)

file-ext? %data/file.txt
; returns ".txt"
file-ext? %data/file.temp.png
; returns ".png"
file-ext? "data/file.temp.png"
; returns ".png"

reader

Creates a new reader from a file path, file object, or string.

source uri, file object, or string to read from

returns native reader object

reader %data/file.txt |kind?
; returns reader
reader Open %data/file.txt |kind?
; returns reader
reader "some string" |kind?
; returns reader

stdin

Gets a reader for standard input.

none

returns native reader object connected to standard input

stdout

Gets a writer for standard output.

none

returns native writer object connected to standard output

reader//Read\string

Reads all content from a reader as a string.

reader native reader object

returns string containing all content from the reader

reader "some string" |Read\string
; returns "some string"

reader//Copy

Copies all content from a reader to a writer.

reader native reader object

writer native writer object

returns the reader object if successful

file//Copy

Copies content from a file to a writer.

file native file object

writer native writer object

returns the file object if successful

file//Stat

Gets file information (stat) for a file.

file native file object

returns native file-info object

Stat Open %data/file.txt |kind?
; returns file-info

file-info//Size?

Gets the size of a file in bytes.

file-info native file-info object

returns integer representing the file size in bytes

Size? Stat Open %data/file.txt
; returns 16

file//Read-all

Reads the entire content of a file as a string.

file native file object

returns string containing the entire file content

Read-all Open %data/file.txt
; returns "hello text file
; "

file//Seek\end

Seeks to the end of a file.

file native file object

returns the same file object with position set to end of file

file//Close

Closes an open file.

file native file object

returns empty string if successful

Close Open %data/file.txt
; returns ""

file-schema//Read

Reads the entire content of a file as a string.

path uri representing the file to read

returns string containing the entire file content

Read %data/file.txt
; returns "hello text file
; "

file-schema//Read\bytes

Reads the entire content of a file as bytes.

path uri representing the file to read

returns native bytes object containing the file content

Read %data/file.txt
; returns "hello text file
; "

file-schema//Read\lines

Reads a file and returns its content as a block of lines.

path uri representing the file to read

returns block of strings, each representing a line from the file

Read %data/file.txt
; returns "hello text file
; "

file-schema//Write

Writes content to a file.

path uri representing the file to write to

content string or bytes to write to the file

returns the content that was written

Write %data/write.txt "written
"
; returns "written
; "

write\bytes

Writes bytes to a file.

bytes Go-bytes native value to write

path string path to the file to write

returns integer 1 if successful

append\bytes

Appends two byte arrays into one.

bytes1 first Go-bytes native value

bytes2 second Go-bytes native value

returns combined bytes as a native bytes object

writer//Write\string

Writes a string to a writer.

writer native writer object

content string to write

returns the writer object if successful

HTTPs Operations

Web requests and HTTP protocol functions

https-schema//Open

Opens a HTTPS GET request and returns a reader for the response body.

url uri representing the HTTPS URL to request

returns native reader object for the response body

https-schema//Get

Makes a HTTPS GET request and returns the response body as a string.

url uri representing the HTTPS URL to request

returns string containing the response body

https-schema//Post

Makes a HTTPS POST request and returns the response body as a string.

url uri representing the HTTPS URL to request

data string containing the request body

content-type word specifying the content type (e.g., 'json', 'text')

returns string containing the response body

http-schema//Get

Makes a HTTP GET request and returns the response body as a string.

url uri representing the HTTP URL to request

returns string containing the response body

http-schema//Post

Makes a HTTP POST request and returns the response body as a string.

url uri representing the HTTP URL to request

data string containing the request body

content-type word specifying the content type (e.g., 'json', 'text')

returns string containing the response body

https-schema//Request

Creates a new HTTPS request object.

url uri representing the HTTPS URL to request

method word specifying the HTTP method (e.g., 'GET', 'POST')

data string containing the request body

returns native https-request object

https-request//Header!

Sets a header on a HTTPS request.

request native https-request object

name word representing the header name

value string containing the header value

returns the request object if successful

https-request//Basic-auth!

Sets Basic Authentication on a HTTPS request.

request native https-request object

username string containing the username

password string containing the password

returns the request object if successful

https-request//Call

Executes a HTTPS request and returns the response.

request native https-request object

returns native https-response object

https-response//Reader

Gets a reader for the HTTPS response body that can be used with io.Copy.

response native https-response object

returns native reader object for the response body

https-response//Read-body

Reads the body of a HTTPS response as a string.

response native https-response object

returns string containing the response body

Email Operations

Email sending and SMTP communication

email//Send

Sends an email to the specified address.

to email address to send to

message string containing the email message

returns integer 1 if successful

FTP Operations

File Transfer Protocol operations and connections

ftp-schema//Open

Opens a connection to an FTP server.

server uri representing the FTP server to connect to

returns native ftp-connection object

ftp-connection//Login

Logs in to an FTP server connection.

connection native ftp-connection object

username string containing the username

password string containing the password

returns the connection object if successful

ftp-connection//Retrieve

Retrieves a file from an FTP server.

connection native ftp-connection object

path string containing the path of the file to retrieve

returns native reader object for the retrieved file

File Monitoring

File watching and tailing operations

tail-file

Tails a file, following it for new content. Used for monitoring log files.

path uri or string representing the file to tail

follow boolean indicating whether to follow the file for new content

reopen boolean indicating whether to reopen the file if it's rotated

returns native tail-file object that can be used to read lines as they are added

tail-file//Read-line

Reads the next line from a tailed file. Blocks until a line is available.

tail native tail-file object

returns string containing the next line from the file, or nil if no more lines

tail-file//Close

Closes a tailed file, stopping the monitoring.

tail native tail-file object

returns empty string if successful