Avatar ·

Error "Import cycle not allowed" in Go: how to fix circular package imports

Hello everyone! I just started learning Go and already encountered a problem that I can't solve on my own. I have two packages: `auth` and `user`. In the `auth` package, I want to use the `GetUserByID` function from the `user` package to check if a user exists. And in the `user` package, I need to call the `CheckPermission` function from the `auth` package to check access rights when creating a new user. Here's what my files look like: // auth/auth.go package auth import "project/user" func Login(userID int) bool { user := user.GetUserByID(userID) return user != nil } // user/user.go package user import "project/auth" type User struct { ID int Name string } func CreateUser(name string) *User { if !auth.CheckPermission("admin") { re