internal/impl: unexport ExtensionFieldV1.Value

CL/177620 modifies v1 to stop touching the Value field directly,
such that it is now unexport the Value field.

Change-Id: I0a05bbe59146862fc77c261349d7d90d6fa312e0
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/177621
Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
Joe Tsai 2019-05-16 12:00:29 -07:00
parent 40b83d67fc
commit 11caeff126
5 changed files with 12 additions and 12 deletions

View File

@ -1,7 +1,7 @@
module google.golang.org/protobuf/cmd/protoc-gen-go-grpc/testdata
require (
github.com/golang/protobuf v1.2.1-0.20190515194842-7574ba03306e
github.com/golang/protobuf v1.2.1-0.20190516201927-a2cd3ac1b343
google.golang.org/grpc v1.19.0
google.golang.org/protobuf v1.0.0
)

View File

@ -1,7 +1,7 @@
module google.golang.org/protobuf/cmd/protoc-gen-go/testdata
require (
github.com/golang/protobuf v1.2.1-0.20190515194842-7574ba03306e
github.com/golang/protobuf v1.2.1-0.20190516201927-a2cd3ac1b343
google.golang.org/protobuf v1.0.0
)

2
go.mod
View File

@ -3,6 +3,6 @@ module google.golang.org/protobuf
go 1.9
require (
github.com/golang/protobuf v1.2.1-0.20190515194842-7574ba03306e
github.com/golang/protobuf v1.2.1-0.20190516201927-a2cd3ac1b343
github.com/google/go-cmp v0.3.0
)

4
go.sum
View File

@ -1,7 +1,9 @@
github.com/golang/protobuf v1.2.1-0.20190514181236-7800af189d76/go.mod h1:Zfz6qcDoDBESdv6JsKsGpgNHnkvwJAJwcA9eL+mOkgc=
github.com/golang/protobuf v1.2.1-0.20190515194842-7574ba03306e h1:wrd8ZnV3RJvrouZgfP+s3ZcAkX6J1PbrVFWchWHUz90=
github.com/golang/protobuf v1.2.1-0.20190515194842-7574ba03306e/go.mod h1:GjgUz9uwrRQmdPBBrFqiVbojAmlpy6ryM6DCzC+20rE=
github.com/golang/protobuf v1.2.1-0.20190516201927-a2cd3ac1b343 h1:7ggaFvChsnb7ONk6XaHOlWSUItKRmiaCuisgen9uhSg=
github.com/golang/protobuf v1.2.1-0.20190516201927-a2cd3ac1b343/go.mod h1:PScGDF2x230A126tLt9Ol9RjhXzbiPJrt/CogooD2mE=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
google.golang.org/protobuf v0.0.0-20190514172829-e89e6244e0e8/go.mod h1:791zQGC15vDqjpmPRn1uGPu5oHy/Jzw/Q1n5JsgIIcY=
google.golang.org/protobuf v0.0.0-20190514231807-cdb777356907/go.mod h1:HeRLsKXv4+wE27dOIGwnqcOgq6a1O/GJ7mGhiEPnBrU=
google.golang.org/protobuf v0.0.0-20190516201745-40b83d67fc75/go.mod h1:jf+u8AHuKtkib+0J4/bQXPNzCmT3V9a02hVzYKtatuw=

View File

@ -258,15 +258,13 @@ type ExtensionFieldV1 struct {
// value is either the value of GetValue,
// or a *lazyExtensionValue that then returns the value of GetValue.
//
// TODO: unexport this.
Value interface{}
value interface{}
}
// HasValue reports whether a value is set for the extension field.
// This may be called concurrently.
func (f ExtensionFieldV1) HasValue() bool {
return f.Value != nil
return f.value != nil
}
// GetValue returns the concrete value for the extension field.
@ -287,23 +285,23 @@ func (f ExtensionFieldV1) HasValue() bool {
//
// TODO: switch interface{} to protoreflect.Value
func (f ExtensionFieldV1) GetValue() interface{} {
if f, ok := f.Value.(*lazyExtensionValue); ok {
if f, ok := f.value.(*lazyExtensionValue); ok {
return f.GetValue()
}
return f.Value
return f.value
}
// SetEagerValue sets the current value of the extension.
// This must not be called concurrently.
func (f *ExtensionFieldV1) SetEagerValue(v interface{}) {
f.Value = v
f.value = v
}
// SetLazyValue sets a value that is to be lazily evaluated upon first use.
// The returned value must not be nil.
// This must not be called concurrently.
func (f *ExtensionFieldV1) SetLazyValue(v func() interface{}) {
f.Value = &lazyExtensionValue{value: v}
f.value = &lazyExtensionValue{value: v}
}
type lazyExtensionValue struct {