当前位置:网站首页>Golang magic code
Golang magic code
2022-06-30 09:32:00 【云满笔记】
1. Golang magic code
Golang 有些写法比较 “魔鬼” 的,这里记录一下。
1.1. 普通数据类型可以带方法
int 带方法:
type testint int
func (ti testint) ToString() string {
return "test_int"
}
func main() {
a := testint(2)
fmt.Println(a.ToString())
}
1.2. 验证是否已经实现某 interface 的所有方法
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 {
边栏推荐
- Esp32 (IX): OTA function of function development
- Use Huawei performance management service to configure the sampling rate on demand
- Talk about the job experience of kotlin cooperation process
- Deep Learning with Pytorch- neural network
- Mmdet line by line deltaxywhbboxcoder
- Rew acoustic test (IV): test principle of rew
- Raspberry pie 4B no screen installation system and networking using VNC wireless projection function
- Experience of an acmer
- Abstract factory pattern
- Invalid update: invalid number of sections. The number of sections contained in the table view after
猜你喜欢
Summary of Android knowledge points and common interview questions
4. use ibinder interface flexibly for short-range communication
Applet learning path 2 - event binding
Opencv learning notes-day6-7 (scroll bar operation demonstration is used to adjust image brightness and contrast, and createtrackbar() creates a scroll bar function)
Guilin robust medical acquired 100% equity of Guilin Latex to fill the blank of latex product line
Esp32 things (II): sharpening the knife without mistaking firewood - make preparations before project development
Opencv learning notes -day 11 (split() channel separation function and merge() channel merge function)
Deeply understand the working principle of kotlin collaboration suspend (beginners can also understand it)
Opencv learning notes -day8 (keyboard typing (waitkey()); Wait for typing) action: triggers some action when the appropriate character is typed using the keyboard)
Electron, which can wrap web page programs into desktop applications
随机推荐
I'm late for school
Pipe pipe --namedpipe and anonymouspipe
How do I start? (continuously updating)
ES6 learning path (III) deconstruction assignment
Esp32 (7): I2S and I2C drivers for function development
Esp32 (4): overview of the overall code architecture
9.JNI_ Necessary optimization design
5. Messager framework and imessager interface
Demo of guavacache
Esp32 things (VIII): music playing function of function development
Row column (vertical and horizontal table) conversion of SQL
Esp32 things (II): sharpening the knife without mistaking firewood - make preparations before project development
Find the number that appears only once in the array
POJ 1753 flip game (DFS 𞓜 bit operation)
Niuke IOI weekly competition 20 popularization group (problem solving)
ES6 learning road 5 symbol
Detailed explanation of pipline of mmdetection
Mmdet line by line deltaxywhbboxcoder
Sort (simple description)
[paid promotion] collection of frequently asked questions, FAQ of recommended list