Weird behavior when go build'ing "local packages"

Hi, folks,

        I’m trying to use go mod with “local packages” (to my module). But I keep stumbling on some very weird behavior. I did some empirical debugs (to understand WTF is going on) and looked up on previous posts, but none was able to provide me a solution.
        So my initial idea was to call the package by importing go_packages_by_example/text/template so I’d be able to call the functions from template.go, but that didn’t quite work. Which led me to think that text/template was not being compiled in pkg directory or something like that. So I ran the go build inside the said package which gave me no compiled file. And then go install and text.a file was finally created, but I was still not able to import it correctly. That’s when I changed the import path to go_packages_by_example/text and it kind of imported, but now I have a whole new set of weird behavior. It imports the file as template, but I can’t call text.SomeFunction nor I can do text.template.SomeFuncion or even template.SomeFunction.
        Any ideas on how to tackle this? This should be straightforward. I know I am playing the noob here, but I did everything that I could with Go sources of information and random stack over flow hints. Zero on how to import a package from within a module. Sorry for the picture collage (they only allow 1 per new user :sob: ).

From to bottom

go env
go.mod
GOPATH vs running pwd
project structure
piece of code
go build from within the project error
go mod tidy error
go build from with src/ error
weird import error

P.S. I’m pretty sure I’m missing a picture.

A bit of smoking, food and coke showed me where I was noobing. :joy:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.