Unable to import... (No required module provides package '.../utils/...')

WBOY
Release: 2024-02-12 17:15:12
forward
622 people have browsed it

Unable to import... (No required module provides package .../utils/...)

Question content

Okay, I’m officially stumped. I looked at these 4 similar questions/answers:

No required module provides packet muxer error

Cannot import... (no required module provides package)

Cannot import local modules in golang

vscode: Unable to import golang package

...they all basically duplicate the same answer of running go mod init <name></name> and go mod tidy, which I've done numerous times, same problem still exists.

I did not upload this package to a github repository, it was just stored locally on my windows computer. I have run the command:

go mod init go_backtest

go mod tidy

...I still see these everywhere:

What’s interesting is that "go_backtest/strategies" There is no red underline under the line:

This is what the go.mod file looks like:

module go_backtest

go 1.19
Copy after login

I'm still new to golang, so please be kind, but how can I get this thing to "compile" and run (and make those red underlines disappear!)

Workaround

# The files in the ##utils directory should belong to the same package utils. These files should have the package utils line at the beginning.

And the import statement is used to import packages instead of files. So replace

"go_backtest/utils/datafuncs"
"go_backtest/utils/ga"
Copy after login

and

"go_backtest/utils"
Copy after login

The above is the detailed content of Unable to import... (No required module provides package '.../utils/...'). For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!