Skip to content

issues with kitgen #949

@OmegaRogue

Description

@OmegaRogue

when trying kitgen on one of the examples, it works fine, but when trying to run it on my own service, it panics:

C:\Users\OmegaRogue\go\src\go-kit-todolist\todo-service>kitgen service.go
panic: interface conversion: ast.Node is *ast.SelectorExpr, not *ast.Ident

goroutine 1 [running]:
main.walkIdentList.func1(0x6cf580, 0xc0001d43a0)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/replacewalk.go:20 +0x9f
main.walkToReplace.func1(0x6cf580, 0xc0001d43a0)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/replacewalk.go:68 +0x57
main.selectifyIdent.func1(0x6cf200, 0xc0001b0aa0, 0xc0001d96c0, 0x62f701, 0xc0001d96c0)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/transform.go:99 +0x11f
main.selIdentFn.Visit(0xc0001c5ac0, 0x6cf200, 0xc0001b0aa0, 0xc0001d96c0, 0xc0001d9660, 0x6d1e00)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/transform.go:86 +0x4b
main.walkToReplace(0x6ce1a0, 0xc0001c5ac0, 0x6cf200, 0xc0001b0aa0, 0xc0001dab10)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/replacewalk.go:71 +0xe4
main.walkIdentList(0x6ce1a0, 0xc0001c5ac0, 0xc000007fd0, 0x1, 0x1)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/replacewalk.go:19 +0x79
main.walkToReplace(0x6ce1a0, 0xc0001c5ac0, 0x6cefc0, 0xc0001b4180, 0xc0001d9680)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/replacewalk.go:133 +0x20ad
main.walkToReplace(0x6ce1a0, 0xc0001c5ac0, 0x6cf000, 0xc0001b2330, 0xc0001d3ba0)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/replacewalk.go:158 +0x265
main.walkToReplace(0x6ce1a0, 0xc0001c5ac0, 0x6cf680, 0xc0001b0860, 0xc0001d3b80)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/replacewalk.go:324 +0x681b
main.walkToReplace(0x6ce1a0, 0xc0001c5ac0, 0x6cf740, 0xc0001b2300, 0xc0001d9400)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/replacewalk.go:667 +0x6db7
main.walkToReplace(0x6ce1a0, 0xc0001c5ac0, 0x6cf180, 0xc0001b40c0, 0xc0001daa20)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/replacewalk.go:690 +0x2678
main.walkDeclList(0x6ce1a0, 0xc0001c5ac0, 0xc000124600, 0x11, 0x18)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/replacewalk.go:43 +0x140
main.walkToReplace(0x6ce1a0, 0xc0001c5ac0, 0x6cf040, 0xc000163100, 0xc0001d2220)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/replacewalk.go:734 +0x65f9
main.WalkReplace(0x6ce1a0, 0xc0001c5ac0, 0x6cf040, 0xc000163100, 0x6d1ac0, 0xc0001d4360)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/replacewalk.go:55 +0xa4
main.selectifyIdent(0xc00001048c, 0x4, 0xc000163100, 0x6d1e00, 0xc0001d43a0, 0xc000089930, 0xc000089ca0)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/transform.go:104 +0xf8
main.selectify(0xc000163100, 0x66c5c6, 0x7, 0xc00001048c, 0x4, 0xc00000fcb0, 0x24, 0xc000163100)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/transform.go:77 +0x139
main.deflayout.transformAST(0xc00000a41b, 0x1c, 0xc00008c7d0, 0x0, 0xc0000a6500, 0xc00008c7d0)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/deflayout.go:58 +0x1799
main.process(0xc0000100c0, 0xa, 0x6cde60, 0xc000006058, 0x6ce160, 0xc000042530, 0x0, 0x0, 0xc000042510)
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/main.go:102 +0xbf
main.main()
        C:/Users/OmegaRogue/go/src/github.com/go-kit/kit/cmd/kitgen/main.go:80 +0x2ac

i can't really find any differences between my code and the example code:

// my code
package todosvc

import "context"

type Service interface {
	Hello(ctx context.Context) (string, error)
	ListAll(ctx context.Context) ([]List, error)
	List(ctx context.Context, user string) (List, error)
}

type List struct {
	User  string              `json:"name"`
	Tasks map[string][]string `json:"tasks,omitempty"`
}
// example code
package profilesvc

import "context"

type Service interface {
	PostProfile(ctx context.Context, p Profile) error
	GetProfile(ctx context.Context, id string) (Profile, error)
	PutProfile(ctx context.Context, id string, p Profile) error
	PatchProfile(ctx context.Context, id string, p Profile) error
	DeleteProfile(ctx context.Context, id string) error
	GetAddresses(ctx context.Context, profileID string) ([]Address, error)
	GetAddress(ctx context.Context, profileID string, addressID string) (Address, error)
	PostAddress(ctx context.Context, profileID string, a Address) error
	DeleteAddress(ctx context.Context, profileID string, addressID string) error
}

type Profile struct {
	ID        string    `json:"id"`
	Name      string    `json:"name,omitempty"`
	Addresses []Address `json:"addresses,omitempty"`
}

type Address struct {
	ID       string `json:"id"`
	Location string `json:"location,omitempty"`
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions