Most of Go converts and behaves as it does in Go: slices, maps, pointers, closures, defer, interfaces,
generics, goroutines, channels and select, reflection, and the whole standard library, which is
validated against Go’s own tests. The tables below go feature by feature. Each note links to how the
feature maps to C#, to a working example from the behavioral test suite, or, for a feature with limits,
to the page that describes them.
Symbol
Meaning
Supported: converts and behaves as in Go.
Supported with limits: the note says which.
Not supported yet.
An example link opens a behavioral test: a Go program, its converted C#, and the output both must
print. Limitations and Known issues have the detail behind every
entry that is supported with limits or not supported yet.
Types and values
Feature
Status
Notes
Booleans, integers, floating point
int and uint are platform-width; integer overflow wraps and division by zero panics, as in Go. How · example
Complex numbers
complex64, complex128, real, imag; math/cmplx passes Go’s tests. Example
Strings and runes
UTF-8 bytes, as in Go: indexing reads bytes, range decodes runes. How · example
Constants, untyped constants, iota
Exact constant arithmetic, and Go’s literal spelling kept in the output. How · example
Arrays
Value semantics: assigning or passing an array copies it. How · example
Slices
Shared backing arrays, append growth, three-index slices, nil versus empty. How · example
Maps
Nil-map reads, comma-ok, delete, clear, randomized iteration order. How · example
Structs
Value types, == comparison, anonymous structs, and tags that reflect reads. How · example
Pointers
&x, new, pointers to fields, elements and pointers; a local whose address escapes moves to the heap. How · example
nil and zero values
Every type’s zero value, and a typed nil pointer inside an interface. How · example
Defined (named) types
Conversions and constant contexts as in Go. How · example
Type aliases
Including exported aliases used from another package. How
Shifts
Go’s rules, including the panic on a negative count. One rare form, an untyped-constant left shift typed by a named integer, wraps an oversized count (Limitations). Example
The address of another package’s variable
Real for a value-typed variable. For one whose type is a pointer or an interface it points at a copy (Known issues).
Functions and control flow
Feature
Status
Notes
Multiple results and comma-ok forms
Results become C# tuples, evaluated in Go’s order. How · example
Named results
Including results that a deferred closure reads and changes. Example
Function values and closures
Closures share captured variables, as in Go. How · example
append, copy, len, cap, make, new, delete, close, clear, min, max and the rest. How · example
Variadic functions
f(s...) works. A function that keeps, returns or captures its ...T parameter, or appends or copies into it, works on a private copy of the caller’s slice (Limitations). Example
panic and recover
Go panics and run-time errors (nil dereference, index out of range, divide by zero) recover as in Go. Other .NET exceptions run the deferred calls but recover() returns nil (Limitations). Example
Methods and interfaces
Feature
Status
Notes
Methods on any defined type
Receiver methods become C# extension methods. How · example
Pointer and value receivers
Go’s automatic & and * at the call site. How · example
Converted, except an alias whose target is an anonymous struct or interface (Limitations). Example
A pointer element under a self-referential constraint whose method returns a collection of the element
Walk[*Node] under Walk[N Tree[N]] with Children() []N is refused with GO2CS2002; the same code over a value element converts (Limitations). Two related pointer-element shapes are refused as GO2CS2005 and GO2CS2006 (diagnostic codes).
Go’s semantics, on real threads by default. Each live goroutine then holds an operating-system thread, so thousands at once are fine and hundreds of thousands are not; macOS and Linux each cap the count lower (Limitations, Known issues). How · example
Goroutine stacks
Stacks do not grow: each goroutine reserves a large fixed stack, and recursion past it ends the process (Tuning).
runtime.GOMAXPROCS
Read and set; with the default threads it does not limit parallelism: GOMAXPROCS(1) does not run goroutines one at a time (Limitations).
Deadlock detection
Go’s all goroutines are asleep report, with its goroutine blocks, appears only when every goroutine waits on a nil channel or an empty select {}; any other deadlock hangs (Limitations).
The race detector (-race)
Validation runs without it (Limitations); converted code has no race detector.
encoding/json and text/template pass Go’s tests on it; StructOf, MakeFunc and the rest. How · example
runtime.Caller, Callers, FuncForPC
Go file and line, read from the program’s debug symbols. Example · FuncForPC
Garbage collection
.NET’s collector. GOGC and GOMEMLIMIT are read and reported, but the collector does not follow them (Limitations).
Finalizers, runtime.AddCleanup, weak
Run on .NET object lifetime: an object may not be collectable until the function that dropped it returns. Example
unsafe.Pointer and uintptr
Work over plain data. A pointer to anything .NET’s collector tracks (a string, slice, map, interface or pointer inside) gets a stand-in number, so tricks such as a hand-built slice header do not convert. How · example
unsafe.Slice, unsafe.String and friends
Work, except that a slice of one number type laid over another’s storage is a copy (Limitations). Example
reflect under Native AOT
A type built at run time (StructOf) needs the JIT, and a few shapes no compiled code names are refused by name, as a panic recover can catch (FAQ). Example
Panic output and exit status
Go’s panic lines and exit status 2. The traceback is sometimes shorter than Go’s (Limitations). Example
Goroutine dumps (runtime.Stack for all goroutines)
Lists every goroutine and what it waits on, with frames for the calling goroutine only.
Profiling
Heap and allocation profiles and runtime/trace annotations work; a CPU profile has no samples, so profile with .NET’s tools. Example · trace
debug.ReadBuildInfo
The module, its dependencies and the main build settings; no compiler, build-mode or vcs.* settings. Example
Packages, build and tests
Feature
Status
Notes
Packages and imports
Each package becomes a namespace and its own assembly. How · example
internal packages
Converted like any package; the standard library’s are.
Modules and third-party dependencies
-recurse=nuget converts a module and everything it imports (walkthrough). Some dependencies need a build tag (Limitations).
Build tags, GOOS, GOARCH
Files are selected as Go selects them; one conversion targets one operating system. Example
glibc, validated here. Ubuntu’s own .NET package has a known issue.
darwin/amd64, darwin/arm64
Packages ship for both chips, and the standard library is validated on both (roster). On Apple silicon the standard library is the amd64 build (Known issues).
linux/arm64
glibc, validated here. A few standard-library members throw when called (Known issues). Platforms
windows/arm64
Builds with a warning and runs the Windows build, whose architecture-specific choices follow amd64; not validated. Platforms
The syscall package on Windows, Linux and macOS, including syscall.NewCallback on Windows. Example · callback
cgo: calling C functions
Under go2cs -cgo, a package that calls C library functions converts and compiles, and loads its C library at run time. C types, typedefs and constants arrive through a C pseudo-package. Structs pass by value or by pointer. C.CString, C.GoString, C.GoBytes, C.malloc, C.free, a void * into C memory, and defer C.f(…) convert. Measured on linux/amd64, darwin/amd64, darwin/arm64 and windows/amd64 (Roadmap).
Calling .NET from Go source
The road runs one way: Go source cannot name a .NET API (Limitations).
cgo: callbacks, C globals, unions, inline C
Function pointers and callbacks into Go, C global variables, unions by value, flexible array members, a pointer into Go memory handed to C (an array or slice element, or unsafe.Pointer(&x)), and C code written inline in the Go file. Each is refused by name (Roadmap).
Hand-written assembly (.s files)
Not translated: such a function converts to a stub that fails when called. Many libraries have a pure-Go build tag (Limitations). The standard library uses Go’s portable code and hand-written C# instead (how).
plugin
plugin.Open returns plugin: not implemented, as in a Go build without cgo.