# Test that -modfile=path/to/go.mod is rejected in workspace mode.

! go list -m -modfile=./a/go.alt.mod
stderr 'go: -modfile cannot be used in workspace mode'

env GOFLAGS=-modfile=./a/go.alt.mod
! go list -m
stderr 'go: -modfile cannot be used in workspace mode'

-- go.work --
go 1.20

use (
    ./a
)

-- a/go.mod --
module example.com/foo

go 1.20

-- a/go.alt.mod --
module example.com/foo

go 1.20

-- a/main.go --
package main

import "fmt"

func main() {
	fmt.Println("Hello world!")
}
