Skip to content

cmd/go: relative replacements in a workspace are not resolved relative to their go.mod files #51204

Closed
@jezell

Description

@jezell

What version of Go are you using (go version)?

1.18beta2

Does this issue reproduce with the latest release?

What did you do?

Checkout the following repo:

https://github.com/jezell/gosync

run go work sync

What did you expect to see?

expect the command to complete successfully

What did you see instead?

go: conflicting replacements for example.com/test:
	../test
	../../test
use "go work edit -replace example.com/test=[override]" to resolve

Suggested Fix

It appears that when checking for replacement conflicts, go work sync does not resolve relative replacement paths. While this may work for flat workspaces, this causes problems when module replacements are used within sub folders. Perhaps go work sync should resolve relative paths to absolute paths before performing its check for conflicts so that when two replacements point to exactly the same place the command doesn't fail.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions