I have a custom AUTH package and there i have USER STRUCT.
So i want to import the auth package in my go project and override the struct or add new fields to the struct without modifying the package code.
package auth
type User struct {
gorm.Model
UserEmail string
UserPass string
}
Now i have main.go
package main
import "auth"
// WANT TO OVERRIDE OR EXTEND THE USER STRUCT
auth.User = {
UserAge string
}
function main() {
}
you can define a new type like this:
type NewUser struct {
auth.User
UserAge string
}
So i want to import the auth package in my go project and override the struct or add new fields to the struct without modifying the package code.
You simply cannot do this in Go. You have to redesign.