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

feat: add jmattheis/goverter #8786

Merged
merged 1 commit into from Dec 29, 2022
Merged

feat: add jmattheis/goverter #8786

merged 1 commit into from Dec 29, 2022

Conversation

s-takehana
Copy link
Contributor

@s-takehana s-takehana commented Dec 29, 2022

jmattheis/goverter: Generate type-safe Go converters by simply defining an interface

$ aqua g -i jmattheis/goverter

How to confirm if this package works well

Reviewers aren't necessarily familiar with this package, so please describe how to confirm if this package works well. Please confirm if this package works well yourself as much as possible.

Command and output

Require Go

$ go mod init example
$ goverter example

Confirm output file ./generated/generated.go

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

package generated

import example "example"

type ConverterImpl struct{}

func (c *ConverterImpl) Convert(source []example.Input) []example.Output {
	exampleOutputList := make([]example.Output, len(source))
	for i := 0; i < len(source); i++ {
		exampleOutputList[i] = c.exampleInputToExampleOutput(source[i])
	}
	return exampleOutputList
}
func (c *ConverterImpl) exampleInputToExampleOutput(source example.Input) example.Output {
	var exampleOutput example.Output
	exampleOutput.Name = source.Name
	exampleOutput.Age = source.Age
	return exampleOutput
}

If files such as configuration file are needed, please share them.

input.go

package example

// goverter:converter
type Converter interface {
	Convert(source []Input) []Output
}

type Input struct {
	Name string
	Age  int
}
type Output struct {
	Name string
	Age  int
}

Reference

[jmattheis/goverter](https://github.com/jmattheis/goverter): Generate type-safe Go converters by simply defining an interface

```console
$ aqua g -i jmattheis/goverter
```

## How to confirm if this package works well

Reviewers aren't necessarily familiar with this package, so please describe how to confirm if this package works well.
Please confirm if this package works well yourself as much as possible.

Command and output

```console
$
```

If files such as configuration file are needed, please share them.

```
```

Reference

-
@s-takehana s-takehana marked this pull request as ready for review December 29, 2022 12:08
@s-takehana
Copy link
Contributor Author

Please review.

@suzuki-shunsuke suzuki-shunsuke added the enhancement New feature or request label Dec 29, 2022
@suzuki-shunsuke suzuki-shunsuke added this to the v3.112.1 milestone Dec 29, 2022
@suzuki-shunsuke
Copy link
Member

Thanks!

@suzuki-shunsuke suzuki-shunsuke merged commit 0cacdaf into aquaproj:main Dec 29, 2022
@s-takehana s-takehana deleted the feat/jmattheis/goverter branch December 29, 2022 12:19
@suzuki-shunsuke
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants