Skip to content

Commit

Permalink
Internal changes.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 316770014
  • Loading branch information
alextumanov authored and nickgeorge committed Jun 17, 2020
1 parent cca9b30 commit 869537a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
25 changes: 0 additions & 25 deletions go/google/fhir/jsonformat/internal/protopath/proto_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,6 @@ func (p Path) String() string {
return strings.Join(strParts, ".")
}

// NewPath creates a Path from a string definition using Go field names.
//
// Deprecated: Opaque protos will break this indexing Go proto structs by field
// name. Please use NewProtoPath instead.
func NewPath(p string) Path {
path := Path{}
for _, part := range strings.Split(p, ".") {
path.parts = append(path.parts, goPathPart(part))
}
return path
}

// NewProtoPath creates a Path from a string definition using proto field names.
func NewProtoPath(p string) Path {
path := Path{}
Expand Down Expand Up @@ -592,16 +580,3 @@ func Get(m proto.Message, path Path, defVal interface{}) (interface{}, error) {
}
return get(m.ProtoReflect(), defVal, path.parts)
}

// GetString retrieves a string value from a proto at `path`, or returns an
// empty string. An error will occur if the path is invalid.
//
// Deprecated: use Get and cast the result yourself.
func GetString(m protov1.Message, path Path) (string, error) {
v, err := Get(protov1.MessageV2(m), path, "")
if err != nil {
return "", err
}
// Cannot panic because we've already checked that the value is a string.
return v.(string), nil
}
17 changes: 0 additions & 17 deletions go/google/fhir/jsonformat/internal/protopath/proto_path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,23 +603,6 @@ func TestGet_Errors(t *testing.T) {
}
}

func TestGetString(t *testing.T) {
msg := &rfpb.Account{}
path := NewProtoPath("meta.id.value")
v, err := GetString(msg, path)
if err != nil {
t.Fatalf("GetString(%v, %v) got error %v, expected <nil>", msg, path, err)
}
if v != "" {
t.Fatalf(`GetString(%v, %v) got %v, expected ""`, msg, path, v)
}

path = NewProtoPath("foo")
if _, err := GetString(msg, path); err == nil {
t.Fatalf("GetString(%v, %v) got error <nil>, expected error", msg, path)
}
}

func TestString(t *testing.T) {
tests := []string{
"normal",
Expand Down

0 comments on commit 869537a

Please sign in to comment.