Skip to content

Generation not successful with custom type #57

@Raffo

Description

@Raffo

If I use the following service.go file:

package service

import "context"

type Cluster struct {
	Name string
	URL  string
}

// @microgen middleware, logging, main, http
type StringService interface {
	// @http-method GET
	ListCluster(ctx context.Context) (cluster []*Cluster, err error)
	CreateCluster(ctx context.Context, cluster *Cluster) (err error)
	GetCluster(ctx context.Context, name string) (cluster *Cluster, err error)
}

And generate the code with microgen service.go, I get code that doesn't compile:

go build . 
# test/foo/middleware
../../middleware/logging.go:27:69: undefined: Cluster
../../middleware/logging.go:38:68: undefined: Cluster
../../middleware/logging.go:49:79: undefined: Cluster
../../middleware/logging.go:63:14: undefined: Cluster
# test/foo/transport/converter/http
../../transport/converter/http/exchange_converters.go:64:2: req declared and not used

This is due to some changes that were done in the past, in particular Cluster is missing the right package. I wanted to fix those and actually it wouldn't be so complicated I guess, I could probably submit a PR. I wonder though how we can avoid this from happening again with an adequate test suite, like mentioned in #56 . Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions