<feed xmlns='http://www.w3.org/2005/Atom'>
<title>tailscale/util/codegen/codegen.go, branch knyar/netmapdiff2</title>
<subtitle>The easiest, most secure way to use WireGuard and 2FA</subtitle>
<id>http://git.waynecole.info/tailscale/atom?h=knyar%2Fnetmapdiff2</id>
<link rel='self' href='http://git.waynecole.info/tailscale/atom?h=knyar%2Fnetmapdiff2'/>
<link rel='alternate' type='text/html' href='http://git.waynecole.info/tailscale/'/>
<updated>2025-08-14T20:46:48Z</updated>
<entry>
<title>cmd/viewer, types/views: implement support for json/v2 (#16852)</title>
<updated>2025-08-14T20:46:48Z</updated>
<author>
<name>Joe Tsai</name>
<email>joetsai@digital-static.net</email>
</author>
<published>2025-08-14T20:46:48Z</published>
<link rel='alternate' type='text/html' href='http://git.waynecole.info/tailscale/commit/?id=fbb91758ac41d279bf67103d204690ba8520afa2'/>
<id>urn:sha1:fbb91758ac41d279bf67103d204690ba8520afa2</id>
<content type='text'>
This adds support for having every viewer type implement
jsonv2.MarshalerTo and jsonv2.UnmarshalerFrom.

This provides a significant boost in performance
as the json package no longer needs to validate
the entirety of the JSON value outputted by MarshalJSON,
nor does it need to identify the boundaries of a JSON value
in order to call UnmarshalJSON.

For deeply nested and recursive MarshalJSON or UnmarshalJSON calls,
this can improve runtime from O(N²) to O(N).

This still references "github.com/go-json-experiment/json"
instead of the experimental "encoding/json/v2" package
now available in Go 1.25 under goexperiment.jsonv2
so that code still builds without the experiment tag.
Of note, the "github.com/go-json-experiment/json" package
aliases the standard library under the right build conditions.

Updates tailscale/corp#791

Signed-off-by: Joe Tsai &lt;joetsai@digital-static.net&gt;</content>
</entry>
<entry>
<title>util/codegen: treat unique.Handle as an opaque value type</title>
<updated>2024-11-11T20:39:19Z</updated>
<author>
<name>Brad Fitzpatrick</name>
<email>bradfitz@tailscale.com</email>
</author>
<published>2024-11-11T16:48:09Z</published>
<link rel='alternate' type='text/html' href='http://git.waynecole.info/tailscale/commit/?id=00be1761b76671635b478a20187d83b166991924'/>
<id>urn:sha1:00be1761b76671635b478a20187d83b166991924</id>
<content type='text'>
It doesn't need a Clone method, like a time.Time, etc.

And then, because Go 1.23+ uses unique.Handle internally for
the netip package types, we can remove those special cases.

Updates #14058 (pulled out from that PR)
Updates tailscale/corp#24485

Change-Id: Iac3548a9417ccda5987f98e0305745a6e178b375
Signed-off-by: Brad Fitzpatrick &lt;bradfitz@tailscale.com&gt;
</content>
</entry>
<entry>
<title>cmd/viewer: import types/views when generating a getter for a map field</title>
<updated>2024-10-21T21:29:16Z</updated>
<author>
<name>Nick Khyl</name>
<email>nickk@tailscale.com</email>
</author>
<published>2024-10-21T17:28:41Z</published>
<link rel='alternate' type='text/html' href='http://git.waynecole.info/tailscale/commit/?id=0f4c9c0ecb133f2e7e3df2626e2a6a114d6dc251'/>
<id>urn:sha1:0f4c9c0ecb133f2e7e3df2626e2a6a114d6dc251</id>
<content type='text'>
Fixes #13873

Signed-off-by: Nick Khyl &lt;nickk@tailscale.com&gt;
</content>
</entry>
<entry>
<title>cmd/cloner, cmd/viewer, util/codegen: add support for aliases of cloneable types</title>
<updated>2024-08-23T20:43:40Z</updated>
<author>
<name>Nick Khyl</name>
<email>nickk@tailscale.com</email>
</author>
<published>2024-08-22T22:59:45Z</published>
<link rel='alternate' type='text/html' href='http://git.waynecole.info/tailscale/commit/?id=03acab2639c03c83a5507f95ef0128d893fc405e'/>
<id>urn:sha1:03acab2639c03c83a5507f95ef0128d893fc405e</id>
<content type='text'>
We have several checked type assertions to *types.Named in both cmd/cloner and cmd/viewer.
As Go 1.23 updates the go/types package to produce Alias type nodes for type aliases,
these type assertions no longer work as expected unless the new behavior is disabled
with gotypesalias=0.

In this PR, we add codegen.NamedTypeOf(t types.Type), which functions like t.(*types.Named)
but also unrolls type aliases. We then use it in place of type assertions in the cmd/cloner and
cmd/viewer packages where appropriate.

We also update type switches to include *types.Alias alongside *types.Named in relevant cases,
remove *types.Struct cases when switching on types.Type.Underlying and update the tests
with more cases where type aliases can be used.

Updates #13224
Updates #12912

Signed-off-by: Nick Khyl &lt;nickk@tailscale.com&gt;
</content>
</entry>
<entry>
<title>util/codegen, cmd/cloner, cmd/viewer: update codegen.LookupMethod to support alias type nodes</title>
<updated>2024-08-23T20:26:05Z</updated>
<author>
<name>Nick Khyl</name>
<email>nickk@tailscale.com</email>
</author>
<published>2024-08-22T21:33:35Z</published>
<link rel='alternate' type='text/html' href='http://git.waynecole.info/tailscale/commit/?id=a9dc6e07ad277e6a44ff0038b32ac3538e23e666'/>
<id>urn:sha1:a9dc6e07ad277e6a44ff0038b32ac3538e23e666</id>
<content type='text'>
Go 1.23 updates the go/types package to produce Alias type nodes for type aliases, unless disabled with gotypesalias=0.
This new default behavior breaks codegen.LookupMethod, which uses checked type assertions to types.Named and
types.Interface, as only named types and interfaces have methods.

In this PR, we update codegen.LookupMethod to perform method lookup on the right-hand side of the alias declaration
and clearly switch on the supported type nodes types. We also improve support for various edge cases, such as when an alias
is used as a type parameter constraint, and add tests for the LookupMethod function.

Additionally, we update cmd/viewer/tests to include types with aliases used in type fields and generic type constraints.

Updates #13224
Updates #12912

Signed-off-by: Nick Khyl &lt;nickk@tailscale.com&gt;
</content>
</entry>
<entry>
<title>fix #13076: codegen error when using anonymous struct</title>
<updated>2024-08-14T04:41:39Z</updated>
<author>
<name>cai.li</name>
<email>cai.li@qingteng.cn</email>
</author>
<published>2024-08-09T13:09:17Z</published>
<link rel='alternate' type='text/html' href='http://git.waynecole.info/tailscale/commit/?id=2506bf5b0699f29f101b1323930cdd6280575984'/>
<id>urn:sha1:2506bf5b0699f29f101b1323930cdd6280575984</id>
<content type='text'>
Signed-off-by: cai.li &lt;cai.li@qingteng.cn&gt;
</content>
</entry>
<entry>
<title>cmd/viewer, types/views, util/codegen: add viewer support for custom container types</title>
<updated>2024-07-19T17:50:39Z</updated>
<author>
<name>Nick Khyl</name>
<email>nickk@tailscale.com</email>
</author>
<published>2024-07-14T16:45:55Z</published>
<link rel='alternate' type='text/html' href='http://git.waynecole.info/tailscale/commit/?id=20562a4fb9c2af417c44b3ab63a826d9d0f6b6b2'/>
<id>urn:sha1:20562a4fb9c2af417c44b3ab63a826d9d0f6b6b2</id>
<content type='text'>
This adds support for container-like types such as Container[T] that
don't explicitly specify a view type for T. Instead, a package implementing
a container type should also implement and export a ContainerView[T, V] type
and a ContainerViewOf(*Container[T]) ContainerView[T, V] function, which
returns a view for the specified container, inferring the element view type V
from the element type T.

Updates #12736

Signed-off-by: Nick Khyl &lt;nickk@tailscale.com&gt;
</content>
</entry>
<entry>
<title>cmd/cloner, cmd/viewer, util/codegen: add support for generic types and interfaces</title>
<updated>2024-07-11T21:38:53Z</updated>
<author>
<name>Nick Khyl</name>
<email>nickk@tailscale.com</email>
</author>
<published>2024-07-08T15:11:00Z</published>
<link rel='alternate' type='text/html' href='http://git.waynecole.info/tailscale/commit/?id=fc28c8e7f39d83e75dfd6009c789c0a9739ba9bd'/>
<id>urn:sha1:fc28c8e7f39d83e75dfd6009c789c0a9739ba9bd</id>
<content type='text'>
This adds support for generic types and interfaces to our cloner and viewer codegens.
It updates these packages to determine whether to make shallow or deep copies based
on the type parameter constraints. Additionally, if a template parameter or an interface
type has View() and Clone() methods, we'll use them for getters and the cloner of the
owning structure.

Updates #12736

Signed-off-by: Nick Khyl &lt;nickk@tailscale.com&gt;
</content>
</entry>
<entry>
<title>all: use Go 1.22 range-over-int</title>
<updated>2024-04-16T22:32:38Z</updated>
<author>
<name>Brad Fitzpatrick</name>
<email>bradfitz@tailscale.com</email>
</author>
<published>2024-04-16T20:15:13Z</published>
<link rel='alternate' type='text/html' href='http://git.waynecole.info/tailscale/commit/?id=7c1d6e35a5863d58f3727af07dea0578fca87030'/>
<id>urn:sha1:7c1d6e35a5863d58f3727af07dea0578fca87030</id>
<content type='text'>
Updates #11058

Change-Id: I35e7ef9b90e83cac04ca93fd964ad00ed5b48430
Signed-off-by: Brad Fitzpatrick &lt;bradfitz@tailscale.com&gt;
</content>
</entry>
<entry>
<title>util/codegen: support embedded fields</title>
<updated>2023-05-09T22:40:17Z</updated>
<author>
<name>Brad Fitzpatrick</name>
<email>bradfitz@tailscale.com</email>
</author>
<published>2023-05-09T22:35:47Z</published>
<link rel='alternate' type='text/html' href='http://git.waynecole.info/tailscale/commit/?id=4f454f4122f54b79f54ecadc61da781f495be83c'/>
<id>urn:sha1:4f454f4122f54b79f54ecadc61da781f495be83c</id>
<content type='text'>
I noticed cmd/{cloner,viewer} didn't support structs with embedded
fields while working on a change in another repo. This adds support.

Signed-off-by: Brad Fitzpatrick &lt;bradfitz@tailscale.com&gt;
</content>
</entry>
</feed>
