More idiomatic way in Go to encode a []byte slice int an int64?

Viewed 4876

Is there a better or more idiomatic way in Go to encode a []byte slice into an int64?

package main

import "fmt"

func main() {
    var mySlice = []byte{244, 244, 244, 244, 244, 244, 244, 244}
    var data int64
    for i := 0; i < 8; i++ {
                data |= int64(mySlice[i] & byte(255)) << uint((8*8)-((i+1)*8))
    }
    fmt.Println(data)
}

http://play.golang.org/p/VjaqeFkgBX

2 Answers
Related