skip to Main Content

My system is WSL 2 in Windows 10.

 OS: Debian 10 buster
 Kernel: x86_64 Linux 4.19.104-microsoft-standard
 Shell: zsh 5.7.1
 CPU: AMD Ryzen 9 4900HS with Radeon Graphics @ 16x 2.994GHz

Golang info:

go version go1.15.2 linux/amd64
GOROOT="/usr/local/go"
GOPATH="/mnt/c/workspace/6.824"

And I met a problem when I build a project by plugin model:

$ go build -buildmode=plugin ../mrapps/wc.go
build command-line-arguments: cannot find module for path _/mnt/c/workspace/6.824/src/mr

It is so strange that "_/mnt"

How can I solve it?
Why has a "_" before the path?

Help me, please.

2

Answers


  1. I would try and use go mod instead of relying on GOPATH

    unset GOPATH
    cd /mnt/c/workspace/6.824/
    go mod init "yourProject"
    go build -buildmode=plugin mrapps/wc.go
    
    Login or Signup to reply.
  2. You are using go mod. And you can try the following command to fix:

    cd 6.824
    go mod init "6.824-golabs-2020" 
    # change file src/mrapps/wc.go line9 to `import "6.824-golabs-2020/src/mr"`
    cd src
    go build -buildmode=plugin mrapps/wc.go
    

    More details about mod you can refer to https://golang.org/ref/mod

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search