Take these two bits of code: 1. http://play.golang.org/p/Oh6xNm2dRK 2. http://play.golang.org/p/Vd-6AGCBKQ
In 1. the media is first created as the empty interface and then type asserted to a string. In 2. the media is a string.
Both try to convert the media to a byte array, why the difference? Aren't they both strings by that time?
The first one doesn't change the type of media
, which is already defined as interface{}
. You need to set it to a new string variable, or do it inline:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.