question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support Go 1.18 workspaces

See original GitHub issue

NX-GO : Support Go 1.18 workspaces

Go 1.18 introduces Go workspaces, a clean and nice way to manage a repository that contains multiple modules written in go. It works by adding a go.wok file in the root directory and add a go.mod file in each go module.

To adapt this solution to nx-go, we need to be able to manage versions before 1.18 (without the go.work files) and the next versions.

It can be also nice to add an utility to upgrade the current workspaces to th new module management system.

App & libs creation

When creating apps and libs we have now 4 use cases. (The first match skip the followings)

  • A go.mod file is in the root directory: the new package is created as before.
  • A go.work file is in the root directory: the package is created with its own go.mod file in its directory and it is added in the use list in the go.work file.
  • The option “useWorkspace” is added in the command line the go version is checked, if it is before 1.18 an error is thrown otherwise, a go.work file is added in the root directory.
  • Same behavior as before 1.18

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
phillipCoutocommented, Oct 16, 2022

Hi! Could you be so kind to explain how to get go workspaces working with nx?

From my understading, I should just initialize the workspace in the root directory of the nx project, is this correct?

The current stable version does not yet support it out of the box. As this issue is adding the functionality in question. There is a release candidates for 2.7.0 with support for workspaces though which you can evaluate.

@Anthony-Jhoiro may be better to answer how to use workspaces with 2.7.0 as I have been MIA for a few months and just getting caught up again.

0reactions
phillipCoutocommented, Oct 16, 2022

Hello @phillipCouto !

Thank you for your answer. I had the same question, I’m just getting started with nx, and I am not sure if adding a goScope property in the nx.json is a good practice. The behavior could be :

If the property is set, then the module import path will be the concatenation of the goScope property and the module relative path. Otherwise, the module import path will be the relative path of the module.

What do you think about this?

Sounds good to me! Really sorry for the late reply. I need to review my Github notification settings!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get familiar with workspaces - The Go Programming Language
Workspaces in Go 1.18 let you work on multiple modules simultaneously ... Workspaces are flexible and support a variety of workflows.
Read more >
Support for go 1.18 "workspace" mode? · Issue #1232 - GitHub
Has anyone put any thought into gazelle support the new "workspace" mode added in go 1.18? Some reference links: Docs: https://go.dev/ref/mod# ...
Read more >
Workspaces in Go 1.18 - zerokspot.com - Horst Gutmann
Let's say you have two packages: producer and consumer . You want to implement a great new feature in consumer but you need...
Read more >
Go 1.18 Release Notes - The Go Programming Language
The go command now supports a "Workspace" mode. If a go.work file is found in the working directory or a parent directory, or...
Read more >
Setting up your workspace
Starting with Go 1.18, the go command has native support for multi-module workspaces, via go.work files. These files are recognized by gopls starting...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found