golang interface{} 类型转换

package main

import (
    "fmt"
    "strconv"
)

var articleId interface{}
func main() {
        articleId = 12.0
        switch articleId.(type) {
        case string:
            fmt.Println("string ***", articleId)
        case float64:
            fmt.Println("float64****", strconv.FormatFloat(articleId.(float64), 'f', -1, 64))
        case []byte:
        fmt.Println("[]byte****", string(articleId.([]byte)))
    }
}

你可能感兴趣的:(golang interface{} 类型转换)