Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

concatenation "string" + Id("futureVariables") #61

Open
malikov0216 opened this issue May 29, 2019 · 1 comment
Open

concatenation "string" + Id("futureVariables") #61

malikov0216 opened this issue May 29, 2019 · 1 comment

Comments

@malikov0216
Copy link

`type APIparameters struct {
PathParam []pathParameters
Host string
Security string
}
var api APIparameters
api.Host = "api host"
group.List(Id("request"), Id("err")).Op(":=").Id("http").Dot("NewRequest").Call(Id("method"),LitFunc(func() interface{} { return Lit(api.Host).Id("endpoint") }), Id("body"))
There is an error when concatinating LitFunc(func() interface{} { return Lit(api.Host).Id("endpoint") })
panic: unsupported type for literal: *jen.Statement

goroutine 1 [running]:
github.com/dave/jennifer/jen.token.render(0x1184c8e, 0x7, 0x11827a0, 0xc0000db0e0, 0xc0000c80a0, 0x11b4160, 0xc0000c0750, 0xc0000db0c0, 0xc0000d75b8, 0x1041959)
/Users/nartay/go/src/github.com/dave/jennifer/jen/tokens.go:64 +0xed4
github.com/dave/jennifer/jen.(*Statement).render(0xc0000db0c0, 0xc0000c80a0, 0x11b4160, 0xc0000c0750, 0x0, 0x0, 0x0)
/Users/nartay/go/src/github.com/dave/jennifer/jen/statement.go:64 +0xcb
github.com/dave/jennifer/jen.(*Group).renderItems(0xc0000966c0, 0xc0000c80a0, 0x11b4160, 0xc0000c0750, 0x1, 0x0, 0x0)
/Users/nartay/go/src/github.com/dave/jennifer/jen/group.go:110 +0x18a
github.com/dave/jennifer/jen.(*Group).render(0xc0000966c0, 0xc0000c80a0, 0x11b4160, 0xc0000c0750, 0xc0000dafc0, 0x0, 0x0)
/Users/nartay/go/src/github.com/dave/jennifer/jen/group.go:53 +0x84
github.com/dave/jennifer/jen.(*Statement).render(0xc0000dafc0, 0xc0000c80a0, 0x11b4160, 0xc0000c0750, 0x0, 0x0, 0x0)
/Users/nartay/go/src/github.com/dave/jennifer/jen/statement.go:64 +0xcb
github.com/dave/jennifer/jen.(*Group).renderItems(0xc0000964e0, 0xc0000c80a0, 0x11b4160, 0xc0000c0750, 0x1, 0x0, 0x0)
/Users/nartay/go/src/github.com/dave/jennifer/jen/group.go:110 +0x18a
github.com/dave/jennifer/jen.(*Group).render(0xc0000964e0, 0xc0000c80a0, 0x11b4160, 0xc0000c0750, 0xc0000da500, 0x0, 0x0)
/Users/nartay/go/src/github.com/dave/jennifer/jen/group.go:53 +0x84
github.com/dave/jennifer/jen.(*Statement).render(0xc0000da500, 0xc0000c80a0, 0x11b4160, 0xc0000c0750, 0x0, 0x0, 0x0)
/Users/nartay/go/src/github.com/dave/jennifer/jen/statement.go:64 +0xcb
github.com/dave/jennifer/jen.(*Group).renderItems(0xc0000960c0, 0xc0000c80a0, 0x11b4160, 0xc0000c0750, 0x1167a80, 0xc0000d0c01, 0xc0000c0750)
/Users/nartay/go/src/github.com/dave/jennifer/jen/group.go:110 +0x18a
github.com/dave/jennifer/jen.(*Group).render(0xc0000960c0, 0xc0000c80a0, 0x11b4160, 0xc0000c0750, 0x0, 0xc0000d09d0, 0xc0000c05d0)
/Users/nartay/go/src/github.com/dave/jennifer/jen/group.go:53 +0x84
github.com/dave/jennifer/jen.(*File).Render(0xc0000c80a0, 0x11b4160, 0xc0000c0720, 0x4, 0x20)
/Users/nartay/go/src/github.com/dave/jennifer/jen/jen.go:36 +0x82
github.com/dave/jennifer/jen.(*File).Save(0xc0000c80a0, 0x1184c9c, 0x7, 0x2, 0x3)
/Users/nartay/go/src/github.com/dave/jennifer/jen/jen.go:24 +0x5a
main.main()
/Users/nartay/Desktop/job/code_generate/readingJSON/readingJSON.go:130 +0x1e8f
exit status 2

`

@dave
Copy link
Owner

dave commented Aug 6, 2019

Hi, sorry for the delay on this one... I’m currently taking a break from open source work and hiking across Nepal for five months...

What exactly are you trying to do here? The parameter of the LitFunc method should be a function that returns one of the types that Lit accepts - e.g. bool, string, int, complex128, float64, float32, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, uintptr and complex64

See https://github.com/dave/jennifer/blob/master/README.md#lit

Right now your function is returning a *Statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants