Skip to content

solod-dev/example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

So by example

A hands-on introduction to Solod (So) — a subset of Go that translates to C.

This repo contains small examples that show individual features, as well as larger apps that demonstrate how everything works together.

Examples

Language:

Hello worldValuesVariablesConstantsForIf/elseSwitchArraysSlicesMapsFunctionsMultiple returnsVariadic functionsFor-rangePointersStrings and runesStructsMethodsInterfacesEnumsErrorsPanicDefer

Standard library:

MemorySlicesMapsC interopStringsTimeRandom numbersNumber parsingReading filesWriting filesScanningFile pathsDirectoriesTemp filesCommand lineEnv variablesLogging

Apps

Coreutils: cat, cut, head, sort, uniq, wc

Count word frequencies by serge-hulne

Curl interop

FreeSWITCH module by seven1240

Key-value store with SQLite interop

Reverse lines in file

Running the code

To run a specific example locally, use the so run command. For example:

so run lang/05-for
so run apps/head -n 4 data/jenny.txt

You'll need to have a C compiler installed and available as cc, or you can set a custom compiler by using the CC environment variable.

To see the generated C code, use the so translate command. For example:

so translate -o lang/05-for/generated lang/05-for

Partially based on Go by Example by Mark McGranaghan, licensed under CC BY 3.0.

About

Solod by example

Resources

License

Stars

Watchers

Forks

Contributors