Interface
• Duck typing
• Method set
• Not Java like interface
• Flexible!
• Add method to struct
e.g. Interface
// Apply this to any type implementing Sortable
func Sort(data Sortable)
{
for i := 1; i < data.Len(); i++ {
for j := i; j > 0 && data.Less(j, j-1); j-- {
data.Swap(j, j-1);
}
}
}
Goroutine
• Lightweight process
• go keyword
• Concurrently
• Channel (CSP)
• Communication between goroutines
e.g. Goroutine
func main()
{
ch := make(chan int); // Create a new channel.
go generate(ch); // Start as a goroutine.
for {
// do something
// fmt.Print(<-ch);
}
}
e.g. Channel
// Send the sequence 2, 3, 4, ... to channel 'ch'.
func generate(ch chan int)
{
for i := 2; ; i++ {
ch <- i // Send 'i' to channel 'ch'.
}
}
Others
• Garbage Collected
• M&S, IBM’s Recycler in the future
• Windows support
• Patch welcome! but...
• Multiple values
• etc...
Earthquake Problem
Issue 9
is here to stay!
• Future works
• Performance, Libraries, Tools, etc...
• Go vs Go!
• Going : Go is not Go!
• Issue9
• http://issuenine.com/ :)
0 comments
Post a comment