Monday, April 22, 2024
HomeGolangCasting to struct in exterior Module - Getting Assist

Casting to struct in exterior Module – Getting Assist


I’m making an attempt to solid a struct in my bundle to a different in an exterior module

In my bundle I created

sort Userinfo struct {
    username    string
    password    string
    passwordSet bool
}

which is an identical to “internet/url” Userinfo
although when I attempt to solid from one to the opposite like this:

ui := Userinfo{"myusername", "password", true}
url.Userinfo(ui)

I get

can not convert ui (variable of sort Userinfo) to sort "internet/url".Userinfo

Why can’t I solid to the opposite struct although they’re utterly an identical?
If that is typically not attainable, is there some hack to take action, I have to convert to the opposite for compatibility causes?

(After all I additionally imported “internet/url” in my bundle)

Thanks!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments