goimports-reviser can operate only on files in a Go module, but Go workspaces allow one to write files outside of modules and use the dependencies listed in the module.
To reproduce:
mkdir analysis lib
cat >analysis/main.go <<EOF
package main
import "example.com/hello"
func main() {
println(hello.Hello("you"))
}
EOF
cat >go.work <<EOF
go 1.22.2
use ./lib
EOF
cat >lib/lib.go <<EOF
package hello
func Hello(who string) string {
return "Hello " + who + "!"
}
EOF
cat >lib/go.mod <<EOF
module example.com/hello
go 1.22.1
EOF
# To run the main program:
# go run analysis/main.go
# Revise imports:
goimports-reviser analysis/main.go
Result:
open go.mod: no such file or directory
Usage of .../goimports-reviser:
...
goimports-reviser
can operate only on files in a Go module, but Go workspaces allow one to write files outside of modules and use the dependencies listed in the module.To reproduce:
Result: