Browse Source

Merge pull request #2579 from xiang90/update-proto

*: update protobuf
Xiang Li 10 years ago
parent
commit
e5f2f40145
47 changed files with 1029 additions and 404 deletions
  1. 4 4
      Godeps/Godeps.json
  2. 1 1
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/Makefile
  3. 97 11
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/all_test.go
  4. 10 2
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/clone.go
  5. 24 3
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/clone_test.go
  6. 4 9
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/decode.go
  7. 1 1
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/decode_gogo.go
  8. 113 20
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode.go
  9. 29 7
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode_gogo.go
  10. 2 2
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/equal.go
  11. 2 2
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/equal_test.go
  12. 36 21
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions.go
  13. 33 1
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions_gogo.go
  14. 94 0
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions_test.go
  15. 4 4
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib.go
  16. 1 1
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib_gogo.go
  17. 81 10
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/message_set.go
  18. 66 0
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/message_set_test.go
  19. 2 2
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_reflect.go
  20. 2 2
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe.go
  21. 1 1
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go
  22. 65 52
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties.go
  23. 8 4
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties_gogo.go
  24. 1 1
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/size2_test.go
  25. 5 3
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/size_test.go
  26. 3 2
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/skip_gogo.go
  27. 1 1
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/testdata/Makefile
  28. 1 1
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/testdata/golden_test.go
  29. 38 8
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/testdata/test.pb.go
  30. 1 1
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/testdata/test.pb.go.golden
  31. 9 1
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/testdata/test.proto
  32. 16 13
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/text.go
  33. 1 1
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_gogo.go
  34. 33 28
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser.go
  35. 12 6
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser_test.go
  36. 23 3
      Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_test.go
  37. 28 26
      etcdserver/etcdserverpb/etcdserver.pb.go
  38. 1 1
      etcdserver/etcdserverpb/etcdserver.proto
  39. 53 45
      migrate/etcd4pb/log_entry.pb.go
  40. 1 1
      migrate/etcd4pb/log_entry.proto
  41. 87 69
      raft/raftpb/raft.pb.go
  42. 1 1
      raft/raftpb/raft.proto
  43. 6 6
      scripts/genproto.sh
  44. 10 10
      snap/snappb/snap.pb.go
  45. 1 1
      snap/snappb/snap.proto
  46. 16 14
      wal/walpb/record.pb.go
  47. 1 1
      wal/walpb/record.proto

+ 4 - 4
Godeps/Godeps.json

