The index
Every name in SG on one page: the words of the language, its types and signs, the types and modules of the library, and the commands.
A name in bold has a page of its own, from the simplest use to the hardest; the others say what they are in one line until theirs is written. Every name in a program on this site leads here or to its page.
- Keywords 48
- Primitive types 16
- Values with a name 4
- Signs 9
- Types of the library 34
- Modules of the library 18
- Commands 7
Keywords
alias | Gives a type a second name: the same type, which builds what it builds. |
align | align(N) struct keeps every value of the type at a multiple of N bytes, wherever it is kept. |
as | Names a value lent for a block: a shared value opened, a locked value taken, an item a select receives. |
assert | Stops the program, or fails the test, when a condition is false. |
async | Makes a function a light task, which may await and never holds its thread. |
atomic | A number or a bool that tasks change without a lock, one step at a time. |
await | Waits for a task in an async function, without holding the thread, and gives what it returned. |
break | Leaves the loop it is in, or the loop it names, at once. |
checked | shared checked T: a shared value changed through any owner, each borrow of it checked while the program runs. |
const | A value fixed when the program is compiled. |
continue | Ends this round of the loop and goes on with the next. |
else | The block that runs when the condition of an if is false. |
embed | embed("logo.gif"): the bytes of a file beside the source, read when the program is compiled and kept in it. |
enum | Declares a type whose value is one of several variants, each with values of its own. |
export | Makes a function of SG that C calls by its name, or through a CFunc, a pointer to a function as C has it. |
extern | Declares the functions of a C library, or of a C file beside the program, to call inside unsafe. |
for | Goes over the numbers of a range or the items of a collection, one round for each. |
if | Runs a block when a condition holds. |
in | Stands between the name and the items in a for. |
interface | What a type can do; eight are built in and named after the colon, and a program cannot write its own yet. |
is | Tests whether a value is one variant, or null, and names what it carries. |
lock | A short block that alone touches a locked value; it never waits, so locks cannot deadlock. |
locked | shared locked T: a value that tasks reach only inside a lock. |
match | Chooses by the shape of a value; every case must be covered. |
new | Puts a value on the heap and gives the pointer that owns it. |
not | Turns the test of is around: x is not P, whose names are seen where the test failed. |
or | Joins patterns: the arm, or the is, fits when one of them does. |
packed | A struct with no padding between its fields and an alignment of 1, for a layout a file or a device gives. |
public | Shows a name to other modules; without it, a name stays inside its own module. |
raw | An address of C, which owns nothing, may be null, and is not checked by the compiler. |
read | Lends a value to be looked at, not changed. |
readonly | Marks a field that is given when the value is built and never changed afterwards, nor anything behind it. |
ref | Lends a value to be changed in place; the only borrow of it while it lasts. |
return | Ends the function, with its value. |
share | Makes one more owner of a shared value, or an owner from a weak look. |
shared | shared T: a value on the heap with several owners, only read. |
static | A value made once, the first time the program uses it. |
struct | Declares a type made of named fields, with the methods that work on them. |
test | A block of checks written next to the code, which only sg test compiles and runs. |
try | Opens a Result: its value, or the error handed to the caller. |
union | A type whose fields all lie in the same bytes; it holds one of them at a time, read inside unsafe. |
unsafe | Marks code the checker cannot follow: raw memory, calls of C, the fields of a union. |
use | Brings the public names of a module into a file, to be written without the module in front. |
var | Declares a variable; its type comes from its value. |
weak | weak T: a look at a shared value that does not keep it alive; share asks for an owner. |
when | Adds a condition to an arm of a match, or makes a lock block wait until one holds. |
while | Repeats a block as long as a condition holds. |
with | A copy of a struct with some fields changed: p with { x = 3 }. |
Primitive types
bool | true or false; the only type a condition can be. |
byte | An integer of 8 bits, 0 to 255: one byte of a text, a file or a buffer. |
char | One character of Unicode, in 32 bits; not a number. |
double | A fraction of 64 bits (IEEE 754); its arithmetic is the hardware's and never panics. |
float | A fraction of 32 bits (IEEE 754), about 7 digits; half the size of a double, for large arrays and for C. |
int | An integer of 32 bits, with a sign; a whole number is one when nothing else is asked for. |
long | An integer of 64 bits, with a sign; for sums, sizes of files and time in milliseconds. |
nint | An integer with a sign, as wide as an address; every length, index and position is one. |
nuint | An integer without a sign, as wide as an address; C's size_t, and an address as a number. |
sbyte | An integer of 8 bits, with a sign, from -128 to 127: a small step, a reading, a signed byte of a file. |
short | An integer of 16 bits, with a sign, from -32 768 to 32 767: a sample of sound, a field of two bytes. |
string | Text in UTF-8 that owns its memory; read string is a borrow of it. |
uint | An integer of 32 bits without a sign, 0 to 4 294 967 295: for bits, masks, colors and hashes. |
ulong | An integer of 64 bits without a sign, 0 to 18 446 744 073 709 551 615: for hashes, random numbers and sets of 64 bits. |
ushort | An integer of 16 bits without a sign, from 0 to 65 535: a port, a field of a packet, a counter that wraps. |
void | The return type of a function that gives nothing back. |
Values with a name
false | The bool that is not true; what a comparison gives when it does not hold, and the zero value of a bool. |
null | No value; only a type written T? may hold it, and it is tested with is null. |
this | The value a method was called on; read this looks, ref this changes, this alone takes it. |
true | The bool that is not false; what a comparison gives when it holds. |
Signs
$"{x}" | Text with values written into it, checked when the program is compiled; .toString() makes it a string. |
a..b | A range: the numbers from a up to b, without b; in a pattern, a..=b takes b too. |
c ? a : b | A value picked by a condition: a when c is true, b when it is false; only that arm runs. |
T? | A T that may be null; it is tested before it is used as a T. |
T[] | A slice: a window onto items that something else owns. |
T* | A pointer that owns a value on the heap. |
x ?? y | The value of x, or y when x is null or an error. |
x?.y | A field or a method of x, or null when x is null. |
xs[^1] | An index counted from the end: xs[^1] is the last item, xs[^n] is xs[xs.length() - n]. |
Types of the library
Base64 | A type of the library, in Hex, Base64 and percent. |
CancellationSource | A type of the library, in Tasks. |
Channel | A type of the library, in Tasks. |
Clock | A type of the library, in Time. |
Command | A type of the library, in Programs and the system. |
DateError | A type of the library, in Time. |
DateTime | A type of the library, in Time. |
DateTimeOffset | A type of the library, in Time. |
DecodeError | A type of the library, in Hex, Base64 and percent. |
Directory | A type of the library, in Files and folders. |
Duration | A type of the library, in Time. |
Environment | A type of the library, in Programs and the system. |
ExitStatus | A type of the library, in Programs and the system. |
HashMap | A type of the library, in Collections. |
HashSet | A type of the library, in Collections. |
Hex | A type of the library, in Hex, Base64 and percent. |
HttpConnection | A type of the library, in HTTP. |
HttpOptions | A type of the library, in HTTP. |
HttpRequest | A type of the library, in HTTP. |
Instant | A type of the library, in Time. |
IoError | A type of the library, in Files and folders. |
List | A list of items that grows, kept in one block of memory. |
Path | A type of the library, in Files and folders. |
Percent | A type of the library, in Hex, Base64 and percent. |
Pipeline | A type of the library, in Programs and the system. |
Process | A type of the library, in Programs and the system. |
Random | A type of the library, in Random numbers. |
SecureRandom | A type of the library, in Random numbers. |
Signals | A type of the library, in Programs and the system. |
Stdin | A type of the library, in Files and folders. |
StreamReader | A type of the library, in Files and folders. |
StreamWriter | A type of the library, in Files and folders. |
Task | A type of the library, in Tasks. |
TaskGroup | A type of the library, in Tasks. |
Modules of the library
Collections | Arrays, slices, List, HashMap and HashSet, with all their methods. |
Compression | Deflate, Zlib and Gzip, both ways, at once or as a stream; zlib's bytes at every level, and a limit on what is opened. |
CRC-32 and Adler-32 | Crc32, the checksum of gzip, PNG and ZIP, and Adler32, the checksum of zlib, at once or piece by piece. |
Files and folders | File, StreamReader and StreamWriter, the standard streams, Directory and watching a folder, Path, FileInfo and IoError. |
Hex, Base64 and percent | Hex, Base64 and the percent-encoding of URLs, bytes written as text and read back, strictly. |
HTTP | HttpConnection, the server's side of HTTP/1.1, a request pulled and answered at a time, read where it lies, with the limits a server on the internet needs on from the start. |
JSON | Json, JsonValue and JsonObject, JSON read strictly into values, looked into, built, changed and written back. |
Log | Log and LogLevel, lines of a log written to the standard error, a level that is off costing almost nothing, and a message never read for anything in it. |
Numbers | The integer and fractional types, their constants, conversions, arithmetic that cannot panic, bits, math and parsing. |
Programs and the system | Command, Process, Pipeline and ExitStatus to run other programs, jobs and the terminal, a terminal of its own and a raw one, Environment, and Signals. |
Random numbers | Random, a fast generator that a seed sets, and SecureRandom, the random bytes of the system. |
Regular expressions | Regex, Match and Captures, patterns matched in a time that grows with the text and no more, and a pattern written in the program checked when it is compiled. |
SHA-256 and HMAC | Sha256, Hmac.sha256 and Bytes.equalInConstantTime, the hash and the keyed tag of the standards. |
Tasks | Task, TaskGroup, Channel and Sender, shared locked values, atomics and cancellation, with their signatures. |
Text | string, read string and char, with every method they have. |
The command line | CommandLine and Arguments, the flags, options and words a program takes, read the GNU way. |
Time | Duration, Instant, DateTime and DateTimeOffset, and the clocks under them. |
Zip archives | ZipReader and ZipWriter, archives read and written as Go reads and writes them, checked for Zip Slip and bombs before anything is read. |
Commands
sg | Runs a program in the interpreter, from a file or a folder; the words after it are the program's own. |
sg add | Adds a package to sg.project and fetches it; with sg update, sg remove and sg lock, which keep sg.lock. |
sg build | Compiles through C: a program, the program of its tests, a library C calls, or an object without an operating system. |
sg emit-c | Prints the C that sg build compiles, for reading, for a sanitizer, or for a build of your own. |
sg help | Prints the page of a word, a sign or a command of SG in the terminal, from sg itself, with no network. |
sg lsp | The language server an editor starts: the first error as you type, and fixes applied with one click. |
sg test | Runs the tests of a file, or of every module in a folder, in the interpreter or compiled. |

