Command gencodec generates marshaling methods for Go struct types.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gencodec/vendor/github.com/garslo/gogen/declare.go

35 lines
498 B

package gogen
import (
"go/ast"
"go/token"
)
type Declare struct {
Name string
TypeName string
}
func (me Declare) Statement() ast.Stmt {
return &ast.DeclStmt{
Decl: &ast.GenDecl{
Tok: token.VAR,
Specs: []ast.Spec{
&ast.ValueSpec{
Names: []*ast.Ident{
&ast.Ident{
Name: me.Name,
Obj: &ast.Object{
Kind: ast.Var,
Name: me.Name,
},
},
},
Type: &ast.Ident{
Name: me.TypeName,
},
},
},
},
}
}