The code you posted does not actually contain the string `api.PetStore`, so
it seems to be incomplete. From extrapolation, I agree that it should work,
so the issue must be in that incomplete part.

On Mon, Sep 11, 2023 at 11:23 PM Tong Sun <suntong...@gmail.com> wrote:

> This is really a go module 101 question, as I'm trying to understand and
> solve the *undefined types* problem that I'm having.
>
> I have:
>
> $ head -1 go.mod
> module backend
>
>
> And in my internal/petstore/main.go file, I have:
>
> package main
>
> import api "backend/internal/petstore/interfaces/ports"
>
> func main() {
> petStore := api.NewPetStore()
> }
>
>
> And in my internal/petstore/interfaces/ports/type.go file, I have:
>
> package api
> type PetStore struct {...}
>
>
> I think it should compile, but I'm getting:
>
> $ go run internal/petstore/main.go
> # command-line-arguments
> internal/petstore/main.go:..:38: undefined: api.PetStore
>
>
> and I have no idea how to fix it.
>
> I also tried to build the whole project with `go build .`, but got
>
> no Go files in <my project root folder>
>
> Please help. thx.
>
> --
> 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/ee028af4-3de2-468c-9ef2-48d8a2ac24cbn%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/ee028af4-3de2-468c-9ef2-48d8a2ac24cbn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAEkBMfFfguq3H6dVUDskxgrngoQU5xUFcYRqQS3sB2Do4fNKSw%40mail.gmail.com.

Reply via email to