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

aliasGives a type a second name: the same type, which builds what it builds.
alignalign(N) struct keeps every value of the type at a multiple of N bytes, wherever it is kept.
asNames a value lent for a block: a shared value opened, a locked value taken, an item a select receives.
assertStops the program, or fails the test, when a condition is false.
asyncMakes a function a light task, which may await and never holds its thread.
atomicA number or a bool that tasks change without a lock, one step at a time.
awaitWaits for a task in an async function, without holding the thread, and gives what it returned.
breakLeaves the loop it is in, or the loop it names, at once.
checkedshared checked T: a shared value changed through any owner, each borrow of it checked while the program runs.
constA value fixed when the program is compiled.
continueEnds this round of the loop and goes on with the next.
elseThe block that runs when the condition of an if is false.
embedembed("logo.gif"): the bytes of a file beside the source, read when the program is compiled and kept in it.
enumDeclares a type whose value is one of several variants, each with values of its own.
exportMakes a function of SG that C calls by its name, or through a CFunc, a pointer to a function as C has it.
externDeclares the functions of a C library, or of a C file beside the program, to call inside unsafe.
forGoes over the numbers of a range or the items of a collection, one round for each.
ifRuns a block when a condition holds.
inStands between the name and the items in a for.
interfaceWhat a type can do; eight are built in and named after the colon, and a program cannot write its own yet.
isTests whether a value is one variant, or null, and names what it carries.
lockA short block that alone touches a locked value; it never waits, so locks cannot deadlock.
lockedshared locked T: a value that tasks reach only inside a lock.
matchChooses by the shape of a value; every case must be covered.
newPuts a value on the heap and gives the pointer that owns it.
notTurns the test of is around: x is not P, whose names are seen where the test failed.
orJoins patterns: the arm, or the is, fits when one of them does.
packedA struct with no padding between its fields and an alignment of 1, for a layout a file or a device gives.
publicShows a name to other modules; without it, a name stays inside its own module.
rawAn address of C, which owns nothing, may be null, and is not checked by the compiler.
readLends a value to be looked at, not changed.
readonlyMarks a field that is given when the value is built and never changed afterwards, nor anything behind it.
refLends a value to be changed in place; the only borrow of it while it lasts.
returnEnds the function, with its value.
shareMakes one more owner of a shared value, or an owner from a weak look.
sharedshared T: a value on the heap with several owners, only read.
staticA value made once, the first time the program uses it.
structDeclares a type made of named fields, with the methods that work on them.
testA block of checks written next to the code, which only sg test compiles and runs.
tryOpens a Result: its value, or the error handed to the caller.
unionA type whose fields all lie in the same bytes; it holds one of them at a time, read inside unsafe.
unsafeMarks code the checker cannot follow: raw memory, calls of C, the fields of a union.
useBrings the public names of a module into a file, to be written without the module in front.
varDeclares a variable; its type comes from its value.
weakweak T: a look at a shared value that does not keep it alive; share asks for an owner.
whenAdds a condition to an arm of a match, or makes a lock block wait until one holds.
whileRepeats a block as long as a condition holds.
withA copy of a struct with some fields changed: p with { x = 3 }.

Primitive types

booltrue or false; the only type a condition can be.
byteAn integer of 8 bits, 0 to 255: one byte of a text, a file or a buffer.
charOne character of Unicode, in 32 bits; not a number.
doubleA fraction of 64 bits (IEEE 754); its arithmetic is the hardware's and never panics.
floatA fraction of 32 bits (IEEE 754), about 7 digits; half the size of a double, for large arrays and for C.
intAn integer of 32 bits, with a sign; a whole number is one when nothing else is asked for.
longAn integer of 64 bits, with a sign; for sums, sizes of files and time in milliseconds.
nintAn integer with a sign, as wide as an address; every length, index and position is one.
nuintAn integer without a sign, as wide as an address; C's size_t, and an address as a number.
sbyteAn integer of 8 bits, with a sign, from -128 to 127: a small step, a reading, a signed byte of a file.
shortAn integer of 16 bits, with a sign, from -32 768 to 32 767: a sample of sound, a field of two bytes.
stringText in UTF-8 that owns its memory; read string is a borrow of it.
uintAn integer of 32 bits without a sign, 0 to 4 294 967 295: for bits, masks, colors and hashes.
ulongAn 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.
ushortAn integer of 16 bits without a sign, from 0 to 65 535: a port, a field of a packet, a counter that wraps.
voidThe return type of a function that gives nothing back.

