Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Empty nested structure [duplicate]

Tags:

go

I was digging in AWS SDK source codes and came across with the following type declaration:

type Condition struct {
    _ struct{} `type:"structure"`

    // the rest of code is removed
}

Do anybody know purpose/explanation of this kind of embedding?

like image 835
Hayk Sahakyan Avatar asked Nov 08 '22 02:11

Hayk Sahakyan


1 Answers

Its been used for code generation perposes. you can think of it like java which treats everything in it as an object.

example of using it is here

{{ $shapeList := ShapeListWithErrors $ }}
{{ range $_, $s := $shapeList }}
{{ if eq $s.Type "structure"}}{{ $s.GoCode }}{{ end }}
{{ end }}
like image 200
CallMeLoki Avatar answered Nov 12 '22 12:11

CallMeLoki