Created
May 23, 2010 01:45
-
-
Save EmielM/410556 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ("log") | |
type Test struct { | |
a []byte | |
} | |
/*func (t *Test) Push(v byte) *Test { | |
n := len(t.a) | |
t.a = t.a[0:n+1] | |
t.a[n] = v | |
return t | |
} | |
func (t *Test) Clear() *Test { | |
t.a = t.a[0:0] | |
return t | |
}*/ | |
func (t *Test) Len() int { | |
return len(t.a) | |
} | |
type Iface interface { | |
//Push(byte) *Test | |
//Clear() *Test | |
Len() int | |
//X() | |
} | |
func main() { | |
var t Iface = &(Test{make([]byte, 0, 10)}) | |
//t.Clear().Push(byte(t.Len()+3)) | |
log.Stdoutf("arr = %s", t.(Test).a) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
emiel-macbook:Temp emiel$ 8g test-chain.go; 8l test-chain.8 | |
test-chain.go:35: Iface cannot contain Test | |
missing Len() int | |
??none??: cannot open file: test-chain.8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment