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

contrib: Add Go multimod workspace setup script. #2904

Merged
merged 1 commit into from
Mar 29, 2022

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Mar 18, 2022

This adds a script to the contrib directory that initializes a Go multi-module workspace and adds all of the modules provided by the dcrd repository to it on an as needed basis. Note that workspaces require Go 1.18+.

This is useful when developing across multiple modules in the repository and allows development environments that make use of the Go language server (aka gopls), such as VSCode, to provide full support without also needing to temporarily create replacements in the various go.mod files or individually add every module.

Do note, however, that workspaces are local, so final submissions to the repository will still require the appropriate changes to the relevant go.mod files to ensure resolution outside of the workspace.

Finally, it also updates the README.md in the contrib directory accordingly.

@davecgh davecgh added this to the 1.8.0 milestone Mar 18, 2022
@chappjc
Copy link
Member

chappjc commented Mar 18, 2022

Looks good. One question - will replace statements in go.mod be a thing of the past once we drop support for go 1.17?

@chappjc
Copy link
Member

chappjc commented Mar 18, 2022

Would be be desirable to also add the cmd app modules to the workspace?

@davecgh
Copy link
Member Author

davecgh commented Mar 18, 2022

Looks good. One question - will replace statements in go.mod be a thing of the past once we drop support for go 1.17?

Perhaps in the main go.mod (and then CI would need to create the workspace to ensure the latest code is tested). However, any modules in development that rely on other unreleased modules will necessarily still need them if committed to the repository. That is mainly what I was referring to with the "Do note, however, that workspaces are local, so final submissions to the repository will still require the appropriate changes to the relevant go.mod files to ensure resolution outside of the workspace."

Would be be desirable to also add the cmd app modules to the workspace?

I'm not sure what you mean here. The apps under cmd aren't separate modules.

@chappjc
Copy link
Member

chappjc commented Mar 18, 2022

The apps under cmd aren't separate modules

Ah, whoops, I have a couple in dcrdata/cmd as their own modules. My mistake.

@davecgh davecgh force-pushed the contrib_go_multi_module_workspace branch from 10ad619 to 47c1d48 Compare March 29, 2022 17:02
Copy link
Member

@chappjc chappjc left a comment

Choose a reason for hiding this comment

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

Looks good. The script works. I've switched to go workspaces and gopls recently and it's great.

---------------------- contrib/dcr_setup_go_workspace.sh ----------------------
new file mode 100755
index 00000000..82131267

This adds a script to the contrib directory that initializes a Go
multi-module workspace and adds all of the modules provided by the dcrd
repository to it on an as needed basis.  Note that workspaces require Go
1.18+.

This is useful when developing across multiple modules in the repository
and allows development environments that make use of the Go language
server (aka gopls), such as VSCode, to provide full support without also
needing to temporarily create replacements in the various go.mod files
or individually add every module.

Do note, however, that workspaces are local, so final submissions to the
repository will still require the appropriate changes to the relevant
go.mod files to ensure resolution outside of the workspace.

Finally, it also updates the README.md in the contrib directory
accordingly.
@davecgh davecgh force-pushed the contrib_go_multi_module_workspace branch from 47c1d48 to cd1afb2 Compare March 29, 2022 17:07
@davecgh davecgh merged commit cd1afb2 into decred:master Mar 29, 2022
@davecgh davecgh deleted the contrib_go_multi_module_workspace branch March 29, 2022 17:19
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