package main import ( "fmt" "os" "encoding/pem" "crypto/x509" "github.com/alexflint/go-arg" ) func run(args *Arguments) error { raw, err := os.ReadFile(args.Input) if err != nil { return err } block, rest := pem.Decode(raw) fmt.Println(block.Type) fmt.Println("len(rest):", len(rest)) cert, err := x509.ParseCertificate(block.Bytes) if err != nil { return err } fmt.Println(cert) return nil } type Arguments struct { Input string `arg:"positional,required"` } func main() { args := &Arguments{} arg.MustParse(args) err := run(args) if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } }