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

Generating in the same namespace. #100

Closed
3 tasks done
ryan961 opened this issue Nov 9, 2023 · 3 comments
Closed
3 tasks done

Generating in the same namespace. #100

ryan961 opened this issue Nov 9, 2023 · 3 comments
Labels
question Further information is requested

Comments

@ryan961
Copy link

ryan961 commented Nov 9, 2023

Have you read the project readme?

  • Yes, but it does not include related information regarding my question.
  • Yes, but the steps described do not work.
  • Yes, but I am having difficulty understanding it and want clarification.

Describe your question
Hello, may I ask how should goverter (v1.1.0) be configured under the same directory level? I'm still getting the import cycle not allowed error after configuring like below:

converter.go

package data

import (
	"time"

	"example/internal/biz"
)

type (
	// goverter:converter
	// goverter:output:file ./converter_gen.go
	// goverter:output:package :data
	// goverter:ignoreMissing
	// goverter:extend TimeToTime
	Converter interface {
		ConvertUser(*User) *biz.UserInfo
	}
)
...
➜  goverter gen ./internal/data

converter_gen.go

// Code generated by github.com/jmattheis/goverter, DO NOT EDIT.

package data

import (
	biz "example/internal/biz"
	data "example/internal/data"
)

type ConverterImpl struct{}

func (c *ConverterImpl) ConvertBizUserInfo(source *biz.UserInfo) *data.User {
......

data "example/internal/data" is redundant.

I looked up the issues, but they all seem out of date.

@ryan961 ryan961 added the question Further information is requested label Nov 9, 2023
@jmattheis
Copy link
Owner

Configure the full output package instead of only the package name (:data). https://goverter.jmattheis.de/#/config/output?id=outputpackage-package

@ryan961
Copy link
Author

ryan961 commented Nov 9, 2023

Thank you for reply. It is OK after just trying :)

package data

import (
	"time"

	"example/internal/biz"
)

type (
	// goverter:converter
	// goverter:output:file ./converter_gen.go
	// goverter:output:package example/internal/data:data
	// goverter:ignoreMissing
	// goverter:extend TimeToTime
	Converter interface {
		ConvertUser(*User) *biz.UserInfo
	}
)
...

@jmattheis
Copy link
Owner

jmattheis commented Nov 9, 2023

Awesome, I've added an FAQ to the website including this question: https://goverter.jmattheis.de/faq

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

No branches or pull requests

2 participants