Thanks for the insights.

I still need to figure out how to tell the `Config` method of the
`go/types` package to look for imports at the right places. (which is
probably at `$(go env GOMODCACHE)`)

Am So., 23. Feb. 2025 um 04:13 Uhr schrieb Kurtis Rader <
kra...@skepticism.us>:

> That book was first published in 2015 -- ten years ago. Things have
> changed a lot since then. In particular, GOPATH mode is no longer the
> default and effectively a historical artifact having been replaced by Go
> module mode. In fact, Go modules were first introduced in Go 1.11 which was
> released in 2018 -- three years after that book was first published. When
> reading "how to" information, whether in a book or a blog post, you have to
> consider when the advice was published and whether it is old enough to
> still be relevant.
>
> I've never watched any videos by this person before but this video seems
> like a thoughtful, relatively recent, review of the book:
> https://www.youtube.com/watch?v=79R27PMKcY0. In particular at the 5:50
> minute mark they point out that the book doesn't talk about Go modules and
> GOPATH is no longer relevant.
>
> On Sat, Feb 22, 2025 at 4:52 PM Björn Försterling <
> bjoern.foersterl...@gmail.com> wrote:
>
>> Hello,
>>
>> according to "The Go Programming Lanuage" (Alan A. A. Donovan/Brian W.
>> Kernighan)
>> page 291 the "GOPATH" should have a subdirectory named "src".
>>
>> However that dir is not present on my system:
>>
>> $ ls $(go env GOPATH)
>> bin  pkg
>>
>> When doing a type check with the "go/types" package and the default
>> importer (importer.Default()) it will also search the imported package
>> inside GOPATH/src:
>>
>> could not import github.com/Code-Hex/Neo-cowsay/v2 (can't find import: "
>> github.com/Code-Hex/Neo-cowsay/v2": cannot find package "
>> github.com/Code-Hex/Neo-cowsay/v2" in any of:
>> /usr/lib/go/src/github.com/Code-Hex/Neo-cowsay/v2 (from $GOROOT)
>> /home/bf/go/src/github.com/Code-Hex/Neo-cowsay/v2 (from $GOPATH))
>>
>> I installed the external package with "go get ..." and I am able to build
>> the
>> module that uses the external package.
>>
>> Does anyone know how it can happen that $GOPATH/src does not exist?
>>
>> Regards
>> Bjoern
>>
>> --
>> 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 visit
>> https://groups.google.com/d/msgid/golang-nuts/96b1e8c0-a280-4f55-815d-acff4985fb96n%40googlegroups.com
>> <https://groups.google.com/d/msgid/golang-nuts/96b1e8c0-a280-4f55-815d-acff4985fb96n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>

-- 
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 visit 
https://groups.google.com/d/msgid/golang-nuts/CA%2BD_Ns90oBmC3kTvSX75x_S%3DstHHoDGMJO4DW9ggxPG0HYg1dQ%40mail.gmail.com.

Reply via email to