package main
import (
"encoding/asn1"
"fmt"
)
type SimpleStruct struct {
Value int
}
func main() {
berBytes := []byte{0x02, 0x01, 0x05}
var simpleStruct SimpleStruct
_, err := asn1.Unmarshal(berBytes, &simpleStruct)
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Printf("Decoded value: %d\n", simpleStruct.Value)
}
I was trying to unmarshal but getting below error:
Error: asn1: structure error: tags don't match (16 vs {class:0 tag:2 length:1 isCompound:false}) {optional:false explicit:false application:false private:false defaultValue: tag: stringType:0 timeType:0 set:false omitEmpty:false} SimpleStruct @2
Could someone please help? Thanks