other-languages

2023-07-05T22:45:28.134219Z

Can someone help with something that should be simple in golang, but I can't find good information on this at all. I have a go project. It's accumulating multiple files, so I dont want all my .go files in one folder. So if I have the following

src/main.go
src/Foo/foo.go
src/Foo/quax.go
src/Bar/bar.go
How can I reference foo.go from main.go ? I've tried go mod init in Foo folder, but then I can't reference that module from main.go I get the error could not import module ... not required module provides package I don't want those sub folders to be independent packages, the .go files in them don't make any sense whatsoever outside this project. I purely want to just tidy it up. I dont get why this isn't really simple ? You can't even do anything like
import (
   "\Foo\foo.go"
)
or
import (
   "\Foo"
)
That's an invalid import path...

2023-07-05T22:48:59.077919Z

All the examples I'm seeing online are referencing github repos. What if I want to structure it with folders but not put it on a repo on github (or any source control at all) ? Surely referencing files can't be tied to VCS in any way whatsoever.

2023-07-05T23:05:13.973789Z

Tried using go work, but I can't get that to work either.

2023-07-06T20:05:16.153489Z

argh, I've no idea what I'm doing wrong. On this project when I try to mimic what they've done above in your link, I still get main.go:5:2 package vm/vm.go is not in GOROOT (/usr/local/go/src/vm/vm.go) I don't know why it wants that path. My source is in ~/Source/exfnlang not the folder its moaning about.

2023-07-06T20:07:04.746849Z

and vs code moans about the import with the error could not import vm/vm.go (no required module provides package "vm/vm.go")

2023-07-06T20:10:40.074999Z

got it finally!

👍 1