当前位置:网站首页>Golang magic code
Golang magic code
2022-06-30 09:46:00 【Cloud man notes】
Fill in the title here
1. Golang magic code
Golang Some writing methods are quite “ Devil ” Of , Here is a record of .
1.1. Common data types can have methods
int Band method :
type testint int
func (ti testint) ToString() string {
return "test_int"
}
func main() {
a := testint(2)
fmt.Println(a.ToString())
}
1.2. Verify that a has been implemented interface All the ways
var _ sinkcommon.ISink = new(SinkInfluxDB)
type ISink interface {
GetInfo() *SinkInfo
LoadConfig(mConf map[string]interface{}) error
Write(pts []ISinkPoint) error
}
func (s *SinkInfluxDB) GetInfo() *sinkcommon.SinkInfo {
func (s *SinkInfluxDB) LoadConfig(mConf map[string]interface{}) error {
func (s *SinkInfluxDB) Write(pts []sinkcommon.ISinkPoint) error {
边栏推荐
猜你喜欢
随机推荐
Pipe pipe --namedpipe and anonymouspipe
Enum demo
GPT (improving language understanding generative pre training) paper notes
Pytorch for former Torch users - Tensors
Code management related issues
utlis 内存池 对象池
Tablet PC based ink handwriting recognition input method
11. customize hooks
Using OpenCV Net for image restoration
ABAP-时间函数
[Ubuntu redis installation]
Express file upload
Deep Learning with Pytorch - autograd
9.JNI_ Necessary optimization design
1, 基本配置
小程序开发踩坑之旅
Idea setting automatic package Guide
单片机 MCU 固件打包脚本软件
Challenge transform() 2D
直播带货源码开发中,如何降低直播中的延迟?









