go2cs 1.26.11.2: the full release notes

Full text of the December XX, 2026 announcement, condensed in the go2cs News Archive.
What changed
- A generic under a method-set constraint that is not
self-referential now converts within its own package. On every converted platform, a generic function or type
whose constraint lists methods, and whose signature puts the type parameter where go2cs’s constraint proxy cannot
carry it (a generic named type, or the type parameter in a result, a map, a channel or a pointer), takes a shape
witness: the type parameter stays the Go type, and its method calls go through a witness type that
package_info.csdeclares. Before, go2cs refused these withGO2CS2005. A site the witness cannot place yet, such as a constraint or type argument from another package, is refused withGO2CS2013, which names the site. See Diagnostic codes. - The converter stops where it would have left a marker in
its output. Some names are known only after a package’s records are final, so the converter writes a marker and
rewrites it afterwards. When that pass cannot finish a file, go2cs now stops with error
GO2CS2014, which names the file and line, where it warned and left a marker that does not compile. This applies on every converted platform. See Diagnostic codes. - Stack traces and
runtime.FuncForPCname functions as Go does. Every function literal now carries its Go name in a[GoFunc]attribute ([GoFunc("main.func1")] () => …, and(*runner).fork.func1for one inside a method), and a frame of a method body is named as Go names the method. A stack trace, a panic’s trace andruntime.FuncForPCprint those names, on every converted platform. %pprints the numberunsafe.Pointer(p)carries.fmt’s%p,reflect.Value’sPointerandUnsafePointer, and the orderfmtprints a map with pointer keys in, now read the same number asunsafe.Pointer(p), sofmt.Sprintf("%p", p) == fmt.Sprintf("%v", unsafe.Pointer(p))holds as in Go. A pointer to storage that holds no references reports its pinned address, and the pin lasts as long as the pointer’s box. A number read fromreflect.Value.UnsafeAddrand turned back into a pointer, including through the field’s underlying type, now names the field, where its first dereference panicked.go2cs -cgocombines with-recurse. A module’s cgo packages convert with the module; under-recurse=nuget -cgothey reference thego.*packages, for the machine’s own operating system and architecture. A cgo package whose C use go2cs refuses is skipped by name and the rest of the module converts (a single-package-cgorun still stops). A-cgoconversion can also target another operating system or architecture with-platformswhenCCnames that target’s C compiler (for examplezig cc -target <triple>). Such a module uses the standard library converted without cgo, sonetresolves host names with Go’s own resolver andos/userreads the user database files; a package that importsruntime/cgoorpluginis refused by name. Packing a cgo package for every platform is still to come. See Limitations.- More of C’s memory reads as Go’s under
-cgo. A pointer field of a C struct (l.next) is read and written at its Go offset in C memory, and*ppand*pp = v, whereppis a**C.T, load and store the C pointer itself. - A pointer word stored through
*unsafe.Pointeror into a func variable is kept.*pand*p = v, wherepis a*unsafe.Pointerthat names a word of C memory or of Go memory rebuilt from a number, read and write that word. Storing a func value’s word into a func variable throughunsafe.Pointernow sets the func, where the write was lost. A word that is not a func value’s word, or that names a closure nothing else holds, panics by name (Limitations). GOMAXPROCSfollows Go’s rule.runtime.NumCPUis the number of CPUs the operating system lets the process run on, and the startingGOMAXPROCSis theGOMAXPROCSenvironment variable or Go’s default for that count, on every converted platform; neither reads .NET’sDOTNET_PROCESSOR_COUNT.runtime.SetDefaultGOMAXPROCSnow works. On linux, the default is lowered to the cgroup’s CPU limit, as in Go. While the setting is not custom, it follows a change of the process’s CPU affinity or CPU limit at run time, as Go 1.25 and later do. A converted test suite’s-paralleldefaults toGOMAXPROCS.sync.RWMutexis Go’s own code. On every converted platform,sync.RWMutexis now the convertedrwmutex.go, Go’s five fields over the semaphore golib already provides, where it was a hand-written class around a managed monitor. A copy of aRWMutexis a separate lock, as in Go, andreflectsees its fields. golib’s semaphore now drops the state of a word nothing is waiting on, so a lock that once blocked no longer keeps its owner alive, and a waiter that asks to queue first (Go’slifo) is queued first.sync.Poolandatomic.CompareAndSwapPointerbehave as Go’s. Async.Poolages its caches at every garbage collection, as Go’s runtime does.atomic.CompareAndSwapPointercompares the pointers’ addresses: an old value that names the stored address through anotherunsafe.Pointerswaps, where it reportedtrueand swapped nothing, and a nil address panics as in Go.- A blank import’s comment says what happens to the package’s
init. On every converted platform, Go’simport _ "image/png"converts to the comment// import _ "image/png" (init forced in ImportInitializers). The other two endings arenothing to initializeand, for a test file’s blank import of the package under test,compiled into this assembly; no hook. - A defined func type is a delegate of its own.
On every converted platform, a Go func type declared with
type, such ascontext.CancelFuncorbufio.SplitFunc, is now a C# delegate named for it, whether or not it has methods; one without methods was written as its underlyingActionorFunc<…>delegate wherever it was used. So%T, reflect’sName()and a type switch now telltype F func(string) errorfromfunc(string) error, as Go does. Thirty exported types of the standard library change this way, among themcontext.CancelFuncandCancelCauseFunc,bufio.SplitFunc,io/fs.WalkDirFunc,path/filepath.WalkFunc,go/types.Qualifierandarchive/zip’sCompressorandDecompressor. Compiled C# code that passed or receivedActionorFunc<…>there must be rebuilt; C# source that assigns a lambda to one of these types compiles unchanged, and source that assigns anActionorFunc<…>value wraps it, as innew CancelFunc(action). See Every defined func type declares its own delegate. - Converting a module: two packages that spell one
anonymous struct now agree on its layout by themselves. When code such as ccgo’s output declares the same
anonymous struct in two packages (modernc.org/sqlite’s
TLARGE_INTEGERand modernc.org/libc’slargeInteger), ago2cs -recurserun now seeds the declaring import so that both packages hold the struct’s arrays the same way, and a value of it crosses between them by value. Before, this took-inline-arrays=<import path>#<TypeName>by hand, which still works; converting modernc.org/sqlite for Windows no longer needs it. This was measured on windows/amd64, linux/amd64, linux/arm64 and darwin/amd64. See-inline-arrays. - Converting a module: github.com/zeebo/xxh3 converts as is. Plain xxh3 v1.1.0 now converts with
go2cs -recurse, with noreplace, and computes the same hashes as Go on windows/amd64, linux/amd64, linux/arm64 and macOS on Intel and Apple silicon. Itsunsafeviews of a string’s or a slice’s bytes convert, and on arm64 its NEON assembly is forwarded to the package’s own Go functions. Thereplacethat the 1.26.11.1 notes describe still works but is no longer needed. See Limitations. - Faster reslicing, smaller Native AOT builds, faster start-up. Reslicing inlines again: a string-building benchmark that ran markedly slower on 1.26.11.1 than on 1.26.10.2 under the JIT and ReadyToRun is back at the 1.26.10.2 speed (measured on win-x64). golib’s pointer boxes keep their per-type tables in one shared holder, so a Native AOT publish of the converted TypeScript parser demo on win-x64 has fewer symbol names and a smaller image, and the AOT compiler needs less memory. A program with many types builds its method sets at start-up faster, measured on linux-x64.
- A converted program runs on a newer .NET when .NET 10 is missing. A
converted executable, Windows GUI program or test host that references the
go.*packages rolls forward to the newest installed .NET when no .NET 10 runtime is present, and a go2cs clone builds with a newer .NET SDK. The packages are validated on .NET 10; setRollForwardtoDisableorLatestMinorin your project to require it. ARollForwardthe project sets, or aruntimeconfig.template.json, takes precedence. - A conversion keeps its Go build cache apart from yours. The
go buildruns that read the Go compiler’s escape decisions for each converted package now use their own cache,go2cs/probe-cacheunder the user cache directory, or the directory named by-probe-cacheorGO2CS_PROBE_CACHE, not yourGOCACHE. The cache is reused across conversions and is safe to delete (Known issues). - The stack-append buffer is emitted only where it
is needed:
-stdliband-tests. Go 1.25 and later give the firstappendto a slice that does not escape a 32-byte buffer, which onlycap()can observe. go2cs 1.26.11.1 reproduced it in every conversion, at the cost of ago build -gcflags=-mper package and target. The new option-stack-append=on|off|autocontrols it; the default,auto, keeps it on for-stdliband-tests, whose converted tests compare against Go’s own, and turns it off for a plain or-recurseconversion, which then runs none of those builds and creates no probe cache. With it off,cap()after such anappendcan read lower than Go’s; pass-stack-append=onto reproduce Go’s (Known issues). - An experimental M:N scheduler, off by default. go2cs can run goroutines
on a small pool of threads, as Go does, instead of one operating-system thread each. The technique is async
twins: a second copy of each function that waits by giving its thread back to the scheduler. It is opt-in: a
program gets it only when its projects are built with twins, through the
GoTwinsForproperty that go.lib’s build files read, so it works for a program converted anywhere, and it runs withGO2CS_MN=1. Thego.*packages are built with their twins; a program that does not opt in never calls them and runs each goroutine on its own thread, as before, but a Native AOT publish of it compiles them all the same (Known issues). The diagnosticsGO2CS0014,GO2CS0015,GO2CS0017,GO2CS0018,GO2CS0019,GO2CS0020andGO2CS0021come only from a build with twins (Async twins, Known issues). - Fixes.
- A deferred call that writes through a slice, an element pointer or an
unsafeview of a named array result, taken beforereturn v, now changes the value the function returns, as in Go. A function literal’s named array result that escapes in a function with adeferhas its storage, where every index through it panicked. - A pointer parameter that a function literal assigns is read through its new target after
the assignment, where the function went on reading the old one, and it may hold nil and pass it on as in Go.
for _, n = range n.kidsinto a pointer parameter converts and repoints it. - A method promoted through an unexported embedded struct of another package, at
any depth, is called on the outer value, so it compiles (goldmark’s
ast.Link) and its writes are kept; a promoted call across another package’s embedded struct takes one step. - A generic type whose pointer-method type parameter gets its pointer from importers converts:
zap’s
zap.ObjectValuescompiles. A*Tstored as the parameter, and the parameter passed as the interface its constraint names, nil included, do as Go does, under Native AOT too. - A generic function written for its importers, whose pointer-method type parameter converts to
a non-empty interface (
inspector.Allin golang.org/x/tools), converts instead of being refused, and the interface holds the caller’s pointer, nil included, under Native AOT too. - A value of another package’s anonymous interface that embeds named interfaces takes that package’s type, and passes where each embedded interface is expected.
- A Go package named
extension, a C# 14 contextual keyword, converts and is imported under its own name. - Two methods or functions of another package that share a name and a parameter list, called with the same
string literals in one file, each reach their own callee: logr’s
Logger.Infobeside slog’s, andfmt.Printlnbesidelog.Println. The file did not build (CS9144), which kept logr’s examples from compiling. - A type defined over another package’s named map is a map, as in Go:
type headers otherpkg.Headeris ranged, indexed, assigned, deleted from and passed tolen, with comma-ok reads andmake. None of those forms compiled. - A struct whose unexported methods come from an
embedded interface asserts to another interface that asks for them, as in Go:
nv{worker}tonamer{ name() }, to an interface literal, through a type switch, and as*nvto either. The assertion read false. - A method a struct gets from an interface
embedded in one of its embedded structs is in the struct’s method set, as in Go:
outer{wrap}, wherewrapembedsifacelib.Hidden, asserts to ifacelib’staggerand tointerface{ Other() string }, and a directouter{...}.Other()compiles. The assertions read false and the call did not build. When the struct itself or a shallower embed supplies some of that interface’s methods, the others are still promoted (context’safterFuncCtxgetsDeadlinefrom itsContext). - A struct that embeds a defined func type converts, and the func type’s methods are
its own, as in Go: go-redis’s
Clientembedscmdable, andclient.Ping()through a*Clientcompiles. The embed is a nil func in the zero value, where its constructor did not build, and a func type of another package promotes its methods into the run-time method set that type assertions read. - A type defined over another package’s named slice is a slice, as in Go: x/text’s
type entrySort colltab.ContractTrieSettakeslen, indexing, slicing,range,makeandappend, so itssort.Interfacemethods compile. They did not (CS0315, CS0021), which kept x/text’s collate/build from building.
- A deferred call that writes through a slice, an element pointer or an
Converting and testing modules
- Modules whose tests use testify convert and match Go. github.com/stretchr/objx (v0.5.2 and v0.5.3), whose tests use testify, go.yaml.in/yaml/v3 v3.0.5 and github.com/pmezard/go-difflib v1.0.0 are validated: each converted test suite matches Go’s results (on linux/amd64), and objx’s runs convert the testify packages its tests import, with testify’s own dependencies. See Validated modules.
- A converted test assembly is compiled without optimization, so a line that test code
reads (
t.Logf, testify’s failure locations) matches Go, while the package under test stays optimized. Set-p:GoTestOptimize=trueto build it optimized, for a benchmark run. Optimized code elsewhere can still report an earlier line (Known issues). -testson a module. A module-cache release is converted and tested from a copy, so a run leaves the module cache unchanged, and a release that ships nogo.modconverts.-tests -recursefinds what a test file imports under the run’s build tags.-test-oracle-vet-offruns Go’s side without vet, for a package whose owngo testfails at vet before any test runs, and states each vet finding; it is refused for a package vet passes.-module-versionnames the version of a module copy, and the run, its record and its proof page say the version is claimed. See Command line.- A converted test project references what its extension-method
calls need. A test that calls a method which C# resolves among same-named extension methods needs every
assembly those candidates’ signatures name; a
-testsproject now references them, where a module’s converted tests could fail to compile for a missing reference. modernc.org/sqlite’s tests are the case: they now reachmath/biganddatabase/sql/driver. Standard-library test projects gain at most a reference or two (measured on windows/amd64, linux/amd64 and darwin/amd64). - Test comparison: the Go side builds a module that reaches
math/bigthrough a linkname. Thego testrun that a converted test suite is compared against now drops themath_big_pure_gotag everywhere except onmath/big’s own row, so a module that pullsmath/bigby linkname links. A module’s proof page now records the build tags of that Go run. Measured on windows/amd64, linux/amd64 and darwin/amd64:math/bigis the only standard-library row whose files change. - A module that imports golang.org/x/crypto or golang.org/x/net converts the same way every
run. The standard library carries its own copies of a few of those packages (
cryptobyte,chacha20poly1305,idnaamong them) under the same import paths. A-recurseconversion could take the module’s package for the standard library’s copy in some runs and not others, and then its build failed with CS0234. A module’s own package now always wins, so the converted tree is the same from run to run.
The go2cs tool
- A
-recurse=nugetconversion no longer reads an older local go2cs root. Such a conversion reads standard-library names only from the metadata built into go2cs, and says once when it finds a local go2cs standard library that it does not read. With go2cs 1.26.11.1 and earlier, it read~/go2cs(orGO2CSPATH, or-go2cspath) ahead of that metadata and could emit names the published packages lack (Known issues). - Each published go2cs binary names its commit.
go2cs -versionof a release archive reports the commit it was built from, unmodified; some 1.26.11.1 archives (linux-x64, osx-arm64) reportedvcs.modified=true. - The “converted by go2cs” badge shows on nuget.org. The badge a converted module’s README carries is now served from cdn.jsdelivr.net, a host nuget.org shows images from (Converting a module).
-
go2cs -helplists the ten options a first conversion needs.go2cs -help alllists every option, sorted into common, advanced and experimental, andgo2cs -help <option>explains one, for examplego2cs -help tests. Help prints to standard output and exits 0. A mistyped option names the nearest ones (there is no option -test-actoin. Did you mean -test-action?) instead of printing every option. Command line is written from the same table: its common options link to an option reference that explains every option. - A Native AOT publish in a
-recurse=nugetprogram’s folder no longer stops on its libraries. With current .NET 10 SDKs,dotnet publish -r <rid> -p:PublishAot=truerun in the program’s folder, wherego2cs -recurse=nugetwrites a solution, built each converted library without the runtime identifier and then stopped on it (The ResolvedILCompilerPack ItemGroup is required), although the program itself was published. The output root’s build file now keepsPublishAotoff for a converted library, as it already kept the library from being published on its own (Tuning).
Known issues
- Newly described: under Native AOT, code that often converts a function to a Go-defined func type is markedly slower. Native AOT builds of code that frequently converts functions to Go-defined func types (for example, an AST visitor passed to a walk on every node) run markedly slower in this release than in earlier ones, because each such conversion goes through reflection; JIT builds are unaffected, and the next release fixes it (Known issues, tracked in issue #43).
- Newly described: the standard library’s async twins make a Native AOT executable larger. The
go.*packages carry their twins from this release, and a Native AOT publish compiles them whether or not the program opts in (Known issues). - Fixed: under Native AOT, a type assertion to
errorthat the method set decides answers as Go’s does. With the go.* 1.26.11.1 packages, a Native AOT executable could answerok == falseforp.(error)on a value whose method set hasError() string. golib’serrornow declares a run-time shell that holds any value, so Native AOT has code for it (Known issues). - Newly described: in optimized code,
runtime.Callercan report an earlier line of the calling function. A program reports Go’s lines in aDebugbuild, or at a large cost with the JIT settings the entry names; converted tests are not affected (Known issues).
Documentation
- A page answers Did AI write this?, with an FAQ entry and a link from the README and the milestones table.
- Known issues reads the Native AOT cost again on the published packages
(linux-x64), and says what to do when a
nugetgopackage built on 1.26.10.3 meets the 1.26.11.1 packages at restore (NU1107). The go2cs tool says that it downloads Go on first use. The FAQ says which parts of cgo convert. <!– 2026-11-23 (P1): dropped, as the draft said to once the fix shipped (it landed, 6379495c3b): “- Known issues names the stale local go2cs root that a-recurse=nugetconversion reads (see the known issue above; drop both bullets together if the fix ships). <!- - Batch 319, P4 a0d69468d4.- ->” The known-issue bullet itself stays, rewritten as the fix, under The go2cs tool. –>
Upgrading from an earlier release
- A Go variadic parameter is
go.variadic<T>, and the break floor is 1.26.11.2. A Go function’s variadic parameter converts to golib’svariadic<T>pack, where it was aSystem.Span<T>. A spread callf(s...)now hands the callee the caller’s slice, as Go does, so the callee’s writes to its elements are kept; they were lost when the parameter moved to the heap. Every package whose public methods take a variadic parameter changes its signatures, so an assembly built against an earlier release must be rebuilt, and the build stops one that is not with errorGO2CS3002, which names the package. C# source that passes the values one by one, or aSpan<T>, compiles unchanged. for rangeover an iterator function is a direct call.for v := range seqconverts to a call ofseqwith the loop body as itsyieldfunction, as Go’s compiler lowers it. One public signature changes:net/http/httptest’sResponseRecorder.Resultloses itsrefform. Rebuild an assembly built against it.- The zero value of a type parameter whose type argument is an unnamed array panics by name. In a generic type’s
method, or in a struct that holds the type parameter by value,
var z TwithTinstantiated as[4]intbuilt a length-0 array without a word; it now panics, and warningGO2CS2019names each instantiation site the compiler can see. See Known issues. - Warning
GO2CS0022for C# that reaches into a Gointernalpackage. A converted Gointernalor vendored package’s assembly records the root that may use it, and hand-written C# outside that root that names one of its types gets the warning, where Go would refuse the import. - golib’s internal helpers are called as
builtin.<name>. Converted code calls golib’s internal helpers through thebuiltinclass, so a Go declaration of the same name (a package functiontmpstring, a locallen) cannot capture them;m[tmpstring(b)]called the program’s owntmpstring. Converted output changes where it calls them. - An unnamed array literal now reads
array<nint>([1, 2, 3]). On every converted platform, a Go array literal of an unnamed array type converts to a call of golib’sarray<T>(…)over a C# collection expression, where it wasnew nint[]{1, 2, 3}.array(). C# source written by hand outside namespacegothat hasusing static go.builtinand reaches a static member of golib’s array or slice type, such asarray<T>.Alias, now fails to compile with CS0119, because the builtin functionsarray<T>(…)andslice<T>(…)are found first. Writego.array<T>.Aliasandgo.slice<T>instead. See Public surface. - Package
mainkeeps its methods in the package class. On every converted platform, a method of a type declared in packagemainis now a member ofmain_package, beside the package’s functions, as the Go file reads; it was a member of a separate holder class,mainᴛ<Type>. A type ofmainkeeps its holder only where one of its methods has the name of something the package reads bare (a package-level name, a universe name such aslen, an import’s name, or a member of golib’sbuiltinclass), which the method would otherwise hide. Library packages keep their holders. C# source written by hand against a converted program that namesmainᴛ<Type>namesmain_packageinstead. - A library method’s body is now a static method of the package class. On every
converted platform, the body of a Go method in a library package is written as Go wrote it, in the package class,
named with a
⁔after the Go name (Add⁔), its receiver the first parameter. The method with the Go name, in the receiver type’s method holder (timeᴛTime), is a one-line forwarder to it thatpackage_info.csdeclares, so calls, interfaces and method sets read as before and a stack trace shows one frame, named as Go names the method (time.Time.Month). The forwarders keep the methods’ names, access and signatures, so C# source that calls a Go method compiles unchanged; the⁔body is internal and is not for hand-written code to call. A type ofmainthat keeps its holder (above) takes the same form. - A Go method on a named slice or array type takes the
generated wrapper member of the same name. A Go method named
Slice,Append,ToSpan,GetEnumerator,Length,Source,Capacity,Low,High,Available,IsNil,MakeorWrapon a named slice or array type (or on a type defined over a named array) now runs when Go code calls it; before, the wrapper’s own member of that name could run instead, silently when the call fit its parameters. The wrapper member stays reachable through its golib interface, e.g.((ISlice)s).Capacity; an array’sSlice, which no interface declares, becomesΔSlice. A type named like one of those members now converts as well. C# source written by hand that called such a member on such a type calls it through the interface instead. - The same holds for named channel, map, numeric,
string and pointer types. A Go method named
Capacity,Length,IsClosed,IsUnbuffered,Receive,Received,Receiving,Sending,MakeorGetEnumeratoron a named channel;Length,IsNil,Count,MakeorGetEnumeratoron a named map;CompareToon a named number; orLength,CompareToorGetEnumeratoron a named string now runs when Go code calls it, and the type still ranges, selects, sorts and measures as Go’s does. A type named like one of its own wrapper’s members converts as well, a named pointer type included:type Value *[3]int,type of *point. The member stays reachable through its golib interface where one declares it, e.g.((IChannel)ch).Capacity, and becomesΔ<name>otherwise (ΔIsClosed); a pointer type namedValuereads its pointee throughValue‿. With-uco=false, a channel whose type declares one of those methods is sent to and received from with the default mode’s operators. Slicing a named pointer to an unnamed array (type P *[3]int,p[1:]) also converts now. C# source written by hand that called such a member on such a type calls it through the interface instead. - A defined type over a struct with a field named
Valueconverts.type Gt Eq, whereEqhas a fieldValue(gorm’sclausepackage), declaredValuetwice. The wrapper forwards the field asValue, as Go selects it, and its own accessor for the underlying struct is nowValue‿. C# source written by hand that read such a wrapper’s underlying struct through.Valuereads.Value‿, or converts it:Eq e = gt;. - golib’s
GoFrameis a plain struct, not aref struct.GoFrameholds the deferred calls of one call of a converted function. The C# compiler no longer refuses a copy, a store, boxing or a capture of it; the source generator does, with errorGO2CS0016, which names the site. A frame may only be a local initialized todefault, arefparameter or argument, or the receiver of its own members. The rule also runs whereRunAnalyzersisfalse, and cannot be turned off. WithRunAnalyzersset tofalse, one part is not checked: a use that binds only with code another source generator writes, such as adefer(…, ref ᒐ)whose lambda names a generated member, because the analyzer that checks those uses does not run. F# and Visual Basic get no check. Hand-written C# that follows the converteddeferpattern keeps the frame a local of its function and passes it only byref. See Public surface and Diagnostic codes. - A Go name spelled with a letter go2cs uses in generated
names refuses its package. A package that declares an identifier spelled with one of those letters (
Ꮡ,ᴛ,жand the others), or aΔname equal to one go2cs generates in that package, stops with errorGO2CS2015, which names each identifier: such a name could bind silently to a generated one. Every otherΔname converts, and a struct field, method or type whose name starts withΔkeeps its Go name in reflection, encoding andfmtoutput. Rename a refused identifier (Diagnostic codes). - One C# type for each anonymous Go type in a package. A Go struct or interface type
written without a name now becomes one C# type in each package, which every site that spells it uses, so some
generated names a hand-written C# file could have named (
Box_T,pair_T) are gone. Those names were never a promise: Public surface now lists them as names that can change in any release. Name the declared Go type instead. - A Go type named
recordis spelledΔrecord. At the start of a C# member,recordbegins a record declaration, so a Go type declared with that name now takes theΔprefix, like other names C# reserves. In the converted standard library this renamesnet/http/fcgi’srecordtype, and its method holderfcgiᴛrecordbecomesfcgiᴛΔrecord. C# source written by hand that names the old spelling names the new one. See Shadowing. - On Apple silicon the packages carry the
arm64standard library. Theosx-arm64assets of every package that differs by platform are now thedarwin/arm64build, where they were thedarwin/amd64build thatosx-x64also carries. On an Apple-silicon Mac,internal/goarchreportsarm64and Go’s_arm64.gofiles are in the packages, asruntime.GOARCHalready reported. Go declares 24 ofsyscall’sdarwin/amd64constants for no other Mac, among themF_MARKDEPENDENCY,SYS_PROFILand theSIOC…andSO_RESTRICT…sets, so they are gone from theosx-arm64asset, as they are from Go on that Mac. An assembly built forosx-arm64against an earlier package that reads one of them fails withMissingMethodException. Take everygo.*package from this release or later; go2cs’s build check stops a build that mixes them. - A converted package built by an older
go2cs needs a rebuild to convert into a named number through a type parameter. golib now converts
T(x),uint64(v),float64(v)andfloat32(v)into or out of a named numeric type argument (type small uint8) through members the go2cs analyzer gives that type, where it used reflection. A package built by an earlier go2cs has no such members, so the conversion throwsNotSupportedException(“no numeric wrapper surface”); the release’s break floor already refuses to build against such a package (GO2CS3002). Rebuild it with this release. @new<T>()of a struct you wrote in C# holds itsdefault. golib builds Go’snew(T)without reflection now, so a converted package trims cleanly. A converted struct is still constructed as before. A hand-written C# struct is not: its parameterless constructor and field initializers no longer run under@new<T>(). Box a constructed one withᏑ(new MyStruct()).- A package built against
1.26.11.1 that takes the address of a
text/template.Templatefield it reaches through the embedded*parse.Treeneeds a rebuild.Template’s promoted field accessorsᏑName,ᏑParseName,ᏑRootandᏑModenow return the field’s pointer,ж<T>, taken once through the embedded*parse.Tree, where they returned aref. In Go,p := &t.Rootkeeps pointing at the treetheld when the address was taken, even aftert.Parsereplaces that tree; therefform followed the new tree. A package built against the earlier accessors fails withMissingMethodExceptionwhen it takes such an address. Rebuild it with this release. - A type written over another package’s named string or number wraps the
basic type.
type X pkg.N, whereNis a named string, integer, float or bool, converts to a wrapper ofN’s basic type, as a type over a same-package name already did, sostring(x),int64(x), arithmetic and fmt behave as Go’s do. In the standard library this changes only the internal packageinternal/syscall/windows/registry: itsKeywrapsuintptr, notsyscall.Handle, and loses its constructor,Valueand implicit conversions overHandle. No Go code outside the standard library can import that package, so no action is needed. See Named numeric types.
Every change since 1.26.11.1, merge by merge
The announcement groups the changes by what a Go developer would notice. This section lists each one, under the same groups, with the merge on the master branch that brought it. The sections above carry the full text of the changes the announcement names.
Package initialization
| Merge | Change |
|---|---|
| 884cffe787 | A package outside the standard library initializes as Go does: package main’s entry point initializes every package of the program in Go’s order before main, where 1.26.11.1 initialized a package when .NET first touched it. Init frames are named main.init.0 and so on, as Go names them. |
| 9227361baa | A package variable whose initializer starts a goroutine, directly or by handing a function to another package or to a standard-library function that runs it on a goroutine, and waits for it, no longer hangs. |
Deadlocks and Go’s fatal errors
| Merge | Change |
|---|---|
| 343c922b00 | When every goroutine is blocked on a channel, select, sync.WaitGroup, sync.Cond or sync.RWMutex, the program prints fatal error: all goroutines are asleep - deadlock! with its goroutines and exits 2, where it hung. GO2CS_DEADLOCK=0 turns the check off. |
| 7bc52c8373 | Concurrent map writes end with Go’s fatal error: concurrent map writes; an unrecovered panic of a struct, pointer, slice, map, array or channel prints Go’s (T) 0x…; a panic value whose Error or String panics prints Go’s fatal error; array == follows Go (a NaN element is unequal; an uncomparable interface element panics); a map key holding an unhashable value panics with Go’s message. |
| 0a7d4ed97e | A sync.WaitGroup reused before the previous Wait returned panics with Go’s message, where it slept through. |
Silent wrong results, now Go’s
| Merge | Change |
|---|---|
| 6399fea4b1 | An array, or a struct holding one, is copied at every site Go copies it: a type assertion, a for-clause variable’s per-iteration copy, an explicit interface conversion, a deferred or spawned receiver. Several shared storage. |
| 61df87eb64 | In generic code instantiated with an array, binding, storing, sending, ranging over or returning a T copies the array, where it shared the caller’s. |
| b66bcf50cf | Slicing a value whose type parameter has an array core shares the array’s storage, as Go does. |
| 1771cb83a8 | A keyed struct literal that leaves out an embedded struct holding an array builds the embed at Go’s zero value. |
| 7f7bc336c3 | unique.Make over an unnamed array type argument gets a descriptor of the right size. |
| 8ae0d5d146 | The address of a field whose path crosses a pointer (&r.e.f through an embedded *E, &m[k].f.g, &p.q.f) is the real field’s; writes through it, and pointer methods called through the chain, were lost on a copy. |
| e3163c185d | &(*r).c and the value-field chains of a named pointer type (type PS *St) address the real field, and a field promoted through an embedded pointer to another package’s struct is addressed through that pointer once, as in Go. |
| 30b190a358 | An immediately invoked function literal given the enclosing function’s pointer parameter or receiver receives the pointer; an interface parameter there held the struct value. |
| b584a43382 | A nil value of a named pointer type stored in an any is Go’s typed nil. |
| a6947b36fe | A call whose results spread into interface parameters converts each result as a direct argument does: a nil *T spread into any is no longer Go’s nil interface. |
| 39599814ac | In generic code with an erased pointer type parameter, a P value converted to an interface holds the pointer. |
| 6de84c454b | An untyped constant shifted by a variable count into a named integer type gives Go’s result. |
| 006feaabc4 | A named untyped integer constant above MaxInt64 computes arithmetic, bit operations and shifts on Go’s value. |
| 85690ecb86 | A float constant expression evaluates to Go’s exact value; an untyped complex constant prints as Go prints it; complex128 division follows Go’s algorithm. |
| 5413fa5be4 | A named untyped float constant converted to float32 rounds once, as Go does; two imported packages with the same name, in different files of one package, bind the right package. |
| dd71b563dd | An untyped constant expression typed as a type parameter whose set holds floats, or ints and floats, is folded exactly, where C# integer arithmetic could overflow. |
| 51dfd72b8f | A file whose Go version is before go1.22 gets one loop variable per loop, as that Go did; in a go1.22 file a loop variable written after a closure captured it, in the same iteration, is the closure’s too. |
| f91b32e4c7 | A captured for-clause loop variable that the body changes through a pointer method or a field is copied back. |
| 74782d1fa5, e806c6fa90 | A shadowed variable used as an assignment target in a select receive, a range assignment, a parenthesized target or through a slice expression binds the inner variable, where it bound the outer one. |
| 19bfc20cb9 | var a, b T = pair() assigns both results. |
| 9afa29f4c0, bb31450268, 5ae4731ec9 | A closure, deferred or spawned call of a pointer method deep in a captured struct, or on a parenthesized operand, works on the variable, not on a copy. |
| 5829e77d01, b8e4447714 | A go or defer whose callee is a variable, a field, an element, a map entry, a dereference or a call reads the function at the statement, as Go does. |
| 7bdefdd720 | f(xs...) hands the callee the caller’s slice, so cap in the callee is Go’s. |
| 4a56f17a3a | Another package’s unexported interface method met through a struct embed is refused by name, GO2CS2016, where a call could reach the wrong method. |
Go’s order of evaluation
| Merge | Change |
|---|---|
| 6ac2b1d71f | Where a call in a statement can change a variable read to its left, the statement’s calls run first and the plain operands are read after them, as Go’s compiler does. |
| 10de31bba7 | A call whose results spread into another call runs in Go’s order: calls written to its left first, inside && and || only when reached; it now converts in switch tags, type-switch guards and go and defer arguments. |
| 56dfefdb8b | A method value is evaluated in Go’s order with the calls around it, and a deferred or spawned promoted method copies its receiver’s arrays. |
Generic code
| Merge | Change |
|---|---|
| bcc8d85081 | The pointer-method constraint idiom (func F[T any, PT interface{ *T; M() }]) converts and runs; four uses are refused by name. |
| dc23d64667 | Constraints built from named terms (interface{ Integer | Float }) are read through those terms; numeric conversions into named numeric types compile; GO2CS2018 refuses a constant compared with a complex-admitting type parameter, which would have answered false. |
| d736e32520, e278c8ca71 | A ~string constraint, also beside a method, compiles and runs; min and max of three or more values compile. |
| a92536875c | A type parameter constrained to a channel type converts: send, receive, close, range, len, cap, make and nil comparison. |
| e24bf2bb49 | A union constraint holding bool compiles. |
| 3036fb7bb4 | A constraint mixing type terms and methods compiles. |
| fcd7945088 | A type-parameter value converted to an interface its constraint does not embed compiles and works. |
| dc8e5a33b1 | A type assertion to an instantiated generic interface answers by method set, also under Native AOT. |
| 4f1c748952 | case T: in a type switch matches by method set; T.String method expressions and float conversions of numeric type parameters compile. |
| f22961960c | The zero value of a type parameter whose type argument is an unnamed array panics by name where it built a length-0 array, and GO2CS2019 warns at the instantiation site; named array results and maps.Equal over arrays work. |
| e9cad4647a, 2183bd9392, 0680af45b6, 354ce40c3f, c34bf7ae9f, 5635e9eb20 | A named constraint over another type parameter, a generic pointer type implementing a generic interface twice, a generic struct embedding an interface it satisfies, generic structs embedded two levels down, a slice bound of an integer type parameter, and a local reusing a type parameter’s name compile. |
Code that failed to compile
| Merge | Change |
|---|---|
| 500ee417d5, 56c2222534 | &p of a pointer parameter or receiver, any(p), interface{}(p) and PP(p) compile; a pointer method on a named func type compiles. |
| 4129024a67 | The address of an array element reached through a slice element, a pointer or a boxed variable compiles. |
| f57d44637f | A method value taken in a function literal, with its receiver through a pointer, compiles. |
| 3c98da4150, 5f116351bf | Func-valued tuple results, and func results spread into parameters of another func type, compile. |
| 0b6295683d, b41f41814c, 027815b1d0 | A struct value-embedding another package’s struct converted to an interface through a pointer, an interface promoted through an alias, and a defined type over a named interface compile. |
| 8ece076f79, 3cedb5e773 | A defined string type compared with an untyped string constant, and a named untyped constant given to a defined float type, compile. |
| beb10acc62 | A pointer type written through an alias is read as a pointer everywhere. |
| b0bd159e8f, 95d1f4b605 | break L out of a labeled select, and f(nil...), compile. |
| 3f127a36b7, 8625f3cd13, 6d0ca4a2c7, 08438e2244, f3fd95b5fa | Type switches: a binding whose address is taken, a lone case nil: arm, array labels of different lengths, constant labels under an interface tag, and a method value beside a named func type convert as Go reads them. |
| f8b40575c3 | Converted code no longer raises C# warnings CS0649, CS8778 or CS0108. |
Code that reads closer to Go
| Merge | Change |
|---|---|
| 29aa53015f | A function with defer opens its frame on the signature line, and each lowered defer carries the Go statement as a comment. |
| e35b87f835 | var c, python, java bool is one C# declaration. |
| fb2526882a, 356c633636 | for v := range seq over an iterator function is a direct call of the iterator with the loop body as its yield, as Go’s compiler lowers it, where it ran the iterator on a second stack; a loop body that defers, parks, recovers or leaves by a non-local jump keeps the earlier form. |
| 8d1c616466 | golib’s internal helpers are called as builtin.<name>, so a Go declaration with the same name (tmpstring, len) cannot capture the converter’s own call. |
cgo
| Merge | Change |
|---|---|
| 299d32d798 | C functions and variables a cgo preamble defines are compiled into a side-built library and called. A package’s #cgo flags are held to the go command’s allowed list, and on Windows the side library loads none of its dependents from the current directory. |
| ca3af91e62 | A package’s own .c and .s files are compiled; warning GO2CS2017 names the files the go command links and the conversion does not. |
| f72cb41c75 | On Windows, a bound C library’s dependents are never loaded from the current directory or PATH. |
| 412d698677 | An //exported Go function can be called back from C on the same thread. |
| ca855400f3 | C.x and &C.x read and write a C global variable in place. |
| ee5f90adc4, 6e69ce74ac | -cgo combines with -tests for one package; the new option -cgo-removals-dry-run; a Go struct viewed as a C struct crosses as an image. |
| cb868cba55, bddb992e0c, d229e5d09f, 1eb5b3e0cb, 15ae6a7535, 43bc309020 | More of C’s memory crosses: a Go pointer as void*, char** out-parameters, values pinned with runtime.Pinner, arrays of C pointers, C structs holding pointer words, elements of Go slices of C structs, void * struct members. |
| f5862b0ac1, 92d334becb, 5c0f578b22 | github.com/mattn/go-sqlite3 converts and compiles, with an undefined C name refused at conversion on every target; -tests builds a cgo package’s test host. |
| 9a48dbc8cb | A cgo package’s NuGet pack includes osx-arm64. |
Windows and Native AOT
| Merge | Change |
|---|---|
| 4385f03f0c | A windows/amd64 system call goes through Go’s calling shape: a float result is returned, up to 42 arguments pass, Control Flow Guard checks the target, and a call block that is not on the thread’s stack is refused. |
| 23be375b13, 9a55ccbd4f | syscall.NewCallback binds callbacks of 0 to 16 arguments, also under Native AOT. |
| 787d62cafa | A program that handles SIGTERM gets Windows’ grace period on console close, logoff or shutdown, and the signal is delivered. |
| 3d7aa8fbf1 | A Native AOT publish turns identical-method folding off by default: it publishes several times faster, and the executable is larger. IlcFoldIdenticalMethodBodies=true restores it. |
| d093136bab | A Native AOT publish writes no native debug symbols by default; NativeDebugSymbols=true restores them. |
| eb88fc75e0 | An assertion to a func type trims cleanly under Native AOT. |
| a226d2683b | append and reslicing take an in-place fast path. |
Goroutines on a pool of threads (M:N, experimental)
| Merge | Change |
|---|---|
| 22884b0d6e | The opt-in (GoTwinsFor) ships in go.lib’s build files, so it works for a program converted anywhere. |
| 05bf73402a | The standard-library packages are built with their twins. |
| 30e537ff41 | The scheduler adds threads for a wait it cannot see, up to a ceiling set with debug.SetMaxThreads or GO2CS_MN_MAXTHREADS; hand-written C# that blocks in native code says so with GoNativeCall. |
| 639adf1cda | Each carrier thread reserves 1 GiB of stack, or what GO2CS_GOROUTINE_STACK says. |
Platforms and the go2cs tool
| Merge | Change |
|---|---|
| 794356390d, 195544727e, 00e05ac55a | On Apple silicon the packages carry the darwin/arm64 standard library, -platforms darwin/arm64 is a conversion target, and the validated macOS rows were read again on that build. |
| 68d912305a, d1ae0957bc | A -recurse output root and a single-package conversion record their target platform, so they build the right standard library on Linux and macOS. |
| 04f29bcb20 | A standard library built for one operating system and run on another prints its warning before the fatal error. |
| 3eeac4987d, f36e08fd2f | A root staged by deploy-core, and -recurse run inside one, build. |
| 8e0b1bab73 | A go2cs built from source between releases reports a development version of the next release, and its -recurse=nuget refuses by name. |
| 1da6aaf25d | A conversion of a package with several files no longer crashes at random with a concurrent map write. |
| 3be8222d62 | A process that converts many packages no longer grows without bound. |
| 7d8af59808, 4126d7073c, 6fbae1bc37, f5ff7330a3 | A -tests host refuses dotnet test by name and builds by hand or in an IDE; a module’s test host finds its module root; a host launched through a Windows short path starts; a run warns when Go’s side cannot write its input directory. |
| a82699d6e7 | GO2CS_CHECK_STRING_WRITES is an opt-in check that panics when a program writes into a string’s bytes. |
| 3063d7e7cc | unsafe views of a string’s or a slice’s bytes convert, and a conversion to an alias of unsafe.Pointer keeps its storage alive. |
| f1046a6dc7 | go.lib ships a NOTICE for the parts derived from Go. |
Breaks
| Merge | Change |
|---|---|
| 58124df9a9, cb6def82a2 | A Go variadic parameter is go.variadic<T>, not System.Span<T>; f(s...) hands the callee the caller’s slice, so its writes are kept. The break floor is 1.26.11.2. |
| d62a18c559 | A defined func type is a delegate of its own. |
| fb2526882a | net/http/httptest’s ResponseRecorder.Result loses its ref form. |
| 9b71871b51 | A converted Go internal or vendored package’s assembly records its root, and warning GO2CS0022 names hand-written C# that uses one of its types from outside it. |
| 11f0a5dde1, c7cba87148, 528c057cfa, 067cccd25e, b297ccaa5e, 93ba8fd1a3, b84fd81611 | The named-wrapper members, Δrecord, the Δ names, the numeric caster, @new<T>(), text/template’s accessors and the registry Key, each described in Upgrading above. |