1

Ok I'm officially stumped. I've reviewed these 4 similar questions/answers:

go no required module provides package mux error

Could not import ... (no required module provides package)

Could not import local modules in Golang

VSCode: Could not import Golang package

...and they all basically repeat the same answer of running go mod init <name> and go mod tidy which I've done numerous times, same issue persists.

I do not have this package uploaded to a github repo, it's just stored locally on my Windows machine. I have run the commands:

go mod init go_backtest

go mod tidy

...and I am still seeing these all over the place:

issue1

what's interesting is there is NOT a red underline under the "go_backtest/strategies" line:

issue2

This is what the go.mod file looks like:

module go_backtest

go 1.19

I'm still a newbie to golang so be kind, but how can I get this thing to "compile" and run (and make those red underlines go away!)

windowshopr
  • 138
  • 7

1 Answers1

2

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

And the import statement is used to import a package instead of a file. So replace

"go_backtest/utils/dataFuncs"
"go_backtest/utils/ga"

with

"go_backtest/utils"
Zeke Lu
  • 6,349
  • 1
  • 17
  • 23
  • 1
    Thank you. I made sure all files in the `utils` folder were from package `utils`, then changed the imports in `main` to `"go_backtest/utils"` and then just used `utils.LoadData()` to call the methods. – windowshopr Apr 22 '23 at 21:14