}
}
if op == nil {
- return nil, os.ErrorString("ignore can't handle type " + wireId.String())
+ return nil, os.ErrorString("ignore can't handle type " + wireId.string())
}
return op, nil;
}
continue;
}
if !dec.compatibleType(localField.Type, wireField.id) {
- details := " (" + wireField.id.String() + " incompatible with " + localField.Type.String() + ") in type " + remoteId.Name();
+ details := " (" + wireField.id.string() + " incompatible with " + localField.Type.String() + ") in type " + remoteId.Name();
return nil, os.ErrorString("gob: wrong type for field " + wireField.name + details);
}
op, indir, err := dec.decOpFor(wireField.id, localField.Type, localField.Name);
id() typeId;
setId(id typeId);
Name() string;
- String() string;
+ string() string; // not public; only for debugging
safeString(seen map[typeId]bool) string;
}
return idToType[t];
}
-// String returns the string representation of the type associated with the typeId.
-func (t typeId) String() string { return t.gobType().String() }
+// string returns the string representation of the type associated with the typeId.
+func (t typeId) string() string { return t.gobType().string() }
// Name returns the name of the type associated with the typeId.
func (t typeId) Name() string { return t.gobType().Name() }
func (t *commonType) setId(id typeId) { t._id = id }
-func (t *commonType) String() string { return t.name }
+func (t *commonType) string() string { return t.name }
func (t *commonType) safeString(seen map[typeId]bool) string {
return t.name
return fmt.Sprintf("[%d]%s", a.Len, a.Elem.gobType().safeString(seen));
}
-func (a *arrayType) String() string { return a.safeString(make(map[typeId]bool)) }
+func (a *arrayType) string() string { return a.safeString(make(map[typeId]bool)) }
// Slice type
type sliceType struct {
return fmt.Sprintf("[]%s", s.Elem.gobType().safeString(seen));
}
-func (s *sliceType) String() string { return s.safeString(make(map[typeId]bool)) }
+func (s *sliceType) string() string { return s.safeString(make(map[typeId]bool)) }
// Struct type
type fieldType struct {
return str;
}
-func (s *structType) String() string { return s.safeString(make(map[typeId]bool)) }
+func (s *structType) string() string { return s.safeString(make(map[typeId]bool)) }
func newStructType(name string) *structType {
s := &structType{commonType{name: name}, nil};
// Sanity checks
func TestBasic(t *testing.T) {
for _, tt := range basicTypes {
- if tt.id.String() != tt.str {
- t.Errorf("checkType: expected %q got %s", tt.str, tt.id.String())
+ if tt.id.string() != tt.str {
+ t.Errorf("checkType: expected %q got %s", tt.str, tt.id.string())
}
if tt.id == 0 {
t.Errorf("id for %q is zero", tt.str)
func TestReregistration(t *testing.T) {
newtyp := getTypeUnlocked("int", reflect.Typeof(int(0)));
if newtyp != tInt.gobType() {
- t.Errorf("reregistration of %s got new type", newtyp.String())
+ t.Errorf("reregistration of %s got new type", newtyp.string())
}
newtyp = getTypeUnlocked("uint", reflect.Typeof(uint(0)));
if newtyp != tUint.gobType() {
- t.Errorf("reregistration of %s got new type", newtyp.String())
+ t.Errorf("reregistration of %s got new type", newtyp.string())
}
newtyp = getTypeUnlocked("string", reflect.Typeof("hello"));
if newtyp != tString.gobType() {
- t.Errorf("reregistration of %s got new type", newtyp.String())
+ t.Errorf("reregistration of %s got new type", newtyp.string())
}
}
if a3int == a3bool {
t.Errorf("registration of [3]bool creates same type as [3]int")
}
- str := a3bool.String();
+ str := a3bool.string();
expected := "[3]bool";
if str != expected {
t.Errorf("array printed as %q; expected %q", str, expected)
if sbool == sint {
t.Errorf("registration of []bool creates same type as []int")
}
- str := sbool.String();
+ str := sbool.string();
expected := "[]bool";
if str != expected {
t.Errorf("slice printed as %q; expected %q", str, expected)
func TestStructType(t *testing.T) {
sstruct := getTypeUnlocked("Foo", reflect.Typeof(Foo{}));
- str := sstruct.String();
+ str := sstruct.string();
// If we can print it correctly, we built it correctly.
expected := "Foo = struct { a int; b int; c string; d bytes; e float; f float; g Bar = struct { x string; }; h Bar; i Foo; }";
if str != expected {