How to convert [4]uint8 into uint32 in Go?

前端 未结 2 530
清酒与你
清酒与你 2021-02-14 08:06

how to convert go\'s type from uint8 to unit32?
Just code:

package main

import (
    \"fmt\"
)

func main() {
    uInt8 := []uint8{0,1,2,3}
    var uInt32          


        
2条回答
  •  再見小時候
    2021-02-14 08:10

    Are you trying to the following?

    t := []int{1, 2, 3, 4}
    s := make([]interface{}, len(t))
    for i, v := range t {
        s[i] = v
    }
    

提交回复
热议问题