There is a code
func ClearScreen(mode *int) string{ mode = defaultValue(mode, 2).(*int) return fmt.Sprintf("%s%dK", CSI, *mode) } func defaultValue(arg *T, value T) *T{ if arg == nil{ arg = new(T) *arg = value } return arg } The defaultValue function is not only used with the int data type, so I declared it to accept the T data type T interface{} ( type T interface{} ). I use pointers so that ClearScreen(nil) can do this (that is, use the default value for the mode argument)
If this can be implemented in a more obvious way, I will be glad if you can help. If this method is not bad, then how to modify it? Golang study not so long ago.
PS CSI - string constant