#package is not in GOROOT

26 messages ยท Page 1 of 1 (latest)

slender lintel
#

hi guys, super easy question

I created a new project go mod init importer

No I created another dir for my package importer in there I have errors.go

in my main.go root I have the import "excel_importer/importer"

But it errors, I did basically try a lot but this it what is is

main.go:5:2: package excel_importer/importer is not in GOROOT (/opt/homebrew/Cellar/go/1.19.2/libexec/src/excel_importer/importer)

minor oak
#

you named the module importer not excel_importer

#

so the import is importer/importer

slender lintel
#

uff

#

that hurts

#

thanks dude ๐Ÿ˜„

#

I was playing around with excel_importer in the beginning but yes, make sense!

minor oak
#

if that post proves insufficient feel free to ask

slender lintel
#

i have a bunch of other errors

#

kinda annoying coming from another language ๐Ÿ˜„

#

importer.writeError(w, err)

now it says undefinied, tho I did importer "importer/importer"

and defined it in errors.go


func writeError(w http.ResponseWriter, err *CustomError) {
    w.Header().Set("Content-Type", "application/json")
    w.WriteHeader(err.Code)
    json.NewEncoder(w).Encode(err)
}```
minor oak
#

I would encourage you to do the go tour https://go.dev/tour/ it goes trough the basics of the language

#

one of which being that symbols that start with a lowercase character are not exported, and therefore not "importable"

slender lintel
#

Nah thats not really the way I learn, I did a basic tour now I am doing my own project

#

ok make sense, cheers!

minor oak
#

you are missing fundamental knowledge that the tour provides, it would be wise to take advantage of it

#

you can then really learn however you prefer

slender lintel
#

its running now, cheers ๐Ÿ™‚

#

will do the tour maybe now ๐Ÿ˜„

#

how long does it take?

minor oak
#

how much time do you have? ๐Ÿ™‚

slender lintel
#

๐Ÿ˜„

#

limited, you know the game

minor oak
#

The tour is not an extremely comprehensive resource, it is reasonably lean and can be done in a reasonably short amount of time
I would advise against speedrunning it, it will take as much time as you need it to take

slender lintel
#

alright