Can someone help me with some GoLang that’s probably a really simple fix but I’m still new to the language ? I’m trying to write a function that returns a pointer to a users account as I need to do that in several different places in my code but I’m getting a “IncompatibleAssign” error on the line where I try to return account. It seems to happen because *api.Account is in a different package to my code; api vs main ?
func GetAccountInfo(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userId string) (*api.Account, error) {
account, err := nk.AccountGetId(ctx, userId)
if err != nil {
return nil, runtime.NewError("could not get user's account info", 13)
}
return account, nil
}
Can you double-check your import statements and ensure you’re using the correct package name, and that there isn’t any package aliasing causing a conflict? The api import should come from github.com/heroiclabs/nakama-common/api.
I can see that the import path needs changing to “github.com/heroiclabs/nakama-common/api” but when I change it and save the file, Visual Code changes it back. Even if I completely delete that entire “digitalsmoke.us/backend…” file and save it, the editor automatically puts it back in. Any idea why ?
Okay I think I’ve fixed it by deleting my local “vendor” folder which allowed me to change the offending line and then I did a “go mod vendor” again. Thanks for pointing me in the right direction.