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

"kit g s" cannot generate function with optional parameter defined. #4

Closed
burxtx opened this issue Jan 16, 2018 · 5 comments
Closed

Comments

@burxtx
Copy link

burxtx commented Jan 16, 2018

When using "kit g s servicename", if a function is defined with optional parameter, seems kit not recognize "..."
my interface defined as below:

package service

import (
        "context"
        "github.com/burxtx/fault/fault/pkg/model"
)

// FaultService describes the service.
type FaultService interface {
        // Add your methods here
        Find(ctx context.Context, condiBeans...interface{}) (m []model.Fault, error error)
        Get(ctx context.Context, id string) (m model.Fault, error error)
        Add(ctx context.Context, fault model.Fault) (i int64, error error)
}

then type "kit g s fault -w --gorilla"

INFO[0000] Type Expresion not supported                 
panic: Error 1:76: expected type, found ')' while formatting source:
func (b *basicFaultService) Find (ctx context.Context,condiBeans ) (m0 []model.Fault,e1 error) {
// TODO implement the business logic of Find
return m0,e1
} 

goroutine 1 [running]:
github.com/dave/jennifer/jen.(*Statement).GoString(0xc4200cfbc0, 0x1, 0x1)
	/root/go/src/github.com/dave/jennifer/jen/statement.go:93 +0x102
github.com/kujtimiihoxha/kit/generator.(*PartialGenerator).String(0xc42000e1f0, 0xc420018c01, 0x5ea)
	/root/go/src/github.com/kujtimiihoxha/kit/generator/generator.go:213 +0x2e
github.com/kujtimiihoxha/kit/generator.(*GenerateService).Generate(0xc420290000, 0x5, 0xa5b916)
	/root/go/src/github.com/kujtimiihoxha/kit/generator/generate_service.go:91 +0x356
github.com/kujtimiihoxha/kit/cmd.glob..func3(0xe75880, 0xc42014ecc0, 0x1, 0x3)
	/root/go/src/github.com/kujtimiihoxha/kit/cmd/g_service.go:41 +0x175
github.com/spf13/cobra.(*Command).execute(0xe75880, 0xc42014ec30, 0x3, 0x3, 0xe75880, 0xc42014ec30)
	/root/go/src/github.com/spf13/cobra/command.go:750 +0x2c1
github.com/spf13/cobra.(*Command).ExecuteC(0xe76180, 0x0, 0x0, 0xc420197ed8)
	/root/go/src/github.com/spf13/cobra/command.go:831 +0x30e
github.com/spf13/cobra.(*Command).Execute(0xe76180, 0x2, 0x2)
	/root/go/src/github.com/spf13/cobra/command.go:784 +0x2b
github.com/kujtimiihoxha/kit/cmd.Execute()
	/root/go/src/github.com/kujtimiihoxha/kit/cmd/root.go:24 +0x31
main.main()
	/root/go/src/github.com/kujtimiihoxha/kit/main.go:29 +0x117```
kujtimiihoxha pushed a commit that referenced this issue Jan 16, 2018
@kujtimiihoxha
Copy link
Owner

@burxtx thanks for the bug report, should be fixed now. Let me know if it works for you now.

@kujtimiihoxha
Copy link
Owner

Closing this issue should be OK now.

@burxtx
Copy link
Author

burxtx commented Jan 17, 2018

Still the same error after updated.

@kujtimiihoxha
Copy link
Owner

Did you run go get -u github.com/kujtimiihoxha/kit? also, run go install github.com/kujtimiihoxha/kit just in case, I tried it locally and it worked for me.

@kujtimiihoxha kujtimiihoxha reopened this Jan 17, 2018
@burxtx
Copy link
Author

burxtx commented Jan 18, 2018

Yes, it finally works after running go install. I am confused why go install not executed after go get.

@burxtx burxtx closed this as completed Jan 18, 2018
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