Skip to content

Conversation

dolmen
Copy link
Collaborator

@dolmen dolmen commented Aug 25, 2025

Summary

Remove external dependency on module github.com/ernesto-jimenez/gogen by copying its package github.com/ernesto-jimenez/gogen/imports (MIT license) as _codegen/internal/imports.

Changes

  • copy github.com/ernesto-jimenez/gogen/imports/imports.go as _codegen/internal/imports/imports.go and add a license block to the file
  • update imports in _codegen/main.go and _codegen/go.mod.

Motivation

The removal of this external dependency (by duplicating its code) improves the control of our source code. It will also allow more refactoring of the codegen steps (in particular this now allow to remove the separate go module).

Cc: @ernesto-jimenez

dolmen added 2 commits August 25, 2025 15:12
Copy code from dependency github.com/ernesto-jimenez/gogen/imports
(which hasn't evolved since 2018) as package _codegen/internal/imports.

This is imported from https://github.com/ernesto-jimenez/gogen at commit
d7d4131e6607813977e78297a6060f360f056a97.
See https://github.com/ernesto-jimenez/gogen/tree/d7d4131e6607813977e78297a6060f360f056a97/imports

The license block is added to match the LICENSE file from the source
repository.
Use our imported copy of package
github.com/ernesto-jimenez/gogen/imports to remove one external
dependency.
@brackendawson
Copy link
Collaborator

This doesn't bring the commit history from source repo, just the files. Should we bring in a subtree instead, or do you think this is a better approach? I know the subtree has proven extremely difficult to re-base.

Copy link
Collaborator

@ccoVeille ccoVeille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

A few remarks anyway

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a README file aside this one mentioning where the code come from (its URL) and why it was imported (the reason)

Also I would add a LICENCE file instead of this header.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The imported code and testify are both MIT licenced, the MIT license of testify applying to the now embedded codegen package is quite correct.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, what about the README file then?

Copy link
Collaborator Author

@dolmen dolmen Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My aim is to get rid of the package and to replace the code from that package with code in _codegen/main.go.
The source URL is in the commit message and in this PR should be enough to document history.

I've assigned @ernesto-jimenez as a reviewer as he wrote that code and was also a maintainer of Testify, so his opinion is what matters the most to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No objections from my side :)

@dolmen
Copy link
Collaborator Author

dolmen commented Sep 2, 2025

@brackendawson wrote:

This doesn't bring the commit history from source repo, just the files.

I don't think we need the history for the file. My goal is to get rid of the code we don't need in that package, and may be ultimately move the few things we use into _codegen/main.go.

Also we don't need a test suite for that package: we just need the code generation to work with the minimum maintainable code, so the code generation output is the test suite.

@brackendawson
Copy link
Collaborator

Code is always more maintainable when it has tests. The code you've copied in verbatim had one test which you have not vendored. Why are we not bringing that too?

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

Successfully merging this pull request may close these issues.

4 participants