Golang---mixed notation easily

March 09, 2023 / Administrator / 21阅读 / 0评论/ 分类: GoLang

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

文章作者:Administrator

文章链接:http://localhost:8090//archives/golang---mixednotationeasily

版权声明:本博客所有文章除特别声明外,均采用CC BY-NC-SA 4.0 许可协议,转载请注明出处!


评论