Solod – A Subset of Go That Translates to C

Solod (So) is a strict subset of Go that transpiles to C11 with zero runtime and manual memory management, bringing Go's syntax and safety to systems programming.
Solod (So) is a strict subset of Go that translates to regular C — with zero runtime, manual memory management, and source-level interop.
Highlights:
- Go in, C out. You write regular Go code and get readable C11 as output.
- Zero runtime. No garbage collection, no reference counting, no hidden allocations.
- Everything is stack-allocated by default. Heap is opt-in through the standard library.
- Native C interop. Call C from So and So from C — no CGO, no overhead.
- Go tooling works out of the box — syntax highlighting, LSP, linting and "go test".
So supports structs, methods, interfaces, slices, multiple returns, and defer. To keep things simple, there are no channels, goroutines, closures, or generics.
So is for systems programming in C, but with Go's syntax, type safety, and tooling.
Example • Installation and usage • Language tour • Stdlib • Playground • So by example • Testing • Benchmarks • Compatibility • Design principles • FAQ • Roadmap • Contributing
This Go code in a file main.go
:
package main
type Person struct {
Name string
Age int
Nums [3]int
}
func (p *Person) Sleep() int {
p.Age += 1
return p.Age
}
func main() {
p := Person{Name: "Alice", Age: 30}
p.Sleep()
println(p.Name, "is now", p.Age, "years old.")
p.Nums[0] = 42
println("1st lucky number is", p.Nums[0])
}
Translates to a header file main.h
:
#pragma once
#include "so/builtin/builtin.h"
typedef struct main_Person {
so_String Name;
so_int Age;
so_int Nums[3];
} main_Person;
so_int main_Person_Sleep(void* self);
Plus an implementation file main.c
:
#include "main.h"
so_int main_Person_Sleep(void* self) {
main_Person* p = (main_Person*)self;
p->Age += 1;
return p->Age;
}
int main(void) {
main_Person p = (main_Person){.Name = so_str("Alice"), .Age = 30};
main_Person_Sleep(&p);
so_println("%.*s %s %" PRId64 " %s", p.Name.len, p.Name.ptr, "is now", p.Age, "years old.");
p.Nums[0] = 42;
so_println("%s %" PRId64, "1st lucky number is", p.Nums[0]);
}
Check out more examples in So by example and learn about the supported language features in the language tour.
Install the So command line tool:
go install solod.dev/cmd/so@latest
Create a new Go project and add the Solod dependency to use the So standard library:
go mod init example
go get solod.dev@latest
Write regular Go code, but use So packages instead of the standard Go packages:
package main
import "solod.dev/so/math"
func main() {
ans := math.Sqrt(1764)
println("Hello, world! The answer is", int(ans))
}
Transpile to C:
so translate -o generated .
The translated C code will be saved in the generated directory.
You can also transpile to C and compile the code to a binary in one step. This uses the C compiler set by the CC environment variable:
so build -o main .
Or you can transpile, compile, and run without saving the binary:
so run .
All commands work with Go modules, not individual files (so run ., not so run main.go). Keep in mind that So is new, so it's still a bit rough around the edges.
So generates C11 code that relies on several GCC/Clang extensions: binary literals, statement expressions, constructor attributes, and alloca. Supported operating systems: Linux, macOS, and Windows (core language only).
Source: Hacker News












