Convert Go source code into C# that reads like Go and behaves the same. The converted Go standard library passes Go's own tests.
See the code
Browse all: Go Standard Library NuGet packages · Converted Go module NuGet packages
go2cs converts Go source code into C# that reads like the Go it came from and behaves the same.
A Go developer can read the converted code and follow it, and a .NET developer can use a Go library as
ordinary managed code. Go's slices, maps, channels, goroutines, defer, multiple returns, struct
embedding and interfaces come from a small runtime library and compile-time source generators, so that
machinery stays out of the converted files. Behavior comes first: a goroutine runs on its own thread
and is not rewritten into async. The converted Go standard library passes Go's own tests, package by
package, on Windows and Linux, and the same validation is in progress on macOS.
October 14, 2026, NuGet 1.24.13.7. With -comments, converted C# now carries Go's doc
comments and in-function comments where Go put them, and blank lines follow Go's in every conversion. An https request from a converted program works on macOS.
Two defects in fully trimmed Native AOT publishes are fixed, including the one that printed named
types raw. This is the last release built from Go 1.24; the next moves to Go 1.26.
Full announcement.
➡ All announcements can be found in the go2cs News Archive.
Given this Go:
type Person struct {
name string
age int32
}
func (p Person) IsAdult() bool {
return p.age >= 18
}
go2cs produces this C#:
partial struct Person {
internal @string name;
internal int32 age;
}
public static bool IsAdult(this Person p) {
return p.age >= 18;
}
The goal — reads like Go — is easiest to judge on real code. Below are converted standard-library files next to their original Go 1.24.13 source, in order of increasing richness:
| Package | Go 1.24.13 source | Converted C# | What it shows |
|---|---|---|---|
errors | errors.go | errors.cs | Error values and an unexported type satisfying the error interface. |
cmp | cmp.go | cmp.cs | Generics with an ordered-type constraint. |
unicode/utf8 | utf8.go | utf8.cs | Constants keeping Go's hex/binary literal formatting; arrays and structs. |
sort | search.go | search.cs | Binary search driven by a func(int) bool closure. |
strings | reader.go | reader.cs | A struct with receiver methods, tuple returns, and interface implementation. |
container/list | list.go | list.cs | A doubly-linked list — pointers and receiver methods. |
Browse the whole set under src/core.
go build. Go 1.24 is out of upstream support, so the converted standard library carries none
of the Go security fixes issued since; the Roadmap says which Go releases
come next.git and curl, and .NET's
native dependencies ICU and OpenSSL
(Microsoft's list).Clone the repository and install the converter from the clone. go install puts the go2cs binary in
GOBIN (or GOPATH/bin), which a standard Go setup already has on its PATH:
git clone https://github.com/ritchiecarroll/go2cs.git
cd go2cs/src/go2cs
go install .
Building go2cs from source has the rest: cross-compiling, running the tests and the layout of the repository.
go2cs [options] <input_dir> [output_dir]
go2cs -recurse=nuget module_dir out # a module and its dependencies; the standard library comes from NuGet
go2cs -recurse=module,nuget module_dir out # only the module's own packages
go2cs package_dir out # one package
go2cs example.go out/example.cs # one file
go2cs -platforms linux/amd64 -recurse=nuget module_dir out-linux # convert for another operating system
go2cs -tests -recurse -test-action all module_dir out # convert a module, run its tests, compare with go test
go2cs -version # which release this converter belongs to
Give the output directory when you convert a single file or package: without it, the C# is written beside the Go input.
| Option | What it does |
|---|---|
-recurse=nuget | Convert a module and its third-party dependencies, in dependency order. The standard library, the runtime and the source generators are NuGet package references, so nothing is staged on your machine. Start here. |
-recurse=module,nuget | Convert only the module's own packages, and reference the dependencies without converting them. Use it when a dependency does not convert yet; the solution builds once the dependencies are in place. |
-tests | Also convert the Go test suite. With -test-action all, build it, run it, and compare its results with go test. For a module it takes plain -recurse, not =nuget or =module. |
-platforms <os/arch> | The platform to convert for. It defaults to the machine you are on. |
-tags <list> | The build tags to select files with, as in go build -tags. |
-comments | Carry the Go comments into the C#. |
-version | Print the release this converter belongs to, and convert nothing. |
Command-line options lists every option and more examples.
Four steps take a Go program with third-party dependencies to a running .NET program:
GOTOOLCHAIN=local, so Go uses the release you installed, and
run go build ./... in your module. A dependency that needs a newer Go has to be pinned to an older
release first.go2cs -recurse=nuget . csharp writes the C# for your
packages and for every dependency under csharp/, and leaves the Go untouched.csharp/src/<import-path>, run
dotnet build on the .slnx file there, or open it in Visual Studio.dotnet run, from the same folder.Converting a real-world Go module does all four with a real program and shows the output. It also covers build tags, converting your own packages before their dependencies, building against a local copy of the standard library, and using modules that are already published as NuGet packages. Wondering which Go modules make good conversions? The go2cs Target Atlas ranks the most-depended-on ones.
More questions: versions, platforms, dependencies, C# to Go.

The whole Go standard library converts and compiles as .NET assemblies, and every package that can be validated matches its own Go test suite in C#, verdict for verdict, with every difference disclosed, on Windows and Linux. Validated Test Packages carries the current counts, package by package, and the Roadmap says where the project stands and what comes next.
You do not have to take the roster's word for it. One command converts a package's Go tests, runs them
in C#, runs go test, and compares the two:
Validate a converted test suite.
Start with CONTRIBUTING.md, then
Building go2cs from source and Architecture.md. There is plenty
of low-hanging fruit here; jump in if you'd like to help.
go2cs is a personal project, worked on in spare time. Issues, ideas and pull requests are welcome and are read, but replies are best-effort and can take a while. Questions belong in Discussions, and defects in Issues.
go2cs contains components under several licenses. The converter (src/go2cs) is
licensed under AGPL-3.0-only with the go2cs Converter Output Exception,
an additional permission under AGPL section 7. Alternative commercial licensing for
the converter is available from the copyright holder listed in
AUTHORS, at the contact
address given there. Original runtime/support libraries and Roslyn
generators use MIT. Standard-library packages, including project-owned
handwritten additions, use BSD-3-Clause, with upstream notices preserved.
Code generated by go2cs is not subject to the converter's AGPL license merely because it was produced by go2cs, and the output exception says so as a binding term: rights in output remain governed by the input source and any separately licensed components incorporated into or referenced by the output, and the project scaffolding the converter emits into your output is MIT. Running the converter, locally or in your own build, triggers no AGPL obligation; only distributing the converter, or offering a modified converter to others over a network, does.
Commercial licensing, sponsorship and acquisition. go2cs is developed by a single maintainer and will stay free for its users. A company that wants to ship the converter inside a proprietary product, offer it as a service without publishing its changes, or take on the project's long-term development is welcome to talk: a commercial license, sponsorship of ongoing work, or an outright acquisition that keeps the tool free for the community are all on the table. The contact address is in AUTHORS. Contributions to the converter carry a Developer Certificate of Origin sign-off and a relicensing grant, see CONTRIBUTING.md, which is what keeps those options open. The go2cs name and logo identify this project; a fork is welcome under the AGPL but should carry its own name.
See LICENSING.md for the component matrix, exceptions and output policy, and NOTICE for attribution.
2,034 followers · starred Feb 2020
74 followers · starred Feb 2021
708 followers · starred Aug 2023
239 followers · starred Apr 2021
Convert Go source code into C# that reads like Go and behaves the same. The converted Go standard library passes Go's own tests.
See the code
Browse all: Go Standard Library NuGet packages · Converted Go module NuGet packages
go2cs converts Go source code into C# that reads like the Go it came from and behaves the same.
A Go developer can read the converted code and follow it, and a .NET developer can use a Go library as
ordinary managed code. Go's slices, maps, channels, goroutines, defer, multiple returns, struct
embedding and interfaces come from a small runtime library and compile-time source generators, so that
machinery stays out of the converted files. Behavior comes first: a goroutine runs on its own thread
and is not rewritten into async. The converted Go standard library passes Go's own tests, package by
package, on Windows and Linux, and the same validation is in progress on macOS.
October 14, 2026, NuGet 1.24.13.7. With -comments, converted C# now carries Go's doc
comments and in-function comments where Go put them, and blank lines follow Go's in every conversion. An https request from a converted program works on macOS.
Two defects in fully trimmed Native AOT publishes are fixed, including the one that printed named
types raw. This is the last release built from Go 1.24; the next moves to Go 1.26.
Full announcement.
➡ All announcements can be found in the go2cs News Archive.
Given this Go:
type Person struct {
name string
age int32
}
func (p Person) IsAdult() bool {
return p.age >= 18
}
go2cs produces this C#:
partial struct Person {
internal @string name;
internal int32 age;
}
public static bool IsAdult(this Person p) {
return p.age >= 18;
}
The goal — reads like Go — is easiest to judge on real code. Below are converted standard-library files next to their original Go 1.24.13 source, in order of increasing richness:
| Package | Go 1.24.13 source | Converted C# | What it shows |
|---|---|---|---|
errors | errors.go | errors.cs | Error values and an unexported type satisfying the error interface. |
cmp | cmp.go | cmp.cs | Generics with an ordered-type constraint. |
unicode/utf8 | utf8.go | utf8.cs | Constants keeping Go's hex/binary literal formatting; arrays and structs. |
sort | search.go | search.cs | Binary search driven by a func(int) bool closure. |
strings | reader.go | reader.cs | A struct with receiver methods, tuple returns, and interface implementation. |
container/list | list.go | list.cs | A doubly-linked list — pointers and receiver methods. |
Browse the whole set under src/core.
go build. Go 1.24 is out of upstream support, so the converted standard library carries none
of the Go security fixes issued since; the Roadmap says which Go releases
come next.git and curl, and .NET's
native dependencies ICU and OpenSSL
(Microsoft's list).Clone the repository and install the converter from the clone. go install puts the go2cs binary in
GOBIN (or GOPATH/bin), which a standard Go setup already has on its PATH:
git clone https://github.com/ritchiecarroll/go2cs.git
cd go2cs/src/go2cs
go install .
Building go2cs from source has the rest: cross-compiling, running the tests and the layout of the repository.
go2cs [options] <input_dir> [output_dir]
go2cs -recurse=nuget module_dir out # a module and its dependencies; the standard library comes from NuGet
go2cs -recurse=module,nuget module_dir out # only the module's own packages
go2cs package_dir out # one package
go2cs example.go out/example.cs # one file
go2cs -platforms linux/amd64 -recurse=nuget module_dir out-linux # convert for another operating system
go2cs -tests -recurse -test-action all module_dir out # convert a module, run its tests, compare with go test
go2cs -version # which release this converter belongs to
Give the output directory when you convert a single file or package: without it, the C# is written beside the Go input.
| Option | What it does |
|---|---|
-recurse=nuget | Convert a module and its third-party dependencies, in dependency order. The standard library, the runtime and the source generators are NuGet package references, so nothing is staged on your machine. Start here. |
-recurse=module,nuget | Convert only the module's own packages, and reference the dependencies without converting them. Use it when a dependency does not convert yet; the solution builds once the dependencies are in place. |
-tests | Also convert the Go test suite. With -test-action all, build it, run it, and compare its results with go test. For a module it takes plain -recurse, not =nuget or =module. |
-platforms <os/arch> | The platform to convert for. It defaults to the machine you are on. |
-tags <list> | The build tags to select files with, as in go build -tags. |
-comments | Carry the Go comments into the C#. |
-version | Print the release this converter belongs to, and convert nothing. |
Command-line options lists every option and more examples.
Four steps take a Go program with third-party dependencies to a running .NET program:
GOTOOLCHAIN=local, so Go uses the release you installed, and
run go build ./... in your module. A dependency that needs a newer Go has to be pinned to an older
release first.go2cs -recurse=nuget . csharp writes the C# for your
packages and for every dependency under csharp/, and leaves the Go untouched.csharp/src/<import-path>, run
dotnet build on the .slnx file there, or open it in Visual Studio.dotnet run, from the same folder.Converting a real-world Go module does all four with a real program and shows the output. It also covers build tags, converting your own packages before their dependencies, building against a local copy of the standard library, and using modules that are already published as NuGet packages. Wondering which Go modules make good conversions? The go2cs Target Atlas ranks the most-depended-on ones.
More questions: versions, platforms, dependencies, C# to Go.

The whole Go standard library converts and compiles as .NET assemblies, and every package that can be validated matches its own Go test suite in C#, verdict for verdict, with every difference disclosed, on Windows and Linux. Validated Test Packages carries the current counts, package by package, and the Roadmap says where the project stands and what comes next.
You do not have to take the roster's word for it. One command converts a package's Go tests, runs them
in C#, runs go test, and compares the two:
Validate a converted test suite.
Start with CONTRIBUTING.md, then
Building go2cs from source and Architecture.md. There is plenty
of low-hanging fruit here; jump in if you'd like to help.
go2cs is a personal project, worked on in spare time. Issues, ideas and pull requests are welcome and are read, but replies are best-effort and can take a while. Questions belong in Discussions, and defects in Issues.
go2cs contains components under several licenses. The converter (src/go2cs) is
licensed under AGPL-3.0-only with the go2cs Converter Output Exception,
an additional permission under AGPL section 7. Alternative commercial licensing for
the converter is available from the copyright holder listed in
AUTHORS, at the contact
address given there. Original runtime/support libraries and Roslyn
generators use MIT. Standard-library packages, including project-owned
handwritten additions, use BSD-3-Clause, with upstream notices preserved.
Code generated by go2cs is not subject to the converter's AGPL license merely because it was produced by go2cs, and the output exception says so as a binding term: rights in output remain governed by the input source and any separately licensed components incorporated into or referenced by the output, and the project scaffolding the converter emits into your output is MIT. Running the converter, locally or in your own build, triggers no AGPL obligation; only distributing the converter, or offering a modified converter to others over a network, does.
Commercial licensing, sponsorship and acquisition. go2cs is developed by a single maintainer and will stay free for its users. A company that wants to ship the converter inside a proprietary product, offer it as a service without publishing its changes, or take on the project's long-term development is welcome to talk: a commercial license, sponsorship of ongoing work, or an outright acquisition that keeps the tool free for the community are all on the table. The contact address is in AUTHORS. Contributions to the converter carry a Developer Certificate of Origin sign-off and a relicensing grant, see CONTRIBUTING.md, which is what keeps those options open. The go2cs name and logo identify this project; a fork is welcome under the AGPL but should carry its own name.
See LICENSING.md for the component matrix, exceptions and output policy, and NOTICE for attribution.
2,034 followers · starred Feb 2020
74 followers · starred Feb 2021
708 followers · starred Aug 2023
239 followers · starred Apr 2021