Golang type type definition and assignment

type A string
type B []string
func main() {
    one := "string"
    two := []string{"string"}
    var a A
    var b B
    b = two 
    a = one   // cannot use one (type string) as type A in assignment
}

in the code above, it"s easy to understand that a=one is incorrect, thinking that An is already a new type
so why is b=two OK? How to understand?

Jul.07,2021

this thing can be regarded as a go trap, or you can call it a feature (/ laugh)

for slice type, as long as the underlying type is the same, it is considered to be the same type. You can replace B with type B [] A and try

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4473e-650cf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4473e-650cf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?