You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using implicit tags, Marshal/Unmarshal provide a number of struct field tags that allow forcing specific encodings to be used for confusable types.
Marshal supports a larger set of these tags than Unmarshal, causing some data to be impossible to roundtrip.
package main
import (
"encoding/asn1"
"fmt"
"time"
)
func main() {
out, err := asn1.MarshalWithParams(time.Now(), "tag:2,generalized")
if err != nil {
fmt.Printf("failed to marshal: %v\n", err)
}
fmt.Printf("out: %x\n", out)
var t time.Time
_, err = asn1.UnmarshalWithParams(out, &t, "tag:2,generalized")
if err != nil {
fmt.Printf("failed to unmarshal: %v\n", err)
}
fmt.Printf("time: %v\n", t)
}
Unmarshal should support the same set of field tags.
The text was updated successfully, but these errors were encountered:
When using implicit tags, Marshal/Unmarshal provide a number of struct field tags that allow forcing specific encodings to be used for confusable types.
Marshal supports a larger set of these tags than Unmarshal, causing some data to be impossible to roundtrip.
Unmarshal should support the same set of field tags.
The text was updated successfully, but these errors were encountered: