go语言中iota的一个例子

https://segmentfault.com/a/ package main import ( "fmt" ) type BitFlag int const ( // iota为0,1左移0位 = 1 Active BitFlag = 1 << iota // Send <=> Active <=> 1 << iota,此时iota为1,1左移1位 = 2 Send // Receive <=> Send <=> 1 << i

go模仿JAVA面向接口_链式编程

https://segmentfault.com/a/ Test.go package test func NewTest() ITestIntf { return &test{""} } type ITestIntf interface { GetName() string SetName(string) ITestIntf } type test struct { name string } func (t *test) GetName() string { return (*t).name } func (t *test) SetName(n string) ITestIntf { (*t).name =n return t } SubTest.go package test func NewSubTest() ISubTestIntf { return &subTest{NewTest(), "", 0} } type ISubTestIntf interface { ITestIntf GetSex() string SetSex(string) ISubTestIntf GetAge()