Nope.  I didn't solve it.  The code compiles because of GO111MODULE=auto and I did not notice that when I posted yesterday.  The code does not compile when GO111MODULE=on

The simple instructions that I suggest be added to the documentation would benefit from having a section called

"Common error messages and how to fix them"

One of these errors that the documentation would be improved by addressing would be

    package packagename is not in GOROOT (usr/local/go/src/packagename)


Another could be

     go: cannot find main module, but found .git/config in /home/name/go/src

     to create a module there run

     go mod init


When I try "go mod init" in my /home/rob/go/src, I get an error

go: cannot determine module path for source directory /home/rob/go/src (outside GOPATH, module path must be specified)


How do I specify my local code?


The documentation is weak in these areas.


-----------------------------------------------------

I solved my issue by restarting the terminal program.  The code now compiles.  And I also tested on Win10 and go 1.16.


I'm glad I asked my question, because nothing I read said that all I had to do to use modules is to go into each code directory I use and

   go mod init <module-name>


Perhaps that simple instruction could be added to the documentation?

It would help complete idiots (or dummies) like me.

--rob solomon


---------------------------------------------------
Now I have a curious problem.  Most of the code I've written is compiling.  I'm using go 1.15.8 under ubuntu.  I did

    I'm logged into ~/go/src

    export GO111MODULE=on

    cd multack            This is my code

    go mod init multack

    cd ..

    Now I'm back in ~/go/src

    go install multack

I get an error saying that "package multack is not in GOROOT (usr/local/go/src/multack)"

If I do

    go run multack/multack.go

That works.

What does this error message mean?

Thanks again.

--rob solomon



--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ebbeb4a6-26ef-2e97-0613-138e0def4120%40fastmail.com.

Reply via email to