Zero Value For Type
int: 0
string: “”
bool: false
Slice: nil
Map: nil
struct: zero value 不是nil
nil is a predeclared identifier representing the zero value for a pointer, channel, func, interface, map, or slice type.
Type must be a pointer, channel, func, interface, map, or slice type
how declare type
type custom-name struct{
...field
}
type custom-name function(int,int)string
type custom-name interface{
...method
}
type custom-name int
function signature
Any function that has the exact same number and type of parameters meets the type signature.
fmt中的占位符
%d %s %v %T %w分别用于什么场景?
If you want to see the stack trace, use fmt.Printf and the verbose output verb (%+v)
If you want to create a new error and wrap the origin error ,use %w