Serdar Yegulalp
Senior Writer

SGo heads off Google Go crashes before they happen

news analysis
Apr 11, 20162 mins

An independently developed dialect of Google's Go language, SGo prevents certain kinds of application crashes at the compilation level

Both the defenders and detractors of Google’s Go language acknowledge its limitations. But according to conventional wisdom, they’re there for a reason, and if you want to do things differently, fork Go and make your own version.

Toni Cárdenas, a developer involved in several Go-related projects, is doing exactly that. He’s rolled out the first iteration of of SGo, a Go variant that prevents certain panics, aka application crashes, by catching them at compile time instead of runtime.

SGo doesn’t provide these features by forking the Go compiler or runtime. Instead, it’s more like a transpiler: It takes code written in SGo and generates a new Go program that adheres to SGo’s rules.

In Go, variables that are uninitialized are set to nil. Unfortunately, this means there are times when an application expects a value, receives a nil instead, and crashes because the condition wasn’t handled. The current version of Go doesn’t do compile-time checking to prevent those problems from seeping into running code.

SGo compiles to conventional Go source code, but along the way, it provides compile-time checks. If the SGo compiler encounters a pointer, interface, map, channel, or function that could be set to nil, it throws an error.

In situations where you need nil, SGo provides a syntax for “optional types” — a variable that can be either a stated type or nil. The flexibility of optional types is deliberately restricted by SGo — again, to prevent a nil-related crash.

Another SGo addition, “entangled optionals,” allows you to return with a function either an error or another set of values if the error is nil. This kind of multiple-return pattern for error handling is common for Go, so this feature, and many others in SGo, complement how Go already works.

Cárdenas claims these latter features “introduce absolutely no runtime costs.” However, as he documents, the final Go program built from SGo code also doesn’t know about SGo’s features.

Most criticisms of Go focus on the language’s lack of generics or its error handling. In the minds of Go’s creators, these are intentional design decisions, so the only way to address them would be to fork the language wholesale.

SGo’s ambitions are more modest. They’re aimed at catching problems that crop up in the language as it currently stands, but don’t require the major, breaking changes that a full-blown fork of Go would entail.

Serdar Yegulalp

Serdar Yegulalp is a senior writer at InfoWorld. A veteran technology journalist, Serdar has been writing about computers, operating systems, databases, programming, and other information technology topics for 30 years. Before joining InfoWorld in 2013, Serdar wrote for Windows Magazine, InformationWeek, Byte, and a slew of other publications. At InfoWorld, Serdar has covered software development, devops, containerization, machine learning, and artificial intelligence, winning several B2B journalism awards including a 2024 Neal Award and a 2025 Azbee Award for best instructional content and best how-to article, respectively. He currently focuses on software development tools and technologies and major programming languages including Python, Rust, Go, Zig, and Wasm. Tune into his weekly Dev with Serdar videos for programming tips and techniques and close looks at programming libraries and tools.

More from this author