Go.mod / go.work woes

I fail to satisfy my module requirements, and don’t understand why…

ch14> egrep '^(import|\))|github.com' neural.go
import (
ch14> go mod init neural
go: creating new go.mod: module neural
go: to add module requirements and sums:
	go mod tidy
ch14> go mod tidy
neural imports
	github.com/tensorflow/tensorflow/tensorflow/go imports
	github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto: module github.com/tensorflow/tensorflow@latest found (v2.9.1+incompatible), but does not contain package github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto
ch14> cat go.mod
module neural

go 1.18

I left one line from the tidy output, although I believe it is not directly relevant (yet).
I add manually to go.mod (I did the go get previously):

require (
	github.com/goml/gobrain v0.0.0-20201212123421-2e2d98ca8249

I have in go.work:

go 1.18

use ../../github.com/goml/gobrain
replace github.com/goml/gobrain v0.0.0-20201212123421-2e2d98ca8249 => ../../github.com/goml/gobrain


ch14> go run neural.go 
neural.go:8:2: module github.com/goml/gobrain provides package github.com/goml/gobrain and is replaced but not required; to add it:
	go get github.com/goml/gobrain@v0.0.0-20201212123421-2e2d98ca8249

This is what I don’t understand: not required? How come not required?
Just to confirm it is provided:

ch14> egrep --include=*.go -r ^package ../../github.com/goml/gobrain
../../github.com/goml/gobrain/util.go:package gobrain
../../github.com/goml/gobrain/persist/persist.go:package persist
../../github.com/goml/gobrain/persist/persist_test.go:package persist
../../github.com/goml/gobrain/feedforward.go:package gobrain
../../github.com/goml/gobrain/feedforward_test.go:package gobrain

At least, the import failures in go mod tidy output were the cause of the truncation of go.mod…
Moving away the unrelated go sources (other topic in the same chapter) fixed it.

And it fixed the whole problem.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.