// bool
{
- data := struct {
- a bool;
- }{true};
+ data := struct{ a bool }{true};
instr := &encInstr{encBool, 6, 0, 0};
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
// int
{
b.Reset();
- data := struct {
- a int;
- }{17};
+ data := struct{ a int }{17};
instr := &encInstr{encInt, 6, 0, 0};
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
// uint
{
b.Reset();
- data := struct {
- a uint;
- }{17};
+ data := struct{ a uint }{17};
instr := &encInstr{encUint, 6, 0, 0};
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
// int8
{
b.Reset();
- data := struct {
- a int8;
- }{17};
+ data := struct{ a int8 }{17};
instr := &encInstr{encInt8, 6, 0, 0};
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
// uint8
{
b.Reset();
- data := struct {
- a uint8;
- }{17};
+ data := struct{ a uint8 }{17};
instr := &encInstr{encUint8, 6, 0, 0};
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
// int16
{
b.Reset();
- data := struct {
- a int16;
- }{17};
+ data := struct{ a int16 }{17};
instr := &encInstr{encInt16, 6, 0, 0};
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
// uint16
{
b.Reset();
- data := struct {
- a uint16;
- }{17};
+ data := struct{ a uint16 }{17};
instr := &encInstr{encUint16, 6, 0, 0};
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
// int32
{
b.Reset();
- data := struct {
- a int32;
- }{17};
+ data := struct{ a int32 }{17};
instr := &encInstr{encInt32, 6, 0, 0};
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
// uint32
{
b.Reset();
- data := struct {
- a uint32;
- }{17};
+ data := struct{ a uint32 }{17};
instr := &encInstr{encUint32, 6, 0, 0};
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
// int64
{
b.Reset();
- data := struct {
- a int64;
- }{17};
+ data := struct{ a int64 }{17};
instr := &encInstr{encInt64, 6, 0, 0};
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
// uint64
{
b.Reset();
- data := struct {
- a uint64;
- }{17};
+ data := struct{ a uint64 }{17};
instr := &encInstr{encUint64, 6, 0, 0};
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
// float
{
b.Reset();
- data := struct {
- a float;
- }{17};
+ data := struct{ a float }{17};
instr := &encInstr{encFloat, 6, 0, 0};
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
// float32
{
b.Reset();
- data := struct {
- a float32;
- }{17};
+ data := struct{ a float32 }{17};
instr := &encInstr{encFloat32, 6, 0, 0};
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
// float64
{
b.Reset();
- data := struct {
- a float64;
- }{17};
+ data := struct{ a float64 }{17};
instr := &encInstr{encFloat64, 6, 0, 0};
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
// bytes == []uint8
{
b.Reset();
- data := struct {
- a []byte;
- }{strings.Bytes("hello")};
+ data := struct{ a []byte }{strings.Bytes("hello")};
instr := &encInstr{encUint8Array, 6, 0, 0};
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
// string
{
b.Reset();
- data := struct {
- a string;
- }{"hello"};
+ data := struct{ a string }{"hello"};
instr := &encInstr{encString, 6, 0, 0};
state := newencoderState(b);
instr.op(instr, state, unsafe.Pointer(&data));
func typestring(i interface{}) string { return Typeof(i).String() }
var typeTests = []pair{
- pair{struct {
- x int;
- }{},
- "int",
- },
- pair{struct {
- x int8;
- }{},
- "int8",
- },
- pair{struct {
- x int16;
- }{},
- "int16",
- },
- pair{struct {
- x int32;
- }{},
- "int32",
- },
- pair{struct {
- x int64;
- }{},
- "int64",
- },
- pair{struct {
- x uint;
- }{},
- "uint",
- },
- pair{struct {
- x uint8;
- }{},
- "uint8",
- },
- pair{struct {
- x uint16;
- }{},
- "uint16",
- },
- pair{struct {
- x uint32;
- }{},
- "uint32",
- },
- pair{struct {
- x uint64;
- }{},
- "uint64",
- },
- pair{struct {
- x float;
- }{},
- "float",
- },
- pair{struct {
- x float32;
- }{},
- "float32",
- },
- pair{struct {
- x float64;
- }{},
- "float64",
- },
- pair{struct {
- x int8;
- }{},
- "int8",
- },
- pair{struct {
- x (**int8);
- }{},
- "**int8",
- },
- pair{struct {
- x (**integer);
- }{},
- "**reflect_test.integer",
- },
- pair{struct {
- x ([32]int32);
- }{},
- "[32]int32",
- },
- pair{struct {
- x ([]int8);
- }{},
- "[]int8",
- },
- pair{struct {
- x (map[string]int32);
- }{},
- "map[string] int32",
- },
- pair{struct {
- x (chan<- string);
- }{},
- "chan<- string",
- },
+ pair{struct{ x int }{}, "int"},
+ pair{struct{ x int8 }{}, "int8"},
+ pair{struct{ x int16 }{}, "int16"},
+ pair{struct{ x int32 }{}, "int32"},
+ pair{struct{ x int64 }{}, "int64"},
+ pair{struct{ x uint }{}, "uint"},
+ pair{struct{ x uint8 }{}, "uint8"},
+ pair{struct{ x uint16 }{}, "uint16"},
+ pair{struct{ x uint32 }{}, "uint32"},
+ pair{struct{ x uint64 }{}, "uint64"},
+ pair{struct{ x float }{}, "float"},
+ pair{struct{ x float32 }{}, "float32"},
+ pair{struct{ x float64 }{}, "float64"},
+ pair{struct{ x int8 }{}, "int8"},
+ pair{struct{ x (**int8) }{}, "**int8"},
+ pair{struct{ x (**integer) }{}, "**reflect_test.integer"},
+ pair{struct{ x ([32]int32) }{}, "[32]int32"},
+ pair{struct{ x ([]int8) }{}, "[]int8"},
+ pair{struct{ x (map[string]int32) }{}, "map[string] int32"},
+ pair{struct{ x (chan<- string) }{}, "chan<- string"},
pair{struct {
x struct {
c chan *int32;
}{},
"struct { c chan *int32; d float32 }",
},
- pair{struct {
- x (func(a int8, b int32));
- }{},
- "func(int8, int32)",
- },
+ pair{struct{ x (func(a int8, b int32)) }{}, "func(int8, int32)"},
pair{struct {
x struct {
c func(chan *integer, *int8);
}
func TestBigUnnamedStruct(t *testing.T) {
- b := struct {
- a, b, c, d int64;
- }{1, 2, 3, 4};
+ b := struct{ a, b, c, d int64 }{1, 2, 3, 4};
v := NewValue(b);
b1 := v.Interface().(struct {
a, b, c, d int64;
func TestIsNil(t *testing.T) {
// These do not implement IsNil
- doNotNil := []interface{}{int(0), float32(0), struct {
- a int;
- }{}};
+ doNotNil := []interface{}{int(0), float32(0), struct{ a int }{}};
for _, ts := range doNotNil {
ty := Typeof(ts);
v := MakeZero(ty);
// These do implement IsNil.
// Wrap in extra struct to hide interface type.
doNil := []interface{}{
- struct {
- x *int;
- }{},
- struct {
- x interface{};
- }{},
- struct {
- x map[string]int;
- }{},
- struct {
- x func() bool;
- }{},
- struct {
- x chan int;
- }{},
- struct {
- x []string;
- }{},
+ struct{ x *int }{},
+ struct{ x interface{} }{},
+ struct{ x map[string]int }{},
+ struct{ x func() bool }{},
+ struct{ x chan int }{},
+ struct{ x []string }{},
};
for _, ts := range doNil {
ty := Typeof(ts).(*StructType).Field(0).Type;