From a029989aff3c26853cf53369d325f7a73263a8b1 Mon Sep 17 00:00:00 2001 From: Maisem Ali Date: Tue, 2 Aug 2022 09:57:10 -0700 Subject: [PATCH] types/dnstype: use viewer instead of cloner This was missed when I did the initial viewer work. Signed-off-by: Maisem Ali --- types/dnstype/dnstype.go | 2 +- types/dnstype/dnstype_view.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/types/dnstype/dnstype.go b/types/dnstype/dnstype.go index 9a3db4744..2c1037c39 100644 --- a/types/dnstype/dnstype.go +++ b/types/dnstype/dnstype.go @@ -5,7 +5,7 @@ // Package dnstype defines types for working with DNS. package dnstype -//go:generate go run tailscale.com/cmd/cloner --type=Resolver --clonefunc=true +//go:generate go run tailscale.com/cmd/viewer --type=Resolver --clonefunc=true import ( "net/netip" diff --git a/types/dnstype/dnstype_view.go b/types/dnstype/dnstype_view.go index 7a68f6381..7f99be2f4 100644 --- a/types/dnstype/dnstype_view.go +++ b/types/dnstype/dnstype_view.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Code generated by tailscale.com/util/codegen (viewer); DO NOT EDIT. +// Code generated by tailscale/cmd/viewer; DO NOT EDIT. package dnstype @@ -15,14 +15,18 @@ import ( ) //go:generate go run tailscale.com/cmd/cloner -clonefunc=true -type=Resolver + // View returns a readonly view of Resolver. func (p *Resolver) View() ResolverView { return ResolverView{ж: p} } -// ResolverView provides a read-only view on Resolver. -// It's methods should only be called if `Valid()` returns true. +// ResolverView provides a read-only view over Resolver. +// +// Its methods should only be called if `Valid()` returns true. type ResolverView struct { + // ж is the underlying mutable value, named with a hard-to-type + // character that looks pointy like a pointer. // It is named distinctively to make you think of how dangerous it is to escape // to callers. You must not let callers be able to mutate it. ж *Resolver @@ -34,7 +38,7 @@ func (v ResolverView) Valid() bool { return v.ж != nil } // AsStruct returns a clone of the underlying value which aliases no memory with // the original. func (v ResolverView) AsStruct() *Resolver { - if v.ж != nil { + if v.ж == nil { return nil } return v.ж.Clone()