Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean the code in my directory "expects" a particular import?

Tags:

go

A Go language tutorial uses the "quote" package to get familiar quotes. When I give the command "go get -v rsc.io/quote", I get the message

code in directory.../github/hello/src/rsc.io/quote/v3 expects import "rsc.io/quote"

So I went there and looked at the code. It has an import statement:

import "rsc.io/quote/v3"

So I thought maybe I had the wrong version of quote. Accordingly, I tried "go get -v rsc.io/quite/v3" THis produces the message:

code in directory .../rsc.io/quote/v3 expects import "rsc.io/quote."

This seems circular: asking without a version number produces a requirement for a versioned package, but trying to get a versioned package produces a requirement without a version number.

like image 218
Anna Naden Avatar asked Dec 22 '22 16:12

Anna Naden


1 Answers

If you continue the tutorial to the end you will see that the addition of a go module, and the subsequent initialisation, will resolve your issue. The .mod file will pull in the required dependencies.

like image 146
Martin Bennett Avatar answered May 06 '23 12:05

Martin Bennett