GO language judges whether a type (object) method exists

if wt, ok := src.(WriterTo); ok {
	return wt.WriteTo(dst)
}

This is a source code snippet taken from the go standard package to determine whether a type (object) has a specified method.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325339529&siteId=291194637
Recommended