Java uses signed bytes, while Go uses unsigned bytes, but they are exactly the same in different representation (notice how 177 + 79 = 256, to give an example).
The questions are: what do you need to do with them and why is printed format important?
Java is doing well too, it only users a different representation. Go uses an uint8 for bytes, while Java uses int8 for them. See this example, it’ll show you they are the same (and also a way to print a byte the “java way” if you need to):
package main
import (
"fmt"
)
func main() {
var goByte byte = 177
var javaByte = int8(goByte)
fmt.Println(goByte)
fmt.Println(javaByte)
}
I want to do 3DES encrytion. I am using Go and the results differ from Java(actual code) becasue od different byte value. Is there a way I can get the same byte array in go as java ?
I’ll insist that they don’t differ, they are exactly the same array of bytes. But if you really, really need to represent them in the same way, just cast bytes to int8s as shown in my previous answer.