Values with a name

falseThe bool that is not true; what a comparison gives when it does not hold, and the zero value of a bool.
nullNo value; only a type written T? may hold it, and it is tested with is null.
thisThe value a method was called on; read this looks, ref this changes, this alone takes it.
trueThe 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..bA range: the numbers from a up to b, without b; in a pattern, a..=b takes b too.
c ? a : bA 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 ?? yThe value of x, or y when x is null or an error.
x?.yA 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

Base64A type of the library, in Hex, Base64 and percent.
CancellationSourceA type of the library, in Tasks.
ChannelA type of the library, in Tasks.
ClockA type of the library, in Time.
CommandA type of the library, in Programs and the system.
DateErrorA type of the library, in Time.
DateTimeA type of the library, in Time.
DateTimeOffsetA type of the library, in Time.
DecodeErrorA type of the library, in Hex, Base64 and percent.
DirectoryA type of the library, in Files and folders.
DurationA type of the library, in Time.
EnvironmentA type of the library, in Programs and the system.
ExitStatusA type of the library, in Programs and the system.
HashMapA type of the library, in Collections.
HashSetA type of the library, in Collections.
HexA type of the library, in Hex, Base64 and percent.
HttpConnectionA type of the library, in HTTP.
HttpOptionsA type of the library, in HTTP.
HttpRequestA type of the library, in HTTP.
InstantA type of the library, in Time.
IoErrorA type of the library, in Files and folders.
ListA list of items that grows, kept in one block of memory.
PathA type of the library, in Files and folders.
PercentA type of the library, in Hex, Base64 and percent.
PipelineA type of the library, in Programs and the system.
ProcessA type of the library, in Programs and the system.
RandomA type of the library, in Random numbers.
SecureRandomA type of the library, in Random numbers.
SignalsA type of the library, in Programs and the system.
StdinA type of the library, in Files and folders.
StreamReaderA type of the library, in Files and folders.
StreamWriterA type of the library, in Files and folders.
TaskA type of the library, in Tasks.
TaskGroupA type of the library, in Tasks.

Modules of the library

CollectionsArrays, slices, List, HashMap and HashSet, with all their methods.
CompressionDeflate, 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-32Crc32, the checksum of gzip, PNG and ZIP, and Adler32, the checksum of zlib, at once or piece by piece.
Files and foldersFile, StreamReader and StreamWriter, the standard streams, Directory and watching a folder, Path, FileInfo and IoError.
Hex, Base64 and percentHex, Base64 and the percent-encoding of URLs, bytes written as text and read back, strictly.
HTTPHttpConnection, 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.
JSONJson, JsonValue and JsonObject, JSON read strictly into values, looked into, built, changed and written back.
LogLog 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.
NumbersThe integer and fractional types, their constants, conversions, arithmetic that cannot panic, bits, math and parsing.
Programs and the systemCommand, 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 numbersRandom, a fast generator that a seed sets, and SecureRandom, the random bytes of the system.
Regular expressionsRegex, 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 HMACSha256, Hmac.sha256 and Bytes.equalInConstantTime, the hash and the keyed tag of the standards.
TasksTask, TaskGroup, Channel and Sender, shared locked values, atomics and cancellation, with their signatures.
Textstring, read string and char, with every method they have.
The command lineCommandLine and Arguments, the flags, options and words a program takes, read the GNU way.
TimeDuration, Instant, DateTime and DateTimeOffset, and the clocks under them.
Zip archivesZipReader and ZipWriter, archives read and written as Go reads and writes them, checked for Zip Slip and bombs before anything is read.

Commands

sgRuns a program in the interpreter, from a file or a folder; the words after it are the program's own.
sg addAdds a package to sg.project and fetches it; with sg update, sg remove and sg lock, which keep sg.lock.
sg buildCompiles through C: a program, the program of its tests, a library C calls, or an object without an operating system.
sg emit-cPrints the C that sg build compiles, for reading, for a sanitizer, or for a build of your own.
sg helpPrints the page of a word, a sign or a command of SG in the terminal, from sg itself, with no network.
sg lspThe language server an editor starts: the first error as you type, and fixes applied with one click.
sg testRuns the tests of a file, or of every module in a folder, in the interpreter or compiled.