metaverse / truss

Truss helps you build go-kit microservices without having to worry about writing or maintaining boilerplate code.
Other
734 stars 143 forks source link

gengokit generrator panic #335

Closed luckyforme233 closed 2 years ago

luckyforme233 commented 2 years ago
 truss --svcout=./ ./proto/service.proto
panic: interface conversion: ast.Spec is *ast.ImportSpec, not *ast.ValueSpec

goroutine 1 [running]:
go/printer.keepTypeColumn(0xc0004e8020, 0x2, 0x2, 0x2, 0x1, 0x276)
        C:/Program Files/Go/src/go/printer/nodes.go:1460 +0x1e8
go/printer.(*printer).genDecl(0xc0000c1720, 0xc0004c0b00)
        C:/Program Files/Go/src/go/printer/nodes.go:1616 +0x2aa
go/printer.(*printer).decl(0xc0000c1720, 0x963260, 0xc0004c0b00)
        C:/Program Files/Go/src/go/printer/nodes.go:1789 +0xb0
go/printer.(*printer).declList(0xc0000c1720, 0xc00048e580, 0x8, 0x8)
        C:/Program Files/Go/src/go/printer/nodes.go:1834 +0x16a
go/printer.(*printer).file(0xc0000c1720, 0xc00048e600)
        C:/Program Files/Go/src/go/printer/nodes.go:1842 +0x14b
go/printer.(*printer).printNode(0xc0000c1720, 0x88aae0, 0xc00048e600, 0xc0004d85e0, 0x30001)
        C:/Program Files/Go/src/go/printer/printer.go:1152 +0x598
go/printer.(*Config).fprint(0xc0000c1908, 0x95b780, 0xc0004e4870, 0xc0004c0600, 0x88aae0, 0xc00048e600, 0xc0004e48a0, 0x0, 0x0)
        C:/Program Files/Go/src/go/printer/printer.go:1309 +0x18e
go/printer.(*Config).Fprint(...)
        C:/Program Files/Go/src/go/printer/printer.go:1367
go/printer.Fprint(...)
        C:/Program Files/Go/src/go/printer/printer.go:1376
github.com/metaverse/truss/gengokit/handlers.(*HookRender).Render(0xc0004bab10, 0x8f1b63, 0x19, 0xc0002aa540, 0x8f1b63, 0x11, 0x0, 0x0)
        D:/gopath/src/github.com/metaverse/truss/gengokit/handlers/hooks.go:68 +0x38c
github.com/metaverse/truss/gengokit/generator.generateResponseFile(0x8f1b63, 0x19, 0xc0002aa540, 0x95bbc0, 0xc000308048, 0x11, 0xc0004cfd40, 0x0, 0x0)
        D:/gopath/src/github.com/metaverse/truss/gengokit/generator/gen.go:73 +0x790
github.com/metaverse/truss/gengokit/generator.GenerateGokit(0xc000547040, 0xc00030b9e0, 0x14, 0xc00028a8e0, 0xa, 0x953948, 0xa, 0x95b6d0, 0x1c, 0xc00032e4b0, ...)
        D:/gopath/src/github.com/metaverse/truss/gengokit/generator/gen.go:38 +0x1fd
main.generateCode(0xc00011a080, 0xc000547040, 0x0, 0x0, 0x0)
        D:/gopath/src/github.com/metaverse/truss/cmd/truss/main.go:293 +0x125
main.main()
        D:/gopath/src/github.com/metaverse/truss/cmd/truss/main.go:117 +0x1ab
zaquestion commented 2 years ago

@pubiu can you post a protofile that reproduces this?

luckyforme233 commented 2 years ago

@pubiu can you post a protofile that reproduces this?

package handlers

import (
    "core/example-service/hook"
    "core/example-service/svc"
    "fmt"
    "os"
    "os/signal"
    "syscall"
)
var (
    env        string // run environment
    configFile string
)

func init() {
    flag.StringVar(&env, "e", "local", "running environment")
    flag.StringVar(&configFile, "c", "", "config file")
}

func InterruptHandler(errc chan<- error) {
    c := make(chan os.Signal, 1)
    signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
    terminateError := fmt.Errorf("%s", <-c)

    // Place whatever shutdown handling you want here

    errc <- terminateError
}

func SetConfig(cfg svc.Config) svc.Config {
    return cfg
}

This code causes a running panic

zaquestion commented 2 years ago

@pubiu that's not the code causing the panic, it's something in ./proto/service.proto which seems to not be parsing correctly. Perhaps you figured it out and that's why you closed the ticket? Otherwise I'll need to .proto file to debug further.