在golang中打印结构体

发布时间:2018-04-06 21:51:10
Go 

正文

package main

import "fmt"

type Student struct {
	Name string
	Age  int
}

func main() {
	var student Student
	fmt.Printf("%v\n", student)
	fmt.Printf("%+v\n", student)
	fmt.Printf("%#v\n", student)
}

输出

{ 0}
{Name: Age:0}
main.Student{Name:"", Age:0}

参考

原文地址:http://zhyoulun.com/post/print-strcut-in-golang
转载请注明出处