dianesis
dianesis

Reputation: 332

Cannot build github.com/jonpchin/gochess - "working directory is not part of a module"

I unwrapped the project and from that project i did go get. Then I received the following errors.

C:\Users\Downloads\gochess-master>go install main.go
main.go:14:2: no required module provides package github.com/dchest/captcha: working directory is not part of a module 
main.go:15:2: no required module provides package github.com/go-sql-driver/mysql: working directory is not part of a module 
main.go:17:2: no required module provides package github.com/jonpchin/gochess/goforum: working directory is not part of a module 
main.go:18:2: no required module provides package github.com/jonpchin/gochess/gostuff: working directory is not part of a module 
main.go:20:2: no required module provides package golang.org/x/net/websocket: working directory is not part of a module

Then I went and tried doing go get each of the packages. I try doing the go install main.go and got same error.

then I tried including the repo inside $GOPATH/src/github.com/jonpchin/gochess and tried doing go get from there. I got the same errors.

Upvotes: 2

Views: 1118

Answers (1)

Brits
Brits

Reputation: 18345

github.com/jonpchin/gochess is a couple of years old and has not been updated to use go modules. I suspect you are using Go 1.16 under which "Module-aware mode is enabled by default, regardless of whether a go.mod file is present in the current working directory or a parent directory". There are a few ways to address this but given that there is a plan to "drop support for GOPATH mode in Go 1.17" the simplest approach might be to download the code and setup modules yourself. The following process works for me (well I get prompted for a mysql password):

git clone https://github.com/jonpchin/gochess
cd gochess
go mod init github.com/jonpchin/gochess
go get
go build
.\gochess.exe

Upvotes: 3

Related Questions