@@ -5,10 +5,6 @@
 		"./..."
 	],
 	"Deps": [
-		{
-			"ImportPath": "code.google.com/p/gogoprotobuf/proto",
-			"Rev": "7fd1620f09261338b6b1ca1289ace83aee0ec946"
-		},
 		{
 			"ImportPath": "code.google.com/p/goprotobuf/proto",
 			"Comment": "go.r60-163",
@@ -24,6 +20,10 @@
 			"Comment": "v0.2.0-rc1-130-g6aa2da5",
 			"Rev": "6aa2da5a7a905609c93036b9307185a04a5a84a5"
 		},
+		{
+			"ImportPath": "github.com/gogo/protobuf/proto",
+			"Rev": "bc946d07d1016848dfd2507f90f0859c9471681e"
+		},
 		{
 			"ImportPath": "github.com/golang/protobuf/proto",
 			"Rev": "5677a0e3d5e89854c9974e1256839ee23f8233ca"

+ 1 - 1
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/Makefile → Godeps/_workspace/src/github.com/gogo/protobuf/proto/Makefile

@@ -1,7 +1,7 @@
 # Go support for Protocol Buffers - Google's data interchange format
 #
 # Copyright 2010 The Go Authors.  All rights reserved.
-# http://code.google.com/p/goprotobuf/
+# https://github.com/golang/protobuf
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are

+ 97 - 11
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/all_test.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/all_test.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2010 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -34,6 +34,7 @@ package proto_test
 import (
 	"bytes"
 	"encoding/json"
+	"errors"
 	"fmt"
 	"math"
 	"math/rand"
@@ -44,7 +45,7 @@ import (
 	"time"
 
 	. "./testdata"
-	. "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
+	. "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
 )
 
 var globalO *Buffer
@@ -394,6 +395,63 @@ func TestNumericPrimitives(t *testing.T) {
 	}
 }
 
+// fakeMarshaler is a simple struct implementing Marshaler and Message interfaces.
+type fakeMarshaler struct {
+	b   []byte
+	err error
+}
+
+func (f fakeMarshaler) Marshal() ([]byte, error) {
+	return f.b, f.err
+}
+
+func (f fakeMarshaler) String() string {
+	return fmt.Sprintf("Bytes: %v Error: %v", f.b, f.err)
+}
+
+func (f fakeMarshaler) ProtoMessage() {}
+
+func (f fakeMarshaler) Reset() {}
+
+// Simple tests for proto messages that implement the Marshaler interface.
+func TestMarshalerEncoding(t *testing.T) {
+	tests := []struct {
+		name    string
+		m       Message
+		want    []byte
+		wantErr error
+	}{
+		{
+			name: "Marshaler that fails",
+			m: fakeMarshaler{
+				err: errors.New("some marshal err"),
+				b:   []byte{5, 6, 7},
+			},
+			// Since there's an error, nothing should be written to buffer.
+			want:    nil,
+			wantErr: errors.New("some marshal err"),
+		},
+		{
+			name: "Marshaler that succeeds",
+			m: fakeMarshaler{
+				b: []byte{0, 1, 2, 3, 4, 127, 255},
+			},
+			want:    []byte{0, 1, 2, 3, 4, 127, 255},
+			wantErr: nil,
+		},
+	}
+	for _, test := range tests {
+		b := NewBuffer(nil)
+		err := b.Marshal(test.m)
+		if !reflect.DeepEqual(test.wantErr, err) {
+			t.Errorf("%s: got err %v wanted %v", test.name, err, test.wantErr)
+		}
+		if !reflect.DeepEqual(test.want, b.Bytes()) {
+			t.Errorf("%s: got bytes %v wanted %v", test.name, b.Bytes(), test.want)
+		}
+	}
+}
+
 // Simple tests for bytes
 func TestBytesPrimitives(t *testing.T) {
 	o := old()
@@ -989,6 +1047,35 @@ func TestSubmessageUnrecognizedFields(t *testing.T) {
 	}
 }
 
+// Check that an int32 field can be upgraded to an int64 field.
+func TestNegativeInt32(t *testing.T) {
+	om := &OldMessage{
+		Num: Int32(-1),
+	}
+	b, err := Marshal(om)
+	if err != nil {
+		t.Fatalf("Marshal of OldMessage: %v", err)
+	}
+
+	// Check the size. It should be 11 bytes;
+	// 1 for the field/wire type, and 10 for the negative number.
+	if len(b) != 11 {
+		t.Errorf("%v marshaled as %q, wanted 11 bytes", om, b)
+	}
+
+	// Unmarshal into a NewMessage.
+	nm := new(NewMessage)
+	if err := Unmarshal(b, nm); err != nil {
+		t.Fatalf("Unmarshal to NewMessage: %v", err)
+	}
+	want := &NewMessage{
+		Num: Int64(-1),
+	}
+	if !Equal(nm, want) {
+		t.Errorf("nm = %v, want %v", nm, want)
+	}
+}
+
 // Check that we can grow an array (repeated field) to have many elements.
 // This test doesn't depend only on our encoding; for variety, it makes sure
 // we create, encode, and decode the correct contents explicitly.  It's therefore
@@ -1116,13 +1203,10 @@ func TestTypeMismatch(t *testing.T) {
 	// Now Unmarshal it to the wrong type.
 	pb2 := initGoTestField()
 	err := o.Unmarshal(pb2)
-	switch err {
-	case ErrWrongType:
-		// fine
-	case nil:
-		t.Error("expected wrong type error, got no error")
-	default:
-		t.Error("expected wrong type error, got", err)
+	if err == nil {
+		t.Error("expected error, got no error")
+	} else if !strings.Contains(err.Error(), "bad wiretype") {
+		t.Error("expected bad wiretype error, got", err)
 	}
 }
 
@@ -1303,10 +1387,11 @@ func TestAllSetDefaults(t *testing.T) {
 		F_Pinf:    Float32(float32(math.Inf(1))),
 		F_Ninf:    Float32(float32(math.Inf(-1))),
 		F_Nan:     Float32(1.7),
+		StrZero:   String(""),
 	}
 	SetDefaults(m)
 	if !Equal(m, expected) {
-		t.Errorf(" got %v\nwant %v", m, expected)
+		t.Errorf("SetDefaults failed\n got %v\nwant %v", m, expected)
 	}
 }
 
@@ -1655,7 +1740,8 @@ func TestEncodingSizes(t *testing.T) {
 		n int
 	}{
 		{&Defaults{F_Int32: Int32(math.MaxInt32)}, 6},
-		{&Defaults{F_Int32: Int32(math.MinInt32)}, 6},
+		{&Defaults{F_Int32: Int32(math.MinInt32)}, 11},
+		{&Defaults{F_Uint32: Uint32(uint32(math.MaxInt32) + 1)}, 6},
 		{&Defaults{F_Uint32: Uint32(math.MaxUint32)}, 6},
 	}
 	for _, test := range tests {

+ 10 - 2
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/clone.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/clone.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2011 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -130,13 +130,21 @@ func mergeAny(out, in reflect.Value) {
 		if in.IsNil() {
 			return
 		}
+		if in.Type().Elem().Kind() == reflect.Uint8 {
+			// []byte is a scalar bytes field, not a repeated field.
+			// Make a deep copy.
+			// Append to []byte{} instead of []byte(nil) so that we never end up
+			// with a nil result.
+			out.SetBytes(append([]byte{}, in.Bytes()...))
+			return
+		}
 		n := in.Len()
 		if out.IsNil() {
 			out.Set(reflect.MakeSlice(in.Type(), 0, n))
 		}
 		switch in.Type().Elem().Kind() {
 		case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64,
-			reflect.String, reflect.Uint32, reflect.Uint64, reflect.Uint8:
+			reflect.String, reflect.Uint32, reflect.Uint64:
 			out.Set(reflect.AppendSlice(out, in))
 		default:
 			for i := 0; i < n; i++ {

+ 24 - 3
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/clone_test.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/clone_test.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2011 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -34,9 +34,8 @@ package proto_test
 import (
 	"testing"
 
-	"github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
-
 	pb "./testdata"
+	"github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
 )
 
 var cloneTestMessage = &pb.MyMessage{
@@ -79,6 +78,22 @@ func TestClone(t *testing.T) {
 	if proto.Equal(m, cloneTestMessage) {
 		t.Error("Mutating clone changed the original")
 	}
+	// Byte fields and repeated fields should be copied.
+	if &m.Pet[0] == &cloneTestMessage.Pet[0] {
+		t.Error("Pet: repeated field not copied")
+	}
+	if &m.Others[0] == &cloneTestMessage.Others[0] {
+		t.Error("Others: repeated field not copied")
+	}
+	if &m.Others[0].Value[0] == &cloneTestMessage.Others[0].Value[0] {
+		t.Error("Others[0].Value: bytes field not copied")
+	}
+	if &m.RepBytes[0] == &cloneTestMessage.RepBytes[0] {
+		t.Error("RepBytes: repeated field not copied")
+	}
+	if &m.RepBytes[0][0] == &cloneTestMessage.RepBytes[0][0] {
+		t.Error("RepBytes[0]: bytes field not copied")
+	}
 }
 
 func TestCloneNil(t *testing.T) {
@@ -167,6 +182,12 @@ var mergeTests = []struct {
 			RepBytes: [][]byte{[]byte("sham"), []byte("wow")},
 		},
 	},
+	// Check that a scalar bytes field replaces rather than appends.
+	{
+		src:  &pb.OtherMessage{Value: []byte("foo")},
+		dst:  &pb.OtherMessage{Value: []byte("bar")},
+		want: &pb.OtherMessage{Value: []byte("foo")},
+	},
 }
 
 func TestMerge(t *testing.T) {

+ 4 - 9
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/decode.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/decode.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2010 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -43,11 +43,6 @@ import (
 	"reflect"
 )
 
-// ErrWrongType occurs when the wire encoding for the field disagrees with
-// that specified in the type being decoded.  This is usually caused by attempting
-// to convert an encoded protocol buffer into a struct of the wrong type.
-var ErrWrongType = errors.New("proto: field/encoding mismatch: wrong type for field")
-
 // errOverflow is returned when an integer is too large to be represented.
 var errOverflow = errors.New("proto: integer overflow")
 
@@ -363,11 +358,11 @@ func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group
 			if is_group {
 				return nil // input is satisfied
 			}
-			return ErrWrongType
+			return fmt.Errorf("proto: %s: wiretype end group for non-group", st)
 		}
 		tag := int(u >> 3)
 		if tag <= 0 {
-			return fmt.Errorf("proto: illegal tag %d", tag)
+			return fmt.Errorf("proto: %s: illegal tag %d (wire type %d)", st, tag, wire)
 		}
 		fieldnum, ok := prop.decoderTags.get(tag)
 		if !ok {
@@ -402,7 +397,7 @@ func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group
 				// a packable field
 				dec = p.packedDec
 			} else {
-				err = ErrWrongType
+				err = fmt.Errorf("proto: bad wiretype for field %s.%s: got wiretype %d, want %d", st, st.Field(fieldnum).Name, wire, p.WireType)
 				continue
 			}
 		}

+ 1 - 1
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/decode_gogo.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/decode_gogo.go

@@ -1,5 +1,5 @@
 // Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
-// http://code.google.com/p/gogoprotobuf/gogoproto
+// http://github.com/gogo/protobuf/gogoproto
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are

+ 113 - 20
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/encode.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2010 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -247,7 +247,7 @@ func (p *Buffer) Marshal(pb Message) error {
 		return ErrNil
 	}
 	if err == nil {
-		err = p.enc_struct(t.Elem(), GetProperties(t.Elem()), base)
+		err = p.enc_struct(GetProperties(t.Elem()), base)
 	}
 
 	if collectStats {
@@ -271,7 +271,7 @@ func Size(pb Message) (n int) {
 		return 0
 	}
 	if err == nil {
-		n = size_struct(t.Elem(), GetProperties(t.Elem()), base)
+		n = size_struct(GetProperties(t.Elem()), base)
 	}
 
 	if collectStats {
@@ -312,13 +312,37 @@ func (o *Buffer) enc_int32(p *Properties, base structPointer) error {
 	if word32_IsNil(v) {
 		return ErrNil
 	}
-	x := word32_Get(v)
+	x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range
 	o.buf = append(o.buf, p.tagcode...)
 	p.valEnc(o, uint64(x))
 	return nil
 }
 
 func size_int32(p *Properties, base structPointer) (n int) {
+	v := structPointer_Word32(base, p.field)
+	if word32_IsNil(v) {
+		return 0
+	}
+	x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range
+	n += len(p.tagcode)
+	n += p.valSize(uint64(x))
+	return
+}
+
+// Encode a uint32.
+// Exactly the same as int32, except for no sign extension.
+func (o *Buffer) enc_uint32(p *Properties, base structPointer) error {
+	v := structPointer_Word32(base, p.field)
+	if word32_IsNil(v) {
+		return ErrNil
+	}
+	x := word32_Get(v)
+	o.buf = append(o.buf, p.tagcode...)
+	p.valEnc(o, uint64(x))
+	return nil
+}
+
+func size_uint32(p *Properties, base structPointer) (n int) {
 	v := structPointer_Word32(base, p.field)
 	if word32_IsNil(v) {
 		return 0
@@ -405,7 +429,7 @@ func (o *Buffer) enc_struct_message(p *Properties, base structPointer) error {
 	}
 
 	o.buf = append(o.buf, p.tagcode...)
-	return o.enc_len_struct(p.stype, p.sprop, structp, &state)
+	return o.enc_len_struct(p.sprop, structp, &state)
 }
 
 func size_struct_message(p *Properties, base structPointer) int {
@@ -424,7 +448,7 @@ func size_struct_message(p *Properties, base structPointer) int {
 	}
 
 	n0 := len(p.tagcode)
-	n1 := size_struct(p.stype, p.sprop, structp)
+	n1 := size_struct(p.sprop, structp)
 	n2 := sizeVarint(uint64(n1)) // size of encoded length
 	return n0 + n1 + n2
 }
@@ -438,7 +462,7 @@ func (o *Buffer) enc_struct_group(p *Properties, base structPointer) error {
 	}
 
 	o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup))
-	err := o.enc_struct(p.stype, p.sprop, b)
+	err := o.enc_struct(p.sprop, b)
 	if err != nil && !state.shouldContinue(err, nil) {
 		return err
 	}
@@ -453,7 +477,7 @@ func size_struct_group(p *Properties, base structPointer) (n int) {
 	}
 
 	n += sizeVarint(uint64((p.Tag << 3) | WireStartGroup))
-	n += size_struct(p.stype, p.sprop, b)
+	n += size_struct(p.sprop, b)
 	n += sizeVarint(uint64((p.Tag << 3) | WireEndGroup))
 	return
 }
@@ -546,7 +570,7 @@ func (o *Buffer) enc_slice_int32(p *Properties, base structPointer) error {
 	}
 	for i := 0; i < l; i++ {
 		o.buf = append(o.buf, p.tagcode...)
-		x := s.Index(i)
+		x := int32(s.Index(i)) // permit sign extension to use full 64-bit range
 		p.valEnc(o, uint64(x))
 	}
 	return nil
@@ -560,7 +584,7 @@ func size_slice_int32(p *Properties, base structPointer) (n int) {
 	}
 	for i := 0; i < l; i++ {
 		n += len(p.tagcode)
-		x := s.Index(i)
+		x := int32(s.Index(i)) // permit sign extension to use full 64-bit range
 		n += p.valSize(uint64(x))
 	}
 	return
@@ -576,7 +600,8 @@ func (o *Buffer) enc_slice_packed_int32(p *Properties, base structPointer) error
 	// TODO: Reuse a Buffer.
 	buf := NewBuffer(nil)
 	for i := 0; i < l; i++ {
-		p.valEnc(buf, uint64(s.Index(i)))
+		x := int32(s.Index(i)) // permit sign extension to use full 64-bit range
+		p.valEnc(buf, uint64(x))
 	}
 
 	o.buf = append(o.buf, p.tagcode...)
@@ -586,6 +611,74 @@ func (o *Buffer) enc_slice_packed_int32(p *Properties, base structPointer) error
 }
 
 func size_slice_packed_int32(p *Properties, base structPointer) (n int) {
+	s := structPointer_Word32Slice(base, p.field)
+	l := s.Len()
+	if l == 0 {
+		return 0
+	}
+	var bufSize int
+	for i := 0; i < l; i++ {
+		x := int32(s.Index(i)) // permit sign extension to use full 64-bit range
+		bufSize += p.valSize(uint64(x))
+	}
+
+	n += len(p.tagcode)
+	n += sizeVarint(uint64(bufSize))
+	n += bufSize
+	return
+}
+
+// Encode a slice of uint32s ([]uint32).
+// Exactly the same as int32, except for no sign extension.
+func (o *Buffer) enc_slice_uint32(p *Properties, base structPointer) error {
+	s := structPointer_Word32Slice(base, p.field)
+	l := s.Len()
+	if l == 0 {
+		return ErrNil
+	}
+	for i := 0; i < l; i++ {
+		o.buf = append(o.buf, p.tagcode...)
+		x := s.Index(i)
+		p.valEnc(o, uint64(x))
+	}
+	return nil
+}
+
+func size_slice_uint32(p *Properties, base structPointer) (n int) {
+	s := structPointer_Word32Slice(base, p.field)
+	l := s.Len()
+	if l == 0 {
+		return 0
+	}
+	for i := 0; i < l; i++ {
+		n += len(p.tagcode)
+		x := s.Index(i)
+		n += p.valSize(uint64(x))
+	}
+	return
+}
+
+// Encode a slice of uint32s ([]uint32) in packed format.
+// Exactly the same as int32, except for no sign extension.
+func (o *Buffer) enc_slice_packed_uint32(p *Properties, base structPointer) error {
+	s := structPointer_Word32Slice(base, p.field)
+	l := s.Len()
+	if l == 0 {
+		return ErrNil
+	}
+	// TODO: Reuse a Buffer.
+	buf := NewBuffer(nil)
+	for i := 0; i < l; i++ {
+		p.valEnc(buf, uint64(s.Index(i)))
+	}
+
+	o.buf = append(o.buf, p.tagcode...)
+	o.EncodeVarint(uint64(len(buf.buf)))
+	o.buf = append(o.buf, buf.buf...)
+	return nil
+}
+
+func size_slice_packed_uint32(p *Properties, base structPointer) (n int) {
 	s := structPointer_Word32Slice(base, p.field)
 	l := s.Len()
 	if l == 0 {
@@ -738,7 +831,7 @@ func (o *Buffer) enc_slice_struct_message(p *Properties, base structPointer) err
 		}
 
 		o.buf = append(o.buf, p.tagcode...)
-		err := o.enc_len_struct(p.stype, p.sprop, structp, &state)
+		err := o.enc_len_struct(p.sprop, structp, &state)
 		if err != nil && !state.shouldContinue(err, nil) {
 			if err == ErrNil {
 				return ErrRepeatedHasNil
@@ -768,7 +861,7 @@ func size_slice_struct_message(p *Properties, base structPointer) (n int) {
 			continue
 		}
 
-		n0 := size_struct(p.stype, p.sprop, structp)
+		n0 := size_struct(p.sprop, structp)
 		n1 := sizeVarint(uint64(n0)) // size of encoded length
 		n += n0 + n1
 	}
@@ -789,7 +882,7 @@ func (o *Buffer) enc_slice_struct_group(p *Properties, base structPointer) error
 
 		o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup))
 
-		err := o.enc_struct(p.stype, p.sprop, b)
+		err := o.enc_struct(p.sprop, b)
 
 		if err != nil && !state.shouldContinue(err, nil) {
 			if err == ErrNil {
@@ -815,7 +908,7 @@ func size_slice_struct_group(p *Properties, base structPointer) (n int) {
 			return // return size up to this point
 		}
 
-		n += size_struct(p.stype, p.sprop, b)
+		n += size_struct(p.sprop, b)
 	}
 	return
 }
@@ -853,11 +946,11 @@ func size_map(p *Properties, base structPointer) int {
 }
 
 // Encode a struct.
-func (o *Buffer) enc_struct(t reflect.Type, prop *StructProperties, base structPointer) error {
+func (o *Buffer) enc_struct(prop *StructProperties, base structPointer) error {
 	var state errorState
 	// Encode fields in tag order so that decoders may use optimizations
 	// that depend on the ordering.
-	// http://code.google.com/apis/protocolbuffers/docs/encoding.html#order
+	// https://developers.google.com/protocol-buffers/docs/encoding#order
 	for _, i := range prop.order {
 		p := prop.Prop[i]
 		if p.enc != nil {
@@ -885,7 +978,7 @@ func (o *Buffer) enc_struct(t reflect.Type, prop *StructProperties, base structP
 	return state.err
 }
 
-func size_struct(t reflect.Type, prop *StructProperties, base structPointer) (n int) {
+func size_struct(prop *StructProperties, base structPointer) (n int) {
 	for _, i := range prop.order {
 		p := prop.Prop[i]
 		if p.size != nil {
@@ -905,11 +998,11 @@ func size_struct(t reflect.Type, prop *StructProperties, base structPointer) (n
 var zeroes [20]byte // longer than any conceivable sizeVarint
 
 // Encode a struct, preceded by its encoded length (as a varint).
-func (o *Buffer) enc_len_struct(t reflect.Type, prop *StructProperties, base structPointer, state *errorState) error {
+func (o *Buffer) enc_len_struct(prop *StructProperties, base structPointer, state *errorState) error {
 	iLen := len(o.buf)
 	o.buf = append(o.buf, 0, 0, 0, 0) // reserve four bytes for length
 	iMsg := len(o.buf)
-	err := o.enc_struct(t, prop, base)
+	err := o.enc_struct(prop, base)
 	if err != nil && !state.shouldContinue(err, nil) {
 		return err
 	}

+ 29 - 7
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/encode_gogo.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode_gogo.go

@@ -1,12 +1,12 @@
 // Extensions for Protocol Buffers to create more go like structures.
 //
 // Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
-// http://code.google.com/p/gogoprotobuf/gogoproto
+// http://github.com/gogo/protobuf/gogoproto
 //
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2010 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// http://github.com/golang/protobuf/
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -91,13 +91,35 @@ func (o *Buffer) enc_ref_int32(p *Properties, base structPointer) error {
 	if refWord32_IsNil(v) {
 		return ErrNil
 	}
-	x := refWord32_Get(v)
+	x := int32(refWord32_Get(v))
 	o.buf = append(o.buf, p.tagcode...)
 	p.valEnc(o, uint64(x))
 	return nil
 }
 
 func size_ref_int32(p *Properties, base structPointer) (n int) {
+	v := structPointer_RefWord32(base, p.field)
+	if refWord32_IsNil(v) {
+		return 0
+	}
+	x := int32(refWord32_Get(v))
+	n += len(p.tagcode)
+	n += p.valSize(uint64(x))
+	return
+}
+
+func (o *Buffer) enc_ref_uint32(p *Properties, base structPointer) error {
+	v := structPointer_RefWord32(base, p.field)
+	if refWord32_IsNil(v) {
+		return ErrNil
+	}
+	x := refWord32_Get(v)
+	o.buf = append(o.buf, p.tagcode...)
+	p.valEnc(o, uint64(x))
+	return nil
+}
+
+func size_ref_uint32(p *Properties, base structPointer) (n int) {
 	v := structPointer_RefWord32(base, p.field)
 	if refWord32_IsNil(v) {
 		return 0
@@ -175,7 +197,7 @@ func (o *Buffer) enc_ref_struct_message(p *Properties, base structPointer) error
 	}
 
 	o.buf = append(o.buf, p.tagcode...)
-	return o.enc_len_struct(p.stype, p.sprop, structp, &state)
+	return o.enc_len_struct(p.sprop, structp, &state)
 }
 
 //TODO this is only copied, please fix this
@@ -195,7 +217,7 @@ func size_ref_struct_message(p *Properties, base structPointer) int {
 	}
 
 	n0 := len(p.tagcode)
-	n1 := size_struct(p.stype, p.sprop, structp)
+	n1 := size_struct(p.sprop, structp)
 	n2 := sizeVarint(uint64(n1)) // size of encoded length
 	return n0 + n1 + n2
 }
@@ -226,7 +248,7 @@ func (o *Buffer) enc_slice_ref_struct_message(p *Properties, base structPointer)
 		}
 
 		o.buf = append(o.buf, p.tagcode...)
-		err := o.enc_len_struct(p.stype, p.sprop, structp, &state)
+		err := o.enc_len_struct(p.sprop, structp, &state)
 		if err != nil && !state.shouldContinue(err, nil) {
 			if err == ErrNil {
 				return ErrRepeatedHasNil
@@ -260,7 +282,7 @@ func size_slice_ref_struct_message(p *Properties, base structPointer) (n int) {
 			continue
 		}
 
-		n0 := size_struct(p.stype, p.sprop, structp)
+		n0 := size_struct(p.sprop, structp)
 		n1 := sizeVarint(uint64(n0)) // size of encoded length
 		n += n0 + n1
 	}

+ 2 - 2
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/equal.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/equal.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2011 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -57,7 +57,7 @@ Equality is defined in this way:
     although represented by []byte, is not a repeated field)
   - Two unset fields are equal.
   - Two unknown field sets are equal if their current
-    encoded state is equal. (TODO)
+    encoded state is equal.
   - Two extension sets are equal iff they have corresponding
     elements that are pairwise equal.
   - Every other combination of things are not equal.

+ 2 - 2
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/equal_test.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/equal_test.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2011 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -35,7 +35,7 @@ import (
 	"testing"
 
 	pb "./testdata"
-	. "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
+	. "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
 )
 
 // Four identical base messages.

+ 36 - 21
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/extensions.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2010 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -174,32 +174,39 @@ func extensionProperties(ed *ExtensionDesc) *Properties {
 // encodeExtensionMap encodes any unmarshaled (unencoded) extensions in m.
 func encodeExtensionMap(m map[int32]Extension) error {
 	for k, e := range m {
-		if e.value == nil || e.desc == nil {
-			// Extension is only in its encoded form.
-			continue
-		}
-
-		// We don't skip extensions that have an encoded form set,
-		// because the extension value may have been mutated after
-		// the last time this function was called.
-
-		et := reflect.TypeOf(e.desc.ExtensionType)
-		props := extensionProperties(e.desc)
-
-		p := NewBuffer(nil)
-		// If e.value has type T, the encoder expects a *struct{ X T }.
-		// Pass a *T with a zero field and hope it all works out.
-		x := reflect.New(et)
-		x.Elem().Set(reflect.ValueOf(e.value))
-		if err := props.enc(p, props, toStructPointer(x)); err != nil {
+		err := encodeExtension(&e)
+		if err != nil {
 			return err
 		}
-		e.enc = p.buf
 		m[k] = e
 	}
 	return nil
 }
 
+func encodeExtension(e *Extension) error {
+	if e.value == nil || e.desc == nil {
+		// Extension is only in its encoded form.
+		return nil
+	}
+	// We don't skip extensions that have an encoded form set,
+	// because the extension value may have been mutated after
+	// the last time this function was called.
+
+	et := reflect.TypeOf(e.desc.ExtensionType)
+	props := extensionProperties(e.desc)
+
+	p := NewBuffer(nil)
+	// If e.value has type T, the encoder expects a *struct{ X T }.
+	// Pass a *T with a zero field and hope it all works out.
+	x := reflect.New(et)
+	x.Elem().Set(reflect.ValueOf(e.value))
+	if err := props.enc(p, props, toStructPointer(x)); err != nil {
+		return err
+	}
+	e.enc = p.buf
+	return nil
+}
+
 func sizeExtensionMap(m map[int32]Extension) (n int) {
 	for _, e := range m {
 		if e.value == nil || e.desc == nil {
@@ -300,7 +307,8 @@ func GetExtension(pb extendableProto, extension *ExtensionDesc) (interface{}, er
 	}
 
 	if epb, doki := pb.(extensionsMap); doki {
-		e, ok := epb.ExtensionMap()[extension.Field]
+		emap := epb.ExtensionMap()
+		e, ok := emap[extension.Field]
 		if !ok {
 			return nil, ErrMissingExtension
 		}
@@ -325,6 +333,7 @@ func GetExtension(pb extendableProto, extension *ExtensionDesc) (interface{}, er
 		e.value = v
 		e.desc = extension
 		e.enc = nil
+		emap[extension.Field] = e
 		return e.value, nil
 	} else if epb, doki := pb.(extensionsBytes); doki {
 		ext := epb.GetExtensions()
@@ -395,6 +404,9 @@ func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, e
 	extensions = make([]interface{}, len(es))
 	for i, e := range es {
 		extensions[i], err = GetExtension(epb, e)
+		if err == ErrMissingExtension {
+			err = nil
+		}
 		if err != nil {
 			return
 		}
@@ -411,7 +423,10 @@ func SetExtension(pb extendableProto, extension *ExtensionDesc, value interface{
 	if typ != reflect.TypeOf(value) {
 		return errors.New("proto: bad extension value type")
 	}
+	return setExtension(pb, extension, value)
+}
 
+func setExtension(pb extendableProto, extension *ExtensionDesc, value interface{}) error {
 	if epb, doki := pb.(extensionsMap); doki {
 		epb.ExtensionMap()[extension.Field] = Extension{desc: extension, value: value}
 	} else if epb, doki := pb.(extensionsBytes); doki {

+ 33 - 1
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/extensions_gogo.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions_gogo.go

@@ -1,5 +1,5 @@
 // Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
-// http://code.google.com/p/gogoprotobuf/gogoproto
+// http://github.com/gogo/protobuf/gogoproto
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -28,6 +28,7 @@ package proto
 
 import (
 	"bytes"
+	"errors"
 	"fmt"
 	"reflect"
 	"sort"
@@ -185,5 +186,36 @@ func NewExtension(e []byte) Extension {
 }
 
 func (this Extension) GoString() string {
+	if this.enc == nil {
+		if err := encodeExtension(&this); err != nil {
+			panic(err)
+		}
+	}
 	return fmt.Sprintf("proto.NewExtension(%#v)", this.enc)
 }
+
+func SetUnsafeExtension(pb extendableProto, fieldNum int32, value interface{}) error {
+	typ := reflect.TypeOf(pb).Elem()
+	ext, ok := extensionMaps[typ]
+	if !ok {
+		return fmt.Errorf("proto: bad extended type; %s is not extendable", typ.String())
+	}
+	desc, ok := ext[fieldNum]
+	if !ok {
+		return errors.New("proto: bad extension number; not in declared ranges")
+	}
+	return setExtension(pb, desc, value)
+}
+
+func GetUnsafeExtension(pb extendableProto, fieldNum int32) (interface{}, error) {
+	typ := reflect.TypeOf(pb).Elem()
+	ext, ok := extensionMaps[typ]
+	if !ok {
+		return nil, fmt.Errorf("proto: bad extended type; %s is not extendable", typ.String())
+	}
+	desc, ok := ext[fieldNum]
+	if !ok {
+		return nil, fmt.Errorf("unregistered field number %d", fieldNum)
+	}
+	return GetExtension(pb, desc)
+}

+ 94 - 0
Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions_test.go

@@ -0,0 +1,94 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2014 The Go Authors.  All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package proto_test
+
+import (
+	"testing"
+
+	pb "./testdata"
+	"github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
+)
+
+func TestGetExtensionsWithMissingExtensions(t *testing.T) {
+	msg := &pb.MyMessage{}
+	ext1 := &pb.Ext{}
+	if err := proto.SetExtension(msg, pb.E_Ext_More, ext1); err != nil {
+		t.Fatalf("Could not set ext1: %s", ext1)
+	}
+	exts, err := proto.GetExtensions(msg, []*proto.ExtensionDesc{
+		pb.E_Ext_More,
+		pb.E_Ext_Text,
+	})
+	if err != nil {
+		t.Fatalf("GetExtensions() failed: %s", err)
+	}
+	if exts[0] != ext1 {
+		t.Errorf("ext1 not in returned extensions: %T %v", exts[0], exts[0])
+	}
+	if exts[1] != nil {
+		t.Errorf("ext2 in returned extensions: %T %v", exts[1], exts[1])
+	}
+}
+
+func TestGetExtensionStability(t *testing.T) {
+	check := func(m *pb.MyMessage) bool {
+		ext1, err := proto.GetExtension(m, pb.E_Ext_More)
+		if err != nil {
+			t.Fatalf("GetExtension() failed: %s", err)
+		}
+		ext2, err := proto.GetExtension(m, pb.E_Ext_More)
+		if err != nil {
+			t.Fatalf("GetExtension() failed: %s", err)
+		}
+		return ext1 == ext2
+	}
+	msg := &pb.MyMessage{Count: proto.Int32(4)}
+	ext0 := &pb.Ext{}
+	if err := proto.SetExtension(msg, pb.E_Ext_More, ext0); err != nil {
+		t.Fatalf("Could not set ext1: %s", ext0)
+	}
+	if !check(msg) {
+		t.Errorf("GetExtension() not stable before marshaling")
+	}
+	bb, err := proto.Marshal(msg)
+	if err != nil {
+		t.Fatalf("Marshal() failed: %s", err)
+	}
+	msg1 := &pb.MyMessage{}
+	err = proto.Unmarshal(bb, msg1)
+	if err != nil {
+		t.Fatalf("Unmarshal() failed: %s", err)
+	}
+	if !check(msg1) {
+		t.Errorf("GetExtension() not stable after unmarshaling")
+	}
+}

+ 4 - 4
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/lib.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2010 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -89,7 +89,7 @@
 
 		package example
 
-		import "code.google.com/p/gogoprotobuf/proto"
+		import "github.com/gogo/protobuf/proto"
 
 		type FOO int32
 		const (
@@ -168,7 +168,7 @@
 		import (
 			"log"
 
-			"code.google.com/p/gogoprotobuf/proto"
+			"github.com/gogo/protobuf/proto"
 			"./example.pb"
 		)
 
@@ -667,7 +667,7 @@ func buildDefaultMessage(t reflect.Type) (dm defaultMessage) {
 		}
 
 		// scalar fields without defaults
-		if prop.Default == "" {
+		if !prop.HasDefault {
 			dm.scalars = append(dm.scalars, sf)
 			continue
 		}

+ 1 - 1
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/lib_gogo.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib_gogo.go

@@ -1,5 +1,5 @@
 // Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
-// http://code.google.com/p/gogoprotobuf/gogoproto
+// http://github.com/gogo/protobuf/gogoproto
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are

+ 81 - 10
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/message_set.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/message_set.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2010 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -36,7 +36,10 @@ package proto
  */
 
 import (
+	"bytes"
+	"encoding/json"
 	"errors"
+	"fmt"
 	"reflect"
 	"sort"
 )
@@ -127,7 +130,7 @@ func (ms *MessageSet) Marshal(pb Message) error {
 
 	mti, ok := pb.(messageTypeIder)
 	if !ok {
-		return ErrWrongType // TODO: custom error?
+		return ErrNoMessageTypeId
 	}
 
 	mtid := mti.MessageTypeId()
@@ -188,16 +191,84 @@ func UnmarshalMessageSet(buf []byte, m map[int32]Extension) error {
 		return err
 	}
 	for _, item := range ms.Item {
-		// restore wire type and field number varint, plus length varint.
-		b := EncodeVarint(uint64(*item.TypeId)<<3 | WireBytes)
-		b = append(b, EncodeVarint(uint64(len(item.Message)))...)
-		b = append(b, item.Message...)
+		id := *item.TypeId
+		msg := item.Message
+
+		// Restore wire type and field number varint, plus length varint.
+		// Be careful to preserve duplicate items.
+		b := EncodeVarint(uint64(id)<<3 | WireBytes)
+		if ext, ok := m[id]; ok {
+			// Existing data; rip off the tag and length varint
+			// so we join the new data correctly.
+			// We can assume that ext.enc is set because we are unmarshaling.
+			o := ext.enc[len(b):]   // skip wire type and field number
+			_, n := DecodeVarint(o) // calculate length of length varint
+			o = o[n:]               // skip length varint
+			msg = append(o, msg...) // join old data and new data
+		}
+		b = append(b, EncodeVarint(uint64(len(msg)))...)
+		b = append(b, msg...)
 
-		m[*item.TypeId] = Extension{enc: b}
+		m[id] = Extension{enc: b}
 	}
 	return nil
 }
 
+// MarshalMessageSetJSON encodes the extension map represented by m in JSON format.
+// It is called by generated MarshalJSON methods on protocol buffer messages with the message_set_wire_format option.
+func MarshalMessageSetJSON(m map[int32]Extension) ([]byte, error) {
+	var b bytes.Buffer
+	b.WriteByte('{')
+
+	// Process the map in key order for deterministic output.
+	ids := make([]int32, 0, len(m))
+	for id := range m {
+		ids = append(ids, id)
+	}
+	sort.Sort(int32Slice(ids)) // int32Slice defined in text.go
+
+	for i, id := range ids {
+		ext := m[id]
+		if i > 0 {
+			b.WriteByte(',')
+		}
+
+		msd, ok := messageSetMap[id]
+		if !ok {
+			// Unknown type; we can't render it, so skip it.
+			continue
+		}
+		fmt.Fprintf(&b, `"[%s]":`, msd.name)
+
+		x := ext.value
+		if x == nil {
+			x = reflect.New(msd.t.Elem()).Interface()
+			if err := Unmarshal(ext.enc, x.(Message)); err != nil {
+				return nil, err
+			}
+		}
+		d, err := json.Marshal(x)
+		if err != nil {
+			return nil, err
+		}
+		b.Write(d)
+	}
+	b.WriteByte('}')
+	return b.Bytes(), nil
+}
+
+// UnmarshalMessageSetJSON decodes the extension map encoded in buf in JSON format.
+// It is called by generated UnmarshalJSON methods on protocol buffer messages with the message_set_wire_format option.
+func UnmarshalMessageSetJSON(buf []byte, m map[int32]Extension) error {
+	// Common-case fast path.
+	if len(buf) == 0 || bytes.Equal(buf, []byte("{}")) {
+		return nil
+	}
+
+	// This is fairly tricky, and it's not clear that it is needed.
+	return errors.New("TODO: UnmarshalMessageSetJSON not yet implemented")
+}
+
 // A global registry of types that can be used in a MessageSet.
 
 var messageSetMap = make(map[int32]messageSetDesc)
@@ -208,9 +279,9 @@ type messageSetDesc struct {
 }
 
 // RegisterMessageSetType is called from the generated code.
-func RegisterMessageSetType(i messageTypeIder, name string) {
-	messageSetMap[i.MessageTypeId()] = messageSetDesc{
-		t:    reflect.TypeOf(i),
+func RegisterMessageSetType(m Message, fieldNum int32, name string) {
+	messageSetMap[fieldNum] = messageSetDesc{
+		t:    reflect.TypeOf(m),
 		name: name,
 	}
 }

+ 66 - 0
Godeps/_workspace/src/github.com/gogo/protobuf/proto/message_set_test.go

@@ -0,0 +1,66 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2014 The Go Authors.  All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//     * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package proto
+
+import (
+	"bytes"
+	"testing"
+)
+
+func TestUnmarshalMessageSetWithDuplicate(t *testing.T) {
+	// Check that a repeated message set entry will be concatenated.
+	in := &MessageSet{
+		Item: []*_MessageSet_Item{
+			{TypeId: Int32(12345), Message: []byte("hoo")},
+			{TypeId: Int32(12345), Message: []byte("hah")},
+		},
+	}
+	b, err := Marshal(in)
+	if err != nil {
+		t.Fatalf("Marshal: %v", err)
+	}
+	t.Logf("Marshaled bytes: %q", b)
+
+	m := make(map[int32]Extension)
+	if err := UnmarshalMessageSet(b, m); err != nil {
+		t.Fatalf("UnmarshalMessageSet: %v", err)
+	}
+	ext, ok := m[12345]
+	if !ok {
+		t.Fatalf("Didn't retrieve extension 12345; map is %v", m)
+	}
+	// Skip wire type/field number and length varints.
+	got := skipVarint(skipVarint(ext.enc))
+	if want := []byte("hoohah"); !bytes.Equal(got, want) {
+		t.Errorf("Combined extension is %q, want %q", got, want)
+	}
+}

+ 2 - 2
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/pointer_reflect.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_reflect.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2012 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -29,7 +29,7 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-// +build appengine
+// +build appengine,!appenginevm
 
 // This file contains an implementation of proto field accesses using package reflect.
 // It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can

+ 2 - 2
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/pointer_unsafe.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2012 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -29,7 +29,7 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-// +build !appengine
+// +build !appengine appenginevm
 
 // This file contains the implementation of the proto field accesses using package unsafe.
 

+ 1 - 1
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/pointer_unsafe_gogo.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go

@@ -1,5 +1,5 @@
 // Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
-// http://code.google.com/p/gogoprotobuf/gogoproto
+// http://github.com/gogo/protobuf/gogoproto
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are

+ 65 - 52
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/properties.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties.go

@@ -1,12 +1,12 @@
 // Extensions for Protocol Buffers to create more go like structures.
 //
 // Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
-// http://code.google.com/p/gogoprotobuf/gogoproto
+// http://github.com/gogo/protobuf/gogoproto
 //
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2010 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -150,17 +150,19 @@ func (sp *StructProperties) Swap(i, j int) { sp.order[i], sp.order[j] = sp.order
 
 // Properties represents the protocol-specific behavior of a single struct field.
 type Properties struct {
-	Name       string // name of the field, for error messages
-	OrigName   string // original name before protocol compiler (always set)
-	Wire       string
-	WireType   int
-	Tag        int
-	Required   bool
-	Optional   bool
-	Repeated   bool
-	Packed     bool   // relevant for repeated primitives only
-	Enum       string // set for enum types only
+	Name     string // name of the field, for error messages
+	OrigName string // original name before protocol compiler (always set)
+	Wire     string
+	WireType int
+	Tag      int
+	Required bool
+	Optional bool
+	Repeated bool
+	Packed   bool   // relevant for repeated primitives only
+	Enum     string // set for enum types only
+
 	Default    string // default value
+	HasDefault bool   // whether an explicit default was provided
 	CustomType string
 	def_uint64 uint64
 
@@ -209,7 +211,7 @@ func (p *Properties) String() string {
 	if len(p.Enum) > 0 {
 		s += ",enum=" + p.Enum
 	}
-	if len(p.Default) > 0 {
+	if p.HasDefault {
 		s += ",def=" + p.Default
 	}
 	return s
@@ -281,6 +283,7 @@ func (p *Properties) Parse(s string) {
 		case strings.HasPrefix(f, "enum="):
 			p.Enum = f[5:]
 		case strings.HasPrefix(f, "def="):
+			p.HasDefault = true
 			p.Default = f[4:] // rest of string
 			if i+1 < len(fields) {
 				// Commas aren't escaped, and def is always last.
@@ -314,7 +317,7 @@ func (p *Properties) setEncAndDec(typ reflect.Type, lockGetProp bool) {
 	switch t1 := typ; t1.Kind() {
 	default:
 		if !p.setNonNullableEncAndDec(t1) {
-			fmt.Fprintf(os.Stderr, "proto: no coders for %T\n", t1)
+			fmt.Fprintf(os.Stderr, "proto: no coders for %v\n", t1)
 		}
 	case reflect.Ptr:
 		switch t2 := t1.Elem(); t2.Kind() {
@@ -325,18 +328,22 @@ func (p *Properties) setEncAndDec(typ reflect.Type, lockGetProp bool) {
 			p.enc = (*Buffer).enc_bool
 			p.dec = (*Buffer).dec_bool
 			p.size = size_bool
-		case reflect.Int32, reflect.Uint32:
+		case reflect.Int32:
 			p.enc = (*Buffer).enc_int32
 			p.dec = (*Buffer).dec_int32
 			p.size = size_int32
+		case reflect.Uint32:
+			p.enc = (*Buffer).enc_uint32
+			p.dec = (*Buffer).dec_int32 // can reuse
+			p.size = size_uint32
 		case reflect.Int64, reflect.Uint64:
 			p.enc = (*Buffer).enc_int64
 			p.dec = (*Buffer).dec_int64
 			p.size = size_int64
 		case reflect.Float32:
-			p.enc = (*Buffer).enc_int32 // can just treat them as bits
+			p.enc = (*Buffer).enc_uint32 // can just treat them as bits
 			p.dec = (*Buffer).dec_int32
-			p.size = size_int32
+			p.size = size_uint32
 		case reflect.Float64:
 			p.enc = (*Buffer).enc_int64 // can just treat them as bits
 			p.dec = (*Buffer).dec_int64
@@ -375,48 +382,50 @@ func (p *Properties) setEncAndDec(typ reflect.Type, lockGetProp bool) {
 			}
 			p.dec = (*Buffer).dec_slice_bool
 			p.packedDec = (*Buffer).dec_slice_packed_bool
-		case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
-			switch t2.Bits() {
-			case 32:
-				if p.Packed {
-					p.enc = (*Buffer).enc_slice_packed_int32
-					p.size = size_slice_packed_int32
-				} else {
-					p.enc = (*Buffer).enc_slice_int32
-					p.size = size_slice_int32
-				}
-				p.dec = (*Buffer).dec_slice_int32
-				p.packedDec = (*Buffer).dec_slice_packed_int32
-			case 64:
-				if p.Packed {
-					p.enc = (*Buffer).enc_slice_packed_int64
-					p.size = size_slice_packed_int64
-				} else {
-					p.enc = (*Buffer).enc_slice_int64
-					p.size = size_slice_int64
-				}
-				p.dec = (*Buffer).dec_slice_int64
-				p.packedDec = (*Buffer).dec_slice_packed_int64
-			case 8:
-				if t2.Kind() == reflect.Uint8 {
-					p.enc = (*Buffer).enc_slice_byte
-					p.dec = (*Buffer).dec_slice_byte
-					p.size = size_slice_byte
-				}
-			default:
-				logNoSliceEnc(t1, t2)
-				break
+		case reflect.Int32:
+			if p.Packed {
+				p.enc = (*Buffer).enc_slice_packed_int32
+				p.size = size_slice_packed_int32
+			} else {
+				p.enc = (*Buffer).enc_slice_int32
+				p.size = size_slice_int32
 			}
+			p.dec = (*Buffer).dec_slice_int32
+			p.packedDec = (*Buffer).dec_slice_packed_int32
+		case reflect.Uint32:
+			if p.Packed {
+				p.enc = (*Buffer).enc_slice_packed_uint32
+				p.size = size_slice_packed_uint32
+			} else {
+				p.enc = (*Buffer).enc_slice_uint32
+				p.size = size_slice_uint32
+			}
+			p.dec = (*Buffer).dec_slice_int32
+			p.packedDec = (*Buffer).dec_slice_packed_int32
+		case reflect.Int64, reflect.Uint64:
+			if p.Packed {
+				p.enc = (*Buffer).enc_slice_packed_int64
+				p.size = size_slice_packed_int64
+			} else {
+				p.enc = (*Buffer).enc_slice_int64
+				p.size = size_slice_int64
+			}
+			p.dec = (*Buffer).dec_slice_int64
+			p.packedDec = (*Buffer).dec_slice_packed_int64
+		case reflect.Uint8:
+			p.enc = (*Buffer).enc_slice_byte
+			p.dec = (*Buffer).dec_slice_byte
+			p.size = size_slice_byte
 		case reflect.Float32, reflect.Float64:
 			switch t2.Bits() {
 			case 32:
 				// can just treat them as bits
 				if p.Packed {
-					p.enc = (*Buffer).enc_slice_packed_int32
-					p.size = size_slice_packed_int32
+					p.enc = (*Buffer).enc_slice_packed_uint32
+					p.size = size_slice_packed_uint32
 				} else {
-					p.enc = (*Buffer).enc_slice_int32
-					p.size = size_slice_int32
+					p.enc = (*Buffer).enc_slice_uint32
+					p.size = size_slice_uint32
 				}
 				p.dec = (*Buffer).dec_slice_int32
 				p.packedDec = (*Buffer).dec_slice_packed_int32
@@ -539,7 +548,11 @@ var (
 )
 
 // GetProperties returns the list of properties for the type represented by t.
+// t must represent a generated struct type of a protocol message.
 func GetProperties(t reflect.Type) *StructProperties {
+	if t.Kind() != reflect.Struct {
+		panic("proto: type must have kind struct")
+	}
 	mutex.Lock()
 	sprop := getPropertiesLocked(t)
 	mutex.Unlock()

+ 8 - 4
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/properties_gogo.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties_gogo.go

@@ -1,5 +1,5 @@
 // Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
-// http://code.google.com/p/gogoprotobuf/gogoproto
+// http://github.com/gogo/protobuf/gogoproto
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -55,18 +55,22 @@ func (p *Properties) setNonNullableEncAndDec(typ reflect.Type) bool {
 		p.enc = (*Buffer).enc_ref_bool
 		p.dec = (*Buffer).dec_ref_bool
 		p.size = size_ref_bool
-	case reflect.Int32, reflect.Uint32:
+	case reflect.Int32:
 		p.enc = (*Buffer).enc_ref_int32
 		p.dec = (*Buffer).dec_ref_int32
 		p.size = size_ref_int32
+	case reflect.Uint32:
+		p.enc = (*Buffer).enc_ref_uint32
+		p.dec = (*Buffer).dec_ref_int32
+		p.size = size_ref_uint32
 	case reflect.Int64, reflect.Uint64:
 		p.enc = (*Buffer).enc_ref_int64
 		p.dec = (*Buffer).dec_ref_int64
 		p.size = size_ref_int64
 	case reflect.Float32:
-		p.enc = (*Buffer).enc_ref_int32 // can just treat them as bits
+		p.enc = (*Buffer).enc_ref_uint32 // can just treat them as bits
 		p.dec = (*Buffer).dec_ref_int32
-		p.size = size_ref_int32
+		p.size = size_ref_uint32
 	case reflect.Float64:
 		p.enc = (*Buffer).enc_ref_int64 // can just treat them as bits
 		p.dec = (*Buffer).dec_ref_int64

+ 1 - 1
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/size2_test.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/size2_test.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2012 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are

+ 5 - 3
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/size_test.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/size_test.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2012 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -36,7 +36,7 @@ import (
 	"testing"
 
 	pb "./testdata"
-	. "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
+	. "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
 )
 
 var messageWithExtension1 = &pb.MyMessage{Count: Int32(7)}
@@ -65,8 +65,10 @@ var SizeTests = []struct {
 	// Basic types.
 	{"bool", &pb.Defaults{F_Bool: Bool(true)}},
 	{"int32", &pb.Defaults{F_Int32: Int32(12)}},
+	{"negative int32", &pb.Defaults{F_Int32: Int32(-1)}},
 	{"small int64", &pb.Defaults{F_Int64: Int64(1)}},
 	{"big int64", &pb.Defaults{F_Int64: Int64(1 << 20)}},
+	{"negative int64", &pb.Defaults{F_Int64: Int64(-1)}},
 	{"fixed32", &pb.Defaults{F_Fixed32: Uint32(71)}},
 	{"fixed64", &pb.Defaults{F_Fixed64: Uint64(72)}},
 	{"uint32", &pb.Defaults{F_Uint32: Uint32(123)}},
@@ -83,7 +85,7 @@ var SizeTests = []struct {
 	{"empty repeated bool", &pb.MoreRepeated{Bools: []bool{}}},
 	{"repeated bool", &pb.MoreRepeated{Bools: []bool{false, true, true, false}}},
 	{"packed repeated bool", &pb.MoreRepeated{BoolsPacked: []bool{false, true, true, false, true, true, true}}},
-	{"repeated int32", &pb.MoreRepeated{Ints: []int32{1, 12203, 1729}}},
+	{"repeated int32", &pb.MoreRepeated{Ints: []int32{1, 12203, 1729, -1}}},
 	{"repeated int32 packed", &pb.MoreRepeated{IntsPacked: []int32{1, 12203, 1729}}},
 	{"repeated int64 packed", &pb.MoreRepeated{Int64SPacked: []int64{
 		// Need enough large numbers to verify that the header is counting the number of bytes

+ 3 - 2
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/skip_gogo.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/skip_gogo.go

@@ -1,5 +1,5 @@
 // Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
-// http://code.google.com/p/gogoprotobuf/gogoproto
+// http://github.com/gogo/protobuf/gogoproto
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -27,6 +27,7 @@
 package proto
 
 import (
+	"fmt"
 	"io"
 )
 
@@ -109,7 +110,7 @@ func Skip(data []byte) (n int, err error) {
 			index += 4
 			return index, nil
 		default:
-			return 0, ErrWrongType
+			return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
 		}
 	}
 	panic("unreachable")

+ 1 - 1
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/testdata/Makefile → Godeps/_workspace/src/github.com/gogo/protobuf/proto/testdata/Makefile

@@ -1,7 +1,7 @@
 # Go support for Protocol Buffers - Google's data interchange format
 #
 # Copyright 2010 The Go Authors.  All rights reserved.
-# http://code.google.com/p/goprotobuf/
+# https://github.com/golang/protobuf
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are

+ 1 - 1
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/testdata/golden_test.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/testdata/golden_test.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2012 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are

+ 38 - 8
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/testdata/test.pb.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/testdata/test.pb.go

@@ -36,13 +36,11 @@ It has these top-level messages:
 */
 package testdata
 
-import proto "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
-import json "encoding/json"
+import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
 import math "math"
 
-// Reference proto, json, and math imports to suppress error if they are not otherwise used.
+// Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal
-var _ = &json.SyntaxError{}
 var _ = math.Inf
 
 type FOO int32
@@ -1072,6 +1070,7 @@ func (m *MaxTag) GetLastField() string {
 
 type OldMessage struct {
 	Nested           *OldMessage_Nested `protobuf:"bytes,1,opt,name=nested" json:"nested,omitempty"`
+	Num              *int32             `protobuf:"varint,2,opt,name=num" json:"num,omitempty"`
 	XXX_unrecognized []byte             `json:"-"`
 }
 
@@ -1086,6 +1085,13 @@ func (m *OldMessage) GetNested() *OldMessage_Nested {
 	return nil
 }
 
+func (m *OldMessage) GetNum() int32 {
+	if m != nil && m.Num != nil {
+		return *m.Num
+	}
+	return 0
+}
+
 type OldMessage_Nested struct {
 	Name             *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
 	XXX_unrecognized []byte  `json:"-"`
@@ -1105,8 +1111,10 @@ func (m *OldMessage_Nested) GetName() string {
 // NewMessage is wire compatible with OldMessage;
 // imagine it as a future version.
 type NewMessage struct {
-	Nested           *NewMessage_Nested `protobuf:"bytes,1,opt,name=nested" json:"nested,omitempty"`
-	XXX_unrecognized []byte             `json:"-"`
+	Nested *NewMessage_Nested `protobuf:"bytes,1,opt,name=nested" json:"nested,omitempty"`
+	// This is an int32 in OldMessage.
+	Num              *int64 `protobuf:"varint,2,opt,name=num" json:"num,omitempty"`
+	XXX_unrecognized []byte `json:"-"`
 }
 
 func (m *NewMessage) Reset()         { *m = NewMessage{} }
@@ -1120,6 +1128,13 @@ func (m *NewMessage) GetNested() *NewMessage_Nested {
 	return nil
 }
 
+func (m *NewMessage) GetNum() int64 {
+	if m != nil && m.Num != nil {
+		return *m.Num
+	}
+	return 0
+}
+
 type NewMessage_Nested struct {
 	Name             *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
 	FoodGroup        *string `protobuf:"bytes,2,opt,name=food_group" json:"food_group,omitempty"`
@@ -1401,6 +1416,12 @@ func (m *MyMessageSet) Marshal() ([]byte, error) {
 func (m *MyMessageSet) Unmarshal(buf []byte) error {
 	return proto.UnmarshalMessageSet(buf, m.ExtensionMap())
 }
+func (m *MyMessageSet) MarshalJSON() ([]byte, error) {
+	return proto.MarshalMessageSetJSON(m.XXX_extensions)
+}
+func (m *MyMessageSet) UnmarshalJSON(buf []byte) error {
+	return proto.UnmarshalMessageSetJSON(buf, m.XXX_extensions)
+}
 
 // ensure MyMessageSet satisfies proto.Marshaler and proto.Unmarshaler
 var _ proto.Marshaler = (*MyMessageSet)(nil)
@@ -1514,8 +1535,10 @@ type Defaults struct {
 	F_Ninf *float32 `protobuf:"fixed32,16,opt,def=-inf" json:"F_Ninf,omitempty"`
 	F_Nan  *float32 `protobuf:"fixed32,17,opt,def=nan" json:"F_Nan,omitempty"`
 	// Sub-message.
-	Sub              *SubDefaults `protobuf:"bytes,18,opt,name=sub" json:"sub,omitempty"`
-	XXX_unrecognized []byte       `json:"-"`
+	Sub *SubDefaults `protobuf:"bytes,18,opt,name=sub" json:"sub,omitempty"`
+	// Redundant but explicit defaults.
+	StrZero          *string `protobuf:"bytes,19,opt,name=str_zero,def=" json:"str_zero,omitempty"`
+	XXX_unrecognized []byte  `json:"-"`
 }
 
 func (m *Defaults) Reset()         { *m = Defaults{} }
@@ -1669,6 +1692,13 @@ func (m *Defaults) GetSub() *SubDefaults {
 	return nil
 }
 
+func (m *Defaults) GetStrZero() string {
+	if m != nil && m.StrZero != nil {
+		return *m.StrZero
+	}
+	return ""
+}
+
 type SubDefaults struct {
 	N                *int64 `protobuf:"varint,1,opt,name=n,def=7" json:"n,omitempty"`
 	XXX_unrecognized []byte `json:"-"`

+ 1 - 1
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/testdata/test.pb.go.golden → Godeps/_workspace/src/github.com/gogo/protobuf/proto/testdata/test.pb.go.golden

@@ -4,7 +4,7 @@
 
 package testdata
 
-import proto "code.google.com/p/gogoprotobuf/proto"
+import proto "github.com/gogo/protobuf/proto"
 import json "encoding/json"
 import math "math"
 

+ 9 - 1
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/testdata/test.proto → Godeps/_workspace/src/github.com/gogo/protobuf/proto/testdata/test.proto

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2010 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -203,6 +203,8 @@ message OldMessage {
     optional string name = 1;
   }
   optional Nested nested = 1;
+
+  optional int32 num = 2;
 }
 
 // NewMessage is wire compatible with OldMessage;
@@ -213,6 +215,9 @@ message NewMessage {
     optional string food_group = 2;
   }
   optional Nested nested = 1;
+
+  // This is an int32 in OldMessage.
+  optional int64 num = 2;
 }
 
 // Smaller tests for ASCII formatting.
@@ -376,6 +381,9 @@ message Defaults {
 
   // Sub-message.
   optional SubDefaults sub = 18;
+
+  // Redundant but explicit defaults.
+  optional string str_zero = 19 [default=""];
 }
 
 message SubDefaults {

+ 16 - 13
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/text.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/text.go

@@ -1,12 +1,12 @@
 // Extensions for Protocol Buffers to create more go like structures.
 //
 // Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
-// http://code.google.com/p/gogoprotobuf/gogoproto
+// http://github.com/gogo/protobuf/gogoproto
 //
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2010 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -41,6 +41,7 @@ package proto
 import (
 	"bufio"
 	"bytes"
+	"encoding"
 	"fmt"
 	"io"
 	"log"
@@ -79,13 +80,6 @@ type textWriter struct {
 	w        writer
 }
 
-// textMarshaler is implemented by Messages that can marshal themsleves.
-// It is identical to encoding.TextMarshaler, introduced in go 1.2,
-// which will eventually replace it.
-type textMarshaler interface {
-	MarshalText() (text []byte, err error)
-}
-
 func (w *textWriter) WriteString(s string) (n int, err error) {
 	if !strings.Contains(s, "\n") {
 		if !w.compact && w.complete {
@@ -237,11 +231,20 @@ func writeStruct(w *textWriter, sv reflect.Value) error {
 						return err
 					}
 				}
+				v := fv.Index(j)
+				if v.Kind() == reflect.Ptr && v.IsNil() {
+					// A nil message in a repeated field is not valid,
+					// but we can handle that more gracefully than panicking.
+					if _, err := w.Write([]byte("<nil>\n")); err != nil {
+						return err
+					}
+					continue
+				}
 				if len(props.Enum) > 0 {
-					if err := writeEnum(w, fv.Index(j), props); err != nil {
+					if err := writeEnum(w, v, props); err != nil {
 						return err
 					}
-				} else if err := writeAny(w, fv.Index(j), props); err != nil {
+				} else if err := writeAny(w, v, props); err != nil {
 					return err
 				}
 				if err := w.WriteByte('\n'); err != nil {
@@ -373,7 +376,7 @@ func writeAny(w *textWriter, v reflect.Value, props *Properties) error {
 			}
 		}
 		w.indent()
-		if tm, ok := v.Interface().(textMarshaler); ok {
+		if tm, ok := v.Interface().(encoding.TextMarshaler); ok {
 			text, err := tm.MarshalText()
 			if err != nil {
 				return err
@@ -679,7 +682,7 @@ func marshalText(w io.Writer, pb Message, compact bool) error {
 		compact:  compact,
 	}
 
-	if tm, ok := pb.(textMarshaler); ok {
+	if tm, ok := pb.(encoding.TextMarshaler); ok {
 		text, err := tm.MarshalText()
 		if err != nil {
 			return err

+ 1 - 1
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/text_gogo.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_gogo.go

@@ -1,5 +1,5 @@
 // Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
-// http://code.google.com/p/gogoprotobuf/gogoproto
+// http://github.com/gogo/protobuf/gogoproto
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are

+ 33 - 28
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/text_parser.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser.go

@@ -1,12 +1,12 @@
 // Extensions for Protocol Buffers to create more go like structures.
 //
 // Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
-// http://code.google.com/p/gogoprotobuf/gogoproto
+// http://github.com/gogo/protobuf/gogoproto
 //
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2010 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -40,6 +40,7 @@ package proto
 // TODO: message sets.
 
 import (
+	"encoding"
 	"errors"
 	"fmt"
 	"reflect"
@@ -48,13 +49,6 @@ import (
 	"unicode/utf8"
 )
 
-// textUnmarshaler is implemented by Messages that can unmarshal themsleves.
-// It is identical to encoding.TextUnmarshaler, introduced in go 1.2,
-// which will eventually replace it.
-type textUnmarshaler interface {
-	UnmarshalText(text []byte) error
-}
-
 type ParseError struct {
 	Message string
 	Line    int // 1-based line number
@@ -366,8 +360,8 @@ func (p *textParser) next() *token {
 	return &p.cur
 }
 
-// Return an error indicating which required field was not set.
-func (p *textParser) missingRequiredFieldError(sv reflect.Value) *ParseError {
+// Return a RequiredNotSetError indicating which required field was not set.
+func (p *textParser) missingRequiredFieldError(sv reflect.Value) *RequiredNotSetError {
 	st := sv.Type()
 	sprops := GetProperties(st)
 	for i := 0; i < st.NumField(); i++ {
@@ -377,10 +371,10 @@ func (p *textParser) missingRequiredFieldError(sv reflect.Value) *ParseError {
 
 		props := sprops.Prop[i]
 		if props.Required {
-			return p.errorf("message %v missing required field %q", st, props.OrigName)
+			return &RequiredNotSetError{fmt.Sprintf("%v.%v", st, props.OrigName)}
 		}
 	}
-	return p.errorf("message %v missing required field", st) // should not happen
+	return &RequiredNotSetError{fmt.Sprintf("%v.<unknown field name>", st)} // should not happen
 }
 
 // Returns the index in the struct for the named field, as well as the parsed tag properties.
@@ -431,9 +425,11 @@ func (p *textParser) checkForColon(props *Properties, typ reflect.Type) *ParseEr
 	return nil
 }
 
-func (p *textParser) readStruct(sv reflect.Value, terminator string) *ParseError {
+func (p *textParser) readStruct(sv reflect.Value, terminator string) error {
 	st := sv.Type()
 	reqCount := GetProperties(st).reqCount
+	var reqFieldErr error
+	fieldSet := make(map[string]bool)
 	// A struct is a sequence of "name: value", terminated by one of
 	// '>' or '}', or the end of the input.  A name may also be
 	// "[extension]".
@@ -494,7 +490,10 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) *ParseError
 				ext = reflect.New(typ.Elem()).Elem()
 			}
 			if err := p.readAny(ext, props); err != nil {
-				return err
+				if _, ok := err.(*RequiredNotSetError); !ok {
+					return err
+				}
+				reqFieldErr = err
 			}
 			ep := sv.Addr().Interface().(extendableProto)
 			if !rep {
@@ -512,17 +511,17 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) *ParseError
 			}
 		} else {
 			// This is a normal, non-extension field.
-			fi, props, ok := structFieldByName(st, tok.value)
+			name := tok.value
+			fi, props, ok := structFieldByName(st, name)
 			if !ok {
-				return p.errorf("unknown field name %q in %v", tok.value, st)
+				return p.errorf("unknown field name %q in %v", name, st)
 			}
 
 			dst := sv.Field(fi)
-			isDstNil := isNil(dst)
 
 			// Check that it's not already set if it's not a repeated field.
-			if !props.Repeated && !isDstNil && dst.Kind() == reflect.Ptr {
-				return p.errorf("non-repeated field %q was repeated", tok.value)
+			if !props.Repeated && fieldSet[name] {
+				return p.errorf("non-repeated field %q was repeated", name)
 			}
 
 			if err := p.checkForColon(props, st.Field(fi).Type); err != nil {
@@ -530,11 +529,13 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) *ParseError
 			}
 
 			// Parse into the field.
+			fieldSet[name] = true
 			if err := p.readAny(dst, props); err != nil {
-				return err
-			}
-
-			if props.Required {
+				if _, ok := err.(*RequiredNotSetError); !ok {
+					return err
+				}
+				reqFieldErr = err
+			} else if props.Required {
 				reqCount--
 			}
 		}
@@ -552,10 +553,10 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) *ParseError
 	if reqCount > 0 {
 		return p.missingRequiredFieldError(sv)
 	}
-	return nil
+	return reqFieldErr
 }
 
-func (p *textParser) readAny(v reflect.Value, props *Properties) *ParseError {
+func (p *textParser) readAny(v reflect.Value, props *Properties) error {
 	tok := p.next()
 	if tok.err != nil {
 		return tok.err
@@ -655,6 +656,7 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) *ParseError {
 			fv.SetInt(x)
 			return nil
 		}
+
 		if len(props.Enum) == 0 {
 			break
 		}
@@ -673,6 +675,7 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) *ParseError {
 			fv.SetInt(x)
 			return nil
 		}
+
 	case reflect.Ptr:
 		// A basic field (indirected through pointer), or a repeated message/group
 		p.back()
@@ -693,7 +696,7 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) *ParseError {
 		default:
 			return p.errorf("expected '{' or '<', found %q", tok.value)
 		}
-		// TODO: Handle nested messages which implement textUnmarshaler.
+		// TODO: Handle nested messages which implement encoding.TextUnmarshaler.
 		return p.readStruct(fv, terminator)
 	case reflect.Uint32:
 		if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil {
@@ -711,8 +714,10 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) *ParseError {
 
 // UnmarshalText reads a protocol buffer in Text format. UnmarshalText resets pb
 // before starting to unmarshal, so any existing data in pb is always removed.
+// If a required field is not set and no other error occurs,
+// UnmarshalText returns *RequiredNotSetError.
 func UnmarshalText(s string, pb Message) error {
-	if um, ok := pb.(textUnmarshaler); ok {
+	if um, ok := pb.(encoding.TextUnmarshaler); ok {
 		err := um.UnmarshalText([]byte(s))
 		return err
 	}

+ 12 - 6
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/text_parser_test.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser_test.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2010 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -37,7 +37,7 @@ import (
 	"testing"
 
 	. "./testdata"
-	. "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
+	. "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
 )
 
 type UnmarshalTextTest struct {
@@ -156,8 +156,8 @@ var unMarshalTextTests = []UnmarshalTextTest{
 
 	// Number too large for int64
 	{
-		in:  "count: 123456789012345678901",
-		err: "line 1.7: invalid int32: 123456789012345678901",
+		in:  "count: 1 others { key: 123456789012345678901 }",
+		err: "line 1.23: invalid int64: 123456789012345678901",
 	},
 
 	// Number too large for int32
@@ -294,8 +294,11 @@ var unMarshalTextTests = []UnmarshalTextTest{
 
 	// Missing required field
 	{
-		in:  ``,
-		err: `line 1.0: message testdata.MyMessage missing required field "count"`,
+		in:  `name: "Pawel"`,
+		err: `proto: required field "testdata.MyMessage.count" not set`,
+		out: &MyMessage{
+			Name: String("Pawel"),
+		},
 	},
 
 	// Repeated non-repeated field
@@ -408,6 +411,9 @@ func TestUnmarshalText(t *testing.T) {
 			} else if err.Error() != test.err {
 				t.Errorf("Test %d: Incorrect error.\nHave: %v\nWant: %v",
 					i, err.Error(), test.err)
+			} else if _, ok := err.(*RequiredNotSetError); ok && test.out != nil && !reflect.DeepEqual(pb, test.out) {
+				t.Errorf("Test %d: Incorrect populated \nHave: %v\nWant: %v",
+					i, pb, test.out)
 			}
 		}
 	}

+ 23 - 3
Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto/text_test.go → Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_test.go

@@ -1,7 +1,7 @@
 // Go support for Protocol Buffers - Google's data interchange format
 //
 // Copyright 2010 The Go Authors.  All rights reserved.
-// http://code.google.com/p/goprotobuf/
+// https://github.com/golang/protobuf
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
@@ -39,9 +39,8 @@ import (
 	"strings"
 	"testing"
 
-	"github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
-
 	pb "./testdata"
+	"github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
 )
 
 // textMessage implements the methods that allow it to marshal and unmarshal
@@ -385,3 +384,24 @@ func TestFloats(t *testing.T) {
 		}
 	}
 }
+
+func TestRepeatedNilText(t *testing.T) {
+	m := &pb.MessageList{
+		Message: []*pb.MessageList_Message{
+			nil,
+			{
+				Name: proto.String("Horse"),
+			},
+			nil,
+		},
+	}
+	want := `Message <nil>
+Message {
+  name: "Horse"
+}
+Message <nil>
+`
+	if s := proto.MarshalTextString(m); s != want {
+		t.Errorf(" got: %s\nwant: %s", s, want)
+	}
+}

+ 28 - 26
etcdserver/etcdserverpb/etcdserver.pb.go

@@ -14,18 +14,17 @@
 */
 package etcdserverpb
 
-import proto "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
-import json "encoding/json"
+import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
 import math "math"
 
-// discarding unused import gogoproto "code.google.com/p/gogoprotobuf/gogoproto/gogo.pb"
+// discarding unused import gogoproto "github.com/gogo/protobuf/gogoproto/gogo.pb"
 
 import io "io"
-import code_google_com_p_gogoprotobuf_proto "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
+import fmt "fmt"
+import github_com_gogo_protobuf_proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
 
-// Reference proto, json, and math imports to suppress error if they are not otherwise used.
+// Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal
-var _ = &json.SyntaxError{}
 var _ = math.Inf
 
 type Request struct {
@@ -85,7 +84,7 @@ func (m *Request) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -100,7 +99,7 @@ func (m *Request) Unmarshal(data []byte) error {
 			}
 		case 2:
 			if wireType != 2 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Method", wireType)
 			}
 			var stringLen uint64
 			for shift := uint(0); ; shift += 7 {
@@ -122,7 +121,7 @@ func (m *Request) Unmarshal(data []byte) error {
 			index = postIndex
 		case 3:
 			if wireType != 2 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType)
 			}
 			var stringLen uint64
 			for shift := uint(0); ; shift += 7 {
@@ -144,7 +143,7 @@ func (m *Request) Unmarshal(data []byte) error {
 			index = postIndex
 		case 4:
 			if wireType != 2 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Val", wireType)
 			}
 			var stringLen uint64
 			for shift := uint(0); ; shift += 7 {
@@ -166,7 +165,7 @@ func (m *Request) Unmarshal(data []byte) error {
 			index = postIndex
 		case 5:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Dir", wireType)
 			}
 			var v int
 			for shift := uint(0); ; shift += 7 {
@@ -183,7 +182,7 @@ func (m *Request) Unmarshal(data []byte) error {
 			m.Dir = bool(v != 0)
 		case 6:
 			if wireType != 2 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field PrevValue", wireType)
 			}
 			var stringLen uint64
 			for shift := uint(0); ; shift += 7 {
@@ -205,7 +204,7 @@ func (m *Request) Unmarshal(data []byte) error {
 			index = postIndex
 		case 7:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field PrevIndex", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -220,7 +219,7 @@ func (m *Request) Unmarshal(data []byte) error {
 			}
 		case 8:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field PrevExist", wireType)
 			}
 			var v int
 			for shift := uint(0); ; shift += 7 {
@@ -238,7 +237,7 @@ func (m *Request) Unmarshal(data []byte) error {
 			m.PrevExist = &b
 		case 9:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -253,7 +252,7 @@ func (m *Request) Unmarshal(data []byte) error {
 			}
 		case 10:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Wait", wireType)
 			}
 			var v int
 			for shift := uint(0); ; shift += 7 {
@@ -270,7 +269,7 @@ func (m *Request) Unmarshal(data []byte) error {
 			m.Wait = bool(v != 0)
 		case 11:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Since", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -285,7 +284,7 @@ func (m *Request) Unmarshal(data []byte) error {
 			}
 		case 12:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Recursive", wireType)
 			}
 			var v int
 			for shift := uint(0); ; shift += 7 {
@@ -302,7 +301,7 @@ func (m *Request) Unmarshal(data []byte) error {
 			m.Recursive = bool(v != 0)
 		case 13:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Sorted", wireType)
 			}
 			var v int
 			for shift := uint(0); ; shift += 7 {
@@ -319,7 +318,7 @@ func (m *Request) Unmarshal(data []byte) error {
 			m.Sorted = bool(v != 0)
 		case 14:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Quorum", wireType)
 			}
 			var v int
 			for shift := uint(0); ; shift += 7 {
@@ -336,7 +335,7 @@ func (m *Request) Unmarshal(data []byte) error {
 			m.Quorum = bool(v != 0)
 		case 15:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -351,7 +350,7 @@ func (m *Request) Unmarshal(data []byte) error {
 			}
 		case 16:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Stream", wireType)
 			}
 			var v int
 			for shift := uint(0); ; shift += 7 {
@@ -376,7 +375,7 @@ func (m *Request) Unmarshal(data []byte) error {
 				}
 			}
 			index -= sizeOfWire
-			skippy, err := code_google_com_p_gogoprotobuf_proto.Skip(data[index:])
+			skippy, err := github_com_gogo_protobuf_proto.Skip(data[index:])
 			if err != nil {
 				return err
 			}
@@ -410,7 +409,7 @@ func (m *Metadata) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field NodeID", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -425,7 +424,7 @@ func (m *Metadata) Unmarshal(data []byte) error {
 			}
 		case 2:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field ClusterID", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -448,7 +447,7 @@ func (m *Metadata) Unmarshal(data []byte) error {
 				}
 			}
 			index -= sizeOfWire
-			skippy, err := code_google_com_p_gogoprotobuf_proto.Skip(data[index:])
+			skippy, err := github_com_gogo_protobuf_proto.Skip(data[index:])
 			if err != nil {
 				return err
 			}
@@ -491,6 +490,7 @@ func (m *Request) Size() (n int) {
 	}
 	return n
 }
+
 func (m *Metadata) Size() (n int) {
 	var l int
 	_ = l
@@ -626,6 +626,7 @@ func (m *Request) MarshalTo(data []byte) (n int, err error) {
 	}
 	return i, nil
 }
+
 func (m *Metadata) Marshal() (data []byte, err error) {
 	size := m.Size()
 	data = make([]byte, size)
@@ -652,6 +653,7 @@ func (m *Metadata) MarshalTo(data []byte) (n int, err error) {
 	}
 	return i, nil
 }
+
 func encodeFixed64Etcdserver(data []byte, offset int, v uint64) int {
 	data[offset] = uint8(v)
 	data[offset+1] = uint8(v >> 8)

+ 1 - 1
etcdserver/etcdserverpb/etcdserver.proto

@@ -1,6 +1,6 @@
 package etcdserverpb;
 
-import "code.google.com/p/gogoprotobuf/gogoproto/gogo.proto";
+import "github.com/gogo/protobuf/gogoproto/gogo.proto";
 
 option (gogoproto.marshaler_all) = true;
 option (gogoproto.sizer_all) = true;

+ 53 - 45
migrate/etcd4pb/log_entry.pb.go

@@ -2,34 +2,36 @@
 // source: log_entry.proto
 // DO NOT EDIT!
 
+/*
+	Package protobuf is a generated protocol buffer package.
+
+	It is generated from these files:
+		log_entry.proto
+
+	It has these top-level messages:
+		LogEntry
+*/
 package protobuf
 
-import proto "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
-import json "encoding/json"
+import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
 import math "math"
 
-// discarding unused import gogoproto "code.google.com/p/gogoprotobuf/gogoproto/gogo.pb"
+// discarding unused import gogoproto "github.com/gogo/protobuf/gogoproto/gogo.pb"
 
 import io "io"
-import code_google_com_p_gogoprotobuf_proto "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
-
 import fmt "fmt"
+import github_com_gogo_protobuf_proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
+
 import strings "strings"
 import reflect "reflect"
 
-import fmt1 "fmt"
-import strings1 "strings"
-import code_google_com_p_gogoprotobuf_proto1 "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
 import sort "sort"
 import strconv "strconv"
-import reflect1 "reflect"
 
-import fmt2 "fmt"
 import bytes "bytes"
 
-// Reference proto, json, and math imports to suppress error if they are not otherwise used.
+// Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal
-var _ = &json.SyntaxError{}
 var _ = math.Inf
 
 type LogEntry struct {
@@ -94,7 +96,7 @@ func (m *LogEntry) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -111,7 +113,7 @@ func (m *LogEntry) Unmarshal(data []byte) error {
 			m.Index = &v
 		case 2:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Term", wireType)
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -128,7 +130,7 @@ func (m *LogEntry) Unmarshal(data []byte) error {
 			m.Term = &v
 		case 3:
 			if wireType != 2 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field CommandName", wireType)
 			}
 			var stringLen uint64
 			for shift := uint(0); ; shift += 7 {
@@ -151,7 +153,7 @@ func (m *LogEntry) Unmarshal(data []byte) error {
 			index = postIndex
 		case 4:
 			if wireType != 2 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Command", wireType)
 			}
 			var byteLen int
 			for shift := uint(0); ; shift += 7 {
@@ -169,7 +171,7 @@ func (m *LogEntry) Unmarshal(data []byte) error {
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
-			m.Command = append(m.Command, data[index:postIndex]...)
+			m.Command = append([]byte{}, data[index:postIndex]...)
 			index = postIndex
 		default:
 			var sizeOfWire int
@@ -181,7 +183,7 @@ func (m *LogEntry) Unmarshal(data []byte) error {
 				}
 			}
 			index -= sizeOfWire
-			skippy, err := code_google_com_p_gogoprotobuf_proto.Skip(data[index:])
+			skippy, err := github_com_gogo_protobuf_proto.Skip(data[index:])
 			if err != nil {
 				return err
 			}
@@ -283,11 +285,7 @@ type randyLogEntry interface {
 }
 
 func randUTF8RuneLogEntry(r randyLogEntry) rune {
-	res := rune(r.Uint32() % 1112064)
-	if 55296 <= res {
-		res += 2047
-	}
-	return res
+	return rune(r.Intn(126-43) + 43)
 }
 func randStringLogEntry(r randyLogEntry) string {
 	v5 := r.Intn(100)
@@ -314,7 +312,11 @@ func randFieldLogEntry(data []byte, r randyLogEntry, fieldNumber int, wire int)
 	switch wire {
 	case 0:
 		data = encodeVarintPopulateLogEntry(data, uint64(key))
-		data = encodeVarintPopulateLogEntry(data, uint64(r.Int63()))
+		v6 := r.Int63()
+		if r.Intn(2) == 0 {
+			v6 *= -1
+		}
+		data = encodeVarintPopulateLogEntry(data, uint64(v6))
 	case 1:
 		data = encodeVarintPopulateLogEntry(data, uint64(key))
 		data = append(data, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
@@ -381,6 +383,7 @@ func (m *LogEntry) MarshalTo(data []byte) (n int, err error) {
 	}
 	return i, nil
 }
+
 func encodeFixed64LogEntry(data []byte, offset int, v uint64) int {
 	data[offset] = uint8(v)
 	data[offset+1] = uint8(v >> 8)
@@ -412,18 +415,23 @@ func (this *LogEntry) GoString() string {
 	if this == nil {
 		return "nil"
 	}
-	s := strings1.Join([]string{`&protobuf.LogEntry{` + `Index:` + valueToGoStringLogEntry(this.Index, "uint64"), `Term:` + valueToGoStringLogEntry(this.Term, "uint64"), `CommandName:` + valueToGoStringLogEntry(this.CommandName, "string"), `Command:` + valueToGoStringLogEntry(this.Command, "byte"), `XXX_unrecognized:` + fmt1.Sprintf("%#v", this.XXX_unrecognized) + `}`}, ", ")
+	s := strings.Join([]string{`&protobuf.LogEntry{` +
+		`Index:` + valueToGoStringLogEntry(this.Index, "uint64"),
+		`Term:` + valueToGoStringLogEntry(this.Term, "uint64"),
+		`CommandName:` + valueToGoStringLogEntry(this.CommandName, "string"),
+		`Command:` + valueToGoStringLogEntry(this.Command, "byte"),
+		`XXX_unrecognized:` + fmt.Sprintf("%#v", this.XXX_unrecognized) + `}`}, ", ")
 	return s
 }
 func valueToGoStringLogEntry(v interface{}, typ string) string {
-	rv := reflect1.ValueOf(v)
+	rv := reflect.ValueOf(v)
 	if rv.IsNil() {
 		return "nil"
 	}
-	pv := reflect1.Indirect(rv).Interface()
-	return fmt1.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
+	pv := reflect.Indirect(rv).Interface()
+	return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
 }
-func extensionToGoStringLogEntry(e map[int32]code_google_com_p_gogoprotobuf_proto1.Extension) string {
+func extensionToGoStringLogEntry(e map[int32]github_com_gogo_protobuf_proto.Extension) string {
 	if e == nil {
 		return "nil"
 	}
@@ -437,7 +445,7 @@ func extensionToGoStringLogEntry(e map[int32]code_google_com_p_gogoprotobuf_prot
 	for _, k := range keys {
 		ss = append(ss, strconv.Itoa(k)+": "+e[int32(k)].GoString())
 	}
-	s += strings1.Join(ss, ",") + "}"
+	s += strings.Join(ss, ",") + "}"
 	return s
 }
 func (this *LogEntry) VerboseEqual(that interface{}) error {
@@ -445,53 +453,53 @@ func (this *LogEntry) VerboseEqual(that interface{}) error {
 		if this == nil {
 			return nil
 		}
-		return fmt2.Errorf("that == nil && this != nil")
+		return fmt.Errorf("that == nil && this != nil")
 	}
 
 	that1, ok := that.(*LogEntry)
 	if !ok {
-		return fmt2.Errorf("that is not of type *LogEntry")
+		return fmt.Errorf("that is not of type *LogEntry")
 	}
 	if that1 == nil {
 		if this == nil {
 			return nil
 		}
-		return fmt2.Errorf("that is type *LogEntry but is nil && this != nil")
+		return fmt.Errorf("that is type *LogEntry but is nil && this != nil")
 	} else if this == nil {
-		return fmt2.Errorf("that is type *LogEntrybut is not nil && this == nil")
+		return fmt.Errorf("that is type *LogEntrybut is not nil && this == nil")
 	}
 	if this.Index != nil && that1.Index != nil {
 		if *this.Index != *that1.Index {
-			return fmt2.Errorf("Index this(%v) Not Equal that(%v)", *this.Index, *that1.Index)
+			return fmt.Errorf("Index this(%v) Not Equal that(%v)", *this.Index, *that1.Index)
 		}
 	} else if this.Index != nil {
-		return fmt2.Errorf("this.Index == nil && that.Index != nil")
+		return fmt.Errorf("this.Index == nil && that.Index != nil")
 	} else if that1.Index != nil {
-		return fmt2.Errorf("Index this(%v) Not Equal that(%v)", this.Index, that1.Index)
+		return fmt.Errorf("Index this(%v) Not Equal that(%v)", this.Index, that1.Index)
 	}
 	if this.Term != nil && that1.Term != nil {
 		if *this.Term != *that1.Term {
-			return fmt2.Errorf("Term this(%v) Not Equal that(%v)", *this.Term, *that1.Term)
+			return fmt.Errorf("Term this(%v) Not Equal that(%v)", *this.Term, *that1.Term)
 		}
 	} else if this.Term != nil {
-		return fmt2.Errorf("this.Term == nil && that.Term != nil")
+		return fmt.Errorf("this.Term == nil && that.Term != nil")
 	} else if that1.Term != nil {
-		return fmt2.Errorf("Term this(%v) Not Equal that(%v)", this.Term, that1.Term)
+		return fmt.Errorf("Term this(%v) Not Equal that(%v)", this.Term, that1.Term)
 	}
 	if this.CommandName != nil && that1.CommandName != nil {
 		if *this.CommandName != *that1.CommandName {
-			return fmt2.Errorf("CommandName this(%v) Not Equal that(%v)", *this.CommandName, *that1.CommandName)
+			return fmt.Errorf("CommandName this(%v) Not Equal that(%v)", *this.CommandName, *that1.CommandName)
 		}
 	} else if this.CommandName != nil {
-		return fmt2.Errorf("this.CommandName == nil && that.CommandName != nil")
+		return fmt.Errorf("this.CommandName == nil && that.CommandName != nil")
 	} else if that1.CommandName != nil {
-		return fmt2.Errorf("CommandName this(%v) Not Equal that(%v)", this.CommandName, that1.CommandName)
+		return fmt.Errorf("CommandName this(%v) Not Equal that(%v)", this.CommandName, that1.CommandName)
 	}
 	if !bytes.Equal(this.Command, that1.Command) {
-		return fmt2.Errorf("Command this(%v) Not Equal that(%v)", this.Command, that1.Command)
+		return fmt.Errorf("Command this(%v) Not Equal that(%v)", this.Command, that1.Command)
 	}
 	if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
-		return fmt2.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized)
+		return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized)
 	}
 	return nil
 }

+ 1 - 1
migrate/etcd4pb/log_entry.proto

@@ -1,6 +1,6 @@
 package protobuf;
 
-import "code.google.com/p/gogoprotobuf/gogoproto/gogo.proto";
+import "github.com/gogo/protobuf/gogoproto/gogo.proto";
 
 option (gogoproto.gostring_all) = true;
 option (gogoproto.equal_all) = true;

+ 87 - 69
raft/raftpb/raft.pb.go

@@ -19,18 +19,17 @@
 */
 package raftpb
 
-import proto "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
-import json "encoding/json"
+import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
 import math "math"
 
-// discarding unused import gogoproto "code.google.com/p/gogoprotobuf/gogoproto/gogo.pb"
+// discarding unused import gogoproto "github.com/gogo/protobuf/gogoproto/gogo.pb"
 
 import io "io"
-import code_google_com_p_gogoprotobuf_proto "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
+import fmt "fmt"
+import github_com_gogo_protobuf_proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
 
-// Reference proto, json, and math imports to suppress error if they are not otherwise used.
+// Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal
-var _ = &json.SyntaxError{}
 var _ = math.Inf
 
 type EntryType int32
@@ -275,7 +274,7 @@ func (m *Entry) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -290,7 +289,7 @@ func (m *Entry) Unmarshal(data []byte) error {
 			}
 		case 2:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Term", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -305,7 +304,7 @@ func (m *Entry) Unmarshal(data []byte) error {
 			}
 		case 3:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -320,7 +319,7 @@ func (m *Entry) Unmarshal(data []byte) error {
 			}
 		case 4:
 			if wireType != 2 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
 			}
 			var byteLen int
 			for shift := uint(0); ; shift += 7 {
@@ -338,7 +337,7 @@ func (m *Entry) Unmarshal(data []byte) error {
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
-			m.Data = append(m.Data, data[index:postIndex]...)
+			m.Data = append([]byte{}, data[index:postIndex]...)
 			index = postIndex
 		default:
 			var sizeOfWire int
@@ -350,7 +349,7 @@ func (m *Entry) Unmarshal(data []byte) error {
 				}
 			}
 			index -= sizeOfWire
-			skippy, err := code_google_com_p_gogoprotobuf_proto.Skip(data[index:])
+			skippy, err := github_com_gogo_protobuf_proto.Skip(data[index:])
 			if err != nil {
 				return err
 			}
@@ -384,7 +383,7 @@ func (m *SnapshotMetadata) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 2 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field ConfState", wireType)
 			}
 			var msglen int
 			for shift := uint(0); ; shift += 7 {
@@ -408,7 +407,7 @@ func (m *SnapshotMetadata) Unmarshal(data []byte) error {
 			index = postIndex
 		case 2:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -423,7 +422,7 @@ func (m *SnapshotMetadata) Unmarshal(data []byte) error {
 			}
 		case 3:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Term", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -446,7 +445,7 @@ func (m *SnapshotMetadata) Unmarshal(data []byte) error {
 				}
 			}
 			index -= sizeOfWire
-			skippy, err := code_google_com_p_gogoprotobuf_proto.Skip(data[index:])
+			skippy, err := github_com_gogo_protobuf_proto.Skip(data[index:])
 			if err != nil {
 				return err
 			}
@@ -480,7 +479,7 @@ func (m *Snapshot) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 2 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
 			}
 			var byteLen int
 			for shift := uint(0); ; shift += 7 {
@@ -498,11 +497,11 @@ func (m *Snapshot) Unmarshal(data []byte) error {
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
-			m.Data = append(m.Data, data[index:postIndex]...)
+			m.Data = append([]byte{}, data[index:postIndex]...)
 			index = postIndex
 		case 2:
 			if wireType != 2 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType)
 			}
 			var msglen int
 			for shift := uint(0); ; shift += 7 {
@@ -534,7 +533,7 @@ func (m *Snapshot) Unmarshal(data []byte) error {
 				}
 			}
 			index -= sizeOfWire
-			skippy, err := code_google_com_p_gogoprotobuf_proto.Skip(data[index:])
+			skippy, err := github_com_gogo_protobuf_proto.Skip(data[index:])
 			if err != nil {
 				return err
 			}
@@ -568,7 +567,7 @@ func (m *Message) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -583,7 +582,7 @@ func (m *Message) Unmarshal(data []byte) error {
 			}
 		case 2:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field To", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -598,7 +597,7 @@ func (m *Message) Unmarshal(data []byte) error {
 			}
 		case 3:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field From", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -613,7 +612,7 @@ func (m *Message) Unmarshal(data []byte) error {
 			}
 		case 4:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Term", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -628,7 +627,7 @@ func (m *Message) Unmarshal(data []byte) error {
 			}
 		case 5:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field LogTerm", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -643,7 +642,7 @@ func (m *Message) Unmarshal(data []byte) error {
 			}
 		case 6:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -658,7 +657,7 @@ func (m *Message) Unmarshal(data []byte) error {
 			}
 		case 7:
 			if wireType != 2 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType)
 			}
 			var msglen int
 			for shift := uint(0); ; shift += 7 {
@@ -681,7 +680,7 @@ func (m *Message) Unmarshal(data []byte) error {
 			index = postIndex
 		case 8:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Commit", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -696,7 +695,7 @@ func (m *Message) Unmarshal(data []byte) error {
 			}
 		case 9:
 			if wireType != 2 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Snapshot", wireType)
 			}
 			var msglen int
 			for shift := uint(0); ; shift += 7 {
@@ -720,7 +719,7 @@ func (m *Message) Unmarshal(data []byte) error {
 			index = postIndex
 		case 10:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Reject", wireType)
 			}
 			var v int
 			for shift := uint(0); ; shift += 7 {
@@ -737,7 +736,7 @@ func (m *Message) Unmarshal(data []byte) error {
 			m.Reject = bool(v != 0)
 		case 11:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field RejectHint", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -760,7 +759,7 @@ func (m *Message) Unmarshal(data []byte) error {
 				}
 			}
 			index -= sizeOfWire
-			skippy, err := code_google_com_p_gogoprotobuf_proto.Skip(data[index:])
+			skippy, err := github_com_gogo_protobuf_proto.Skip(data[index:])
 			if err != nil {
 				return err
 			}
@@ -794,7 +793,7 @@ func (m *HardState) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Term", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -809,7 +808,7 @@ func (m *HardState) Unmarshal(data []byte) error {
 			}
 		case 2:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Vote", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -824,7 +823,7 @@ func (m *HardState) Unmarshal(data []byte) error {
 			}
 		case 3:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Commit", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -847,7 +846,7 @@ func (m *HardState) Unmarshal(data []byte) error {
 				}
 			}
 			index -= sizeOfWire
-			skippy, err := code_google_com_p_gogoprotobuf_proto.Skip(data[index:])
+			skippy, err := github_com_gogo_protobuf_proto.Skip(data[index:])
 			if err != nil {
 				return err
 			}
@@ -881,7 +880,7 @@ func (m *ConfState) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Nodes", wireType)
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -906,7 +905,7 @@ func (m *ConfState) Unmarshal(data []byte) error {
 				}
 			}
 			index -= sizeOfWire
-			skippy, err := code_google_com_p_gogoprotobuf_proto.Skip(data[index:])
+			skippy, err := github_com_gogo_protobuf_proto.Skip(data[index:])
 			if err != nil {
 				return err
 			}
@@ -940,7 +939,7 @@ func (m *ConfChange) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -955,7 +954,7 @@ func (m *ConfChange) Unmarshal(data []byte) error {
 			}
 		case 2:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -970,7 +969,7 @@ func (m *ConfChange) Unmarshal(data []byte) error {
 			}
 		case 3:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field NodeID", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -985,7 +984,7 @@ func (m *ConfChange) Unmarshal(data []byte) error {
 			}
 		case 4:
 			if wireType != 2 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Context", wireType)
 			}
 			var byteLen int
 			for shift := uint(0); ; shift += 7 {
@@ -1003,7 +1002,7 @@ func (m *ConfChange) Unmarshal(data []byte) error {
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
-			m.Context = append(m.Context, data[index:postIndex]...)
+			m.Context = append([]byte{}, data[index:postIndex]...)
 			index = postIndex
 		default:
 			var sizeOfWire int
@@ -1015,7 +1014,7 @@ func (m *ConfChange) Unmarshal(data []byte) error {
 				}
 			}
 			index -= sizeOfWire
-			skippy, err := code_google_com_p_gogoprotobuf_proto.Skip(data[index:])
+			skippy, err := github_com_gogo_protobuf_proto.Skip(data[index:])
 			if err != nil {
 				return err
 			}
@@ -1034,13 +1033,16 @@ func (m *Entry) Size() (n int) {
 	n += 1 + sovRaft(uint64(m.Type))
 	n += 1 + sovRaft(uint64(m.Term))
 	n += 1 + sovRaft(uint64(m.Index))
-	l = len(m.Data)
-	n += 1 + l + sovRaft(uint64(l))
+	if m.Data != nil {
+		l = len(m.Data)
+		n += 1 + l + sovRaft(uint64(l))
+	}
 	if m.XXX_unrecognized != nil {
 		n += len(m.XXX_unrecognized)
 	}
 	return n
 }
+
 func (m *SnapshotMetadata) Size() (n int) {
 	var l int
 	_ = l
@@ -1053,11 +1055,14 @@ func (m *SnapshotMetadata) Size() (n int) {
 	}
 	return n
 }
+
 func (m *Snapshot) Size() (n int) {
 	var l int
 	_ = l
-	l = len(m.Data)
-	n += 1 + l + sovRaft(uint64(l))
+	if m.Data != nil {
+		l = len(m.Data)
+		n += 1 + l + sovRaft(uint64(l))
+	}
 	l = m.Metadata.Size()
 	n += 1 + l + sovRaft(uint64(l))
 	if m.XXX_unrecognized != nil {
@@ -1065,6 +1070,7 @@ func (m *Snapshot) Size() (n int) {
 	}
 	return n
 }
+
 func (m *Message) Size() (n int) {
 	var l int
 	_ = l
@@ -1090,6 +1096,7 @@ func (m *Message) Size() (n int) {
 	}
 	return n
 }
+
 func (m *HardState) Size() (n int) {
 	var l int
 	_ = l
@@ -1101,6 +1108,7 @@ func (m *HardState) Size() (n int) {
 	}
 	return n
 }
+
 func (m *ConfState) Size() (n int) {
 	var l int
 	_ = l
@@ -1114,14 +1122,17 @@ func (m *ConfState) Size() (n int) {
 	}
 	return n
 }
+
 func (m *ConfChange) Size() (n int) {
 	var l int
 	_ = l
 	n += 1 + sovRaft(uint64(m.ID))
 	n += 1 + sovRaft(uint64(m.Type))
 	n += 1 + sovRaft(uint64(m.NodeID))
-	l = len(m.Context)
-	n += 1 + l + sovRaft(uint64(l))
+	if m.Context != nil {
+		l = len(m.Context)
+		n += 1 + l + sovRaft(uint64(l))
+	}
 	if m.XXX_unrecognized != nil {
 		n += len(m.XXX_unrecognized)
 	}
@@ -1165,15 +1176,18 @@ func (m *Entry) MarshalTo(data []byte) (n int, err error) {
 	data[i] = 0x18
 	i++
 	i = encodeVarintRaft(data, i, uint64(m.Index))
-	data[i] = 0x22
-	i++
-	i = encodeVarintRaft(data, i, uint64(len(m.Data)))
-	i += copy(data[i:], m.Data)
+	if m.Data != nil {
+		data[i] = 0x22
+		i++
+		i = encodeVarintRaft(data, i, uint64(len(m.Data)))
+		i += copy(data[i:], m.Data)
+	}
 	if m.XXX_unrecognized != nil {
 		i += copy(data[i:], m.XXX_unrecognized)
 	}
 	return i, nil
 }
+
 func (m *SnapshotMetadata) Marshal() (data []byte, err error) {
 	size := m.Size()
 	data = make([]byte, size)
@@ -1208,6 +1222,7 @@ func (m *SnapshotMetadata) MarshalTo(data []byte) (n int, err error) {
 	}
 	return i, nil
 }
+
 func (m *Snapshot) Marshal() (data []byte, err error) {
 	size := m.Size()
 	data = make([]byte, size)
@@ -1223,10 +1238,12 @@ func (m *Snapshot) MarshalTo(data []byte) (n int, err error) {
 	_ = i
 	var l int
 	_ = l
-	data[i] = 0xa
-	i++
-	i = encodeVarintRaft(data, i, uint64(len(m.Data)))
-	i += copy(data[i:], m.Data)
+	if m.Data != nil {
+		data[i] = 0xa
+		i++
+		i = encodeVarintRaft(data, i, uint64(len(m.Data)))
+		i += copy(data[i:], m.Data)
+	}
 	data[i] = 0x12
 	i++
 	i = encodeVarintRaft(data, i, uint64(m.Metadata.Size()))
@@ -1240,6 +1257,7 @@ func (m *Snapshot) MarshalTo(data []byte) (n int, err error) {
 	}
 	return i, nil
 }
+
 func (m *Message) Marshal() (data []byte, err error) {
 	size := m.Size()
 	data = make([]byte, size)
@@ -1312,6 +1330,7 @@ func (m *Message) MarshalTo(data []byte) (n int, err error) {
 	}
 	return i, nil
 }
+
 func (m *HardState) Marshal() (data []byte, err error) {
 	size := m.Size()
 	data = make([]byte, size)
@@ -1341,6 +1360,7 @@ func (m *HardState) MarshalTo(data []byte) (n int, err error) {
 	}
 	return i, nil
 }
+
 func (m *ConfState) Marshal() (data []byte, err error) {
 	size := m.Size()
 	data = make([]byte, size)
@@ -1360,13 +1380,7 @@ func (m *ConfState) MarshalTo(data []byte) (n int, err error) {
 		for _, num := range m.Nodes {
 			data[i] = 0x8
 			i++
-			for num >= 1<<7 {
-				data[i] = uint8(uint64(num)&0x7f | 0x80)
-				num >>= 7
-				i++
-			}
-			data[i] = uint8(num)
-			i++
+			i = encodeVarintRaft(data, i, uint64(num))
 		}
 	}
 	if m.XXX_unrecognized != nil {
@@ -1374,6 +1388,7 @@ func (m *ConfState) MarshalTo(data []byte) (n int, err error) {
 	}
 	return i, nil
 }
+
 func (m *ConfChange) Marshal() (data []byte, err error) {
 	size := m.Size()
 	data = make([]byte, size)
@@ -1398,15 +1413,18 @@ func (m *ConfChange) MarshalTo(data []byte) (n int, err error) {
 	data[i] = 0x18
 	i++
 	i = encodeVarintRaft(data, i, uint64(m.NodeID))
-	data[i] = 0x22
-	i++
-	i = encodeVarintRaft(data, i, uint64(len(m.Context)))
-	i += copy(data[i:], m.Context)
+	if m.Context != nil {
+		data[i] = 0x22
+		i++
+		i = encodeVarintRaft(data, i, uint64(len(m.Context)))
+		i += copy(data[i:], m.Context)
+	}
 	if m.XXX_unrecognized != nil {
 		i += copy(data[i:], m.XXX_unrecognized)
 	}
 	return i, nil
 }
+
 func encodeFixed64Raft(data []byte, offset int, v uint64) int {
 	data[offset] = uint8(v)
 	data[offset+1] = uint8(v >> 8)

+ 1 - 1
raft/raftpb/raft.proto

@@ -1,6 +1,6 @@
 package raftpb;
 
-import "code.google.com/p/gogoprotobuf/gogoproto/gogo.proto";
+import "github.com/gogo/protobuf/gogoproto/gogo.proto";
 
 option (gogoproto.marshaler_all) = true;
 option (gogoproto.sizer_all) = true;

+ 6 - 6
scripts/genproto.sh

@@ -5,9 +5,9 @@
 #
 
 PREFIX="github.com/coreos/etcd/Godeps/_workspace/src"
-DIRS="./wal/walpb ./etcdserver/etcdserverpb ./snap/snappb ./raft/raftpb"
+DIRS="./wal/walpb ./etcdserver/etcdserverpb ./snap/snappb ./raft/raftpb ./migrate/etcd4pb"
 
-SHA="20c42d4d4d776b60d32c2d35ecac40a60793f661"
+SHA="bc946d07d1016848dfd2507f90f0859c9471681e"
 
 if ! protoc --version > /dev/null; then
 	echo "could not find protoc, is it installed + in PATH?"
@@ -18,8 +18,8 @@ fi
 # TODO(jonboulle): vendor this instead of `go get`ting it.
 export GOPATH=${PWD}/gopath
 export GOBIN=${PWD}/bin
-go get code.google.com/p/gogoprotobuf/{proto,protoc-gen-gogo,gogoproto}
-pushd ${GOPATH}/src/code.google.com/p/gogoprotobuf
+go get github.com/gogo/protobuf/{proto,protoc-gen-gogo,gogoproto}
+pushd ${GOPATH}/src/github.com/gogo/protobuf/
 	git reset --hard ${SHA}
 	make
 popd
@@ -28,8 +28,8 @@ export PATH="${GOBIN}:${PATH}"
 
 for dir in ${DIRS}; do
 	pushd ${dir}
-		protoc --gogo_out=. -I=.:${GOPATH}/src/code.google.com/p/gogoprotobuf/protobuf:${GOPATH}/src *.proto
-		sed -i".bak" -e "s|code.google.com/p/gogoprotobuf/proto|${PREFIX}/code.google.com/p/gogoprotobuf/proto|" *.go
+		protoc --gogo_out=. -I=.:${GOPATH}/src/github.com/gogo/protobuf/protobuf:${GOPATH}/src *.proto
+		sed -i".bak" -e "s|github.com/gogo/protobuf/proto|${PREFIX}/github.com/gogo/protobuf/proto|" *.go
 		rm -f *.bak
 	popd
 done

+ 10 - 10
snap/snappb/snap.pb.go

@@ -13,18 +13,17 @@
 */
 package snappb
 
-import proto "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
-import json "encoding/json"
+import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
 import math "math"
 
-// discarding unused import gogoproto "code.google.com/p/gogoprotobuf/gogoproto/gogo.pb"
+// discarding unused import gogoproto "github.com/gogo/protobuf/gogoproto/gogo.pb"
 
 import io "io"
-import code_google_com_p_gogoprotobuf_proto "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
+import fmt "fmt"
+import github_com_gogo_protobuf_proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
 
-// Reference proto, json, and math imports to suppress error if they are not otherwise used.
+// Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal
-var _ = &json.SyntaxError{}
 var _ = math.Inf
 
 type Snapshot struct {
@@ -60,7 +59,7 @@ func (m *Snapshot) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Crc", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -75,7 +74,7 @@ func (m *Snapshot) Unmarshal(data []byte) error {
 			}
 		case 2:
 			if wireType != 2 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
 			}
 			var byteLen int
 			for shift := uint(0); ; shift += 7 {
@@ -93,7 +92,7 @@ func (m *Snapshot) Unmarshal(data []byte) error {
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
-			m.Data = append(m.Data, data[index:postIndex]...)
+			m.Data = append([]byte{}, data[index:postIndex]...)
 			index = postIndex
 		default:
 			var sizeOfWire int
@@ -105,7 +104,7 @@ func (m *Snapshot) Unmarshal(data []byte) error {
 				}
 			}
 			index -= sizeOfWire
-			skippy, err := code_google_com_p_gogoprotobuf_proto.Skip(data[index:])
+			skippy, err := github_com_gogo_protobuf_proto.Skip(data[index:])
 			if err != nil {
 				return err
 			}
@@ -174,6 +173,7 @@ func (m *Snapshot) MarshalTo(data []byte) (n int, err error) {
 	}
 	return i, nil
 }
+
 func encodeFixed64Snap(data []byte, offset int, v uint64) int {
 	data[offset] = uint8(v)
 	data[offset+1] = uint8(v >> 8)

+ 1 - 1
snap/snappb/snap.proto

@@ -1,6 +1,6 @@
 package snappb;
 
-import "code.google.com/p/gogoprotobuf/gogoproto/gogo.proto";
+import "github.com/gogo/protobuf/gogoproto/gogo.proto";
 
 option (gogoproto.marshaler_all) = true;
 option (gogoproto.sizer_all) = true;

+ 16 - 14
wal/walpb/record.pb.go

@@ -14,18 +14,17 @@
 */
 package walpb
 
-import proto "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
-import json "encoding/json"
+import proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
 import math "math"
 
-// discarding unused import gogoproto "code.google.com/p/gogoprotobuf/gogoproto/gogo.pb"
+// discarding unused import gogoproto "github.com/gogo/protobuf/gogoproto/gogo.pb"
 
 import io "io"
-import code_google_com_p_gogoprotobuf_proto "github.com/coreos/etcd/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
+import fmt "fmt"
+import github_com_gogo_protobuf_proto "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
 
-// Reference proto, json, and math imports to suppress error if they are not otherwise used.
+// Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal
-var _ = &json.SyntaxError{}
 var _ = math.Inf
 
 type Record struct {
@@ -72,7 +71,7 @@ func (m *Record) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -87,7 +86,7 @@ func (m *Record) Unmarshal(data []byte) error {
 			}
 		case 2:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Crc", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -102,7 +101,7 @@ func (m *Record) Unmarshal(data []byte) error {
 			}
 		case 3:
 			if wireType != 2 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
 			}
 			var byteLen int
 			for shift := uint(0); ; shift += 7 {
@@ -120,7 +119,7 @@ func (m *Record) Unmarshal(data []byte) error {
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
-			m.Data = append(m.Data, data[index:postIndex]...)
+			m.Data = append([]byte{}, data[index:postIndex]...)
 			index = postIndex
 		default:
 			var sizeOfWire int
@@ -132,7 +131,7 @@ func (m *Record) Unmarshal(data []byte) error {
 				}
 			}
 			index -= sizeOfWire
-			skippy, err := code_google_com_p_gogoprotobuf_proto.Skip(data[index:])
+			skippy, err := github_com_gogo_protobuf_proto.Skip(data[index:])
 			if err != nil {
 				return err
 			}
@@ -166,7 +165,7 @@ func (m *Snapshot) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -181,7 +180,7 @@ func (m *Snapshot) Unmarshal(data []byte) error {
 			}
 		case 2:
 			if wireType != 0 {
-				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
+				return fmt.Errorf("proto: wrong wireType = %d for field Term", wireType)
 			}
 			for shift := uint(0); ; shift += 7 {
 				if index >= l {
@@ -204,7 +203,7 @@ func (m *Snapshot) Unmarshal(data []byte) error {
 				}
 			}
 			index -= sizeOfWire
-			skippy, err := code_google_com_p_gogoprotobuf_proto.Skip(data[index:])
+			skippy, err := github_com_gogo_protobuf_proto.Skip(data[index:])
 			if err != nil {
 				return err
 			}
@@ -231,6 +230,7 @@ func (m *Record) Size() (n int) {
 	}
 	return n
 }
+
 func (m *Snapshot) Size() (n int) {
 	var l int
 	_ = l
@@ -287,6 +287,7 @@ func (m *Record) MarshalTo(data []byte) (n int, err error) {
 	}
 	return i, nil
 }
+
 func (m *Snapshot) Marshal() (data []byte, err error) {
 	size := m.Size()
 	data = make([]byte, size)
@@ -313,6 +314,7 @@ func (m *Snapshot) MarshalTo(data []byte) (n int, err error) {
 	}
 	return i, nil
 }
+
 func encodeFixed64Record(data []byte, offset int, v uint64) int {
 	data[offset] = uint8(v)
 	data[offset+1] = uint8(v >> 8)

+ 1 - 1
wal/walpb/record.proto

@@ -1,6 +1,6 @@
 package walpb;
 
-import "code.google.com/p/gogoprotobuf/gogoproto/gogo.proto";
+import "github.com/gogo/protobuf/gogoproto/gogo.proto";
 
 option (gogoproto.marshaler_all) = true;
 option (gogoproto.sizer_all) = true;