Here you are confusing many basic things thing. Let me clear them on by one
- In golang custom types are treated as separate types even both are defined with the same built-in type
For example
type StringType1 string
type StringType2 string
var name1 StringType1="Umar"
var name2 StringType2="Hayat"
fmt.Println("StringType1 : ", name1)
fmt.Println("StringType2 : ", name2)
The output of the above code is https://play.golang.org/p/QDcaM1IolbJ
StringType1 : Umar
StringType2 : Hayat
Here we have two custom types StringType1
and StringType2 both are defined by
string`. But we can not assign a variable of these two types to each other directly until we convert them to the required type e.g
name1=name2
Output
cannot use name2 (type StringType2) as type StringType1 in assignment
Similar is the case with your code. You are converting a string
to a custom type without applying conversion.
- Second you are trying to convert a
string
to a byte array of fixed length 15 and type uint8
. This can be done as mentioned by @Cerise Limon
copy(account[:], c.Param("adress"))
But keep one thing here in mind you are copying string
to unit8
type so you should not expect characters in account
instead it will be ASCI values of that string character. I hope it will clear all your miss conceptions.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…