【发布时间】:2020-05-21 00:17:20
【问题描述】:
我从pod.CreationTimeStamp 获取时间并尝试将其存储在变量中。我如何将时间存储到字符串中。
tmp := json_format{}
pods, _ := clientset.CoreV1().Pods(namespace).List(v1.ListOptions{LabelSelector:app_name})
for _, pod := range pods.Items {
tmp.Creation_Time = append(tmp.Creation_Time,pod.CreationTimestamp)
}
它给出了这个错误:cannot convert pod.ObjectMeta.CreationTimestamp (type "k8s.io/apimachinery/pkg/apis/meta/v1".Time) to type string
type json_format struct{
Creation_Time string
}
【问题讨论】:
标签: go kubernetes kubernetes-go-client