Skip to content

PANIC=Format method: runtime error: invalid memory address or nil pointer dereference with go 1.17 #77

@wallrj

Description

@wallrj

When I run the following short script with Go 1.17 it prints a PANIC=Format method message

package main

import (
	"github.com/kr/pretty"
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func main() {
	o := corev1.Secret{
		ObjectMeta: metav1.ObjectMeta{
			Name: "foo",
		},
	}
	pretty.Println(o)
}
$ go1.16.1 run ./
v1.Secret{
    TypeMeta:   v1.TypeMeta{},
    ObjectMeta: v1.ObjectMeta{
        Name:                       "foo",
        GenerateName:               "",
        Namespace:                  "",
        SelfLink:                   "",
        UID:                        "",
        ResourceVersion:            "",
        Generation:                 0,
        CreationTimestamp:          v1.Time{},
        DeletionTimestamp:          (*v1.Time)(nil),
        DeletionGracePeriodSeconds: (*int64)(nil),
        Labels:                     {},
        Annotations:                {},
        OwnerReferences:            nil,
        Finalizers:                 nil,
        ClusterName:                "",
        ManagedFields:              nil,
    },
    Immutable:  (*bool)(nil),
    Data:       {},
    StringData: {},
    Type:       "",
}
$ go1.17 run ./
v1.Secret{
%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions